at32f413_acc.h 5.3 KB

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