at32f413_crc.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. **************************************************************************
  3. * @file at32f413_crc.h
  4. * @version v2.0.5
  5. * @date 2022-05-20
  6. * @brief at32f413 crc header file
  7. **************************************************************************
  8. * Copyright notice & Disclaimer
  9. *
  10. * The software Board Support Package (BSP) that is made available to
  11. * download from Artery official website is the copyrighted work of Artery.
  12. * Artery authorizes customers to use, copy, and distribute the BSP
  13. * software and its related documentation for the purpose of design and
  14. * development in conjunction with Artery microcontrollers. Use of the
  15. * software is governed by this copyright notice and the following disclaimer.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  18. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  19. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  20. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  21. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  23. *
  24. **************************************************************************
  25. */
  26. /* define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __AT32F413_CRC_H
  28. #define __AT32F413_CRC_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* includes ------------------------------------------------------------------*/
  33. #include "at32f413.h"
  34. /** @addtogroup AT32F413_periph_driver
  35. * @{
  36. */
  37. /** @addtogroup CRC
  38. * @{
  39. */
  40. /** @defgroup CRC_exported_types
  41. * @{
  42. */
  43. /**
  44. * @brief crc reverse input data
  45. */
  46. typedef enum
  47. {
  48. CRC_REVERSE_INPUT_NO_AFFECTE = 0x00, /*!< input data no reverse */
  49. CRC_REVERSE_INPUT_BY_BYTE = 0x01, /*!< input data reverse by byte */
  50. CRC_REVERSE_INPUT_BY_HALFWORD = 0x02, /*!< input data reverse by half word */
  51. CRC_REVERSE_INPUT_BY_WORD = 0x03 /*!< input data reverse by word */
  52. } crc_reverse_input_type;
  53. /**
  54. * @brief crc reverse output data
  55. */
  56. typedef enum
  57. {
  58. CRC_REVERSE_OUTPUT_NO_AFFECTE = 0x00, /*!< output data no reverse */
  59. CRC_REVERSE_OUTPUT_DATA = 0x01 /*!< output data reverse by word */
  60. } crc_reverse_output_type;
  61. /**
  62. * @brief type define crc register all
  63. */
  64. typedef struct
  65. {
  66. /**
  67. * @brief crc dt register, offset:0x00
  68. */
  69. union
  70. {
  71. __IO uint32_t dt;
  72. struct
  73. {
  74. __IO uint32_t dt : 32; /* [31:0] */
  75. } dt_bit;
  76. };
  77. /**
  78. * @brief crc cdt register, offset:0x04
  79. */
  80. union
  81. {
  82. __IO uint32_t cdt;
  83. struct
  84. {
  85. __IO uint32_t cdt : 8 ; /* [7:0] */
  86. __IO uint32_t reserved1 : 24 ;/* [31:8] */
  87. } cdt_bit;
  88. };
  89. /**
  90. * @brief crc ctrl register, offset:0x08
  91. */
  92. union
  93. {
  94. __IO uint32_t ctrl;
  95. struct
  96. {
  97. __IO uint32_t rst : 1 ; /* [0] */
  98. __IO uint32_t reserved1 : 4 ; /* [4:1] */
  99. __IO uint32_t revid : 2 ; /* [6:5] */
  100. __IO uint32_t revod : 1 ; /* [7] */
  101. __IO uint32_t reserved2 : 24 ;/* [31:8] */
  102. } ctrl_bit;
  103. };
  104. /**
  105. * @brief crm reserved1 register, offset:0x0C
  106. */
  107. __IO uint32_t reserved1;
  108. /**
  109. * @brief crc idt register, offset:0x10
  110. */
  111. union
  112. {
  113. __IO uint32_t idt;
  114. struct
  115. {
  116. __IO uint32_t idt : 32; /* [31:0] */
  117. } idt_bit;
  118. };
  119. } crc_type;
  120. /**
  121. * @}
  122. */
  123. #define CRC ((crc_type *) CRC_BASE)
  124. /** @defgroup CRC_exported_functions
  125. * @{
  126. */
  127. void crc_data_reset(void);
  128. uint32_t crc_one_word_calculate(uint32_t data);
  129. uint32_t crc_block_calculate(uint32_t *pbuffer, uint32_t length);
  130. uint32_t crc_data_get(void);
  131. void crc_common_data_set(uint8_t cdt_value);
  132. uint8_t crc_common_date_get(void);
  133. void crc_init_data_set(uint32_t value);
  134. void crc_reverse_input_data_set(crc_reverse_input_type value);
  135. void crc_reverse_output_data_set(crc_reverse_output_type value);
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /**
  143. * @}
  144. */
  145. #ifdef __cplusplus
  146. }
  147. #endif
  148. #endif