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
60
61
66
71
72
79
93
94
99
104
105
110
115
116
121
125
126
131
135
136
141
145
146
151
/* ... */
#include "usbd_audio_if.h"
#include "stm324xg_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);
return 0;
}{ ... }
/* ... */
static int8_t Audio_DeInit(uint32_t options)
{
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
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);
}{ ... }