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
75
76
83
97
98
103
108
109
114
119
120
125
129
130
135
139
140
145
149
150
155
/* ... */
#include "usbd_audio_if.h"
#include "stm32469i_discovery_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_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, 2*size);
break;
case AUDIO_CMD_START:
case AUDIO_CMD_PLAY:
BSP_AUDIO_OUT_ChangeBuffer((uint16_t *)pbuf, 2*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);
}{ ... }