123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- #ifndef NRFX_I2S_H__
- #define NRFX_I2S_H__
- #include <nrfx.h>
- #include <hal/nrf_i2s.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRFX_I2S_PIN_NOT_USED 0xFF
- typedef struct
- {
- uint8_t sck_pin;
- uint8_t lrck_pin;
- uint8_t mck_pin;
-
- uint8_t sdout_pin;
-
- uint8_t sdin_pin;
-
- uint8_t irq_priority;
- nrf_i2s_mode_t mode;
- nrf_i2s_format_t format;
- nrf_i2s_align_t alignment;
- nrf_i2s_swidth_t sample_width;
- nrf_i2s_channels_t channels;
- nrf_i2s_mck_t mck_setup;
- nrf_i2s_ratio_t ratio;
- } nrfx_i2s_config_t;
- typedef struct
- {
- uint32_t * p_rx_buffer;
- uint32_t const * p_tx_buffer;
- } nrfx_i2s_buffers_t;
- #define NRFX_I2S_DEFAULT_CONFIG \
- { \
- .sck_pin = NRFX_I2S_CONFIG_SCK_PIN, \
- .lrck_pin = NRFX_I2S_CONFIG_LRCK_PIN, \
- .mck_pin = NRFX_I2S_CONFIG_MCK_PIN, \
- .sdout_pin = NRFX_I2S_CONFIG_SDOUT_PIN, \
- .sdin_pin = NRFX_I2S_CONFIG_SDIN_PIN, \
- .irq_priority = NRFX_I2S_CONFIG_IRQ_PRIORITY, \
- .mode = (nrf_i2s_mode_t)NRFX_I2S_CONFIG_MASTER, \
- .format = (nrf_i2s_format_t)NRFX_I2S_CONFIG_FORMAT, \
- .alignment = (nrf_i2s_align_t)NRFX_I2S_CONFIG_ALIGN, \
- .sample_width = (nrf_i2s_swidth_t)NRFX_I2S_CONFIG_SWIDTH, \
- .channels = (nrf_i2s_channels_t)NRFX_I2S_CONFIG_CHANNELS, \
- .mck_setup = (nrf_i2s_mck_t)NRFX_I2S_CONFIG_MCK_SETUP, \
- .ratio = (nrf_i2s_ratio_t)NRFX_I2S_CONFIG_RATIO, \
- }
- #define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED (1UL << 0)
-
- typedef void (* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const * p_released,
- uint32_t status);
- nrfx_err_t nrfx_i2s_init(nrfx_i2s_config_t const * p_config,
- nrfx_i2s_data_handler_t handler);
- void nrfx_i2s_uninit(void);
- nrfx_err_t nrfx_i2s_start(nrfx_i2s_buffers_t const * p_initial_buffers,
- uint16_t buffer_size,
- uint8_t flags);
- nrfx_err_t nrfx_i2s_next_buffers_set(nrfx_i2s_buffers_t const * p_buffers);
- void nrfx_i2s_stop(void);
- void nrfx_i2s_irq_handler(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|