Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: XBee mbed NetServicesMin
Diff: frame_layer/culc_crc16.cpp
- Revision:
- 0:42adca80439c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/frame_layer/culc_crc16.cpp	Thu Mar 22 12:40:48 2012 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+#include "types.h"
+#include "config.h"
+#include "culc_crc16.h"
+
+unsigned int One_Byte_CRC16_Calc (uint16_t crc , uint8_t data)
+{
+  //  DBG("++++++++++++ CRC culc start initial CRC:%04X DATA:%04X\n",crc,data);
+    for (int i = 0; i < 8; ++i)
+    {
+        if ((crc / 0x7fff) ^ (data & 0x01))    // Ex-OR input LSB first
+        {
+            crc = crc ^ 0x4002; // 0100 0000 0000 0010 << 1 
+            crc = crc << 1;
+            crc ++;
+        }
+        else
+        {
+         //   crc = crc *2;    // left shift
+            crc = crc << 1;
+        }
+     //   TEMP = TEMP/2;    // right shift
+        data = data >> 1;
+    }
+ //   DBG("************** CRC culc result  CRC:%04X\n",crc);
+    return crc;
+}