Yoshihiro TSUBOI / BLE_API_Native_IRC

Dependents:   BLE_Health_Thermometer_IRC BLE_RCBController_micono_test BLE_konashi_PIO_test BLE_ADT7410_TMP102_Sample ... more

Fork of BLE_API_Native_blog by Donal Morrissey

Committer:
ytsuboi
Date:
Wed Jun 11 15:15:30 2014 +0000
Revision:
19:d84e7516652b
Parent:
17:d5600677d532
Changed Low freq. clock source from XTAL to IRC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 17:d5600677d532 1 /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
ktownsend 17:d5600677d532 2 *
ktownsend 17:d5600677d532 3 * The information contained herein is property of Nordic Semiconductor ASA.
ktownsend 17:d5600677d532 4 * Terms and conditions of usage are described in detail in NORDIC
ktownsend 17:d5600677d532 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
ktownsend 17:d5600677d532 6 *
ktownsend 17:d5600677d532 7 * Licensees are granted free, non-transferable use of the information. NO
ktownsend 17:d5600677d532 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
ktownsend 17:d5600677d532 9 * the file.
ktownsend 17:d5600677d532 10 *
ktownsend 17:d5600677d532 11 */
ktownsend 17:d5600677d532 12
ktownsend 17:d5600677d532 13 #include "crc16.h"
ktownsend 17:d5600677d532 14 #include <stdio.h>
ktownsend 17:d5600677d532 15
ktownsend 17:d5600677d532 16 uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc)
ktownsend 17:d5600677d532 17 {
ktownsend 17:d5600677d532 18 uint32_t i;
ktownsend 17:d5600677d532 19 uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc;
ktownsend 17:d5600677d532 20
ktownsend 17:d5600677d532 21 for (i = 0; i < size; i++)
ktownsend 17:d5600677d532 22 {
ktownsend 17:d5600677d532 23 crc = (unsigned char)(crc >> 8) | (crc << 8);
ktownsend 17:d5600677d532 24 crc ^= p_data[i];
ktownsend 17:d5600677d532 25 crc ^= (unsigned char)(crc & 0xff) >> 4;
ktownsend 17:d5600677d532 26 crc ^= (crc << 8) << 4;
ktownsend 17:d5600677d532 27 crc ^= ((crc & 0xff) << 4) << 1;
ktownsend 17:d5600677d532 28 }
ktownsend 17:d5600677d532 29
ktownsend 17:d5600677d532 30 return crc;
ktownsend 17:d5600677d532 31 }