hpm_adc12_drv.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. * Copyright (c) 2021-2024 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_ADC12_DRV_H
  8. #define HPM_ADC12_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_adc12_regs.h"
  11. #include "hpm_soc_feature.h"
  12. /**
  13. * @brief ADC12 driver APIs
  14. * @defgroup adc12_interface ADC12 driver APIs
  15. * @ingroup adc_interfaces
  16. * @{
  17. */
  18. /** @brief Define ADC12 validity check for the signal type */
  19. #define ADC12_IS_SIGNAL_TYPE_INVALID(TYPE) (TYPE > (uint32_t)adc12_sample_signal_count)
  20. /** @brief Define ADC12 validity check for the channel number */
  21. #define ADC12_IS_CHANNEL_INVALID(CH) (CH > ADC12_SOC_MAX_CH_NUM)
  22. /** @brief Define ADC12 validity check for the channel sample cycle */
  23. #define ADC12_IS_CHANNEL_SAMPLE_CYCLE_INVALID(CYC) (CYC == 0)
  24. /** @brief Define ADC12 validity check for the trigger number */
  25. #define ADC12_IS_TRIG_CH_INVLAID(CH) (CH > ADC_SOC_MAX_TRIG_CH_NUM)
  26. /** @brief Define ADC12 validity check for the trigger length */
  27. #define ADC12_IS_TRIG_LEN_INVLAID(TRIG_LEN) (TRIG_LEN > ADC_SOC_MAX_TRIG_CH_LEN)
  28. /** @brief Define ADC12 validity check for the sequence length */
  29. #define ADC12_IS_SEQ_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_SEQ_MAX_LEN))
  30. /** @brief Define ADC12 validity check for the DMA buffer length in the sequence mode */
  31. #define ADC12_IS_SEQ_DMA_BUFF_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_SEQ_MAX_DMA_BUFF_LEN_IN_4BYTES))
  32. /** @brief Define ADC12 validity check for the DMA buffer length in the preemption mode */
  33. #define ADC12_IS_PMT_DMA_BUFF_LEN_INVLAID(LEN) ((LEN == 0) || (LEN > ADC_SOC_PMT_MAX_DMA_BUFF_LEN_IN_4BYTES))
  34. /** @brief Define ADC12 sample signal types. */
  35. typedef enum {
  36. adc12_sample_signal_single_ended = 0,
  37. adc12_sample_signal_differential = 1,
  38. adc12_sample_signal_count = 2
  39. } adc12_sample_signal_t;
  40. /** @brief Define ADC12 resolutions. */
  41. typedef enum {
  42. adc12_res_6_bits = 0,
  43. adc12_res_8_bits,
  44. adc12_res_10_bits,
  45. adc12_res_12_bits
  46. } adc12_resolution_t;
  47. /** @brief Define ADC12 conversion modes. */
  48. typedef enum {
  49. adc12_conv_mode_oneshot = 0,
  50. adc12_conv_mode_period,
  51. adc12_conv_mode_sequence,
  52. adc12_conv_mode_preemption
  53. } adc12_conversion_mode_t;
  54. /** @brief Define ADC12 Clock Divider */
  55. typedef enum {
  56. adc12_clock_divider_1 = 1,
  57. adc12_clock_divider_2,
  58. adc12_clock_divider_3,
  59. adc12_clock_divider_4,
  60. adc12_clock_divider_5,
  61. adc12_clock_divider_6,
  62. adc12_clock_divider_7,
  63. adc12_clock_divider_8,
  64. adc12_clock_divider_9,
  65. adc12_clock_divider_10,
  66. adc12_clock_divider_11,
  67. adc12_clock_divider_12,
  68. adc12_clock_divider_13,
  69. adc12_clock_divider_14,
  70. adc12_clock_divider_15,
  71. adc12_clock_divider_16,
  72. } adc12_clock_divider_t;
  73. /** @brief Define ADC12 irq events. */
  74. typedef enum {
  75. /** This mask indicates that a trigger conversion is complete. */
  76. adc12_event_trig_complete = ADC12_INT_STS_TRIG_CMPT_MASK,
  77. /** This mask indicates that a conflict caused by software-triggered conversions. */
  78. adc12_event_trig_sw_conflict = ADC12_INT_STS_TRIG_SW_CFLCT_MASK,
  79. /** This mask indicates that a conflict caused by hardware-triggered conversions. */
  80. adc12_event_trig_hw_conflict = ADC12_INT_STS_TRIG_HW_CFLCT_MASK,
  81. /** This mask indicates that a conflict caused when bus reading from different channels. */
  82. adc12_event_read_conflict = ADC12_INT_STS_READ_CFLCT_MASK,
  83. /** This mask indicates that a conflict caused by sequence-triggered conversions. */
  84. adc12_event_seq_sw_conflict = ADC12_INT_STS_SEQ_SW_CFLCT_MASK,
  85. /** This mask indicates that a conflict caused by hardware-triggered conversions. */
  86. adc12_event_seq_hw_conflict = ADC12_INT_STS_SEQ_HW_CFLCT_MASK,
  87. /** This mask indicates that DMA is stopped currently. */
  88. adc12_event_seq_dma_abort = ADC12_INT_STS_SEQ_DMAABT_MASK,
  89. /** This mask indicates that all of the configured conversion(s) in a queue is(are) complete. */
  90. adc12_event_seq_full_complete = ADC12_INT_STS_SEQ_CMPT_MASK,
  91. /** This mask indicates that one of the configured conversion(s) in a queue is complete. */
  92. adc12_event_seq_single_complete = ADC12_INT_STS_SEQ_CVC_MASK,
  93. /** This mask indicates that DMA FIFO is full currently. */
  94. adc12_event_dma_fifo_full = ADC12_INT_STS_DMA_FIFO_FULL_MASK
  95. } adc12_irq_event_t;
  96. /** @brief ADC12 common configuration struct. */
  97. typedef struct {
  98. uint8_t res;
  99. uint8_t conv_mode;
  100. uint32_t adc_clk_div;
  101. bool wait_dis;
  102. bool sel_sync_ahb;
  103. bool adc_ahb_en;
  104. } adc12_config_t;
  105. /** @brief ADC12 channel configuration struct. */
  106. typedef struct {
  107. uint8_t ch;
  108. uint8_t diff_sel;
  109. uint16_t thshdh;
  110. uint16_t thshdl;
  111. bool wdog_int_en;
  112. uint8_t sample_cycle_shift;
  113. uint32_t sample_cycle;
  114. } adc12_channel_config_t;
  115. /** @brief ADC12 channel configuration struct. */
  116. typedef struct {
  117. uint8_t ch;
  118. uint16_t thshdh;
  119. uint16_t thshdl;
  120. } adc12_channel_threshold_t;
  121. /** @brief ADC12 DMA configuration struct. */
  122. typedef struct {
  123. uint32_t *start_addr;
  124. uint32_t buff_len_in_4bytes;
  125. uint32_t stop_pos;
  126. bool stop_en;
  127. } adc12_dma_config_t;
  128. /** @brief ADC12 DMA configuration struct for the sequence mode. */
  129. typedef struct {
  130. uint32_t :4;
  131. uint32_t result :12;
  132. uint32_t seq_num :4;
  133. uint32_t :4;
  134. uint32_t adc_ch :5;
  135. uint32_t :2;
  136. uint32_t cycle_bit :1;
  137. } adc12_seq_dma_data_t;
  138. /** @brief ADC12 DMA configuration struct for the preemption mode. */
  139. typedef struct {
  140. uint32_t :4;
  141. uint32_t result :12;
  142. uint32_t seq_num :2;
  143. uint32_t :2;
  144. uint32_t trig_ch :4;
  145. uint32_t adc_ch :5;
  146. uint32_t :2;
  147. uint32_t cycle_bit :1;
  148. } adc12_pmt_dma_data_t;
  149. /** @brief ADC12 configuration struct for the period mode. */
  150. typedef struct {
  151. uint8_t ch;
  152. uint8_t prescale;
  153. uint8_t period_count;
  154. } adc12_prd_config_t;
  155. /** @brief ADC12 queue configuration struct for the sequence mode. */
  156. typedef struct {
  157. bool seq_int_en;
  158. uint8_t ch;
  159. } adc12_seq_queue_config_t;
  160. /** @brief ADC12 configuration struct for the sequence mode. */
  161. typedef struct {
  162. adc12_seq_queue_config_t queue[ADC_SOC_SEQ_MAX_LEN];
  163. bool restart_en;
  164. bool cont_en;
  165. bool sw_trig_en;
  166. bool hw_trig_en;
  167. uint8_t seq_len;
  168. } adc12_seq_config_t;
  169. /** @brief ADC12 trigger configuration struct for the preemption mode. */
  170. typedef struct {
  171. bool inten[ADC_SOC_MAX_TRIG_CH_LEN];
  172. uint8_t adc_ch[ADC_SOC_MAX_TRIG_CH_LEN];
  173. uint8_t trig_ch;
  174. uint8_t trig_len;
  175. } adc12_pmt_config_t;
  176. #ifdef __cplusplus
  177. extern "C" {
  178. #endif
  179. /**
  180. * @name Initialization and Deinitialization
  181. * @{
  182. */
  183. /**
  184. * @brief Get a default configuration for an ADC12 instance.
  185. *
  186. * @param[out] config A pointer to the configuration struct of @ref adc12_config_t.
  187. */
  188. void adc12_get_default_config(adc12_config_t *config);
  189. /**
  190. * @brief Get a default configuration for an ADC12 channel.
  191. *
  192. * @param[out] config A pointer to the configuration struct of @ref adc12_channel_config_t.
  193. */
  194. void adc12_get_channel_default_config(adc12_channel_config_t *config);
  195. /**
  196. * @brief De-initialize an ADC12 instance.
  197. *
  198. * @param[in] ptr An ADC12 peripheral base address.
  199. * @return A result of de-initializing an ADC12 instance.
  200. * @retval status_success De-initialize an ADC12 instance successfully. Please refer to @ref hpm_stat_t.
  201. * @retval status_invalid_argument De-initialize an ADC12 instance unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  202. */
  203. hpm_stat_t adc12_deinit(ADC12_Type *ptr);
  204. /**
  205. * @brief Initialize an ADC12 instance.
  206. *
  207. * @param[in] ptr An ADC12 peripheral base address.
  208. * @param[in] config A pointer to the configuration struct of @ref adc12_config_t.
  209. * @return A result of initializing an ADC12 instance.
  210. * @retval status_success Initialize an ADC12 instance successfully. Please refer to @ref hpm_stat_t.
  211. * @retval status_invalid_argument Initialize an ADC12 instance unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  212. */
  213. hpm_stat_t adc12_init(ADC12_Type *ptr, adc12_config_t *config);
  214. /**
  215. * @brief Initialize an ADC12 channel.
  216. *
  217. * @param[in] ptr An ADC12 peripheral base address.
  218. * @param[in] config A pointer to the configuration struct of @ref adc12_channel_config_t.
  219. * @return A result of initializing an ADC12 channel.
  220. * @retval status_success Initialize an ADC12 channel successfully. Please refer to @ref hpm_stat_t.
  221. * @retval status_invalid_argument Initialize an ADC12 channel unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  222. */
  223. hpm_stat_t adc12_init_channel(ADC12_Type *ptr, adc12_channel_config_t *config);
  224. /**
  225. * @brief Get thresholds of an ADC12 channel
  226. *
  227. * @param[in] ptr An ADC12 peripheral base address.
  228. * @param[in] ch An ADC12 channel number
  229. * @param[out] config A pointer to the structure of channel threshold
  230. * @return A result of getting thresholds of an ADC12 channel .
  231. * @retval status_success Initialize an ADC12 channel successfully. Please refer to @ref hpm_stat_t.
  232. * @retval status_invalid_argument Initialize an ADC12 channel unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  233. */
  234. hpm_stat_t adc12_get_channel_threshold(ADC12_Type *ptr, uint8_t ch, adc12_channel_threshold_t *config);
  235. /**
  236. * @brief Configure the the period mode for an ADC12 instance.
  237. *
  238. * @param[in] ptr An ADC12 peripheral base address.
  239. * @param[in] config A pointer to the configuration struct of @ref adc12_prd_config_t.
  240. * @return A result of configuring the the period mode for an ADC12 instance.
  241. * @retval status_success Configure the the period mode successfully. Please refer to @ref hpm_stat_t.
  242. * @retval status_invalid_argument Configure the the period mode unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  243. */
  244. hpm_stat_t adc12_set_prd_config(ADC12_Type *ptr, adc12_prd_config_t *config);
  245. /**
  246. * @brief Configure the the sequence mode for an ADC12 instance.
  247. *
  248. * @param[in] ptr An ADC12 peripheral base address.
  249. * @param[in] config A pointer to configuration struct of @ref adc12_seq_config_t.
  250. * @return A result of configuring the the sequence mode for an ADC12 instance.
  251. * @retval status_success Configure the the sequence mode successfully. Please refer to @ref hpm_stat_t.
  252. * @retval status_invalid_argument Configure the the sequence mode unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  253. */
  254. hpm_stat_t adc12_set_seq_config(ADC12_Type *ptr, adc12_seq_config_t *config);
  255. /**
  256. * @brief Configure the preemption mode for an ADC12 instance.
  257. *
  258. * @param[in] ptr An ADC12 peripheral base address.
  259. * @param[in] config A pointer to configuration struct of @ref adc12_pmt_config_t.
  260. * @return A result of configuring the preemption mode for an ADC12 instance.
  261. * @retval status_success Configure the preemption mode successfully. Please refer to @ref hpm_stat_t.
  262. * @retval status_invalid_argument Configure the preemption mode unsuccessfully due to passing one or more invalid arguments. Please refer to @ref hpm_stat_t.
  263. */
  264. hpm_stat_t adc12_set_pmt_config(ADC12_Type *ptr, adc12_pmt_config_t *config);
  265. /** @} */
  266. /**
  267. * @name DMA Control
  268. * @{
  269. */
  270. /**
  271. * @brief Configure the stop position offset in the specified memory of DMA write operation for the sequence mode.
  272. *
  273. * @param[in] ptr An ADC12 peripheral base address.
  274. * @param[in] stop_pos A stop position offset.
  275. */
  276. static inline void adc12_set_seq_stop_pos(ADC12_Type *ptr, uint16_t stop_pos)
  277. {
  278. ptr->SEQ_DMA_CFG = (ptr->SEQ_DMA_CFG & ~ADC12_SEQ_DMA_CFG_STOP_POS_MASK)
  279. | ADC12_SEQ_DMA_CFG_STOP_POS_SET(stop_pos);
  280. }
  281. /**
  282. * @brief Configure the start address of DMA write operation for the preemption mode.
  283. *
  284. * @param[in] ptr An ADC12 peripheral base address.
  285. * @param[in] addr A start address of DMA write operation.
  286. */
  287. static inline void adc12_init_pmt_dma(ADC12_Type *ptr, uint32_t addr)
  288. {
  289. ptr->TRG_DMA_ADDR = addr & ADC12_TRG_DMA_ADDR_TRG_DMA_ADDR_MASK;
  290. }
  291. /**
  292. * @brief Configure the start address of DMA write operation for the sequence mode.
  293. *
  294. * @param[in] ptr An ADC12 peripheral base address.
  295. * @param[in] config A pointer to configuration struct of @ref adc12_dma_config_t.
  296. * @return An implementation result of DMA initializing for the sequence mode
  297. * @retval status_success ADC12 initialize in sequence mode successfully. Please refert to @ref hpm_stat_t.
  298. * @retval status_invalid_argument ADC12 initialize in sequence mode unsuccessfully due to passing invalid arguments. Please refert to @ref hpm_stat_t.
  299. */
  300. hpm_stat_t adc12_init_seq_dma(ADC12_Type *ptr, adc12_dma_config_t *config);
  301. /** @} */
  302. /**
  303. * @name Status
  304. * @{
  305. */
  306. /**
  307. * @brief Get all ADC12 status flags.
  308. *
  309. * @param[in] ptr An ADC12 peripheral base address.
  310. * @return A mask indicating all corresponding interrupt statuses.
  311. * @retval A mask. Please refer to @ref adc12_irq_event_t.
  312. */
  313. static inline uint32_t adc12_get_status_flags(ADC12_Type *ptr)
  314. {
  315. return ptr->INT_STS;
  316. }
  317. /**
  318. * @brief Set value of the WAIT_DIS bit. The ADC does not block access to the associated peripheral bus
  319. * until the ADC has completed its conversion. *
  320. *
  321. * @param[in] ptr An ADC12 peripheral base address.
  322. * @deprecated This API will be removed from V2.0.x
  323. */
  324. static inline void adc12_disable_busywait(ADC12_Type *ptr)
  325. {
  326. ptr->BUF_CFG0 |= ADC12_BUF_CFG0_WAIT_DIS_SET(1);
  327. }
  328. /**
  329. * @brief Set value of the WAIT_DIS bit. ADC blocks access to the associated peripheral bus
  330. * until the ADC completes the conversion.
  331. *
  332. * @param[in] ptr An ADC12 peripheral base address.
  333. * @deprecated This API will be removed from V2.0.x
  334. */
  335. static inline void adc12_enable_busywait(ADC12_Type *ptr)
  336. {
  337. ptr->BUF_CFG0 &= ~ADC12_BUF_CFG0_WAIT_DIS_MASK;
  338. }
  339. /**
  340. * @brief Set nonblocking read in oneshot mode.
  341. * @note An ADC does not block access to the associated peripheral whether it completes a conversion or not.
  342. *
  343. * @param[in] ptr An ADC12 peripheral base address.
  344. */
  345. static inline void adc12_set_nonblocking_read(ADC12_Type *ptr)
  346. {
  347. ptr->BUF_CFG0 |= ADC12_BUF_CFG0_WAIT_DIS_MASK;
  348. }
  349. /**
  350. * @brief Set blocking read in oneshot mode.
  351. * @note An ADC blocks access to the associated peripheral bus until it completes a conversion.
  352. *
  353. * @param[in] ptr An ADC12 peripheral base address.
  354. */
  355. static inline void adc12_set_blocking_read(ADC12_Type *ptr)
  356. {
  357. ptr->BUF_CFG0 &= ~ADC12_BUF_CFG0_WAIT_DIS_MASK;
  358. }
  359. /**
  360. * @brief Judge whether the current setting is none-blocking mode or not.
  361. *
  362. * @param[in] ptr An ADC12 peripheral base address.
  363. * @return A result indicating the status of bus waiting.
  364. * @retval True means that nonblocking reading.
  365. * @retval False means that blocking reading.
  366. *
  367. */
  368. static inline bool adc12_is_nonblocking_mode(ADC12_Type *ptr)
  369. {
  370. return (ADC12_BUF_CFG0_WAIT_DIS_GET(ptr->BUF_CFG0) ? true : false);
  371. }
  372. /**
  373. * @brief Get the status of a conversion validity.
  374. *
  375. * @param[in] ptr An ADC12 peripheral base address.
  376. * @param[in] ch An ADC12 peripheral channel.
  377. * @return Status indicating the validity of the current conversion result.
  378. *
  379. * @note This function is only used when the WAIT_DIS bit in the BUF_RESULT register is 1.
  380. */
  381. static inline bool adc12_get_conv_valid_status(ADC12_Type *ptr, uint8_t ch)
  382. {
  383. return ADC12_BUS_RESULT_VALID_GET(ptr->BUS_RESULT[ch]);
  384. }
  385. /**
  386. * @brief Clear the status flags.
  387. *
  388. *
  389. * @param[in] ptr An ADC12 peripheral base address.
  390. * @param[in] mask A mask that means the specified flags to be cleared. Please refer to @ref adc12_irq_event_t.
  391. *
  392. * @note Only the specified flags can be cleared by writing the INT_STS register.
  393. */
  394. static inline void adc12_clear_status_flags(ADC12_Type *ptr, uint32_t mask)
  395. {
  396. ptr->INT_STS = mask;
  397. }
  398. /** @} */
  399. /**
  400. * @name Interrupts
  401. * @{
  402. */
  403. /**
  404. * @brief Enable interrupts.
  405. *
  406. * @param[in] ptr An ADC12 peripheral base address.
  407. * @param[in] mask A mask indicating the specified ADC interrupt events. Please refer to @ref adc12_irq_event_t.
  408. */
  409. static inline void adc12_enable_interrupts(ADC12_Type *ptr, uint32_t mask)
  410. {
  411. ptr->INT_EN |= mask;
  412. }
  413. /**
  414. * @brief Disable interrupts.
  415. *
  416. * @param[in] ptr An ADC12 peripheral base address.
  417. * @param[in] mask A mask indicating the specified interrupt events. Please refer to @ref adc12_irq_event_t.
  418. */
  419. static inline void adc12_disable_interrupts(ADC12_Type *ptr, uint32_t mask)
  420. {
  421. ptr->INT_EN &= ~mask;
  422. }
  423. /** @} */
  424. /**
  425. * @name Trigger and Conversion
  426. * @{
  427. */
  428. /**
  429. * @brief Trigger ADC conversions by software in sequence mode
  430. *
  431. * @param[in] ptr An ADC12 peripheral base address.
  432. * @return An implementation result of getting an ADC12 software trigger.
  433. * @retval status_success ADC12 software triggers successfully. Please refer to @ref hpm_stat_t.
  434. * @retval status_fail ADC12 software triggers unsuccessfully. Please refer to @ref hpm_stat_t.
  435. */
  436. hpm_stat_t adc12_trigger_seq_by_sw(ADC12_Type *ptr);
  437. /**
  438. * @brief Trigger ADC conversions by software in preemption mode
  439. *
  440. * @param[in] ptr An ADC12 peripheral base address.
  441. * @param[in] trig_ch A trigger channel number(e.g. TRIG0A,TRIG0B,TRIG0C...).
  442. * @return An implementation result of getting an ADC12 software trigger.
  443. * @retval status_success ADC12 software triggers successfully. Please refer to @ref hpm_stat_t.
  444. * @retval status_fail ADC12 software triggers unsuccessfully. Please refer to @ref hpm_stat_t.
  445. */
  446. hpm_stat_t adc12_trigger_pmt_by_sw(ADC12_Type *ptr, uint8_t trig_ch);
  447. /**
  448. * @brief Get the result in oneshot mode.
  449. *
  450. * @param[in] ptr An ADC12 peripheral base address.
  451. * @param[in] ch An ADC12 peripheral channel.
  452. * @param[out] result A pointer to an ADC12 conversion result.
  453. * @return An implementation result of getting an ADC12 conversion result in oneshot mode.
  454. * @retval status_success Get the result of an ADC12 conversion in oneshot mode successfully. Please refer to @ref hpm_stat_t.
  455. * @retval status_invalid_argument Get the result of an ADC12 conversion in oneshot mode unsuccessfully due to passing invalid arguments. Please refer to @ref hpm_stat_t.
  456. */
  457. hpm_stat_t adc12_get_oneshot_result(ADC12_Type *ptr, uint8_t ch, uint16_t *result);
  458. /**
  459. * @brief Get the result in the period mode.
  460. *
  461. * @param[in] ptr An ADC12 peripheral base address.
  462. * @param[in] ch An ADC12 peripheral channel.
  463. * @param[out] result A pointer to a specified ADC12 conversion result
  464. * @return An implementation of getting an ADC12 conversion result in the period mode.
  465. * @retval status_success Get the result of an ADC12 conversion in the period mode successfully. Please refer to @ref hpm_stat_t.
  466. * @retval status_invalid_argument Get the result of an ADC12 conversion in the period mode unsuccessfully due to passing invalid arguments. Please refer to @ref hpm_stat_t.
  467. */
  468. hpm_stat_t adc12_get_prd_result(ADC12_Type *ptr, uint8_t ch, uint16_t *result);
  469. /** @} */
  470. #ifdef __cplusplus
  471. }
  472. #endif
  473. /** @} */
  474. #endif /* HPM_ADC12_DRV_H */