テストモード追加、LED有効化 left -> SerialRX, Data Recieve Complete , Serial Tx , Light Tx
Dependencies: XBee mbed NetServicesMin
frame_layer/culc_crc16.cpp
- Committer:
- recotana
- Date:
- 2012-04-18
- Revision:
- 2:dec6319cf02c
- Parent:
- 0:42adca80439c
File content as of revision 2:dec6319cf02c:
#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; }