1 static void Moudle_Check_SIM_Status() 2 { 3 if(SIM800C_Connect_Error_Flag == FALSE) 4 { 5 Timer6.usDelay_Timer = 0; 6 do 7 { 8 //DMA重新接收设置 9 SIM800C.DMA_Receive_Set(); 10 11 //发送AT指令 12 UART2.SendString(AT_CMD_CPIN); 13 //打印信息 14 printf("%s",AT_CMD_CPIN); 15 //延时1000ms,等待接收完成 16 HAL_Delay(1000); 17 18 //打印信息 19 printf("%s",UART2.pucRec_Buffer); 20 21 //超时处理 22 if(Timer6.usDelay_Timer >= TIMER6_10S) 23 { 24 SIM800C.Error(); 25 break; 26 } 27 } 28 while(strstr((const char*)UART2.pucRec_Buffer,"OK") == NULL); 29 } 30 }View Code
1 /* Private define-------------------------------------------------------------*/ 2 3 /* Private variables----------------------------------------------------------*/ 4 5 static uint8_t ucSend_Buffer[UART2_Send_LENGTH] = {0x00}; 6 static uint8_t ucRec_Buffer [UART2_Rec_LENGTH] = {0x00}; 7 8 /* Private function prototypes------------------------------------------------*/ 9 static void SendArray(uint8_t*,uint16_t); //串口发送数组 10 static void SendString(uint8_t*); //串口发送字符串 11 12 static void RS485_Set_SendMode(void); //RS-485接口设置为发送模式 13 static void RS485_Set_RecMode(void); //RS-485接口设置为接收模式 14 15 /* Public variables-----------------------------------------------------------*/ 16 UART_t UART2 = 17 { 18 ucSend_Buffer, 19 ucRec_Buffer, 20 21 SendArray, 22 SendString, 23 24 TTL, 25 RS485_Set_SendMode, 26 RS485_Set_RecMode 27 };