stm32f10x_crc.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f10x_crc.c
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   This file provides all the CRC firmware functions.
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00019   */ 
00020 
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "stm32f10x_crc.h"
00023 
00024 /** @addtogroup STM32F10x_StdPeriph_Driver
00025   * @{
00026   */
00027 
00028 /** @defgroup CRC 
00029   * @brief CRC driver modules
00030   * @{
00031   */
00032 
00033 /** @defgroup CRC_Private_TypesDefinitions
00034   * @{
00035   */
00036 
00037 /**
00038   * @}
00039   */
00040 
00041 /** @defgroup CRC_Private_Defines
00042   * @{
00043   */
00044 
00045 /**
00046   * @}
00047   */
00048 
00049 /** @defgroup CRC_Private_Macros
00050   * @{
00051   */
00052 
00053 /**
00054   * @}
00055   */
00056 
00057 /** @defgroup CRC_Private_Variables
00058   * @{
00059   */
00060 
00061 /**
00062   * @}
00063   */
00064 
00065 /** @defgroup CRC_Private_FunctionPrototypes
00066   * @{
00067   */
00068 
00069 /**
00070   * @}
00071   */
00072 
00073 /** @defgroup CRC_Private_Functions
00074   * @{
00075   */
00076 
00077 /**
00078   * @brief  Resets the CRC Data register (DR).
00079   * @param  None
00080   * @retval None
00081   */
00082 void CRC_ResetDR(void)
00083 {
00084   /* Reset CRC generator */
00085   CRC->CR = CRC_CR_RESET;
00086 }
00087 
00088 /**
00089   * @brief  Computes the 32-bit CRC of a given data word(32-bit).
00090   * @param  Data: data word(32-bit) to compute its CRC
00091   * @retval 32-bit CRC
00092   */
00093 uint32_t CRC_CalcCRC(uint32_t Data)
00094 {
00095   CRC->DR = Data;
00096   
00097   return (CRC->DR);
00098 }
00099 
00100 /**
00101   * @brief  Computes the 32-bit CRC of a given buffer of data word(32-bit).
00102   * @param  pBuffer: pointer to the buffer containing the data to be computed
00103   * @param  BufferLength: length of the buffer to be computed                                   
00104   * @retval 32-bit CRC
00105   */
00106 uint32_t CRC_CalcBlockCRC(uint32_t pBuffer[], uint32_t BufferLength)
00107 {
00108   uint32_t index = 0;
00109   
00110   for(index = 0; index < BufferLength; index++)
00111   {
00112     CRC->DR = pBuffer[index];
00113   }
00114   return (CRC->DR);
00115 }
00116 
00117 /**
00118   * @brief  Returns the current CRC value.
00119   * @param  None
00120   * @retval 32-bit CRC
00121   */
00122 uint32_t CRC_GetCRC(void)
00123 {
00124   return (CRC->DR);
00125 }
00126 
00127 /**
00128   * @brief  Stores a 8-bit data in the Independent Data(ID) register.
00129   * @param  IDValue: 8-bit value to be stored in the ID register                                        
00130   * @retval None
00131   */
00132 void CRC_SetIDRegister(uint8_t IDValue)
00133 {
00134   CRC->IDR = IDValue;
00135 }
00136 
00137 /**
00138   * @brief  Returns the 8-bit data stored in the Independent Data(ID) register
00139   * @param  None
00140   * @retval 8-bit value of the ID register 
00141   */
00142 uint8_t CRC_GetIDRegister(void)
00143 {
00144   return (CRC->IDR);
00145 }
00146 
00147 /**
00148   * @}
00149   */
00150 
00151 /**
00152   * @}
00153   */
00154 
00155 /**
00156   * @}
00157   */
00158 
00159 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32