theCore C++ embedded framework
CS43L22 driver module
Collaboration diagram for CS43L22 driver module:

Data Structures

class  ecl::cs43l22< I2c, I2s, Rst_gpio >
 The CS43L22 codec driver implementation. More...
 

Functions

static err ecl::cs43l22< I2c, I2s, Rst_gpio >::init ()
 Codec low-level initialization routine. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::power_up ()
 Codec power up sequence. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::power_down ()
 Codec power down sequence. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::send_pcm_buffer (const uint16_t *buffer, size_t count)
 Send PCM buffer to the codec. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::pcm_stream_start (const uint16_t *buffer, size_t count, user_callback callback)
 Starts stream of the PCM buffer to the codec. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::pcm_stream_stop ()
 Stop active stream. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_master_volume (uint8_t volume, channel ch=channel::all)
 Set master volume for specific channel. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_headphone_volume (uint8_t volume, channel ch=channel::all)
 Set headphone volume for specific channel. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::headphone_mute (channel ch=channel::all)
 Mute headphone channel. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::headphone_unmute (channel ch=channel::all)
 Unmute headphone channel. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_on_time (beep_on_time value)
 Set beep on time. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_off_time (beep_off_time value)
 Set beep off time. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_frequency (beep_frequency value)
 Set beep frequency. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_volume (uint8_t volume)
 Set beep Volume. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::beep_enable (beep_mode mode=beep_mode::multiple)
 Enable beep generator. More...
 
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::beep_disable ()
 Disable beep generator. More...
 
template<ecl::i2s::audio_frequency frequency>
static err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_sampling_frequency ()
 Set sampling frequency for PCM audio data. More...
 

Detailed Description

Function Documentation

◆ init()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::init ( )
static

Codec low-level initialization routine.

This method performs low-level initialization of the codec and underlayer buses. This method must be called once before any operations with codec.

Return values
Statusof the operation.
Here is the call graph for this function:

◆ power_up()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::power_up ( )
static

Codec power up sequence.

Must not be called if codec is already powered.

This method performs power up sequence of the codec which is recommended by CS43L22 Reference Manual (RM). To use this method, the init() method must be called previously.

Return values
Statusof the operation.
Here is the call graph for this function:

◆ power_down()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::power_down ( )
static

Codec power down sequence.

Must not be called if codec is not powered.

This method performs power down sequence of the codec which is recommended by CS43L22 Reference Manual (RM). To use this method, the init() method must be called previously.

Return values
Statusof the operation.
Here is the call graph for this function:

◆ send_pcm_buffer()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::send_pcm_buffer ( const uint16_t *  buffer,
size_t  count 
)
static

Send PCM buffer to the codec.

This method blocks until all data is transferred. The PCM data contains audio samples. Sample size is constant and equal to 16 bit. Sampling frequency can be changed with cs43l22< I2c, I2s, Rst_gpio >::set_sampling_frequency() method. The buffer format is next: LRLR.... Where L - left channel and R - right channel.

Parameters
bufferThe buffer which contains PCM data. Must not be null.
countNumber of samples in PCM buffer. Must not be null.
Return values
Statusof the operation.

◆ pcm_stream_start()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::pcm_stream_start ( const uint16_t *  buffer,
size_t  count,
user_callback  callback 
)
static

Starts stream of the PCM buffer to the codec.

When stream is started, the user callback is called on two events: Halt Transfer (HT) and Transfer Completed (TC). When half of samples are transferred, the HT is generated and user can write the data into fist half of the buffer. After all sample are transferred, the TC is generated. After this the codec is continuing streaming from the start of the buffer until it is stopped by cs43l22< I2c, I2s, Rst_gpio >::pcm_stream_stop(). NOTE: The HT and TC events are generated in IRQ context. The user callback should not perform blocking operations, busy wait etc. The PCM data contains audio samples. Sample size is constant and equal to 16 bit. Sampling frequency can be changed with cs43l22< I2c, I2s, Rst_gpio >::set_sampling_frequency() method. The buffer format is next: LRLR.... Where L - left channel and R - right channel.

Parameters
bufferThe buffer which contains PCM data. Must not be null.
countNumber of samples in PCM buffer. Must not be null. Must be multiple of 2 and less of equal to 0xFFFF.
callbackUser callback is called on HT and TC events.
Return values
Statusof the operation.

◆ pcm_stream_stop()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::pcm_stream_stop ( )
static

Stop active stream.

Must not be called if stream is not active.

This method stops active PCM stream. It is recommended to call this method during processing of the HT or TC event. In case this method is called during processing of the TC event the steam will be stopped immediately. Otherwise, it will be stopped after next TC event.

Return values
Statusof the operation.

◆ set_master_volume()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_master_volume ( uint8_t  volume,
channel  ch = channel::all 
)
static

Set master volume for specific channel.

Parameters
chAudio channel.
volumeThe volume value. Must be in range [0, cs43l22< I2c, I2s, Rst_gpio >::max_master_volume]
Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_headphone_volume()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_headphone_volume ( uint8_t  volume,
channel  ch = channel::all 
)
static

Set headphone volume for specific channel.

Parameters
chAudio channel.
volumeThe volume value. Must be in range [0, cs43l22< I2c, I2s, Rst_gpio >::max_headphone_volume]
Return values
Statusof the operation.
Here is the call graph for this function:

◆ headphone_mute()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::headphone_mute ( channel  ch = channel::all)
static

Mute headphone channel.

Parameters
chAudio channel.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ headphone_unmute()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::headphone_unmute ( channel  ch = channel::all)
static

Unmute headphone channel.

Parameters
chAudio channel.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_beep_on_time()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_on_time ( beep_on_time  value)
static

Set beep on time.

Must not be called if beep is enabled. See RM for details.

Parameters
valueThe value of beep on time.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_beep_off_time()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_off_time ( beep_off_time  value)
static

Set beep off time.

Must not be called if beep is enabled. See RM for details.

Parameters
valueThe value of beep off time.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_beep_frequency()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_frequency ( beep_frequency  value)
static

Set beep frequency.

Must not be called if beep is enabled. See RM for details.

Parameters
valueThe value of beep frequency.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_beep_volume()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_beep_volume ( uint8_t  volume)
static

Set beep Volume.

Must not be called if beep is enabled. See RM for details.

Parameters
volumeThe value of beep volume. Must be in range [0, cs43l22< I2c, I2s, Rst_gpio >::max_beep_volume]
Return values
Statusof the operation.
Here is the call graph for this function:

◆ beep_enable()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::beep_enable ( beep_mode  mode = beep_mode::multiple)
static

Enable beep generator.

Parameters
modeThe operation mode for beep generator.
Return values
Statusof the operation.
Here is the call graph for this function:

◆ beep_disable()

template<class I2c , class I2s , class Rst_gpio >
err ecl::cs43l22< I2c, I2s, Rst_gpio >::beep_disable ( )
static

Disable beep generator.

Return values
Statusof the operation.
Here is the call graph for this function:

◆ set_sampling_frequency()

template<class I2c , class I2s , class Rst_gpio >
template<ecl::i2s::audio_frequency frequency>
err ecl::cs43l22< I2c, I2s, Rst_gpio >::set_sampling_frequency ( )
static

Set sampling frequency for PCM audio data.

Template Parameters
frequencyAudio frequency.
Return values
Statusof the operation.