mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins
Fork of mbed-dev by
targets/TARGET_Maxim/TARGET_MAX32620C/mxc/crc.c@188:3f10722804f9, 2018-07-30 (annotated)
- Committer:
- ua1arn
- Date:
- Mon Jul 30 12:31:10 2018 +0000
- Revision:
- 188:3f10722804f9
- Parent:
- 186:707f6e361f3e
before add multi-configuration USB descriptors
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
186:707f6e361f3e | 1 | /** |
Anna Bridge |
186:707f6e361f3e | 2 | * @file |
Anna Bridge |
186:707f6e361f3e | 3 | * @brief This file contains the function implementations for the Cyclic |
Anna Bridge |
186:707f6e361f3e | 4 | * Redundency Check (CRC) peripheral module. |
Anna Bridge |
186:707f6e361f3e | 5 | */ |
Anna Bridge |
186:707f6e361f3e | 6 | |
Anna Bridge |
186:707f6e361f3e | 7 | /* **************************************************************************** |
Anna Bridge |
186:707f6e361f3e | 8 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
186:707f6e361f3e | 9 | * |
Anna Bridge |
186:707f6e361f3e | 10 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
186:707f6e361f3e | 11 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
186:707f6e361f3e | 12 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
186:707f6e361f3e | 13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
186:707f6e361f3e | 14 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
186:707f6e361f3e | 15 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
186:707f6e361f3e | 16 | * |
Anna Bridge |
186:707f6e361f3e | 17 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
186:707f6e361f3e | 18 | * in all copies or substantial portions of the Software. |
Anna Bridge |
186:707f6e361f3e | 19 | * |
Anna Bridge |
186:707f6e361f3e | 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
186:707f6e361f3e | 21 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
186:707f6e361f3e | 22 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
186:707f6e361f3e | 23 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
186:707f6e361f3e | 24 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
186:707f6e361f3e | 25 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
186:707f6e361f3e | 26 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
186:707f6e361f3e | 27 | * |
Anna Bridge |
186:707f6e361f3e | 28 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 29 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
186:707f6e361f3e | 30 | * Products, Inc. Branding Policy. |
Anna Bridge |
186:707f6e361f3e | 31 | * |
Anna Bridge |
186:707f6e361f3e | 32 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
186:707f6e361f3e | 33 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
186:707f6e361f3e | 34 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
186:707f6e361f3e | 35 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
186:707f6e361f3e | 36 | * ownership rights. |
Anna Bridge |
186:707f6e361f3e | 37 | * |
Anna Bridge |
186:707f6e361f3e | 38 | * $Date: 2016-09-09 11:49:04 -0500 (Fri, 09 Sep 2016) $ |
Anna Bridge |
186:707f6e361f3e | 39 | * $Revision: 24339 $ |
Anna Bridge |
186:707f6e361f3e | 40 | * |
Anna Bridge |
186:707f6e361f3e | 41 | *************************************************************************** */ |
Anna Bridge |
186:707f6e361f3e | 42 | |
Anna Bridge |
186:707f6e361f3e | 43 | /* **** Includes **** */ |
Anna Bridge |
186:707f6e361f3e | 44 | #include "crc.h" |
Anna Bridge |
186:707f6e361f3e | 45 | |
Anna Bridge |
186:707f6e361f3e | 46 | /** |
Anna Bridge |
186:707f6e361f3e | 47 | * @ingroup crc |
Anna Bridge |
186:707f6e361f3e | 48 | * @{ |
Anna Bridge |
186:707f6e361f3e | 49 | */ |
Anna Bridge |
186:707f6e361f3e | 50 | |
Anna Bridge |
186:707f6e361f3e | 51 | /* **** Definitions **** */ |
Anna Bridge |
186:707f6e361f3e | 52 | |
Anna Bridge |
186:707f6e361f3e | 53 | /* **** Globals **** */ |
Anna Bridge |
186:707f6e361f3e | 54 | |
Anna Bridge |
186:707f6e361f3e | 55 | /* **** Functions **** */ |
Anna Bridge |
186:707f6e361f3e | 56 | |
Anna Bridge |
186:707f6e361f3e | 57 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 58 | void CRC16_Init(uint8_t CCITT_TRUE, uint8_t lilEndian) |
Anna Bridge |
186:707f6e361f3e | 59 | { |
Anna Bridge |
186:707f6e361f3e | 60 | if(CCITT_TRUE) |
Anna Bridge |
186:707f6e361f3e | 61 | MXC_CRC->reseed |= MXC_F_CRC_RESEED_CCITT_MODE; |
Anna Bridge |
186:707f6e361f3e | 62 | else |
Anna Bridge |
186:707f6e361f3e | 63 | MXC_CRC->reseed &= ~MXC_F_CRC_RESEED_CCITT_MODE; |
Anna Bridge |
186:707f6e361f3e | 64 | |
Anna Bridge |
186:707f6e361f3e | 65 | if(lilEndian) |
Anna Bridge |
186:707f6e361f3e | 66 | MXC_CRC->reseed |= MXC_F_CRC_RESEED_REV_ENDIAN16; |
Anna Bridge |
186:707f6e361f3e | 67 | else |
Anna Bridge |
186:707f6e361f3e | 68 | MXC_CRC->reseed &= ~MXC_F_CRC_RESEED_REV_ENDIAN16; |
Anna Bridge |
186:707f6e361f3e | 69 | } |
Anna Bridge |
186:707f6e361f3e | 70 | |
Anna Bridge |
186:707f6e361f3e | 71 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 72 | void CRC32_Init(uint8_t lilEndian) |
Anna Bridge |
186:707f6e361f3e | 73 | { |
Anna Bridge |
186:707f6e361f3e | 74 | if(lilEndian) |
Anna Bridge |
186:707f6e361f3e | 75 | MXC_CRC->reseed |= MXC_F_CRC_RESEED_REV_ENDIAN32; |
Anna Bridge |
186:707f6e361f3e | 76 | else |
Anna Bridge |
186:707f6e361f3e | 77 | MXC_CRC->reseed &= ~MXC_F_CRC_RESEED_REV_ENDIAN32; |
Anna Bridge |
186:707f6e361f3e | 78 | } |
Anna Bridge |
186:707f6e361f3e | 79 | |
Anna Bridge |
186:707f6e361f3e | 80 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 81 | |
Anna Bridge |
186:707f6e361f3e | 82 | void CRC16_Reseed(uint16_t initData) |
Anna Bridge |
186:707f6e361f3e | 83 | { |
Anna Bridge |
186:707f6e361f3e | 84 | //set initial value |
Anna Bridge |
186:707f6e361f3e | 85 | MXC_CRC->seed16 = initData; |
Anna Bridge |
186:707f6e361f3e | 86 | |
Anna Bridge |
186:707f6e361f3e | 87 | //reseed the CRC16 generator |
Anna Bridge |
186:707f6e361f3e | 88 | MXC_CRC->reseed |= MXC_F_CRC_RESEED_CRC16; |
Anna Bridge |
186:707f6e361f3e | 89 | |
Anna Bridge |
186:707f6e361f3e | 90 | //wait for reseed to clear itself |
Anna Bridge |
186:707f6e361f3e | 91 | while(MXC_CRC->reseed & MXC_F_CRC_RESEED_CRC16); |
Anna Bridge |
186:707f6e361f3e | 92 | |
Anna Bridge |
186:707f6e361f3e | 93 | } |
Anna Bridge |
186:707f6e361f3e | 94 | |
Anna Bridge |
186:707f6e361f3e | 95 | /* ************************************************************************* */ |
Anna Bridge |
186:707f6e361f3e | 96 | void CRC32_Reseed(uint32_t initData) |
Anna Bridge |
186:707f6e361f3e | 97 | { |
Anna Bridge |
186:707f6e361f3e | 98 | //set initial value |
Anna Bridge |
186:707f6e361f3e | 99 | MXC_CRC->seed32 = initData; |
Anna Bridge |
186:707f6e361f3e | 100 | |
Anna Bridge |
186:707f6e361f3e | 101 | //reseed the CRC16 generator |
Anna Bridge |
186:707f6e361f3e | 102 | MXC_CRC->reseed |= MXC_F_CRC_RESEED_CRC32; |
Anna Bridge |
186:707f6e361f3e | 103 | |
Anna Bridge |
186:707f6e361f3e | 104 | //wait for reseed to clear itself |
Anna Bridge |
186:707f6e361f3e | 105 | while(MXC_CRC->reseed & MXC_F_CRC_RESEED_CRC32); |
Anna Bridge |
186:707f6e361f3e | 106 | } |
Anna Bridge |
186:707f6e361f3e | 107 | |
Anna Bridge |
186:707f6e361f3e | 108 | /**@} end of group crc */ |