29
29
#define PCNT_UNIT_ACTIVE 1
30
30
#define PCNT_UNIT_INACTIVE 0
31
31
32
- static uint8_t pcnt_state [4 ];
32
+ static uint8_t pcnt_unit_state [4 ];
33
+
34
+ void peripherals_pcnt_reset (void ) {
35
+ for (uint8_t i = 0 ; i <=3 ; i ++ ) {
36
+ pcnt_unit_state [i ] = PCNT_UNIT_INACTIVE ;
37
+ }
38
+ }
33
39
34
40
int peripherals_pcnt_init (pcnt_config_t pcnt_config ) {
35
41
// Look for available pcnt unit
36
42
for (uint8_t i = 0 ; i <=3 ; i ++ ) {
37
- if (pcnt_state [i ] == PCNT_UNIT_INACTIVE ) {
43
+ if (pcnt_unit_state [i ] == PCNT_UNIT_INACTIVE ) {
38
44
pcnt_config .unit = (pcnt_unit_t )i ;
39
- pcnt_state [i ] = PCNT_UNIT_ACTIVE ;
45
+ pcnt_unit_state [i ] = PCNT_UNIT_ACTIVE ;
40
46
break ;
41
47
} else if (i == 3 ) {
42
48
return -1 ;
@@ -46,10 +52,6 @@ int peripherals_pcnt_init(pcnt_config_t pcnt_config) {
46
52
// Initialize PCNT unit
47
53
pcnt_unit_config (& pcnt_config );
48
54
49
- // Configure and enable the input filter
50
- pcnt_set_filter_value (pcnt_config .unit , 100 );
51
- pcnt_filter_enable (pcnt_config .unit );
52
-
53
55
// Initialize PCNT's counter
54
56
pcnt_counter_pause (pcnt_config .unit );
55
57
pcnt_counter_clear (pcnt_config .unit );
@@ -61,6 +63,6 @@ int peripherals_pcnt_init(pcnt_config_t pcnt_config) {
61
63
}
62
64
63
65
void peripherals_pcnt_deinit (pcnt_unit_t * unit ) {
64
- pcnt_state [* unit ] = PCNT_UNIT_INACTIVE ;
66
+ pcnt_unit_state [* unit ] = PCNT_UNIT_INACTIVE ;
65
67
* unit = PCNT_UNIT_MAX ;
66
68
}
0 commit comments