modified locally to use with HRM1017

Dependents:   BLE_HTM_HRM1017

Fork of nRF51822 by Nordic Semiconductor

Committer:
nobukuma
Date:
Thu Dec 04 12:50:37 2014 +0000
Revision:
69:b4a3693da52b
Parent:
65:98215c4f3a25
modified locally to use with HRM1017

Who changed what in which revision?

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