stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.h
Go to the documentation of this file.
1 
37 /* Define to prevent recursive inclusion -------------------------------------*/
38 #ifndef __WM8994_H
39 #define __WM8994_H
40 
41 /* Includes ------------------------------------------------------------------*/
42 #include "../Common/audio.h"
43 
68 /******************************************************************************/
69 /*************************** Codec User defines ******************************/
70 /******************************************************************************/
71 /* Codec output DEVICE */
72 #define OUTPUT_DEVICE_SPEAKER ((uint16_t)0x0001)
73 #define OUTPUT_DEVICE_HEADPHONE ((uint16_t)0x0002)
74 #define OUTPUT_DEVICE_BOTH ((uint16_t)0x0003)
75 #define OUTPUT_DEVICE_AUTO ((uint16_t)0x0004)
76 #define INPUT_DEVICE_DIGITAL_MICROPHONE_1 ((uint16_t)0x0100)
77 #define INPUT_DEVICE_DIGITAL_MICROPHONE_2 ((uint16_t)0x0200)
78 #define INPUT_DEVICE_INPUT_LINE_1 ((uint16_t)0x0300)
79 #define INPUT_DEVICE_INPUT_LINE_2 ((uint16_t)0x0400)
80 #define INPUT_DEVICE_DIGITAL_MIC1_MIC2 ((uint16_t)0x0800)
81 
82 /* Volume Levels values */
83 #define DEFAULT_VOLMIN 0x00
84 #define DEFAULT_VOLMAX 0xFF
85 #define DEFAULT_VOLSTEP 0x04
86 
87 #define AUDIO_PAUSE 0
88 #define AUDIO_RESUME 1
89 
90 /* Codec POWER DOWN modes */
91 #define CODEC_PDWN_HW 1
92 #define CODEC_PDWN_SW 2
93 
94 /* MUTE commands */
95 #define AUDIO_MUTE_ON 1
96 #define AUDIO_MUTE_OFF 0
97 
98 /* AUDIO FREQUENCY */
99 #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
100 #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
101 #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
102 #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
103 #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
104 #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
105 #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
106 #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
107 #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
108 
109 #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100)))
110 #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100)))
111 
112 /******************************************************************************/
113 /****************************** REGISTER MAPPING ******************************/
114 /******************************************************************************/
118 #define WM8994_ID 0x8994
119 
124 #define WM8994_CHIPID_ADDR 0x00
125 
141 /*------------------------------------------------------------------------------
142  Audio Codec functions
143 ------------------------------------------------------------------------------*/
144 /* High Layer codec functions */
145 uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq);
146 void wm8994_DeInit(void);
147 uint32_t wm8994_ReadID(uint16_t DeviceAddr);
148 uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
149 uint32_t wm8994_Pause(uint16_t DeviceAddr);
150 uint32_t wm8994_Resume(uint16_t DeviceAddr);
151 uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd);
152 uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
153 uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
154 uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
155 uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
156 uint32_t wm8994_Reset(uint16_t DeviceAddr);
157 
158 /* AUDIO IO functions */
159 void AUDIO_IO_Init(void);
160 void AUDIO_IO_DeInit(void);
161 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
162 uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
163 void AUDIO_IO_Delay(uint32_t Delay);
164 
165 /* Audio driver structure */
167 
168 #endif /* __WM8994_H */
169 
186 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
wm8994_Init
uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq)
Initializes the audio codec and the control interface.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:137
wm8994_drv
AUDIO_DrvTypeDef wm8994_drv
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:86
wm8994_SetOutputMode
uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
Switch dynamically (while audio file is played) the output target (speaker or headphone).
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:879
wm8994_Pause
uint32_t wm8994_Pause(uint16_t DeviceAddr)
Pauses playing on the audio codec.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:679
AUDIO_IO_Read
uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg)
Reads a single data.
Definition: stm32f769i_discovery.c:597
wm8994_Resume
uint32_t wm8994_Resume(uint16_t DeviceAddr)
Resumes playing on the audio codec.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:698
AUDIO_IO_Write
void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value)
Writes a single data.
Definition: stm32f769i_discovery.c:580
wm8994_Play
uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t *pBuffer, uint16_t Size)
Start the audio Codec play feature.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:663
wm8994_Stop
uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd)
Stops audio Codec playing. It powers down the codec.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:722
wm8994_Reset
uint32_t wm8994_Reset(uint16_t DeviceAddr)
Resets wm8994 registers.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:1026
wm8994_SetVolume
uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
Sets higher or lower the codec volume level.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:768
wm8994_DeInit
void wm8994_DeInit(void)
Deinitializes the audio codec.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:638
AUDIO_IO_Init
void AUDIO_IO_Init(void)
Initializes Audio low level.
Definition: stm32f4_discovery.c:626
AUDIO_IO_DeInit
void AUDIO_IO_DeInit(void)
DeInitializes Audio low level.
Definition: stm32f4_discovery.c:658
AUDIO_DrvTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/BSP/Components/Common/audio.h:81
wm8994_SetMute
uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
Enables or disables the mute feature on the audio codec.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:844
wm8994_ReadID
uint32_t wm8994_ReadID(uint16_t DeviceAddr)
Get the WM8994 ID.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:649
AUDIO_IO_Delay
void AUDIO_IO_Delay(uint32_t Delay)
AUDIO Codec delay.
Definition: stm32469i_discovery.c:783
wm8994_SetFrequency
uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
Sets new frequency.
Definition: stm32f769/stm32f769i-disco/Drivers/BSP/Components/wm8994/wm8994.c:966


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:55