优化架构

This commit is contained in:
2026-06-03 19:53:57 +08:00
parent 9869835739
commit 249409457f
3 changed files with 31 additions and 15 deletions
+22 -7
View File
@@ -25,8 +25,8 @@ const GPIO_CONFIG DO_PERIPH[] = {
#endif
//串口配置表
const COM_CONFIG COM_PERIPH[] = {
{COM0,.TxPort = GPIO9, .RxPort =GPIO10, .Speed = GPIO_Speed_50MHz,.Rs485 = false},
{COM1,.TxPort = GPIO2, .RxPort = GPIO3, .Speed = GPIO_Speed_50MHz,.Rs485 = true,.TxRxEn = GPIO55},
{COM0,.TxPort = GPIO9, .RxPort =GPIO10},
{COM1,.TxPort = GPIO2, .RxPort = GPIO3,.TxRxEn = GPIO55},
};
void BspExtraInit(void);
@@ -78,11 +78,8 @@ void BspInit(void) {
//串口配置
for (i = 0;i < ARRAY_LEN(COM_PERIPH);i++) {
GpioConfig(&COM_PERIPH[i].TxPort, GPIO_Mode_AF_PP, COM_PERIPH[i].Speed);
GpioConfig(&COM_PERIPH[i].RxPort, GPIO_Mode_IPU, COM_PERIPH[i].Speed);
if (COM_PERIPH[i].Rs485 == true) {
GpioConfig(&COM_PERIPH[i].TxRxEn, GPIO_Mode_AF_PP, COM_PERIPH[i].Speed);
}
GpioConfig(&COM_PERIPH[i].TxPort, GPIO_Mode_AF_PP, GPIO_Speed_2MHz);
GpioConfig(&COM_PERIPH[i].RxPort, GPIO_Mode_IPU, GPIO_Speed_2MHz);
}
INTERRUPT_ENABLE
@@ -160,6 +157,24 @@ void LedToggle(uint8_t Chnl)
GpioSet(&LED_PERIPH[Chnl].GpioX,LED_ON);
}
}
void Rs485StdConfig(const COM_MAP_T *ComX,unsigned int Baud)
{
for (unsigned char i = 0;i < ARRAY_LEN(COM_PERIPH);i++) {
if (ComX == COM_PERIPH[i].ComX) {
if (COM_PERIPH[i].TxRxEn.ClockTree) {
GpioSet(&COM_PERIPH[i].TxRxEn,Baud);
}
ComStdConfig(COM_PERIPH[i].ComX,Baud);
}
}
}
void Rs485AdvConfig(const COM_MAP_T *ComX, uint32_t Baud, uint8_t DataBits, uint8_t StopBits, uint8_t Parity)
{
}
/**
* @brief 重写Printf函数
* @note void
+4
View File
@@ -93,4 +93,8 @@ void ComStdConfig(const COM_MAP_T *ComX, uint32_t Baud)
void ComAdvConfig(const COM_MAP_T *ComX, uint32_t Baud, uint8_t DataBits, uint8_t StopBits, uint8_t Parity)
{
ComInit(ComX, Baud, DataBits, StopBits, Parity);
}
unsigned int CalcBaudTransIoSpeed(unsigned int Baud) {
}