STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
usb_device.c
Go to the documentation of this file.
1
/* USER CODE BEGIN Header */
2
/**
3
******************************************************************************
4
* @file : usb_device.c
5
* @version : v1.0_Cube
6
* @brief : This file implements the USB Device
7
******************************************************************************
8
* @attention
9
*
10
* Copyright (c) 2026 STMicroelectronics.
11
* All rights reserved.
12
*
13
* This software is licensed under terms that can be found in the LICENSE file
14
* in the root directory of this software component.
15
* If no LICENSE file comes with this software, it is provided AS-IS.
16
*
17
******************************************************************************
18
*/
19
/* USER CODE END Header */
20
21
/* Includes ------------------------------------------------------------------*/
22
23
#include "
usb_device.h
"
24
#include "
usbd_core.h
"
25
#include "
usbd_desc.h
"
26
#include "
usbd_cdc.h
"
27
#include "
usbd_cdc_if.h
"
28
29
/* USER CODE BEGIN Includes */
30
31
/* USER CODE END Includes */
32
33
/* USER CODE BEGIN PV */
34
/* Private variables ---------------------------------------------------------*/
35
36
/* USER CODE END PV */
37
38
/* USER CODE BEGIN PFP */
39
/* Private function prototypes -----------------------------------------------*/
40
41
/* USER CODE END PFP */
42
43
/* USB Device Core handle declaration. */
44
USBD_HandleTypeDef
hUsbDeviceHS
;
45
46
/*
47
* -- Insert your variables declaration here --
48
*/
49
/* USER CODE BEGIN 0 */
50
51
/* USER CODE END 0 */
52
53
/*
54
* -- Insert your external function declaration here --
55
*/
56
/* USER CODE BEGIN 1 */
57
58
/* USER CODE END 1 */
59
60
/**
61
* Init USB device Library, add supported class and start the library
62
* @retval None
63
*/
64
void
MX_USB_DEVICE_Init
(
void
)
65
{
66
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
67
68
/* USER CODE END USB_DEVICE_Init_PreTreatment */
69
70
/* Init Device Library, add supported class and start the library. */
71
if
(
USBD_Init
(&
hUsbDeviceHS
, &
HS_Desc
,
DEVICE_HS
) !=
USBD_OK
)
72
{
73
Error_Handler
();
74
}
75
if
(
USBD_RegisterClass
(&
hUsbDeviceHS
, &
USBD_CDC
) !=
USBD_OK
)
76
{
77
Error_Handler
();
78
}
79
if
(
USBD_CDC_RegisterInterface
(&
hUsbDeviceHS
, &
USBD_Interface_fops_HS
) !=
USBD_OK
)
80
{
81
Error_Handler
();
82
}
83
if
(
USBD_Start
(&
hUsbDeviceHS
) !=
USBD_OK
)
84
{
85
Error_Handler
();
86
}
87
88
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
89
HAL_PWREx_EnableUSBVoltageDetector
();
90
91
/* USER CODE END USB_DEVICE_Init_PostTreatment */
92
}
93
94
/**
95
* @}
96
*/
97
98
/**
99
* @}
100
*/
101
Error_Handler
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition
main.c:1145
HAL_PWREx_EnableUSBVoltageDetector
void HAL_PWREx_EnableUSBVoltageDetector(void)
hUsbDeviceHS
USBD_HandleTypeDef hUsbDeviceHS
Definition
usb_device.c:44
USBD_Interface_fops_HS
USBD_CDC_ItfTypeDef USBD_Interface_fops_HS
CDC Interface callback.
Definition
usbd_cdc_if.c:145
DEVICE_HS
#define DEVICE_HS
Definition
usbd_conf.h:81
USBD_RegisterClass
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass)
USBD_RegisterClass Link class driver to Device Core.
Definition
usbd_core.c:202
USBD_Start
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev)
USBD_Start Start the USB Device Core.
Definition
usbd_core.c:384
USBD_Init
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id)
USBD_Init Initialize the device stack and load the class driver.
Definition
usbd_core.c:92
USBD_CDC
USBD_ClassTypeDef USBD_CDC
Definition
usbd_cdc.c:141
USBD_HandleTypeDef
struct _USBD_HandleTypeDef USBD_HandleTypeDef
USBD_OK
@ USBD_OK
Definition
usbd_def.h:281
HS_Desc
USBD_DescriptorsTypeDef HS_Desc
Descriptor for the Usb device.
Definition
usbd_desc.c:134
MX_USB_DEVICE_Init
void MX_USB_DEVICE_Init(void)
Init USB device Library, add supported class and start the library.
Definition
usb_device.c:64
USBD_CDC_RegisterInterface
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops)
USBD_CDC_RegisterInterface.
Definition
usbd_cdc.c:738
usb_device.h
: Header for usb_device.c file.
usbd_cdc.h
header file for the usbd_cdc.c file.
usbd_cdc_if.h
: Header for usbd_cdc_if.c file.
usbd_core.h
Header file for usbd_core.c file.
usbd_desc.h
firmware
Flight_Computer
USB_DEVICE
App
usb_device.c
Generated by
1.15.0