The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_EFM32HG_STK3400/TOOLCHAIN_GCC_ARM/em_gpcrc.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_EFM32GG11_STK3701/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_gpcrc.h@170:e95d10626187
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 170:e95d10626187 | 1 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 2 | * @file |
AnnaBridge | 170:e95d10626187 | 3 | * @brief General Purpose Cyclic Redundancy Check (GPCRC) API. |
AnnaBridge | 170:e95d10626187 | 4 | * @version 5.3.3 |
AnnaBridge | 170:e95d10626187 | 5 | ******************************************************************************* |
AnnaBridge | 170:e95d10626187 | 6 | * # License |
AnnaBridge | 170:e95d10626187 | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
AnnaBridge | 170:e95d10626187 | 8 | ******************************************************************************* |
AnnaBridge | 170:e95d10626187 | 9 | * |
AnnaBridge | 170:e95d10626187 | 10 | * Permission is granted to anyone to use this software for any purpose, |
AnnaBridge | 170:e95d10626187 | 11 | * including commercial applications, and to alter it and redistribute it |
AnnaBridge | 170:e95d10626187 | 12 | * freely, subject to the following restrictions: |
AnnaBridge | 170:e95d10626187 | 13 | * |
AnnaBridge | 170:e95d10626187 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
AnnaBridge | 170:e95d10626187 | 15 | * claim that you wrote the original software. |
AnnaBridge | 170:e95d10626187 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
AnnaBridge | 170:e95d10626187 | 17 | * misrepresented as being the original software. |
AnnaBridge | 170:e95d10626187 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
AnnaBridge | 170:e95d10626187 | 19 | * |
AnnaBridge | 170:e95d10626187 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
AnnaBridge | 170:e95d10626187 | 21 | * obligation to support this Software. Silicon Labs is providing the |
AnnaBridge | 170:e95d10626187 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
AnnaBridge | 170:e95d10626187 | 23 | * including, but not limited to, any implied warranties of merchantability |
AnnaBridge | 170:e95d10626187 | 24 | * or fitness for any particular purpose or warranties against infringement |
AnnaBridge | 170:e95d10626187 | 25 | * of any proprietary rights of a third party. |
AnnaBridge | 170:e95d10626187 | 26 | * |
AnnaBridge | 170:e95d10626187 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
AnnaBridge | 170:e95d10626187 | 28 | * special damages, or any other relief, or for any claim by any third party, |
AnnaBridge | 170:e95d10626187 | 29 | * arising from your use of this Software. |
AnnaBridge | 170:e95d10626187 | 30 | * |
AnnaBridge | 170:e95d10626187 | 31 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 32 | |
AnnaBridge | 170:e95d10626187 | 33 | #ifndef EM_GPCRC_H |
AnnaBridge | 170:e95d10626187 | 34 | #define EM_GPCRC_H |
AnnaBridge | 170:e95d10626187 | 35 | |
AnnaBridge | 170:e95d10626187 | 36 | #include "em_bus.h" |
AnnaBridge | 170:e95d10626187 | 37 | #include "em_device.h" |
AnnaBridge | 170:e95d10626187 | 38 | #if defined(GPCRC_PRESENT) && (GPCRC_COUNT > 0) |
AnnaBridge | 170:e95d10626187 | 39 | |
AnnaBridge | 170:e95d10626187 | 40 | #include <stdint.h> |
AnnaBridge | 170:e95d10626187 | 41 | #include <stdbool.h> |
AnnaBridge | 170:e95d10626187 | 42 | |
AnnaBridge | 170:e95d10626187 | 43 | #ifdef __cplusplus |
AnnaBridge | 170:e95d10626187 | 44 | extern "C" { |
AnnaBridge | 170:e95d10626187 | 45 | #endif |
AnnaBridge | 170:e95d10626187 | 46 | |
AnnaBridge | 170:e95d10626187 | 47 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 48 | * @addtogroup emlib |
AnnaBridge | 170:e95d10626187 | 49 | * @{ |
AnnaBridge | 170:e95d10626187 | 50 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 51 | |
AnnaBridge | 170:e95d10626187 | 52 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 53 | * @addtogroup GPCRC |
AnnaBridge | 170:e95d10626187 | 54 | * @brief General Purpose Cyclic Redundancy Check (GPCRC) API. |
AnnaBridge | 170:e95d10626187 | 55 | * |
AnnaBridge | 170:e95d10626187 | 56 | * @details |
AnnaBridge | 170:e95d10626187 | 57 | * The GPCRC API functions provide full support for the GPCRC peripheral. |
AnnaBridge | 170:e95d10626187 | 58 | * |
AnnaBridge | 170:e95d10626187 | 59 | * The GPCRC module is a peripheral that implements a Cyclic Redundancy Check |
AnnaBridge | 170:e95d10626187 | 60 | * (CRC) function. It supports a fixed 32-bit polynomial and a user |
AnnaBridge | 170:e95d10626187 | 61 | * configurable 16-bit polynomial. The fixed 32-bit polynomial is the commonly |
AnnaBridge | 170:e95d10626187 | 62 | * used IEEE 802.3 polynomial 0x04C11DB7. |
AnnaBridge | 170:e95d10626187 | 63 | * |
AnnaBridge | 170:e95d10626187 | 64 | * When using a 16-bit polynomial it's up to the user to choose a polynomial |
AnnaBridge | 170:e95d10626187 | 65 | * that fits the application. Commonly used 16-bit polynomial are 0x1021 |
AnnaBridge | 170:e95d10626187 | 66 | * (CCITT-16), 0x3D65 (IEC16-MBus), and 0x8005 (ZigBee, 802.15.4, and USB). |
AnnaBridge | 170:e95d10626187 | 67 | * See this link for other polynomials: |
AnnaBridge | 170:e95d10626187 | 68 | * https://en.wikipedia.org/wiki/Cyclic_redundancy_check |
AnnaBridge | 170:e95d10626187 | 69 | * |
AnnaBridge | 170:e95d10626187 | 70 | * Before a CRC calculation can begin it is important to call the |
AnnaBridge | 170:e95d10626187 | 71 | * @ref GPCRC_Start function. This function will reset the CRC calculation |
AnnaBridge | 170:e95d10626187 | 72 | * by copying the configured initialization value over to the CRC data register. |
AnnaBridge | 170:e95d10626187 | 73 | * |
AnnaBridge | 170:e95d10626187 | 74 | * There are two ways of sending input data to the GPCRC. You can either write |
AnnaBridge | 170:e95d10626187 | 75 | * the input data into the input data register using the input functions |
AnnaBridge | 170:e95d10626187 | 76 | * @ref GPCRC_InputU32, @ref GPCRC_InputU16 and @ref GPCRC_InputU8, or the |
AnnaBridge | 170:e95d10626187 | 77 | * user can setup the @ref LDMA to transfer data directly to one of the GPCRC |
AnnaBridge | 170:e95d10626187 | 78 | * input data registers. |
AnnaBridge | 170:e95d10626187 | 79 | * |
AnnaBridge | 170:e95d10626187 | 80 | * <b> Examples of GPCRC usage: </b> |
AnnaBridge | 170:e95d10626187 | 81 | * |
AnnaBridge | 170:e95d10626187 | 82 | * A CRC-32 Calculation: |
AnnaBridge | 170:e95d10626187 | 83 | * |
AnnaBridge | 170:e95d10626187 | 84 | * @include em_gpcrc_crc32.c |
AnnaBridge | 170:e95d10626187 | 85 | * |
AnnaBridge | 170:e95d10626187 | 86 | * A CRC-16 Calculation: |
AnnaBridge | 170:e95d10626187 | 87 | * |
AnnaBridge | 170:e95d10626187 | 88 | * @include em_gpcrc_crc16.c |
AnnaBridge | 170:e95d10626187 | 89 | * |
AnnaBridge | 170:e95d10626187 | 90 | * A CRC-CCITT calculation: |
AnnaBridge | 170:e95d10626187 | 91 | * |
AnnaBridge | 170:e95d10626187 | 92 | * @include em_gpcrc_ccit.c |
AnnaBridge | 170:e95d10626187 | 93 | * |
AnnaBridge | 170:e95d10626187 | 94 | * @{ |
AnnaBridge | 170:e95d10626187 | 95 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 96 | |
AnnaBridge | 170:e95d10626187 | 97 | /******************************************************************************* |
AnnaBridge | 170:e95d10626187 | 98 | ******************************* STRUCTS *********************************** |
AnnaBridge | 170:e95d10626187 | 99 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 100 | |
AnnaBridge | 170:e95d10626187 | 101 | /** CRC initialization structure. */ |
AnnaBridge | 170:e95d10626187 | 102 | typedef struct { |
AnnaBridge | 170:e95d10626187 | 103 | /** |
AnnaBridge | 170:e95d10626187 | 104 | * CRC polynomial value. The GPCRC support either a fixed 32-bit polynomial |
AnnaBridge | 170:e95d10626187 | 105 | * or a user configurable 16 bit polynomial. The fixed 32-bit polynomial |
AnnaBridge | 170:e95d10626187 | 106 | * is the one used in IEEE 802.3, which has the value 0x04C11DB7. To use the |
AnnaBridge | 170:e95d10626187 | 107 | * 32-bit fixed polynomial just assign 0x04C11DB7 to the crcPoly field. To use |
AnnaBridge | 170:e95d10626187 | 108 | * a 16-bit polynomial assign a value to crcPoly where the upper 16 bit's are |
AnnaBridge | 170:e95d10626187 | 109 | * zero. |
AnnaBridge | 170:e95d10626187 | 110 | * |
AnnaBridge | 170:e95d10626187 | 111 | * The polynomial should be written in normal bit order. So for instance |
AnnaBridge | 170:e95d10626187 | 112 | * if you want to use the CRC-16 polynomial X^16 + X^15 + X^2 + 1 then we |
AnnaBridge | 170:e95d10626187 | 113 | * can first convert it to hex representation and remove the highest order term |
AnnaBridge | 170:e95d10626187 | 114 | * of the polynomial. This would give us 0x8005 as the value to write into |
AnnaBridge | 170:e95d10626187 | 115 | * crcPoly. |
AnnaBridge | 170:e95d10626187 | 116 | */ |
AnnaBridge | 170:e95d10626187 | 117 | uint32_t crcPoly; |
AnnaBridge | 170:e95d10626187 | 118 | |
AnnaBridge | 170:e95d10626187 | 119 | /** |
AnnaBridge | 170:e95d10626187 | 120 | * CRC initialization value. This value is assigned to the GPCRC_INIT register. |
AnnaBridge | 170:e95d10626187 | 121 | * The initValue is loaded into the data register when calling the |
AnnaBridge | 170:e95d10626187 | 122 | * @ref GPCRC_Start function or when one of the data registers are read |
AnnaBridge | 170:e95d10626187 | 123 | * while @ref autoInit is enabled. |
AnnaBridge | 170:e95d10626187 | 124 | */ |
AnnaBridge | 170:e95d10626187 | 125 | uint32_t initValue; |
AnnaBridge | 170:e95d10626187 | 126 | |
AnnaBridge | 170:e95d10626187 | 127 | /** |
AnnaBridge | 170:e95d10626187 | 128 | * Reverse byte order. This has an effect when sending a 32-bit word or |
AnnaBridge | 170:e95d10626187 | 129 | * 16-bit half word input to the CRC calculation. When set to true the input |
AnnaBridge | 170:e95d10626187 | 130 | * bytes are reversed before entering the CRC calculation. When set to |
AnnaBridge | 170:e95d10626187 | 131 | * false the input bytes stay in the same order. |
AnnaBridge | 170:e95d10626187 | 132 | */ |
AnnaBridge | 170:e95d10626187 | 133 | bool reverseByteOrder; |
AnnaBridge | 170:e95d10626187 | 134 | |
AnnaBridge | 170:e95d10626187 | 135 | /** |
AnnaBridge | 170:e95d10626187 | 136 | * Reverse bits within each input byte. This setting enables or disable byte |
AnnaBridge | 170:e95d10626187 | 137 | * level bit reversal. When byte-level bit reversal is enabled then each byte |
AnnaBridge | 170:e95d10626187 | 138 | * of input data will be reversed before entering the CRC calculation. |
AnnaBridge | 170:e95d10626187 | 139 | */ |
AnnaBridge | 170:e95d10626187 | 140 | bool reverseBits; |
AnnaBridge | 170:e95d10626187 | 141 | |
AnnaBridge | 170:e95d10626187 | 142 | /** |
AnnaBridge | 170:e95d10626187 | 143 | * Enable/disable byte mode. When byte mode is enabled then all input |
AnnaBridge | 170:e95d10626187 | 144 | * is treated as single byte input, even though the input is a 32-bit word |
AnnaBridge | 170:e95d10626187 | 145 | * or a 16-bit half word. Only the least significant byte of the data-word |
AnnaBridge | 170:e95d10626187 | 146 | * will be used for CRC calculation for all writes. |
AnnaBridge | 170:e95d10626187 | 147 | */ |
AnnaBridge | 170:e95d10626187 | 148 | bool enableByteMode; |
AnnaBridge | 170:e95d10626187 | 149 | |
AnnaBridge | 170:e95d10626187 | 150 | /** |
AnnaBridge | 170:e95d10626187 | 151 | * Enable automatic initialization by re-seeding the CRC result based on |
AnnaBridge | 170:e95d10626187 | 152 | * the init value after reading one of the CRC data registers |
AnnaBridge | 170:e95d10626187 | 153 | */ |
AnnaBridge | 170:e95d10626187 | 154 | bool autoInit; |
AnnaBridge | 170:e95d10626187 | 155 | |
AnnaBridge | 170:e95d10626187 | 156 | /** Enable/disable GPCRC when initialization is completed. */ |
AnnaBridge | 170:e95d10626187 | 157 | bool enable; |
AnnaBridge | 170:e95d10626187 | 158 | } GPCRC_Init_TypeDef; |
AnnaBridge | 170:e95d10626187 | 159 | |
AnnaBridge | 170:e95d10626187 | 160 | /** Default configuration for GPCRC_Init_TypeDef structure. */ |
AnnaBridge | 170:e95d10626187 | 161 | #define GPCRC_INIT_DEFAULT \ |
AnnaBridge | 170:e95d10626187 | 162 | { \ |
AnnaBridge | 170:e95d10626187 | 163 | 0x04C11DB7UL, /* CRC32 Polynomial value. */ \ |
AnnaBridge | 170:e95d10626187 | 164 | 0x00000000UL, /* Initialization value. */ \ |
AnnaBridge | 170:e95d10626187 | 165 | false, /* Byte order is normal. */ \ |
AnnaBridge | 170:e95d10626187 | 166 | false, /* Bit order is not reversed on output. */ \ |
AnnaBridge | 170:e95d10626187 | 167 | false, /* Disable byte mode. */ \ |
AnnaBridge | 170:e95d10626187 | 168 | false, /* Disable automatic init on data read. */ \ |
AnnaBridge | 170:e95d10626187 | 169 | true, /* Enable GPCRC. */ \ |
AnnaBridge | 170:e95d10626187 | 170 | } |
AnnaBridge | 170:e95d10626187 | 171 | |
AnnaBridge | 170:e95d10626187 | 172 | /******************************************************************************* |
AnnaBridge | 170:e95d10626187 | 173 | ****************************** PROTOTYPES ********************************* |
AnnaBridge | 170:e95d10626187 | 174 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 175 | |
AnnaBridge | 170:e95d10626187 | 176 | void GPCRC_Init(GPCRC_TypeDef * gpcrc, const GPCRC_Init_TypeDef * init); |
AnnaBridge | 170:e95d10626187 | 177 | void GPCRC_Reset(GPCRC_TypeDef * gpcrc); |
AnnaBridge | 170:e95d10626187 | 178 | |
AnnaBridge | 170:e95d10626187 | 179 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 180 | * @brief |
AnnaBridge | 170:e95d10626187 | 181 | * Enable/disable GPCRC. |
AnnaBridge | 170:e95d10626187 | 182 | * |
AnnaBridge | 170:e95d10626187 | 183 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 184 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 185 | * |
AnnaBridge | 170:e95d10626187 | 186 | * @param[in] enable |
AnnaBridge | 170:e95d10626187 | 187 | * True to enable GPCRC, false to disable. |
AnnaBridge | 170:e95d10626187 | 188 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 189 | __STATIC_INLINE void GPCRC_Enable(GPCRC_TypeDef * gpcrc, bool enable) |
AnnaBridge | 170:e95d10626187 | 190 | { |
AnnaBridge | 170:e95d10626187 | 191 | BUS_RegBitWrite(&gpcrc->CTRL, _GPCRC_CTRL_EN_SHIFT, enable); |
AnnaBridge | 170:e95d10626187 | 192 | } |
AnnaBridge | 170:e95d10626187 | 193 | |
AnnaBridge | 170:e95d10626187 | 194 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 195 | * @brief |
AnnaBridge | 170:e95d10626187 | 196 | * Issues a command to initialize the CRC calculation. |
AnnaBridge | 170:e95d10626187 | 197 | * |
AnnaBridge | 170:e95d10626187 | 198 | * @details |
AnnaBridge | 170:e95d10626187 | 199 | * This function issues the command INIT in GPCRC_CMD that initializes the |
AnnaBridge | 170:e95d10626187 | 200 | * CRC calculation by writing the initial values to the DATA register. |
AnnaBridge | 170:e95d10626187 | 201 | * |
AnnaBridge | 170:e95d10626187 | 202 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 203 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 204 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 205 | __STATIC_INLINE void GPCRC_Start(GPCRC_TypeDef * gpcrc) |
AnnaBridge | 170:e95d10626187 | 206 | { |
AnnaBridge | 170:e95d10626187 | 207 | gpcrc->CMD = GPCRC_CMD_INIT; |
AnnaBridge | 170:e95d10626187 | 208 | } |
AnnaBridge | 170:e95d10626187 | 209 | |
AnnaBridge | 170:e95d10626187 | 210 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 211 | * @brief |
AnnaBridge | 170:e95d10626187 | 212 | * Set the initialization value of the CRC. |
AnnaBridge | 170:e95d10626187 | 213 | * |
AnnaBridge | 170:e95d10626187 | 214 | * @param [in] initValue |
AnnaBridge | 170:e95d10626187 | 215 | * The value to use to initialize a CRC calculation. This value is moved into |
AnnaBridge | 170:e95d10626187 | 216 | * the data register when calling @ref GPCRC_Start |
AnnaBridge | 170:e95d10626187 | 217 | * |
AnnaBridge | 170:e95d10626187 | 218 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 219 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 220 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 221 | __STATIC_INLINE void GPCRC_InitValueSet(GPCRC_TypeDef * gpcrc, uint32_t initValue) |
AnnaBridge | 170:e95d10626187 | 222 | { |
AnnaBridge | 170:e95d10626187 | 223 | gpcrc->INIT = initValue; |
AnnaBridge | 170:e95d10626187 | 224 | } |
AnnaBridge | 170:e95d10626187 | 225 | |
AnnaBridge | 170:e95d10626187 | 226 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 227 | * @brief |
AnnaBridge | 170:e95d10626187 | 228 | * Writes a 32 bit value to the input data register of the CRC. |
AnnaBridge | 170:e95d10626187 | 229 | * |
AnnaBridge | 170:e95d10626187 | 230 | * @details |
AnnaBridge | 170:e95d10626187 | 231 | * Use this function to write a 32 bit input data to the CRC. The CRC |
AnnaBridge | 170:e95d10626187 | 232 | * calculation is based on the provided input data using the configured |
AnnaBridge | 170:e95d10626187 | 233 | * CRC polynomial. |
AnnaBridge | 170:e95d10626187 | 234 | * |
AnnaBridge | 170:e95d10626187 | 235 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 236 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 237 | * |
AnnaBridge | 170:e95d10626187 | 238 | * @param[in] data |
AnnaBridge | 170:e95d10626187 | 239 | * Data to be written to the input data register. |
AnnaBridge | 170:e95d10626187 | 240 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 241 | __STATIC_INLINE void GPCRC_InputU32(GPCRC_TypeDef * gpcrc, uint32_t data) |
AnnaBridge | 170:e95d10626187 | 242 | { |
AnnaBridge | 170:e95d10626187 | 243 | gpcrc->INPUTDATA = data; |
AnnaBridge | 170:e95d10626187 | 244 | } |
AnnaBridge | 170:e95d10626187 | 245 | |
AnnaBridge | 170:e95d10626187 | 246 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 247 | * @brief |
AnnaBridge | 170:e95d10626187 | 248 | * Writes a 16 bit value to the input data register of the CRC. |
AnnaBridge | 170:e95d10626187 | 249 | * |
AnnaBridge | 170:e95d10626187 | 250 | * @details |
AnnaBridge | 170:e95d10626187 | 251 | * Use this function to write a 16 bit input data to the CRC. The CRC |
AnnaBridge | 170:e95d10626187 | 252 | * calculation is based on the provided input data using the configured |
AnnaBridge | 170:e95d10626187 | 253 | * CRC polynomial. |
AnnaBridge | 170:e95d10626187 | 254 | * |
AnnaBridge | 170:e95d10626187 | 255 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 256 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 257 | * |
AnnaBridge | 170:e95d10626187 | 258 | * @param[in] data |
AnnaBridge | 170:e95d10626187 | 259 | * Data to be written to the input data register. |
AnnaBridge | 170:e95d10626187 | 260 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 261 | __STATIC_INLINE void GPCRC_InputU16(GPCRC_TypeDef * gpcrc, uint16_t data) |
AnnaBridge | 170:e95d10626187 | 262 | { |
AnnaBridge | 170:e95d10626187 | 263 | gpcrc->INPUTDATAHWORD = data; |
AnnaBridge | 170:e95d10626187 | 264 | } |
AnnaBridge | 170:e95d10626187 | 265 | |
AnnaBridge | 170:e95d10626187 | 266 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 267 | * @brief |
AnnaBridge | 170:e95d10626187 | 268 | * Writes an 8 bit value to the input data register of the CRC. |
AnnaBridge | 170:e95d10626187 | 269 | * |
AnnaBridge | 170:e95d10626187 | 270 | * @details |
AnnaBridge | 170:e95d10626187 | 271 | * Use this function to write a 8 bit input data to the CRC. The CRC |
AnnaBridge | 170:e95d10626187 | 272 | * calculation is based on the provided input data using the configured |
AnnaBridge | 170:e95d10626187 | 273 | * CRC polynomial. |
AnnaBridge | 170:e95d10626187 | 274 | * |
AnnaBridge | 170:e95d10626187 | 275 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 276 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 277 | * |
AnnaBridge | 170:e95d10626187 | 278 | * @param[in] data |
AnnaBridge | 170:e95d10626187 | 279 | * Data to be written to the input data register. |
AnnaBridge | 170:e95d10626187 | 280 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 281 | __STATIC_INLINE void GPCRC_InputU8(GPCRC_TypeDef * gpcrc, uint8_t data) |
AnnaBridge | 170:e95d10626187 | 282 | { |
AnnaBridge | 170:e95d10626187 | 283 | gpcrc->INPUTDATABYTE = data; |
AnnaBridge | 170:e95d10626187 | 284 | } |
AnnaBridge | 170:e95d10626187 | 285 | |
AnnaBridge | 170:e95d10626187 | 286 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 287 | * @brief |
AnnaBridge | 170:e95d10626187 | 288 | * Reads the data register of the CRC. |
AnnaBridge | 170:e95d10626187 | 289 | * |
AnnaBridge | 170:e95d10626187 | 290 | * @details |
AnnaBridge | 170:e95d10626187 | 291 | * Use this function to read the calculated CRC value. |
AnnaBridge | 170:e95d10626187 | 292 | * |
AnnaBridge | 170:e95d10626187 | 293 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 294 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 295 | * |
AnnaBridge | 170:e95d10626187 | 296 | * @return |
AnnaBridge | 170:e95d10626187 | 297 | * Content of the CRC data register. |
AnnaBridge | 170:e95d10626187 | 298 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 299 | __STATIC_INLINE uint32_t GPCRC_DataRead(GPCRC_TypeDef * gpcrc) |
AnnaBridge | 170:e95d10626187 | 300 | { |
AnnaBridge | 170:e95d10626187 | 301 | return gpcrc->DATA; |
AnnaBridge | 170:e95d10626187 | 302 | } |
AnnaBridge | 170:e95d10626187 | 303 | |
AnnaBridge | 170:e95d10626187 | 304 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 305 | * @brief |
AnnaBridge | 170:e95d10626187 | 306 | * Reads the data register of the CRC bit reversed. |
AnnaBridge | 170:e95d10626187 | 307 | * |
AnnaBridge | 170:e95d10626187 | 308 | * @details |
AnnaBridge | 170:e95d10626187 | 309 | * Use this function to read the calculated CRC value bit reversed. When |
AnnaBridge | 170:e95d10626187 | 310 | * using a 32-bit polynomial then bits [31:0] are reversed, when using a |
AnnaBridge | 170:e95d10626187 | 311 | * 16-bit polynomial then bits [15:0] are reversed. |
AnnaBridge | 170:e95d10626187 | 312 | * |
AnnaBridge | 170:e95d10626187 | 313 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 314 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 315 | * |
AnnaBridge | 170:e95d10626187 | 316 | * @return |
AnnaBridge | 170:e95d10626187 | 317 | * Content of the CRC data register bit reversed. |
AnnaBridge | 170:e95d10626187 | 318 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 319 | __STATIC_INLINE uint32_t GPCRC_DataReadBitReversed(GPCRC_TypeDef * gpcrc) |
AnnaBridge | 170:e95d10626187 | 320 | { |
AnnaBridge | 170:e95d10626187 | 321 | return gpcrc->DATAREV; |
AnnaBridge | 170:e95d10626187 | 322 | } |
AnnaBridge | 170:e95d10626187 | 323 | |
AnnaBridge | 170:e95d10626187 | 324 | /***************************************************************************//** |
AnnaBridge | 170:e95d10626187 | 325 | * @brief |
AnnaBridge | 170:e95d10626187 | 326 | * Reads the data register of the CRC byte reversed. |
AnnaBridge | 170:e95d10626187 | 327 | * |
AnnaBridge | 170:e95d10626187 | 328 | * @details |
AnnaBridge | 170:e95d10626187 | 329 | * Use this function to read the calculated CRC value byte reversed. |
AnnaBridge | 170:e95d10626187 | 330 | * |
AnnaBridge | 170:e95d10626187 | 331 | * @param[in] gpcrc |
AnnaBridge | 170:e95d10626187 | 332 | * Pointer to GPCRC peripheral register block. |
AnnaBridge | 170:e95d10626187 | 333 | * |
AnnaBridge | 170:e95d10626187 | 334 | * @return |
AnnaBridge | 170:e95d10626187 | 335 | * Content of the CRC data register byte reversed. |
AnnaBridge | 170:e95d10626187 | 336 | ******************************************************************************/ |
AnnaBridge | 170:e95d10626187 | 337 | __STATIC_INLINE uint32_t GPCRC_DataReadByteReversed(GPCRC_TypeDef * gpcrc) |
AnnaBridge | 170:e95d10626187 | 338 | { |
AnnaBridge | 170:e95d10626187 | 339 | return gpcrc->DATABYTEREV; |
AnnaBridge | 170:e95d10626187 | 340 | } |
AnnaBridge | 170:e95d10626187 | 341 | |
AnnaBridge | 170:e95d10626187 | 342 | /** @} (end addtogroup GPCRC) */ |
AnnaBridge | 170:e95d10626187 | 343 | /** @} (end addtogroup emlib) */ |
AnnaBridge | 170:e95d10626187 | 344 | |
AnnaBridge | 170:e95d10626187 | 345 | #ifdef __cplusplus |
AnnaBridge | 170:e95d10626187 | 346 | } |
AnnaBridge | 170:e95d10626187 | 347 | #endif |
AnnaBridge | 170:e95d10626187 | 348 | |
AnnaBridge | 170:e95d10626187 | 349 | #endif /* defined(GPCRC_COUNT) && (GPCRC_COUNT > 0) */ |
AnnaBridge | 170:e95d10626187 | 350 | #endif /* EM_GPCRC_H */ |