Header-only driver class for the CS43L22 codec chip.
More...
#include <CS43L22.h>
|
| | CS43L22 ()=default |
| |
| void | deinit () |
| | Deinitializes the audio codec.
|
| |
| uint32_t | init (uint16_t outputDevice, uint8_t volume, uint32_t audioFreq) |
| |
| uint32_t | pause () |
| | Pauses playing on the audio codec.
|
| |
| uint32_t | play (uint16_t *pBuffer, uint16_t size) |
| |
| uint32_t | readID () |
| | Get the CS43L22 ID.
|
| |
| uint32_t | reset () |
| | Resets cs43l22 registers.
|
| |
| uint32_t | resume () |
| | Resumes playing on the audio codec.
|
| |
| void | setAddress (uint16_t addr) |
| | Defines the I2C device address.
|
| |
| uint32_t | setFrequency (uint32_t audioFreq) |
| | Sets new frequency: not implemented for this codec, as it is automatically detected by the codec.
|
| |
| uint32_t | setMute (uint32_t cmd) |
| |
| uint32_t | setOutputMode (uint8_t output) |
| |
| uint32_t | setVolume (uint8_t volume) |
| |
| void | setWire (i2c_bus_handle_t handle) |
| | Defines the I2C bus instance to be used.
|
| |
| uint32_t | stop (uint32_t cmd) |
| |
| uint8_t | writeReg (uint8_t reg, uint8_t value) |
| |
Header-only driver class for the CS43L22 codec chip.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ AudioFrequency
| Enumerator |
|---|
| AUDIO_FREQUENCY_192K | |
| AUDIO_FREQUENCY_96K | |
| AUDIO_FREQUENCY_48K | |
| AUDIO_FREQUENCY_44K | |
| AUDIO_FREQUENCY_32K | |
| AUDIO_FREQUENCY_22K | |
| AUDIO_FREQUENCY_16K | |
| AUDIO_FREQUENCY_11K | |
| AUDIO_FREQUENCY_8K | |
◆ CS43L22()
◆ cs43l22VolumeConvert()
| static constexpr uint8_t cs43l22VolumeConvert |
( |
uint8_t |
volume | ) |
|
|
inlinestaticconstexpr |
◆ deinit()
Deinitializes the audio codec.
◆ init()
| uint32_t init |
( |
uint16_t |
outputDevice, |
|
|
uint8_t |
volume, |
|
|
uint32_t |
audioFreq |
|
) |
| |
|
inline |
Initializes the audio codec and the control interface.
- Parameters
-
| outputDevice | can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO |
| volume | Initial volume level (from 0 (Mute) to 100 (Max)) |
◆ pause()
Pauses playing on the audio codec.
◆ play()
| uint32_t play |
( |
uint16_t * |
pBuffer, |
|
|
uint16_t |
size |
|
) |
| |
|
inline |
Start the audio Codec play feature.
- Note
- For this codec no Play options are required.
◆ readID()
◆ reset()
Resets cs43l22 registers.
◆ resume()
Resumes playing on the audio codec.
◆ setAddress()
| void setAddress |
( |
uint16_t |
addr | ) |
|
|
inline |
Defines the I2C device address.
◆ setFrequency()
| uint32_t setFrequency |
( |
uint32_t |
audioFreq | ) |
|
|
inline |
Sets new frequency: not implemented for this codec, as it is automatically detected by the codec.
◆ setMute()
| uint32_t setMute |
( |
uint32_t |
cmd | ) |
|
|
inline |
Enables or disables the mute feature on the audio codec.
- Parameters
-
| cmd | AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the mute mode. |
◆ setOutputMode()
| uint32_t setOutputMode |
( |
uint8_t |
output | ) |
|
|
inline |
Switch dynamically (while audio file is played) the output target (speaker or headphone).
- Parameters
-
| output | specifies the audio output target: OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO |
◆ setVolume()
| uint32_t setVolume |
( |
uint8_t |
volume | ) |
|
|
inline |
Sets higher or lower the codec volume level.
- Parameters
-
| volume | a byte value from 0 to 100 (which is mapped to 0 - 255, refer to codec registers description for more details). |
◆ setWire()
Defines the I2C bus instance to be used.
◆ stop()
| uint32_t stop |
( |
uint32_t |
cmd | ) |
|
|
inline |
Stops audio Codec playing. It powers down the codec.
- Parameters
-
| cmd | selects the power down mode (e.g. AUDIO_MUTE_ON). |
◆ writeReg()
| uint8_t writeReg |
( |
uint8_t |
reg, |
|
|
uint8_t |
value |
|
) |
| |
|
inline |
◆ AUDIO_MUTE_OFF
| constexpr int AUDIO_MUTE_OFF = 0 |
|
staticconstexpr |
◆ AUDIO_MUTE_ON
| constexpr int AUDIO_MUTE_ON = 1 |
|
staticconstexpr |
◆ AUDIO_PAUSE
| constexpr int AUDIO_PAUSE = 0 |
|
staticconstexpr |
◆ AUDIO_RESUME
| constexpr int AUDIO_RESUME = 1 |
|
staticconstexpr |
◆ CODEC_PDWN_HW
| constexpr int CODEC_PDWN_HW = 1 |
|
staticconstexpr |
◆ CODEC_PDWN_SW
| constexpr int CODEC_PDWN_SW = 2 |
|
staticconstexpr |
◆ CODEC_STANDARD
| constexpr uint8_t CODEC_STANDARD = 0x04 |
|
staticconstexpr |
◆ CS43L22_CHIPID_ADDR
| constexpr uint8_t CS43L22_CHIPID_ADDR = 0x01 |
|
staticconstexpr |
◆ CS43L22_ID
| constexpr uint8_t CS43L22_ID = 0xE0 |
|
staticconstexpr |
◆ CS43L22_ID_MASK
| constexpr uint8_t CS43L22_ID_MASK = 0xF8 |
|
staticconstexpr |
◆ CS43L22_REG_ANALOG_ZC_SR_SETT
| constexpr uint8_t CS43L22_REG_ANALOG_ZC_SR_SETT = 0x0A |
|
staticconstexpr |
◆ CS43L22_REG_BATT_COMPENSATION
| constexpr uint8_t CS43L22_REG_BATT_COMPENSATION = 0x2F |
|
staticconstexpr |
◆ CS43L22_REG_BEEP_FREQ_ON_TIME
| constexpr uint8_t CS43L22_REG_BEEP_FREQ_ON_TIME = 0x1C |
|
staticconstexpr |
◆ CS43L22_REG_BEEP_TONE_CFG
| constexpr uint8_t CS43L22_REG_BEEP_TONE_CFG = 0x1E |
|
staticconstexpr |
◆ CS43L22_REG_BEEP_VOL_OFF_TIME
| constexpr uint8_t CS43L22_REG_BEEP_VOL_OFF_TIME = 0x1D |
|
staticconstexpr |
◆ CS43L22_REG_CH_MIXER_SWAP
| constexpr uint8_t CS43L22_REG_CH_MIXER_SWAP = 0x26 |
|
staticconstexpr |
◆ CS43L22_REG_CHARGE_PUMP_FREQ
| constexpr uint8_t CS43L22_REG_CHARGE_PUMP_FREQ = 0x34 |
|
staticconstexpr |
◆ CS43L22_REG_CLOCKING_CTL
| constexpr uint8_t CS43L22_REG_CLOCKING_CTL = 0x05 |
|
staticconstexpr |
◆ CS43L22_REG_HEADPHONE_A_VOL
| constexpr uint8_t CS43L22_REG_HEADPHONE_A_VOL = 0x22 |
|
staticconstexpr |
◆ CS43L22_REG_HEADPHONE_B_VOL
| constexpr uint8_t CS43L22_REG_HEADPHONE_B_VOL = 0x23 |
|
staticconstexpr |
◆ CS43L22_REG_ID
| constexpr uint8_t CS43L22_REG_ID = 0x01 |
|
staticconstexpr |
◆ CS43L22_REG_INTERFACE_CTL1
| constexpr uint8_t CS43L22_REG_INTERFACE_CTL1 = 0x06 |
|
staticconstexpr |
◆ CS43L22_REG_INTERFACE_CTL2
| constexpr uint8_t CS43L22_REG_INTERFACE_CTL2 = 0x07 |
|
staticconstexpr |
◆ CS43L22_REG_LIMIT_ATTACK_RATE
| constexpr uint8_t CS43L22_REG_LIMIT_ATTACK_RATE = 0x29 |
|
staticconstexpr |
◆ CS43L22_REG_LIMIT_CTL1
| constexpr uint8_t CS43L22_REG_LIMIT_CTL1 = 0x27 |
|
staticconstexpr |
◆ CS43L22_REG_LIMIT_CTL2
| constexpr uint8_t CS43L22_REG_LIMIT_CTL2 = 0x28 |
|
staticconstexpr |
◆ CS43L22_REG_MASTER_A_VOL
| constexpr uint8_t CS43L22_REG_MASTER_A_VOL = 0x20 |
|
staticconstexpr |
◆ CS43L22_REG_MASTER_B_VOL
| constexpr uint8_t CS43L22_REG_MASTER_B_VOL = 0x21 |
|
staticconstexpr |
◆ CS43L22_REG_MISC_CTL
| constexpr uint8_t CS43L22_REG_MISC_CTL = 0x0E |
|
staticconstexpr |
◆ CS43L22_REG_OVF_CLK_STATUS
| constexpr uint8_t CS43L22_REG_OVF_CLK_STATUS = 0x2E |
|
staticconstexpr |
◆ CS43L22_REG_PASSTHR_A_SELECT
| constexpr uint8_t CS43L22_REG_PASSTHR_A_SELECT = 0x08 |
|
staticconstexpr |
◆ CS43L22_REG_PASSTHR_A_VOL
| constexpr uint8_t CS43L22_REG_PASSTHR_A_VOL = 0x14 |
|
staticconstexpr |
◆ CS43L22_REG_PASSTHR_B_SELECT
| constexpr uint8_t CS43L22_REG_PASSTHR_B_SELECT = 0x09 |
|
staticconstexpr |
◆ CS43L22_REG_PASSTHR_B_VOL
| constexpr uint8_t CS43L22_REG_PASSTHR_B_VOL = 0x15 |
|
staticconstexpr |
◆ CS43L22_REG_PASSTHR_GANG_CTL
| constexpr uint8_t CS43L22_REG_PASSTHR_GANG_CTL = 0x0C |
|
staticconstexpr |
◆ CS43L22_REG_PCMA_VOL
| constexpr uint8_t CS43L22_REG_PCMA_VOL = 0x1A |
|
staticconstexpr |
◆ CS43L22_REG_PCMB_VOL
| constexpr uint8_t CS43L22_REG_PCMB_VOL = 0x1B |
|
staticconstexpr |
◆ CS43L22_REG_PLAYBACK_CTL1
| constexpr uint8_t CS43L22_REG_PLAYBACK_CTL1 = 0x0D |
|
staticconstexpr |
◆ CS43L22_REG_PLAYBACK_CTL2
| constexpr uint8_t CS43L22_REG_PLAYBACK_CTL2 = 0x0F |
|
staticconstexpr |
◆ CS43L22_REG_POWER_CTL1
| constexpr uint8_t CS43L22_REG_POWER_CTL1 = 0x02 |
|
staticconstexpr |
◆ CS43L22_REG_POWER_CTL2
| constexpr uint8_t CS43L22_REG_POWER_CTL2 = 0x04 |
|
staticconstexpr |
◆ CS43L22_REG_SPEAKER_A_VOL
| constexpr uint8_t CS43L22_REG_SPEAKER_A_VOL = 0x24 |
|
staticconstexpr |
◆ CS43L22_REG_SPEAKER_B_VOL
| constexpr uint8_t CS43L22_REG_SPEAKER_B_VOL = 0x25 |
|
staticconstexpr |
◆ CS43L22_REG_SPEAKER_STATUS
| constexpr uint8_t CS43L22_REG_SPEAKER_STATUS = 0x31 |
|
staticconstexpr |
◆ CS43L22_REG_TEMPMONITOR_CTL
| constexpr uint8_t CS43L22_REG_TEMPMONITOR_CTL = 0x32 |
|
staticconstexpr |
◆ CS43L22_REG_THERMAL_FOLDBACK
| constexpr uint8_t CS43L22_REG_THERMAL_FOLDBACK = 0x33 |
|
staticconstexpr |
◆ CS43L22_REG_TONE_CTL
| constexpr uint8_t CS43L22_REG_TONE_CTL = 0x1F |
|
staticconstexpr |
◆ CS43L22_REG_VP_BATTERY_LEVEL
| constexpr uint8_t CS43L22_REG_VP_BATTERY_LEVEL = 0x30 |
|
staticconstexpr |
◆ DEFAULT_VOLMAX
| constexpr uint8_t DEFAULT_VOLMAX = 0xFF |
|
staticconstexpr |
◆ DEFAULT_VOLMIN
| constexpr uint8_t DEFAULT_VOLMIN = 0x00 |
|
staticconstexpr |
◆ DEFAULT_VOLSTEP
| constexpr uint8_t DEFAULT_VOLSTEP = 0x04 |
|
staticconstexpr |
◆ device_addr
◆ i2c_handle
◆ is_stop
◆ output_dev
| volatile uint8_t output_dev = 0 |
|
protected |
◆ OUTPUT_DEVICE_AUTO
| constexpr uint8_t OUTPUT_DEVICE_AUTO = 4 |
|
staticconstexpr |
◆ OUTPUT_DEVICE_BOTH
| constexpr uint8_t OUTPUT_DEVICE_BOTH = 3 |
|
staticconstexpr |
◆ OUTPUT_DEVICE_HEADPHONE
| constexpr uint8_t OUTPUT_DEVICE_HEADPHONE = 2 |
|
staticconstexpr |
◆ OUTPUT_DEVICE_SPEAKER
| constexpr uint8_t OUTPUT_DEVICE_SPEAKER = 1 |
|
staticconstexpr |
The documentation for this class was generated from the following file: