HPM SDK
HPMicro Software Development Kit
hpm_gptmr_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_GPTMR_DRV_H
9 #define HPM_GPTMR_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_gptmr_regs.h"
12 #include "hpm_soc_feature.h"
13 
24 #define GPTMR_CH_CMP_IRQ_MASK(ch, cmp) (1 << (ch * 4 + 2 + cmp))
25 #define GPTMR_CH_CAP_IRQ_MASK(ch) (1 << (ch * 4 + 1))
26 #define GPTMR_CH_RLD_IRQ_MASK(ch) (1 << (ch * 4))
27 
31 #define GPTMR_CH_CMP_STAT_MASK(ch, cmp) (1 << (ch * 4 + 2 + cmp))
32 #define GPTMR_CH_CAP_STAT_MASK(ch) (1 << (ch * 4 + 1))
33 #define GPTMR_CH_RLD_STAT_MASK(ch) (1 << (ch * 4))
34 
38 #define GPTMR_CH_GCR_SWSYNCT_MASK(ch) (1 << ch)
39 
43 #define GPTMR_CH_CMP_COUNT (2U)
44 
48 typedef enum gptmr_synci_edge {
54 
58 typedef enum gptmr_work_mode {
65 
76 
80 typedef enum gptmr_counter_type {
87 
92 #if defined(HPM_IP_FEATURE_GPTMR_CNT_MODE) && (HPM_IP_FEATURE_GPTMR_CNT_MODE == 1)
93 typedef enum gptmr_counter_mode {
94  gptmr_counter_mode_internal = 0,
95  gptmr_counter_mode_external,
96 } gptmr_counter_mode_t;
97 #endif
98 
99 #if defined(HPM_IP_FEATURE_GPTMR_MONITOR) && (HPM_IP_FEATURE_GPTMR_MONITOR == 1)
100 typedef enum gptmr_channel_monitor_type {
101  monitor_signal_period = 0,
102  monitor_signal_high_level_time,
103 } gptmr_channel_monitor_type_t;
104 
105 typedef struct gptmr_channel_monitor_config {
106  gptmr_channel_monitor_type_t monitor_type;
107  uint32_t max_value;
108  uint32_t min_value;
109 } gptmr_channel_monitor_config_t;
110 #endif
111 
112 #if defined(HPM_IP_FEATURE_GPTMR_QEI_MODE) && (HPM_IP_FEATURE_GPTMR_QEI_MODE == 1)
113 typedef enum gptmr_qei_ch_group {
114  gptmr_qei_ch_group_01 = 0,
115  gptmr_qei_ch_group_23 = 2,
116 } gptmr_qei_ch_group_t;
117 
118 typedef enum gptmr_qei_type {
119  gptmr_qei_ud_mode = 0,
120  gptmr_qei_ab_mode,
121  gptmr_qei_pd_mode,
122 } gptmr_qei_type_t;
123 
124 typedef struct gptmr_qei_config {
125  gptmr_qei_type_t type;
126  gptmr_qei_ch_group_t ch_group;
127  uint32_t phmax;
128 } gptmr_qei_config_t;
129 
130 #endif
131 
132 #if defined(HPM_IP_FEATURE_GPTMR_BURST_MODE) && (HPM_IP_FEATURE_GPTMR_BURST_MODE == 1)
133 typedef enum gptmr_burst_counter_mode {
134  gptmr_burst_counter_restart = 0,
135  gptmr_burst_counter_continue,
136 } gptmr_burst_counter_mode_t;
137 
138 #endif
139 
143 typedef struct gptmr_channel_cfg {
148  uint32_t reload;
154 #if defined(HPM_IP_FEATURE_GPTMR_MONITOR) && (HPM_IP_FEATURE_GPTMR_MONITOR == 1)
155  bool enable_monitor;
156  gptmr_channel_monitor_config_t monitor_config;
157 #endif
158 #if defined(HPM_IP_FEATURE_GPTMR_CNT_MODE) && (HPM_IP_FEATURE_GPTMR_CNT_MODE == 1)
159  gptmr_counter_mode_t counter_mode;
160 #endif
161 #if defined(HPM_IP_FEATURE_GPTMR_OP_MODE) && (HPM_IP_FEATURE_GPTMR_OP_MODE == 1)
162  bool enable_opmode;
163 #endif
165 
166 
167 #ifdef __cplusplus
168 extern "C" {
169 #endif
170 
180 static inline void gptmr_channel_enable(GPTMR_Type *ptr, uint8_t ch_index, bool enable)
181 {
182  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR
184  | GPTMR_CHANNEL_CR_CMPEN_SET(enable);
185 }
186 
193 static inline void gptmr_channel_reset_count(GPTMR_Type *ptr, uint8_t ch_index)
194 {
195  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_CNTRST_MASK;
196  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CNTRST_MASK;
197 }
198 
206 static inline void gptmr_channel_update_count(GPTMR_Type *ptr,
207  uint8_t ch_index,
208  uint32_t value)
209 {
210  if ((value > 0) && (value != 0xFFFFFFFFu)) {
211  value--;
212  }
214  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_CNTUPT_MASK;
215 }
216 
225  uint8_t ch_index,
226  gptmr_synci_edge_t edge)
227 {
228  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR
231 }
232 
243  uint8_t ch_index,
244  bool enable)
245 {
246  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR
248 }
249 
257 static inline uint32_t gptmr_channel_get_counter(GPTMR_Type *ptr,
258  uint8_t ch_index,
259  gptmr_counter_type_t capture)
260 {
261  uint32_t value;
262  switch (capture) {
265  break;
268  break;
271  break;
274  break;
275  default:
277  break;
278  }
279  return value;
280 }
281 
288 static inline void gptmr_trigger_channel_software_sync(GPTMR_Type *ptr, uint32_t ch_index_mask)
289 {
290 #if defined(HPM_IP_FEATURE_GPTMR_QEI_MODE) && (HPM_IP_FEATURE_GPTMR_QEI_MODE == 1)
291  ptr->GCR = (ptr->GCR & ~GPTMR_GCR_SWSYNCT_MASK) | GPTMR_GCR_SWSYNCT_SET(ch_index_mask);
292 #else
293  ptr->GCR = ch_index_mask;
294 #endif
295 }
296 
303 static inline void gptmr_enable_irq(GPTMR_Type *ptr, uint32_t irq_mask)
304 {
305  ptr->IRQEN |= irq_mask;
306 }
307 
314 static inline void gptmr_disable_irq(GPTMR_Type *ptr, uint32_t irq_mask)
315 {
316  ptr->IRQEN &= ~irq_mask;
317 }
318 
325 static inline bool gptmr_check_status(GPTMR_Type *ptr, uint32_t mask)
326 {
327  return (ptr->SR & mask) == mask;
328 }
329 
336 static inline void gptmr_clear_status(GPTMR_Type *ptr, uint32_t mask)
337 {
338  ptr->SR = mask;
339 }
340 
347 static inline uint32_t gptmr_get_status(GPTMR_Type *ptr)
348 {
349  return ptr->SR;
350 }
351 
352 
359 static inline void gptmr_stop_counter(GPTMR_Type *ptr, uint8_t ch_index)
360 {
361  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CEN_MASK;
362 }
363 
370 static inline void gptmr_enable_cmp_output(GPTMR_Type *ptr, uint8_t ch_index)
371 {
372  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_CMPEN_MASK;
373 }
374 
381 static inline void gptmr_disable_cmp_output(GPTMR_Type *ptr, uint8_t ch_index)
382 {
383  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CMPEN_MASK;
384 }
385 
393 static inline void gptmr_channel_set_capmode(GPTMR_Type *ptr, uint8_t ch_index, gptmr_work_mode_t mode)
394 {
395  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR & ~GPTMR_CHANNEL_CR_CAPMODE_MASK) | GPTMR_CHANNEL_CR_CAPMODE_SET(mode);
396 }
397 
405 static inline gptmr_work_mode_t gptmr_channel_get_capmode(GPTMR_Type *ptr, uint8_t ch_index)
406 {
408 }
409 
418 static inline void gptmr_update_cmp(GPTMR_Type *ptr, uint8_t ch_index, uint8_t cmp_index, uint32_t cmp)
419 {
420  if ((cmp > 0) && (cmp != 0xFFFFFFFFu)) {
421  cmp--;
422  }
423  ptr->CHANNEL[ch_index].CMP[cmp_index] = GPTMR_CHANNEL_CMP_CMP_SET(cmp);
424 }
425 
433 static inline uint32_t gptmr_channel_get_reload(GPTMR_Type *ptr, uint8_t ch_index)
434 {
435  return ptr->CHANNEL[ch_index].RLD;
436 }
437 
445 static inline void gptmr_channel_config_update_reload(GPTMR_Type *ptr, uint8_t ch_index, uint32_t reload)
446 {
447  if ((reload > 0) && (reload != 0xFFFFFFFFu)) {
448  reload--;
449  }
450  ptr->CHANNEL[ch_index].RLD = GPTMR_CHANNEL_RLD_RLD_SET(reload);
451 }
452 
461 {
463 }
464 
478  uint8_t ch_index,
479  gptmr_channel_config_t *config,
480  bool enable);
481 
489 
490 
491 #if defined(HPM_IP_FEATURE_GPTMR_CNT_MODE) && (HPM_IP_FEATURE_GPTMR_CNT_MODE == 1)
499 static inline void gptmr_channel_set_counter_mode(GPTMR_Type *ptr, uint8_t ch_index, gptmr_counter_mode_t mode)
500 {
501  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR & ~GPTMR_CHANNEL_CR_CNT_MODE_MASK) | GPTMR_CHANNEL_CR_CNT_MODE_SET(mode);
502 }
503 
511 static inline gptmr_counter_mode_t gptmr_channel_get_counter_mode(GPTMR_Type *ptr, uint8_t ch_index)
512 {
513  return ((ptr->CHANNEL[ch_index].CR & GPTMR_CHANNEL_CR_CNT_MODE_MASK) ==
515  gptmr_counter_mode_external : gptmr_counter_mode_internal;
516 }
517 
518 #endif
519 
520 #if defined(HPM_IP_FEATURE_GPTMR_OP_MODE) && (HPM_IP_FEATURE_GPTMR_OP_MODE == 1)
529 static inline void gptmr_channel_enable_opmode(GPTMR_Type *ptr, uint8_t ch_index)
530 {
531  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_OPMODE_MASK;
532 }
533 
540 static inline void gptmr_channel_disable_opmode(GPTMR_Type *ptr, uint8_t ch_index)
541 {
542  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_OPMODE_MASK;
543 }
544 
552 static inline bool gptmr_channel_is_opmode(GPTMR_Type *ptr, uint8_t ch_index)
553 {
554  return ((ptr->CHANNEL[ch_index].CR & GPTMR_CHANNEL_CR_OPMODE_MASK) == GPTMR_CHANNEL_CR_OPMODE_MASK) ? true : false;
555 }
556 #endif
557 
558 #if defined(HPM_IP_FEATURE_GPTMR_MONITOR) && (HPM_IP_FEATURE_GPTMR_MONITOR == 1)
565 static inline void gptmr_channel_enable_monitor(GPTMR_Type *ptr, uint8_t ch_index)
566 {
567  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_MONITOR_EN_MASK;
568 }
569 
576 static inline void gptmr_channel_disable_monitor(GPTMR_Type *ptr, uint8_t ch_index)
577 {
578  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_MONITOR_EN_MASK;
579 }
580 
588 static inline void gptmr_channel_set_monitor_type(GPTMR_Type *ptr, uint8_t ch_index, gptmr_channel_monitor_type_t type)
589 {
590  ptr->CHANNEL[ch_index].CR = (ptr->CHANNEL[ch_index].CR & ~GPTMR_CHANNEL_CR_MONITOR_SEL_MASK) | GPTMR_CHANNEL_CR_MONITOR_SEL_SET(type);
591 }
592 
600 static inline gptmr_channel_monitor_type_t gptmr_channel_get_monitor_type(GPTMR_Type *ptr, uint8_t ch_index)
601 {
602  return (gptmr_channel_monitor_type_t)GPTMR_CHANNEL_CR_MONITOR_SEL_GET(ptr->CHANNEL[ch_index].CR);
603 }
610 void gptmr_channel_get_default_monitor_config(GPTMR_Type *ptr, gptmr_channel_monitor_config_t *config);
611 
625 hpm_stat_t gptmr_channel_monitor_config(GPTMR_Type *ptr, uint8_t ch_index,
626  gptmr_channel_monitor_config_t *config,
627  bool enable);
628 
629 #endif
630 
631 #if defined(HPM_IP_FEATURE_GPTMR_BURST_MODE) && (HPM_IP_FEATURE_GPTMR_BURST_MODE == 1)
641 static inline hpm_stat_t gptmr_channel_enable_burst_mode(GPTMR_Type *ptr, uint8_t ch_index)
642 {
643  /* enable burst mode, should disable opmode first */
644  if (gptmr_channel_is_opmode(ptr, ch_index) == true) {
646  }
647  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_BURST_MODE_MASK;
648  return status_success;
649 }
650 
657 static inline void gptmr_channel_disable_burst_mode(GPTMR_Type *ptr, uint8_t ch_index)
658 {
659  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_BURST_MODE_MASK;
660 }
661 
669 static inline bool gptmr_channel_is_burst_mode(GPTMR_Type *ptr, uint8_t ch_index)
670 {
671  return ((ptr->CHANNEL[ch_index].CR & GPTMR_CHANNEL_CR_BURST_MODE_MASK) == GPTMR_CHANNEL_CR_BURST_MODE_MASK) ? true : false;
672 }
673 
681 static inline void gptmr_channel_set_target_burst_count(GPTMR_Type *ptr, uint8_t ch_index, uint16_t burst_count)
682 {
684 }
685 
693 static inline uint16_t gptmr_channel_get_target_burst_count(GPTMR_Type *ptr, uint8_t ch_index)
694 {
695  return (uint16_t)GPTMR_CHANNEL_BURST_CFG_BURST_CFG_GET(ptr->CHANNEL[ch_index].BURST_CFG);
696 }
697 
706 static inline uint32_t gptmr_channel_get_current_burst_count(GPTMR_Type *ptr, uint8_t ch_index)
707 {
709 
710 }
711 
721 hpm_stat_t gptmr_channel_burst_mode_start_counter(GPTMR_Type *ptr, uint8_t ch_index, gptmr_burst_counter_mode_t mode);
722 
729 static inline void gptmr_channel_burst_mode_stop_counter(GPTMR_Type *ptr, uint8_t ch_index)
730 {
731  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CEN_MASK;
732 }
733 #endif
734 
741 static inline void gptmr_start_counter(GPTMR_Type *ptr, uint8_t ch_index)
742 {
743 #if defined(HPM_IP_FEATURE_GPTMR_OP_MODE) && (HPM_IP_FEATURE_GPTMR_OP_MODE == 1)
744  /* if support opmode, should clear CEN and set CEN */
745  if (gptmr_channel_is_opmode(ptr, ch_index) == true) {
746  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CEN_MASK;
747  }
748 #endif
749  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_CEN_MASK;
750 }
751 
752 #if defined(HPM_IP_FEATURE_GPTMR_QEI_MODE) && (HPM_IP_FEATURE_GPTMR_QEI_MODE == 1)
753 
760 void gptmr_config_qei(GPTMR_Type *ptr, gptmr_qei_config_t *qei_config);
761 
769 void gptmr_set_qei_type(GPTMR_Type *ptr, gptmr_qei_ch_group_t ch_group, gptmr_qei_type_t type);
770 
778 gptmr_qei_type_t gptmr_get_qei_type(GPTMR_Type *ptr, gptmr_qei_ch_group_t ch_group);
779 
787 uint32_t gptmr_get_qei_phcnt(GPTMR_Type *ptr, gptmr_qei_ch_group_t ch_group);
788 
789 #endif
790 
797 static inline void gptmr_channel_set_cmp_initial_polarity(GPTMR_Type *ptr, uint8_t ch_index, bool high)
798 {
799  if (high) {
800  ptr->CHANNEL[ch_index].CR |= GPTMR_CHANNEL_CR_CMPINIT_MASK;
801  } else {
802  ptr->CHANNEL[ch_index].CR &= ~GPTMR_CHANNEL_CR_CMPINIT_MASK;
803  }
804 }
805 
812 static inline bool gptmr_channel_get_cmp_initial_polarity(GPTMR_Type *ptr, uint8_t ch_index)
813 {
814  return (ptr->CHANNEL[ch_index].CR & GPTMR_CHANNEL_CR_CMPINIT_MASK) ? true : false;
815 }
816 
821 #ifdef __cplusplus
822 }
823 #endif
824 
825 #endif /* HPM_GPTMR_DRV_H */
#define GPTMR_CHANNEL_RLD_RLD_SET(x)
Definition: hpm_gptmr_regs.h:234
#define GPTMR_CHANNEL_CAPNEG_CAPNEG_SHIFT
Definition: hpm_gptmr_regs.h:265
#define GPTMR_GCR_SWSYNCT_MASK
Definition: hpm_gptmr_regs.h:626
#define GPTMR_CHANNEL_CNTUPTVAL_CNTUPTVAL_SET(x)
Definition: hpm_gptmr_regs.h:245
#define GPTMR_CHANNEL_CR_CMPEN_MASK
Definition: hpm_gptmr_regs.h:151
#define GPTMR_CHANNEL_CAPPRD_CAPPRD_SHIFT
Definition: hpm_gptmr_regs.h:275
#define GPTMR_CHANNEL_CAPPOS_CAPPOS_SHIFT
Definition: hpm_gptmr_regs.h:255
#define GPTMR_CHANNEL_CNT_COUNTER_SHIFT
Definition: hpm_gptmr_regs.h:295
#define GPTMR_CHANNEL_CR_DMAEN_SET(x)
Definition: hpm_gptmr_regs.h:177
#define GPTMR_CHANNEL_CMP_CMP_SET(x)
Definition: hpm_gptmr_regs.h:223
#define GPTMR_CHANNEL_CR_CEN_MASK
Definition: hpm_gptmr_regs.h:128
#define GPTMR_CHANNEL_CR_DMASEL_GET(x)
Definition: hpm_gptmr_regs.h:168
#define GPTMR_CHANNEL_CR_CAPMODE_GET(x)
Definition: hpm_gptmr_regs.h:213
#define GPTMR_CHANNEL_CAPNEG_CAPNEG_MASK
Definition: hpm_gptmr_regs.h:264
#define GPTMR_CHANNEL_CAPDTY_MEAS_HIGH_SHIFT
Definition: hpm_gptmr_regs.h:285
#define GPTMR_CHANNEL_CR_MONITOR_EN_MASK
Definition: hpm_gptmr_regs.h:77
#define GPTMR_CHANNEL_CAPPOS_CAPPOS_MASK
Definition: hpm_gptmr_regs.h:254
#define GPTMR_CHANNEL_CR_CNTUPT_MASK
Definition: hpm_gptmr_regs.h:40
#define GPTMR_CHANNEL_CR_SYNCIFEN_MASK
Definition: hpm_gptmr_regs.h:108
#define GPTMR_CHANNEL_CR_CAPMODE_SET(x)
Definition: hpm_gptmr_regs.h:212
#define GPTMR_CHANNEL_CNT_COUNTER_MASK
Definition: hpm_gptmr_regs.h:294
#define GPTMR_CHANNEL_CR_CMPEN_SET(x)
Definition: hpm_gptmr_regs.h:153
#define GPTMR_CHANNEL_CR_DMAEN_MASK
Definition: hpm_gptmr_regs.h:175
#define GPTMR_CHANNEL_CR_MONITOR_SEL_MASK
Definition: hpm_gptmr_regs.h:63
#define GPTMR_CHANNEL_CR_CAPMODE_MASK
Definition: hpm_gptmr_regs.h:210
#define GPTMR_CHANNEL_CR_MONITOR_SEL_GET(x)
Definition: hpm_gptmr_regs.h:66
#define GPTMR_GCR_SWSYNCT_SET(x)
Definition: hpm_gptmr_regs.h:628
#define GPTMR_CHANNEL_CR_SYNCIREN_MASK
Definition: hpm_gptmr_regs.h:118
#define GPTMR_CHANNEL_CR_CNTRST_MASK
Definition: hpm_gptmr_regs.h:87
#define GPTMR_CHANNEL_CAPPRD_CAPPRD_MASK
Definition: hpm_gptmr_regs.h:274
#define GPTMR_CHANNEL_CR_OPMODE_MASK
Definition: hpm_gptmr_regs.h:52
#define GPTMR_CHANNEL_CR_CMPINIT_MASK
Definition: hpm_gptmr_regs.h:141
#define GPTMR_CHANNEL_CR_MONITOR_SEL_SET(x)
Definition: hpm_gptmr_regs.h:65
#define GPTMR_CHANNEL_CAPDTY_MEAS_HIGH_MASK
Definition: hpm_gptmr_regs.h:284
#define GPTMR_CHANNEL_CR_CNT_MODE_SET(x)
Definition: hpm_gptmr_regs.h:66
#define GPTMR_CHANNEL_CR_CNT_MODE_MASK
Definition: hpm_gptmr_regs.h:64
#define GPTMR_CHANNEL_BURST_CFG_BURST_CFG_GET(x)
Definition: hpm_gptmr_regs.h:280
#define GPTMR_CHANNEL_BURST_CFG_BURST_CFG_MASK
Definition: hpm_gptmr_regs.h:277
#define GPTMR_CHANNEL_BURST_CFG_BURST_CFG_SET(x)
Definition: hpm_gptmr_regs.h:279
#define GPTMR_CHANNEL_BURST_COUNT_BURST_COUNT_GET(x)
Definition: hpm_gptmr_regs.h:289
#define GPTMR_CHANNEL_CR_BURST_MODE_MASK
Definition: hpm_gptmr_regs.h:53
uint32_t hpm_stat_t
Definition: hpm_common.h:135
@ status_invalid_argument
Definition: hpm_common.h:191
@ status_success
Definition: hpm_common.h:189
static uint32_t gptmr_get_status(GPTMR_Type *ptr)
gptmr get status
Definition: hpm_gptmr_drv.h:347
static bool gptmr_check_status(GPTMR_Type *ptr, uint32_t mask)
gptmr check status
Definition: hpm_gptmr_drv.h:325
static uint32_t gptmr_channel_get_counter(GPTMR_Type *ptr, uint8_t ch_index, gptmr_counter_type_t capture)
gptmr channel get counter value
Definition: hpm_gptmr_drv.h:257
gptmr_dma_request_event
GPTMR DMA request event.
Definition: hpm_gptmr_drv.h:69
static uint32_t gptmr_channel_get_reload(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel get reload
Definition: hpm_gptmr_drv.h:433
static void gptmr_channel_enable_dma_request(GPTMR_Type *ptr, uint8_t ch_index, bool enable)
gptmr channel enable dma request
Definition: hpm_gptmr_drv.h:242
enum gptmr_dma_request_event gptmr_dma_request_event_t
GPTMR DMA request event.
static void gptmr_channel_enable(GPTMR_Type *ptr, uint8_t ch_index, bool enable)
gptmr channel enable
Definition: hpm_gptmr_drv.h:180
gptmr_synci_edge
GPTMR synci valid edge.
Definition: hpm_gptmr_drv.h:48
enum gptmr_work_mode gptmr_work_mode_t
GPTMR work mode.
static bool gptmr_channel_get_cmp_initial_polarity(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel get comparator initial output polarity
Definition: hpm_gptmr_drv.h:812
static gptmr_work_mode_t gptmr_channel_get_capmode(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel get capmode
Definition: hpm_gptmr_drv.h:405
static void gptmr_enable_irq(GPTMR_Type *ptr, uint32_t irq_mask)
gptmr enable irq
Definition: hpm_gptmr_drv.h:303
static void gptmr_start_counter(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel start counter
Definition: hpm_gptmr_drv.h:741
static void gptmr_trigger_channel_software_sync(GPTMR_Type *ptr, uint32_t ch_index_mask)
gptmr trigger channel software sync
Definition: hpm_gptmr_drv.h:288
gptmr_work_mode
GPTMR work mode.
Definition: hpm_gptmr_drv.h:58
static void gptmr_channel_set_cmp_initial_polarity(GPTMR_Type *ptr, uint8_t ch_index, bool high)
gptmr channel set comparator initial output polarity
Definition: hpm_gptmr_drv.h:797
enum gptmr_synci_edge gptmr_synci_edge_t
GPTMR synci valid edge.
struct gptmr_channel_cfg gptmr_channel_config_t
GPTMR counter mode.
static void gptmr_update_cmp(GPTMR_Type *ptr, uint8_t ch_index, uint8_t cmp_index, uint32_t cmp)
gptmr channel update comparator
Definition: hpm_gptmr_drv.h:418
void gptmr_channel_get_default_config(GPTMR_Type *ptr, gptmr_channel_config_t *config)
gptmr channel get default config
Definition: hpm_gptmr_drv.c:10
static void gptmr_disable_cmp_output(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel disable compare output
Definition: hpm_gptmr_drv.h:381
static gptmr_dma_request_event_t gptmr_channel_get_dma_request_event(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel get dma request event
Definition: hpm_gptmr_drv.h:460
hpm_stat_t gptmr_channel_config(GPTMR_Type *ptr, uint8_t ch_index, gptmr_channel_config_t *config, bool enable)
gptmr channel config
Definition: hpm_gptmr_drv.c:40
static void gptmr_channel_config_update_reload(GPTMR_Type *ptr, uint8_t ch_index, uint32_t reload)
gptmr channel update reload
Definition: hpm_gptmr_drv.h:445
static void gptmr_channel_select_synci_valid_edge(GPTMR_Type *ptr, uint8_t ch_index, gptmr_synci_edge_t edge)
gptmr channel slect synci valid edge
Definition: hpm_gptmr_drv.h:224
static void gptmr_channel_set_capmode(GPTMR_Type *ptr, uint8_t ch_index, gptmr_work_mode_t mode)
gptmr channel set capmode
Definition: hpm_gptmr_drv.h:393
static void gptmr_stop_counter(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel stop counter
Definition: hpm_gptmr_drv.h:359
static void gptmr_enable_cmp_output(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel enable compare output
Definition: hpm_gptmr_drv.h:370
enum gptmr_counter_type gptmr_counter_type_t
GPTMR counter type.
#define GPTMR_CH_CMP_COUNT
GPTMR one channel support output comparator count.
Definition: hpm_gptmr_drv.h:43
static void gptmr_clear_status(GPTMR_Type *ptr, uint32_t mask)
gptmr clear status
Definition: hpm_gptmr_drv.h:336
gptmr_counter_type
GPTMR counter type.
Definition: hpm_gptmr_drv.h:80
static void gptmr_channel_reset_count(GPTMR_Type *ptr, uint8_t ch_index)
gptmr channel reset counter
Definition: hpm_gptmr_drv.h:193
static void gptmr_disable_irq(GPTMR_Type *ptr, uint32_t irq_mask)
gptmr disable irq
Definition: hpm_gptmr_drv.h:314
static void gptmr_channel_update_count(GPTMR_Type *ptr, uint8_t ch_index, uint32_t value)
gptmr channel update counter
Definition: hpm_gptmr_drv.h:206
@ gptmr_dma_request_on_cmp1
Definition: hpm_gptmr_drv.h:71
@ gptmr_dma_request_on_cmp0
Definition: hpm_gptmr_drv.h:70
@ gptmr_dma_request_on_input_signal_toggle
Definition: hpm_gptmr_drv.h:72
@ gptmr_dma_request_on_reload
Definition: hpm_gptmr_drv.h:73
@ gptmr_dma_request_disabled
Definition: hpm_gptmr_drv.h:74
@ gptmr_synci_edge_falling
Definition: hpm_gptmr_drv.h:50
@ gptmr_synci_edge_both
Definition: hpm_gptmr_drv.h:52
@ gptmr_synci_edge_none
Definition: hpm_gptmr_drv.h:49
@ gptmr_synci_edge_rising
Definition: hpm_gptmr_drv.h:51
@ gptmr_work_mode_capture_at_rising_edge
Definition: hpm_gptmr_drv.h:60
@ gptmr_work_mode_no_capture
Definition: hpm_gptmr_drv.h:59
@ gptmr_work_mode_capture_at_both_edge
Definition: hpm_gptmr_drv.h:62
@ gptmr_work_mode_measure_width
Definition: hpm_gptmr_drv.h:63
@ gptmr_work_mode_capture_at_falling_edge
Definition: hpm_gptmr_drv.h:61
@ gptmr_counter_type_rising_edge
Definition: hpm_gptmr_drv.h:81
@ gptmr_counter_type_measured_duty_cycle
Definition: hpm_gptmr_drv.h:84
@ gptmr_counter_type_normal
Definition: hpm_gptmr_drv.h:85
@ gptmr_counter_type_measured_period
Definition: hpm_gptmr_drv.h:83
@ gptmr_counter_type_falling_edge
Definition: hpm_gptmr_drv.h:82
Definition: hpm_gptmr_regs.h:12
__RW uint32_t CNTUPTVAL
Definition: hpm_gptmr_regs.h:17
__R uint32_t CAPNEG
Definition: hpm_gptmr_regs.h:20
__RW uint32_t BURST_CFG
Definition: hpm_gptmr_regs.h:18
__R uint32_t BURST_COUNT
Definition: hpm_gptmr_regs.h:19
__R uint32_t CAPPRD
Definition: hpm_gptmr_regs.h:21
__RW uint32_t SR
Definition: hpm_gptmr_regs.h:27
__R uint32_t CAPPOS
Definition: hpm_gptmr_regs.h:19
__RW uint32_t CR
Definition: hpm_gptmr_regs.h:14
__R uint32_t CNT
Definition: hpm_gptmr_regs.h:23
__RW uint32_t IRQEN
Definition: hpm_gptmr_regs.h:28
__RW uint32_t RLD
Definition: hpm_gptmr_regs.h:16
__R uint32_t CAPDTY
Definition: hpm_gptmr_regs.h:22
__RW uint32_t CMP[2]
Definition: hpm_gptmr_regs.h:15
struct GPTMR_Type::@315 CHANNEL[4]
__W uint32_t GCR
Definition: hpm_gptmr_regs.h:29
GPTMR counter mode.
Definition: hpm_gptmr_drv.h:143
bool debug_mode
Definition: hpm_gptmr_drv.h:153
uint32_t cmp[(2U)]
Definition: hpm_gptmr_drv.h:147
bool enable_software_sync
Definition: hpm_gptmr_drv.h:152
bool cmp_initial_polarity_high
Definition: hpm_gptmr_drv.h:149
uint32_t reload
Definition: hpm_gptmr_drv.h:148
gptmr_work_mode_t mode
Definition: hpm_gptmr_drv.h:144
gptmr_synci_edge_t synci_edge
Definition: hpm_gptmr_drv.h:146
gptmr_dma_request_event_t dma_request_event
Definition: hpm_gptmr_drv.h:145
bool enable_sync_follow_previous_channel
Definition: hpm_gptmr_drv.h:151
bool enable_cmp_output
Definition: hpm_gptmr_drv.h:150
Monitor config.
Definition: hpm_sysctl_drv.h:299