bugfix for duplicate symbol
Fork of nRF51822 by
nordic-sdk/components/libraries/crc16/crc16.c@103:138bdc859cc9, 2015-04-15 (annotated)
- Committer:
- rgrover1
- Date:
- Wed Apr 15 08:59:11 2015 +0100
- Revision:
- 103:138bdc859cc9
Synchronized with git rev fa183c40
Author: Rohit Grover
updating to v7.1 of the Nordic SDK.
Re-organized file layout to match that from the SDK.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rgrover1 | 103:138bdc859cc9 | 1 | /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved. |
rgrover1 | 103:138bdc859cc9 | 2 | * |
rgrover1 | 103:138bdc859cc9 | 3 | * The information contained herein is property of Nordic Semiconductor ASA. |
rgrover1 | 103:138bdc859cc9 | 4 | * Terms and conditions of usage are described in detail in NORDIC |
rgrover1 | 103:138bdc859cc9 | 5 | * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT. |
rgrover1 | 103:138bdc859cc9 | 6 | * |
rgrover1 | 103:138bdc859cc9 | 7 | * Licensees are granted free, non-transferable use of the information. NO |
rgrover1 | 103:138bdc859cc9 | 8 | * WARRANTY of ANY KIND is provided. This heading must NOT be removed from |
rgrover1 | 103:138bdc859cc9 | 9 | * the file. |
rgrover1 | 103:138bdc859cc9 | 10 | * |
rgrover1 | 103:138bdc859cc9 | 11 | */ |
rgrover1 | 103:138bdc859cc9 | 12 | |
rgrover1 | 103:138bdc859cc9 | 13 | #include "crc16.h" |
rgrover1 | 103:138bdc859cc9 | 14 | #include <stdio.h> |
rgrover1 | 103:138bdc859cc9 | 15 | |
rgrover1 | 103:138bdc859cc9 | 16 | uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc) |
rgrover1 | 103:138bdc859cc9 | 17 | { |
rgrover1 | 103:138bdc859cc9 | 18 | uint32_t i; |
rgrover1 | 103:138bdc859cc9 | 19 | uint16_t crc = (p_crc == NULL) ? 0xffff : *p_crc; |
rgrover1 | 103:138bdc859cc9 | 20 | |
rgrover1 | 103:138bdc859cc9 | 21 | for (i = 0; i < size; i++) |
rgrover1 | 103:138bdc859cc9 | 22 | { |
rgrover1 | 103:138bdc859cc9 | 23 | crc = (unsigned char)(crc >> 8) | (crc << 8); |
rgrover1 | 103:138bdc859cc9 | 24 | crc ^= p_data[i]; |
rgrover1 | 103:138bdc859cc9 | 25 | crc ^= (unsigned char)(crc & 0xff) >> 4; |
rgrover1 | 103:138bdc859cc9 | 26 | crc ^= (crc << 8) << 4; |
rgrover1 | 103:138bdc859cc9 | 27 | crc ^= ((crc & 0xff) << 4) << 1; |
rgrover1 | 103:138bdc859cc9 | 28 | } |
rgrover1 | 103:138bdc859cc9 | 29 | |
rgrover1 | 103:138bdc859cc9 | 30 | return crc; |
rgrover1 | 103:138bdc859cc9 | 31 | } |