Nordic Thingy:52 v2.2.0
Speaker driver

Speaker driver API. More...

Data Structures

struct  drv_speaker_init_t
 Speaker driver initialization type. More...
 

Typedefs

typedef void(* drv_speaker_evt_handler_t) (drv_speaker_evt_t evt)
 Speaker driver event handler callback type.
 

Enumerations

enum  drv_speaker_evt_t
 Speaker driver event types.
 

Functions

uint32_t drv_speaker_ble_pcm_play (uint8_t *p_sound, uint32_t length)
 Function for playing an 8-bit 8 kHz PCM encoded audio split into packages. More...
 
uint32_t drv_speaker_flash_pcm_play (uint8_t const *const p_sound, uint32_t size)
 Function for playing an 8-bit 8 kHz PCM encoded audio sample. More...
 
uint32_t drv_speaker_init (drv_speaker_init_t *p_params)
 Function for initializing the speaker driver. More...
 
uint32_t drv_speaker_sample_play (uint8_t sample_id)
 Function for playing one of the prestored samples. See sounds.h. More...
 
uint32_t drv_speaker_tone_start (uint16_t freq_hz, uint32_t duration_ms, uint8_t volume)
 Function for playing a single tone through the speaker. More...
 

Detailed Description

Speaker driver API.

Function Documentation

◆ drv_speaker_ble_pcm_play()

uint32_t drv_speaker_ble_pcm_play ( uint8_t *  p_sound,
uint32_t  length 
)

Function for playing an 8-bit 8 kHz PCM encoded audio split into packages.

Parameters
[in]p_soundSound sample. PCM encoded, 8-bit.
[in]lengthLength of the package.
Return values
NRF_SUCCESSCompleted successfully.
Othercodes from underlying drivers.

◆ drv_speaker_flash_pcm_play()

uint32_t drv_speaker_flash_pcm_play ( uint8_t const *const  p_sound,
uint32_t  size 
)

Function for playing an 8-bit 8 kHz PCM encoded audio sample.

Parameters
[in]p_soundSound sample. PCM encoded, 8-bit.
[in]sizeSize of the sample.
Return values
NRF_SUCCESSCompleted successfully.
Othercodes from underlying drivers.

◆ drv_speaker_init()

uint32_t drv_speaker_init ( drv_speaker_init_t p_params)

Function for initializing the speaker driver.

Parameters
[in]p_paramsInitialization parameters.
Return values
NRF_SUCCESSCompleted successfully.
NRF_ERROR_NULLNull pointer supplied.
Othercodes from underlying drivers.

◆ drv_speaker_sample_play()

uint32_t drv_speaker_sample_play ( uint8_t  sample_id)

Function for playing one of the prestored samples. See sounds.h.

Parameters
[in]sample_idID of the sample to play.
Return values
NRF_ERROR_INVALID_PARAMInvalid sample requested.
Othercodes from underlying drivers.

◆ drv_speaker_tone_start()

uint32_t drv_speaker_tone_start ( uint16_t  freq_hz,
uint32_t  duration_ms,
uint8_t  volume 
)

Function for playing a single tone through the speaker.

Parameters
[in]freq_hzTone frequency (>100 Hz).
[in]duration_msTone length [ms].
[in]volumeSpeaker volume (0 to 100). 0 Volume will cause the function to return immediately with NRF_SUCCESS.
Return values
NRF_SUCCESSCompleted successfully.
NRF_ERROR_NOT_SUPPORTEDInvalid parameters supplied.