Select one of the symbols to view example projects that use it.
 
Outline
#define __CS43L22_H
#include "../Common/audio.h"
#define OUTPUT_DEVICE_SPEAKER
#define OUTPUT_DEVICE_HEADPHONE
#define OUTPUT_DEVICE_BOTH
#define OUTPUT_DEVICE_AUTO
#define DEFAULT_VOLMIN
#define DEFAULT_VOLMAX
#define DEFAULT_VOLSTEP
#define AUDIO_PAUSE
#define AUDIO_RESUME
#define CODEC_PDWN_HW
#define CODEC_PDWN_SW
#define AUDIO_MUTE_ON
#define AUDIO_MUTE_OFF
#define AUDIO_FREQUENCY_192K
#define AUDIO_FREQUENCY_96K
#define AUDIO_FREQUENCY_48K
#define AUDIO_FREQUENCY_44K
#define AUDIO_FREQUENCY_32K
#define AUDIO_FREQUENCY_22K
#define AUDIO_FREQUENCY_16K
#define AUDIO_FREQUENCY_11K
#define AUDIO_FREQUENCY_8K
#define CS43L22_REG_ID
#define CS43L22_REG_POWER_CTL1
#define CS43L22_REG_POWER_CTL2
#define CS43L22_REG_CLOCKING_CTL
#define CS43L22_REG_INTERFACE_CTL1
#define CS43L22_REG_INTERFACE_CTL2
#define CS43L22_REG_PASSTHR_A_SELECT
#define CS43L22_REG_PASSTHR_B_SELECT
#define CS43L22_REG_ANALOG_ZC_SR_SETT
#define CS43L22_REG_PASSTHR_GANG_CTL
#define CS43L22_REG_PLAYBACK_CTL1
#define CS43L22_REG_MISC_CTL
#define CS43L22_REG_PLAYBACK_CTL2
#define CS43L22_REG_PASSTHR_A_VOL
#define CS43L22_REG_PASSTHR_B_VOL
#define CS43L22_REG_PCMA_VOL
#define CS43L22_REG_PCMB_VOL
#define CS43L22_REG_BEEP_FREQ_ON_TIME
#define CS43L22_REG_BEEP_VOL_OFF_TIME
#define CS43L22_REG_BEEP_TONE_CFG
#define CS43L22_REG_TONE_CTL
#define CS43L22_REG_MASTER_A_VOL
#define CS43L22_REG_MASTER_B_VOL
#define CS43L22_REG_HEADPHONE_A_VOL
#define CS43L22_REG_HEADPHONE_B_VOL
#define CS43L22_REG_SPEAKER_A_VOL
#define CS43L22_REG_SPEAKER_B_VOL
#define CS43L22_REG_CH_MIXER_SWAP
#define CS43L22_REG_LIMIT_CTL1
#define CS43L22_REG_LIMIT_CTL2
#define CS43L22_REG_LIMIT_ATTACK_RATE
#define CS43L22_REG_OVF_CLK_STATUS
#define CS43L22_REG_BATT_COMPENSATION
#define CS43L22_REG_VP_BATTERY_LEVEL
#define CS43L22_REG_SPEAKER_STATUS
#define CS43L22_REG_TEMPMONITOR_CTL
#define CS43L22_REG_THERMAL_FOLDBACK
#define CS43L22_REG_CHARGE_PUMP_FREQ
#define CS43L22_ID
#define CS43L22_ID_MASK
#define CS43L22_CHIPID_ADDR
cs43l22_Init(uint16_t, uint16_t, uint8_t, uint32_t);
cs43l22_DeInit();
cs43l22_ReadID(uint16_t);
cs43l22_Play(uint16_t, uint16_t *, uint16_t);
cs43l22_Pause(uint16_t);
cs43l22_Resume(uint16_t);
cs43l22_Stop(uint16_t, uint32_t);
cs43l22_SetVolume(uint16_t, uint8_t);
cs43l22_SetFrequency(uint16_t, uint32_t);
cs43l22_SetMute(uint16_t, uint32_t);
cs43l22_SetOutputMode(uint16_t, uint8_t);
cs43l22_Reset(uint16_t);
AUDIO_IO_Init();
AUDIO_IO_DeInit();
AUDIO_IO_Write(uint8_t, uint8_t, uint8_t);
AUDIO_IO_Read(uint8_t, uint8_t);
cs43l22_drv;
Files
loading...
CodeScopeSTM32 Libraries and Samplescs43l22cs43l22.h
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file cs43l22.h * @author MCD Application Team * @brief This file contains all the functions prototypes for the cs43l22.c driver. ****************************************************************************** * @attention * * Copyright (c) 2015 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __CS43L22_H #define __CS43L22_H /* Includes ------------------------------------------------------------------*/ #include "../Common/audio.h" /** @addtogroup BSP * @{ *//* ... */ /** @addtogroup Component * @{ *//* ... */ /** @addtogroup CS43L22 * @{ *//* ... */ /** @defgroup CS43L22_Exported_Types * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup CS43L22_Exported_Constants * @{ *//* ... */ /******************************************************************************/ /*************************** Codec User defines ******************************/ /******************************************************************************/ /* Codec output DEVICE */ #define OUTPUT_DEVICE_SPEAKER 1 #define OUTPUT_DEVICE_HEADPHONE 2 #define OUTPUT_DEVICE_BOTH 3 #define OUTPUT_DEVICE_AUTO 4 /* Volume Levels values */ #define DEFAULT_VOLMIN 0x00 #define DEFAULT_VOLMAX 0xFF #define DEFAULT_VOLSTEP 0x04 #define AUDIO_PAUSE 0 #define AUDIO_RESUME 1 /* Codec POWER DOWN modes */ #define CODEC_PDWN_HW 1 #define CODEC_PDWN_SW 2 /* MUTE commands */ #define AUDIO_MUTE_ON 1 #define AUDIO_MUTE_OFF 0 /* AUDIO FREQUENCY */ #define AUDIO_FREQUENCY_192K ((uint32_t)192000) #define AUDIO_FREQUENCY_96K ((uint32_t)96000) #define AUDIO_FREQUENCY_48K ((uint32_t)48000) #define AUDIO_FREQUENCY_44K ((uint32_t)44100) #define AUDIO_FREQUENCY_32K ((uint32_t)32000) #define AUDIO_FREQUENCY_22K ((uint32_t)22050) #define AUDIO_FREQUENCY_16K ((uint32_t)16000) #define AUDIO_FREQUENCY_11K ((uint32_t)11025) #define AUDIO_FREQUENCY_8K ((uint32_t)8000) /** CS43l22 Registers ***/ #define CS43L22_REG_ID 0x01 #define CS43L22_REG_POWER_CTL1 0x02 #define CS43L22_REG_POWER_CTL2 0x04 #define CS43L22_REG_CLOCKING_CTL 0x05 #define CS43L22_REG_INTERFACE_CTL1 0x06 #define CS43L22_REG_INTERFACE_CTL2 0x07 #define CS43L22_REG_PASSTHR_A_SELECT 0x08 #define CS43L22_REG_PASSTHR_B_SELECT 0x09 #define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A #define CS43L22_REG_PASSTHR_GANG_CTL 0x0C #define CS43L22_REG_PLAYBACK_CTL1 0x0D #define CS43L22_REG_MISC_CTL 0x0E #define CS43L22_REG_PLAYBACK_CTL2 0x0F #define CS43L22_REG_PASSTHR_A_VOL 0x14 #define CS43L22_REG_PASSTHR_B_VOL 0x15 #define CS43L22_REG_PCMA_VOL 0x1A #define CS43L22_REG_PCMB_VOL 0x1B #define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C #define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D #define CS43L22_REG_BEEP_TONE_CFG 0x1E #define CS43L22_REG_TONE_CTL 0x1F #define CS43L22_REG_MASTER_A_VOL 0x20 #define CS43L22_REG_MASTER_B_VOL 0x21 #define CS43L22_REG_HEADPHONE_A_VOL 0x22 #define CS43L22_REG_HEADPHONE_B_VOL 0x23 #define CS43L22_REG_SPEAKER_A_VOL 0x24 #define CS43L22_REG_SPEAKER_B_VOL 0x25 #define CS43L22_REG_CH_MIXER_SWAP 0x26 #define CS43L22_REG_LIMIT_CTL1 0x27 #define CS43L22_REG_LIMIT_CTL2 0x28 #define CS43L22_REG_LIMIT_ATTACK_RATE 0x29 #define CS43L22_REG_OVF_CLK_STATUS 0x2E #define CS43L22_REG_BATT_COMPENSATION 0x2F #define CS43L22_REG_VP_BATTERY_LEVEL 0x30 #define CS43L22_REG_SPEAKER_STATUS 0x31 #define CS43L22_REG_TEMPMONITOR_CTL 0x32 #define CS43L22_REG_THERMAL_FOLDBACK 0x33 #define CS43L22_REG_CHARGE_PUMP_FREQ 0x34 /******************************************************************************/ /****************************** REGISTER MAPPING ******************************/ /******************************************************************************/ /** * @brief CS43L22 ID *//* ... */ #define CS43L22_ID 0xE0 #define CS43L22_ID_MASK 0xF8 /** * @brief Chip ID Register: Chip I.D. and Revision Register * Read only register * Default value: 0x01 * [7:3] CHIPID[4:0]: I.D. code for the CS43L22. * Default value: 11100b * [2:0] REVID[2:0]: CS43L22 revision level. * Default value: * 000 - Rev A0 * 001 - Rev A1 * 010 - Rev B0 * 011 - Rev B1 *//* ... */ #define CS43L22_CHIPID_ADDR 0x01 63 defines /** * @} *//* ... */ /** @defgroup CS43L22_Exported_Macros * @{ *//* ... */ /** * @} *//* ... */ /** @defgroup CS43L22_Exported_Functions * @{ *//* ... */ /*------------------------------------------------------------------------------ Audio Codec functions ------------------------------------------------------------------------------*//* ... */ /* High Layer codec functions */ uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); void cs43l22_DeInit(void); uint32_t cs43l22_ReadID(uint16_t DeviceAddr); uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); uint32_t cs43l22_Pause(uint16_t DeviceAddr); uint32_t cs43l22_Resume(uint16_t DeviceAddr); uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd); uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume); uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd); uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); uint32_t cs43l22_Reset(uint16_t DeviceAddr); /* AUDIO IO functions */ void AUDIO_IO_Init(void); void AUDIO_IO_DeInit(void); void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); /* Audio driver structure */ extern AUDIO_DrvTypeDef cs43l22_drv; /* ... */ #endif /* __CS43L22_H */ /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */ /** * @} *//* ... */