Audio devices of the nRF52: the PDM and I2S interfaces.
More...
Audio devices of the nRF52: the PDM and I2S interfaces.
The PDM interface records one or two digital microphones at 16 kHz from a 1.28 MHz clock; its gain runs from -20 to +20 dB. The I2S interface plays mono at 16 kHz, sent as stereo with both channels equal, and runs as a slave when the link has PBL_AUDIO_FMT_CODEC_MASTER, still providing a 4 MHz master clock. Both keep the high-frequency crystal on while streaming.
void pbl_audio_nrf5_i2s_irq_handler(const struct pbl_audio_nrf5_i2s *i2s)
I2S interrupt handler, to connect with PBL_IRQ_CONNECT().
void pbl_audio_nrf5_pdm_irq_handler(const struct pbl_audio_nrf5_pdm *pdm)
PDM interrupt handler, to connect with PBL_IRQ_CONNECT().
#define PBL_IRQ_CONNECT(line, prio, isr, arg, flags)
Bind a SoC interrupt line to a handler at build time.
Definition irq.h:117
◆ pbl_audio_nrf5_pdm
| struct pbl_audio_nrf5_pdm |
| Data Fields |
|
struct pbl_audio |
audio |
Audio device. |
|
struct pbl_gpio |
clk |
Clock pin. |
|
int32_t |
default_gain_mdb |
Gain after initialization, in mdB. |
|
struct pbl_gpio |
din |
Data pin. |
|
struct pbl_audio_nrf5_pdm_state * |
state |
Driver runtime state. |
◆ pbl_audio_nrf5_i2s
| struct pbl_audio_nrf5_i2s |
| Data Fields |
|
struct pbl_audio |
audio |
Audio device. |
|
struct pbl_gpio |
lrck |
Frame clock pin. |
|
struct pbl_gpio |
mck |
Master clock pin. |
|
struct pbl_gpio |
sck |
Bit clock pin. |
|
struct pbl_gpio |
sdout |
Data out pin. |
|
struct pbl_audio_nrf5_i2s_state * |
state |
Driver runtime state. |
◆ PBL_AUDIO_NRF5_I2S_BOUNCE_FRAMES
| #define PBL_AUDIO_NRF5_I2S_BOUNCE_FRAMES 512U |
Stereo frames of an I2S bounce buffer.
◆ PBL_AUDIO_NRF5_I2S_DEFINE
| #define PBL_AUDIO_NRF5_I2S_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_link, |
|
|
|
... |
|
) |
| |
Value:
static struct pbl_audio_nrf5_i2s_state sym##_i2s_state; \
PBL_AUDIO_INIT(sym, _name,
PBL_AUDIO_PLAYBACK, &pbl_audio_nrf5_i2s_ops, _link,
nullptr), \
.
state = &sym##_i2s_state, \
__VA_ARGS__ \
}; \
PBL_DEVICE_REGISTER(sym, &sym.
audio.
dev)
struct pbl_audio audio
Audio device.
Definition nrf5.h:96
I2S interface.
Definition nrf5.h:94
struct pbl_audio_state * state
Runtime state.
Definition audio.h:308
struct pbl_device dev
Device.
Definition audio.h:304
#define PBL_AUDIO_STATE_DEFINE(sym)
Define the class state of an audio device.
Definition audio.h:331
@ PBL_AUDIO_PLAYBACK
From memory to the hardware.
Definition audio.h:88
Define the I2S interface, a playback device.
Periods are copied into stereo bounce buffers, so a period must fit one.
- Parameters
-
| sym | Symbol of the device. |
| _name | Device name. |
| _link | What the interface is wired to. |
| ... | Pins: sck, lrck, mck and sdout, from PBL_GPIO(). |
◆ PBL_AUDIO_NRF5_PDM_DEFINE
| #define PBL_AUDIO_NRF5_PDM_DEFINE |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_clk, |
|
|
|
_din, |
|
|
|
_default_gain_mdb |
|
) |
| |
Value:
static struct pbl_audio_nrf5_pdm_state sym##_pdm_state; \
PBL_AUDIO_INIT(sym, _name,
PBL_AUDIO_CAPTURE, &pbl_audio_nrf5_pdm_ops,
nullptr,
nullptr), \
.clk = _clk, \
.din = _din, \
.default_gain_mdb = (_default_gain_mdb), \
.
state = &sym##_pdm_state, \
}; \
PBL_DEVICE_REGISTER(sym, &sym.
audio.
dev)
struct pbl_audio audio
Audio device.
Definition nrf5.h:38
struct pbl_audio_nrf5_pdm_state * state
Driver runtime state.
Definition nrf5.h:46
PDM interface.
Definition nrf5.h:36
@ PBL_AUDIO_CAPTURE
From the hardware to memory.
Definition audio.h:90
Define the PDM interface, a capture device.
- Parameters
-
| sym | Symbol of the device. |
| _name | Device name. |
| _clk | Clock pin, from PBL_GPIO(). |
| _din | Data pin, from PBL_GPIO(). |
| _default_gain_mdb | Gain after initialization, in mdB. |
◆ pbl_audio_nrf5_i2s_irq_handler()
◆ pbl_audio_nrf5_pdm_irq_handler()