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.
Dependents: BLE_iBeacon_Exercise
Fork of BLE_API_Native by
Diff: hw/nRF51822n/nordic/app_common/crc16.c
- Revision:
- 0:4c3097c65247
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hw/nRF51822n/nordic/app_common/crc16.c Thu Feb 06 11:51:06 2014 +0000
@@ -0,0 +1,31 @@
+/* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
+ *
+ * The information contained herein is property of Nordic Semiconductor ASA.
+ * Terms and conditions of usage are described in detail in NORDIC
+ * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
+ *
+ * Licensees are granted free, non-transferable use of the information. NO
+ * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
+ * the file.
+ *
+ */
+
+#include "crc16.h"
+#include <stdio.h>
+
+uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc)
+{
+ uint32_t i;
+ uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc;
+
+ for (i = 0; i < size; i++)
+ {
+ crc = (unsigned char)(crc >> 8) | (crc << 8);
+ crc ^= p_data[i];
+ crc ^= (unsigned char)(crc & 0xff) >> 4;
+ crc ^= (crc << 8) << 4;
+ crc ^= ((crc & 0xff) << 4) << 1;
+ }
+
+ return crc;
+}
