R1 code for micro:bit based train controller code, requires second micro:bit running rx code to operate - see https://meanderingpi.wordpress.com/ for more information

Fork of nrf51-sdk by Lancaster University

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers crc16.h Source File

crc16.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) Nordic Semiconductor ASA
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without modification,
00006  * are permitted provided that the following conditions are met:
00007  *
00008  *   1. Redistributions of source code must retain the above copyright notice, this
00009  *   list of conditions and the following disclaimer.
00010  *
00011  *   2. Redistributions in binary form must reproduce the above copyright notice, this
00012  *   list of conditions and the following disclaimer in the documentation and/or
00013  *   other materials provided with the distribution.
00014  *
00015  *   3. Neither the name of Nordic Semiconductor ASA nor the names of other
00016  *   contributors to this software may be used to endorse or promote products
00017  *   derived from this software without specific prior written permission.
00018  *
00019  *
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00022  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00023  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00024  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00025  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00027  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030  *
00031  */
00032  
00033 /** @file
00034  *
00035  * @defgroup crc_compute CRC compute
00036  * @{
00037  * @ingroup hci_transport
00038  *
00039  * @brief    This module implements the CRC-16 calculation in the blocks.
00040  */
00041  
00042 #ifndef CRC16_H__
00043 #define CRC16_H__
00044 
00045 #include <stdint.h>
00046 
00047 /**@brief Function for calculating CRC-16 in blocks.
00048  *
00049  * Feed each consecutive data block into this function, along with the current value of p_crc as 
00050  * returned by the previous call of this function. The first call of this function should pass NULL 
00051  * as the initial value of the crc in p_crc.
00052  *
00053  * @param[in] p_data The input data block for computation.
00054  * @param[in] size   The size of the input data block in bytes.
00055  * @param[in] p_crc  The previous calculated CRC-16 value or NULL if first call.  
00056  *
00057  * @return The updated CRC-16 value, based on the input supplied.
00058  */
00059 uint16_t crc16_compute(const uint8_t * p_data, uint32_t size, const uint16_t * p_crc);
00060 
00061 #endif // CRC16_H__
00062  
00063 /** @} */