HWright9 / TunerStudioOS

Arduino Operating System to Connect to Tuner Studio
GNU General Public License v3.0
9 stars 3 forks source link

Arduino NANO . #2

Closed Ms3pro closed 1 year ago

Ms3pro commented 1 year ago

Hi! Can I add Arduino NANO support ?

Ms3pro commented 1 year ago

It turned out to be easy for me, and now there is nano support. The studio tuner loses connection periodically, loses connection every few seconds, then turns on again. For nano, you need to reduce the speed of the serial port to 57600.

HWright9 commented 1 year ago

Hi, This is a little odd becuase the Nano and the Uno use the same microcontroller. I don't know why the Nano would need a slower serial data rate. When i tested with an Uno I had no issues. I guess a slower baud rate would help with any electrical noise but not sure why you are having that problem in the first place. Were there any other code changes you had to make to compile for the Nano?

Ms3pro commented 1 year ago

Maybe it 's really electro noise . In the code , I just added nano wherever there is a choice of boards .

if defined(ARDUINO_AVR_MEGA2560)

HardwareSerial &AUX_SERIALLink = Serial3; // setup which serial port connects to the speeduino secondary serial
HardwareSerial &TS_SERIALLink  = Serial;   // setup which serial port connects to TS

elif defined (ARDUINO_AVR_NANO)

HardwareSerial &AUX_SERIALLink = Serial; // setup which serial port connects to the speeduino secondary serial
HardwareSerial &TS_SERIALLink  = Serial;   // setup which serial port connects to TS

elif defined (ARDUINO_AVR_UNO)

HardwareSerial &AUX_SERIALLink = Serial; // setup which serial port connects to the speeduino secondary serial
HardwareSerial &TS_SERIALLink  = Serial;   // setup which serial port connects to TS

else

#error Incorrect board selected. Currently AVR Mega2560 and NANO and UNO supported. Please select the correct board and upload again

endif

ifndef GLOBALS_H

define GLOBALS_H

if defined(ARDUINO_ARCH_AVR)

define CORE_AVR

define AVR_WDT

elif defined(CORE_TEENSY)

define BOARD_NR_GPIO_PINS 34

define EEPROM_SIZE_8KB

elif defined(STM32_MCU_SERIES) || defined(_VARIANT_ARDUINOSTM32)

define CORE_STM32

define EEPROM_SIZE_8KB

extern "C" char* sbrk(int incr); //Used by UTIL_freeRam inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet)

define portOutputRegister(port) (volatile byte )( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte value

define portInputRegister(port) (volatile byte )( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte value

else

error Incorrect board selected. Currently AVR Mega2560 and NANO supported. Please select the correct board and upload again

endif

// now set specific processor compile flags

if defined(AVR_ATmega1280) || defined(ARDUINO_AVR_MEGA2560) || defined(AVR_ATmega2561)

define EEPROM_SIZE_8KB

define MEGA_AVR

define BOARD_NR_GPIO_PINS 54

define BOARD_MAX_IO_PINS 58 //digital pins + analog channels + 1

define BOARD_MAX_DIGITAL_PINS 52

define BOARD_MAX_ADC_PINS 15

elif defined(ARDUINO_AVR_NANO)

define BOARD_NR_GPIO_PINS 19

define BOARD_MAX_IO_PINS 20 //digital pins + analog channels + 1

define BOARD_MAX_DIGITAL_PINS 13

define BOARD_MAX_ADC_PINS 6

elif defined(ARDUINO_AVR_UNO)

define BOARD_NR_GPIO_PINS 19

define BOARD_MAX_IO_PINS 20 //digital pins + analog channels + 1

define BOARD_MAX_DIGITAL_PINS 13

define BOARD_MAX_ADC_PINS 6

else

error Incorrect board selected. Currently AVR Mega2560 and NANO and UNO supported. Please select the correct board and upload again

endif