/** ****************************************************************************** * @file tim.c * @author Jerry * @version V2.1 * @date 19-April-2022 * @brief tim program body. ****************************************************************************** * @attention * * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" #include "global.h" uint8_t Screen_RevFlg; uint8_t Screen_RevCount; uint8_t Screen_RevHandlerFlg; //在主函数执行分析处理 uint8_t MODBUS_RevFlg; uint8_t MODBUS_RevCount; uint8_t MODBUS1_RevFlg; uint8_t MODBUS1_RevCount; /*三选一模块*/ #if BLE_Conn uint8_t BLE_RevFlg; uint8_t BLE_RevCount; #endif #if WIFI_Conn uint8_t WIFI_RevFlg; uint8_t WIFI_RevCount; #endif #if LTE_Conn uint8_t LTE_RevFlg; uint8_t LTE_RevCount; #endif /**RS485 网口3.4**/ //usart1 init void uf_UART1_Init( u32 bound ) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; USART_InitTypeDef USART_InitStructure; /* Enable the USART1 Pins Software Remapping */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA , ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); USART_InitStructure.USART_BaudRate = bound; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); /* Configure USART1 Rx (PA.10) as input floating */ /* Configure USART1 Tx (PA.09) as alternate function push-pull */ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); /* Enable the USART1 Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3; //485通信主从机 优先级:3,0 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); if(bmsMem.E2_485Addr == 1) { USART_ITConfig(USART1, USART_IT_RXNE, DISABLE); //设备做主机时关闭接收中断 } else { USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //设备做从机时打开接收中断 } //USART_ITConfig(USART1, USART_IT_IDLE, ENABLE); USART_Cmd(USART1, ENABLE); } //send multiple bytes void USART1_SendMulByte(uint8_t *p, uint8_t size) { uint8_t i; for(i=0;i