Hardware access layer for managing the Pulse Density Modulation (PDM) peripheral. More...
Macros | |
#define | NRF_PDM_HAS_MCLKCONFIG 1 |
Symbol indicating whether master clock source configuration is available. | |
#define | NRF_PDM_HAS_RATIO_CONFIG 1 |
Symbol indicating whether ratio configuration is available. | |
#define | NRF_PDM_GAIN_MINIMUM 0x00 |
Minimum value of PDM gain. | |
#define | NRF_PDM_GAIN_DEFAULT 0x28 |
Default value of PDM gain. | |
#define | NRF_PDM_GAIN_MAXIMUM 0x50 |
Maximum value of PDM gain. | |
Typedefs | |
typedef uint8_t | nrf_pdm_gain_t |
PDM gain type. | |
Enumerations | |
enum | nrf_pdm_task_t { NRF_PDM_TASK_START = offsetof(NRF_PDM_Type, TASKS_START), NRF_PDM_TASK_STOP = offsetof(NRF_PDM_Type, TASKS_STOP) } |
PDM tasks. More... | |
enum | nrf_pdm_event_t { NRF_PDM_EVENT_STARTED = offsetof(NRF_PDM_Type, EVENTS_STARTED), NRF_PDM_EVENT_STOPPED = offsetof(NRF_PDM_Type, EVENTS_STOPPED), NRF_PDM_EVENT_END = offsetof(NRF_PDM_Type, EVENTS_END) } |
PDM events. More... | |
enum | nrf_pdm_int_mask_t { NRF_PDM_INT_STARTED = PDM_INTENSET_STARTED_Msk, NRF_PDM_INT_STOPPED = PDM_INTENSET_STOPPED_Msk, NRF_PDM_INT_END = PDM_INTENSET_END_Msk } |
PDM interrupt masks. More... | |
enum | nrf_pdm_freq_t { NRF_PDM_FREQ_1000K = PDM_PDMCLKCTRL_FREQ_1000K, NRF_PDM_FREQ_1032K = PDM_PDMCLKCTRL_FREQ_Default, NRF_PDM_FREQ_1067K = PDM_PDMCLKCTRL_FREQ_1067K, NRF_PDM_FREQ_1231K = PDM_PDMCLKCTRL_FREQ_1231K, NRF_PDM_FREQ_1280K = PDM_PDMCLKCTRL_FREQ_1280K, NRF_PDM_FREQ_1333K = PDM_PDMCLKCTRL_FREQ_1333K } |
PDM clock frequency. More... | |
enum | nrf_pdm_ratio_t { NRF_PDM_RATIO_64X = PDM_RATIO_RATIO_Ratio64, NRF_PDM_RATIO_80X = PDM_RATIO_RATIO_Ratio80 } |
PDM ratio between PDM_CLK and output sample rate. More... | |
enum | nrf_pdm_mode_t { NRF_PDM_MODE_STEREO = PDM_MODE_OPERATION_Stereo, NRF_PDM_MODE_MONO = PDM_MODE_OPERATION_Mono } |
PDM operation mode. More... | |
enum | nrf_pdm_edge_t { NRF_PDM_EDGE_LEFTFALLING = PDM_MODE_EDGE_LeftFalling, NRF_PDM_EDGE_LEFTRISING = PDM_MODE_EDGE_LeftRising } |
PDM sampling mode. More... | |
enum | nrf_pdm_mclksrc_t { NRF_PDM_MCLKSRC_PCLK32M = PDM_MCLKCONFIG_SRC_PCLK32M, NRF_PDM_MCLKSRC_ACLK = PDM_MCLKCONFIG_SRC_ACLK } |
PDM master clock source selection. More... | |
Functions | |
NRF_STATIC_INLINE void | nrf_pdm_task_trigger (NRF_PDM_Type *p_reg, nrf_pdm_task_t task) |
Function for triggering a PDM task. More... | |
NRF_STATIC_INLINE uint32_t | nrf_pdm_task_address_get (NRF_PDM_Type const *p_reg, nrf_pdm_task_t task) |
Function for getting the address of a PDM task register. More... | |
NRF_STATIC_INLINE bool | nrf_pdm_event_check (NRF_PDM_Type const *p_reg, nrf_pdm_event_t event) |
Function for retrieving the state of the PDM event. More... | |
NRF_STATIC_INLINE void | nrf_pdm_event_clear (NRF_PDM_Type *p_reg, nrf_pdm_event_t event) |
Function for clearing a PDM event. More... | |
NRF_STATIC_INLINE uint32_t | nrf_pdm_event_address_get (NRF_PDM_Type const *p_reg, nrf_pdm_event_t event) |
Function for getting the address of a PDM event register. More... | |
NRF_STATIC_INLINE void | nrf_pdm_int_enable (NRF_PDM_Type *p_reg, uint32_t mask) |
Function for enabling PDM interrupts. More... | |
NRF_STATIC_INLINE uint32_t | nrf_pdm_int_enable_check (NRF_PDM_Type const *p_reg, uint32_t mask) |
Function for checking if the specified interrupts are enabled. More... | |
NRF_STATIC_INLINE void | nrf_pdm_int_disable (NRF_PDM_Type *p_reg, uint32_t mask) |
Function for disabling interrupts. More... | |
NRF_STATIC_INLINE void | nrf_pdm_subscribe_set (NRF_PDM_Type *p_reg, nrf_pdm_task_t task, uint8_t channel) |
Function for setting the subscribe configuration for a given PDM task. More... | |
NRF_STATIC_INLINE void | nrf_pdm_subscribe_clear (NRF_PDM_Type *p_reg, nrf_pdm_task_t task) |
Function for clearing the subscribe configuration for a given PDM task. More... | |
NRF_STATIC_INLINE void | nrf_pdm_publish_set (NRF_PDM_Type *p_reg, nrf_pdm_event_t event, uint8_t channel) |
Function for setting the publish configuration for a given PDM event. More... | |
NRF_STATIC_INLINE void | nrf_pdm_publish_clear (NRF_PDM_Type *p_reg, nrf_pdm_event_t event) |
Function for clearing the publish configuration for a given PDM event. More... | |
NRF_STATIC_INLINE void | nrf_pdm_enable (NRF_PDM_Type *p_reg) |
Function for enabling the PDM peripheral. More... | |
NRF_STATIC_INLINE void | nrf_pdm_disable (NRF_PDM_Type *p_reg) |
Function for disabling the PDM peripheral. More... | |
NRF_STATIC_INLINE bool | nrf_pdm_enable_check (NRF_PDM_Type const *p_reg) |
Function for checking if the PDM peripheral is enabled. More... | |
NRF_STATIC_INLINE void | nrf_pdm_mode_set (NRF_PDM_Type *p_reg, nrf_pdm_mode_t pdm_mode, nrf_pdm_edge_t pdm_edge) |
Function for setting the PDM operation mode. More... | |
NRF_STATIC_INLINE void | nrf_pdm_mode_get (NRF_PDM_Type const *p_reg, nrf_pdm_mode_t *p_pdm_mode, nrf_pdm_edge_t *p_pdm_edge) |
Function for getting the PDM operation mode. More... | |
NRF_STATIC_INLINE void | nrf_pdm_clock_set (NRF_PDM_Type *p_reg, nrf_pdm_freq_t pdm_freq) |
Function for setting the PDM clock frequency. More... | |
NRF_STATIC_INLINE nrf_pdm_freq_t | nrf_pdm_clock_get (NRF_PDM_Type const *p_reg) |
Function for getting the PDM clock frequency. More... | |
NRF_STATIC_INLINE void | nrf_pdm_psel_connect (NRF_PDM_Type *p_reg, uint32_t psel_clk, uint32_t psel_din) |
Function for setting up the PDM pins. More... | |
NRF_STATIC_INLINE uint32_t | nrf_pdm_clk_pin_get (NRF_PDM_Type const *p_reg) |
Function for getting the CLK pin selection. More... | |
NRF_STATIC_INLINE uint32_t | nrf_pdm_din_pin_get (NRF_PDM_Type const *p_reg) |
Function for getting the DIN pin selection. More... | |
NRF_STATIC_INLINE void | nrf_pdm_psel_disconnect (NRF_PDM_Type *p_reg) |
Function for disconnecting the PDM pins. More... | |
NRF_STATIC_INLINE void | nrf_pdm_gain_set (NRF_PDM_Type *p_reg, nrf_pdm_gain_t gain_l, nrf_pdm_gain_t gain_r) |
Function for setting the PDM gain. More... | |
NRF_STATIC_INLINE void | nrf_pdm_gain_get (NRF_PDM_Type const *p_reg, nrf_pdm_gain_t *p_gain_l, nrf_pdm_gain_t *p_gain_r) |
Function for getting the PDM gain. More... | |
NRF_STATIC_INLINE void | nrf_pdm_buffer_set (NRF_PDM_Type *p_reg, uint32_t *p_buffer, uint32_t num) |
Function for setting the PDM sample buffer. More... | |
NRF_STATIC_INLINE uint32_t * | nrf_pdm_buffer_get (NRF_PDM_Type const *p_reg) |
Function for getting the current PDM sample buffer address. More... | |
NRF_STATIC_INLINE void | nrf_pdm_ratio_set (NRF_PDM_Type *p_reg, nrf_pdm_ratio_t ratio) |
Function for setting ratio between PDM_CLK and output sample rate. More... | |
NRF_STATIC_INLINE void | nrf_pdm_mclksrc_configure (NRF_PDM_Type *p_reg, nrf_pdm_mclksrc_t mclksrc) |
Function for configuring PDM master clock source. More... | |
Hardware access layer for managing the Pulse Density Modulation (PDM) peripheral.
enum nrf_pdm_edge_t |
enum nrf_pdm_event_t |
enum nrf_pdm_freq_t |
enum nrf_pdm_int_mask_t |
enum nrf_pdm_mclksrc_t |
enum nrf_pdm_mode_t |
enum nrf_pdm_ratio_t |
enum nrf_pdm_task_t |
NRF_STATIC_INLINE uint32_t * nrf_pdm_buffer_get | ( | NRF_PDM_Type const * | p_reg | ) |
Function for getting the current PDM sample buffer address.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_pdm_buffer_set | ( | NRF_PDM_Type * | p_reg, |
uint32_t * | p_buffer, | ||
uint32_t | num | ||
) |
Function for setting the PDM sample buffer.
The amount of allocated RAM depends on the operation mode.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | p_buffer | Pointer to the RAM address where samples are to be written with EasyDMA. |
[in] | num | Number of samples to allocate memory for in EasyDMA mode. |
NRF_STATIC_INLINE uint32_t nrf_pdm_clk_pin_get | ( | NRF_PDM_Type const * | p_reg | ) |
Function for getting the CLK pin selection.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE nrf_pdm_freq_t nrf_pdm_clock_get | ( | NRF_PDM_Type const * | p_reg | ) |
Function for getting the PDM clock frequency.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_pdm_clock_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_freq_t | pdm_freq | ||
) |
Function for setting the PDM clock frequency.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | pdm_freq | PDM clock frequency. |
NRF_STATIC_INLINE uint32_t nrf_pdm_din_pin_get | ( | NRF_PDM_Type const * | p_reg | ) |
Function for getting the DIN pin selection.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_pdm_disable | ( | NRF_PDM_Type * | p_reg | ) |
Function for disabling the PDM peripheral.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_pdm_enable | ( | NRF_PDM_Type * | p_reg | ) |
Function for enabling the PDM peripheral.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
The PDM peripheral must be enabled before use.
NRF_STATIC_INLINE bool nrf_pdm_enable_check | ( | NRF_PDM_Type const * | p_reg | ) |
Function for checking if the PDM peripheral is enabled.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
true | The PDM peripheral is enabled. |
false | The PDM peripheral is not enabled. |
NRF_STATIC_INLINE uint32_t nrf_pdm_event_address_get | ( | NRF_PDM_Type const * | p_reg, |
nrf_pdm_event_t | event | ||
) |
Function for getting the address of a PDM event register.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | PDM event. |
NRF_STATIC_INLINE bool nrf_pdm_event_check | ( | NRF_PDM_Type const * | p_reg, |
nrf_pdm_event_t | event | ||
) |
Function for retrieving the state of the PDM event.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | Event to be checked. |
true | The event has been generated. |
false | The event has not been generated. |
NRF_STATIC_INLINE void nrf_pdm_event_clear | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_event_t | event | ||
) |
Function for clearing a PDM event.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | PDM event. |
NRF_STATIC_INLINE void nrf_pdm_gain_get | ( | NRF_PDM_Type const * | p_reg, |
nrf_pdm_gain_t * | p_gain_l, | ||
nrf_pdm_gain_t * | p_gain_r | ||
) |
Function for getting the PDM gain.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[out] | p_gain_l | Left channel gain. |
[out] | p_gain_r | Right channel gain. |
NRF_STATIC_INLINE void nrf_pdm_gain_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_gain_t | gain_l, | ||
nrf_pdm_gain_t | gain_r | ||
) |
Function for setting the PDM gain.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | gain_l | Left channel gain. |
[in] | gain_r | Right channel gain. |
NRF_STATIC_INLINE void nrf_pdm_int_disable | ( | NRF_PDM_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for disabling interrupts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be disabled. |
NRF_STATIC_INLINE void nrf_pdm_int_enable | ( | NRF_PDM_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for enabling PDM interrupts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be enabled. |
NRF_STATIC_INLINE uint32_t nrf_pdm_int_enable_check | ( | NRF_PDM_Type const * | p_reg, |
uint32_t | mask | ||
) |
Function for checking if the specified interrupts are enabled.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be checked. |
NRF_STATIC_INLINE void nrf_pdm_mclksrc_configure | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_mclksrc_t | mclksrc | ||
) |
Function for configuring PDM master clock source.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mclksrc | Master Clock source selection. |
NRF_STATIC_INLINE void nrf_pdm_mode_get | ( | NRF_PDM_Type const * | p_reg, |
nrf_pdm_mode_t * | p_pdm_mode, | ||
nrf_pdm_edge_t * | p_pdm_edge | ||
) |
Function for getting the PDM operation mode.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[out] | p_pdm_mode | PDM operation mode. |
[out] | p_pdm_edge | PDM sampling mode. |
NRF_STATIC_INLINE void nrf_pdm_mode_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_mode_t | pdm_mode, | ||
nrf_pdm_edge_t | pdm_edge | ||
) |
Function for setting the PDM operation mode.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | pdm_mode | PDM operation mode. |
[in] | pdm_edge | PDM sampling mode. |
NRF_STATIC_INLINE void nrf_pdm_psel_connect | ( | NRF_PDM_Type * | p_reg, |
uint32_t | psel_clk, | ||
uint32_t | psel_din | ||
) |
Function for setting up the PDM pins.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | psel_clk | CLK pin number. |
[in] | psel_din | DIN pin number. |
NRF_STATIC_INLINE void nrf_pdm_psel_disconnect | ( | NRF_PDM_Type * | p_reg | ) |
Function for disconnecting the PDM pins.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_pdm_publish_clear | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_event_t | event | ||
) |
Function for clearing the publish configuration for a given PDM event.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | Event for which to clear the configuration. |
NRF_STATIC_INLINE void nrf_pdm_publish_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_event_t | event, | ||
uint8_t | channel | ||
) |
Function for setting the publish configuration for a given PDM event.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | Event for which to set the configuration. |
[in] | channel | Channel through which to publish the event. |
NRF_STATIC_INLINE void nrf_pdm_ratio_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_ratio_t | ratio | ||
) |
Function for setting ratio between PDM_CLK and output sample rate.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | ratio | Ratio between PDM_CLK and output sample rate. |
NRF_STATIC_INLINE void nrf_pdm_subscribe_clear | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_task_t | task | ||
) |
Function for clearing the subscribe configuration for a given PDM task.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | Task for which to clear the configuration. |
NRF_STATIC_INLINE void nrf_pdm_subscribe_set | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_task_t | task, | ||
uint8_t | channel | ||
) |
Function for setting the subscribe configuration for a given PDM task.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | Task for which to set the configuration. |
[in] | channel | Channel through which to subscribe events. |
NRF_STATIC_INLINE uint32_t nrf_pdm_task_address_get | ( | NRF_PDM_Type const * | p_reg, |
nrf_pdm_task_t | task | ||
) |
Function for getting the address of a PDM task register.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | PDM task. |
NRF_STATIC_INLINE void nrf_pdm_task_trigger | ( | NRF_PDM_Type * | p_reg, |
nrf_pdm_task_t | task | ||
) |
Function for triggering a PDM task.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | PDM task. |