Select one of the symbols to view example projects that use it.
 
Outline
Includes
#include "usbd_audio_if.h"
#include "stm324xg_eval_audio.h"
Private function prototypes
Private variables
USBD_AUDIO_fops
Audio_Init(uint32_t, uint32_t, uint32_t)
Audio_DeInit(uint32_t)
Audio_PlaybackCmd(uint8_t *, uint32_t, uint8_t)
Audio_VolumeCtl(uint8_t)
Audio_MuteCtl(uint8_t)
Audio_PeriodicTC(uint8_t *, uint32_t, uint8_t)
Audio_GetState()
BSP_AUDIO_OUT_TransferComplete_CallBack()
BSP_AUDIO_OUT_HalfTransfer_CallBack()
Files
loading...
SourceVuSTM32 Libraries and SamplesAUDIO_StandaloneSrc/usbd_audio_if.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** ****************************************************************************** * @file USB_Device/AUDIO_Standalone/Src/usbd_audio_if.c * @author MCD Application Team * @brief USB Device Audio interface file. ****************************************************************************** * @attention * * Copyright (c) 2017 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* ... */ /* Includes ------------------------------------------------------------------*/ #include "usbd_audio_if.h" #include "stm324xg_eval_audio.h" Includes /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ 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 /* Private variables ---------------------------------------------------------*/ 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 /* Private functions ---------------------------------------------------------*/ /** * @brief Initializes the AUDIO media low layer. * @param AudioFreq: Audio frequency used to play the audio stream. * @param Volume: Initial volume level (from 0 (Mute) to 100 (Max)) * @param options: Reserved for future use * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ 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; }{ ... } /** * @brief De-Initializes the AUDIO media low layer. * @param options: Reserved for future use * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ static int8_t Audio_DeInit(uint32_t options) { BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW); return 0; }{ ... } /** * @brief Handles AUDIO command. * @param pbuf: Pointer to buffer of data to be sent * @param size: Number of data to be sent (in bytes) * @param cmd: Command opcode * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ 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; }{ ... } /** * @brief Controls AUDIO Volume. * @param vol: Volume level (0..100) * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ static int8_t Audio_VolumeCtl(uint8_t vol) { BSP_AUDIO_OUT_SetVolume(vol); return 0; }{ ... } /** * @brief Controls AUDIO Mute. * @param cmd: Command opcode * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ static int8_t Audio_MuteCtl(uint8_t cmd) { BSP_AUDIO_OUT_SetMute(cmd); return 0; }{ ... } /** * @brief Audio_PeriodicTC * @param cmd: Command opcode * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ static int8_t Audio_PeriodicTC(uint8_t *pbuf, uint32_t size, uint8_t cmd) { return 0; }{ ... } /** * @brief Gets AUDIO State. * @param None * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL *//* ... */ static int8_t Audio_GetState(void) { return 0; }{ ... } /** * @brief Manages the DMA full Transfer complete event. * @param None * @retval None *//* ... */ void BSP_AUDIO_OUT_TransferComplete_CallBack(void) { USBD_AUDIO_Sync(&USBD_Device, AUDIO_OFFSET_FULL); }{ ... } /** * @brief Manages the DMA Half Transfer complete event. * @param None * @retval None *//* ... */ void BSP_AUDIO_OUT_HalfTransfer_CallBack(void) { USBD_AUDIO_Sync(&USBD_Device, AUDIO_OFFSET_HALF); }{ ... }
Details