添加很多设备

This commit is contained in:
2024-03-04 01:01:14 +08:00
parent bef8342c93
commit cb1b2eb7d4
35 changed files with 22897 additions and 20328 deletions
+10 -3
View File
@@ -93,12 +93,12 @@ void USART1_Init(uint32_t BaudRate,uint16_t WordLength,uint16_t StopBits,uint16_
void usart_init(void)
{
usart_config(&uart1,USART1 ,GPIOA, GPIO_Pin_9, GPIOA, GPIO_Pin_10,115200, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No,128,128);
usart_config(&uart3,USART3 ,GPIOC, GPIO_Pin_10, GPIOC, GPIO_Pin_11,19200, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No,128,128);
usart_config(&uart1,USART1 ,GPIOA, GPIO_Pin_9, GPIOA, GPIO_Pin_10, 0,115200, USART_WordLength_8b, USART_StopBits_1, USART_Parity_No,128,128);
usart_config(&uart3,USART3 ,GPIOC, GPIO_Pin_10, GPIOC, GPIO_Pin_11, GPIO_PartialRemap_USART3,19200,USART_WordLength_8b, USART_StopBits_1, USART_Parity_No,128,128);
}
void usart_config(UART_ptr ptr,USART_TypeDef *UART, GPIO_TypeDef *GPIO_Tx, uint32_t Pin_Tx, GPIO_TypeDef *GPIO_Rx, uint32_t Pin_Rx,
void usart_config(UART_ptr ptr,USART_TypeDef *UART, GPIO_TypeDef *GPIO_Tx, uint32_t Pin_Tx, GPIO_TypeDef *GPIO_Rx, uint32_t Pin_Rx, uint32_t GPIO_Remap,
uint32_t BaudRate, uint16_t WordLength, uint16_t StopBits, uint16_t Parity,
uint32_t buff_tx_len,uint32_t buff_rx_len)
{
@@ -108,6 +108,7 @@ void usart_config(UART_ptr ptr,USART_TypeDef *UART, GPIO_TypeDef *GPIO_Tx, uint3
NVIC_InitTypeDef NVIC_InitStructure = {0};
uint32_t RCC_Periph = RCC_APB2Periph_USART1;
ptr->USART = UART;
ptr->GPIO_Tx = GPIO_Tx;
ptr->Pin_Tx = Pin_Tx;
@@ -130,6 +131,12 @@ void usart_config(UART_ptr ptr,USART_TypeDef *UART, GPIO_TypeDef *GPIO_Tx, uint3
else if(ptr->USART == USART3){RCC_Periph = RCC_APB1Periph_USART3;RCC_APB1PeriphClockCmd(RCC_Periph, ENABLE);}
else if(ptr->USART == UART4){RCC_Periph = RCC_APB1Periph_UART4;RCC_APB1PeriphClockCmd(RCC_Periph, ENABLE);}
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
if(GPIO_Remap)
{
GPIO_PinRemapConfig(GPIO_Remap, ENABLE);
}
//初始化IO口
//init tx