1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
22
23
24
25
34
46
47
48
55
64
65
70
77
78
85
99
100
105
110
111
116
121
122
127
131
132
137
141
142
147
151
152
157
/* ... */
#include "usbd_audio_if.h"
#include "stm324x9i_eval_audio.h"
Includes
static int8_t Audio_Init(uint32_t AudioFreq, uint32_t Volume, uint32_t options);
static int8_t Audio_DeInit(uint32_t options);
static int8_t Audio_PlaybackCmd(uint8_t * pbuf, uint32_t size, uint8_t cmd);
static int8_t Audio_VolumeCtl(uint8_t vol);
static int8_t Audio_MuteCtl(uint8_t cmd);
static int8_t Audio_PeriodicTC(uint8_t *pbuf, uint32_t size, uint8_t cmd);
static int8_t Audio_GetState(void);
Private function prototypes
extern USBD_HandleTypeDef USBD_Device;
USBD_AUDIO_ItfTypeDef USBD_AUDIO_fops = {
Audio_Init,
Audio_DeInit,
Audio_PlaybackCmd,
Audio_VolumeCtl,
Audio_MuteCtl,
Audio_PeriodicTC,
Audio_GetState,
...};
Private variables
/* ... */
static int8_t Audio_Init(uint32_t AudioFreq, uint32_t Volume, uint32_t options)
{
BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_AUTO, Volume, AudioFreq);
/* ... */
BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
return 0;
}{ ... }
/* ... */
static int8_t Audio_DeInit(uint32_t options)
{
BSP_AUDIO_OUT_SetMute(AUDIO_MUTE_ON);
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
BSP_AUDIO_OUT_SetMute(AUDIO_MUTE_OFF);
return 0;
}{ ... }
/* ... */
static int8_t Audio_PlaybackCmd(uint8_t * pbuf, uint32_t size, uint8_t cmd)
{
switch (cmd)
{
case AUDIO_CMD_START:
BSP_AUDIO_OUT_Play((uint16_t *) pbuf, size);
break;
case AUDIO_CMD_START:
case AUDIO_CMD_PLAY:
BSP_AUDIO_OUT_ChangeBuffer((uint16_t *) pbuf, size);
break;case AUDIO_CMD_PLAY:
}switch (cmd) { ... }
return 0;
}{ ... }
/* ... */
static int8_t Audio_VolumeCtl(uint8_t vol)
{
BSP_AUDIO_OUT_SetVolume(vol);
return 0;
}{ ... }
/* ... */
static int8_t Audio_MuteCtl(uint8_t cmd)
{
BSP_AUDIO_OUT_SetMute(cmd);
return 0;
}{ ... }
/* ... */
static int8_t Audio_PeriodicTC(uint8_t *pbuf, uint32_t size, uint8_t cmd)
{
return 0;
}{ ... }
/* ... */
static int8_t Audio_GetState(void)
{
return 0;
}{ ... }
/* ... */
void BSP_AUDIO_OUT_TransferComplete_CallBack(void)
{
USBD_AUDIO_Sync(&USBD_Device, AUDIO_OFFSET_FULL);
}{ ... }
/* ... */
void BSP_AUDIO_OUT_HalfTransfer_CallBack(void)
{
USBD_AUDIO_Sync(&USBD_Device, AUDIO_OFFSET_HALF);
}{ ... }