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