From da02cf36b7265693bef7d982c6d46b372ed53693 Mon Sep 17 00:00:00 2001
From: chen <15335560115@163.com>
Date: 星期三, 21 五月 2025 18:16:14 +0800
Subject: [PATCH] 将网关读取标签配置和修改标签配置调通,但下发修改配置只能改组id其他能改但不能保存,掉电后会初始化问题未解决

---
 keil/include/src/Radio/crc.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/keil/include/src/Radio/crc.c b/keil/include/src/Radio/crc.c
new file mode 100644
index 0000000..68ed1c9
--- /dev/null
+++ b/keil/include/src/Radio/crc.c
@@ -0,0 +1,47 @@
+#include "crc.h"
+
+
+uint16_t ComputeCrc( uint16_t crc, uint8_t dataByte, uint16_t polynomial )
+{
+  uint8_t i;
+  
+  for( i = 0; i < 8; i++ )
+  {
+   if( ( ( ( crc & 0x8000 ) >> 8 ) ^ ( dataByte & 0x80 ) ) != 0 )
+   {
+     crc <<= 1; // shift left once
+     crc ^= polynomial; // XOR with polynomial
+   }
+   else
+   { 
+     crc <<= 1; // shift left once
+   }
+   dataByte <<= 1; // Next data bit
+  }
+  return crc;
+}
+
+
+uint16_t RadioComputeCRC( uint8_t *buffer, uint8_t length, uint8_t crcType )
+{
+  uint8_t i = 0;
+  uint16_t crc = 0;
+  uint16_t polynomial = 0;
+  
+  polynomial = ( crcType == CRC_TYPE_IBM ) ? POLYNOMIAL_IBM : POLYNOMIAL_CCITT;
+  crc = ( crcType == CRC_TYPE_IBM ) ? CRC_IBM_SEED : CRC_CCITT_SEED;
+  for( i = 0; i < length; i++ )
+  {
+   crc = ComputeCrc( crc, buffer[i], polynomial );
+  }
+  if( crcType == CRC_TYPE_IBM )
+  {
+   return crc;
+  }
+  else
+  {
+   return( ( uint16_t ) ( ~crc ));
+   }
+}
+
+

--
Gitblit v1.9.3