updated wait_ms(ms) to thread_sleep_for(ms) for Mbed OS 6

Committer:
Jerome Coutant
Date:
Tue May 16 10:50:26 2017 +0200
Revision:
2:123b894b49dd
Child:
3:3cdfcc4f7c9d
STM32Cube_FW_BSP_DISCO_F469NI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jerome Coutant 2:123b894b49dd 1 /**
Jerome Coutant 2:123b894b49dd 2 ******************************************************************************
Jerome Coutant 2:123b894b49dd 3 * @file cs43l22.h
Jerome Coutant 2:123b894b49dd 4 * @author MCD Application Team
Jerome Coutant 2:123b894b49dd 5 * @version V2.0.2
Jerome Coutant 2:123b894b49dd 6 * @date 06-October-2015
Jerome Coutant 2:123b894b49dd 7 * @brief This file contains all the functions prototypes for the cs43l22.c driver.
Jerome Coutant 2:123b894b49dd 8 ******************************************************************************
Jerome Coutant 2:123b894b49dd 9 * @attention
Jerome Coutant 2:123b894b49dd 10 *
Jerome Coutant 2:123b894b49dd 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Jerome Coutant 2:123b894b49dd 12 *
Jerome Coutant 2:123b894b49dd 13 * Redistribution and use in source and binary forms, with or without modification,
Jerome Coutant 2:123b894b49dd 14 * are permitted provided that the following conditions are met:
Jerome Coutant 2:123b894b49dd 15 * 1. Redistributions of source code must retain the above copyright notice,
Jerome Coutant 2:123b894b49dd 16 * this list of conditions and the following disclaimer.
Jerome Coutant 2:123b894b49dd 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Jerome Coutant 2:123b894b49dd 18 * this list of conditions and the following disclaimer in the documentation
Jerome Coutant 2:123b894b49dd 19 * and/or other materials provided with the distribution.
Jerome Coutant 2:123b894b49dd 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Jerome Coutant 2:123b894b49dd 21 * may be used to endorse or promote products derived from this software
Jerome Coutant 2:123b894b49dd 22 * without specific prior written permission.
Jerome Coutant 2:123b894b49dd 23 *
Jerome Coutant 2:123b894b49dd 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Jerome Coutant 2:123b894b49dd 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Jerome Coutant 2:123b894b49dd 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Jerome Coutant 2:123b894b49dd 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Jerome Coutant 2:123b894b49dd 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Jerome Coutant 2:123b894b49dd 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Jerome Coutant 2:123b894b49dd 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Jerome Coutant 2:123b894b49dd 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Jerome Coutant 2:123b894b49dd 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Jerome Coutant 2:123b894b49dd 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Jerome Coutant 2:123b894b49dd 34 *
Jerome Coutant 2:123b894b49dd 35 ******************************************************************************
Jerome Coutant 2:123b894b49dd 36 */
Jerome Coutant 2:123b894b49dd 37
Jerome Coutant 2:123b894b49dd 38 /* Define to prevent recursive inclusion -------------------------------------*/
Jerome Coutant 2:123b894b49dd 39 #ifndef __CS43L22_H
Jerome Coutant 2:123b894b49dd 40 #define __CS43L22_H
Jerome Coutant 2:123b894b49dd 41
Jerome Coutant 2:123b894b49dd 42 /* Includes ------------------------------------------------------------------*/
Jerome Coutant 2:123b894b49dd 43 #include "../Common/audio.h"
Jerome Coutant 2:123b894b49dd 44
Jerome Coutant 2:123b894b49dd 45 /** @addtogroup BSP
Jerome Coutant 2:123b894b49dd 46 * @{
Jerome Coutant 2:123b894b49dd 47 */
Jerome Coutant 2:123b894b49dd 48
Jerome Coutant 2:123b894b49dd 49 /** @addtogroup Component
Jerome Coutant 2:123b894b49dd 50 * @{
Jerome Coutant 2:123b894b49dd 51 */
Jerome Coutant 2:123b894b49dd 52
Jerome Coutant 2:123b894b49dd 53 /** @addtogroup CS43L22
Jerome Coutant 2:123b894b49dd 54 * @{
Jerome Coutant 2:123b894b49dd 55 */
Jerome Coutant 2:123b894b49dd 56
Jerome Coutant 2:123b894b49dd 57 /** @defgroup CS43L22_Exported_Types
Jerome Coutant 2:123b894b49dd 58 * @{
Jerome Coutant 2:123b894b49dd 59 */
Jerome Coutant 2:123b894b49dd 60
Jerome Coutant 2:123b894b49dd 61 /**
Jerome Coutant 2:123b894b49dd 62 * @}
Jerome Coutant 2:123b894b49dd 63 */
Jerome Coutant 2:123b894b49dd 64
Jerome Coutant 2:123b894b49dd 65 /** @defgroup CS43L22_Exported_Constants
Jerome Coutant 2:123b894b49dd 66 * @{
Jerome Coutant 2:123b894b49dd 67 */
Jerome Coutant 2:123b894b49dd 68
Jerome Coutant 2:123b894b49dd 69 /******************************************************************************/
Jerome Coutant 2:123b894b49dd 70 /*************************** Codec User defines ******************************/
Jerome Coutant 2:123b894b49dd 71 /******************************************************************************/
Jerome Coutant 2:123b894b49dd 72 /* Codec output DEVICE */
Jerome Coutant 2:123b894b49dd 73 #define OUTPUT_DEVICE_SPEAKER 1
Jerome Coutant 2:123b894b49dd 74 #define OUTPUT_DEVICE_HEADPHONE 2
Jerome Coutant 2:123b894b49dd 75 #define OUTPUT_DEVICE_BOTH 3
Jerome Coutant 2:123b894b49dd 76 #define OUTPUT_DEVICE_AUTO 4
Jerome Coutant 2:123b894b49dd 77
Jerome Coutant 2:123b894b49dd 78 /* Volume Levels values */
Jerome Coutant 2:123b894b49dd 79 #define DEFAULT_VOLMIN 0x00
Jerome Coutant 2:123b894b49dd 80 #define DEFAULT_VOLMAX 0xFF
Jerome Coutant 2:123b894b49dd 81 #define DEFAULT_VOLSTEP 0x04
Jerome Coutant 2:123b894b49dd 82
Jerome Coutant 2:123b894b49dd 83 #define AUDIO_PAUSE 0
Jerome Coutant 2:123b894b49dd 84 #define AUDIO_RESUME 1
Jerome Coutant 2:123b894b49dd 85
Jerome Coutant 2:123b894b49dd 86 /* Codec POWER DOWN modes */
Jerome Coutant 2:123b894b49dd 87 #define CODEC_PDWN_HW 1
Jerome Coutant 2:123b894b49dd 88 #define CODEC_PDWN_SW 2
Jerome Coutant 2:123b894b49dd 89
Jerome Coutant 2:123b894b49dd 90 /* MUTE commands */
Jerome Coutant 2:123b894b49dd 91 #define AUDIO_MUTE_ON 1
Jerome Coutant 2:123b894b49dd 92 #define AUDIO_MUTE_OFF 0
Jerome Coutant 2:123b894b49dd 93
Jerome Coutant 2:123b894b49dd 94 /* AUDIO FREQUENCY */
Jerome Coutant 2:123b894b49dd 95 #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
Jerome Coutant 2:123b894b49dd 96 #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
Jerome Coutant 2:123b894b49dd 97 #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
Jerome Coutant 2:123b894b49dd 98 #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
Jerome Coutant 2:123b894b49dd 99 #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
Jerome Coutant 2:123b894b49dd 100 #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
Jerome Coutant 2:123b894b49dd 101 #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
Jerome Coutant 2:123b894b49dd 102 #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
Jerome Coutant 2:123b894b49dd 103 #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
Jerome Coutant 2:123b894b49dd 104
Jerome Coutant 2:123b894b49dd 105 /** CS43l22 Registers ***/
Jerome Coutant 2:123b894b49dd 106 #define CS43L22_REG_ID 0x01
Jerome Coutant 2:123b894b49dd 107 #define CS43L22_REG_POWER_CTL1 0x02
Jerome Coutant 2:123b894b49dd 108 #define CS43L22_REG_POWER_CTL2 0x04
Jerome Coutant 2:123b894b49dd 109 #define CS43L22_REG_CLOCKING_CTL 0x05
Jerome Coutant 2:123b894b49dd 110 #define CS43L22_REG_INTERFACE_CTL1 0x06
Jerome Coutant 2:123b894b49dd 111 #define CS43L22_REG_INTERFACE_CTL2 0x07
Jerome Coutant 2:123b894b49dd 112 #define CS43L22_REG_PASSTHR_A_SELECT 0x08
Jerome Coutant 2:123b894b49dd 113 #define CS43L22_REG_PASSTHR_B_SELECT 0x09
Jerome Coutant 2:123b894b49dd 114 #define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A
Jerome Coutant 2:123b894b49dd 115 #define CS43L22_REG_PASSTHR_GANG_CTL 0x0C
Jerome Coutant 2:123b894b49dd 116 #define CS43L22_REG_PLAYBACK_CTL1 0x0D
Jerome Coutant 2:123b894b49dd 117 #define CS43L22_REG_MISC_CTL 0x0E
Jerome Coutant 2:123b894b49dd 118 #define CS43L22_REG_PLAYBACK_CTL2 0x0F
Jerome Coutant 2:123b894b49dd 119 #define CS43L22_REG_PASSTHR_A_VOL 0x14
Jerome Coutant 2:123b894b49dd 120 #define CS43L22_REG_PASSTHR_B_VOL 0x15
Jerome Coutant 2:123b894b49dd 121 #define CS43L22_REG_PCMA_VOL 0x1A
Jerome Coutant 2:123b894b49dd 122 #define CS43L22_REG_PCMB_VOL 0x1B
Jerome Coutant 2:123b894b49dd 123 #define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C
Jerome Coutant 2:123b894b49dd 124 #define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D
Jerome Coutant 2:123b894b49dd 125 #define CS43L22_REG_BEEP_TONE_CFG 0x1E
Jerome Coutant 2:123b894b49dd 126 #define CS43L22_REG_TONE_CTL 0x1F
Jerome Coutant 2:123b894b49dd 127 #define CS43L22_REG_MASTER_A_VOL 0x20
Jerome Coutant 2:123b894b49dd 128 #define CS43L22_REG_MASTER_B_VOL 0x21
Jerome Coutant 2:123b894b49dd 129 #define CS43L22_REG_HEADPHONE_A_VOL 0x22
Jerome Coutant 2:123b894b49dd 130 #define CS43L22_REG_HEADPHONE_B_VOL 0x23
Jerome Coutant 2:123b894b49dd 131 #define CS43L22_REG_SPEAKER_A_VOL 0x24
Jerome Coutant 2:123b894b49dd 132 #define CS43L22_REG_SPEAKER_B_VOL 0x25
Jerome Coutant 2:123b894b49dd 133 #define CS43L22_REG_CH_MIXER_SWAP 0x26
Jerome Coutant 2:123b894b49dd 134 #define CS43L22_REG_LIMIT_CTL1 0x27
Jerome Coutant 2:123b894b49dd 135 #define CS43L22_REG_LIMIT_CTL2 0x28
Jerome Coutant 2:123b894b49dd 136 #define CS43L22_REG_LIMIT_ATTACK_RATE 0x29
Jerome Coutant 2:123b894b49dd 137 #define CS43L22_REG_OVF_CLK_STATUS 0x2E
Jerome Coutant 2:123b894b49dd 138 #define CS43L22_REG_BATT_COMPENSATION 0x2F
Jerome Coutant 2:123b894b49dd 139 #define CS43L22_REG_VP_BATTERY_LEVEL 0x30
Jerome Coutant 2:123b894b49dd 140 #define CS43L22_REG_SPEAKER_STATUS 0x31
Jerome Coutant 2:123b894b49dd 141 #define CS43L22_REG_TEMPMONITOR_CTL 0x32
Jerome Coutant 2:123b894b49dd 142 #define CS43L22_REG_THERMAL_FOLDBACK 0x33
Jerome Coutant 2:123b894b49dd 143 #define CS43L22_REG_CHARGE_PUMP_FREQ 0x34
Jerome Coutant 2:123b894b49dd 144
Jerome Coutant 2:123b894b49dd 145 /******************************************************************************/
Jerome Coutant 2:123b894b49dd 146 /****************************** REGISTER MAPPING ******************************/
Jerome Coutant 2:123b894b49dd 147 /******************************************************************************/
Jerome Coutant 2:123b894b49dd 148 /**
Jerome Coutant 2:123b894b49dd 149 * @brief CS43L22 ID
Jerome Coutant 2:123b894b49dd 150 */
Jerome Coutant 2:123b894b49dd 151 #define CS43L22_ID 0xE0
Jerome Coutant 2:123b894b49dd 152 #define CS43L22_ID_MASK 0xF8
Jerome Coutant 2:123b894b49dd 153 /**
Jerome Coutant 2:123b894b49dd 154 * @brief Chip ID Register: Chip I.D. and Revision Register
Jerome Coutant 2:123b894b49dd 155 * Read only register
Jerome Coutant 2:123b894b49dd 156 * Default value: 0x01
Jerome Coutant 2:123b894b49dd 157 * [7:3] CHIPID[4:0]: I.D. code for the CS43L22.
Jerome Coutant 2:123b894b49dd 158 * Default value: 11100b
Jerome Coutant 2:123b894b49dd 159 * [2:0] REVID[2:0]: CS43L22 revision level.
Jerome Coutant 2:123b894b49dd 160 * Default value:
Jerome Coutant 2:123b894b49dd 161 * 000 - Rev A0
Jerome Coutant 2:123b894b49dd 162 * 001 - Rev A1
Jerome Coutant 2:123b894b49dd 163 * 010 - Rev B0
Jerome Coutant 2:123b894b49dd 164 * 011 - Rev B1
Jerome Coutant 2:123b894b49dd 165 */
Jerome Coutant 2:123b894b49dd 166 #define CS43L22_CHIPID_ADDR 0x01
Jerome Coutant 2:123b894b49dd 167
Jerome Coutant 2:123b894b49dd 168 /**
Jerome Coutant 2:123b894b49dd 169 * @}
Jerome Coutant 2:123b894b49dd 170 */
Jerome Coutant 2:123b894b49dd 171
Jerome Coutant 2:123b894b49dd 172 /** @defgroup CS43L22_Exported_Macros
Jerome Coutant 2:123b894b49dd 173 * @{
Jerome Coutant 2:123b894b49dd 174 */
Jerome Coutant 2:123b894b49dd 175
Jerome Coutant 2:123b894b49dd 176 /**
Jerome Coutant 2:123b894b49dd 177 * @}
Jerome Coutant 2:123b894b49dd 178 */
Jerome Coutant 2:123b894b49dd 179
Jerome Coutant 2:123b894b49dd 180 /** @defgroup CS43L22_Exported_Functions
Jerome Coutant 2:123b894b49dd 181 * @{
Jerome Coutant 2:123b894b49dd 182 */
Jerome Coutant 2:123b894b49dd 183
Jerome Coutant 2:123b894b49dd 184 /*------------------------------------------------------------------------------
Jerome Coutant 2:123b894b49dd 185 Audio Codec functions
Jerome Coutant 2:123b894b49dd 186 ------------------------------------------------------------------------------*/
Jerome Coutant 2:123b894b49dd 187 /* High Layer codec functions */
Jerome Coutant 2:123b894b49dd 188 uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
Jerome Coutant 2:123b894b49dd 189 void cs43l22_DeInit(void);
Jerome Coutant 2:123b894b49dd 190 uint32_t cs43l22_ReadID(uint16_t DeviceAddr);
Jerome Coutant 2:123b894b49dd 191 uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
Jerome Coutant 2:123b894b49dd 192 uint32_t cs43l22_Pause(uint16_t DeviceAddr);
Jerome Coutant 2:123b894b49dd 193 uint32_t cs43l22_Resume(uint16_t DeviceAddr);
Jerome Coutant 2:123b894b49dd 194 uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd);
Jerome Coutant 2:123b894b49dd 195 uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
Jerome Coutant 2:123b894b49dd 196 uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
Jerome Coutant 2:123b894b49dd 197 uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
Jerome Coutant 2:123b894b49dd 198 uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
Jerome Coutant 2:123b894b49dd 199 uint32_t cs43l22_Reset(uint16_t DeviceAddr);
Jerome Coutant 2:123b894b49dd 200
Jerome Coutant 2:123b894b49dd 201 /* AUDIO IO functions */
Jerome Coutant 2:123b894b49dd 202 void AUDIO_IO_Init(void);
Jerome Coutant 2:123b894b49dd 203 void AUDIO_IO_DeInit(void);
Jerome Coutant 2:123b894b49dd 204 void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
Jerome Coutant 2:123b894b49dd 205 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
Jerome Coutant 2:123b894b49dd 206
Jerome Coutant 2:123b894b49dd 207 /* Audio driver structure */
Jerome Coutant 2:123b894b49dd 208 extern AUDIO_DrvTypeDef cs43l22_drv;
Jerome Coutant 2:123b894b49dd 209
Jerome Coutant 2:123b894b49dd 210 #endif /* __CS43L22_H */
Jerome Coutant 2:123b894b49dd 211
Jerome Coutant 2:123b894b49dd 212 /**
Jerome Coutant 2:123b894b49dd 213 * @}
Jerome Coutant 2:123b894b49dd 214 */
Jerome Coutant 2:123b894b49dd 215
Jerome Coutant 2:123b894b49dd 216 /**
Jerome Coutant 2:123b894b49dd 217 * @}
Jerome Coutant 2:123b894b49dd 218 */
Jerome Coutant 2:123b894b49dd 219
Jerome Coutant 2:123b894b49dd 220 /**
Jerome Coutant 2:123b894b49dd 221 * @}
Jerome Coutant 2:123b894b49dd 222 */
Jerome Coutant 2:123b894b49dd 223
Jerome Coutant 2:123b894b49dd 224 /**
Jerome Coutant 2:123b894b49dd 225 * @}
Jerome Coutant 2:123b894b49dd 226 */
Jerome Coutant 2:123b894b49dd 227
Jerome Coutant 2:123b894b49dd 228 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/