ST / BSP_DISCO_L4R9I

Dependents:   DISCO_L4R9I-LCD-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cs42l51.h Source File

cs42l51.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    cs42l51.h
00004   * @author  MCD Application Team
00005   * @brief   This file contains all the functions prototypes for the cs42l51.c driver.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2017 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 __CS42L51_H
00022 #define __CS42L51_H
00023 
00024 /* Includes ------------------------------------------------------------------*/
00025 #include "../Common/audio.h"
00026 
00027 /** @addtogroup BSP
00028   * @{
00029   */ 
00030 
00031 /** @addtogroup Component
00032   * @{
00033   */ 
00034   
00035 /** @addtogroup CS42L51
00036   * @{
00037   */
00038 
00039 /** @defgroup CS42L51_Exported_Types
00040   * @{
00041   */
00042 
00043 /**
00044   * @}
00045   */
00046 
00047 /** @defgroup CS42L51_Exported_Constants
00048   * @{
00049   */ 
00050 
00051 /******************************************************************************/
00052 /***************************  Codec User defines ******************************/
00053 /******************************************************************************/
00054 /* Codec output devices */
00055 #define OUTPUT_DEVICE_HEADPHONE       0x01
00056 
00057 /* Codec input devices */
00058 #define INPUT_DEVICE_MIC1             0x10
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 /******************************************************************************/
00088 /****************************** REGISTER MAPPING ******************************/
00089 /******************************************************************************/
00090 /** 
00091   * @brief  CS42L51 ID  
00092   */  
00093 #define  CS42L51_ID            0xD8
00094 #define  CS42L51_ID_MASK       0xF8
00095 /**
00096   * @brief Chip ID Register: Chip I.D. and Revision Register
00097   *  Read only register
00098   *  Default value: 0x01
00099   *  [7:3] CHIPID[4:0]: I.D. code for the CS42L51.
00100   *        Default value: 11100b
00101   *  [2:0] REVID[2:0]: CS42L51 revision level.
00102   *        Default value: 
00103   *        000 - Rev A0
00104   *        001 - Rev A1
00105   *        010 - Rev B0
00106   *        011 - Rev B1
00107   */
00108 #define CS42L51_CHIPID_ADDR    0x01
00109 
00110 /**
00111   * @}
00112   */ 
00113 
00114 /** @defgroup CS42L51_Exported_Macros
00115   * @{
00116   */
00117 #define VOLUME_CONVERT(Volume)    ((Volume >= 100) ? 0 : ((uint8_t)(((Volume * 2) + 56))))
00118 /**
00119   * @}
00120   */ 
00121 
00122 /** @defgroup CS42L51_Exported_Functions
00123   * @{
00124   */
00125     
00126 /*------------------------------------------------------------------------------
00127                            Audio Codec functions 
00128 ------------------------------------------------------------------------------*/
00129 /* High Layer codec functions */
00130 uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq);
00131 void     cs42l51_DeInit(void);
00132 uint32_t cs42l51_ReadID(uint16_t DeviceAddr);
00133 uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
00134 uint32_t cs42l51_Pause(uint16_t DeviceAddr);
00135 uint32_t cs42l51_Resume(uint16_t DeviceAddr);
00136 uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t Cmd);
00137 uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
00138 uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
00139 uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
00140 uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
00141 uint32_t cs42l51_Reset(uint16_t DeviceAddr);
00142 
00143 /* AUDIO IO functions */
00144 void      AUDIO_IO_Init(void);
00145 void      AUDIO_IO_DeInit(void);
00146 void      AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
00147 uint8_t   AUDIO_IO_Read(uint8_t Addr, uint8_t Reg);
00148 void      AUDIO_IO_Delay(uint32_t Delay);
00149 
00150 /* Audio driver structure */
00151 extern AUDIO_DrvTypeDef   cs42l51_drv;
00152 
00153 /**
00154   * @}
00155   */ 
00156 
00157 /**
00158   * @}
00159   */ 
00160 
00161 /**
00162   * @}
00163   */
00164 
00165 /**
00166   * @}
00167   */ 
00168 
00169 #endif /* __CS42L51_H */
00170 
00171 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/