| Nordic Thingy:52 v2.0.0

Data Structures | Typedefs | Enumerations | Functions
Speaker driver
Drivers

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_sound | Sound sample. PCM encoded, 8-bit.
  [in] | length | Length of the package.

Return values

  NRF_SUCCESS | Completed successfully.
  Other | codes 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_sound | Sound sample. PCM encoded, 8-bit.
  [in] | size | Size of the sample.

Return values

  NRF_SUCCESS | Completed successfully.
  Other | codes 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_params | Initialization parameters.

Return values

  NRF_SUCCESS | Completed successfully.
  NRF_ERROR_NULL | Null pointer supplied.
  Other | codes 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_id | ID of the sample to play.

Return values

  NRF_ERROR_INVALID_PARAM | Invalid sample requested.
  Other | codes 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_hz | Tone frequency (>100 Hz).
  [in] | duration_ms | Tone length [ms].
  [in] | volume | Speaker volume (0 to 100). 0 Volume will cause the function to return immediately with NRF_SUCCESS.

Return values

  NRF_SUCCESS | Completed successfully.
  NRF_ERROR_NOT_SUPPORTED | Invalid parameters supplied.