theCore C++ embedded framework
ecl::cs43l22< I2c, I2s, Rst_gpio > Class Template Reference

The CS43L22 codec driver implementation. More...

#include </home/travis/build/forGGe/theCore/dev/cs43l22/export/dev/cs43l22.hpp>

Public Types

enum  channel { channel::left, channel::right, channel::all }
 Represents audio channel. More...
 
enum  beep_frequency {
  beep_frequency::hz260 = 0x0, beep_frequency::hz521 = 0x10, beep_frequency::hz585 = 0x20, beep_frequency::hz666 = 0x30,
  beep_frequency::hz705 = 0x40, beep_frequency::hz774 = 0x50, beep_frequency::hz888 = 0x60, beep_frequency::hz1000 = 0x70,
  beep_frequency::hz1043 = 0x80, beep_frequency::hz1200 = 0x90, beep_frequency::hz1333 = 0xA0, beep_frequency::hz1411 = 0xB0,
  beep_frequency::hz1600 = 0xC0, beep_frequency::hz1714 = 0xD0, beep_frequency::hz2000 = 0xE0, beep_frequency::hz2181 = 0xF0
}
 Register masks for frequencies supported by beep generator. More...
 
enum  beep_on_time {
  beep_on_time::ms86 = 0x0, beep_on_time::ms430 = 0x1, beep_on_time::ms780 = 0x2, beep_on_time::ms1200 = 0x3,
  beep_on_time::ms1500 = 0x4, beep_on_time::ms1800 = 0x5, beep_on_time::ms2200 = 0x6, beep_on_time::ms2500 = 0x7,
  beep_on_time::ms2800 = 0x8, beep_on_time::ms3200 = 0x9, beep_on_time::ms3500 = 0xA, beep_on_time::ms3800 = 0xB,
  beep_on_time::ms4200 = 0xC, beep_on_time::ms4500 = 0xD, beep_on_time::ms4800 = 0xE, beep_on_time::ms5200 = 0xF
}
 Register masks for possible values for on duration of the beep signal. More...
 
enum  beep_off_time {
  beep_off_time::ms1230 = 0x0, beep_off_time::ms2580 = 0x20, beep_off_time::ms3900 = 0x40, beep_off_time::ms5200 = 0x60,
  beep_off_time::ms6600 = 0x80, beep_off_time::ms8050 = 0xA0, beep_off_time::ms9350 = 0xC0, beep_off_time::ms10800 = 0xE0
}
 Register masks for possible values for off duration of the beep signal. More...
 
enum  beep_mode { beep_mode::single = 0x40, beep_mode::multiple = 0x80, beep_mode::continuous = 0xC0 }
 Register masks for operation modes of the beep generator. More...
 
using user_callback = std::function< void(ecl::bus_event type) >
 Describes the user callback. More...
 

Static Public Member Functions

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

Static Public Attributes

static constexpr uint8_t max_master_volume = 0xE4
 Maximum value of the master volume. More...
 
static constexpr uint8_t max_headphone_volume = 0xFF
 Maximum value of the headphone volume. More...
 
static constexpr uint8_t max_beep_volume = 0x1F
 Maximum value of the beep volume. More...
 

Detailed Description

template<class I2c, class I2s, class Rst_gpio>
class ecl::cs43l22< I2c, I2s, Rst_gpio >

The CS43L22 codec driver implementation.

Template Parameters
I2cI2C generic bus driver.
I2sI2S generic bus driver.
Rst_gpioReset pin represented by generic GPIO class.

Member Typedef Documentation

◆ user_callback

template<class I2c , class I2s , class Rst_gpio >
using ecl::cs43l22< I2c, I2s, Rst_gpio >::user_callback = std::function< void (ecl::bus_event type) >

Describes the user callback.

NOTE: The user callback is called in IRQ context.

Parameters
typeRepresents the type of event: half-transfer (HT) or transfer completed (TC).

Member Enumeration Documentation

◆ channel

template<class I2c , class I2s , class Rst_gpio >
enum ecl::cs43l22::channel
strong

Represents audio channel.

Enumerator
left 
right 
all 

◆ beep_frequency

template<class I2c , class I2s , class Rst_gpio >
enum ecl::cs43l22::beep_frequency
strong

Register masks for frequencies supported by beep generator.

Enumerator
hz260 
hz521 

260.78 Hz

hz585 

521.74 Hz

hz666 

585.37 Hz

hz705 

666.67 Hz

hz774 

705.88 Hz

hz888 

774.19 Hz

hz1000 

888.89 Hz

hz1043 

1000.00 Hz

hz1200 

1043.48 Hz

hz1333 

1200.00 Hz

hz1411 

1333.33 Hz

hz1600 

1411.76 Hz

hz1714 

1600.00 Hz

hz2000 

1714.29 Hz

hz2181 

2000.00 Hz

◆ beep_on_time

template<class I2c , class I2s , class Rst_gpio >
enum ecl::cs43l22::beep_on_time
strong

Register masks for possible values for on duration of the beep signal.

Enumerator
ms86 
ms430 

86 ms

ms780 

430 ms

ms1200 

780 ms

ms1500 

1.20 s

ms1800 

1.50 s

ms2200 

1.80 s

ms2500 

2.20 s

ms2800 

2.50 s

ms3200 

2.80 s

ms3500 

3.20 s

ms3800 

3.50 s

ms4200 

3.80 s

ms4500 

4.20 s

ms4800 

4.50 s

ms5200 

4.80 s

◆ beep_off_time

template<class I2c , class I2s , class Rst_gpio >
enum ecl::cs43l22::beep_off_time
strong

Register masks for possible values for off duration of the beep signal.

Enumerator
ms1230 
ms2580 

1.23 s

ms3900 

2.58 s

ms5200 

3.90 s

ms6600 

5.20 s

ms8050 

6.60 s

ms9350 

8.05 s

ms10800 

9.35 s

◆ beep_mode

template<class I2c , class I2s , class Rst_gpio >
enum ecl::cs43l22::beep_mode
strong

Register masks for operation modes of the beep generator.

Enumerator
single 
multiple 

Play one beep.

continuous 

Play beep for on_time, mute for off_time.

Field Documentation

◆ max_master_volume

template<class I2c , class I2s , class Rst_gpio >
constexpr uint8_t ecl::cs43l22< I2c, I2s, Rst_gpio >::max_master_volume = 0xE4
static

Maximum value of the master volume.

The minimum value (0) represents the signal out the DSP: -102 dB. The maximum value (0xE4) represents +12 dB. Step size is 0.5 dB.

◆ max_headphone_volume

template<class I2c , class I2s , class Rst_gpio >
constexpr uint8_t ecl::cs43l22< I2c, I2s, Rst_gpio >::max_headphone_volume = 0xFF
static

Maximum value of the headphone volume.

The minimum value (0) represents the signal out the DAC: -127 dB (muted). The maximum value (0xFF) represents the signal out the DAC: 0 dB. Step size is 0.5 dB.

◆ max_beep_volume

template<class I2c , class I2s , class Rst_gpio >
constexpr uint8_t ecl::cs43l22< I2c, I2s, Rst_gpio >::max_beep_volume = 0x1F
static

Maximum value of the beep volume.

The minimum value (0) represents the gain: -56 dB. The maximum value (0x1F) represents the gain: +6 dB. Step size is 2 dB.


The documentation for this class was generated from the following file: