123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- #ifndef NRFX_ADC_H__
- #define NRFX_ADC_H__
- #include <nrfx.h>
- #include <hal/nrf_adc.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRFX_ADC_EVT_DONE,
- NRFX_ADC_EVT_SAMPLE,
- } nrfx_adc_evt_type_t;
- typedef struct
- {
- nrf_adc_value_t * p_buffer;
- uint16_t size;
- } nrfx_adc_done_evt_t;
- typedef struct
- {
- nrf_adc_value_t sample;
- } nrfx_adc_sample_evt_t;
- typedef struct
- {
- nrfx_adc_evt_type_t type;
- union
- {
- nrfx_adc_done_evt_t done;
- nrfx_adc_sample_evt_t sample;
- } data;
- } nrfx_adc_evt_t;
- #define NRFX_ADC_DEFAULT_CHANNEL(analog_input) \
- { \
- NULL, \
- { \
- .resolution = NRF_ADC_CONFIG_RES_10BIT, \
- .scaling = NRF_ADC_CONFIG_SCALING_INPUT_FULL_SCALE, \
- .reference = NRF_ADC_CONFIG_REF_VBG, \
- .input = (analog_input), \
- .extref = NRF_ADC_CONFIG_EXTREFSEL_NONE \
- } \
- }
- typedef struct nrfx_adc_channel_s nrfx_adc_channel_t;
- struct nrfx_adc_channel_s
- {
- nrfx_adc_channel_t * p_next;
- nrf_adc_config_t config;
- };
- typedef struct
- {
- uint8_t interrupt_priority;
- } nrfx_adc_config_t;
- #define NRFX_ADC_DEFAULT_CONFIG \
- { \
- .interrupt_priority = NRFX_ADC_CONFIG_IRQ_PRIORITY \
- }
- typedef void (*nrfx_adc_event_handler_t)(nrfx_adc_evt_t const * p_event);
- nrfx_err_t nrfx_adc_init(nrfx_adc_config_t const * p_config,
- nrfx_adc_event_handler_t event_handler);
- void nrfx_adc_uninit(void);
- void nrfx_adc_channel_enable(nrfx_adc_channel_t * const p_channel);
- void nrfx_adc_channel_disable(nrfx_adc_channel_t * const p_channel);
- void nrfx_adc_all_channels_disable(void);
- void nrfx_adc_sample(void);
- nrfx_err_t nrfx_adc_sample_convert(nrfx_adc_channel_t const * const p_channel,
- nrf_adc_value_t * p_value);
- nrfx_err_t nrfx_adc_buffer_convert(nrf_adc_value_t * buffer, uint16_t size);
- bool nrfx_adc_is_busy(void);
- __STATIC_INLINE uint32_t nrfx_adc_start_task_get(void);
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE uint32_t nrfx_adc_start_task_get(void)
- {
- return nrf_adc_task_address_get(NRF_ADC_TASK_START);
- }
- #endif
- void nrfx_adc_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|