123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- #ifndef NRFX_QDEC_H__
- #define NRFX_QDEC_H__
- #include <nrfx.h>
- #include <hal/nrf_qdec.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef struct
- {
- nrf_qdec_reportper_t reportper;
- nrf_qdec_sampleper_t sampleper;
- uint32_t psela;
- uint32_t pselb;
- uint32_t pselled;
- uint32_t ledpre;
- nrf_qdec_ledpol_t ledpol;
- bool dbfen;
- bool sample_inten;
- uint8_t interrupt_priority;
- } nrfx_qdec_config_t;
- #define NRFX_QDEC_DEFAULT_CONFIG \
- { \
- .reportper = (nrf_qdec_reportper_t)NRFX_QDEC_CONFIG_REPORTPER, \
- .sampleper = (nrf_qdec_sampleper_t)NRFX_QDEC_CONFIG_SAMPLEPER, \
- .psela = NRFX_QDEC_CONFIG_PIO_A, \
- .pselb = NRFX_QDEC_CONFIG_PIO_B, \
- .pselled = NRFX_QDEC_CONFIG_PIO_LED, \
- .ledpre = NRFX_QDEC_CONFIG_LEDPRE, \
- .ledpol = (nrf_qdec_ledpol_t)NRFX_QDEC_CONFIG_LEDPOL, \
- .dbfen = NRFX_QDEC_CONFIG_DBFEN, \
- .sample_inten = NRFX_QDEC_CONFIG_SAMPLE_INTEN, \
- .interrupt_priority = NRFX_QDEC_CONFIG_IRQ_PRIORITY, \
- }
- typedef struct
- {
- int8_t value;
- } nrfx_qdec_sample_data_evt_t;
- typedef struct
- {
- int16_t acc;
- uint16_t accdbl;
- } nrfx_qdec_report_data_evt_t;
- typedef struct
- {
- nrf_qdec_event_t type;
- union
- {
- nrfx_qdec_sample_data_evt_t sample;
- nrfx_qdec_report_data_evt_t report;
- } data;
- } nrfx_qdec_event_t;
- typedef void (*nrfx_qdec_event_handler_t)(nrfx_qdec_event_t event);
- nrfx_err_t nrfx_qdec_init(nrfx_qdec_config_t const * p_config,
- nrfx_qdec_event_handler_t event_handler);
- void nrfx_qdec_uninit(void);
- void nrfx_qdec_enable(void);
- void nrfx_qdec_disable(void);
- void nrfx_qdec_accumulators_read(int16_t * p_acc, int16_t * p_accdbl);
- __STATIC_INLINE uint32_t nrfx_qdec_task_address_get(nrf_qdec_task_t task)
- {
- return (uint32_t)nrf_qdec_task_address_get(task);
- }
- __STATIC_INLINE uint32_t nrfx_qdec_event_address_get(nrf_qdec_event_t event)
- {
- return (uint32_t)nrf_qdec_event_address_get(event);
- }
- void nrfx_qdec_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|