at32f413_acc.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /**
  2. **************************************************************************
  3. * @file at32f413_acc.h
  4. * @version v2.0.5
  5. * @date 2022-05-20
  6. * @brief at32f413 acc 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_ACC_H
  28. #define __AT32F413_ACC_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* Includes ------------------------------------------------------------------*/
  33. #include "at32f413.h"
  34. /** @addtogroup AT32F413_periph_driver
  35. * @{
  36. */
  37. /** @addtogroup ACC
  38. * @{
  39. */
  40. /** @defgroup ACC_exported_constants
  41. * @{
  42. */
  43. #define ACC_CAL_HICKCAL ((uint16_t)0x0000) /*!< acc hick calibration */
  44. #define ACC_CAL_HICKTRIM ((uint16_t)0x0002) /*!< acc hick trim */
  45. #define ACC_RSLOST_FLAG ((uint16_t)0x0002) /*!< acc reference signal lost error flag */
  46. #define ACC_CALRDY_FLAG ((uint16_t)0x0001) /*!< acc internal high-speed clock calibration ready error flag */
  47. #define ACC_CALRDYIEN_INT ((uint16_t)0x0020) /*!< acc internal high-speed clock calibration ready interrupt enable */
  48. #define ACC_EIEN_INT ((uint16_t)0x0010) /*!< acc reference signal lost interrupt enable */
  49. /**
  50. * @}
  51. */
  52. /** @defgroup ACC_exported_types
  53. * @{
  54. */
  55. /**
  56. * @brief type define acc register all
  57. */
  58. typedef struct
  59. {
  60. /**
  61. * @brief acc sts register, offset:0x00
  62. */
  63. union
  64. {
  65. __IO uint32_t sts;
  66. struct
  67. {
  68. __IO uint32_t calrdy : 1; /* [0] */
  69. __IO uint32_t rslost : 1; /* [1] */
  70. __IO uint32_t reserved1 : 30;/* [31:2] */
  71. } sts_bit;
  72. };
  73. /**
  74. * @brief acc ctrl1 register, offset:0x04
  75. */
  76. union
  77. {
  78. __IO uint32_t ctrl1;
  79. struct
  80. {
  81. __IO uint32_t calon : 1; /* [0] */
  82. __IO uint32_t entrim : 1; /* [1] */
  83. __IO uint32_t reserved1 : 2; /* [3:2] */
  84. __IO uint32_t eien : 1; /* [4] */
  85. __IO uint32_t calrdyien : 1; /* [5] */
  86. __IO uint32_t reserved2 : 2; /* [7:6] */
  87. __IO uint32_t step : 4; /* [11:8] */
  88. __IO uint32_t reserved3 : 20;/* [31:12] */
  89. } ctrl1_bit;
  90. };
  91. /**
  92. * @brief acc ctrl2 register, offset:0x08
  93. */
  94. union
  95. {
  96. __IO uint32_t ctrl2;
  97. struct
  98. {
  99. __IO uint32_t hickcal : 8; /* [7:0] */
  100. __IO uint32_t hicktrim : 6; /* [13:8] */
  101. __IO uint32_t reserved1 : 18;/* [31:14] */
  102. } ctrl2_bit;
  103. };
  104. /**
  105. * @brief acc acc_c1 register, offset:0x0C
  106. */
  107. union
  108. {
  109. __IO uint32_t c1;
  110. struct
  111. {
  112. __IO uint32_t c1 : 16;/* [15:0] */
  113. __IO uint32_t reserved1 : 16;/* [31:16] */
  114. } c1_bit;
  115. };
  116. /**
  117. * @brief acc acc_c2 register, offset:0x10
  118. */
  119. union
  120. {
  121. __IO uint32_t c2;
  122. struct
  123. {
  124. __IO uint32_t c2 : 16;/* [15:0] */
  125. __IO uint32_t reserved1 : 16;/* [31:16] */
  126. } c2_bit;
  127. };
  128. /**
  129. * @brief acc acc_c3 register, offset:0x14
  130. */
  131. union
  132. {
  133. __IO uint32_t c3;
  134. struct
  135. {
  136. __IO uint32_t c3 : 16;/* [15:0] */
  137. __IO uint32_t reserved1 : 16;/* [31:16] */
  138. } c3_bit;
  139. };
  140. } acc_type;
  141. /**
  142. * @}
  143. */
  144. #define ACC ((acc_type *) ACC_BASE)
  145. /** @defgroup ACC_exported_functions
  146. * @{
  147. */
  148. void acc_calibration_mode_enable(uint16_t acc_trim, confirm_state new_state);
  149. void acc_step_set(uint8_t step_value);
  150. void acc_interrupt_enable(uint16_t acc_int, confirm_state new_state);
  151. uint8_t acc_hicktrim_get(void);
  152. uint8_t acc_hickcal_get(void);
  153. void acc_write_c1(uint16_t acc_c1_value);
  154. void acc_write_c2(uint16_t acc_c2_value);
  155. void acc_write_c3(uint16_t acc_c3_value);
  156. uint16_t acc_read_c1(void);
  157. uint16_t acc_read_c2(void);
  158. uint16_t acc_read_c3(void);
  159. flag_status acc_flag_get(uint16_t acc_flag);
  160. void acc_flag_clear(uint16_t acc_flag);
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @}
  166. */
  167. /**
  168. * @}
  169. */
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif