| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- /* USER CODE BEGIN Header */
- /**
- ******************************************************************************
- * @file : usbd_audio_if.c
- * @version : v1.0_Cube
- * @brief : Generic media access layer.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2024 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.
- *
- ******************************************************************************
- */
- /* USER CODE END Header */
- /* Includes ------------------------------------------------------------------*/
- #include "usbd_audio_if.h"
- /* USER CODE BEGIN INCLUDE */
- /* USER CODE END INCLUDE */
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* USER CODE BEGIN PV */
- /* Private variables ---------------------------------------------------------*/
- /* USER CODE END PV */
- /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
- * @brief Usb device library.
- * @{
- */
- /** @addtogroup USBD_AUDIO_IF
- * @{
- */
- /** @defgroup USBD_AUDIO_IF_Private_TypesDefinitions USBD_AUDIO_IF_Private_TypesDefinitions
- * @brief Private types.
- * @{
- */
- /* USER CODE BEGIN PRIVATE_TYPES */
- /* USER CODE END PRIVATE_TYPES */
- /**
- * @}
- */
- /** @defgroup USBD_AUDIO_IF_Private_Defines USBD_AUDIO_IF_Private_Defines
- * @brief Private defines.
- * @{
- */
- /* USER CODE BEGIN PRIVATE_DEFINES */
- /* USER CODE END PRIVATE_DEFINES */
- /**
- * @}
- */
- /** @defgroup USBD_AUDIO_IF_Private_Macros USBD_AUDIO_IF_Private_Macros
- * @brief Private macros.
- * @{
- */
- /* USER CODE BEGIN PRIVATE_MACRO */
- /* USER CODE END PRIVATE_MACRO */
- /**
- * @}
- */
- /** @defgroup USBD_AUDIO_IF_Private_Variables USBD_AUDIO_IF_Private_Variables
- * @brief Private variables.
- * @{
- */
- /* USER CODE BEGIN PRIVATE_VARIABLES */
- /* USER CODE END PRIVATE_VARIABLES */
- /**
- * @}
- */
- /** @defgroup USBD_AUDIO_IF_Exported_Variables USBD_AUDIO_IF_Exported_Variables
- * @brief Public variables.
- * @{
- */
- extern USBD_HandleTypeDef hUsbDeviceFS;
- /* USER CODE BEGIN EXPORTED_VARIABLES */
- /* USER CODE END EXPORTED_VARIABLES */
- /**
- * @}
- */
- /** @defgroup USBD_AUDIO_IF_Private_FunctionPrototypes USBD_AUDIO_IF_Private_FunctionPrototypes
- * @brief Private functions declaration.
- * @{
- */
- static int8_t AUDIO_Init_FS(uint32_t AudioFreq, uint32_t Volume, uint32_t options);
- static int8_t AUDIO_DeInit_FS(uint32_t options);
- static int8_t AUDIO_AudioCmd_FS(uint8_t* pbuf, uint32_t size, uint8_t cmd);
- static int8_t AUDIO_VolumeCtl_FS(uint8_t vol);
- static int8_t AUDIO_MuteCtl_FS(uint8_t cmd);
- static int8_t AUDIO_PeriodicTC_FS(uint8_t *pbuf, uint32_t size, uint8_t cmd);
- static int8_t AUDIO_GetState_FS(void);
- /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
- /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
- /**
- * @}
- */
- USBD_AUDIO_ItfTypeDef USBD_AUDIO_fops_FS =
- {
- AUDIO_Init_FS,
- AUDIO_DeInit_FS,
- AUDIO_AudioCmd_FS,
- AUDIO_VolumeCtl_FS,
- AUDIO_MuteCtl_FS,
- AUDIO_PeriodicTC_FS,
- AUDIO_GetState_FS,
- };
- /* Private functions ---------------------------------------------------------*/
- /**
- * @brief Initializes the AUDIO media low layer over USB FS IP
- * @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 USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_Init_FS(uint32_t AudioFreq, uint32_t Volume, uint32_t options)
- {
- /* USER CODE BEGIN 0 */
- UNUSED(AudioFreq);
- UNUSED(Volume);
- UNUSED(options);
- return (USBD_OK);
- /* USER CODE END 0 */
- }
- /**
- * @brief De-Initializes the AUDIO media low layer
- * @param options: Reserved for future use
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_DeInit_FS(uint32_t options)
- {
- /* USER CODE BEGIN 1 */
- UNUSED(options);
- return (USBD_OK);
- /* USER CODE END 1 */
- }
- /**
- * @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 USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_AudioCmd_FS(uint8_t* pbuf, uint32_t size, uint8_t cmd)
- {
- /* USER CODE BEGIN 2 */
- switch(cmd)
- {
- case AUDIO_CMD_START:
- break;
- case AUDIO_CMD_PLAY:
- break;
- }
- UNUSED(pbuf);
- UNUSED(size);
- UNUSED(cmd);
- return (USBD_OK);
- /* USER CODE END 2 */
- }
- /**
- * @brief Controls AUDIO Volume.
- * @param vol: volume level (0..100)
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_VolumeCtl_FS(uint8_t vol)
- {
- /* USER CODE BEGIN 3 */
- UNUSED(vol);
- return (USBD_OK);
- /* USER CODE END 3 */
- }
- /**
- * @brief Controls AUDIO Mute.
- * @param cmd: command opcode
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_MuteCtl_FS(uint8_t cmd)
- {
- /* USER CODE BEGIN 4 */
- UNUSED(cmd);
- return (USBD_OK);
- /* USER CODE END 4 */
- }
- /**
- * @brief AUDIO_PeriodicT_FS
- * @param cmd: Command opcode
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_PeriodicTC_FS(uint8_t *pbuf, uint32_t size, uint8_t cmd)
- {
- /* USER CODE BEGIN 5 */
- UNUSED(pbuf);
- UNUSED(size);
- UNUSED(cmd);
- return (USBD_OK);
- /* USER CODE END 5 */
- }
- /**
- * @brief Gets AUDIO State.
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
- static int8_t AUDIO_GetState_FS(void)
- {
- /* USER CODE BEGIN 6 */
- return (USBD_OK);
- /* USER CODE END 6 */
- }
- /**
- * @brief Manages the DMA full transfer complete event.
- * @retval None
- */
- void TransferComplete_CallBack_FS(void)
- {
- /* USER CODE BEGIN 7 */
- USBD_AUDIO_Sync(&hUsbDeviceFS, AUDIO_OFFSET_FULL);
- /* USER CODE END 7 */
- }
- /**
- * @brief Manages the DMA Half transfer complete event.
- * @retval None
- */
- void HalfTransfer_CallBack_FS(void)
- {
- /* USER CODE BEGIN 8 */
- USBD_AUDIO_Sync(&hUsbDeviceFS, AUDIO_OFFSET_HALF);
- /* USER CODE END 8 */
- }
- /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
- /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
- /**
- * @}
- */
- /**
- * @}
- */
|