123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #include "comm_car_485.h"
- //-------------参数定义
- rs485RecDate s_rs485RecDate;
- rs485SendDate s_rs485SendDate;
- /**
- * @brief crc16计算
- * @param ptr: 数据首地址
- * @param len: 数据长度
- * @return
- */
- unsigned short mb_crc16(unsigned char *ptr, int len)
- {
- unsigned int i;
- unsigned short crc = 0xFFFF;
-
- while(len--)
- {
- crc ^= *ptr++;
- for (i = 0; i < 8; ++i)
- {
- if (crc & 1)
- crc = (crc >> 1) ^ 0xA001;
- else
- crc = (crc >> 1);
- }
- }
-
- return crc;
- }
- /**
- * @brief 485发送函数
- * @param data: 发送的数据
- * @param dataLen: 发送的数据长度
- * @note
- * @retval 无
- */
- void rs485_sendDate(uint8_t data[], uint32_t dataLen){
-
- }
- /**
- * @brief 485接收分析函数
- * @param data: 接收到的数据
- * @note
- * @retval 无
- */
- void rs485_recDateAnalyse(uint8_t data[]){
- /* 尝试获取互斥量,等待无限长时间 */
- if(osMutexAcquire(mutex_rs485RecDateHandle, osWaitForever) == osOK){
- /* 访问完成,释放互斥量 */
- osMutexRelease(mutex_rs485RecDateHandle);
- }
-
- }
- /**
- * @brief 轮询发送接收
- * @note
- * @retval 无
- */
- void rs485_poll_sendReceive(void){
- static uint8_t rs485Step = 0;
- switch(rs485Step){
- case 0:
- break;
- case 1:
- break;
- default: break;
- }
- }
|