stm32f469/stm32f469i-disco/Drivers/BSP/Components/cs43l22/cs43l22.h
Go to the documentation of this file.
1 
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __CS43L22_H
38 #define __CS43L22_H
39 
40 /* Includes ------------------------------------------------------------------*/
41 #include "../Common/audio.h"
42 
67 /******************************************************************************/
68 /*************************** Codec User defines ******************************/
69 /******************************************************************************/
70 /* Codec output DEVICE */
71 #define OUTPUT_DEVICE_SPEAKER 1
72 #define OUTPUT_DEVICE_HEADPHONE 2
73 #define OUTPUT_DEVICE_BOTH 3
74 #define OUTPUT_DEVICE_AUTO 4
75 
76 /* Volume Levels values */
77 #define DEFAULT_VOLMIN 0x00
78 #define DEFAULT_VOLMAX 0xFF
79 #define DEFAULT_VOLSTEP 0x04
80 
81 #define AUDIO_PAUSE 0
82 #define AUDIO_RESUME 1
83 
84 /* Codec POWER DOWN modes */
85 #define CODEC_PDWN_HW 1
86 #define CODEC_PDWN_SW 2
87 
88 /* MUTE commands */
89 #define AUDIO_MUTE_ON 1
90 #define AUDIO_MUTE_OFF 0
91 
92 /* AUDIO FREQUENCY */
93 #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
94 #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
95 #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
96 #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
97 #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
98 #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
99 #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
100 #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
101 #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
102 
104 #define CS43L22_REG_ID 0x01
105 #define CS43L22_REG_POWER_CTL1 0x02
106 #define CS43L22_REG_POWER_CTL2 0x04
107 #define CS43L22_REG_CLOCKING_CTL 0x05
108 #define CS43L22_REG_INTERFACE_CTL1 0x06
109 #define CS43L22_REG_INTERFACE_CTL2 0x07
110 #define CS43L22_REG_PASSTHR_A_SELECT 0x08
111 #define CS43L22_REG_PASSTHR_B_SELECT 0x09
112 #define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A
113 #define CS43L22_REG_PASSTHR_GANG_CTL 0x0C
114 #define CS43L22_REG_PLAYBACK_CTL1 0x0D
115 #define CS43L22_REG_MISC_CTL 0x0E
116 #define CS43L22_REG_PLAYBACK_CTL2 0x0F
117 #define CS43L22_REG_PASSTHR_A_VOL 0x14
118 #define CS43L22_REG_PASSTHR_B_VOL 0x15
119 #define CS43L22_REG_PCMA_VOL 0x1A
120 #define CS43L22_REG_PCMB_VOL 0x1B
121 #define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C
122 #define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D
123 #define CS43L22_REG_BEEP_TONE_CFG 0x1E
124 #define CS43L22_REG_TONE_CTL 0x1F
125 #define CS43L22_REG_MASTER_A_VOL 0x20
126 #define CS43L22_REG_MASTER_B_VOL 0x21
127 #define CS43L22_REG_HEADPHONE_A_VOL 0x22
128 #define CS43L22_REG_HEADPHONE_B_VOL 0x23
129 #define CS43L22_REG_SPEAKER_A_VOL 0x24
130 #define CS43L22_REG_SPEAKER_B_VOL 0x25
131 #define CS43L22_REG_CH_MIXER_SWAP 0x26
132 #define CS43L22_REG_LIMIT_CTL1 0x27
133 #define CS43L22_REG_LIMIT_CTL2 0x28
134 #define CS43L22_REG_LIMIT_ATTACK_RATE 0x29
135 #define CS43L22_REG_OVF_CLK_STATUS 0x2E
136 #define CS43L22_REG_BATT_COMPENSATION 0x2F
137 #define CS43L22_REG_VP_BATTERY_LEVEL 0x30
138 #define CS43L22_REG_SPEAKER_STATUS 0x31
139 #define CS43L22_REG_TEMPMONITOR_CTL 0x32
140 #define CS43L22_REG_THERMAL_FOLDBACK 0x33
141 #define CS43L22_REG_CHARGE_PUMP_FREQ 0x34
142 
143 /******************************************************************************/
144 /****************************** REGISTER MAPPING ******************************/
145 /******************************************************************************/
149 #define CS43L22_ID 0xE0
150 #define CS43L22_ID_MASK 0xF8
151 
164 #define CS43L22_CHIPID_ADDR 0x01
165 
182 /*------------------------------------------------------------------------------
183  Audio Codec functions
184 ------------------------------------------------------------------------------*/
185 /* High Layer codec functions */
186 uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
187 void cs43l22_DeInit(void);
188 uint32_t cs43l22_ReadID(uint16_t DeviceAddr);
189 uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
190 uint32_t cs43l22_Pause(uint16_t DeviceAddr);
191 uint32_t cs43l22_Resume(uint16_t DeviceAddr);
192 uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd);
193 uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
194 uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
195 uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
196 uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
197 uint32_t cs43l22_Reset(uint16_t DeviceAddr);
198 
199 /* AUDIO IO functions */
200 void AUDIO_IO_Init(void);
201 void AUDIO_IO_DeInit(void);
202 void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
203 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
204 
205 /* Audio driver structure */
207 
208 #endif /* __CS43L22_H */
209 
226 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
cs43l22_drv
AUDIO_DrvTypeDef cs43l22_drv
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:87
cs43l22_ReadID
uint32_t cs43l22_ReadID(uint16_t DeviceAddr)
Get the CS43L22 ID.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:228
cs43l22_SetVolume
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
Sets higher or lower the codec volume level.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:344
cs43l22_Play
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t *pBuffer, uint16_t Size)
Start the audio Codec play feature.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:246
AUDIO_IO_Read
uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg)
Reads a single data.
Definition: stm32f4_discovery.c:680
AUDIO_IO_Write
void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
Writes a single data.
Definition: stm32f4_discovery.c:669
cs43l22_SetMute
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
Enables or disables the mute feature on the audio codec.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:383
cs43l22_Init
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
Initializes the audio codec and the control interface.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:133
cs43l22_DeInit
void cs43l22_DeInit(void)
Deinitializes the audio codec.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:217
cs43l22_SetOutputMode
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:412
cs43l22_Reset
uint32_t cs43l22_Reset(uint16_t DeviceAddr)
Resets cs43l22 registers.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:451
AUDIO_DrvTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:81
cs43l22_Resume
uint32_t cs43l22_Resume(uint16_t DeviceAddr)
Resumes playing on the audio codec.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:291
cs43l22_Pause
uint32_t cs43l22_Pause(uint16_t DeviceAddr)
Pauses playing on the audio codec.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:272
AUDIO_IO_Init
void AUDIO_IO_Init(void)
Initializes Audio low level.
Definition: stm32f4_discovery.c:626
AUDIO_IO_DeInit
void AUDIO_IO_DeInit(void)
DeInitializes Audio low level.
Definition: stm32f4_discovery.c:658
cs43l22_SetFrequency
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
Sets new frequency.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:371
cs43l22_Stop
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
Stops audio Codec playing. It powers down the codec.
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/cs43l22/cs43l22.c:319


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:48