stm32f3xx_ll_crc.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_ll_crc.c
  4. * @author MCD Application Team
  5. * @brief CRC LL module driver.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. #if defined(USE_FULL_LL_DRIVER)
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "stm32f3xx_ll_crc.h"
  38. #ifdef USE_FULL_ASSERT
  39. #include "stm32_assert.h"
  40. #else
  41. #define assert_param(expr) ((void)0U)
  42. #endif
  43. /** @addtogroup STM32F3xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (CRC)
  47. /** @addtogroup CRC_LL
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /* Private function prototypes -----------------------------------------------*/
  55. /* Exported functions --------------------------------------------------------*/
  56. /** @addtogroup CRC_LL_Exported_Functions
  57. * @{
  58. */
  59. /** @addtogroup CRC_LL_EF_Init
  60. * @{
  61. */
  62. /**
  63. * @brief De-initialize CRC registers (Registers restored to their default values).
  64. * @param CRCx CRC Instance
  65. * @retval An ErrorStatus enumeration value:
  66. * - SUCCESS: CRC registers are de-initialized
  67. * - ERROR: CRC registers are not de-initialized
  68. */
  69. ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
  70. {
  71. ErrorStatus status = SUCCESS;
  72. /* Check the parameters */
  73. assert_param(IS_CRC_ALL_INSTANCE(CRCx));
  74. if (CRCx == CRC)
  75. {
  76. /* Set programmable polynomial size in CR register to reset value (32 bits)*/
  77. LL_CRC_SetPolynomialSize(CRCx, LL_CRC_POLYLENGTH_32B);
  78. /* Set programmable polynomial in POL register to reset value */
  79. LL_CRC_SetPolynomialCoef(CRCx, LL_CRC_DEFAULT_CRC32_POLY);
  80. /* Set INIT register to reset value */
  81. LL_CRC_SetInitialData(CRCx, LL_CRC_DEFAULT_CRC_INITVALUE);
  82. /* Set Reversibility options on I/O data values in CR register to reset value */
  83. LL_CRC_SetInputDataReverseMode(CRCx, LL_CRC_INDATA_REVERSE_NONE);
  84. LL_CRC_SetOutputDataReverseMode(CRCx, LL_CRC_OUTDATA_REVERSE_NONE);
  85. /* Reset the CRC calculation unit */
  86. LL_CRC_ResetCRCCalculationUnit(CRCx);
  87. /* Reset IDR register */
  88. LL_CRC_Write_IDR(CRCx, 0x00U);
  89. }
  90. else
  91. {
  92. status = ERROR;
  93. }
  94. return (status);
  95. }
  96. /**
  97. * @}
  98. */
  99. /**
  100. * @}
  101. */
  102. /**
  103. * @}
  104. */
  105. #endif /* defined (CRC) */
  106. /**
  107. * @}
  108. */
  109. #endif /* USE_FULL_LL_DRIVER */
  110. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/