EFM32 Giant Gecko Software Documentation  efm32gg-doc-4.2.1
em_crc.c
Go to the documentation of this file.
1 /***************************************************************************/
33 #include "em_crc.h"
34 #include "em_assert.h"
35 
36 #if defined(CRC_COUNT) && (CRC_COUNT > 0)
37 
38 /***************************************************************************/
43 /***************************************************************************/
48 /*******************************************************************************
49  ******************************** ENUMS ************************************
50  ******************************************************************************/
51 
52 
53 /*******************************************************************************
54  ******************************* STRUCTS ***********************************
55  ******************************************************************************/
56 
57 
58 /*******************************************************************************
59  *************************** GLOBAL FUNCTIONS ******************************
60  ******************************************************************************/
61 
62 /***************************************************************************/
81 void CRC_Init(CRC_Init_TypeDef const *init)
82 {
83  /* Sanity check of bitsPerWord. */
84  EFM_ASSERT(init->bitsPerWord < 16U);
85 
86  /* Set CRC control configuration parameters such as CRC width, byte and bit
87  * bit order, the number of bits per word, inverting input/output, etc. */
88  CRC->CTRL = (uint32_t)init->crcWidth
89  | (uint32_t)init->byteReverse
90  | (uint32_t)init->inputBitOrder
91  | (uint32_t)init->bitReverse
92  | ((uint32_t)init->bitsPerWord >> _CRC_CTRL_BITSPERWORD_SHIFT)
93  | ((uint32_t)init->inputPadding >> _CRC_CTRL_PADCRCINPUT_SHIFT)
94  | ((uint32_t)init->invInput >> _CRC_CTRL_INPUTINV_SHIFT)
95  | ((uint32_t)init->invOutput >> _CRC_CTRL_OUTPUTINV_SHIFT);
96 
97  /* Set CRC polynomial value. */
98  CRC->POLY = init->crcPoly;
99 
100  /* Load CRC initialization value to CRC_INIT. Please note, that the
101  * initialization is not performed here! */
102  CRC->INIT = init->initValue;
103 }
104 
105 
106 /***************************************************************************/
110 void CRC_Reset(void)
111 {
112  /* Reset CRC registers to their default value. */
113  CRC->CTRL = _CRC_CTRL_RESETVALUE;
114  CRC->POLY = _CRC_POLY_RESETVALUE;
115  CRC->INIT = _CRC_INIT_RESETVALUE;
116 }
117 
118 
122 #endif /* defined(CRC_COUNT) && (CRC_COUNT > 0) */
Emlib peripheral API "assert" implementation.
Cyclic Redundancy Check (CRC) API.