nesper
nesper copied to clipboard
PCNT module has incorrect value definitions
This definition in pcnt.nim:
type
pcnt_evt_type_t* {.size: sizeof(cint).} = enum
PCNT_EVT_L_LIM = 0, ## !< PCNT watch point event: Minimum counter value
PCNT_EVT_H_LIM = 1, ## !< PCNT watch point event: Maximum counter value
PCNT_EVT_THRES_0 = 2, ## !< PCNT watch point event: threshold0 value event
PCNT_EVT_THRES_1 = 3, ## !< PCNT watch point event: threshold1 value event
PCNT_EVT_ZERO = 4, ## !< PCNT watch point event: counter value zero event
PCNT_EVT_MAX
Does not match the values defined in pcnt.h provided by ESP-IDF, which is
typedef enum {
PCNT_EVT_THRES_1 = 1 << 2, /*!< PCNT watch point event: threshold1 value event */
PCNT_EVT_THRES_0 = 1 << 3, /*!< PCNT watch point event: threshold0 value event */
PCNT_EVT_L_LIM = 1 << 4, /*!< PCNT watch point event: Minimum counter value */
PCNT_EVT_H_LIM = 1 << 5, /*!< PCNT watch point event: Maximum counter value */
PCNT_EVT_ZERO = 1 << 6, /*!< PCNT watch point event: counter value zero event */
PCNT_EVT_MAX
} pcnt_evt_type_t;
When pcnt_unit_config() is called, the error "PCNT value type error" is thrown. I assume this is not the intended behaviour.
The easiest fix I can see sould be to change the def in pcnt.nim to this:
type
pcnt_evt_type_t* {.size: sizeof(cint).} = enum
PCNT_EVT_THRES_1 = 4, ## !< PCNT watch point event: threshold1 value event
PCNT_EVT_THRES_0 = 8, ## !< PCNT watch point event: threshold0 value event
PCNT_EVT_L_LIM = 16, ## !< PCNT watch point event: Minimum counter value
PCNT_EVT_H_LIM = 32, ## !< PCNT watch point event: Maximum counter value
PCNT_EVT_ZERO = 64, ## !< PCNT watch point event: counter value zero event
PCNT_EVT_MAX
Note: I haven't checked any other versions of ESP-IDF/Nesper other than what I have installed, which is: ESP-IDF: v4.4.5 Nesper: 0.6.1
Thanks! Looks like the conversion missed the shift part. Could you make a PR for this?