STM32CUBEMX_DMA串口空闲中断接收+接收发送缓冲区

STM32CUBEMX_DMA串口空闲中断接收+接收发送缓冲区

前言:
我了解的串口接收指令的方式有:在这里插入图片描述

1、接收数据中断+特定帧尾
2、接收数据中断+空闲中断
3、DMA接收+空闲中断
我最推荐第三种,尤其是数据量比较大且频繁的时候

串口配置
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
my_it.c

#include "my_it.h"
#include "mymain.h"
#include "main.h"
#include "gpio.h"
#include "tim.h"
#include "usart.h"
#include "uart_lcd.h"void MY_UART_IDLECallback(UART_HandleTypeDef *huart)//自定义的串口超时中断回调函数
{HAL_UART_DMAStop(&huart3);															//暂停DMAunsigned char data_length  = BUFFER_SIZE - __HAL_DMA_GET_COUNTER(&hdma_usart3_rx);	//计算此帧数据长度if(data_length == RBUFF_UNIT){unsigned char recv_data[10] = {0};memcpy(recv_data,receive_buff,RBUFF_UNIT);RxDataBufCheck(recv_data,RBUFF_UNIT);}//HAL_UART_Transmit_DMA(&huart3,receive_buff,data_length);							//回环测试,接收到什么返回什么HAL_UART_Receive_DMA(&huart3, (unsigned char*)receive_buff, BUFFER_SIZE);			//继续开启接收data_length = 0;
}void MY_UART_IRQHandler(UART_HandleTypeDef *huart)//此函数调用放在void USART3_IRQHandler(void)内执行
{if(USART3 == huart->Instance){if(RESET != __HAL_UART_GET_FLAG(&huart3, UART_FLAG_IDLE))	//判断是否是空闲中断{__HAL_UART_CLEAR_IDLEFLAG(&huart3);						//清除空闲中断MY_UART_IDLECallback(huart);							//空闲中断处理函数}}
}

my_it.h

#ifndef __MY_IT_H
#define __MY_IT_H
#include "log.h"
#include "usart.h"extern DMA_HandleTypeDef hdma_usart3_rx;void MY_UART_IRQHandler(UART_HandleTypeDef *huart);
void MY_UART_IDLECallback(UART_HandleTypeDef *huart);#endif

uart_lcd.c

#include "uart_lcd.h"
#include "sensor.h"
#include "dev_control.h"
#include <stdint.h>unsigned char  UART_RxDataBuf[R_NUM][RBUFF_UNIT];           //接收缓冲区
unsigned char *UART_RxDataInPtr;
unsigned char *UART_RxDataOutPtr;
unsigned char *UART_RxDataEndPtr;unsigned char  UART_TxDataBuf[T_NUM][TBUFF_UNIT];           //发送缓冲区
unsigned char *UART_TxDataInPtr;
unsigned char *UART_TxDataOutPtr;
unsigned char *UART_TxDataEndPtr;unsigned char receive_buff[BUFFER_SIZE];					//串口接收临时缓存//发送数据实例
#include "uart_lcd.h"
#include "sensor.h"
#include "dev_control.h"
#include <stdint.h>unsigned char  UART_RxDataBuf[R_NUM][RBUFF_UNIT];           //接收缓冲区
unsigned char *UART_RxDataInPtr;
unsigned char *UART_RxDataOutPtr;
unsigned char *UART_RxDataEndPtr;unsigned char  UART_TxDataBuf[T_NUM][TBUFF_UNIT];           //发送缓冲区
unsigned char *UART_TxDataInPtr;
unsigned char *UART_TxDataOutPtr;
unsigned char *UART_TxDataEndPtr;unsigned char receive_buff[BUFFER_SIZE];					//串口接收临时缓存//发送数据实例
unsigned char lcd_send_data[] = {0xFF,0x55,0x00,0x04,0x00,0x00,0x00,0x00,0xC1,0xBB};//大小端转化
unsigned short swapEndian16(unsigned short value) 
{return ((value & 0xFF00) >> 8) | ((value & 0x00FF) << 8);
}unsigned int swapEndian32(unsigned int value) 
{return ((value & 0xFF000000) >> 24) |((value & 0x00FF0000) >> 8) |((value & 0x0000FF00) << 8) |((value & 0x000000FF) << 24);
}/* Table of CRC values for high order byte */
const uint8_t crctablehi[] = {0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41,0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81,0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0,0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40,0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01,0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0,0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01,0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41,0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81,0x40
};
/* Table of CRC values for low order byte */
const uint8_t crctablelo[] = {0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4,0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09,0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD,0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7,0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A,0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE,0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2,0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F,0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB,0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91,0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C,0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88,0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C,0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80,0x40
};unsigned short crc16Modbus(unsigned char *ptr, unsigned short len)
{unsigned char crchi = 0xff;unsigned char crclo = 0xff;unsigned short index;while(len--){index = crclo ^ *ptr++;crclo = crchi ^ crctablehi[index];crchi = crctablelo[index];}return (crchi | crclo << 8);//(crchi << 8 | crclo)高低字节互换//return (crchi << 8 | crclo);
}void uartLcdInit(void)
{UART_RxDataInPtr = UART_RxDataBuf[0];UART_RxDataOutPtr = UART_RxDataInPtr;UART_RxDataEndPtr = UART_RxDataBuf[R_NUM-1];UART_TxDataInPtr = UART_TxDataBuf[0];UART_TxDataOutPtr = UART_TxDataInPtr;UART_TxDataEndPtr = UART_TxDataBuf[T_NUM-1];__HAL_UART_ENABLE_IT(&huart3, UART_IT_IDLE);//使能空闲中断HAL_UART_Receive_DMA(&huart3, (unsigned char*)receive_buff, BUFFER_SIZE);//开始DMA接收串口数据
}void uartLcdTask(void)//50ms调用一次,来定时处理缓存数据
{if(UART_RxDataOutPtr != UART_RxDataInPtr)//if成立说明缓冲区有数据了{//解析处理数据unsigned char recv_data[RBUFF_UNIT] = {0};memcpy(recv_data,UART_RxDataOutPtr,RBUFF_UNIT);RxDataBufAnalyze(recv_data);UART_RxDataOutPtr += RBUFF_UNIT;             //指针下移if(UART_RxDataOutPtr == UART_RxDataEndPtr)   //指针移动到缓冲区的尾部{UART_RxDataOutPtr = UART_RxDataBuf[0];   //指针归为到缓冲区开头}}if(UART_TxDataOutPtr != UART_TxDataInPtr)//if成立说明了发送缓冲区有数据了{UARTLCD_debug("TxData:%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\r\n",UART_TxDataOutPtr[0],UART_TxDataOutPtr[1],UART_TxDataOutPtr[2],UART_TxDataOutPtr[3],UART_TxDataOutPtr[4],UART_TxDataOutPtr[5],UART_TxDataOutPtr[6],UART_TxDataOutPtr[7],UART_TxDataOutPtr[8],UART_TxDataOutPtr[9]);HAL_UART_Transmit_DMA(&huart3,UART_TxDataOutPtr,TBUFF_UNIT);	//发送数据UART_TxDataOutPtr += TBUFF_UNIT;                      			//指针下移if(UART_TxDataOutPtr == UART_TxDataEndPtr)              		//指针移动到了缓冲区的尾巴{UART_TxDataOutPtr = UART_TxDataBuf[0];            			//指针归为到缓冲区开头}}
}void uartLcdMainUpdate(unsigned int num)	//在需要与串口屏发送数据的地方调用
{TxDataBufSend(UARTLCD_COMMAND_INIT_CHECK,num);
}void TxDataBufAdd(unsigned char *data)
{memcpy(UART_TxDataInPtr,data,TBUFF_UNIT);      					//拷贝数据到发送缓冲区UART_TxDataInPtr += TBUFF_UNIT;                 				//指针下移if(UART_TxDataInPtr == UART_TxDataOutPtr){UARTLCD_error("UART_TxDataBuf exceed !!!\r\n");				//缓存满了报错提示}if(UART_TxDataInPtr == UART_TxDataEndPtr)      					//指针移动到缓冲区的尾部{UART_TxDataInPtr = UART_TxDataBuf[0];    					//指针归为到缓冲区开头}
}void RxDataBufAdd(unsigned char *data)
{memcpy(UART_RxDataInPtr,data,RBUFF_UNIT);  						//拷贝数据到接收缓冲区UART_RxDataInPtr += RBUFF_UNIT;                     			//指针下移if(UART_RxDataInPtr == UART_RxDataOutPtr)           			//缓存满了报错提示{UARTLCD_error("UART_RxDataBuf exceed !!!\r\n");}if(UART_RxDataInPtr == UART_RxDataEndPtr)           			//指针移动到缓冲区的尾部{UART_RxDataInPtr = UART_RxDataBuf[0];           			//指针归为到缓冲区开头}
//	for(int i = 0;i<10;i++)
//	{
//		for(int j = 0;j<10;j++)
//		{
//			Debug_printf("%x,",UART_RxDataBuf[i][j]);
//		}
//		Debug_printf("\r\n");
//	}
//	Debug_printf("\r\n");
}void TxDataBufPack(unsigned char command,unsigned int num)	//发送串口数据封包
{uartLcdDataFrame_t * send_data = (uartLcdDataFrame_t *)lcd_send_data;send_data->bodyData.commandData = command;send_data->bodyData.controlData = swapEndian32(num);unsigned char bodyData[RBUFF_UNIT-2] = {0};memcpy(bodyData,&send_data->bodyData,RBUFF_UNIT-2);unsigned short send_crc = crc16Modbus(bodyData,RBUFF_UNIT-2);send_data->crcData = send_crc;TxDataBufAdd((unsigned char *)send_data);
}void TxDataBufSend(unsigned char command,unsigned int num)	//直接发送数据,不经过缓存
{uartLcdDataFrame_t * send_data = (uartLcdDataFrame_t *)lcd_send_data;send_data->bodyData.commandData = command;send_data->bodyData.controlData = swapEndian32(num);unsigned char bodyData[RBUFF_UNIT-2] = {0};memcpy(bodyData,&send_data->bodyData,RBUFF_UNIT-2);unsigned short send_crc = crc16Modbus(bodyData,RBUFF_UNIT-2);send_data->crcData = send_crc;unsigned char send_data_[TBUFF_UNIT] = {0};memcpy(send_data_,send_data,TBUFF_UNIT);UARTLCD_debug("TxDataBufSend:%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\r\n",send_data_[0],send_data_[1],send_data_[2],send_data_[3],send_data_[4],send_data_[5],send_data_[6],send_data_[7],send_data_[8],send_data_[9]);HAL_UART_Transmit_DMA(&huart3,(unsigned char *)lcd_send_data,TBUFF_UNIT);HAL_Delay(2);
}void RxDataBufCheck(unsigned char *data,unsigned char length)	//校验接收到的串口数据是不是一帧数据
{if(length != RBUFF_UNIT) return;uartLcdDataFrame_t * recv_data = (uartLcdDataFrame_t *)data;if(recv_data->bodyData.headData == 0x55FF)//校验头{unsigned char bodyData[RBUFF_UNIT-2] = {0};memcpy(bodyData,&recv_data->bodyData,RBUFF_UNIT-2);unsigned short recv_crc = crc16Modbus(bodyData,RBUFF_UNIT-2);if(recv_crc == recv_data->crcData)//校验CRC{
//			Debug_printf("RxDataBufCheck recv data:%x,%x,%x,%x,%x\r\n",
//			recv_data->bodyData.headData,recv_data->bodyData.commandData,recv_data->bodyData.lengthData,
//			recv_data->bodyData.controlData,recv_data->crcData);RxDataBufAdd(data);//加入环形缓冲区}}
}void RxDataBufAnalyze(unsigned char *data)	//处理串口指令
{UARTLCD_debug("RxDataBufAnalyze:%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\r\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7],data[8],data[9]);uartLcdDataFrame_t * recv_data = (uartLcdDataFrame_t *)data;switch(recv_data->bodyData.commandData){case UARTLCD_COMMAND_INIT_CHECK:break;case UARTLCD_COMMAND_FLOW_LEVEL:break;case UARTLCD_COMMAND_SMOKE_CLEAN:break;case UARTLCD_COMMAND_AIR_CONSUME:break;case UARTLCD_COMMAND_PRESSURE_NOW:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_PRESSURE_TARGET:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_PRESSURE_REDUCE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_PRESSURE_ADD:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_FLOW_NOW:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_FLOW_TARGET:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_FLOW_REDUCE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_FLOW_ADD:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_PRESSURE_MODE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_HEAT_STATE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_AIR_START:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_AIR_INPUT_STATE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_BUZZER_LEVEL:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_LANGUAGE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_MESSAGE_WARNING:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_LIGHT_WARNING:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_USB_CHANGE:devBuzzerSetNum(1);break;case UARTLCD_COMMAND_VERSION_MESSGAE:devBuzzerSetNum(1);break;			default:break;}
}	

uart_lcd.h

#ifndef __UART_LCD_H
#define __UART_LCD_H
#include "main.h"
#include "log.h"
#include "usart.h"
#include "eeprom.h"
#include <string.h>#define UARTLCD_TASK_PERIOD  2 //#define UARTLCD_LOG_EN 0
#if UARTLCD_LOG_EN#define UARTLCD_printf(format, ...) 		printf(RTT_CTRL_TEXT_WHITE format , ##__VA_ARGS__)//"\r\n"#define UARTLCD_info(format, ...)   		printf(RTT_CTRL_TEXT_GREEN"[uartlcd]info:" format , ##__VA_ARGS__)#define UARTLCD_debug(format, ...)  		printf(RTT_CTRL_TEXT_WHITE"[uartlcd]debug:" format , ##__VA_ARGS__)#define UARTLCD_warning(format, ...)  	printf(RTT_CTRL_TEXT_YELLOW"[uartlcd]warning:" format , ##__VA_ARGS__)#define UARTLCD_error(format, ...)  		printf(RTT_CTRL_TEXT_RED"[uartlcd]error:" format ,##__VA_ARGS__)
#else#define UARTLCD_printf(format, ...)#define UARTLCD_info(format, ...)#define UARTLCD_debug(format, ...)#define UARTLCD_warning(format, ...)#define UARTLCD_error(format, ...)
#endif#define  R_NUM               20     //缓冲区的个数(可以缓存几帧数据)
#define  RBUFF_UNIT          10   	//缓冲区一帧数据的长度#define  T_NUM               20     //缓冲区的个数(可以缓存几帧数据)
#define  TBUFF_UNIT          10   	//缓冲区一帧数据的长度extern unsigned char  UART_RxDataBuf[R_NUM][RBUFF_UNIT];           //接收缓存区
extern unsigned char *UART_RxDataInPtr;                            //接收缓存区存放数据的位置
extern unsigned char *UART_RxDataOutPtr;                           //接收缓存区读取数据的位置
extern unsigned char *UART_RxDataEndPtr;                           //接收缓存区结束的位置extern unsigned char  UART_TxDataBuf[T_NUM][TBUFF_UNIT];           //发送缓存区
extern unsigned char *UART_TxDataInPtr;                            //发送缓存区存放数据的位置
extern unsigned char *UART_TxDataOutPtr;                           //发送缓存区读取数据的位置
extern unsigned char *UART_TxDataEndPtr;                           //发送缓存区结束的位置#define BUFFER_SIZE  100											//串口接收数据的临时缓存区大小
extern unsigned char receive_buff[BUFFER_SIZE];						//串口接收数据的临时缓存区typedef struct
{unsigned short headData;		//数据头unsigned char commandData;		//数据指令unsigned char lengthData;		//数据内容长度unsigned int controlData;		//数据内容
} uartLcdDataBody_t;typedef struct
{uartLcdDataBody_t bodyData;		//消息体unsigned short crcData;			//数据校验
} uartLcdDataFrame_t;enum{UARTLCD_COMMAND_INIT_CHECK,				UARTLCD_COMMAND_FLOW_LEVEL,		UARTLCD_COMMAND_SMOKE_CLEAN,	UARTLCD_COMMAND_AIR_CONSUME,	UARTLCD_COMMAND_PRESSURE_NOW,	UARTLCD_COMMAND_PRESSURE_TARGET,UARTLCD_COMMAND_PRESSURE_REDUCE,UARTLCD_COMMAND_PRESSURE_ADD,	UARTLCD_COMMAND_FLOW_NOW,		UARTLCD_COMMAND_FLOW_TARGET,	UARTLCD_COMMAND_FLOW_REDUCE,	UARTLCD_COMMAND_FLOW_ADD,		UARTLCD_COMMAND_PRESSURE_MODE,	UARTLCD_COMMAND_HEAT_STATE,		UARTLCD_COMMAND_AIR_START,		UARTLCD_COMMAND_AIR_INPUT_STATE,UARTLCD_COMMAND_BUZZER_LEVEL,	UARTLCD_COMMAND_LANGUAGE,		UARTLCD_COMMAND_MESSAGE_WARNING,UARTLCD_COMMAND_LIGHT_WARNING,	UARTLCD_COMMAND_USB_CHANGE,		UARTLCD_COMMAND_VERSION_MESSGAE	
};void uartLcdInit(void);
void uartLcdEndInit(void);
void uartLcdTask(void);unsigned short swapEndian16(unsigned short value);
unsigned int swapEndian32(unsigned int value);
unsigned short crc16Modbus(unsigned char *ptr, unsigned short len);void uartLcdMainUpdate(unsigned int num);					void TxDataBufAdd(unsigned char *data);							//向发送缓冲区加入一条待发送的数据
void RxDataBufAdd(unsigned char *data);							//向接收缓冲区加入一条待处理的数据
void RxDataBufCheck(unsigned char *data,unsigned char length);	//检验接收到串口数据是不是一帧合格的数据
void RxDataBufAnalyze(unsigned char *data);						//处理串口指令
void TxDataBufPack(unsigned char command,unsigned int num);		//发送串口数据封包
void TxDataBufSend(unsigned char command,unsigned int num);		//直接发送串口数据,不经过缓存#endif

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/139145.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Stm32_标准库_14_串口蓝牙模块_解决手机与蓝牙模块数据传输的不完整性

由手机向蓝牙模块传输时间信息&#xff0c;Stm32获取信息并将已存在信息修改为传入信息 测试代码&#xff1a; #include "stm32f10x.h" // Device header #include "Delay.h" #include "OLED.h" #include "Serial.h"uint16_t num…

索尼PS5 Pro将搭载RDNA 3定制GPU 拥有30个WGP/60个CU,频率更高

此前有报道称&#xff0c;PlayStation 5 Pro已进入开发最后阶段&#xff0c;其内部代号为“Trinity”&#xff0c;搭载的SoC对应代号为“Viola”&#xff0c;遵循了索尼使用《黑客帝国》人物名字作为代号的做法。 近日&#xff0c;RedGamingTech透露&#xff0c;索尼PlayStatio…

vscode配置c++和opencv环境

因为想要用c刷题&#xff0c;但是之前的vs被重装的时候删除了&#xff0c;DEVc实在是不好看的界面&#xff0c;于是就想起了之前写html的vscode&#xff0c;没想到配置环境花了一整天&#xff0c;还总是报错&#xff0c;也许是电脑配置不一样&#xff0c;所以就出了问题吧&…

ubuntu20.04 nerf开山之作

源码 GitHub - yenchenlin/nerf-pytorch: A PyTorch implementation of NeRF (Neural Radiance Fields) that reproduces the results. 代码的相关解读 NeRF代码解读-相机参数与坐标系变换 - 知乎 原文题目&#xff1a;NeRF: Representing Scenes as Neural Radiance Field…

leetcode-200. 岛屿数量

1. 题目 leetcode题目链接 2. 解答 思路&#xff1a; 需要循环遍历每个节点&#xff1b;找到陆地&#xff0c;基于陆地开始遍历陆地的上下左右&#xff1b;数组dirm dirn就可以表示某个区域的上下左右&#xff1b;标记遍历过的节点&#xff1b;设计循环的退出条件&#xf…

【Django 01】环境搭配与项目配置

1. 介绍 https://github.com/Joe-2002/sweettalk-django4.2#readme Django 是一个使用 Python 编写的开源 Web 应用程序框架&#xff0c;它提供了一套用于快速开发安全、 可扩展和高效的 Web 应用程序的工具和功能。Django 基于 MVC&#xff08;Model-View-Controller&#xf…

Windows工业三防平板全功能NFC近距离感应一维/二维扫描

Windows系统工业三防平板电脑是一种在智慧工厂仓储物流、MES数采、车载设备、设备检测、自动化控制等领域广泛应用的先进设备。此外&#xff0c;它还在公共服务领域&#xff0c;如高速交通、物流运输、电力检测、公务执法、银行金融、船舶装备、户外勘测、建筑工程、汽车检测、…

使用vscode + vite + vue3+ element3 搭建vue3脚手架

技术栈 开发工具&#xff1a;VSCode 代码管理&#xff1a;Git 前端框架&#xff1a;Vue3 构建工具&#xff1a;Vite 路由&#xff1a;vue-router 状态管理&#xff1a;vuex AJAX&#xff1a;axios UI库&#xff1a;element-ui 3 数据模拟&#xff1a;mockjs css预处理&#xf…

0基础学习VR全景平台篇 第108篇:全景图细节处理(下,航拍)

上课&#xff01;全体起立~ 大家好&#xff0c;欢迎观看蛙色官方系列全景摄影课程&#xff01; &#xff08;调色前图库&#xff09; &#xff08;原图-大图&#xff09; 一、导入文件 单击右下角导入按钮&#xff0c;选择航拍图片所在文件夹&#xff0c;选择图片&#xff0…

零基础学习HTML5(列表、表格、表单)

01-列表 作用&#xff1a;布局内容排列整齐的区域。 列表分类&#xff1a;无序列表、有序列表、定义列表。 无序列表 作用&#xff1a;布局排列整齐的不需要规定顺序的区域。 标签&#xff1a;ul 嵌套 li&#xff0c;ul 是无序列表&#xff0c;li 是列表条目。 <ul>…

01. 汇编LED驱动实验

01. 汇编LED驱动实验 汇编原理分析为什么要学习Cortex—A汇编STM32IO初始化流程IMX6UL初始化流程 汇编基础处理器内部数据传输指令存储器访问指令 编写驱动编译程序烧写bin文件 汇编原理分析 为什么要学习Cortex—A汇编 需要用汇编初始化一些SOC外设使用汇编初始化DDR&#x…

【mfc/VS2022】计图实验:绘图工具设计知识笔记2

按钮添加处理程序 1.类视图找到对应类右击&#xff0c;类向导 2. 找到对应的的按钮id 如何将画出的两个相交的圆都显示出来&#xff0c;而不是重叠&#xff08;如下图&#xff09;隐藏了一条圆弧 问题如图&#xff1a; 因为矩形和圆心其实是个背景色的封闭图形&#xff0c;所…