summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c')
-rw-r--r--digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c b/digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c
new file mode 100644
index 00000000..3ba6ed45
--- /dev/null
+++ b/digital/beacon/src/Bitcloud_stack/Components/HAL/drivers/OFD/src/ofdCrcService.c
@@ -0,0 +1,66 @@
+/**************************************************************************//**
+\file ofdCrcService.c
+
+\brief Implementation of crc counting algorithm.
+
+\author
+ Atmel Corporation: http://www.atmel.com \n
+ Support email: avr@atmel.com
+
+ Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
+ Licensed under Atmel's Limited License Agreement (BitCloudTM).
+
+\internal
+ History:
+ 7/08/09 A. Khromykh - Created
+*******************************************************************************/
+/******************************************************************************
+ * WARNING: CHANGING THIS FILE MAY AFFECT CORE FUNCTIONALITY OF THE STACK. *
+ * EXPERT USERS SHOULD PROCEED WITH CAUTION. *
+ ******************************************************************************/
+
+#ifdef _OTAU_
+#if (APP_USE_OTAU == 1)
+#if APP_USE_FAKE_OFD_DRIVER == 0
+
+/******************************************************************************
+ Includes section
+******************************************************************************/
+#include <types.h>
+
+/******************************************************************************
+ Implementations section
+******************************************************************************/
+/**************************************************************************//**
+\brief Counts crc current memory area. CRC-8. Polynom 0x31 x^8 + x^5 + x^4 + 1.
+
+\param[in]
+ crc - first crc state
+\param[in]
+ pcBlock - pointer to the memory for crc counting
+\param[in]
+ length - memory size
+
+\return
+ current area crc
+******************************************************************************/
+uint8_t ofdCrc(uint8_t crc, uint8_t *pcBlock, uint8_t length)
+{
+ uint8_t i;
+
+ while (length--)
+ {
+ crc ^= *pcBlock++;
+
+ for (i = 0; i < 8; i++)
+ crc = crc & 0x80 ? (crc << 1) ^ 0x31 : crc << 1;
+ }
+
+ return crc;
+}
+
+#endif // APP_USE_FAKE_OFD_DRIVER == 0
+#endif // (APP_USE_OTAU == 1)
+#endif // _OTAU_
+
+// eof ofdCrcService.c