add uart4 and uart5

This commit is contained in:
ZYQ-FEIYUE
2022-08-20 23:37:10 +08:00
parent ba7efc3e60
commit 9c78fdbfb0
3 changed files with 58 additions and 13 deletions

View File

@@ -150,6 +150,26 @@ 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);
}
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);
}
else
{
return;
@@ -290,3 +310,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

View File

@@ -29,19 +29,6 @@
typedef enum
{
SERIAL_7N1,
SERIAL_7N2,
SERIAL_7E1,
SERIAL_7E2,
SERIAL_7O1,
SERIAL_7O2,
SERIAL_7N0_5,
SERIAL_7N1_5,
SERIAL_7E0_5,
SERIAL_7E1_5,
SERIAL_7O0_5,
SERIAL_7O1_5,
SERIAL_8N1,
SERIAL_8N2,
SERIAL_8E1,
@@ -139,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

View File

@@ -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