BSP driver for DISCO_L496AG
Dependents: DISCO_L496AG-LCD-prova_1 DISCO_L496AG-LCD-prova_2 DISCO_L496AG-LCD-demo DISCO_L496AG-SRAM-demo
Drivers/BSP/Components/cs42l51/cs42l51.h@2:106c7b82e064, 2019-11-20 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Nov 20 16:48:24 2019 +0100
- Revision:
- 2:106c7b82e064
- Parent:
- 0:d83f1c8ca282
Update BSP files with CubeL4 V1.14.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:d83f1c8ca282 | 1 | /** |
bcostm | 0:d83f1c8ca282 | 2 | ****************************************************************************** |
bcostm | 0:d83f1c8ca282 | 3 | * @file cs42l51.h |
bcostm | 0:d83f1c8ca282 | 4 | * @author MCD Application Team |
bcostm | 0:d83f1c8ca282 | 5 | * @brief This file contains all the functions prototypes for the cs42l51.c driver. |
bcostm | 0:d83f1c8ca282 | 6 | ****************************************************************************** |
bcostm | 0:d83f1c8ca282 | 7 | * @attention |
bcostm | 0:d83f1c8ca282 | 8 | * |
Jerome Coutant
2:106c7b82e064
|
9
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
|
Jerome Coutant
2:106c7b82e064
|
10
|
* All rights reserved.</center></h2>
|
|
bcostm | 0:d83f1c8ca282 | 11 | * |
Jerome Coutant
2:106c7b82e064
|
12
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
Jerome Coutant
2:106c7b82e064
|
13
|
* the "License"; You may not use this file except in compliance with the
|
|
Jerome Coutant
2:106c7b82e064
|
14
|
* License. You may obtain a copy of the License at:
|
|
Jerome Coutant
2:106c7b82e064
|
15
|
* opensource.org/licenses/BSD-3-Clause
|
|
bcostm | 0:d83f1c8ca282 | 16 | * |
bcostm | 0:d83f1c8ca282 | 17 | ****************************************************************************** |
bcostm | 0:d83f1c8ca282 | 18 | */ |
bcostm | 0:d83f1c8ca282 | 19 | |
bcostm | 0:d83f1c8ca282 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bcostm | 0:d83f1c8ca282 | 21 | #ifndef __CS42L51_H |
bcostm | 0:d83f1c8ca282 | 22 | #define __CS42L51_H |
bcostm | 0:d83f1c8ca282 | 23 | |
bcostm | 0:d83f1c8ca282 | 24 | /* Includes ------------------------------------------------------------------*/ |
bcostm | 0:d83f1c8ca282 | 25 | #include "../Common/audio.h" |
bcostm | 0:d83f1c8ca282 | 26 | |
bcostm | 0:d83f1c8ca282 | 27 | /** @addtogroup BSP |
bcostm | 0:d83f1c8ca282 | 28 | * @{ |
bcostm | 0:d83f1c8ca282 | 29 | */ |
bcostm | 0:d83f1c8ca282 | 30 | |
bcostm | 0:d83f1c8ca282 | 31 | /** @addtogroup Component |
bcostm | 0:d83f1c8ca282 | 32 | * @{ |
bcostm | 0:d83f1c8ca282 | 33 | */ |
bcostm | 0:d83f1c8ca282 | 34 | |
bcostm | 0:d83f1c8ca282 | 35 | /** @addtogroup CS42L51 |
bcostm | 0:d83f1c8ca282 | 36 | * @{ |
bcostm | 0:d83f1c8ca282 | 37 | */ |
bcostm | 0:d83f1c8ca282 | 38 | |
bcostm | 0:d83f1c8ca282 | 39 | /** @defgroup CS42L51_Exported_Types |
bcostm | 0:d83f1c8ca282 | 40 | * @{ |
bcostm | 0:d83f1c8ca282 | 41 | */ |
bcostm | 0:d83f1c8ca282 | 42 | |
bcostm | 0:d83f1c8ca282 | 43 | /** |
bcostm | 0:d83f1c8ca282 | 44 | * @} |
bcostm | 0:d83f1c8ca282 | 45 | */ |
bcostm | 0:d83f1c8ca282 | 46 | |
bcostm | 0:d83f1c8ca282 | 47 | /** @defgroup CS42L51_Exported_Constants |
bcostm | 0:d83f1c8ca282 | 48 | * @{ |
bcostm | 0:d83f1c8ca282 | 49 | */ |
bcostm | 0:d83f1c8ca282 | 50 | |
bcostm | 0:d83f1c8ca282 | 51 | /******************************************************************************/ |
bcostm | 0:d83f1c8ca282 | 52 | /*************************** Codec User defines ******************************/ |
bcostm | 0:d83f1c8ca282 | 53 | /******************************************************************************/ |
bcostm | 0:d83f1c8ca282 | 54 | /* Codec output devices */ |
bcostm | 0:d83f1c8ca282 | 55 | #define OUTPUT_DEVICE_HEADPHONE 0x01 |
bcostm | 0:d83f1c8ca282 | 56 | |
bcostm | 0:d83f1c8ca282 | 57 | /* Codec input devices */ |
bcostm | 0:d83f1c8ca282 | 58 | #define INPUT_DEVICE_MIC1 0x10 |
bcostm | 0:d83f1c8ca282 | 59 | |
bcostm | 0:d83f1c8ca282 | 60 | /* Volume Levels values */ |
bcostm | 0:d83f1c8ca282 | 61 | #define DEFAULT_VOLMIN 0x00 |
bcostm | 0:d83f1c8ca282 | 62 | #define DEFAULT_VOLMAX 0xFF |
bcostm | 0:d83f1c8ca282 | 63 | #define DEFAULT_VOLSTEP 0x04 |
bcostm | 0:d83f1c8ca282 | 64 | |
bcostm | 0:d83f1c8ca282 | 65 | #define AUDIO_PAUSE 0 |
bcostm | 0:d83f1c8ca282 | 66 | #define AUDIO_RESUME 1 |
bcostm | 0:d83f1c8ca282 | 67 | |
bcostm | 0:d83f1c8ca282 | 68 | /* Codec POWER DOWN modes */ |
bcostm | 0:d83f1c8ca282 | 69 | #define CODEC_PDWN_HW 1 |
bcostm | 0:d83f1c8ca282 | 70 | #define CODEC_PDWN_SW 2 |
bcostm | 0:d83f1c8ca282 | 71 | |
bcostm | 0:d83f1c8ca282 | 72 | /* MUTE commands */ |
bcostm | 0:d83f1c8ca282 | 73 | #define AUDIO_MUTE_ON 1 |
bcostm | 0:d83f1c8ca282 | 74 | #define AUDIO_MUTE_OFF 0 |
bcostm | 0:d83f1c8ca282 | 75 | |
bcostm | 0:d83f1c8ca282 | 76 | /* AUDIO FREQUENCY */ |
bcostm | 0:d83f1c8ca282 | 77 | #define AUDIO_FREQUENCY_192K ((uint32_t)192000) |
bcostm | 0:d83f1c8ca282 | 78 | #define AUDIO_FREQUENCY_96K ((uint32_t)96000) |
bcostm | 0:d83f1c8ca282 | 79 | #define AUDIO_FREQUENCY_48K ((uint32_t)48000) |
bcostm | 0:d83f1c8ca282 | 80 | #define AUDIO_FREQUENCY_44K ((uint32_t)44100) |
bcostm | 0:d83f1c8ca282 | 81 | #define AUDIO_FREQUENCY_32K ((uint32_t)32000) |
bcostm | 0:d83f1c8ca282 | 82 | #define AUDIO_FREQUENCY_22K ((uint32_t)22050) |
bcostm | 0:d83f1c8ca282 | 83 | #define AUDIO_FREQUENCY_16K ((uint32_t)16000) |
bcostm | 0:d83f1c8ca282 | 84 | #define AUDIO_FREQUENCY_11K ((uint32_t)11025) |
bcostm | 0:d83f1c8ca282 | 85 | #define AUDIO_FREQUENCY_8K ((uint32_t)8000) |
bcostm | 0:d83f1c8ca282 | 86 | |
bcostm | 0:d83f1c8ca282 | 87 | /******************************************************************************/ |
bcostm | 0:d83f1c8ca282 | 88 | /****************************** REGISTER MAPPING ******************************/ |
bcostm | 0:d83f1c8ca282 | 89 | /******************************************************************************/ |
bcostm | 0:d83f1c8ca282 | 90 | /** |
bcostm | 0:d83f1c8ca282 | 91 | * @brief CS42L51 ID |
bcostm | 0:d83f1c8ca282 | 92 | */ |
bcostm | 0:d83f1c8ca282 | 93 | #define CS42L51_ID 0xD8 |
bcostm | 0:d83f1c8ca282 | 94 | #define CS42L51_ID_MASK 0xF8 |
bcostm | 0:d83f1c8ca282 | 95 | /** |
bcostm | 0:d83f1c8ca282 | 96 | * @brief Chip ID Register: Chip I.D. and Revision Register |
bcostm | 0:d83f1c8ca282 | 97 | * Read only register |
bcostm | 0:d83f1c8ca282 | 98 | * Default value: 0x01 |
bcostm | 0:d83f1c8ca282 | 99 | * [7:3] CHIPID[4:0]: I.D. code for the CS42L51. |
bcostm | 0:d83f1c8ca282 | 100 | * Default value: 11100b |
bcostm | 0:d83f1c8ca282 | 101 | * [2:0] REVID[2:0]: CS42L51 revision level. |
bcostm | 0:d83f1c8ca282 | 102 | * Default value: |
bcostm | 0:d83f1c8ca282 | 103 | * 000 - Rev A0 |
bcostm | 0:d83f1c8ca282 | 104 | * 001 - Rev A1 |
bcostm | 0:d83f1c8ca282 | 105 | * 010 - Rev B0 |
bcostm | 0:d83f1c8ca282 | 106 | * 011 - Rev B1 |
bcostm | 0:d83f1c8ca282 | 107 | */ |
bcostm | 0:d83f1c8ca282 | 108 | #define CS42L51_CHIPID_ADDR 0x01 |
bcostm | 0:d83f1c8ca282 | 109 | |
bcostm | 0:d83f1c8ca282 | 110 | /** |
bcostm | 0:d83f1c8ca282 | 111 | * @} |
bcostm | 0:d83f1c8ca282 | 112 | */ |
bcostm | 0:d83f1c8ca282 | 113 | |
bcostm | 0:d83f1c8ca282 | 114 | /** @defgroup CS42L51_Exported_Macros |
bcostm | 0:d83f1c8ca282 | 115 | * @{ |
bcostm | 0:d83f1c8ca282 | 116 | */ |
bcostm | 0:d83f1c8ca282 | 117 | #define VOLUME_CONVERT(Volume) ((Volume >= 100) ? 0 : ((uint8_t)(((Volume * 2) + 56)))) |
bcostm | 0:d83f1c8ca282 | 118 | /** |
bcostm | 0:d83f1c8ca282 | 119 | * @} |
bcostm | 0:d83f1c8ca282 | 120 | */ |
bcostm | 0:d83f1c8ca282 | 121 | |
bcostm | 0:d83f1c8ca282 | 122 | /** @defgroup CS42L51_Exported_Functions |
bcostm | 0:d83f1c8ca282 | 123 | * @{ |
bcostm | 0:d83f1c8ca282 | 124 | */ |
bcostm | 0:d83f1c8ca282 | 125 | |
bcostm | 0:d83f1c8ca282 | 126 | /*------------------------------------------------------------------------------ |
bcostm | 0:d83f1c8ca282 | 127 | Audio Codec functions |
bcostm | 0:d83f1c8ca282 | 128 | ------------------------------------------------------------------------------*/ |
bcostm | 0:d83f1c8ca282 | 129 | /* High Layer codec functions */ |
bcostm | 0:d83f1c8ca282 | 130 | uint32_t cs42l51_Init(uint16_t DeviceAddr, uint16_t Device, uint8_t Volume, uint32_t AudioFreq); |
bcostm | 0:d83f1c8ca282 | 131 | void cs42l51_DeInit(void); |
bcostm | 0:d83f1c8ca282 | 132 | uint32_t cs42l51_ReadID(uint16_t DeviceAddr); |
bcostm | 0:d83f1c8ca282 | 133 | uint32_t cs42l51_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); |
bcostm | 0:d83f1c8ca282 | 134 | uint32_t cs42l51_Pause(uint16_t DeviceAddr); |
bcostm | 0:d83f1c8ca282 | 135 | uint32_t cs42l51_Resume(uint16_t DeviceAddr); |
bcostm | 0:d83f1c8ca282 | 136 | uint32_t cs42l51_Stop(uint16_t DeviceAddr, uint32_t Cmd); |
bcostm | 0:d83f1c8ca282 | 137 | uint32_t cs42l51_SetVolume(uint16_t DeviceAddr, uint8_t Volume); |
bcostm | 0:d83f1c8ca282 | 138 | uint32_t cs42l51_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); |
bcostm | 0:d83f1c8ca282 | 139 | uint32_t cs42l51_SetMute(uint16_t DeviceAddr, uint32_t Cmd); |
bcostm | 0:d83f1c8ca282 | 140 | uint32_t cs42l51_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); |
bcostm | 0:d83f1c8ca282 | 141 | uint32_t cs42l51_Reset(uint16_t DeviceAddr); |
bcostm | 0:d83f1c8ca282 | 142 | |
bcostm | 0:d83f1c8ca282 | 143 | /* AUDIO IO functions */ |
bcostm | 0:d83f1c8ca282 | 144 | void AUDIO_IO_Init(void); |
bcostm | 0:d83f1c8ca282 | 145 | void AUDIO_IO_DeInit(void); |
bcostm | 0:d83f1c8ca282 | 146 | void AUDIO_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value); |
bcostm | 0:d83f1c8ca282 | 147 | uint8_t AUDIO_IO_Read(uint8_t Addr, uint8_t Reg); |
bcostm | 0:d83f1c8ca282 | 148 | void AUDIO_IO_Delay(uint32_t Delay); |
bcostm | 0:d83f1c8ca282 | 149 | |
bcostm | 0:d83f1c8ca282 | 150 | /* Audio driver structure */ |
bcostm | 0:d83f1c8ca282 | 151 | extern AUDIO_DrvTypeDef cs42l51_drv; |
bcostm | 0:d83f1c8ca282 | 152 | |
bcostm | 0:d83f1c8ca282 | 153 | /** |
bcostm | 0:d83f1c8ca282 | 154 | * @} |
bcostm | 0:d83f1c8ca282 | 155 | */ |
bcostm | 0:d83f1c8ca282 | 156 | |
bcostm | 0:d83f1c8ca282 | 157 | /** |
bcostm | 0:d83f1c8ca282 | 158 | * @} |
bcostm | 0:d83f1c8ca282 | 159 | */ |
bcostm | 0:d83f1c8ca282 | 160 | |
bcostm | 0:d83f1c8ca282 | 161 | /** |
bcostm | 0:d83f1c8ca282 | 162 | * @} |
bcostm | 0:d83f1c8ca282 | 163 | */ |
bcostm | 0:d83f1c8ca282 | 164 | |
bcostm | 0:d83f1c8ca282 | 165 | /** |
bcostm | 0:d83f1c8ca282 | 166 | * @} |
bcostm | 0:d83f1c8ca282 | 167 | */ |
bcostm | 0:d83f1c8ca282 | 168 | |
bcostm | 0:d83f1c8ca282 | 169 | #endif /* __CS42L51_H */ |
bcostm | 0:d83f1c8ca282 | 170 | |
bcostm | 0:d83f1c8ca282 | 171 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |