at32f425_crc.h 4.1 KB

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