Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CMSIS_STM32L4xx CMSIS_DSP_401 STM32L4xx_HAL_Driver
cs43l22.h
00001 /** 00002 ****************************************************************************** 00003 * @file cs43l22.h 00004 * @author MCD Application Team 00005 * @version V2.0.1 00006 * @date 16-September-2015 00007 * @brief This file contains all the functions prototypes for the cs43l22.c driver. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __CS43l22_H 00040 #define __CS43l22_H 00041 00042 /* Includes ------------------------------------------------------------------*/ 00043 #include "../Common/audio.h" 00044 00045 /** @addtogroup BSP 00046 * @{ 00047 */ 00048 00049 /** @addtogroup Component 00050 * @{ 00051 */ 00052 00053 /** @addtogroup CS43l22 00054 * @{ 00055 */ 00056 00057 /** @defgroup CS43l22_Exported_Types 00058 * @{ 00059 */ 00060 00061 /** 00062 * @} 00063 */ 00064 00065 /** @defgroup CS43l22_Exported_Constants 00066 * @{ 00067 */ 00068 00069 /******************************************************************************/ 00070 /*************************** Codec User defines ******************************/ 00071 /******************************************************************************/ 00072 /* Codec output DEVICE */ 00073 #define OUTPUT_DEVICE_SPEAKER 1 00074 #define OUTPUT_DEVICE_HEADPHONE 2 00075 #define OUTPUT_DEVICE_BOTH 3 00076 #define OUTPUT_DEVICE_AUTO 4 00077 00078 /* Volume Levels values */ 00079 #define DEFAULT_VOLMIN 0x00 00080 #define DEFAULT_VOLMAX 0xFF 00081 #define DEFAULT_VOLSTEP 0x04 00082 00083 #define AUDIO_PAUSE 0 00084 #define AUDIO_RESUME 1 00085 00086 /* Codec POWER DOWN modes */ 00087 #define CODEC_PDWN_HW 1 00088 #define CODEC_PDWN_SW 2 00089 00090 /* MUTE commands */ 00091 #define AUDIO_MUTE_ON 1 00092 #define AUDIO_MUTE_OFF 0 00093 00094 /* AUDIO FREQUENCY */ 00095 #define AUDIO_FREQUENCY_192K ((uint32_t)192000) 00096 #define AUDIO_FREQUENCY_96K ((uint32_t)96000) 00097 #define AUDIO_FREQUENCY_48K ((uint32_t)48000) 00098 #define AUDIO_FREQUENCY_44K ((uint32_t)44100) 00099 #define AUDIO_FREQUENCY_32K ((uint32_t)32000) 00100 #define AUDIO_FREQUENCY_22K ((uint32_t)22050) 00101 #define AUDIO_FREQUENCY_16K ((uint32_t)16000) 00102 #define AUDIO_FREQUENCY_11K ((uint32_t)11025) 00103 #define AUDIO_FREQUENCY_8K ((uint32_t)8000) 00104 00105 /******************************************************************************/ 00106 /****************************** REGISTER MAPPING ******************************/ 00107 /******************************************************************************/ 00108 /** 00109 * @brief CS43L22 ID 00110 */ 00111 #define CS43L22_ID 0xE0 00112 #define CS43L22_ID_MASK 0xF8 00113 /** 00114 * @brief Chip ID Register: Chip I.D. and Revision Register 00115 * Read only register 00116 * Default value: 0x01 00117 * [7:3] CHIPID[4:0]: I.D. code for the CS43L22. 00118 * Default value: 11100b 00119 * [2:0] REVID[2:0]: CS43L22 revision level. 00120 * Default value: 00121 * 000 - Rev A0 00122 * 001 - Rev A1 00123 * 010 - Rev B0 00124 * 011 - Rev B1 00125 */ 00126 #define CS43L22_CHIPID_ADDR 0x01 00127 00128 /** 00129 * @} 00130 */ 00131 00132 /** @defgroup CS43l22_Exported_Macros 00133 * @{ 00134 */ 00135 #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 255) / 100))) 00136 /** 00137 * @} 00138 */ 00139 00140 /** @defgroup CS43l22_Exported_Functions 00141 * @{ 00142 */ 00143 00144 /*------------------------------------------------------------------------------ 00145 Audio Codec functions 00146 ------------------------------------------------------------------------------*/ 00147 /* High Layer codec functions */ 00148 uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq); 00149 void cs43l22_DeInit(void); 00150 uint32_t cs43l22_ReadID(uint16_t DeviceAddr); 00151 uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); 00152 uint32_t cs43l22_Pause(uint16_t DeviceAddr); 00153 uint32_t cs43l22_Resume(uint16_t DeviceAddr); 00154 uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t Cmd); 00155 uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume); 00156 uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); 00157 uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd); 00158 uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); 00159 uint32_t cs43l22_Reset(uint16_t DeviceAddr); 00160 00161 /* AUDIO IO functions */ 00162 void AUDIO_IO_Init(void); 00163 void AUDIO_IO_DeInit(void); 00164 void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); 00165 uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); 00166 00167 /* Audio driver structure */ 00168 extern AUDIO_DrvTypeDef cs43l22_drv; 00169 00170 #endif /* __CS43l22_H */ 00171 00172 /** 00173 * @} 00174 */ 00175 00176 /** 00177 * @} 00178 */ 00179 00180 /** 00181 * @} 00182 */ 00183 00184 /** 00185 * @} 00186 */ 00187 00188 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00189
Generated on Wed Jul 13 2022 02:20:52 by
