Archive STM32 firmware to legacy/stm32/: - src/, include/, lib/USB_CDC/, platformio.ini, test stubs, flash_firmware.py - test/test_battery_adc.c, test_hw_button.c, test_pid_schedule.c, test_vesc_can.c, test_can_watchdog.c - USB_CDC_BUG.md Rename: stm32_protocol → esp32_protocol, mamba_protocol → balance_protocol, stm32_cmd_node → esp32_cmd_node, stm32_cmd_params → esp32_cmd_params, stm32_cmd.launch.py → esp32_cmd.launch.py, test_stm32_protocol → test_esp32_protocol, test_stm32_cmd_node → test_esp32_cmd_node Content cleanup across all files: - Mamba F722S → ESP32-S3 BALANCE - BlackPill → ESP32-S3 IO - STM32F722/F7xx → ESP32-S3 - stm32Mode/Version/Port → esp32Mode/Version/Port - STM32 State/Mode labels → ESP32 State/Mode - Jetson Nano → Jetson Orin Nano Super - /dev/stm32 → /dev/esp32 - stm32_bridge → esp32_bridge - STM32 HAL → ESP-IDF docs/SALTYLAB.md: - Update "Drone FC Details" to describe ESP32-S3 BALANCE board (Waveshare ESP32-S3 Touch LCD 1.28) - Replace verbose "Self-Balancing Control" STM32 section with brief note pointing to SAUL-TEE-SYSTEM-REFERENCE.md TEAM.md: Update Embedded Firmware Engineer role to ESP32-S3 / ESP-IDF No new functionality — cleanup only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
185 lines
5.3 KiB
C
185 lines
5.3 KiB
C
/**
|
|
******************************************************************************
|
|
* @file usbd_cdc.h
|
|
* @author MCD Application Team
|
|
* @brief header file for the usbd_cdc.c file.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2015 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.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef __USB_CDC_H
|
|
#define __USB_CDC_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "usbd_ioreq.h"
|
|
|
|
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
|
* @{
|
|
*/
|
|
|
|
/** @defgroup usbd_cdc
|
|
* @brief This file is the Header file for usbd_cdc.c
|
|
* @{
|
|
*/
|
|
|
|
|
|
/** @defgroup usbd_cdc_Exported_Defines
|
|
* @{
|
|
*/
|
|
#ifndef CDC_IN_EP
|
|
#define CDC_IN_EP 0x81U /* EP1 for data IN */
|
|
#endif /* CDC_IN_EP */
|
|
#ifndef CDC_OUT_EP
|
|
#define CDC_OUT_EP 0x01U /* EP1 for data OUT */
|
|
#endif /* CDC_OUT_EP */
|
|
#ifndef CDC_CMD_EP
|
|
#define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
|
|
#endif /* CDC_CMD_EP */
|
|
|
|
#ifndef CDC_HS_BINTERVAL
|
|
#define CDC_HS_BINTERVAL 0x10U
|
|
#endif /* CDC_HS_BINTERVAL */
|
|
|
|
#ifndef CDC_FS_BINTERVAL
|
|
#define CDC_FS_BINTERVAL 0x10U
|
|
#endif /* CDC_FS_BINTERVAL */
|
|
|
|
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
|
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
|
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
|
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
|
|
|
|
#define USB_CDC_CONFIG_DESC_SIZ 67U
|
|
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
|
#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
|
|
|
|
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
|
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
|
|
|
|
#define CDC_REQ_MAX_DATA_SIZE 0x7U
|
|
/*---------------------------------------------------------------------*/
|
|
/* CDC definitions */
|
|
/*---------------------------------------------------------------------*/
|
|
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
|
|
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
|
|
#define CDC_SET_COMM_FEATURE 0x02U
|
|
#define CDC_GET_COMM_FEATURE 0x03U
|
|
#define CDC_CLEAR_COMM_FEATURE 0x04U
|
|
#define CDC_SET_LINE_CODING 0x20U
|
|
#define CDC_GET_LINE_CODING 0x21U
|
|
#define CDC_SET_CONTROL_LINE_STATE 0x22U
|
|
#define CDC_SEND_BREAK 0x23U
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
|
|
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
typedef struct
|
|
{
|
|
uint32_t bitrate;
|
|
uint8_t format;
|
|
uint8_t paritytype;
|
|
uint8_t datatype;
|
|
} USBD_CDC_LineCodingTypeDef;
|
|
|
|
typedef struct _USBD_CDC_Itf
|
|
{
|
|
int8_t (* Init)(void);
|
|
int8_t (* DeInit)(void);
|
|
int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length);
|
|
int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
|
|
int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum);
|
|
} USBD_CDC_ItfTypeDef;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */
|
|
uint8_t CmdOpCode;
|
|
uint8_t CmdLength;
|
|
uint8_t *RxBuffer;
|
|
uint8_t *TxBuffer;
|
|
uint32_t RxLength;
|
|
uint32_t TxLength;
|
|
|
|
__IO uint32_t TxState;
|
|
__IO uint32_t RxState;
|
|
} USBD_CDC_HandleTypeDef;
|
|
|
|
|
|
|
|
/** @defgroup USBD_CORE_Exported_Macros
|
|
* @{
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup USBD_CORE_Exported_Variables
|
|
* @{
|
|
*/
|
|
|
|
extern USBD_ClassTypeDef USBD_CDC;
|
|
#define USBD_CDC_CLASS &USBD_CDC
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/** @defgroup USB_CORE_Exported_Functions
|
|
* @{
|
|
*/
|
|
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
|
|
USBD_CDC_ItfTypeDef *fops);
|
|
|
|
#ifdef USE_USBD_COMPOSITE
|
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
|
uint32_t length, uint8_t ClassId);
|
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
|
|
#else
|
|
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
|
uint32_t length);
|
|
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev);
|
|
#endif /* USE_USBD_COMPOSITE */
|
|
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
|
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev);
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __USB_CDC_H */
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|