EFR32 Blue Gecko 1 Software Documentation  efr32bg1-doc-5.1.2
em_gpcrc.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef EM_GPCRC_H
34 #define EM_GPCRC_H
35 
36 #include "em_bus.h"
37 #include "em_device.h"
38 #if defined(GPCRC_PRESENT) && (GPCRC_COUNT > 0)
39 
40 #include <stdint.h>
41 #include <stdbool.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /***************************************************************************/
52 /***************************************************************************/
97 /*******************************************************************************
98  ******************************* STRUCTS ***********************************
99  ******************************************************************************/
100 
102 typedef struct
103 {
118  uint32_t crcPoly;
119 
126  uint32_t initValue;
127 
135 
142 
150 
155  bool autoInit;
156 
158  bool enable;
160 
162 #define GPCRC_INIT_DEFAULT \
163 { \
164  0x04C11DB7UL, /* CRC32 Polynomial value. */ \
165  0x00000000UL, /* Initialization value. */ \
166  false, /* Byte order is normal. */ \
167  false, /* Bit order is not reversed on output. */ \
168  false, /* Disable byte mode. */ \
169  false, /* Disable automatic init on data read. */ \
170  true, /* Enable GPCRC. */ \
171 }
172 
173 /*******************************************************************************
174  ****************************** PROTOTYPES *********************************
175  ******************************************************************************/
176 
177 void GPCRC_Init(GPCRC_TypeDef * gpcrc, const GPCRC_Init_TypeDef * init);
178 void GPCRC_Reset(GPCRC_TypeDef * gpcrc);
179 
180 /***************************************************************************/
190 __STATIC_INLINE void GPCRC_Enable(GPCRC_TypeDef * gpcrc, bool enable)
191 {
192  BUS_RegBitWrite(&gpcrc->CTRL, _GPCRC_CTRL_EN_SHIFT, enable);
193 }
194 
195 /***************************************************************************/
206 __STATIC_INLINE void GPCRC_Start(GPCRC_TypeDef * gpcrc)
207 {
208  gpcrc->CMD = GPCRC_CMD_INIT;
209 }
210 
211 /***************************************************************************/
222 __STATIC_INLINE void GPCRC_InitValueSet(GPCRC_TypeDef * gpcrc, uint32_t initValue)
223 {
224  gpcrc->INIT = initValue;
225 }
226 
227 /***************************************************************************/
242 __STATIC_INLINE void GPCRC_InputU32(GPCRC_TypeDef * gpcrc, uint32_t data)
243 {
244  gpcrc->INPUTDATA = data;
245 }
246 
247 /***************************************************************************/
262 __STATIC_INLINE void GPCRC_InputU16(GPCRC_TypeDef * gpcrc, uint16_t data)
263 {
264  gpcrc->INPUTDATAHWORD = data;
265 }
266 
267 /***************************************************************************/
282 __STATIC_INLINE void GPCRC_InputU8(GPCRC_TypeDef * gpcrc, uint8_t data)
283 {
284  gpcrc->INPUTDATABYTE = data;
285 }
286 
287 /***************************************************************************/
300 __STATIC_INLINE uint32_t GPCRC_DataRead(GPCRC_TypeDef * gpcrc)
301 {
302  return gpcrc->DATA;
303 }
304 
305 /***************************************************************************/
320 __STATIC_INLINE uint32_t GPCRC_DataReadBitReversed(GPCRC_TypeDef * gpcrc)
321 {
322  return gpcrc->DATAREV;
323 }
324 
325 /***************************************************************************/
338 __STATIC_INLINE uint32_t GPCRC_DataReadByteReversed(GPCRC_TypeDef * gpcrc)
339 {
340  return gpcrc->DATABYTEREV;
341 }
342 
346 #ifdef __cplusplus
347 }
348 #endif
349 
350 #endif /* defined(GPCRC_COUNT) && (GPCRC_COUNT > 0) */
351 #endif /* EM_GPCRC_H */
__STATIC_INLINE void GPCRC_InputU16(GPCRC_TypeDef *gpcrc, uint16_t data)
Writes a 16 bit value to the input data register of the CRC.
Definition: em_gpcrc.h:262
__IOM uint32_t CMD
__STATIC_INLINE void GPCRC_Start(GPCRC_TypeDef *gpcrc)
Issues a command to initialize the CRC calculation.
Definition: em_gpcrc.h:206
__STATIC_INLINE void GPCRC_Enable(GPCRC_TypeDef *gpcrc, bool enable)
Enable/disable GPCRC.
Definition: em_gpcrc.h:190
__STATIC_INLINE void GPCRC_InputU32(GPCRC_TypeDef *gpcrc, uint32_t data)
Writes a 32 bit value to the input data register of the CRC.
Definition: em_gpcrc.h:242
__IM uint32_t DATAREV
void GPCRC_Init(GPCRC_TypeDef *gpcrc, const GPCRC_Init_TypeDef *init)
Initialize the General Purpose Cyclic Redundancy Check (GPCRC) module.
Definition: em_gpcrc.c:73
RAM and peripheral bit-field set and clear API.
void GPCRC_Reset(GPCRC_TypeDef *gpcrc)
Reset GPCRC registers to the hardware reset state.
Definition: em_gpcrc.c:116
__STATIC_INLINE uint32_t GPCRC_DataReadByteReversed(GPCRC_TypeDef *gpcrc)
Reads the data register of the CRC byte reversed.
Definition: em_gpcrc.h:338
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
__STATIC_INLINE void GPCRC_InitValueSet(GPCRC_TypeDef *gpcrc, uint32_t initValue)
Set the initialization value of the CRC.
Definition: em_gpcrc.h:222
__STATIC_INLINE void GPCRC_InputU8(GPCRC_TypeDef *gpcrc, uint8_t data)
Writes an 8 bit value to the input data register of the CRC.
Definition: em_gpcrc.h:282
__IOM uint32_t INPUTDATABYTE
#define GPCRC_CMD_INIT
__STATIC_INLINE uint32_t GPCRC_DataRead(GPCRC_TypeDef *gpcrc)
Reads the data register of the CRC.
Definition: em_gpcrc.h:300
__IOM uint32_t INIT
uint32_t crcPoly
Definition: em_gpcrc.h:118
__IOM uint32_t INPUTDATAHWORD
#define _GPCRC_CTRL_EN_SHIFT
__IOM uint32_t CTRL
__IOM uint32_t INPUTDATA
__IM uint32_t DATA
__STATIC_INLINE uint32_t GPCRC_DataReadBitReversed(GPCRC_TypeDef *gpcrc)
Reads the data register of the CRC bit reversed.
Definition: em_gpcrc.h:320
__STATIC_INLINE void BUS_RegBitWrite(volatile uint32_t *addr, unsigned int bit, unsigned int val)
Perform a single-bit write operation on a peripheral register.
Definition: em_bus.h:148
__IM uint32_t DATABYTEREV
uint32_t initValue
Definition: em_gpcrc.h:126