mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_crc.c@52:a51c77007319, 2013-12-02 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 02 11:30:05 2013 +0000
- Revision:
- 52:a51c77007319
- Child:
- 70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd
Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/
Add STMicroelectronics NUCLEO_F103RB target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 52:a51c77007319 | 1 | /** |
mbed_official | 52:a51c77007319 | 2 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 3 | * @file stm32f10x_crc.c |
mbed_official | 52:a51c77007319 | 4 | * @author MCD Application Team |
mbed_official | 52:a51c77007319 | 5 | * @version V3.5.0 |
mbed_official | 52:a51c77007319 | 6 | * @date 11-March-2011 |
mbed_official | 52:a51c77007319 | 7 | * @brief This file provides all the CRC firmware functions. |
mbed_official | 52:a51c77007319 | 8 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 9 | * @attention |
mbed_official | 52:a51c77007319 | 10 | * |
mbed_official | 52:a51c77007319 | 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mbed_official | 52:a51c77007319 | 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
mbed_official | 52:a51c77007319 | 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
mbed_official | 52:a51c77007319 | 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
mbed_official | 52:a51c77007319 | 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
mbed_official | 52:a51c77007319 | 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mbed_official | 52:a51c77007319 | 17 | * |
mbed_official | 52:a51c77007319 | 18 | * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> |
mbed_official | 52:a51c77007319 | 19 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 20 | */ |
mbed_official | 52:a51c77007319 | 21 | |
mbed_official | 52:a51c77007319 | 22 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 52:a51c77007319 | 23 | #include "stm32f10x_crc.h" |
mbed_official | 52:a51c77007319 | 24 | |
mbed_official | 52:a51c77007319 | 25 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 52:a51c77007319 | 26 | * @{ |
mbed_official | 52:a51c77007319 | 27 | */ |
mbed_official | 52:a51c77007319 | 28 | |
mbed_official | 52:a51c77007319 | 29 | /** @defgroup CRC |
mbed_official | 52:a51c77007319 | 30 | * @brief CRC driver modules |
mbed_official | 52:a51c77007319 | 31 | * @{ |
mbed_official | 52:a51c77007319 | 32 | */ |
mbed_official | 52:a51c77007319 | 33 | |
mbed_official | 52:a51c77007319 | 34 | /** @defgroup CRC_Private_TypesDefinitions |
mbed_official | 52:a51c77007319 | 35 | * @{ |
mbed_official | 52:a51c77007319 | 36 | */ |
mbed_official | 52:a51c77007319 | 37 | |
mbed_official | 52:a51c77007319 | 38 | /** |
mbed_official | 52:a51c77007319 | 39 | * @} |
mbed_official | 52:a51c77007319 | 40 | */ |
mbed_official | 52:a51c77007319 | 41 | |
mbed_official | 52:a51c77007319 | 42 | /** @defgroup CRC_Private_Defines |
mbed_official | 52:a51c77007319 | 43 | * @{ |
mbed_official | 52:a51c77007319 | 44 | */ |
mbed_official | 52:a51c77007319 | 45 | |
mbed_official | 52:a51c77007319 | 46 | /** |
mbed_official | 52:a51c77007319 | 47 | * @} |
mbed_official | 52:a51c77007319 | 48 | */ |
mbed_official | 52:a51c77007319 | 49 | |
mbed_official | 52:a51c77007319 | 50 | /** @defgroup CRC_Private_Macros |
mbed_official | 52:a51c77007319 | 51 | * @{ |
mbed_official | 52:a51c77007319 | 52 | */ |
mbed_official | 52:a51c77007319 | 53 | |
mbed_official | 52:a51c77007319 | 54 | /** |
mbed_official | 52:a51c77007319 | 55 | * @} |
mbed_official | 52:a51c77007319 | 56 | */ |
mbed_official | 52:a51c77007319 | 57 | |
mbed_official | 52:a51c77007319 | 58 | /** @defgroup CRC_Private_Variables |
mbed_official | 52:a51c77007319 | 59 | * @{ |
mbed_official | 52:a51c77007319 | 60 | */ |
mbed_official | 52:a51c77007319 | 61 | |
mbed_official | 52:a51c77007319 | 62 | /** |
mbed_official | 52:a51c77007319 | 63 | * @} |
mbed_official | 52:a51c77007319 | 64 | */ |
mbed_official | 52:a51c77007319 | 65 | |
mbed_official | 52:a51c77007319 | 66 | /** @defgroup CRC_Private_FunctionPrototypes |
mbed_official | 52:a51c77007319 | 67 | * @{ |
mbed_official | 52:a51c77007319 | 68 | */ |
mbed_official | 52:a51c77007319 | 69 | |
mbed_official | 52:a51c77007319 | 70 | /** |
mbed_official | 52:a51c77007319 | 71 | * @} |
mbed_official | 52:a51c77007319 | 72 | */ |
mbed_official | 52:a51c77007319 | 73 | |
mbed_official | 52:a51c77007319 | 74 | /** @defgroup CRC_Private_Functions |
mbed_official | 52:a51c77007319 | 75 | * @{ |
mbed_official | 52:a51c77007319 | 76 | */ |
mbed_official | 52:a51c77007319 | 77 | |
mbed_official | 52:a51c77007319 | 78 | /** |
mbed_official | 52:a51c77007319 | 79 | * @brief Resets the CRC Data register (DR). |
mbed_official | 52:a51c77007319 | 80 | * @param None |
mbed_official | 52:a51c77007319 | 81 | * @retval None |
mbed_official | 52:a51c77007319 | 82 | */ |
mbed_official | 52:a51c77007319 | 83 | void CRC_ResetDR(void) |
mbed_official | 52:a51c77007319 | 84 | { |
mbed_official | 52:a51c77007319 | 85 | /* Reset CRC generator */ |
mbed_official | 52:a51c77007319 | 86 | CRC->CR = CRC_CR_RESET; |
mbed_official | 52:a51c77007319 | 87 | } |
mbed_official | 52:a51c77007319 | 88 | |
mbed_official | 52:a51c77007319 | 89 | /** |
mbed_official | 52:a51c77007319 | 90 | * @brief Computes the 32-bit CRC of a given data word(32-bit). |
mbed_official | 52:a51c77007319 | 91 | * @param Data: data word(32-bit) to compute its CRC |
mbed_official | 52:a51c77007319 | 92 | * @retval 32-bit CRC |
mbed_official | 52:a51c77007319 | 93 | */ |
mbed_official | 52:a51c77007319 | 94 | uint32_t CRC_CalcCRC(uint32_t Data) |
mbed_official | 52:a51c77007319 | 95 | { |
mbed_official | 52:a51c77007319 | 96 | CRC->DR = Data; |
mbed_official | 52:a51c77007319 | 97 | |
mbed_official | 52:a51c77007319 | 98 | return (CRC->DR); |
mbed_official | 52:a51c77007319 | 99 | } |
mbed_official | 52:a51c77007319 | 100 | |
mbed_official | 52:a51c77007319 | 101 | /** |
mbed_official | 52:a51c77007319 | 102 | * @brief Computes the 32-bit CRC of a given buffer of data word(32-bit). |
mbed_official | 52:a51c77007319 | 103 | * @param pBuffer: pointer to the buffer containing the data to be computed |
mbed_official | 52:a51c77007319 | 104 | * @param BufferLength: length of the buffer to be computed |
mbed_official | 52:a51c77007319 | 105 | * @retval 32-bit CRC |
mbed_official | 52:a51c77007319 | 106 | */ |
mbed_official | 52:a51c77007319 | 107 | uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength) |
mbed_official | 52:a51c77007319 | 108 | { |
mbed_official | 52:a51c77007319 | 109 | uint32_t index = 0; |
mbed_official | 52:a51c77007319 | 110 | |
mbed_official | 52:a51c77007319 | 111 | for(index = 0; index < BufferLength; index++) |
mbed_official | 52:a51c77007319 | 112 | { |
mbed_official | 52:a51c77007319 | 113 | CRC->DR = pBuffer[index]; |
mbed_official | 52:a51c77007319 | 114 | } |
mbed_official | 52:a51c77007319 | 115 | return (CRC->DR); |
mbed_official | 52:a51c77007319 | 116 | } |
mbed_official | 52:a51c77007319 | 117 | |
mbed_official | 52:a51c77007319 | 118 | /** |
mbed_official | 52:a51c77007319 | 119 | * @brief Returns the current CRC value. |
mbed_official | 52:a51c77007319 | 120 | * @param None |
mbed_official | 52:a51c77007319 | 121 | * @retval 32-bit CRC |
mbed_official | 52:a51c77007319 | 122 | */ |
mbed_official | 52:a51c77007319 | 123 | uint32_t CRC_GetCRC(void) |
mbed_official | 52:a51c77007319 | 124 | { |
mbed_official | 52:a51c77007319 | 125 | return (CRC->DR); |
mbed_official | 52:a51c77007319 | 126 | } |
mbed_official | 52:a51c77007319 | 127 | |
mbed_official | 52:a51c77007319 | 128 | /** |
mbed_official | 52:a51c77007319 | 129 | * @brief Stores a 8-bit data in the Independent Data(ID) register. |
mbed_official | 52:a51c77007319 | 130 | * @param IDValue: 8-bit value to be stored in the ID register |
mbed_official | 52:a51c77007319 | 131 | * @retval None |
mbed_official | 52:a51c77007319 | 132 | */ |
mbed_official | 52:a51c77007319 | 133 | void CRC_SetIDRegister(uint8_t IDValue) |
mbed_official | 52:a51c77007319 | 134 | { |
mbed_official | 52:a51c77007319 | 135 | CRC->IDR = IDValue; |
mbed_official | 52:a51c77007319 | 136 | } |
mbed_official | 52:a51c77007319 | 137 | |
mbed_official | 52:a51c77007319 | 138 | /** |
mbed_official | 52:a51c77007319 | 139 | * @brief Returns the 8-bit data stored in the Independent Data(ID) register |
mbed_official | 52:a51c77007319 | 140 | * @param None |
mbed_official | 52:a51c77007319 | 141 | * @retval 8-bit value of the ID register |
mbed_official | 52:a51c77007319 | 142 | */ |
mbed_official | 52:a51c77007319 | 143 | uint8_t CRC_GetIDRegister(void) |
mbed_official | 52:a51c77007319 | 144 | { |
mbed_official | 52:a51c77007319 | 145 | return (CRC->IDR); |
mbed_official | 52:a51c77007319 | 146 | } |
mbed_official | 52:a51c77007319 | 147 | |
mbed_official | 52:a51c77007319 | 148 | /** |
mbed_official | 52:a51c77007319 | 149 | * @} |
mbed_official | 52:a51c77007319 | 150 | */ |
mbed_official | 52:a51c77007319 | 151 | |
mbed_official | 52:a51c77007319 | 152 | /** |
mbed_official | 52:a51c77007319 | 153 | * @} |
mbed_official | 52:a51c77007319 | 154 | */ |
mbed_official | 52:a51c77007319 | 155 | |
mbed_official | 52:a51c77007319 | 156 | /** |
mbed_official | 52:a51c77007319 | 157 | * @} |
mbed_official | 52:a51c77007319 | 158 | */ |
mbed_official | 52:a51c77007319 | 159 | |
mbed_official | 52:a51c77007319 | 160 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ |