优化架构
This commit is contained in:
+22
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user