1 /***************************************************************************/ /** 2 * @file rsi_crc.h 3 ******************************************************************************* 4 * # License 5 * <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b> 6 ******************************************************************************* 7 * 8 * SPDX-License-Identifier: Zlib 9 * 10 * The licensor of this software is Silicon Laboratories Inc. 11 * 12 * This software is provided 'as-is', without any express or implied 13 * warranty. In no event will the authors be held liable for any damages 14 * arising from the use of this software. 15 * 16 * Permission is granted to anyone to use this software for any purpose, 17 * including commercial applications, and to alter it and redistribute it 18 * freely, subject to the following restrictions: 19 * 20 * 1. The origin of this software must not be misrepresented; you must not 21 * claim that you wrote the original software. If you use this software 22 * in a product, an acknowledgment in the product documentation would be 23 * appreciated but is not required. 24 * 2. Altered source versions must be plainly marked as such, and must not be 25 * misrepresented as being the original software. 26 * 3. This notice may not be removed or altered from any source distribution. 27 * 28 ******************************************************************************/ 29 30 // Includes Files 31 32 #include "rsi_ccp_common.h" 33 #include "base_types.h" 34 35 #ifndef RSI_CRC_H 36 #define RSI_CRC_H 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #define DIN_WIDTH_32 31 43 #define DIN_WIDTH_16 15 44 #define DIN_WIDTH_8 7 45 46 // brief: Structure of CRC Calculation 47 typedef struct { 48 uint32_t crc; //Calculated CRC Value 49 uint32_t polynomial; //Polynomial Value for CRC Calculation 50 unsigned int 51 polyWidth : 5; //Number of bits/width of the polynomial has to be written here for the computation of final CRC 52 uint32_t lfsrVal; //lfsr Initialization value for CRC Calculation 53 unsigned int widthType : 3; //Data Width taken Variable. 54 //When width_type - 0 :Take the data width from either reg programmed or from cnt 55 //width_type -1 :Take the data width from Reg. 56 //width_type-2 : Take the data width from CNT. 57 unsigned int dinWidth : 5; //Valid number of bits in the input data in din_width_from_reg set mode 58 uint32_t numBytes; //Input data number of bytes 59 unsigned int aempty : 4; //Almost empty Threshold value. Max value is 15 60 unsigned int afull : 4; //Almost Full Threshold value. Max value is 15 61 uint32_t InputData; 62 uint32_t swapLfsr; 63 uint32_t swapDin; 64 uint32_t useUdma; 65 uint32_t inputSize; 66 uint32_t dataIn; 67 uint32_t bitWidth; 68 uint32_t lfsrState; 69 } RSI_CRC_PARAMS_T; 70 71 // CRC FUNCTION PROTOTYPES 72 void crc_set_gen_control(CRC_Type *pCRC); 73 74 uint32_t crc_get_gen_status(CRC_Type *pCRC); 75 76 void crc_polynomial(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 77 78 uint32_t crc_polynomial_width(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 79 80 void crc_lfsr_init(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 81 82 uint32_t crc_use_swapped_init(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 83 84 uint32_t crc_set_data_width_type(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 85 86 uint32_t crc_set_fifo_thresholds(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 87 88 uint32_t crc_write_data(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams, uint32_t data); 89 90 uint32_t monitor_crc_calc(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 91 92 void crc_lfsr_dynamic_write(CRC_Type *pCRC, RSI_CRC_PARAMS_T *pCRCParams); 93 94 void crc_reset_fifo(CRC_Type *pCRC); 95 96 uint32_t crc_get_fifo_status(CRC_Type *pCRC); 97 #ifdef __cplusplus 98 } 99 #endif 100 101 #endif // RSI_CRC_H 102