Merge pull request #9 from ZYQ-FEIYUE/main

add uart4 uart5
This commit is contained in:
WeAct Studio
2022-08-21 09:21:51 +08:00
committed by GitHub
4 changed files with 63 additions and 1 deletions

View File

@@ -150,6 +150,30 @@ void HardwareSerial::begin(
crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE); crm_periph_clock_enable(CRM_GPIOB_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_USART3_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 else
{ {
return; return;
@@ -290,3 +314,21 @@ extern "C" SERIAL_3_IRQ_HANDLER_DEF()
Serial3.IRQHandler(); Serial3.IRQHandler();
} }
#endif #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

View File

@@ -126,4 +126,12 @@ extern HardwareSerial Serial2;
extern HardwareSerial Serial3; extern HardwareSerial Serial3;
#endif #endif
#if SERIAL_4_ENABLE
extern HardwareSerial Serial4;
#endif
#if SERIAL_5_ENABLE
extern HardwareSerial Serial5;
#endif
#endif #endif

View File

@@ -54,6 +54,18 @@
# define SERIAL_3_IRQ_HANDLER_DEF() void USART3_IRQHandler(void) # define SERIAL_3_IRQ_HANDLER_DEF() void USART3_IRQHandler(void)
#endif #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) */ /* Wire (Software I2C) */
#define WIRE_USE_FULL_SPEED_I2C 0 #define WIRE_USE_FULL_SPEED_I2C 0
#define WIRE_SDA_PIN PB7 #define WIRE_SDA_PIN PB7

View File

@@ -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.verbose=-d
tools.Artery_ISP_Console.upload.params.quiet= 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"