diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index f8e5b4b..4ff30a3 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -159,7 +159,7 @@ void HardwareSerial::begin( crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_UART4_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK,TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); gpio_pin_remap_config(UART4_GMUX_0010, TRUE); } else if(_USARTx == UART5) @@ -171,9 +171,43 @@ void HardwareSerial::begin( crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_UART5_PERIPH_CLOCK, TRUE); - crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK,TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); gpio_pin_remap_config(UART5_GMUX_0001, TRUE); } + else if (_USARTx == USART6) + { + GPIOx = GPIOA; + Tx_Pin = GPIO_Pin_4; + Rx_Pin = GPIO_Pin_5; + USARTx_IRQn = USART6_IRQn; + + crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_USART6_PERIPH_CLOCK, TRUE); + } + else if (_USARTx == UART7) + { + GPIOx = GPIOB; + Tx_Pin = GPIO_Pin_4; + Rx_Pin = GPIO_Pin_3; + USARTx_IRQn = UART7_IRQn; + + crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_UART7_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(UART7_GMUX, TRUE); + } + else if (_USARTx == UART8) + { + GPIOx = GPIOC; + Tx_Pin = GPIO_Pin_2; + Rx_Pin = GPIO_Pin_3; + USARTx_IRQn = UART8_IRQn; + + crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_UART8_PERIPH_CLOCK, TRUE); + crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE); + gpio_pin_remap_config(UART8_GMUX, TRUE); + } else { return; @@ -332,3 +366,30 @@ extern "C" SERIAL_5_IRQ_HANDLER_DEF() Serial5.IRQHandler(); } #endif + +#if SERIAL_6_ENABLE +HardwareSerial Serial6(SERIAL_6_USART); + +extern "C" SERIAL_6_IRQ_HANDLER_DEF() +{ + Serial6.IRQHandler(); +} +#endif + +#if SERIAL_7_ENABLE +HardwareSerial Serial7(SERIAL_7_UART); + +extern "C" SERIAL_7_IRQ_HANDLER_DEF() +{ + Serial7.IRQHandler(); +} +#endif + +#if SERIAL_8_ENABLE +HardwareSerial Serial8(SERIAL_8_UART); + +extern "C" SERIAL_8_IRQ_HANDLER_DEF() +{ + Serial8.IRQHandler(); +} +#endif \ No newline at end of file diff --git a/cores/arduino/libcore/config/mcu_config.h b/cores/arduino/libcore/config/mcu_config.h index b7016cb..e257a56 100644 --- a/cores/arduino/libcore/config/mcu_config.h +++ b/cores/arduino/libcore/config/mcu_config.h @@ -66,6 +66,24 @@ # define SERIAL_5_IRQ_HANDLER_DEF() void UART5_IRQHandler(void) #endif +#define SERIAL_6_ENABLE 1 +#if SERIAL_6_ENABLE +# define SERIAL_6_USART USART6 +# define SERIAL_6_IRQ_HANDLER_DEF() void USART6_IRQHandler(void) +#endif + +#define SERIAL_7_ENABLE 1 +#if SERIAL_7_ENABLE +# define SERIAL_7_UART UART7 +# define SERIAL_7_IRQ_HANDLER_DEF() void UART7_IRQHandler(void) +#endif + +#define SERIAL_8_ENABLE 1 +#if SERIAL_8_ENABLE +# define SERIAL_8_UART UART8 +# define SERIAL_8_IRQ_HANDLER_DEF() void UART8_IRQHandler(void) +#endif + /* Wire (Software I2C) */ #define WIRE_USE_FULL_SPEED_I2C 0 #define WIRE_SDA_PIN PB7 diff --git a/package_at32_index.json b/package_at32_index.json index c7051f8..f072d70 100644 --- a/package_at32_index.json +++ b/package_at32_index.json @@ -12,7 +12,7 @@ { "name": "AT32F403ACGU7 Core Board", "architecture": "at32f403a", - "version": "0.0.6", + "version": "0.0.7", "category": "Contributed", "url": "https://github.com/WeActStudio/ArduinoCore-AT32F4/archive/refs/heads/main.zip", "archiveFileName": "ArduinoCore-AT32F4-main.zip", diff --git a/platform.txt b/platform.txt index 4cda097..988c3a6 100644 --- a/platform.txt +++ b/platform.txt @@ -1,6 +1,6 @@ ##==============================================## name=WeActStudio AT32F403A Boards -version=0.0.6 +version=0.0.7 ##==============================================## ####AT32 compile variables