HPM SDK
HPMicro Software Development Kit
hpm_pdgo_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_PDGO_DRV_H
9 #define HPM_PDGO_DRV_H
10 
11 #include "hpm_common.h"
12 #include "hpm_pdgo_regs.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #define DGO_GPR_WORD_COUNT (8U)
19 #define DGO_WAKEUP_COUNTER_TICKS_PER_SEC (32768UL)
20 #define DGO_TURNOFF_COUNTER_TICKS_PER_SEC (24000000UL)
21 #define DGO_WAKEUP_TICK_IN_US (1000000UL / DGO_WAKEUP_COUNTER_TICKS_PER_SEC)
22 #define DGO_TURNOFF_TICKS_PER_US (DGO_TURNOFF_COUNTER_TICKS_PER_SEC / 1000000UL)
23 
27 typedef enum {
38 typedef enum {
50 typedef enum {
66 typedef enum {
72 
76 typedef enum {
79 
83 typedef enum {
86 
90 typedef enum {
96 
100 typedef enum {
107 
111 typedef enum {
128 
132 typedef enum {
138 
142 typedef enum {
146 
150 typedef enum {
154 
158 typedef enum {
164 
168 typedef enum {
183 
187 typedef enum {
193 
197 typedef enum {
203 
207 typedef enum {
213 
217 typedef enum {
222 
226 typedef enum {
236 
240 typedef enum {
246 
250 typedef struct {
251  bool enable;
254  uint16_t filter_length;
258 
262 typedef struct {
263  bool enable;
270  uint16_t cmp_value;
271  uint16_t period_value;
273 
274 typedef union {
275  uint8_t state;
276  struct {
277  uint8_t a_level : 1;
278  uint8_t b_level : 1;
279  uint8_t z_edge : 1;
280  uint8_t h_level : 1;
281  uint8_t : 4;
282  } level_mode;
283  struct {
284  uint8_t rise_forward : 1;
285  uint8_t fall_reverse : 1;
286  uint8_t fall_forward : 1;
287  uint8_t rise_reverse : 1;
288  uint8_t : 4;
289  } edge_mode;
291 
292 typedef struct {
293  uint8_t phase;
294  uint32_t line;
295  uint32_t revolution;
297 
301 typedef struct {
302  bool enable;
304  uint8_t phase_bias;
307  dgo_wuio_pin_num_t z_sel;
310  uint32_t resolution;
311  dgo_pcnt_z_mode_t z_mode;
312  dgo_pcnt_sig_state_t z_state;
318  uint16_t tacho_len;
321  uint32_t cmp0_value;
322  uint32_t cmp1_value;
324 
339 static inline void pdgo_set_turnoff_counter(PDGO_Type *ptr, uint32_t counter)
340 {
341  ptr->DGO_TURNOFF = counter;
342 }
343 
348 static inline void pdgo_enable_software_wakeup(PDGO_Type *ptr)
349 {
351 }
352 
357 static inline void pdgo_disable_software_wakeup(PDGO_Type *ptr)
358 {
360 }
361 
367 static inline void pdgo_set_wakeup_counter(PDGO_Type *ptr, uint32_t counter)
368 {
369  ptr->WKUP_CYC = 0;
370  ptr->WAKEUP = counter;
371 }
372 
379 static inline uint32_t pdgo_get_wakeup_counter(PDGO_Type *ptr)
380 {
381  return ptr->WAKEUP;
382 }
383 
389 static inline void pdgo_set_cycle_wakeup_counter(PDGO_Type *ptr, uint32_t counter)
390 {
391  ptr->WKUP_CYC = counter;
392 }
393 
398 static inline void pdgo_enable_wkup_pin_wakeup(PDGO_Type *ptr)
399 {
401 }
402 
407 static inline void pdgo_disable_wkup_pin_wakeup(PDGO_Type *ptr)
408 {
410 }
411 
416 static inline void pdgo_enable_wuio_pins_wakeup(PDGO_Type *ptr)
417 {
419 }
420 
425 static inline void pdgo_disable_wuio_pins_wakeup(PDGO_Type *ptr)
426 {
428 }
429 
435 {
437 }
438 
444 {
446 }
447 
453 {
455 }
456 
462 {
464 }
465 
471 static inline void pdgo_enable_wakeup_by_bit_mask(PDGO_Type *ptr, uint32_t mask)
472 {
473  ptr->WKUP_EN |= mask;
474 }
475 
481 static inline void pdgo_disable_wakeup_by_bit_mask(PDGO_Type *ptr, uint32_t mask)
482 {
483  ptr->WKUP_EN &= ~mask;
484 }
485 
492 static inline uint32_t pdgo_get_wakeup_status(PDGO_Type *ptr)
493 {
494  return ptr->WKUP_STS;
495 }
496 
502 static inline void pdgo_clear_wakeup_status(PDGO_Type *ptr, uint32_t mask)
503 {
504  ptr->WKUP_STS = mask;
505 }
506 
511 static inline void pdgo_disable_all_irq(PDGO_Type *ptr)
512 {
513  ptr->IRQ0_EN = 0;
514  ptr->IRQ1_EN = 0;
515 }
516 
523 {
524  ptr->IRQ0_EN |= mask;
525 }
526 
533 {
534  ptr->IRQ0_EN &= ~mask;
535 }
536 
541 static inline uint32_t pdgo_get_irq0_en(PDGO_Type *ptr)
542 {
543  return ptr->IRQ0_EN;
544 }
545 
552 static inline uint32_t pdgo_get_irq0_status(PDGO_Type *ptr)
553 {
554  return ptr->IRQ0_STS;
555 }
556 
562 static inline void pdgo_clear_irq0_status(PDGO_Type *ptr, uint32_t mask)
563 {
564  ptr->IRQ0_STS = mask;
565 }
566 
573 {
574  ptr->IRQ1_EN |= mask;
575 }
576 
583 {
584  ptr->IRQ1_EN &= ~mask;
585 }
586 
591 static inline uint32_t pdgo_get_irq1_en(PDGO_Type *ptr)
592 {
593  return ptr->IRQ1_EN;
594 }
595 
602 static inline uint32_t pdgo_get_irq1_status(PDGO_Type *ptr)
603 {
604  return ptr->IRQ1_STS;
605 }
606 
612 static inline void pdgo_clear_irq1_status(PDGO_Type *ptr, uint32_t mask)
613 {
614  ptr->IRQ1_STS = mask;
615 }
616 
621 static inline void pdgo_enable_retention_mode(PDGO_Type *ptr)
622 {
624 }
625 
634 {
635  return ((ptr->DGO_CTRL & PDGO_DGO_CTRL_RET_MASK) != 0U);
636 }
637 
642 static inline void pdgo_disable_retention_mode(PDGO_Type *ptr)
643 {
645 }
646 
652 {
654 }
655 
661 {
663 }
664 
670 {
672 }
673 
679 {
681 }
682 
689 {
690  ptr->PIN_CTRL &= ~(PDGO_PIN_CTRL_WUIO0_MASK << num);
691 }
692 
699 {
700  ptr->PIN_CTRL |= (PDGO_PIN_CTRL_WUIO0_MASK << num);
701 }
702 
709 static inline void pdgo_write_gpr(PDGO_Type *ptr, uint32_t index, uint32_t content)
710 {
711  if (index < DGO_GPR_WORD_COUNT) {
712  ptr->GPR[index] = content;
713  }
714 }
715 
723 static inline uint32_t pdgo_read_gpr(PDGO_Type *ptr, uint32_t index)
724 {
725  uint32_t reg_val = 0;
726  if (index < DGO_GPR_WORD_COUNT) {
727  reg_val = ptr->GPR[index];
728  }
729  return reg_val;
730 }
731 
738 static inline uint32_t pdgo_get_wakeup_counter_from_us(uint32_t us)
739 {
740  return (us + DGO_WAKEUP_TICK_IN_US - 1U) / DGO_WAKEUP_TICK_IN_US;
741 }
742 
749 static inline uint32_t pdgo_get_us_from_wakeup_counter(uint32_t counter)
750 {
751  return (counter * DGO_WAKEUP_TICK_IN_US);
752 }
753 
760 static inline uint32_t pdgo_get_turnoff_counter_from_us(uint32_t us)
761 {
762  return (us * DGO_TURNOFF_TICKS_PER_US);
763 }
764 
771 static inline uint32_t pdgo_get_us_from_turnoff_counter(uint32_t counter)
772 {
773  return (counter + DGO_TURNOFF_TICKS_PER_US - 1U) / DGO_TURNOFF_TICKS_PER_US;
774 }
775 
782 static inline void pdgo_set_wuio_pin_enable(PDGO_Type *ptr, dgo_wuio_pin_num_t num, bool enable)
783 {
784  ptr->IOFILTER[num] = (ptr->IOFILTER[num] & ~PDGO_IOFILTER_EN_MASK) | PDGO_IOFILTER_EN_SET(enable);
785 }
786 
793 static inline void pdgo_set_pcap_enable(PDGO_Type *ptr, dgo_pcap_num_t num, bool enable)
794 {
795  ptr->PCAP[num].CTRL = (ptr->PCAP[num].CTRL & ~PDGO_PCAP_CTRL_EN_MASK) | PDGO_PCAP_CTRL_EN_SET(enable);
796 }
797 
804 static inline void pdgo_set_pcap_counter_value(PDGO_Type *ptr, dgo_pcap_num_t num, uint16_t value)
805 {
806  ptr->PCAP[num].COUNTER = value;
807  while (PDGO_PCAP_COUNTER_COUNTER_GET(ptr->PCAP[num].COUNTER) != value) {
808  ;
809  }
810 }
811 
819 static inline uint16_t pdgo_get_pcap_counter_value(PDGO_Type *ptr, dgo_pcap_num_t num)
820 {
821  return PDGO_PCAP_COUNTER_COUNTER_GET(ptr->PCAP[num].COUNTER);
822 }
823 
830 static inline void pdgo_set_pcnt_enable(PDGO_Type *ptr, dgo_pcnt_num_t num, bool enable)
831 {
832  ptr->PCNT[num].CNT_CFG = (ptr->PCNT[num].CNT_CFG & ~PDGO_PCNT_CNT_CFG_EN_MASK) | PDGO_PCNT_CNT_CFG_EN_SET(enable);
833 }
834 
842 {
844 }
845 
852 static inline void pdgo_set_pcnt_cmp0_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
853 {
854  ptr->PCNT[num].CMP0 = value;
855  while (ptr->PCNT[num].CMP0 != value) {
856  ;
857  }
858 }
859 
866 static inline void pdgo_set_pcnt_cmp1_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
867 {
868  ptr->PCNT[num].CMP1 = value;
869  while (ptr->PCNT[num].CMP1 != value) {
870  ;
871  }
872 }
873 
880 static inline void pdgo_set_pcnt_raw_counter_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
881 {
882  uint8_t bias = PDGO_PCNT_CNT_CFG_BIAS_GET(ptr->PCNT[num].CNT_CFG);
883 
884  ptr->PCNT[num].CNT = value;
885  while (ptr->PCNT[num].CNT != (value + bias)) {
886  ;
887  }
888 }
889 
898 {
899  return ptr->PCNT[num].CNT;
900 }
901 
908 {
910 }
911 
918 {
920 }
921 
928 static inline void pdgo_set_pcnt_dir_override_value(PDGO_Type *ptr, dgo_pcnt_num_t num, bool reverse)
929 {
931 }
932 
940 
948 
956 
964 
972 
982 
990 void pdgo_config_pcnt_range_compare(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t cmp0, uint32_t cmp1);
991 
1000 
1005 #ifdef __cplusplus
1006 }
1007 #endif
1008 
1009 #endif /* HPM_DGO_DRV_H */
dgo_pcap_cnt_mode_t
pulse capture counter mode
Definition: hpm_pdgo_drv.h:150
@ dgo_pcap_cnt_period
Definition: hpm_pdgo_drv.h:152
@ dgo_pcap_cnt_oneshot
Definition: hpm_pdgo_drv.h:151
dgo_pcnt_dump_mode_t
pulse counter dump mode
Definition: hpm_pdgo_drv.h:207
@ dgo_pcnt_dump_h_edge_mode
Definition: hpm_pdgo_drv.h:209
@ dgo_pcnt_dump_disable
Definition: hpm_pdgo_drv.h:208
@ dgo_pcnt_dump_h_level_mode_with_ab
Definition: hpm_pdgo_drv.h:210
@ dgo_pcnt_dump_h_level_mode
Definition: hpm_pdgo_drv.h:211
dgo_pcap_cnt_event_t
pulse capture counter event
Definition: hpm_pdgo_drv.h:158
@ dgo_pcap_cnt_wuio_fall_edge
Definition: hpm_pdgo_drv.h:161
@ dgo_pcap_cnt_wuio_both_edge
Definition: hpm_pdgo_drv.h:162
@ dgo_pcap_cnt_internal_clk
Definition: hpm_pdgo_drv.h:159
@ dgo_pcap_cnt_wuio_rise_edge
Definition: hpm_pdgo_drv.h:160
dgo_pcap_match_mode_t
pulse capture match mode
Definition: hpm_pdgo_drv.h:111
@ dgo_pcap_match_mode_highdump_le_cmp
Definition: hpm_pdgo_drv.h:116
@ dgo_pcap_match_mode_lowdump_le_cmp
Definition: hpm_pdgo_drv.h:118
@ dgo_pcap_match_mode_highdump_add_lowdump_le_cmp
Definition: hpm_pdgo_drv.h:120
@ dgo_pcap_match_mode_lowdump_minus_highdump_ge_cmp
Definition: hpm_pdgo_drv.h:125
@ dgo_pcap_match_mode_highdump_ge_cmp
Definition: hpm_pdgo_drv.h:115
@ dgo_pcap_match_mode_lowdump_minus_highdump_le_cmp
Definition: hpm_pdgo_drv.h:124
@ dgo_pcap_match_mode_highdump_add_lowdump_ge_cmp
Definition: hpm_pdgo_drv.h:119
@ dgo_pcap_match_mode_cnt_le_cmp
Definition: hpm_pdgo_drv.h:114
@ dgo_pcap_match_mode_lowdump_ge_cmp
Definition: hpm_pdgo_drv.h:117
@ dgo_pcap_match_disable
Definition: hpm_pdgo_drv.h:112
@ dgo_pcap_match_mode_highdump_minus_lowdump_le_cmp
Definition: hpm_pdgo_drv.h:126
@ dgo_pcap_match_mode_abs_highdump_minus_lowdump_le_cmp
Definition: hpm_pdgo_drv.h:122
@ dgo_pcap_match_mode_cnt_ge_cmp
Definition: hpm_pdgo_drv.h:113
@ dgo_pcap_match_mode_highdump_minus_lowdump_ge_cmp
Definition: hpm_pdgo_drv.h:123
@ dgo_pcap_match_mode_abs_highdump_minus_lowdump_ge_cmp
Definition: hpm_pdgo_drv.h:121
dgo_pcnt_num_t
pulse counter number
Definition: hpm_pdgo_drv.h:83
@ dgo_pcnt_0
Definition: hpm_pdgo_drv.h:84
#define DGO_TURNOFF_TICKS_PER_US
Definition: hpm_pdgo_drv.h:22
#define DGO_GPR_WORD_COUNT
Definition: hpm_pdgo_drv.h:18
dgo_wuio_irq_mode_t
filter mode
Definition: hpm_pdgo_drv.h:90
@ dgo_wuio_irq_rise_edge_mode
Definition: hpm_pdgo_drv.h:93
@ dgo_wuio_irq_disable
Definition: hpm_pdgo_drv.h:91
@ dgo_wuio_irq_both_edge_mode
Definition: hpm_pdgo_drv.h:94
@ dgo_wuio_irq_level_mode
Definition: hpm_pdgo_drv.h:92
dgo_pcnt_decode_mode_t
pulse counter decode mode
Definition: hpm_pdgo_drv.h:168
@ dgo_pcnt_ud_f_1x
Definition: hpm_pdgo_drv.h:177
@ dgo_pcnt_ab_4x
Definition: hpm_pdgo_drv.h:169
@ dgo_pcnt_pd_f_2x
Definition: hpm_pdgo_drv.h:175
@ dgo_pcnt_ud_f_2x
Definition: hpm_pdgo_drv.h:179
@ dgo_pcnt_ab_2x
Definition: hpm_pdgo_drv.h:170
@ dgo_pcnt_pd_f_1x
Definition: hpm_pdgo_drv.h:173
@ dgo_pcnt_ab_1x
Definition: hpm_pdgo_drv.h:171
@ dgo_pcnt_pd_2x
Definition: hpm_pdgo_drv.h:174
@ dgo_pcnt_ud_1x
Definition: hpm_pdgo_drv.h:176
@ dgo_pcnt_ud_uvw_6y
Definition: hpm_pdgo_drv.h:181
@ dgo_pcnt_ud_2x
Definition: hpm_pdgo_drv.h:178
@ dgo_pcnt_pd_1x
Definition: hpm_pdgo_drv.h:172
@ dgo_pcnt_ud_uvw_6x
Definition: hpm_pdgo_drv.h:180
dgo_irq0_bit_mask_t
irq0 source
Definition: hpm_pdgo_drv.h:38
@ dgo_irq0_wuio2_pin
Definition: hpm_pdgo_drv.h:43
@ dgo_irq0_wkup_pin
Definition: hpm_pdgo_drv.h:39
@ dgo_irq0_wuio3_pin
Definition: hpm_pdgo_drv.h:44
@ dgo_irq0_wuio1_pin
Definition: hpm_pdgo_drv.h:42
@ dgo_irq0_software
Definition: hpm_pdgo_drv.h:40
@ dgo_irq0_wuio0_pin
Definition: hpm_pdgo_drv.h:41
dgo_pcnt_z_mode_t
pulse counter z phase mode
Definition: hpm_pdgo_drv.h:187
@ dgo_pcnt_z_level_mode
Definition: hpm_pdgo_drv.h:191
@ dgo_pcnt_z_disable
Definition: hpm_pdgo_drv.h:188
@ dgo_pcnt_z_edge_mode
Definition: hpm_pdgo_drv.h:189
@ dgo_pcnt_z_level_mode_with_ab
Definition: hpm_pdgo_drv.h:190
dgo_pcnt_h_mode_t
pulse counter h phase mode
Definition: hpm_pdgo_drv.h:197
@ dgo_pcnt_h_edge_mode
Definition: hpm_pdgo_drv.h:199
@ dgo_pcnt_h_level_mode_with_ab
Definition: hpm_pdgo_drv.h:200
@ dgo_pcnt_h_level_mode
Definition: hpm_pdgo_drv.h:201
@ dgo_pcnt_h_disable
Definition: hpm_pdgo_drv.h:198
dgo_pcnt_tacho_mode_t
pulse counter tacho mode
Definition: hpm_pdgo_drv.h:217
@ dgo_pcnt_tacho_period_mode
Definition: hpm_pdgo_drv.h:219
@ dgo_pcnt_tacho_travel_mode
Definition: hpm_pdgo_drv.h:220
@ dgo_pcnt_tacho_disable
Definition: hpm_pdgo_drv.h:218
dgo_pcap_cnt_dir_t
pulse capture counter direction
Definition: hpm_pdgo_drv.h:142
@ dgo_pcap_cnt_up
Definition: hpm_pdgo_drv.h:143
@ dgo_pcap_cnt_down
Definition: hpm_pdgo_drv.h:144
dgo_pcap_dump_mode_t
pulse capture dump mode
Definition: hpm_pdgo_drv.h:132
@ dgo_pcap_dump_disable
Definition: hpm_pdgo_drv.h:133
@ dgo_pcap_dump_wuio_fall_edge
Definition: hpm_pdgo_drv.h:135
@ dgo_pcap_dump_cnt_finish
Definition: hpm_pdgo_drv.h:136
@ dgo_pcap_dump_wuio_rise_edge
Definition: hpm_pdgo_drv.h:134
dgo_pcap_num_t
pulse capture number
Definition: hpm_pdgo_drv.h:76
@ dgo_pcap_0
Definition: hpm_pdgo_drv.h:77
dgo_wakeup_bit_mask_t
wakeup source
Definition: hpm_pdgo_drv.h:27
@ dgo_wakeup_pcnt0
Definition: hpm_pdgo_drv.h:32
@ dgo_wakeup_wkup_pin
Definition: hpm_pdgo_drv.h:28
@ dgo_wakeup_software
Definition: hpm_pdgo_drv.h:29
@ dgo_wakeup_wuio_pins
Definition: hpm_pdgo_drv.h:30
@ dgo_wakeup_pcap0
Definition: hpm_pdgo_drv.h:31
#define DGO_WAKEUP_TICK_IN_US
Definition: hpm_pdgo_drv.h:21
dgo_pcnt_cmp_mode_t
pulse counter compare mode
Definition: hpm_pdgo_drv.h:226
@ dgo_pcnt_cmp_match_forward_mode1
Definition: hpm_pdgo_drv.h:232
@ dgo_pcnt_cmp_match_forward_mode0
Definition: hpm_pdgo_drv.h:231
@ dgo_pcnt_cmp_match_mode0
Definition: hpm_pdgo_drv.h:229
@ dgo_pcnt_cmp_disable
Definition: hpm_pdgo_drv.h:227
@ dgo_pcnt_cmp_range_match_mode
Definition: hpm_pdgo_drv.h:228
@ dgo_pcnt_cmp_match_mode1
Definition: hpm_pdgo_drv.h:230
@ dgo_pcnt_cmp_match_reverse_mode0
Definition: hpm_pdgo_drv.h:233
@ dgo_pcnt_cmp_match_reverse_mode1
Definition: hpm_pdgo_drv.h:234
dgo_irq1_bit_mask_t
irq0 source
Definition: hpm_pdgo_drv.h:50
@ dgo_irq1_pcnt0_update
Definition: hpm_pdgo_drv.h:54
@ dgo_irq1_pcnt0_cmp0_match
Definition: hpm_pdgo_drv.h:57
@ dgo_irq1_pcap0_dump
Definition: hpm_pdgo_drv.h:52
@ dgo_irq1_pcap0_match
Definition: hpm_pdgo_drv.h:53
@ dgo_irq1_pcnt0_seq_err
Definition: hpm_pdgo_drv.h:60
@ dgo_irq1_pcap0_period
Definition: hpm_pdgo_drv.h:51
@ dgo_irq1_pcnt0_z_match
Definition: hpm_pdgo_drv.h:55
@ dgo_irq1_pcnt0_dec_err
Definition: hpm_pdgo_drv.h:59
@ dgo_irq1_pcnt0_tacho
Definition: hpm_pdgo_drv.h:58
@ dgo_irq1_pcnt0_h_match
Definition: hpm_pdgo_drv.h:56
dgo_wuio_pin_num_t
wuio pin number
Definition: hpm_pdgo_drv.h:66
@ dgo_wuio_pin_0
Definition: hpm_pdgo_drv.h:67
@ dgo_wuio_pin_2
Definition: hpm_pdgo_drv.h:69
@ dgo_wuio_pin_3
Definition: hpm_pdgo_drv.h:70
@ dgo_wuio_pin_1
Definition: hpm_pdgo_drv.h:68
dgo_filter_mode_t
filter mode
Definition: hpm_pdgo_drv.h:100
@ dgo_filter_mode_stable_high
Definition: hpm_pdgo_drv.h:103
@ dgo_filter_mode_rapid_change
Definition: hpm_pdgo_drv.h:101
@ dgo_filter_mode_delay
Definition: hpm_pdgo_drv.h:102
@ dgo_filter_mode_bypass
Definition: hpm_pdgo_drv.h:105
@ dgo_filter_mode_stable_low
Definition: hpm_pdgo_drv.h:104
dgo_pcnt_range_cmp_src_t
pulse counter range match mode compare source
Definition: hpm_pdgo_drv.h:240
@ dgo_pcnt_cmp_src_tacho_line
Definition: hpm_pdgo_drv.h:243
@ dgo_pcnt_cmp_src_tacho_time
Definition: hpm_pdgo_drv.h:244
@ dgo_pcnt_cmp_src_line_phase
Definition: hpm_pdgo_drv.h:241
@ dgo_pcnt_cmp_src_revolution_line_phase
Definition: hpm_pdgo_drv.h:242
static uint32_t pdgo_get_us_from_turnoff_counter(uint32_t counter)
Convert the DGO Turn-off counter to microseconds.
Definition: hpm_pdgo_drv.h:771
static uint32_t pdgo_get_wakeup_counter(PDGO_Type *ptr)
Get DGO wakeup counter value.
Definition: hpm_pdgo_drv.h:379
static uint32_t pdgo_get_us_from_wakeup_counter(uint32_t counter)
Convert the DGO Wake-up counter to microseconds.
Definition: hpm_pdgo_drv.h:749
static void pdgo_enable_pullup_resistor_for_reset_pin(PDGO_Type *ptr)
Enable pull-up resistor for Reset Pin.
Definition: hpm_pdgo_drv.h:651
static void pdgo_enable_pulldown_resistor_for_wakeup_pin(PDGO_Type *ptr)
Definition: hpm_pdgo_drv.h:669
static bool pdgo_is_retention_mode_enabled(PDGO_Type *ptr)
Check whether the DGO retention mode is enabled or not.
Definition: hpm_pdgo_drv.h:633
static void pdgo_enable_retention_mode(PDGO_Type *ptr)
Enable DGO register retention mode.
Definition: hpm_pdgo_drv.h:621
static void pdgo_disable_pullup_resistor_for_reset_pin(PDGO_Type *ptr)
Disable pull-up resistor for Reset Pin.
Definition: hpm_pdgo_drv.h:660
static void pdgo_disable_retention_mode(PDGO_Type *ptr)
Disable DGO register retention mode.
Definition: hpm_pdgo_drv.h:642
static uint32_t pdgo_get_wakeup_counter_from_us(uint32_t us)
Convert the microsecond to DGO Wake-up counter value.
Definition: hpm_pdgo_drv.h:738
static void pdgo_disable_pulldown_resistor_for_wakeup_pin(PDGO_Type *ptr)
Definition: hpm_pdgo_drv.h:678
static uint32_t pdgo_read_gpr(PDGO_Type *ptr, uint32_t index)
Read data from DGO GPR register.
Definition: hpm_pdgo_drv.h:723
static void pdgo_write_gpr(PDGO_Type *ptr, uint32_t index, uint32_t content)
Write data to DGO GPR register.
Definition: hpm_pdgo_drv.h:709
static uint32_t pdgo_get_turnoff_counter_from_us(uint32_t us)
Convert the microsecond to DGO Turn-off counter value.
Definition: hpm_pdgo_drv.h:760
static void pdgo_set_wakeup_counter(PDGO_Type *ptr, uint32_t counter)
Set DGO wakeup counter.
Definition: hpm_pdgo_drv.h:367
static void pdgo_set_turnoff_counter(PDGO_Type *ptr, uint32_t counter)
Set DGO turn-off counter.
Definition: hpm_pdgo_drv.h:339
#define PDGO_PCNT_HOMING_CFG_CMP0_MODE_MASK
Definition: hpm_pdgo_regs.h:1289
#define PDGO_PIN_CTRL_RSTN_MASK
Definition: hpm_pdgo_regs.h:157
#define PDGO_IRQ0_EN_WUIO3_MASK
Definition: hpm_pdgo_regs.h:469
#define PDGO_IRQ0_EN_WUIO2_MASK
Definition: hpm_pdgo_regs.h:481
#define PDGO_DGO_CTRL_RET_MASK
Definition: hpm_pdgo_regs.h:120
#define PDGO_PCNT_CNT_CFG_BIAS_GET(x)
Definition: hpm_pdgo_regs.h:1113
#define PDGO_PIN_CTRL_WKUP_MASK
Definition: hpm_pdgo_regs.h:169
#define PDGO_PCAP_CTRL_EN_MASK
Definition: hpm_pdgo_regs.h:928
#define PDGO_IRQ1_EN_PCAP0_DUMP_MASK
Definition: hpm_pdgo_regs.h:687
#define PDGO_IRQ1_EN_PCNT0_HOME_MASK
Definition: hpm_pdgo_regs.h:639
#define PDGO_PCNT_CNT_CFG_EN_SET(x)
Definition: hpm_pdgo_regs.h:1073
#define PDGO_IRQ0_EN_WUIO1_MASK
Definition: hpm_pdgo_regs.h:493
#define PDGO_IRQ1_EN_PCAP0_MATCH_MASK
Definition: hpm_pdgo_regs.h:675
#define PDGO_WKUP_EN_PCNT0_MASK
Definition: hpm_pdgo_regs.h:319
#define PDGO_IRQ0_EN_WKUP_MASK
Definition: hpm_pdgo_regs.h:457
#define PDGO_PCNT_CNT_CFG_OVRD_MASK
Definition: hpm_pdgo_regs.h:1083
#define PDGO_IRQ1_EN_PCNT0_DECERR_MASK
Definition: hpm_pdgo_regs.h:603
#define PDGO_PCAP_COUNTER_COUNTER_GET(x)
Definition: hpm_pdgo_regs.h:1039
#define PDGO_WKUP_EN_CYC_MASK
Definition: hpm_pdgo_regs.h:358
#define PDGO_PCNT_HOMING_CFG_CMP0_MODE_SET(x)
Definition: hpm_pdgo_regs.h:1291
#define PDGO_IRQ0_EN_CYC_MASK
Definition: hpm_pdgo_regs.h:445
#define PDGO_PCNT_DIRECTION_DIR_MASK
Definition: hpm_pdgo_regs.h:1401
#define PDGO_IRQ1_EN_PCNT0_SEQERR_MASK
Definition: hpm_pdgo_regs.h:591
#define PDGO_PCNT_DIRECTION_DIR_SET(x)
Definition: hpm_pdgo_regs.h:1403
#define PDGO_IOFILTER_EN_MASK
Definition: hpm_pdgo_regs.h:844
#define PDGO_PIN_CTRL_WUIO0_MASK
Definition: hpm_pdgo_regs.h:217
#define PDGO_WKUP_EN_PCAP0_MASK
Definition: hpm_pdgo_regs.h:332
#define PDGO_WKUP_EN_WUIO_MASK
Definition: hpm_pdgo_regs.h:345
#define PDGO_WKUP_EN_WKUP_MASK
Definition: hpm_pdgo_regs.h:371
#define PDGO_IRQ1_EN_PCNT0_MATCH0_MASK
Definition: hpm_pdgo_regs.h:627
#define PDGO_IOFILTER_EN_SET(x)
Definition: hpm_pdgo_regs.h:846
#define PDGO_IRQ1_EN_PCAP0_PERIOD_MASK
Definition: hpm_pdgo_regs.h:699
#define PDGO_IRQ1_EN_PCNT0_TACHO_MASK
Definition: hpm_pdgo_regs.h:615
#define PDGO_IRQ1_EN_PCNT0_Z_MASK
Definition: hpm_pdgo_regs.h:651
#define PDGO_PCAP_CTRL_EN_SET(x)
Definition: hpm_pdgo_regs.h:930
#define PDGO_IRQ0_EN_WUIO0_MASK
Definition: hpm_pdgo_regs.h:505
#define PDGO_PCNT_CNT_CFG_EN_MASK
Definition: hpm_pdgo_regs.h:1071
#define PDGO_IRQ1_EN_PCNT0_UPDATE_MASK
Definition: hpm_pdgo_regs.h:663
static int32_t bias
Definition: hpm_math.h:14118
static void pdgo_set_pcap_enable(PDGO_Type *ptr, dgo_pcap_num_t num, bool enable)
Set PCAP enable.
Definition: hpm_pdgo_drv.h:793
void pdgo_config_wuio_filter(PDGO_Type *ptr, dgo_wuio_pin_num_t num, dgo_wuio_filter_cfg_t *cfg)
Config wakeup IO filter.
Definition: hpm_pdgo_drv.c:11
static void pdgo_disable_all_irq(PDGO_Type *ptr)
Disable DGO all interrupts.
Definition: hpm_pdgo_drv.h:511
static void pdgo_enable_irq0_by_bit_mask(PDGO_Type *ptr, dgo_irq0_bit_mask_t mask)
Enable DGO interrupt0 by bit mask.
Definition: hpm_pdgo_drv.h:522
static uint32_t pdgo_get_wakeup_status(PDGO_Type *ptr)
Get Wake-up status.
Definition: hpm_pdgo_drv.h:492
static uint32_t pdgo_get_irq1_status(PDGO_Type *ptr)
Get irq1 status.
Definition: hpm_pdgo_drv.h:602
static void pdgo_disable_wkup_pin_wakeup(PDGO_Type *ptr)
Disable wkup pin Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:407
void pdgo_get_pcnt_counter(PDGO_Type *ptr, dgo_pcnt_num_t num, dgo_pcnt_counter_t *counter)
Get PCNT counter.
Definition: hpm_pdgo_drv.c:134
static void pdgo_disable_pulse_counter0_wakeup(PDGO_Type *ptr)
Disable pulse counter0 Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:461
static void pdgo_disable_software_wakeup(PDGO_Type *ptr)
Disable Software Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:357
static void pdgo_disable_pulldown_resistor_for_wuio_pin(PDGO_Type *ptr, dgo_wuio_pin_num_t num)
Definition: hpm_pdgo_drv.h:698
static void pdgo_set_pcnt_raw_counter_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
Set PCNT raw counter value.
Definition: hpm_pdgo_drv.h:880
void pdgo_config_pcnt(PDGO_Type *ptr, dgo_pcnt_num_t num, dgo_pcnt_cfg_t *cfg)
Config pulse capture.
Definition: hpm_pdgo_drv.c:81
static void pdgo_enable_software_wakeup(PDGO_Type *ptr)
Enable Software Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:348
static void pdgo_set_pcnt_enable(PDGO_Type *ptr, dgo_pcnt_num_t num, bool enable)
Set PCNT enable.
Definition: hpm_pdgo_drv.h:830
static uint32_t pdgo_get_pcnt_raw_counter_value(PDGO_Type *ptr, dgo_pcnt_num_t num)
Get PCNT raw counter value.
Definition: hpm_pdgo_drv.h:897
void pdgo_config_pcnt_range_compare(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t cmp0, uint32_t cmp1)
Config PCNT range compare.
Definition: hpm_pdgo_drv.c:236
static void pdgo_set_cycle_wakeup_counter(PDGO_Type *ptr, uint32_t counter)
Set DGO cycle wakeup counter.
Definition: hpm_pdgo_drv.h:389
static void pdgo_disable_pcnt_dir_override(PDGO_Type *ptr, dgo_pcnt_num_t num)
Disable PCNT dir override.
Definition: hpm_pdgo_drv.h:917
static void pdgo_enable_pulldown_resistor_for_wuio_pin(PDGO_Type *ptr, dgo_wuio_pin_num_t num)
Definition: hpm_pdgo_drv.h:688
static uint32_t pdgo_get_irq0_status(PDGO_Type *ptr)
Get irq0 status.
Definition: hpm_pdgo_drv.h:552
static void pdgo_clear_wakeup_status(PDGO_Type *ptr, uint32_t mask)
Clear Wake-up status.
Definition: hpm_pdgo_drv.h:502
static void pdgo_enable_wkup_pin_wakeup(PDGO_Type *ptr)
Enable wkup pin Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:398
static void pdgo_set_pcnt_dir_override_value(PDGO_Type *ptr, dgo_pcnt_num_t num, bool reverse)
Set PCNT dir override value.
Definition: hpm_pdgo_drv.h:928
static void pdgo_enable_pulse_capture0_wakeup(PDGO_Type *ptr)
Enable pulse capture0 Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:434
static void pdgo_clear_irq1_status(PDGO_Type *ptr, uint32_t mask)
Clear irq1 status.
Definition: hpm_pdgo_drv.h:612
static void pdgo_disable_irq1_by_bit_mask(PDGO_Type *ptr, dgo_irq1_bit_mask_t mask)
Disable DGO interrupt1 by bit mask.
Definition: hpm_pdgo_drv.h:582
static void pdgo_disable_pulse_capture0_wakeup(PDGO_Type *ptr)
Disable pulse capture0 Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:443
static uint32_t pdgo_get_irq0_en(PDGO_Type *ptr)
Get DGO interrupt0 enable status.
Definition: hpm_pdgo_drv.h:541
static void pdgo_enable_pulse_counter0_wakeup(PDGO_Type *ptr)
Enable pulse counter0 Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:452
static void pdgo_enable_irq1_by_bit_mask(PDGO_Type *ptr, dgo_irq1_bit_mask_t mask)
Enable DGO interrupt1 by bit mask.
Definition: hpm_pdgo_drv.h:572
static void pdgo_enable_wakeup_by_bit_mask(PDGO_Type *ptr, uint32_t mask)
Enable Wake-up by bit mask.
Definition: hpm_pdgo_drv.h:471
uint32_t pdgo_convert_pcnt_counter(PDGO_Type *ptr, dgo_pcnt_num_t num, dgo_pcnt_counter_t *counter)
Convert PCNT counter to raw counter value.
Definition: hpm_pdgo_drv.c:184
static void pdgo_enable_pcnt_dir_override(PDGO_Type *ptr, dgo_pcnt_num_t num)
Enable PCNT dir override.
Definition: hpm_pdgo_drv.h:907
static void pdgo_set_pcnt_cmp_mode(PDGO_Type *ptr, dgo_pcnt_num_t num, dgo_pcnt_cmp_mode_t mode)
Set PCNT cmp mode.
Definition: hpm_pdgo_drv.h:841
static uint32_t pdgo_get_irq1_en(PDGO_Type *ptr)
Get DGO interrupt1 enable status.
Definition: hpm_pdgo_drv.h:591
static void pdgo_set_pcap_counter_value(PDGO_Type *ptr, dgo_pcap_num_t num, uint16_t value)
Set PCAP counter value.
Definition: hpm_pdgo_drv.h:804
float pdgo_calc_pcnt_tacho_cycles_per_line(PDGO_Type *ptr, dgo_pcnt_num_t num)
Calculate PCNT tacho, unit: cycles per line.
Definition: hpm_pdgo_drv.c:244
static void pdgo_disable_wakeup_by_bit_mask(PDGO_Type *ptr, uint32_t mask)
Disable Wake-up by bit mask.
Definition: hpm_pdgo_drv.h:481
static void pdgo_disable_irq0_by_bit_mask(PDGO_Type *ptr, dgo_irq0_bit_mask_t mask)
Disable DGO interrupt0 by bit mask.
Definition: hpm_pdgo_drv.h:532
static void pdgo_set_wuio_pin_enable(PDGO_Type *ptr, dgo_wuio_pin_num_t num, bool enable)
Set WUIO pin enable.
Definition: hpm_pdgo_drv.h:782
static void pdgo_enable_wuio_pins_wakeup(PDGO_Type *ptr)
Enable wuio pins Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:416
static void pdgo_disable_wuio_pins_wakeup(PDGO_Type *ptr)
Disable wuio pins Wake-up feature on DGO.
Definition: hpm_pdgo_drv.h:425
void pdgo_get_pcnt_defconfig(PDGO_Type *ptr, dgo_pcnt_num_t num, dgo_pcnt_cfg_t *cfg)
Get pulse capture default config.
Definition: hpm_pdgo_drv.c:53
void pdgo_config_pcap(PDGO_Type *ptr, dgo_pcap_num_t num, dgo_pcap_cfg_t *cfg)
Config pulse capture.
Definition: hpm_pdgo_drv.c:33
static void pdgo_set_pcnt_cmp0_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
Set PCNT cmp0 value.
Definition: hpm_pdgo_drv.h:852
static void pdgo_set_pcnt_cmp1_value(PDGO_Type *ptr, dgo_pcnt_num_t num, uint32_t value)
Set PCNT cmp1 value.
Definition: hpm_pdgo_drv.h:866
static uint16_t pdgo_get_pcap_counter_value(PDGO_Type *ptr, dgo_pcap_num_t num)
Get PCAP counter value.
Definition: hpm_pdgo_drv.h:819
static void pdgo_clear_irq0_status(PDGO_Type *ptr, uint32_t mask)
Clear irq0 status.
Definition: hpm_pdgo_drv.h:562
Definition: hpm_pdgo_regs.h:12
__RW uint32_t IRQ0_STS
Definition: hpm_pdgo_regs.h:25
struct PDGO_Type::@397 PCAP[1]
__RW uint32_t IRQ1_EN
Definition: hpm_pdgo_regs.h:26
__RW uint32_t IRQ1_STS
Definition: hpm_pdgo_regs.h:27
__RW uint32_t DIRECTION
Definition: hpm_pdgo_regs.h:47
__RW uint32_t DGO_CTRL
Definition: hpm_pdgo_regs.h:15
__RW uint32_t CNT
Definition: hpm_pdgo_regs.h:50
__RW uint32_t WAKEUP
Definition: hpm_pdgo_regs.h:19
__RW uint32_t WKUP_STS
Definition: hpm_pdgo_regs.h:22
__W uint32_t DGO_TURNOFF
Definition: hpm_pdgo_regs.h:13
__RW uint32_t IRQ0_EN
Definition: hpm_pdgo_regs.h:24
struct PDGO_Type::@398 PCNT[1]
__RW uint32_t IOFILTER[4]
Definition: hpm_pdgo_regs.h:31
__RW uint32_t CMP0
Definition: hpm_pdgo_regs.h:48
__RW uint32_t COUNTER
Definition: hpm_pdgo_regs.h:37
__RW uint32_t GPR[8]
Definition: hpm_pdgo_regs.h:29
__RW uint32_t PIN_CTRL
Definition: hpm_pdgo_regs.h:17
__RW uint32_t WKUP_CYC
Definition: hpm_pdgo_regs.h:20
__RW uint32_t CNT_CFG
Definition: hpm_pdgo_regs.h:42
__RW uint32_t CMP1
Definition: hpm_pdgo_regs.h:49
__RW uint32_t HOMING_CFG
Definition: hpm_pdgo_regs.h:45
__RW uint32_t CTRL
Definition: hpm_pdgo_regs.h:34
__RW uint32_t WKUP_EN
Definition: hpm_pdgo_regs.h:21
pulse capture config structure
Definition: hpm_pdgo_drv.h:262
dgo_pcap_cnt_dir_t cnt_dir
Definition: hpm_pdgo_drv.h:267
uint16_t cmp_value
Definition: hpm_pdgo_drv.h:270
bool enable
Definition: hpm_pdgo_drv.h:263
dgo_pcap_match_mode_t match_mode
Definition: hpm_pdgo_drv.h:265
dgo_pcap_dump_mode_t dump_mode
Definition: hpm_pdgo_drv.h:266
dgo_pcap_cnt_mode_t cnt_mode
Definition: hpm_pdgo_drv.h:268
dgo_wuio_pin_num_t wuio_select
Definition: hpm_pdgo_drv.h:264
dgo_pcap_cnt_event_t cnt_event
Definition: hpm_pdgo_drv.h:269
uint16_t period_value
Definition: hpm_pdgo_drv.h:271
pulse counter config structure
Definition: hpm_pdgo_drv.h:301
dgo_wuio_pin_num_t a_sel
Definition: hpm_pdgo_drv.h:305
bool enable
Definition: hpm_pdgo_drv.h:302
bool dir_invert_en
Definition: hpm_pdgo_drv.h:303
dgo_wuio_pin_num_t b_sel
Definition: hpm_pdgo_drv.h:306
dgo_pcnt_sig_state_t dump_state
Definition: hpm_pdgo_drv.h:316
uint32_t cmp0_value
Definition: hpm_pdgo_drv.h:321
dgo_pcnt_h_mode_t h_mode
Definition: hpm_pdgo_drv.h:313
uint16_t tacho_len
Definition: hpm_pdgo_drv.h:318
dgo_wuio_pin_num_t h_sel
Definition: hpm_pdgo_drv.h:308
dgo_pcnt_sig_state_t h_state
Definition: hpm_pdgo_drv.h:314
dgo_pcnt_cmp_mode_t cmp0_mode
Definition: hpm_pdgo_drv.h:319
uint32_t resolution
Definition: hpm_pdgo_drv.h:310
dgo_pcnt_tacho_mode_t tacho_mode
Definition: hpm_pdgo_drv.h:317
dgo_pcnt_range_cmp_src_t range_cmp_src
Definition: hpm_pdgo_drv.h:320
dgo_pcnt_dump_mode_t dump_mode
Definition: hpm_pdgo_drv.h:315
uint8_t phase_bias
Definition: hpm_pdgo_drv.h:304
dgo_pcnt_decode_mode_t decode_mode
Definition: hpm_pdgo_drv.h:309
uint32_t cmp1_value
Definition: hpm_pdgo_drv.h:322
Definition: hpm_pdgo_drv.h:292
uint32_t line
Definition: hpm_pdgo_drv.h:294
uint32_t revolution
Definition: hpm_pdgo_drv.h:295
uint8_t phase
Definition: hpm_pdgo_drv.h:293
wakeup io pins filter config structure
Definition: hpm_pdgo_drv.h:250
bool enable
Definition: hpm_pdgo_drv.h:251
dgo_filter_mode_t filter_mode
Definition: hpm_pdgo_drv.h:255
bool output_init_value
Definition: hpm_pdgo_drv.h:253
dgo_wuio_irq_mode_t irq_mode
Definition: hpm_pdgo_drv.h:256
bool output_invert
Definition: hpm_pdgo_drv.h:252
uint16_t filter_length
Definition: hpm_pdgo_drv.h:254
Definition: hpm_pdgo_drv.h:274
uint8_t fall_reverse
Definition: hpm_pdgo_drv.h:285
uint8_t b_level
Definition: hpm_pdgo_drv.h:278
uint8_t a_level
Definition: hpm_pdgo_drv.h:277
uint8_t rise_reverse
Definition: hpm_pdgo_drv.h:287
uint8_t fall_forward
Definition: hpm_pdgo_drv.h:286
uint8_t state
Definition: hpm_pdgo_drv.h:275
uint8_t rise_forward
Definition: hpm_pdgo_drv.h:284
uint8_t h_level
Definition: hpm_pdgo_drv.h:280