diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index 6fba901..f8e5b4b 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -150,6 +150,30 @@ void HardwareSerial::begin( crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_USART3_PERIPH_CLOCK, TRUE); } + else if(_USARTx == UART4) + { + GPIOx = GPIOA; + Tx_Pin = GPIO_Pin_0; + Rx_Pin = GPIO_Pin_1; + USARTx_IRQn = UART4_IRQn; + + 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); + gpio_pin_remap_config(UART4_GMUX_0010, TRUE); + } + else if(_USARTx == UART5) + { + GPIOx = GPIOB; + Tx_Pin = GPIO_Pin_9; + Rx_Pin = GPIO_Pin_8; + USARTx_IRQn = UART5_IRQn; + + 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); + gpio_pin_remap_config(UART5_GMUX_0001, TRUE); + } else { return; @@ -290,3 +314,21 @@ extern "C" SERIAL_3_IRQ_HANDLER_DEF() Serial3.IRQHandler(); } #endif + +#if SERIAL_4_ENABLE +HardwareSerial Serial4(SERIAL_4_UART); + +extern "C" SERIAL_4_IRQ_HANDLER_DEF() +{ + Serial4.IRQHandler(); +} +#endif + +#if SERIAL_5_ENABLE +HardwareSerial Serial5(SERIAL_5_UART); + +extern "C" SERIAL_5_IRQ_HANDLER_DEF() +{ + Serial5.IRQHandler(); +} +#endif diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index a4c447c..59f0584 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -126,4 +126,12 @@ extern HardwareSerial Serial2; extern HardwareSerial Serial3; #endif +#if SERIAL_4_ENABLE +extern HardwareSerial Serial4; +#endif + +#if SERIAL_5_ENABLE +extern HardwareSerial Serial5; +#endif + #endif diff --git a/cores/arduino/libcore/config/mcu_config.h b/cores/arduino/libcore/config/mcu_config.h index e0e5d49..b7016cb 100644 --- a/cores/arduino/libcore/config/mcu_config.h +++ b/cores/arduino/libcore/config/mcu_config.h @@ -54,6 +54,18 @@ # define SERIAL_3_IRQ_HANDLER_DEF() void USART3_IRQHandler(void) #endif +#define SERIAL_4_ENABLE 1 +#if SERIAL_4_ENABLE +# define SERIAL_4_UART UART4 +# define SERIAL_4_IRQ_HANDLER_DEF() void UART4_IRQHandler(void) +#endif + +#define SERIAL_5_ENABLE 1 +#if SERIAL_5_ENABLE +# define SERIAL_5_UART UART5 +# define SERIAL_5_IRQ_HANDLER_DEF() void UART5_IRQHandler(void) +#endif + /* Wire (Software I2C) */ #define WIRE_USE_FULL_SPEED_I2C 0 #define WIRE_SDA_PIN PB7 diff --git a/platform.txt b/platform.txt index 3b81079..9968a51 100644 --- a/platform.txt +++ b/platform.txt @@ -65,4 +65,4 @@ tools.Artery_ISP_Console.path={runtime.tools.Artery_ISP_Console.path} tools.Artery_ISP_Console.upload.params.verbose=-d tools.Artery_ISP_Console.upload.params.quiet= -tools.Artery_ISP_Console.upload.pattern=sh "{path}/{cmd}" "{build.path}/{build.project_name}.hex" +tools.Artery_ISP_Console.upload.pattern="{path}/{cmd}" "{build.path}/{build.project_name}.hex"