STM32L476G-Discovery board drivers V1.0.0
Dependents: DiscoLogger DISCO_L476VG_GlassLCD DISCO_L476VG_MicrophoneRecorder DISCO_L476VG_UART ... more
cs43l22.h
00001 /** 00002 ****************************************************************************** 00003 * @file cs43l22.h 00004 * @author MCD Application Team 00005 * @brief This file contains all the functions prototypes for the cs43l22.c driver. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2015 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef __CS43L22_H 00022 #define __CS43L22_H 00023 00024 /* Includes ------------------------------------------------------------------*/ 00025 #include "../Common/audio.h" 00026 00027 /** @addtogroup BSP 00028 * @{ 00029 */ 00030 00031 /** @addtogroup Component 00032 * @{ 00033 */ 00034 00035 /** @addtogroup CS43L22 00036 * @{ 00037 */ 00038 00039 /** @defgroup CS43L22_Exported_Types 00040 * @{ 00041 */ 00042 00043 /** 00044 * @} 00045 */ 00046 00047 /** @defgroup CS43L22_Exported_Constants 00048 * @{ 00049 */ 00050 00051 /******************************************************************************/ 00052 /*************************** Codec User defines ******************************/ 00053 /******************************************************************************/ 00054 /* Codec output DEVICE */ 00055 #define OUTPUT_DEVICE_SPEAKER 1 00056 #define OUTPUT_DEVICE_HEADPHONE 2 00057 #define OUTPUT_DEVICE_BOTH 3 00058 #define OUTPUT_DEVICE_AUTO 4 00059 00060 /* Volume Levels values */ 00061 #define DEFAULT_VOLMIN 0x00 00062 #define DEFAULT_VOLMAX 0xFF 00063 #define DEFAULT_VOLSTEP 0x04 00064 00065 #define AUDIO_PAUSE 0 00066 #define AUDIO_RESUME 1 00067 00068 /* Codec POWER DOWN modes */ 00069 #define CODEC_PDWN_HW 1 00070 #define CODEC_PDWN_SW 2 00071 00072 /* MUTE commands */ 00073 #define AUDIO_MUTE_ON 1 00074 #define AUDIO_MUTE_OFF 0 00075 00076 /* AUDIO FREQUENCY */ 00077 #define AUDIO_FREQUENCY_192K ((uint32_t)192000) 00078 #define AUDIO_FREQUENCY_96K ((uint32_t)96000) 00079 #define AUDIO_FREQUENCY_48K ((uint32_t)48000) 00080 #define AUDIO_FREQUENCY_44K ((uint32_t)44100) 00081 #define AUDIO_FREQUENCY_32K ((uint32_t)32000) 00082 #define AUDIO_FREQUENCY_22K ((uint32_t)22050) 00083 #define AUDIO_FREQUENCY_16K ((uint32_t)16000) 00084 #define AUDIO_FREQUENCY_11K ((uint32_t)11025) 00085 #define AUDIO_FREQUENCY_8K ((uint32_t)8000) 00086 00087 /** CS43l22 Registers ***/ 00088 #define CS43L22_REG_ID 0x01 00089 #define CS43L22_REG_POWER_CTL1 0x02 00090 #define CS43L22_REG_POWER_CTL2 0x04 00091 #define CS43L22_REG_CLOCKING_CTL 0x05 00092 #define CS43L22_REG_INTERFACE_CTL1 0x06 00093 #define CS43L22_REG_INTERFACE_CTL2 0x07 00094 #define CS43L22_REG_PASSTHR_A_SELECT 0x08 00095 #define CS43L22_REG_PASSTHR_B_SELECT 0x09 00096 #define CS43L22_REG_ANALOG_ZC_SR_SETT 0x0A 00097 #define CS43L22_REG_PASSTHR_GANG_CTL 0x0C 00098 #define CS43L22_REG_PLAYBACK_CTL1 0x0D 00099 #define CS43L22_REG_MISC_CTL 0x0E 00100 #define CS43L22_REG_PLAYBACK_CTL2 0x0F 00101 #define CS43L22_REG_PASSTHR_A_VOL 0x14 00102 #define CS43L22_REG_PASSTHR_B_VOL 0x15 00103 #define CS43L22_REG_PCMA_VOL 0x1A 00104 #define CS43L22_REG_PCMB_VOL 0x1B 00105 #define CS43L22_REG_BEEP_FREQ_ON_TIME 0x1C 00106 #define CS43L22_REG_BEEP_VOL_OFF_TIME 0x1D 00107 #define CS43L22_REG_BEEP_TONE_CFG 0x1E 00108 #define CS43L22_REG_TONE_CTL 0x1F 00109 #define CS43L22_REG_MASTER_A_VOL 0x20 00110 #define CS43L22_REG_MASTER_B_VOL 0x21 00111 #define CS43L22_REG_HEADPHONE_A_VOL 0x22 00112 #define CS43L22_REG_HEADPHONE_B_VOL 0x23 00113 #define CS43L22_REG_SPEAKER_A_VOL 0x24 00114 #define CS43L22_REG_SPEAKER_B_VOL 0x25 00115 #define CS43L22_REG_CH_MIXER_SWAP 0x26 00116 #define CS43L22_REG_LIMIT_CTL1 0x27 00117 #define CS43L22_REG_LIMIT_CTL2 0x28 00118 #define CS43L22_REG_LIMIT_ATTACK_RATE 0x29 00119 #define CS43L22_REG_OVF_CLK_STATUS 0x2E 00120 #define CS43L22_REG_BATT_COMPENSATION 0x2F 00121 #define CS43L22_REG_VP_BATTERY_LEVEL 0x30 00122 #define CS43L22_REG_SPEAKER_STATUS 0x31 00123 #define CS43L22_REG_TEMPMONITOR_CTL 0x32 00124 #define CS43L22_REG_THERMAL_FOLDBACK 0x33 00125 #define CS43L22_REG_CHARGE_PUMP_FREQ 0x34 00126 00127 /******************************************************************************/ 00128 /****************************** REGISTER MAPPING ******************************/ 00129 /******************************************************************************/ 00130 /** 00131 * @brief CS43L22 ID 00132 */ 00133 #define CS43L22_ID 0xE0 00134 #define CS43L22_ID_MASK 0xF8 00135 /** 00136 * @brief Chip ID Register: Chip I.D. and Revision Register 00137 * Read only register 00138 * Default value: 0x01 00139 * [7:3] CHIPID[4:0]: I.D. code for the CS43L22. 00140 * Default value: 11100b 00141 * [2:0] REVID[2:0]: CS43L22 revision level. 00142 * Default value: 00143 * 000 - Rev A0 00144 * 001 - Rev A1 00145 * 010 - Rev B0 00146 * 011 - Rev B1 00147 */ 00148 #define CS43L22_CHIPID_ADDR 0x01 00149 00150 /** 00151 * @} 00152 */ 00153 00154 /** @defgroup CS43L22_Exported_Macros 00155 * @{ 00156 */ 00157 00158 /** 00159 * @} 00160 */ 00161 00162 /** @defgroup CS43L22_Exported_Functions 00163 * @{ 00164 */ 00165 00166 /*------------------------------------------------------------------------------ 00167 Audio Codec functions 00168 ------------------------------------------------------------------------------*/ 00169 /* High Layer codec functions */ 00170 uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); 00171 void cs43l22_DeInit(void); 00172 uint32_t cs43l22_ReadID(uint16_t DeviceAddr); 00173 uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); 00174 uint32_t cs43l22_Pause(uint16_t DeviceAddr); 00175 uint32_t cs43l22_Resume(uint16_t DeviceAddr); 00176 uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd); 00177 uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume); 00178 uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); 00179 uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd); 00180 uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); 00181 uint32_t cs43l22_Reset(uint16_t DeviceAddr); 00182 00183 /* AUDIO IO functions */ 00184 void AUDIO_IO_Init(void); 00185 void AUDIO_IO_DeInit(void); 00186 void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); 00187 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); 00188 00189 /* Audio driver structure */ 00190 extern AUDIO_DrvTypeDef cs43l22_drv; 00191 00192 #endif /* __CS43L22_H */ 00193 00194 /** 00195 * @} 00196 */ 00197 00198 /** 00199 * @} 00200 */ 00201 00202 /** 00203 * @} 00204 */ 00205 00206 /** 00207 * @} 00208 */ 00209 00210 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 18:37:21 by 1.7.2