add files from nrf52832 bootloader project
This commit is contained in:
		
							
								
								
									
										31
									
								
								nRF5_SDK_11.0.0_89a8197/components/libraries/crc16/crc16.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								nRF5_SDK_11.0.0_89a8197/components/libraries/crc16/crc16.c
									
									
									
									
									
										Normal file
									
								
							@@ -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 <stdlib.h>
 | 
			
		||||
 | 
			
		||||
uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc)
 | 
			
		||||
{
 | 
			
		||||
    uint16_t crc = (p_crc == NULL) ? 0xFFFF : *p_crc;
 | 
			
		||||
 | 
			
		||||
    for (uint32_t i = 0; i < size; i++)
 | 
			
		||||
    {
 | 
			
		||||
        crc  = (uint8_t)(crc >> 8) | (crc << 8);
 | 
			
		||||
        crc ^= p_data[i];
 | 
			
		||||
        crc ^= (uint8_t)(crc & 0xFF) >> 4;
 | 
			
		||||
        crc ^= (crc << 8) << 4;
 | 
			
		||||
        crc ^= ((crc & 0xFF) << 4) << 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return crc;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								nRF5_SDK_11.0.0_89a8197/components/libraries/crc16/crc16.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								nRF5_SDK_11.0.0_89a8197/components/libraries/crc16/crc16.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
/* 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.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
/** @file
 | 
			
		||||
 *
 | 
			
		||||
 * @defgroup crc_compute CRC compute
 | 
			
		||||
 * @{
 | 
			
		||||
 * @ingroup hci_transport
 | 
			
		||||
 *
 | 
			
		||||
 * @brief    This module implements CRC-16-CCITT (polynomial 0x1021) with 0xFFFF initial value.
 | 
			
		||||
 *           The data can be passed in multiple blocks.
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
#ifndef CRC16_H__
 | 
			
		||||
#define CRC16_H__
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
/**@brief Function for calculating CRC-16 in blocks.
 | 
			
		||||
 *
 | 
			
		||||
 * Feed each consecutive data block into this function, along with the current value of p_crc as
 | 
			
		||||
 * returned by the previous call of this function. The first call of this function should pass NULL
 | 
			
		||||
 * as the initial value of the crc in p_crc.
 | 
			
		||||
 *
 | 
			
		||||
 * @param[in] p_data The input data block for computation.
 | 
			
		||||
 * @param[in] size   The size of the input data block in bytes.
 | 
			
		||||
 * @param[in] p_crc  The previous calculated CRC-16 value or NULL if first call.
 | 
			
		||||
 *
 | 
			
		||||
 * @return The updated CRC-16 value, based on the input supplied.
 | 
			
		||||
 */
 | 
			
		||||
uint16_t crc16_compute(uint8_t const * p_data, uint32_t size, uint16_t const * p_crc);
 | 
			
		||||
 | 
			
		||||
#endif // CRC16_H__
 | 
			
		||||
 
 | 
			
		||||
/** @} */
 | 
			
		||||
		Reference in New Issue
	
	Block a user