/* Private defines -----------------------------------------------------------*/
#define DQ_IN_Pin GPIO_PIN_3
#define DQ_IN_GPIO_Port GPIOE
+#define DQ_IN_EXTI_IRQn EXTI3_IRQn
#define PA4_BEIDOU_RST_EN_Pin GPIO_PIN_4
#define PA4_BEIDOU_RST_EN_GPIO_Port GPIOA
#define PB14_RMII_INT_Pin GPIO_PIN_14
/* #define HAL_SMARTCARD_MODULE_ENABLED */
/* #define HAL_SMBUS_MODULE_ENABLED */
/* #define HAL_WWDG_MODULE_ENABLED */
-#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_PCD_MODULE_ENABLED */
/* #define HAL_HCD_MODULE_ENABLED */
/* #define HAL_DSI_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */
void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
+void EXTI3_IRQHandler(void);
void TIM1_UP_TIM10_IRQHandler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void USART3_IRQHandler(void);
+void UART4_IRQHandler(void);
+void UART5_IRQHandler(void);
void DMA2_Stream0_IRQHandler(void);
void ETH_IRQHandler(void);
-void OTG_FS_IRQHandler(void);
void USART6_IRQHandler(void);
/* USER CODE BEGIN EFP */
#include "main.h"
#include "cmsis_os.h"
#include "lwip.h"
-#include "usb_device.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
I2C_HandleTypeDef hi2c3;
TIM_HandleTypeDef htim2;
+TIM_HandleTypeDef htim3;
UART_HandleTypeDef huart4;
UART_HandleTypeDef huart5;
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
- .stack_size = 128 * 4,
+ .stack_size = 512 * 4,
.priority = (osPriority_t) osPriorityNormal,
};
/* Definitions for bdTask */
static void MX_USART3_UART_Init(void);
static void MX_USART6_UART_Init(void);
static void MX_TIM2_Init(void);
+static void MX_TIM3_Init(void);
void main_task(void *argument);
void bd_task(void *argument);
MX_USART3_UART_Init();
MX_USART6_UART_Init();
MX_TIM2_Init();
+ MX_TIM3_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
}
+/**
+ * @brief TIM3 Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_TIM3_Init(void)
+{
+
+ /* USER CODE BEGIN TIM3_Init 0 */
+
+ /* USER CODE END TIM3_Init 0 */
+
+ TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+ TIM_MasterConfigTypeDef sMasterConfig = {0};
+
+ /* USER CODE BEGIN TIM3_Init 1 */
+
+ /* USER CODE END TIM3_Init 1 */
+ htim3.Instance = TIM3;
+ htim3.Init.Prescaler = 0;
+ htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim3.Init.Period = 65535;
+ htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+ if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+ sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM3_Init 2 */
+
+ /* USER CODE END TIM3_Init 2 */
+
+}
+
/**
* @brief UART4 Initialization Function
* @param None
HAL_GPIO_WritePin(PB15_ETH_RESET_GPIO_Port, PB15_ETH_RESET_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOD, LAKI_WAKE_UP_Pin|PD14_LORA_M0_Pin|DM222_PAPWR_EN_Pin, GPIO_PIN_RESET);
+ HAL_GPIO_WritePin(GPIOD, LAKI_WAKE_UP_Pin|PD13_GPS_RST_EN_Pin|PD14_LORA_M0_Pin|DM222_PAPWR_EN_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOD, LAKI_RESET_Pin|PD13_GPS_RST_EN_Pin|PD15_LORA_M1_Pin|LORA_RST_Pin, GPIO_PIN_SET);
+ HAL_GPIO_WritePin(GPIOD, LAKI_RESET_Pin|PD15_LORA_M1_Pin|LORA_RST_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(FAN_EN_GPIO_Port, FAN_EN_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : DQ_IN_Pin */
GPIO_InitStruct.Pin = DQ_IN_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(DQ_IN_GPIO_Port, &GPIO_InitStruct);
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(SYS_LED_GPIO_Port, &GPIO_InitStruct);
+ /* EXTI interrupt init*/
+ HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(EXTI3_IRQn);
+
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
{
/* init code for LWIP */
MX_LWIP_Init();
-
- /* init code for USB_DEVICE */
- MX_USB_DEVICE_Init();
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
/* USER CODE END TIM2_MspInit 1 */
}
+ else if(htim_base->Instance==TIM3)
+ {
+ /* USER CODE BEGIN TIM3_MspInit 0 */
+
+ /* USER CODE END TIM3_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM3_CLK_ENABLE();
+ /* USER CODE BEGIN TIM3_MspInit 1 */
+
+ /* USER CODE END TIM3_MspInit 1 */
+ }
}
/* USER CODE END TIM2_MspDeInit 1 */
}
+ else if(htim_base->Instance==TIM3)
+ {
+ /* USER CODE BEGIN TIM3_MspDeInit 0 */
+
+ /* USER CODE END TIM3_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM3_CLK_DISABLE();
+ /* USER CODE BEGIN TIM3_MspDeInit 1 */
+
+ /* USER CODE END TIM3_MspDeInit 1 */
+ }
}
GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+ /* UART4 interrupt Init */
+ HAL_NVIC_SetPriority(UART4_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(UART4_IRQn);
/* USER CODE BEGIN UART4_MspInit 1 */
/* USER CODE END UART4_MspInit 1 */
GPIO_InitStruct.Alternate = GPIO_AF8_UART5;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+ /* UART5 interrupt Init */
+ HAL_NVIC_SetPriority(UART5_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(UART5_IRQn);
/* USER CODE BEGIN UART5_MspInit 1 */
/* USER CODE END UART5_MspInit 1 */
*/
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10|GPIO_PIN_11);
+ /* UART4 interrupt DeInit */
+ HAL_NVIC_DisableIRQ(UART4_IRQn);
/* USER CODE BEGIN UART4_MspDeInit 1 */
/* USER CODE END UART4_MspDeInit 1 */
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
+ /* UART5 interrupt DeInit */
+ HAL_NVIC_DisableIRQ(UART5_IRQn);
/* USER CODE BEGIN UART5_MspDeInit 1 */
/* USER CODE END UART5_MspDeInit 1 */
/* External variables --------------------------------------------------------*/
extern ETH_HandleTypeDef heth;
-extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
extern DMA_HandleTypeDef hdma_adc1;
+extern UART_HandleTypeDef huart4;
+extern UART_HandleTypeDef huart5;
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern UART_HandleTypeDef huart3;
/* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/
+/**
+ * @brief This function handles EXTI line3 interrupt.
+ */
+void EXTI3_IRQHandler(void)
+{
+ /* USER CODE BEGIN EXTI3_IRQn 0 */
+
+ /* USER CODE END EXTI3_IRQn 0 */
+ HAL_GPIO_EXTI_IRQHandler(DQ_IN_Pin);
+ /* USER CODE BEGIN EXTI3_IRQn 1 */
+
+ /* USER CODE END EXTI3_IRQn 1 */
+}
+
/**
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
*/
/* USER CODE END USART3_IRQn 1 */
}
+/**
+ * @brief This function handles UART4 global interrupt.
+ */
+void UART4_IRQHandler(void)
+{
+ /* USER CODE BEGIN UART4_IRQn 0 */
+
+ /* USER CODE END UART4_IRQn 0 */
+ HAL_UART_IRQHandler(&huart4);
+ /* USER CODE BEGIN UART4_IRQn 1 */
+
+ /* USER CODE END UART4_IRQn 1 */
+}
+
+/**
+ * @brief This function handles UART5 global interrupt.
+ */
+void UART5_IRQHandler(void)
+{
+ /* USER CODE BEGIN UART5_IRQn 0 */
+
+ /* USER CODE END UART5_IRQn 0 */
+ HAL_UART_IRQHandler(&huart5);
+ /* USER CODE BEGIN UART5_IRQn 1 */
+
+ /* USER CODE END UART5_IRQn 1 */
+}
+
/**
* @brief This function handles DMA2 stream0 global interrupt.
*/
/* USER CODE END ETH_IRQn 1 */
}
-/**
- * @brief This function handles USB On The Go FS global interrupt.
- */
-void OTG_FS_IRQHandler(void)
-{
- /* USER CODE BEGIN OTG_FS_IRQn 0 */
-
- /* USER CODE END OTG_FS_IRQn 0 */
- HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
- /* USER CODE BEGIN OTG_FS_IRQn 1 */
-
- /* USER CODE END OTG_FS_IRQn 1 */
-}
-
/**
* @brief This function handles USART6 global interrupt.
*/
--- /dev/null
+/**
+ ******************************************************************************
+ * @file lan8742.c
+ * @author MCD Application Team
+ * @brief This file provides a set of functions needed to manage the LAN742
+ * PHY devices.
+ ******************************************************************************
+ * @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 "lan8742.h"
+
+/** @addtogroup BSP
+ * @{
+ */
+
+/** @addtogroup Component
+ * @{
+ */
+
+/** @defgroup LAN8742 LAN8742
+ * @{
+ */
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/** @defgroup LAN8742_Private_Defines LAN8742 Private Defines
+ * @{
+ */
+#define LAN8742_MAX_DEV_ADDR ((uint32_t)31U)
+/**
+ * @}
+ */
+
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/** @defgroup LAN8742_Private_Functions LAN8742 Private Functions
+ * @{
+ */
+
+/**
+ * @brief Register IO functions to component object
+ * @param pObj: device object of LAN8742_Object_t.
+ * @param ioctx: holds device IO functions.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_ERROR if missing mandatory function
+ */
+int32_t LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
+{
+ if(!pObj || !ioctx->ReadReg || !ioctx->WriteReg || !ioctx->GetTick)
+ {
+ return LAN8742_STATUS_ERROR;
+ }
+
+ pObj->IO.Init = ioctx->Init;
+ pObj->IO.DeInit = ioctx->DeInit;
+ pObj->IO.ReadReg = ioctx->ReadReg;
+ pObj->IO.WriteReg = ioctx->WriteReg;
+ pObj->IO.GetTick = ioctx->GetTick;
+
+ return LAN8742_STATUS_OK;
+}
+
+/**
+ * @brief Initialize the lan8742 and configure the needed hardware resources
+ * @param pObj: device object LAN8742_Object_t.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_ADDRESS_ERROR if cannot find device address
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ */
+ int32_t LAN8742_Init(lan8742_Object_t *pObj)
+ {
+
+ uint32_t tickstart = 0, regvalue = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->Is_Initialized == 0)
+ {
+ if(pObj->IO.Init != 0)
+ {
+ /* GPIO and Clocks initialization */
+ pObj->IO.Init();
+ }
+
+ /* for later check */
+ pObj->DevAddr = 3;
+
+ if(status == LAN8742_STATUS_OK)
+ {
+ pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_AUTONEGO_EN);
+ tickstart = pObj->IO.GetTick();
+
+ /* Wait for 2s to perform initialization */
+ while((pObj->IO.GetTick() - tickstart) <= 2000)
+ {
+ }
+ pObj->Is_Initialized = 1;
+ }
+ }
+
+
+ return status;
+ }
+
+/**
+ * @brief De-Initialize the lan8742 and it's hardware resources
+ * @param pObj: device object LAN8742_Object_t.
+ * @retval None
+ */
+int32_t LAN8742_DeInit(lan8742_Object_t *pObj)
+{
+ if(pObj->Is_Initialized)
+ {
+ if(pObj->IO.DeInit != 0)
+ {
+ if(pObj->IO.DeInit() < 0)
+ {
+ return LAN8742_STATUS_ERROR;
+ }
+ }
+
+ pObj->Is_Initialized = 0;
+ }
+
+ return LAN8742_STATUS_OK;
+}
+
+/**
+ * @brief Disable the LAN8742 power down mode.
+ * @param pObj: device object LAN8742_Object_t.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_DisablePowerDownMode(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
+ {
+ readval &= ~LAN8742_BCR_POWER_DOWN;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Enable the LAN8742 power down mode.
+ * @param pObj: device object LAN8742_Object_t.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_EnablePowerDownMode(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
+ {
+ readval |= LAN8742_BCR_POWER_DOWN;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Start the auto negotiation process.
+ * @param pObj: device object LAN8742_Object_t.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_StartAutoNego(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
+ {
+ readval |= LAN8742_BCR_AUTONEGO_EN;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Get the link state of LAN8742 device.
+ * @param pObj: Pointer to device object.
+ * @param pLinkState: Pointer to link state
+ * @retval LAN8742_STATUS_LINK_DOWN if link is down
+ * LAN8742_STATUS_AUTONEGO_NOTDONE if Auto nego not completed
+ * LAN8742_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
+ * LAN8742_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
+ * LAN8742_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
+ * LAN8742_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_GetLinkState(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+
+ /* Read Status register */
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
+ {
+ return LAN8742_STATUS_READ_ERROR;
+ }
+
+ /* Read Status register again */
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BSR, &readval) < 0)
+ {
+ return LAN8742_STATUS_READ_ERROR;
+ }
+
+ if((readval & LAN8742_BSR_LINK_STATUS) == 0)
+ {
+ /* Return Link Down status */
+ return LAN8742_STATUS_LINK_DOWN;
+ }
+
+ /* Check Auto negotiation */
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) < 0)
+ {
+ return LAN8742_STATUS_READ_ERROR;
+ }
+
+ if((readval & LAN8742_BCR_AUTONEGO_EN) != LAN8742_BCR_AUTONEGO_EN)
+ {
+ if(((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT) && ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE))
+ {
+ return LAN8742_STATUS_100MBITS_FULLDUPLEX;
+ }
+ else if ((readval & LAN8742_BCR_SPEED_SELECT) == LAN8742_BCR_SPEED_SELECT)
+ {
+ return LAN8742_STATUS_100MBITS_HALFDUPLEX;
+ }
+ else if ((readval & LAN8742_BCR_DUPLEX_MODE) == LAN8742_BCR_DUPLEX_MODE)
+ {
+ return LAN8742_STATUS_10MBITS_FULLDUPLEX;
+ }
+ else
+ {
+ return LAN8742_STATUS_10MBITS_HALFDUPLEX;
+ }
+ }
+ else /* Auto Nego enabled */
+ {
+#if 0
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_PHYSCSR, &readval) < 0)
+ {
+ return LAN8742_STATUS_READ_ERROR;
+ }
+
+ /* Check if auto nego not done */
+ if((readval & LAN8742_PHYSCSR_AUTONEGO_DONE) == 0)
+ {
+ return LAN8742_STATUS_AUTONEGO_NOTDONE;
+ }
+
+ if((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_FD)
+ {
+ return LAN8742_STATUS_100MBITS_FULLDUPLEX;
+ }
+ else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_100BTX_HD)
+ {
+ return LAN8742_STATUS_100MBITS_HALFDUPLEX;
+ }
+ else if ((readval & LAN8742_PHYSCSR_HCDSPEEDMASK) == LAN8742_PHYSCSR_10BT_FD)
+ {
+ return LAN8742_STATUS_10MBITS_FULLDUPLEX;
+ }
+ else
+ {
+ return LAN8742_STATUS_10MBITS_HALFDUPLEX;
+ }
+#else
+ if(pObj->IO.ReadReg(pObj->DevAddr, 0x11, &readval) < 0)
+ {
+ return LAN8742_STATUS_READ_ERROR;
+ }
+
+ /* Check if auto nego not done */
+ if((readval & (1<<11)) == 0)
+ {
+ return LAN8742_STATUS_AUTONEGO_NOTDONE;
+ }
+
+ if((readval >>13) == 3 ){//b'01 1'
+ return LAN8742_STATUS_100MBITS_FULLDUPLEX;
+ }else if((readval >>13) == 2 ){//b'01 0'
+ return LAN8742_STATUS_100MBITS_HALFDUPLEX;
+ }else if((readval >>13) == 2 ){//b'00 1'
+ return LAN8742_STATUS_10MBITS_HALFDUPLEX;
+ }else{
+ return LAN8742_STATUS_10MBITS_HALFDUPLEX;
+ }
+#endif
+ }
+}
+
+/**
+ * @brief Set the link state of LAN8742 device.
+ * @param pObj: Pointer to device object.
+ * @param pLinkState: link state can be one of the following
+ * LAN8742_STATUS_100MBITS_FULLDUPLEX if 100Mb/s FD
+ * LAN8742_STATUS_100MBITS_HALFDUPLEX if 100Mb/s HD
+ * LAN8742_STATUS_10MBITS_FULLDUPLEX if 10Mb/s FD
+ * LAN8742_STATUS_10MBITS_HALFDUPLEX if 10Mb/s HD
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_ERROR if parameter error
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_SetLinkState(lan8742_Object_t *pObj, uint32_t LinkState)
+{
+ uint32_t bcrvalue = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &bcrvalue) >= 0)
+ {
+ /* Disable link config (Auto nego, speed and duplex) */
+ bcrvalue &= ~(LAN8742_BCR_AUTONEGO_EN | LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
+
+ if(LinkState == LAN8742_STATUS_100MBITS_FULLDUPLEX)
+ {
+ bcrvalue |= (LAN8742_BCR_SPEED_SELECT | LAN8742_BCR_DUPLEX_MODE);
+ }
+ else if (LinkState == LAN8742_STATUS_100MBITS_HALFDUPLEX)
+ {
+ bcrvalue |= LAN8742_BCR_SPEED_SELECT;
+ }
+ else if (LinkState == LAN8742_STATUS_10MBITS_FULLDUPLEX)
+ {
+ bcrvalue |= LAN8742_BCR_DUPLEX_MODE;
+ }
+ else
+ {
+ /* Wrong link status parameter */
+ status = LAN8742_STATUS_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ if(status == LAN8742_STATUS_OK)
+ {
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, bcrvalue) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+
+ return status;
+}
+
+/**
+ * @brief Enable loopback mode.
+ * @param pObj: Pointer to device object.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_EnableLoopbackMode(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
+ {
+ readval |= LAN8742_BCR_LOOPBACK;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Disable loopback mode.
+ * @param pObj: Pointer to device object.
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_DisableLoopbackMode(lan8742_Object_t *pObj)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &readval) >= 0)
+ {
+ readval &= ~LAN8742_BCR_LOOPBACK;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Enable IT source.
+ * @param pObj: Pointer to device object.
+ * @param Interrupt: IT source to be enabled
+ * should be a value or a combination of the following:
+ * LAN8742_WOL_IT
+ * LAN8742_ENERGYON_IT
+ * LAN8742_AUTONEGO_COMPLETE_IT
+ * LAN8742_REMOTE_FAULT_IT
+ * LAN8742_LINK_DOWN_IT
+ * LAN8742_AUTONEGO_LP_ACK_IT
+ * LAN8742_PARALLEL_DETECTION_FAULT_IT
+ * LAN8742_AUTONEGO_PAGE_RECEIVED_IT
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_EnableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
+ {
+ readval |= Interrupt;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Disable IT source.
+ * @param pObj: Pointer to device object.
+ * @param Interrupt: IT source to be disabled
+ * should be a value or a combination of the following:
+ * LAN8742_WOL_IT
+ * LAN8742_ENERGYON_IT
+ * LAN8742_AUTONEGO_COMPLETE_IT
+ * LAN8742_REMOTE_FAULT_IT
+ * LAN8742_LINK_DOWN_IT
+ * LAN8742_AUTONEGO_LP_ACK_IT
+ * LAN8742_PARALLEL_DETECTION_FAULT_IT
+ * LAN8742_AUTONEGO_PAGE_RECEIVED_IT
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ * LAN8742_STATUS_WRITE_ERROR if cannot write to register
+ */
+int32_t LAN8742_DisableIT(lan8742_Object_t *pObj, uint32_t Interrupt)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_IMR, &readval) >= 0)
+ {
+ readval &= ~Interrupt;
+
+ /* Apply configuration */
+ if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_IMR, readval) < 0)
+ {
+ status = LAN8742_STATUS_WRITE_ERROR;
+ }
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Clear IT flag.
+ * @param pObj: Pointer to device object.
+ * @param Interrupt: IT flag to be cleared
+ * should be a value or a combination of the following:
+ * LAN8742_WOL_IT
+ * LAN8742_ENERGYON_IT
+ * LAN8742_AUTONEGO_COMPLETE_IT
+ * LAN8742_REMOTE_FAULT_IT
+ * LAN8742_LINK_DOWN_IT
+ * LAN8742_AUTONEGO_LP_ACK_IT
+ * LAN8742_PARALLEL_DETECTION_FAULT_IT
+ * LAN8742_AUTONEGO_PAGE_RECEIVED_IT
+ * @retval LAN8742_STATUS_OK if OK
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ */
+int32_t LAN8742_ClearIT(lan8742_Object_t *pObj, uint32_t Interrupt)
+{
+ uint32_t readval = 0;
+ int32_t status = LAN8742_STATUS_OK;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) < 0)
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @brief Get IT Flag status.
+ * @param pObj: Pointer to device object.
+ * @param Interrupt: IT Flag to be checked,
+ * should be a value or a combination of the following:
+ * LAN8742_WOL_IT
+ * LAN8742_ENERGYON_IT
+ * LAN8742_AUTONEGO_COMPLETE_IT
+ * LAN8742_REMOTE_FAULT_IT
+ * LAN8742_LINK_DOWN_IT
+ * LAN8742_AUTONEGO_LP_ACK_IT
+ * LAN8742_PARALLEL_DETECTION_FAULT_IT
+ * LAN8742_AUTONEGO_PAGE_RECEIVED_IT
+ * @retval 1 IT flag is SET
+ * 0 IT flag is RESET
+ * LAN8742_STATUS_READ_ERROR if cannot read register
+ */
+int32_t LAN8742_GetITStatus(lan8742_Object_t *pObj, uint32_t Interrupt)
+{
+ uint32_t readval = 0;
+ int32_t status = 0;
+
+ if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_ISFR, &readval) >= 0)
+ {
+ status = ((readval & Interrupt) == Interrupt);
+ }
+ else
+ {
+ status = LAN8742_STATUS_READ_ERROR;
+ }
+
+ return status;
+}
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
ip4_addr_t ipaddr;
ip4_addr_t netmask;
ip4_addr_t gw;
+uint8_t IP_ADDRESS[4];
+uint8_t NETMASK_ADDRESS[4];
+uint8_t GATEWAY_ADDRESS[4];
/* USER CODE BEGIN OS_THREAD_ATTR_CMSIS_RTOS_V2 */
#define INTERFACE_THREAD_STACK_SIZE ( 1024 )
osThreadAttr_t attributes;
*/
void MX_LWIP_Init(void)
{
+ /* IP addresses initialization */
+ IP_ADDRESS[0] = 192;
+ IP_ADDRESS[1] = 168;
+ IP_ADDRESS[2] = 1;
+ IP_ADDRESS[3] = 200;
+ NETMASK_ADDRESS[0] = 255;
+ NETMASK_ADDRESS[1] = 255;
+ NETMASK_ADDRESS[2] = 255;
+ NETMASK_ADDRESS[3] = 0;
+ GATEWAY_ADDRESS[0] = 192;
+ GATEWAY_ADDRESS[1] = 168;
+ GATEWAY_ADDRESS[2] = 1;
+ GATEWAY_ADDRESS[3] = 1;
+
+/* USER CODE BEGIN IP_ADDRESSES */
+/* USER CODE END IP_ADDRESSES */
+
/* Initilialize the LwIP stack with RTOS */
tcpip_init( NULL, NULL );
- /* IP addresses initialization with DHCP (IPv4) */
- ipaddr.addr = 0;
- netmask.addr = 0;
- gw.addr = 0;
+ /* IP addresses initialization without DHCP (IPv4) */
+ IP4_ADDR(&ipaddr, IP_ADDRESS[0], IP_ADDRESS[1], IP_ADDRESS[2], IP_ADDRESS[3]);
+ IP4_ADDR(&netmask, NETMASK_ADDRESS[0], NETMASK_ADDRESS[1] , NETMASK_ADDRESS[2], NETMASK_ADDRESS[3]);
+ IP4_ADDR(&gw, GATEWAY_ADDRESS[0], GATEWAY_ADDRESS[1], GATEWAY_ADDRESS[2], GATEWAY_ADDRESS[3]);
/* add the network interface (IPv4/IPv6) with RTOS */
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
osThreadNew(ethernet_link_thread, &gnetif, &attributes);
/* USER CODE END H7_OS_THREAD_NEW_CMSIS_RTOS_V2 */
- /* Start DHCP negotiation for a network interface (IPv4) */
- dhcp_start(&gnetif);
-
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */
/* LwIP Stack Parameters (modified compared to initialization value in opt.h) -*/
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
-/*----- Value in opt.h for LWIP_DHCP: 0 -----*/
-#define LWIP_DHCP 1
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
#define MEM_ALIGNMENT 4
-/*----- Value in opt.h for MEMP_NUM_SYS_TIMEOUT: (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + (PPP_SUPPORT*6*MEMP_NUM_PPP_PCB) + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0)) -*/
-#define MEMP_NUM_SYS_TIMEOUT 5
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
#define LWIP_ETHERNET 1
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/
-<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
-<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="project_projx.xsd">
-
+<?xml version="1.0" encoding="UTF-8"?>
+<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" noNamespaceSchemaLocation="project_projx.xsd">
<SchemaVersion>2.1</SchemaVersion>
-
<Header>### uVision Project, (C) Keil Software</Header>
-
<Targets>
<Target>
<TargetName>mcu</TargetName>
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x807FFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
- <FlashUtilSpec></FlashUtilSpec>
- <StartupFile></StartupFile>
- <FlashDriverDll></FlashDriverDll>
+ <FlashUtilSpec />
+ <StartupFile />
+ <FlashDriverDll />
<DeviceId>0</DeviceId>
- <RegisterFile></RegisterFile>
- <MemoryEnv></MemoryEnv>
- <Cmp></Cmp>
- <Asm></Asm>
- <Linker></Linker>
- <OHString></OHString>
- <InfinionOptionDll></InfinionOptionDll>
- <SLE66CMisc></SLE66CMisc>
- <SLE66AMisc></SLE66AMisc>
- <SLE66LinkerMisc></SLE66LinkerMisc>
+ <RegisterFile />
+ <MemoryEnv />
+ <Cmp />
+ <Asm />
+ <Linker />
+ <OHString />
+ <InfinionOptionDll />
+ <SLE66CMisc />
+ <SLE66AMisc />
+ <SLE66LinkerMisc />
<SFDFile>$$Device:STM32F407VETx$CMSIS\SVD\STM32F40x.svd</SFDFile>
<bCustSvd>0</bCustSvd>
<UseEnv>0</UseEnv>
- <BinPath></BinPath>
- <IncludePath></IncludePath>
- <LibPath></LibPath>
- <RegisterFilePath></RegisterFilePath>
- <DBRegisterFilePath></DBRegisterFilePath>
+ <BinPath />
+ <IncludePath />
+ <LibPath />
+ <RegisterFilePath />
+ <DBRegisterFilePath />
<TargetStatus>
<Error>0</Error>
<ExitCodeStop>0</ExitCodeStop>
<CreateHexFile>1</CreateHexFile>
<DebugInformation>1</DebugInformation>
<BrowseInformation>1</BrowseInformation>
- <ListingPath></ListingPath>
+ <ListingPath />
<HexFormatSelection>1</HexFormatSelection>
<Merge32K>0</Merge32K>
<CreateBatchFile>0</CreateBatchFile>
<BeforeCompile>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
- <UserProg1Name></UserProg1Name>
- <UserProg2Name></UserProg2Name>
+ <UserProg1Name />
+ <UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopU1X>0</nStopU1X>
<BeforeMake>
<RunUserProg1>0</RunUserProg1>
<RunUserProg2>0</RunUserProg2>
- <UserProg1Name></UserProg1Name>
- <UserProg2Name></UserProg2Name>
+ <UserProg1Name />
+ <UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopB1X>0</nStopB1X>
<nStopB2X>0</nStopB2X>
</BeforeMake>
<AfterMake>
- <RunUserProg1>0</RunUserProg1>
+ <RunUserProg1>1</RunUserProg1>
<RunUserProg2>1</RunUserProg2>
- <UserProg1Name></UserProg1Name>
- <UserProg2Name></UserProg2Name>
+ <UserProg1Name>fromelf --bin --output=$L@L.bin !L</UserProg1Name>
+ <UserProg2Name />
<UserProg1Dos16Mode>0</UserProg1Dos16Mode>
<UserProg2Dos16Mode>0</UserProg2Dos16Mode>
<nStopA1X>0</nStopA1X>
<nStopA2X>0</nStopA2X>
</AfterMake>
<SelectedForBatchBuild>1</SelectedForBatchBuild>
- <SVCSIdString></SVCSIdString>
+ <SVCSIdString />
</TargetCommonOption>
<CommonProperty>
<UseCPPCompiler>0</UseCPPCompiler>
<AssembleAssemblyFile>0</AssembleAssemblyFile>
<PublicsOnly>0</PublicsOnly>
<StopOnExitCode>3</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
+ <CustomArgument />
+ <IncludeLibraryModules />
<ComprImg>0</ComprImg>
</CommonProperty>
<DllOption>
</Flash1>
<bUseTDR>1</bUseTDR>
<Flash2>BIN\UL2V8M.DLL</Flash2>
- <Flash3></Flash3>
- <Flash4></Flash4>
- <pFcarmOut></pFcarmOut>
- <pFcarmGrp></pFcarmGrp>
- <pFcArmRoot></pFcArmRoot>
+ <Flash3 />
+ <Flash4 />
+ <pFcarmOut />
+ <pFcarmGrp />
+ <pFcArmRoot />
<FcArmLst>0</FcArmLst>
</Utilities>
<TargetArmAds>
<RvctClst>0</RvctClst>
<GenPPlst>0</GenPPlst>
<AdsCpuType>"Cortex-M4"</AdsCpuType>
- <RvctDeviceName></RvctDeviceName>
+ <RvctDeviceName />
<mOS>0</mOS>
<uocRom>0</uocRom>
<uocRam>0</uocRam>
</OCR_RVCT5>
<OCR_RVCT6>
<Type>0</Type>
- <StartAddress>0x0</StartAddress>
- <Size>0x0</Size>
+ <StartAddress>0x10000000</StartAddress>
+ <Size>0x10000</Size>
</OCR_RVCT6>
<OCR_RVCT7>
<Type>0</Type>
<Size>0x4000</Size>
</OCR_RVCT10>
</OnChipMemories>
- <RvctStartVector></RvctStartVector>
+ <RvctStartVector />
</ArmAdsMisc>
<Cads>
<interw>1</interw>
- <Optim>3</Optim>
+ <Optim>2</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
- <MiscControls></MiscControls>
+ <MiscControls />
<Define>USE_HAL_DRIVER,STM32F407xx,ARM_MATH_CM4</Define>
- <Undefine></Undefine>
- <IncludePath>../Core/Inc;../LWIP/App;../LWIP/Target;../Middlewares/Third_Party/LwIP/src/include;../Middlewares/Third_Party/LwIP/system;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Drivers/BSP/Components/lan8742;../Middlewares/Third_Party/LwIP/src/include/netif/ppp;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Middlewares/Third_Party/LwIP/src/include/lwip;../Middlewares/Third_Party/LwIP/src/include/lwip/apps;../Middlewares/Third_Party/LwIP/src/include/lwip/priv;../Middlewares/Third_Party/LwIP/src/include/lwip/prot;../Middlewares/Third_Party/LwIP/src/include/netif;../Middlewares/Third_Party/LwIP/src/include/compat/posix;../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa;../Middlewares/Third_Party/LwIP/src/include/compat/posix/net;../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys;../Middlewares/Third_Party/LwIP/src/include/compat/stdc;../Middlewares/Third_Party/LwIP/system/arch;../Drivers/CMSIS/Include;../USB_DEVICE/App;../USB_DEVICE/Target;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;..\user;..\user_debug</IncludePath>
+ <Undefine />
+ <IncludePath>../Core/Inc;../LWIP/App;../LWIP/Target;../Middlewares/Third_Party/LwIP/src/include;../Middlewares/Third_Party/LwIP/system;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Drivers/BSP/Components/lan8742;../Middlewares/Third_Party/LwIP/src/include/netif/ppp;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Middlewares/Third_Party/LwIP/src/include/lwip;../Middlewares/Third_Party/LwIP/src/include/lwip/apps;../Middlewares/Third_Party/LwIP/src/include/lwip/priv;../Middlewares/Third_Party/LwIP/src/include/lwip/prot;../Middlewares/Third_Party/LwIP/src/include/netif;../Middlewares/Third_Party/LwIP/src/include/compat/posix;../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa;../Middlewares/Third_Party/LwIP/src/include/compat/posix/net;../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys;../Middlewares/Third_Party/LwIP/src/include/compat/stdc;../Middlewares/Third_Party/LwIP/system/arch;../Drivers/CMSIS/Include;../USB_DEVICE/App;../USB_DEVICE/Target;../Middlewares/ST/STM32_USB_Device_Library/Core/Inc;../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc;../user;../user_debug</IncludePath>
</VariousControls>
</Cads>
<Aads>
<useXO>0</useXO>
<ClangAsOpt>1</ClangAsOpt>
<VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
+ <MiscControls />
+ <Define />
+ <Undefine />
<IncludePath>../Core/Inc</IncludePath>
</VariousControls>
</Aads>
<noStLib>0</noStLib>
<RepFail>1</RepFail>
<useFile>0</useFile>
- <TextAddressRange></TextAddressRange>
- <DataAddressRange></DataAddressRange>
- <pXoBase></pXoBase>
- <ScatterFile></ScatterFile>
- <IncludeLibs></IncludeLibs>
- <IncludeLibsPath></IncludeLibsPath>
- <Misc></Misc>
- <LinkerInputFile></LinkerInputFile>
- <DisabledWarnings></DisabledWarnings>
+ <TextAddressRange />
+ <DataAddressRange />
+ <pXoBase />
+ <ScatterFile />
+ <IncludeLibs />
+ <IncludeLibsPath />
+ <Misc />
+ <LinkerInputFile />
+ <DisabledWarnings />
</LDads>
</TargetArmAds>
</TargetOption>
<Group>
<GroupName>Drivers/BSP/Components</GroupName>
<Files>
+ <File>
+ <FileName>yt8512h.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\Drivers\BSP\Components\lan8742\yt8512h.c</FilePath>
+ </File>
<File>
<FileName>lan8742.c</FileName>
<FileType>1</FileType>
<FilePath>../Drivers/BSP/Components/lan8742/lan8742.c</FilePath>
+ <FileOption>
+ <CommonProperty>
+ <UseCPPCompiler>2</UseCPPCompiler>
+ <RVCTCodeConst>0</RVCTCodeConst>
+ <RVCTZI>0</RVCTZI>
+ <RVCTOtherData>0</RVCTOtherData>
+ <ModuleSelection>0</ModuleSelection>
+ <IncludeInBuild>0</IncludeInBuild>
+ <AlwaysBuild>2</AlwaysBuild>
+ <GenerateAssemblyFile>2</GenerateAssemblyFile>
+ <AssembleAssemblyFile>2</AssembleAssemblyFile>
+ <PublicsOnly>2</PublicsOnly>
+ <StopOnExitCode>11</StopOnExitCode>
+ <ComprImg>1</ComprImg>
+ </CommonProperty>
+ <FileArmAds>
+ <Cads>
+ <interw>2</interw>
+ <Optim>0</Optim>
+ <oTime>2</oTime>
+ <SplitLS>2</SplitLS>
+ <OneElfS>2</OneElfS>
+ <Strict>2</Strict>
+ <EnumInt>2</EnumInt>
+ <PlainCh>2</PlainCh>
+ <Ropi>2</Ropi>
+ <Rwpi>2</Rwpi>
+ <wLevel>0</wLevel>
+ <uThumb>2</uThumb>
+ <uSurpInc>2</uSurpInc>
+ <uC99>2</uC99>
+ <uGnu>2</uGnu>
+ <useXO>2</useXO>
+ <v6Lang>0</v6Lang>
+ <v6LangP>0</v6LangP>
+ <vShortEn>2</vShortEn>
+ <vShortWch>2</vShortWch>
+ <v6Lto>2</v6Lto>
+ <v6WtE>2</v6WtE>
+ <v6Rtti>2</v6Rtti>
+ </Cads>
+ </FileArmAds>
+ </FileOption>
</File>
</Files>
</Group>
<FileType>1</FileType>
<FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c</FilePath>
</File>
- <File>
- <FileName>stm32f4xx_hal_pcd.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>stm32f4xx_hal_pcd_ex.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>stm32f4xx_ll_usb.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
<File>
<FileName>stm32f4xx_hal_adc.c</FileName>
<FileType>1</FileType>
</Files>
</Group>
<Group>
- <GroupName>Application/User/USB_DEVICE/App</GroupName>
- <GroupOption>
- <CommonProperty>
- <UseCPPCompiler>0</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>2</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <GroupArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>4</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- <Aads>
- <interw>2</interw>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <thumb>2</thumb>
- <SplitLS>2</SplitLS>
- <SwStkChk>2</SwStkChk>
- <NoWarn>2</NoWarn>
- <uSurpInc>2</uSurpInc>
- <useXO>2</useXO>
- <ClangAsOpt>1</ClangAsOpt>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Aads>
- </GroupArmAds>
- </GroupOption>
+ <GroupName>user</GroupName>
<Files>
<File>
- <FileName>usb_device.c</FileName>
+ <FileName>user_app.c</FileName>
<FileType>1</FileType>
- <FilePath>../USB_DEVICE/App/usb_device.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
+ <FilePath>..\user\user_app.c</FilePath>
</File>
<File>
- <FileName>usbd_desc.c</FileName>
- <FileType>1</FileType>
- <FilePath>../USB_DEVICE/App/usbd_desc.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>usbd_cdc_if.c</FileName>
- <FileType>1</FileType>
- <FilePath>../USB_DEVICE/App/usbd_cdc_if.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- </Files>
- </Group>
- <Group>
- <GroupName>Application/User/USB_DEVICE/Target</GroupName>
- <GroupOption>
- <CommonProperty>
- <UseCPPCompiler>0</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>2</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <GroupArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>4</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- <Aads>
- <interw>2</interw>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <thumb>2</thumb>
- <SplitLS>2</SplitLS>
- <SwStkChk>2</SwStkChk>
- <NoWarn>2</NoWarn>
- <uSurpInc>2</uSurpInc>
- <useXO>2</useXO>
- <ClangAsOpt>1</ClangAsOpt>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Aads>
- </GroupArmAds>
- </GroupOption>
- <Files>
- <File>
- <FileName>usbd_conf.c</FileName>
- <FileType>1</FileType>
- <FilePath>../USB_DEVICE/Target/usbd_conf.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- </Files>
- </Group>
- <Group>
- <GroupName>Middlewares/USB_Device_Library</GroupName>
- <GroupOption>
- <CommonProperty>
- <UseCPPCompiler>0</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>2</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <GroupArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>4</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- <Aads>
- <interw>2</interw>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <thumb>2</thumb>
- <SplitLS>2</SplitLS>
- <SwStkChk>2</SwStkChk>
- <NoWarn>2</NoWarn>
- <uSurpInc>2</uSurpInc>
- <useXO>2</useXO>
- <ClangAsOpt>1</ClangAsOpt>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Aads>
- </GroupArmAds>
- </GroupOption>
- <Files>
- <File>
- <FileName>usbd_core.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>usbd_ctlreq.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>usbd_ioreq.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- <File>
- <FileName>usbd_cdc.c</FileName>
- <FileType>1</FileType>
- <FilePath>../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c</FilePath>
- <FileOption>
- <CommonProperty>
- <UseCPPCompiler>2</UseCPPCompiler>
- <RVCTCodeConst>0</RVCTCodeConst>
- <RVCTZI>0</RVCTZI>
- <RVCTOtherData>0</RVCTOtherData>
- <ModuleSelection>0</ModuleSelection>
- <IncludeInBuild>1</IncludeInBuild>
- <AlwaysBuild>2</AlwaysBuild>
- <GenerateAssemblyFile>2</GenerateAssemblyFile>
- <AssembleAssemblyFile>2</AssembleAssemblyFile>
- <PublicsOnly>2</PublicsOnly>
- <StopOnExitCode>11</StopOnExitCode>
- <CustomArgument></CustomArgument>
- <IncludeLibraryModules></IncludeLibraryModules>
- <ComprImg>1</ComprImg>
- </CommonProperty>
- <FileArmAds>
- <Cads>
- <interw>2</interw>
- <Optim>0</Optim>
- <oTime>2</oTime>
- <SplitLS>2</SplitLS>
- <OneElfS>2</OneElfS>
- <Strict>2</Strict>
- <EnumInt>2</EnumInt>
- <PlainCh>2</PlainCh>
- <Ropi>2</Ropi>
- <Rwpi>2</Rwpi>
- <wLevel>0</wLevel>
- <uThumb>2</uThumb>
- <uSurpInc>2</uSurpInc>
- <uC99>2</uC99>
- <uGnu>2</uGnu>
- <useXO>2</useXO>
- <v6Lang>0</v6Lang>
- <v6LangP>0</v6LangP>
- <vShortEn>2</vShortEn>
- <vShortWch>2</vShortWch>
- <v6Lto>2</v6Lto>
- <v6WtE>2</v6WtE>
- <v6Rtti>2</v6Rtti>
- <VariousControls>
- <MiscControls></MiscControls>
- <Define></Define>
- <Undefine></Undefine>
- <IncludePath></IncludePath>
- </VariousControls>
- </Cads>
- </FileArmAds>
- </FileOption>
- </File>
- </Files>
- </Group>
- <Group>
- <GroupName>user</GroupName>
- <Files>
- <File>
- <FileName>user_app.c</FileName>
- <FileType>1</FileType>
- <FilePath>..\user\user_app.c</FilePath>
- </File>
- <File>
- <FileName>user_noise_sensor.c</FileName>
+ <FileName>user_noise_sensor.c</FileName>
<FileType>1</FileType>
<FilePath>..\user\user_noise_sensor.c</FilePath>
</File>
<FileType>1</FileType>
<FilePath>..\user\user_filter.c</FilePath>
</File>
+ <File>
+ <FileName>user_temperture.c</FileName>
+ <FileType>1</FileType>
+ <FilePath>..\user\user_temperture.c</FilePath>
+ </File>
</Files>
</Group>
<Group>
</Groups>
</Target>
</Targets>
-
<RTE>
- <apis/>
+ <apis />
<components>
<component Cclass="CMSIS" Cgroup="CORE" Cvendor="ARM" Cversion="5.5.0" condition="ARMv6_7_8-M Device">
- <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
+ <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0" />
<targetInfos>
- <targetInfo name="mcu"/>
+ <targetInfo name="mcu" />
</targetInfos>
</component>
<component Cclass="CMSIS" Cgroup="DSP" Cvariant="Source" Cvendor="ARM" Cversion="1.9.0-dev" condition="CMSIS DSP">
- <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0"/>
+ <package name="CMSIS" schemaVersion="1.3" url="http://www.keil.com/pack/" vendor="ARM" version="5.8.0" />
<targetInfos>
- <targetInfo name="mcu"/>
+ <targetInfo name="mcu" />
</targetInfos>
</component>
</components>
- <files/>
+ <files />
</RTE>
-
</Project>
+
+++ /dev/null
-/**
- ******************************************************************************
- * @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 */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_cdc.c
- * @author MCD Application Team
- * @brief This file provides the high layer firmware functions to manage the
- * following functionalities of the USB CDC Class:
- * - Initialization and Configuration of high and low layer
- * - Enumeration as CDC Device (and enumeration for each implemented memory interface)
- * - OUT/IN data transfer
- * - Command IN transfer (class requests management)
- * - Error management
- *
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- * @verbatim
- *
- * ===================================================================
- * CDC Class Driver Description
- * ===================================================================
- * This driver manages the "Universal Serial Bus Class Definitions for Communications Devices
- * Revision 1.2 November 16, 2007" and the sub-protocol specification of "Universal Serial Bus
- * Communications Class Subclass Specification for PSTN Devices Revision 1.2 February 9, 2007"
- * This driver implements the following aspects of the specification:
- * - Device descriptor management
- * - Configuration descriptor management
- * - Enumeration as CDC device with 2 data endpoints (IN and OUT) and 1 command endpoint (IN)
- * - Requests management (as described in section 6.2 in specification)
- * - Abstract Control Model compliant
- * - Union Functional collection (using 1 IN endpoint for control)
- * - Data interface class
- *
- * These aspects may be enriched or modified for a specific user application.
- *
- * This driver doesn't implement the following aspects of the specification
- * (but it is possible to manage these features with some modifications on this driver):
- * - Any class-specific aspect relative to communication classes should be managed by user application.
- * - All communication classes other than PSTN are not managed
- *
- * @endverbatim
- *
- ******************************************************************************
- */
-
-/* BSPDependencies
-- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
-- "stm32xxxxx_{eval}{discovery}_io.c"
-EndBSPDependencies */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_cdc.h"
-#include "usbd_ctlreq.h"
-
-
-/** @addtogroup STM32_USB_DEVICE_LIBRARY
- * @{
- */
-
-
-/** @defgroup USBD_CDC
- * @brief usbd core module
- * @{
- */
-
-/** @defgroup USBD_CDC_Private_TypesDefinitions
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CDC_Private_Defines
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CDC_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CDC_Private_FunctionPrototypes
- * @{
- */
-
-static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
-static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
-static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
-static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
-static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev);
-#ifndef USE_USBD_COMPOSITE
-static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length);
-static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length);
-static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length);
-uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length);
-#endif /* USE_USBD_COMPOSITE */
-
-#ifndef USE_USBD_COMPOSITE
-/* USB Standard Device Descriptor */
-__ALIGN_BEGIN static uint8_t USBD_CDC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
-{
- USB_LEN_DEV_QUALIFIER_DESC,
- USB_DESC_TYPE_DEVICE_QUALIFIER,
- 0x00,
- 0x02,
- 0x00,
- 0x00,
- 0x00,
- 0x40,
- 0x01,
- 0x00,
-};
-#endif /* USE_USBD_COMPOSITE */
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_Private_Variables
- * @{
- */
-
-
-/* CDC interface class callbacks structure */
-USBD_ClassTypeDef USBD_CDC =
-{
- USBD_CDC_Init,
- USBD_CDC_DeInit,
- USBD_CDC_Setup,
- NULL, /* EP0_TxSent */
- USBD_CDC_EP0_RxReady,
- USBD_CDC_DataIn,
- USBD_CDC_DataOut,
- NULL,
- NULL,
- NULL,
-#ifdef USE_USBD_COMPOSITE
- NULL,
- NULL,
- NULL,
- NULL,
-#else
- USBD_CDC_GetHSCfgDesc,
- USBD_CDC_GetFSCfgDesc,
- USBD_CDC_GetOtherSpeedCfgDesc,
- USBD_CDC_GetDeviceQualifierDescriptor,
-#endif /* USE_USBD_COMPOSITE */
-};
-
-#ifndef USE_USBD_COMPOSITE
-/* USB CDC device Configuration Descriptor */
-__ALIGN_BEGIN static uint8_t USBD_CDC_CfgDesc[USB_CDC_CONFIG_DESC_SIZ] __ALIGN_END =
-{
- /* Configuration Descriptor */
- 0x09, /* bLength: Configuration Descriptor size */
- USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
- USB_CDC_CONFIG_DESC_SIZ, /* wTotalLength */
- 0x00,
- 0x02, /* bNumInterfaces: 2 interfaces */
- 0x01, /* bConfigurationValue: Configuration value */
- 0x00, /* iConfiguration: Index of string descriptor
- describing the configuration */
-#if (USBD_SELF_POWERED == 1U)
- 0xC0, /* bmAttributes: Bus Powered according to user configuration */
-#else
- 0x80, /* bmAttributes: Bus Powered according to user configuration */
-#endif /* USBD_SELF_POWERED */
- USBD_MAX_POWER, /* MaxPower (mA) */
-
- /*---------------------------------------------------------------------------*/
-
- /* Interface Descriptor */
- 0x09, /* bLength: Interface Descriptor size */
- USB_DESC_TYPE_INTERFACE, /* bDescriptorType: Interface */
- /* Interface descriptor type */
- 0x00, /* bInterfaceNumber: Number of Interface */
- 0x00, /* bAlternateSetting: Alternate setting */
- 0x01, /* bNumEndpoints: One endpoint used */
- 0x02, /* bInterfaceClass: Communication Interface Class */
- 0x02, /* bInterfaceSubClass: Abstract Control Model */
- 0x01, /* bInterfaceProtocol: Common AT commands */
- 0x00, /* iInterface */
-
- /* Header Functional Descriptor */
- 0x05, /* bLength: Endpoint Descriptor size */
- 0x24, /* bDescriptorType: CS_INTERFACE */
- 0x00, /* bDescriptorSubtype: Header Func Desc */
- 0x10, /* bcdCDC: spec release number */
- 0x01,
-
- /* Call Management Functional Descriptor */
- 0x05, /* bFunctionLength */
- 0x24, /* bDescriptorType: CS_INTERFACE */
- 0x01, /* bDescriptorSubtype: Call Management Func Desc */
- 0x00, /* bmCapabilities: D0+D1 */
- 0x01, /* bDataInterface */
-
- /* ACM Functional Descriptor */
- 0x04, /* bFunctionLength */
- 0x24, /* bDescriptorType: CS_INTERFACE */
- 0x02, /* bDescriptorSubtype: Abstract Control Management desc */
- 0x02, /* bmCapabilities */
-
- /* Union Functional Descriptor */
- 0x05, /* bFunctionLength */
- 0x24, /* bDescriptorType: CS_INTERFACE */
- 0x06, /* bDescriptorSubtype: Union func desc */
- 0x00, /* bMasterInterface: Communication class interface */
- 0x01, /* bSlaveInterface0: Data Class Interface */
-
- /* Endpoint 2 Descriptor */
- 0x07, /* bLength: Endpoint Descriptor size */
- USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
- CDC_CMD_EP, /* bEndpointAddress */
- 0x03, /* bmAttributes: Interrupt */
- LOBYTE(CDC_CMD_PACKET_SIZE), /* wMaxPacketSize */
- HIBYTE(CDC_CMD_PACKET_SIZE),
- CDC_FS_BINTERVAL, /* bInterval */
- /*---------------------------------------------------------------------------*/
-
- /* Data class interface descriptor */
- 0x09, /* bLength: Endpoint Descriptor size */
- USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
- 0x01, /* bInterfaceNumber: Number of Interface */
- 0x00, /* bAlternateSetting: Alternate setting */
- 0x02, /* bNumEndpoints: Two endpoints used */
- 0x0A, /* bInterfaceClass: CDC */
- 0x00, /* bInterfaceSubClass */
- 0x00, /* bInterfaceProtocol */
- 0x00, /* iInterface */
-
- /* Endpoint OUT Descriptor */
- 0x07, /* bLength: Endpoint Descriptor size */
- USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
- CDC_OUT_EP, /* bEndpointAddress */
- 0x02, /* bmAttributes: Bulk */
- LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */
- HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
- 0x00, /* bInterval */
-
- /* Endpoint IN Descriptor */
- 0x07, /* bLength: Endpoint Descriptor size */
- USB_DESC_TYPE_ENDPOINT, /* bDescriptorType: Endpoint */
- CDC_IN_EP, /* bEndpointAddress */
- 0x02, /* bmAttributes: Bulk */
- LOBYTE(CDC_DATA_FS_MAX_PACKET_SIZE), /* wMaxPacketSize */
- HIBYTE(CDC_DATA_FS_MAX_PACKET_SIZE),
- 0x00 /* bInterval */
-};
-#endif /* USE_USBD_COMPOSITE */
-
-static uint8_t CDCInEpAdd = CDC_IN_EP;
-static uint8_t CDCOutEpAdd = CDC_OUT_EP;
-static uint8_t CDCCmdEpAdd = CDC_CMD_EP;
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_Private_Functions
- * @{
- */
-
-/**
- * @brief USBD_CDC_Init
- * Initialize the CDC interface
- * @param pdev: device instance
- * @param cfgidx: Configuration index
- * @retval status
- */
-static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
-{
- UNUSED(cfgidx);
- USBD_CDC_HandleTypeDef *hcdc;
-
- hcdc = (USBD_CDC_HandleTypeDef *)USBD_malloc(sizeof(USBD_CDC_HandleTypeDef));
-
- if (hcdc == NULL)
- {
- pdev->pClassDataCmsit[pdev->classId] = NULL;
- return (uint8_t)USBD_EMEM;
- }
-
- (void)USBD_memset(hcdc, 0, sizeof(USBD_CDC_HandleTypeDef));
-
- pdev->pClassDataCmsit[pdev->classId] = (void *)hcdc;
- pdev->pClassData = pdev->pClassDataCmsit[pdev->classId];
-
-#ifdef USE_USBD_COMPOSITE
- /* Get the Endpoints addresses allocated for this class instance */
- CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
- CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
- CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
-#endif /* USE_USBD_COMPOSITE */
-
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
- /* Open EP IN */
- (void)USBD_LL_OpenEP(pdev, CDCInEpAdd, USBD_EP_TYPE_BULK,
- CDC_DATA_HS_IN_PACKET_SIZE);
-
- pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 1U;
-
- /* Open EP OUT */
- (void)USBD_LL_OpenEP(pdev, CDCOutEpAdd, USBD_EP_TYPE_BULK,
- CDC_DATA_HS_OUT_PACKET_SIZE);
-
- pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 1U;
-
- /* Set bInterval for CDC CMD Endpoint */
- pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = CDC_HS_BINTERVAL;
- }
- else
- {
- /* Open EP IN */
- (void)USBD_LL_OpenEP(pdev, CDCInEpAdd, USBD_EP_TYPE_BULK,
- CDC_DATA_FS_IN_PACKET_SIZE);
-
- pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 1U;
-
- /* Open EP OUT */
- (void)USBD_LL_OpenEP(pdev, CDCOutEpAdd, USBD_EP_TYPE_BULK,
- CDC_DATA_FS_OUT_PACKET_SIZE);
-
- pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 1U;
-
- /* Set bInterval for CMD Endpoint */
- pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = CDC_FS_BINTERVAL;
- }
-
- /* Open Command IN EP */
- (void)USBD_LL_OpenEP(pdev, CDCCmdEpAdd, USBD_EP_TYPE_INTR, CDC_CMD_PACKET_SIZE);
- pdev->ep_in[CDCCmdEpAdd & 0xFU].is_used = 1U;
-
- hcdc->RxBuffer = NULL;
-
- /* Init physical Interface components */
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Init();
-
- /* Init Xfer states */
- hcdc->TxState = 0U;
- hcdc->RxState = 0U;
-
- if (hcdc->RxBuffer == NULL)
- {
- return (uint8_t)USBD_EMEM;
- }
-
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
- /* Prepare Out endpoint to receive next packet */
- (void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
- CDC_DATA_HS_OUT_PACKET_SIZE);
- }
- else
- {
- /* Prepare Out endpoint to receive next packet */
- (void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
- CDC_DATA_FS_OUT_PACKET_SIZE);
- }
-
- return (uint8_t)USBD_OK;
-}
-
-/**
- * @brief USBD_CDC_Init
- * DeInitialize the CDC layer
- * @param pdev: device instance
- * @param cfgidx: Configuration index
- * @retval status
- */
-static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
-{
- UNUSED(cfgidx);
-
-
-#ifdef USE_USBD_COMPOSITE
- /* Get the Endpoints addresses allocated for this CDC class instance */
- CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
- CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
- CDCCmdEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_INTR, (uint8_t)pdev->classId);
-#endif /* USE_USBD_COMPOSITE */
-
- /* Close EP IN */
- (void)USBD_LL_CloseEP(pdev, CDCInEpAdd);
- pdev->ep_in[CDCInEpAdd & 0xFU].is_used = 0U;
-
- /* Close EP OUT */
- (void)USBD_LL_CloseEP(pdev, CDCOutEpAdd);
- pdev->ep_out[CDCOutEpAdd & 0xFU].is_used = 0U;
-
- /* Close Command IN EP */
- (void)USBD_LL_CloseEP(pdev, CDCCmdEpAdd);
- pdev->ep_in[CDCCmdEpAdd & 0xFU].is_used = 0U;
- pdev->ep_in[CDCCmdEpAdd & 0xFU].bInterval = 0U;
-
- /* DeInit physical Interface components */
- if (pdev->pClassDataCmsit[pdev->classId] != NULL)
- {
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->DeInit();
- (void)USBD_free(pdev->pClassDataCmsit[pdev->classId]);
- pdev->pClassDataCmsit[pdev->classId] = NULL;
- pdev->pClassData = NULL;
- }
-
- return (uint8_t)USBD_OK;
-}
-
-/**
- * @brief USBD_CDC_Setup
- * Handle the CDC specific requests
- * @param pdev: instance
- * @param req: usb requests
- * @retval status
- */
-static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
- USBD_SetupReqTypedef *req)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
- uint16_t len;
- uint8_t ifalt = 0U;
- uint16_t status_info = 0U;
- USBD_StatusTypeDef ret = USBD_OK;
-
- if (hcdc == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- switch (req->bmRequest & USB_REQ_TYPE_MASK)
- {
- case USB_REQ_TYPE_CLASS:
- if (req->wLength != 0U)
- {
- if ((req->bmRequest & 0x80U) != 0U)
- {
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(req->bRequest,
- (uint8_t *)hcdc->data,
- req->wLength);
-
- len = MIN(CDC_REQ_MAX_DATA_SIZE, req->wLength);
- (void)USBD_CtlSendData(pdev, (uint8_t *)hcdc->data, len);
- }
- else
- {
- hcdc->CmdOpCode = req->bRequest;
- hcdc->CmdLength = (uint8_t)MIN(req->wLength, USB_MAX_EP0_SIZE);
-
- (void)USBD_CtlPrepareRx(pdev, (uint8_t *)hcdc->data, hcdc->CmdLength);
- }
- }
- else
- {
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(req->bRequest,
- (uint8_t *)req, 0U);
- }
- break;
-
- case USB_REQ_TYPE_STANDARD:
- switch (req->bRequest)
- {
- case USB_REQ_GET_STATUS:
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- (void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
- }
- else
- {
- USBD_CtlError(pdev, req);
- ret = USBD_FAIL;
- }
- break;
-
- case USB_REQ_GET_INTERFACE:
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- (void)USBD_CtlSendData(pdev, &ifalt, 1U);
- }
- else
- {
- USBD_CtlError(pdev, req);
- ret = USBD_FAIL;
- }
- break;
-
- case USB_REQ_SET_INTERFACE:
- if (pdev->dev_state != USBD_STATE_CONFIGURED)
- {
- USBD_CtlError(pdev, req);
- ret = USBD_FAIL;
- }
- break;
-
- case USB_REQ_CLEAR_FEATURE:
- break;
-
- default:
- USBD_CtlError(pdev, req);
- ret = USBD_FAIL;
- break;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- ret = USBD_FAIL;
- break;
- }
-
- return (uint8_t)ret;
-}
-
-/**
- * @brief USBD_CDC_DataIn
- * Data sent on non-control IN endpoint
- * @param pdev: device instance
- * @param epnum: endpoint number
- * @retval status
- */
-static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
-{
- USBD_CDC_HandleTypeDef *hcdc;
- PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *)pdev->pData;
-
- if (pdev->pClassDataCmsit[pdev->classId] == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-
- if ((pdev->ep_in[epnum & 0xFU].total_length > 0U) &&
- ((pdev->ep_in[epnum & 0xFU].total_length % hpcd->IN_ep[epnum & 0xFU].maxpacket) == 0U))
- {
- /* Update the packet total length */
- pdev->ep_in[epnum & 0xFU].total_length = 0U;
-
- /* Send ZLP */
- (void)USBD_LL_Transmit(pdev, epnum, NULL, 0U);
- }
- else
- {
- hcdc->TxState = 0U;
-
- if (((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt != NULL)
- {
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->TransmitCplt(hcdc->TxBuffer, &hcdc->TxLength, epnum);
- }
- }
-
- return (uint8_t)USBD_OK;
-}
-
-/**
- * @brief USBD_CDC_DataOut
- * Data received on non-control Out endpoint
- * @param pdev: device instance
- * @param epnum: endpoint number
- * @retval status
- */
-static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-
- if (pdev->pClassDataCmsit[pdev->classId] == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- /* Get the received data length */
- hcdc->RxLength = USBD_LL_GetRxDataSize(pdev, epnum);
-
- /* USB data will be immediately processed, this allow next USB traffic being
- NAKed till the end of the application Xfer */
-
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Receive(hcdc->RxBuffer, &hcdc->RxLength);
-
- return (uint8_t)USBD_OK;
-}
-
-/**
- * @brief USBD_CDC_EP0_RxReady
- * Handle EP0 Rx Ready event
- * @param pdev: device instance
- * @retval status
- */
-static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-
- if (hcdc == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- if ((pdev->pUserData[pdev->classId] != NULL) && (hcdc->CmdOpCode != 0xFFU))
- {
- ((USBD_CDC_ItfTypeDef *)pdev->pUserData[pdev->classId])->Control(hcdc->CmdOpCode,
- (uint8_t *)hcdc->data,
- (uint16_t)hcdc->CmdLength);
- hcdc->CmdOpCode = 0xFFU;
- }
-
- return (uint8_t)USBD_OK;
-}
-#ifndef USE_USBD_COMPOSITE
-/**
- * @brief USBD_CDC_GetFSCfgDesc
- * Return configuration descriptor
- * @param length : pointer data length
- * @retval pointer to descriptor buffer
- */
-static uint8_t *USBD_CDC_GetFSCfgDesc(uint16_t *length)
-{
- USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
- USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
- USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
-
- if (pEpCmdDesc != NULL)
- {
- pEpCmdDesc->bInterval = CDC_FS_BINTERVAL;
- }
-
- if (pEpOutDesc != NULL)
- {
- pEpOutDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
- }
-
- if (pEpInDesc != NULL)
- {
- pEpInDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
- }
-
- *length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
- return USBD_CDC_CfgDesc;
-}
-
-/**
- * @brief USBD_CDC_GetHSCfgDesc
- * Return configuration descriptor
- * @param length : pointer data length
- * @retval pointer to descriptor buffer
- */
-static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length)
-{
- USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
- USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
- USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
-
- if (pEpCmdDesc != NULL)
- {
- pEpCmdDesc->bInterval = CDC_HS_BINTERVAL;
- }
-
- if (pEpOutDesc != NULL)
- {
- pEpOutDesc->wMaxPacketSize = CDC_DATA_HS_MAX_PACKET_SIZE;
- }
-
- if (pEpInDesc != NULL)
- {
- pEpInDesc->wMaxPacketSize = CDC_DATA_HS_MAX_PACKET_SIZE;
- }
-
- *length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
- return USBD_CDC_CfgDesc;
-}
-
-/**
- * @brief USBD_CDC_GetOtherSpeedCfgDesc
- * Return configuration descriptor
- * @param length : pointer data length
- * @retval pointer to descriptor buffer
- */
-static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length)
-{
- USBD_EpDescTypeDef *pEpCmdDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_CMD_EP);
- USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_OUT_EP);
- USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_CDC_CfgDesc, CDC_IN_EP);
-
- if (pEpCmdDesc != NULL)
- {
- pEpCmdDesc->bInterval = CDC_FS_BINTERVAL;
- }
-
- if (pEpOutDesc != NULL)
- {
- pEpOutDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
- }
-
- if (pEpInDesc != NULL)
- {
- pEpInDesc->wMaxPacketSize = CDC_DATA_FS_MAX_PACKET_SIZE;
- }
-
- *length = (uint16_t)sizeof(USBD_CDC_CfgDesc);
- return USBD_CDC_CfgDesc;
-}
-
-/**
- * @brief USBD_CDC_GetDeviceQualifierDescriptor
- * return Device Qualifier descriptor
- * @param length : pointer data length
- * @retval pointer to descriptor buffer
- */
-uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length)
-{
- *length = (uint16_t)sizeof(USBD_CDC_DeviceQualifierDesc);
-
- return USBD_CDC_DeviceQualifierDesc;
-}
-#endif /* USE_USBD_COMPOSITE */
-/**
- * @brief USBD_CDC_RegisterInterface
- * @param pdev: device instance
- * @param fops: CD Interface callback
- * @retval status
- */
-uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev,
- USBD_CDC_ItfTypeDef *fops)
-{
- if (fops == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- pdev->pUserData[pdev->classId] = fops;
-
- return (uint8_t)USBD_OK;
-}
-
-
-/**
- * @brief USBD_CDC_SetTxBuffer
- * @param pdev: device instance
- * @param pbuff: Tx Buffer
- * @param length: length of data to be sent
- * @param ClassId: The Class ID
- * @retval status
- */
-#ifdef USE_USBD_COMPOSITE
-uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
- uint8_t *pbuff, uint32_t length, uint8_t ClassId)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
-#else
-uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
- uint8_t *pbuff, uint32_t length)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-#endif /* USE_USBD_COMPOSITE */
-
- if (hcdc == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- hcdc->TxBuffer = pbuff;
- hcdc->TxLength = length;
-
- return (uint8_t)USBD_OK;
-}
-
-/**
- * @brief USBD_CDC_SetRxBuffer
- * @param pdev: device instance
- * @param pbuff: Rx Buffer
- * @retval status
- */
-uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-
- if (hcdc == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- hcdc->RxBuffer = pbuff;
-
- return (uint8_t)USBD_OK;
-}
-
-
-/**
- * @brief USBD_CDC_TransmitPacket
- * Transmit packet on IN endpoint
- * @param pdev: device instance
- * @param ClassId: The Class ID
- * @retval status
- */
-#ifdef USE_USBD_COMPOSITE
-uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[ClassId];
-#else
-uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-#endif /* USE_USBD_COMPOSITE */
-
- USBD_StatusTypeDef ret = USBD_BUSY;
-
-#ifdef USE_USBD_COMPOSITE
- /* Get the Endpoints addresses allocated for this class instance */
- CDCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, ClassId);
-#endif /* USE_USBD_COMPOSITE */
-
- if (hcdc == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- if (hcdc->TxState == 0U)
- {
- /* Tx Transfer in progress */
- hcdc->TxState = 1U;
-
- /* Update the packet total length */
- pdev->ep_in[CDCInEpAdd & 0xFU].total_length = hcdc->TxLength;
-
- /* Transmit next packet */
- (void)USBD_LL_Transmit(pdev, CDCInEpAdd, hcdc->TxBuffer, hcdc->TxLength);
-
- ret = USBD_OK;
- }
-
- return (uint8_t)ret;
-}
-
-/**
- * @brief USBD_CDC_ReceivePacket
- * prepare OUT Endpoint for reception
- * @param pdev: device instance
- * @retval status
- */
-uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
-{
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
-
-#ifdef USE_USBD_COMPOSITE
- /* Get the Endpoints addresses allocated for this class instance */
- CDCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
-#endif /* USE_USBD_COMPOSITE */
-
- if (pdev->pClassDataCmsit[pdev->classId] == NULL)
- {
- return (uint8_t)USBD_FAIL;
- }
-
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
- /* Prepare Out endpoint to receive next packet */
- (void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
- CDC_DATA_HS_OUT_PACKET_SIZE);
- }
- else
- {
- /* Prepare Out endpoint to receive next packet */
- (void)USBD_LL_PrepareReceive(pdev, CDCOutEpAdd, hcdc->RxBuffer,
- CDC_DATA_FS_OUT_PACKET_SIZE);
- }
-
- return (uint8_t)USBD_OK;
-}
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_core.h
- * @author MCD Application Team
- * @brief Header file for usbd_core.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 __USBD_CORE_H
-#define __USBD_CORE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_conf.h"
-#include "usbd_def.h"
-#include "usbd_ioreq.h"
-#include "usbd_ctlreq.h"
-
-/** @addtogroup STM32_USB_DEVICE_LIBRARY
- * @{
- */
-
-/** @defgroup USBD_CORE
- * @brief This file is the Header file for usbd_core.c file
- * @{
- */
-
-
-/** @defgroup USBD_CORE_Exported_Defines
- * @{
- */
-#ifndef USBD_DEBUG_LEVEL
-#define USBD_DEBUG_LEVEL 0U
-#endif /* USBD_DEBUG_LEVEL */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CORE_Exported_TypesDefinitions
- * @{
- */
-
-
-/**
- * @}
- */
-
-
-
-/** @defgroup USBD_CORE_Exported_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CORE_Exported_Variables
- * @{
- */
-#define USBD_SOF USBD_LL_SOF
-/**
- * @}
- */
-
-/** @defgroup USBD_CORE_Exported_FunctionsPrototype
- * @{
- */
-USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
-USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
-#if (USBD_USER_REGISTER_CALLBACK == 1U)
-USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback);
-#endif /* USBD_USER_REGISTER_CALLBACK */
-
-#ifdef USE_USBD_COMPOSITE
-USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
- USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr);
-
-USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev);
-uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId);
-#endif /* USE_USBD_COMPOSITE */
-
-uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index);
-uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index);
-
-USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
-USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
-
-USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
-USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
-USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
-
-USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
-USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
-
-USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
-USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
-
-USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
-
-/* USBD Low Level Driver */
-USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
-
-USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
- uint8_t ep_type, uint16_t ep_mps);
-
-USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
-
-USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
- uint8_t *pbuf, uint32_t size);
-
-USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
- uint8_t *pbuf, uint32_t size);
-
-#ifdef USBD_HS_TESTMODE_ENABLE
-USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode);
-#endif /* USBD_HS_TESTMODE_ENABLE */
-
-uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-
-void USBD_LL_Delay(uint32_t Delay);
-
-void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr);
-USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_CORE_H */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_req.h
- * @author MCD Application Team
- * @brief Header file for the usbd_req.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_REQUEST_H
-#define __USB_REQUEST_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_def.h"
-
-
-/** @addtogroup STM32_USB_DEVICE_LIBRARY
- * @{
- */
-
-/** @defgroup USBD_REQ
- * @brief header file for the usbd_req.c file
- * @{
- */
-
-/** @defgroup USBD_REQ_Exported_Defines
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Exported_Types
- * @{
- */
-/**
- * @}
- */
-
-
-
-/** @defgroup USBD_REQ_Exported_Macros
- * @{
- */
-/**
- * @}
- */
-
-/** @defgroup USBD_REQ_Exported_Variables
- * @{
- */
-/**
- * @}
- */
-
-/** @defgroup USBD_REQ_Exported_FunctionsPrototype
- * @{
- */
-
-USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-
-void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
-void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USB_REQUEST_H */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_def.h
- * @author MCD Application Team
- * @brief General defines for the usb device library
- ******************************************************************************
- * @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 __USBD_DEF_H
-#define __USBD_DEF_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_conf.h"
-
-/** @addtogroup STM32_USBD_DEVICE_LIBRARY
- * @{
- */
-
-/** @defgroup USB_DEF
- * @brief general defines for the usb device library file
- * @{
- */
-
-/** @defgroup USB_DEF_Exported_Defines
- * @{
- */
-
-#ifndef NULL
-#define NULL 0U
-#endif /* NULL */
-
-#ifndef USBD_MAX_NUM_INTERFACES
-#define USBD_MAX_NUM_INTERFACES 1U
-#endif /* USBD_MAX_NUM_CONFIGURATION */
-
-#ifndef USBD_MAX_NUM_CONFIGURATION
-#define USBD_MAX_NUM_CONFIGURATION 1U
-#endif /* USBD_MAX_NUM_CONFIGURATION */
-
-#ifdef USE_USBD_COMPOSITE
-#ifndef USBD_MAX_SUPPORTED_CLASS
-#define USBD_MAX_SUPPORTED_CLASS 4U
-#endif /* USBD_MAX_SUPPORTED_CLASS */
-#else
-#ifndef USBD_MAX_SUPPORTED_CLASS
-#define USBD_MAX_SUPPORTED_CLASS 1U
-#endif /* USBD_MAX_SUPPORTED_CLASS */
-#endif /* USE_USBD_COMPOSITE */
-
-#ifndef USBD_MAX_CLASS_ENDPOINTS
-#define USBD_MAX_CLASS_ENDPOINTS 5U
-#endif /* USBD_MAX_CLASS_ENDPOINTS */
-
-#ifndef USBD_MAX_CLASS_INTERFACES
-#define USBD_MAX_CLASS_INTERFACES 5U
-#endif /* USBD_MAX_CLASS_INTERFACES */
-
-#ifndef USBD_LPM_ENABLED
-#define USBD_LPM_ENABLED 0U
-#endif /* USBD_LPM_ENABLED */
-
-#ifndef USBD_SELF_POWERED
-#define USBD_SELF_POWERED 1U
-#endif /*USBD_SELF_POWERED */
-
-#ifndef USBD_MAX_POWER
-#define USBD_MAX_POWER 0x32U /* 100 mA */
-#endif /* USBD_MAX_POWER */
-
-#ifndef USBD_SUPPORT_USER_STRING_DESC
-#define USBD_SUPPORT_USER_STRING_DESC 0U
-#endif /* USBD_SUPPORT_USER_STRING_DESC */
-
-#ifndef USBD_CLASS_USER_STRING_DESC
-#define USBD_CLASS_USER_STRING_DESC 0U
-#endif /* USBD_CLASS_USER_STRING_DESC */
-
-#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
-#define USB_LEN_DEV_DESC 0x12U
-#define USB_LEN_CFG_DESC 0x09U
-#define USB_LEN_IF_DESC 0x09U
-#define USB_LEN_EP_DESC 0x07U
-#define USB_LEN_OTG_DESC 0x03U
-#define USB_LEN_LANGID_STR_DESC 0x04U
-#define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U
-
-#define USBD_IDX_LANGID_STR 0x00U
-#define USBD_IDX_MFC_STR 0x01U
-#define USBD_IDX_PRODUCT_STR 0x02U
-#define USBD_IDX_SERIAL_STR 0x03U
-#define USBD_IDX_CONFIG_STR 0x04U
-#define USBD_IDX_INTERFACE_STR 0x05U
-
-#define USB_REQ_TYPE_STANDARD 0x00U
-#define USB_REQ_TYPE_CLASS 0x20U
-#define USB_REQ_TYPE_VENDOR 0x40U
-#define USB_REQ_TYPE_MASK 0x60U
-
-#define USB_REQ_RECIPIENT_DEVICE 0x00U
-#define USB_REQ_RECIPIENT_INTERFACE 0x01U
-#define USB_REQ_RECIPIENT_ENDPOINT 0x02U
-#define USB_REQ_RECIPIENT_MASK 0x03U
-
-#define USB_REQ_GET_STATUS 0x00U
-#define USB_REQ_CLEAR_FEATURE 0x01U
-#define USB_REQ_SET_FEATURE 0x03U
-#define USB_REQ_SET_ADDRESS 0x05U
-#define USB_REQ_GET_DESCRIPTOR 0x06U
-#define USB_REQ_SET_DESCRIPTOR 0x07U
-#define USB_REQ_GET_CONFIGURATION 0x08U
-#define USB_REQ_SET_CONFIGURATION 0x09U
-#define USB_REQ_GET_INTERFACE 0x0AU
-#define USB_REQ_SET_INTERFACE 0x0BU
-#define USB_REQ_SYNCH_FRAME 0x0CU
-
-#define USB_DESC_TYPE_DEVICE 0x01U
-#define USB_DESC_TYPE_CONFIGURATION 0x02U
-#define USB_DESC_TYPE_STRING 0x03U
-#define USB_DESC_TYPE_INTERFACE 0x04U
-#define USB_DESC_TYPE_ENDPOINT 0x05U
-#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
-#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
-#define USB_DESC_TYPE_IAD 0x0BU
-#define USB_DESC_TYPE_BOS 0x0FU
-
-#define USB_CONFIG_REMOTE_WAKEUP 0x02U
-#define USB_CONFIG_SELF_POWERED 0x01U
-
-#define USB_FEATURE_EP_HALT 0x00U
-#define USB_FEATURE_REMOTE_WAKEUP 0x01U
-#define USB_FEATURE_TEST_MODE 0x02U
-
-#define USB_DEVICE_CAPABITY_TYPE 0x10U
-
-#define USB_CONF_DESC_SIZE 0x09U
-#define USB_IF_DESC_SIZE 0x09U
-#define USB_EP_DESC_SIZE 0x07U
-#define USB_IAD_DESC_SIZE 0x08U
-
-#define USB_HS_MAX_PACKET_SIZE 512U
-#define USB_FS_MAX_PACKET_SIZE 64U
-#define USB_MAX_EP0_SIZE 64U
-
-/* Device Status */
-#define USBD_STATE_DEFAULT 0x01U
-#define USBD_STATE_ADDRESSED 0x02U
-#define USBD_STATE_CONFIGURED 0x03U
-#define USBD_STATE_SUSPENDED 0x04U
-
-
-/* EP0 State */
-#define USBD_EP0_IDLE 0x00U
-#define USBD_EP0_SETUP 0x01U
-#define USBD_EP0_DATA_IN 0x02U
-#define USBD_EP0_DATA_OUT 0x03U
-#define USBD_EP0_STATUS_IN 0x04U
-#define USBD_EP0_STATUS_OUT 0x05U
-#define USBD_EP0_STALL 0x06U
-
-#define USBD_EP_TYPE_CTRL 0x00U
-#define USBD_EP_TYPE_ISOC 0x01U
-#define USBD_EP_TYPE_BULK 0x02U
-#define USBD_EP_TYPE_INTR 0x03U
-
-#ifdef USE_USBD_COMPOSITE
-#define USBD_EP_IN 0x80U
-#define USBD_EP_OUT 0x00U
-#define USBD_FUNC_DESCRIPTOR_TYPE 0x24U
-#define USBD_DESC_SUBTYPE_ACM 0x0FU
-#define USBD_DESC_ECM_BCD_LOW 0x00U
-#define USBD_DESC_ECM_BCD_HIGH 0x10U
-#endif /* USE_USBD_COMPOSITE */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_DEF_Exported_TypesDefinitions
- * @{
- */
-
-typedef struct usb_setup_req
-{
- uint8_t bmRequest;
- uint8_t bRequest;
- uint16_t wValue;
- uint16_t wIndex;
- uint16_t wLength;
-} USBD_SetupReqTypedef;
-
-typedef struct
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wTotalLength;
- uint8_t bNumInterfaces;
- uint8_t bConfigurationValue;
- uint8_t iConfiguration;
- uint8_t bmAttributes;
- uint8_t bMaxPower;
-} __PACKED USBD_ConfigDescTypeDef;
-
-typedef struct
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wTotalLength;
- uint8_t bNumDeviceCaps;
-} USBD_BosDescTypeDef;
-
-typedef struct
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bEndpointAddress;
- uint8_t bmAttributes;
- uint16_t wMaxPacketSize;
- uint8_t bInterval;
-} __PACKED USBD_EpDescTypeDef;
-
-typedef struct
-{
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bDescriptorSubType;
-} USBD_DescHeaderTypeDef;
-
-struct _USBD_HandleTypeDef;
-
-typedef struct _Device_cb
-{
- uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
- uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
- /* Control Endpoints*/
- uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
- uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev);
- uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev);
- /* Class Specific Endpoints*/
- uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
- uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
- uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev);
- uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
- uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
-
- uint8_t *(*GetHSConfigDescriptor)(uint16_t *length);
- uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
- uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
- uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
-#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
- uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length);
-#endif /* USBD_SUPPORT_USER_STRING_DESC */
-
-} USBD_ClassTypeDef;
-
-/* Following USB Device Speed */
-typedef enum
-{
- USBD_SPEED_HIGH = 0U,
- USBD_SPEED_FULL = 1U,
- USBD_SPEED_LOW = 2U,
-} USBD_SpeedTypeDef;
-
-/* Following USB Device status */
-typedef enum
-{
- USBD_OK = 0U,
- USBD_BUSY,
- USBD_EMEM,
- USBD_FAIL,
-} USBD_StatusTypeDef;
-
-/* USB Device descriptors structure */
-typedef struct
-{
- uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
- uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
-#if (USBD_CLASS_USER_STRING_DESC == 1)
- uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
-#endif /* USBD_CLASS_USER_STRING_DESC */
-#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1))
- uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
-#endif /* (USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1) */
-} USBD_DescriptorsTypeDef;
-
-/* USB Device handle structure */
-typedef struct
-{
- uint32_t status;
- uint32_t total_length;
- uint32_t rem_length;
- uint32_t maxpacket;
- uint16_t is_used;
- uint16_t bInterval;
-} USBD_EndpointTypeDef;
-
-#ifdef USE_USBD_COMPOSITE
-typedef enum
-{
- CLASS_TYPE_NONE = 0,
- CLASS_TYPE_HID = 1,
- CLASS_TYPE_CDC = 2,
- CLASS_TYPE_MSC = 3,
- CLASS_TYPE_DFU = 4,
- CLASS_TYPE_CHID = 5,
- CLASS_TYPE_AUDIO = 6,
- CLASS_TYPE_ECM = 7,
- CLASS_TYPE_RNDIS = 8,
- CLASS_TYPE_MTP = 9,
- CLASS_TYPE_VIDEO = 10,
- CLASS_TYPE_PRINTER = 11,
- CLASS_TYPE_CCID = 12,
-} USBD_CompositeClassTypeDef;
-
-
-/* USB Device handle structure */
-typedef struct
-{
- uint8_t add;
- uint8_t type;
- uint8_t size;
- uint8_t is_used;
-} USBD_EPTypeDef;
-
-/* USB Device handle structure */
-typedef struct
-{
- USBD_CompositeClassTypeDef ClassType;
- uint32_t ClassId;
- uint32_t Active;
- uint32_t NumEps;
- USBD_EPTypeDef Eps[USBD_MAX_CLASS_ENDPOINTS];
- uint8_t *EpAdd;
- uint32_t NumIf;
- uint8_t Ifs[USBD_MAX_CLASS_INTERFACES];
- uint32_t CurrPcktSze;
-} USBD_CompositeElementTypeDef;
-#endif /* USE_USBD_COMPOSITE */
-
-/* USB Device handle structure */
-typedef struct _USBD_HandleTypeDef
-{
- uint8_t id;
- uint32_t dev_config;
- uint32_t dev_default_config;
- uint32_t dev_config_status;
- USBD_SpeedTypeDef dev_speed;
- USBD_EndpointTypeDef ep_in[16];
- USBD_EndpointTypeDef ep_out[16];
- __IO uint32_t ep0_state;
- uint32_t ep0_data_len;
- __IO uint8_t dev_state;
- __IO uint8_t dev_old_state;
- uint8_t dev_address;
- uint8_t dev_connection_status;
- uint8_t dev_test_mode;
- uint32_t dev_remote_wakeup;
- uint8_t ConfIdx;
-
- USBD_SetupReqTypedef request;
- USBD_DescriptorsTypeDef *pDesc;
- USBD_ClassTypeDef *pClass[USBD_MAX_SUPPORTED_CLASS];
- void *pClassData;
- void *pClassDataCmsit[USBD_MAX_SUPPORTED_CLASS];
- void *pUserData[USBD_MAX_SUPPORTED_CLASS];
- void *pData;
- void *pBosDesc;
- void *pConfDesc;
- uint32_t classId;
- uint32_t NumClasses;
-#ifdef USE_USBD_COMPOSITE
- USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS];
-#endif /* USE_USBD_COMPOSITE */
-#if (USBD_USER_REGISTER_CALLBACK == 1U)
- void (* DevStateCallback)(uint8_t dev_state, uint8_t cfgidx); /*!< User Notification callback */
-#endif /* USBD_USER_REGISTER_CALLBACK */
-} USBD_HandleTypeDef;
-
-#if (USBD_USER_REGISTER_CALLBACK == 1U)
-typedef void (*USBD_DevStateCallbackTypeDef)(uint8_t dev_state, uint8_t cfgidx); /*!< pointer to User callback function */
-#endif /* USBD_USER_REGISTER_CALLBACK */
-
-/* USB Device endpoint direction */
-typedef enum
-{
- OUT = 0x00,
- IN = 0x80,
-} USBD_EPDirectionTypeDef;
-
-typedef enum
-{
- NETWORK_CONNECTION = 0x00,
- RESPONSE_AVAILABLE = 0x01,
- CONNECTION_SPEED_CHANGE = 0x2A
-} USBD_CDC_NotifCodeTypeDef;
-/**
- * @}
- */
-
-
-
-/** @defgroup USBD_DEF_Exported_Macros
- * @{
- */
-__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
-{
- uint16_t _SwapVal;
- uint16_t _Byte1;
- uint16_t _Byte2;
- uint8_t *_pbuff = addr;
-
- _Byte1 = *(uint8_t *)_pbuff;
- _pbuff++;
- _Byte2 = *(uint8_t *)_pbuff;
-
- _SwapVal = (_Byte2 << 8) | _Byte1;
-
- return _SwapVal;
-}
-
-#ifndef LOBYTE
-#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
-#endif /* LOBYTE */
-
-#ifndef HIBYTE
-#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
-#endif /* HIBYTE */
-
-#ifndef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif /* MIN */
-
-#ifndef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif /* MAX */
-
-#if defined ( __GNUC__ )
-#ifndef __weak
-#define __weak __attribute__((weak))
-#endif /* __weak */
-#ifndef __packed
-#define __packed __attribute__((__packed__))
-#endif /* __packed */
-#endif /* __GNUC__ */
-
-
-/* In HS mode and when the DMA is used, all variables and data structures dealing
- with the DMA during the transaction process should be 4-bytes aligned */
-
-#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
-#ifndef __ALIGN_END
-#define __ALIGN_END __attribute__ ((aligned (4U)))
-#endif /* __ALIGN_END */
-#ifndef __ALIGN_BEGIN
-#define __ALIGN_BEGIN
-#endif /* __ALIGN_BEGIN */
-#else
-#ifndef __ALIGN_END
-#define __ALIGN_END
-#endif /* __ALIGN_END */
-#ifndef __ALIGN_BEGIN
-#if defined (__CC_ARM) /* ARM Compiler */
-#define __ALIGN_BEGIN __align(4U)
-#elif defined (__ICCARM__) /* IAR Compiler */
-#define __ALIGN_BEGIN
-#endif /* __CC_ARM */
-#endif /* __ALIGN_BEGIN */
-#endif /* __GNUC__ */
-
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DEF_Exported_Variables
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DEF_Exported_FunctionsPrototype
- * @{
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_DEF_H */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_ioreq.h
- * @author MCD Application Team
- * @brief Header file for the usbd_ioreq.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 __USBD_IOREQ_H
-#define __USBD_IOREQ_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_def.h"
-#include "usbd_core.h"
-
-/** @addtogroup STM32_USB_DEVICE_LIBRARY
- * @{
- */
-
-/** @defgroup USBD_IOREQ
- * @brief header file for the usbd_ioreq.c file
- * @{
- */
-
-/** @defgroup USBD_IOREQ_Exported_Defines
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Exported_Types
- * @{
- */
-
-
-/**
- * @}
- */
-
-
-
-/** @defgroup USBD_IOREQ_Exported_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_IOREQ_Exported_Variables
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
- * @{
- */
-
-USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len);
-
-USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len);
-
-USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len);
-
-USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len);
-
-USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
-USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
-
-uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_IOREQ_H */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_core.c
- * @author MCD Application Team
- * @brief This file provides all the USBD core functions.
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_core.h"
-
-#ifdef USE_USBD_COMPOSITE
-#include "usbd_composite_builder.h"
-#endif /* USE_USBD_COMPOSITE */
-
-/** @addtogroup STM32_USBD_DEVICE_LIBRARY
- * @{
- */
-
-
-/** @defgroup USBD_CORE
- * @brief usbd core module
- * @{
- */
-
-/** @defgroup USBD_CORE_Private_TypesDefinitions
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CORE_Private_Defines
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CORE_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CORE_Private_FunctionPrototypes
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CORE_Private_Variables
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_CORE_Private_Functions
- * @{
- */
-
-/**
- * @brief USBD_Init
- * Initialize the device stack and load the class driver
- * @param pdev: device instance
- * @param pdesc: Descriptor structure address
- * @param id: Low level core index
- * @retval status: USBD Status
- */
-USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
- USBD_DescriptorsTypeDef *pdesc, uint8_t id)
-{
- USBD_StatusTypeDef ret;
-
- /* Check whether the USB Host handle is valid */
- if (pdev == NULL)
- {
-#if (USBD_DEBUG_LEVEL > 1U)
- USBD_ErrLog("Invalid Device handle");
-#endif /* (USBD_DEBUG_LEVEL > 1U) */
- return USBD_FAIL;
- }
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Unlink previous class*/
- pdev->pClass[i] = NULL;
- pdev->pUserData[i] = NULL;
-
- /* Set class as inactive */
- pdev->tclasslist[i].Active = 0;
- pdev->NumClasses = 0;
- pdev->classId = 0;
- }
-#else
- /* Unlink previous class*/
- pdev->pClass[0] = NULL;
- pdev->pUserData[0] = NULL;
-#endif /* USE_USBD_COMPOSITE */
-
- pdev->pConfDesc = NULL;
-
- /* Assign USBD Descriptors */
- if (pdesc != NULL)
- {
- pdev->pDesc = pdesc;
- }
-
- /* Set Device initial State */
- pdev->dev_state = USBD_STATE_DEFAULT;
- pdev->id = id;
-
- /* Initialize low level driver */
- ret = USBD_LL_Init(pdev);
-
- return ret;
-}
-
-/**
- * @brief USBD_DeInit
- * De-Initialize the device library
- * @param pdev: device instance
- * @retval status: USBD Status
- */
-USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
-{
- USBD_StatusTypeDef ret;
-
- /* Disconnect the USB Device */
- (void)USBD_LL_Stop(pdev);
-
- /* Set Default State */
- pdev->dev_state = USBD_STATE_DEFAULT;
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Free Class Resources */
- pdev->pClass[i]->DeInit(pdev, (uint8_t)pdev->dev_config);
- }
- }
- }
-#else
- /* Free Class Resources */
- if (pdev->pClass[0] != NULL)
- {
- pdev->pClass[0]->DeInit(pdev, (uint8_t)pdev->dev_config);
- }
-
- pdev->pUserData[0] = NULL;
-
-#endif /* USE_USBD_COMPOSITE */
-
- /* Free Device descriptors resources */
- pdev->pDesc = NULL;
- pdev->pConfDesc = NULL;
-
- /* DeInitialize low level driver */
- ret = USBD_LL_DeInit(pdev);
-
- return ret;
-}
-
-/**
- * @brief USBD_RegisterClass
- * Link class driver to Device Core.
- * @param pdev: Device Handle
- * @param pclass: Class handle
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass)
-{
- uint16_t len = 0U;
-
- if (pclass == NULL)
- {
-#if (USBD_DEBUG_LEVEL > 1U)
- USBD_ErrLog("Invalid Class handle");
-#endif /* (USBD_DEBUG_LEVEL > 1U) */
- return USBD_FAIL;
- }
-
- /* link the class to the USB Device handle */
- pdev->pClass[0] = pclass;
-
- /* Get Device Configuration Descriptor */
-#ifdef USE_USB_HS
- if (pdev->pClass[pdev->classId]->GetHSConfigDescriptor != NULL)
- {
- pdev->pConfDesc = (void *)pdev->pClass[pdev->classId]->GetHSConfigDescriptor(&len);
- }
-#else /* Default USE_USB_FS */
- if (pdev->pClass[pdev->classId]->GetFSConfigDescriptor != NULL)
- {
- pdev->pConfDesc = (void *)pdev->pClass[pdev->classId]->GetFSConfigDescriptor(&len);
- }
-#endif /* USE_USB_FS */
-
- /* Increment the NumClasses */
- pdev->NumClasses++;
-
- return USBD_OK;
-}
-
-#ifdef USE_USBD_COMPOSITE
-/**
- * @brief USBD_RegisterClassComposite
- * Link class driver to Device Core.
- * @param pdev : Device Handle
- * @param pclass: Class handle
- * @param classtype: Class type
- * @param EpAddr: Endpoint Address handle
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass,
- USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr)
-{
- USBD_StatusTypeDef ret = USBD_OK;
- uint16_t len = 0U;
-
- if ((pdev->classId < USBD_MAX_SUPPORTED_CLASS) && (pdev->NumClasses < USBD_MAX_SUPPORTED_CLASS))
- {
- if ((uint32_t)pclass != 0U)
- {
- /* Link the class to the USB Device handle */
- pdev->pClass[pdev->classId] = pclass;
- ret = USBD_OK;
-
- pdev->tclasslist[pdev->classId].EpAdd = EpAddr;
-
- /* Call the composite class builder */
- (void)USBD_CMPSIT_AddClass(pdev, pclass, classtype, 0);
-
- /* Increment the ClassId for the next occurrence */
- pdev->classId ++;
- pdev->NumClasses ++;
- }
- else
- {
-#if (USBD_DEBUG_LEVEL > 1U)
- USBD_ErrLog("Invalid Class handle");
-#endif /* (USBD_DEBUG_LEVEL > 1U) */
- ret = USBD_FAIL;
- }
- }
-
- if (ret == USBD_OK)
- {
- /* Get Device Configuration Descriptor */
-#ifdef USE_USB_HS
- pdev->pConfDesc = USBD_CMPSIT.GetHSConfigDescriptor(&len);
-#else /* Default USE_USB_FS */
- pdev->pConfDesc = USBD_CMPSIT.GetFSConfigDescriptor(&len);
-#endif /* USE_USB_FS */
- }
-
- return ret;
-}
-
-/**
- * @brief USBD_UnRegisterClassComposite
- * UnLink all composite class drivers from Device Core.
- * @param pdev: Device Handle
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev)
-{
- USBD_StatusTypeDef ret = USBD_FAIL;
- uint8_t idx1;
- uint8_t idx2;
-
- /* Unroll all activated classes */
- for (idx1 = 0; idx1 < pdev->NumClasses; idx1++)
- {
- /* Check if the class correspond to the requested type and if it is active */
- if (pdev->tclasslist[idx1].Active == 1U)
- {
- /* Set the new class ID */
- pdev->classId = idx1;
-
- /* Free resources used by the selected class */
- if (pdev->pClass[pdev->classId] != NULL)
- {
- /* Free Class Resources */
- if (pdev->pClass[pdev->classId]->DeInit(pdev, (uint8_t)pdev->dev_config) != 0U)
- {
-#if (USBD_DEBUG_LEVEL > 1U)
- USBD_ErrLog("Class DeInit didn't succeed!, can't unregister selected class");
-#endif /* (USBD_DEBUG_LEVEL > 1U) */
-
- ret = USBD_FAIL;
- }
- }
-
- /* Free the class pointer */
- pdev->pClass[pdev->classId] = NULL;
-
- /* Free the class location in classes table and reset its parameters to zero */
- pdev->tclasslist[pdev->classId].ClassType = CLASS_TYPE_NONE;
- pdev->tclasslist[pdev->classId].ClassId = 0U;
- pdev->tclasslist[pdev->classId].Active = 0U;
- pdev->tclasslist[pdev->classId].NumEps = 0U;
- pdev->tclasslist[pdev->classId].NumIf = 0U;
- pdev->tclasslist[pdev->classId].CurrPcktSze = 0U;
-
- for (idx2 = 0U; idx2 < USBD_MAX_CLASS_ENDPOINTS; idx2++)
- {
- pdev->tclasslist[pdev->classId].Eps[idx2].add = 0U;
- pdev->tclasslist[pdev->classId].Eps[idx2].type = 0U;
- pdev->tclasslist[pdev->classId].Eps[idx2].size = 0U;
- pdev->tclasslist[pdev->classId].Eps[idx2].is_used = 0U;
- }
-
- for (idx2 = 0U; idx2 < USBD_MAX_CLASS_INTERFACES; idx2++)
- {
- pdev->tclasslist[pdev->classId].Ifs[idx2] = 0U;
- }
- }
- }
-
- /* Reset the configuration descriptor */
- (void)USBD_CMPST_ClearConfDesc(pdev);
-
- /* Reset the class ID and number of classes */
- pdev->classId = 0U;
- pdev->NumClasses = 0U;
-
- return ret;
-}
-#endif /* USE_USBD_COMPOSITE */
-
-#if (USBD_USER_REGISTER_CALLBACK == 1U)
-/**
- * @brief USBD_RegisterDevStateCallback
- * @param pdev : Device Handle
- * @param pUserCallback: User Callback
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_RegisterDevStateCallback(USBD_HandleTypeDef *pdev, USBD_DevStateCallbackTypeDef pUserCallback)
-{
- pdev->DevStateCallback = pUserCallback;
-
- return USBD_OK;
-}
-#endif /* USBD_USER_REGISTER_CALLBACK */
-
-/**
- * @brief USBD_Start
- * Start the USB Device Core.
- * @param pdev: Device Handle
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev)
-{
-#ifdef USE_USBD_COMPOSITE
- pdev->classId = 0U;
-#endif /* USE_USBD_COMPOSITE */
-
- /* Start the low level driver */
- return USBD_LL_Start(pdev);
-}
-
-/**
- * @brief USBD_Stop
- * Stop the USB Device Core.
- * @param pdev: Device Handle
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev)
-{
- /* Disconnect USB Device */
- (void)USBD_LL_Stop(pdev);
-
- /* Free Class Resources */
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Free Class Resources */
- (void)pdev->pClass[i]->DeInit(pdev, (uint8_t)pdev->dev_config);
- }
- }
- }
-
- /* Reset the class ID */
- pdev->classId = 0U;
-#else
- if (pdev->pClass[0] != NULL)
- {
- (void)pdev->pClass[0]->DeInit(pdev, (uint8_t)pdev->dev_config);
- }
-#endif /* USE_USBD_COMPOSITE */
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_RunTestMode
- * Launch test mode process
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev)
-{
-#ifdef USBD_HS_TESTMODE_ENABLE
- USBD_StatusTypeDef ret;
-
- /* Run USB HS test mode */
- ret = USBD_LL_SetTestMode(pdev, pdev->dev_test_mode);
-
- return ret;
-#else
- /* Prevent unused argument compilation warning */
- UNUSED(pdev);
-
- return USBD_OK;
-#endif /* USBD_HS_TESTMODE_ENABLE */
-}
-
-/**
- * @brief USBD_SetClassConfig
- * Configure device and start the interface
- * @param pdev: device instance
- * @param cfgidx: configuration index
- * @retval status
- */
-
-USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
-{
- USBD_StatusTypeDef ret = USBD_OK;
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Set configuration and Start the Class*/
- if (pdev->pClass[i]->Init(pdev, cfgidx) != 0U)
- {
- ret = USBD_FAIL;
- }
- }
- }
- }
-#else
- if (pdev->pClass[0] != NULL)
- {
- /* Set configuration and Start the Class */
- ret = (USBD_StatusTypeDef)pdev->pClass[0]->Init(pdev, cfgidx);
- }
-#endif /* USE_USBD_COMPOSITE */
-
- return ret;
-}
-
-/**
- * @brief USBD_ClrClassConfig
- * Clear current configuration
- * @param pdev: device instance
- * @param cfgidx: configuration index
- * @retval status
- */
-USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
-{
- USBD_StatusTypeDef ret = USBD_OK;
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Clear configuration and De-initialize the Class process */
- if (pdev->pClass[i]->DeInit(pdev, cfgidx) != 0U)
- {
- ret = USBD_FAIL;
- }
- }
- }
- }
-#else
- /* Clear configuration and De-initialize the Class process */
- if (pdev->pClass[0]->DeInit(pdev, cfgidx) != 0U)
- {
- ret = USBD_FAIL;
- }
-#endif /* USE_USBD_COMPOSITE */
-
- return ret;
-}
-
-
-/**
- * @brief USBD_LL_SetupStage
- * Handle the setup stage
- * @param pdev: device instance
- * @param psetup: setup packet buffer pointer
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
-{
- USBD_StatusTypeDef ret;
-
- USBD_ParseSetupRequest(&pdev->request, psetup);
-
- pdev->ep0_state = USBD_EP0_SETUP;
-
- pdev->ep0_data_len = pdev->request.wLength;
-
- switch (pdev->request.bmRequest & 0x1FU)
- {
- case USB_REQ_RECIPIENT_DEVICE:
- ret = USBD_StdDevReq(pdev, &pdev->request);
- break;
-
- case USB_REQ_RECIPIENT_INTERFACE:
- ret = USBD_StdItfReq(pdev, &pdev->request);
- break;
-
- case USB_REQ_RECIPIENT_ENDPOINT:
- ret = USBD_StdEPReq(pdev, &pdev->request);
- break;
-
- default:
- ret = USBD_LL_StallEP(pdev, (pdev->request.bmRequest & 0x80U));
- break;
- }
-
- return ret;
-}
-
-/**
- * @brief USBD_LL_DataOutStage
- * Handle data OUT stage
- * @param pdev: device instance
- * @param epnum: endpoint index
- * @param pdata: data pointer
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
- uint8_t epnum, uint8_t *pdata)
-{
- USBD_EndpointTypeDef *pep;
- USBD_StatusTypeDef ret = USBD_OK;
- uint8_t idx;
-
- if (epnum == 0U)
- {
- pep = &pdev->ep_out[0];
-
- if (pdev->ep0_state == USBD_EP0_DATA_OUT)
- {
- if (pep->rem_length > pep->maxpacket)
- {
- pep->rem_length -= pep->maxpacket;
-
- (void)USBD_CtlContinueRx(pdev, pdata, MIN(pep->rem_length, pep->maxpacket));
- }
- else
- {
- /* Find the class ID relative to the current request */
- switch (pdev->request.bmRequest & 0x1FU)
- {
- case USB_REQ_RECIPIENT_DEVICE:
- /* Device requests must be managed by the first instantiated class
- (or duplicated by all classes for simplicity) */
- idx = 0U;
- break;
-
- case USB_REQ_RECIPIENT_INTERFACE:
- idx = USBD_CoreFindIF(pdev, LOBYTE(pdev->request.wIndex));
- break;
-
- case USB_REQ_RECIPIENT_ENDPOINT:
- idx = USBD_CoreFindEP(pdev, LOBYTE(pdev->request.wIndex));
- break;
-
- default:
- /* Back to the first class in case of doubt */
- idx = 0U;
- break;
- }
-
- if (idx < USBD_MAX_SUPPORTED_CLASS)
- {
- /* Setup the class ID and route the request to the relative class function */
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[idx]->EP0_RxReady != NULL)
- {
- pdev->classId = idx;
- pdev->pClass[idx]->EP0_RxReady(pdev);
- }
- }
- }
-
- (void)USBD_CtlSendStatus(pdev);
- }
- }
- }
- else
- {
- /* Get the class index relative to this interface */
- idx = USBD_CoreFindEP(pdev, (epnum & 0x7FU));
-
- if (((uint16_t)idx != 0xFFU) && (idx < USBD_MAX_SUPPORTED_CLASS))
- {
- /* Call the class data out function to manage the request */
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[idx]->DataOut != NULL)
- {
- pdev->classId = idx;
- ret = (USBD_StatusTypeDef)pdev->pClass[idx]->DataOut(pdev, epnum);
- }
- }
- if (ret != USBD_OK)
- {
- return ret;
- }
- }
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_DataInStage
- * Handle data in stage
- * @param pdev: device instance
- * @param epnum: endpoint index
- * @param pdata: data pointer
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
- uint8_t epnum, uint8_t *pdata)
-{
- USBD_EndpointTypeDef *pep;
- USBD_StatusTypeDef ret;
- uint8_t idx;
-
- if (epnum == 0U)
- {
- pep = &pdev->ep_in[0];
-
- if (pdev->ep0_state == USBD_EP0_DATA_IN)
- {
- if (pep->rem_length > pep->maxpacket)
- {
- pep->rem_length -= pep->maxpacket;
-
- (void)USBD_CtlContinueSendData(pdev, pdata, pep->rem_length);
-
- /* Prepare endpoint for premature end of transfer */
- (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
- }
- else
- {
- /* last packet is MPS multiple, so send ZLP packet */
- if ((pep->maxpacket == pep->rem_length) &&
- (pep->total_length >= pep->maxpacket) &&
- (pep->total_length < pdev->ep0_data_len))
- {
- (void)USBD_CtlContinueSendData(pdev, NULL, 0U);
- pdev->ep0_data_len = 0U;
-
- /* Prepare endpoint for premature end of transfer */
- (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
- }
- else
- {
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[0]->EP0_TxSent != NULL)
- {
- pdev->classId = 0U;
- pdev->pClass[0]->EP0_TxSent(pdev);
- }
- }
- (void)USBD_LL_StallEP(pdev, 0x80U);
- (void)USBD_CtlReceiveStatus(pdev);
- }
- }
- }
-
- if (pdev->dev_test_mode != 0U)
- {
- (void)USBD_RunTestMode(pdev);
- pdev->dev_test_mode = 0U;
- }
- }
- else
- {
- /* Get the class index relative to this interface */
- idx = USBD_CoreFindEP(pdev, ((uint8_t)epnum | 0x80U));
-
- if (((uint16_t)idx != 0xFFU) && (idx < USBD_MAX_SUPPORTED_CLASS))
- {
- /* Call the class data out function to manage the request */
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[idx]->DataIn != NULL)
- {
- pdev->classId = idx;
- ret = (USBD_StatusTypeDef)pdev->pClass[idx]->DataIn(pdev, epnum);
-
- if (ret != USBD_OK)
- {
- return ret;
- }
- }
- }
- }
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_Reset
- * Handle Reset event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
-{
- USBD_StatusTypeDef ret = USBD_OK;
-
- /* Upon Reset call user call back */
- pdev->dev_state = USBD_STATE_DEFAULT;
- pdev->ep0_state = USBD_EP0_IDLE;
- pdev->dev_config = 0U;
- pdev->dev_remote_wakeup = 0U;
- pdev->dev_test_mode = 0U;
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Clear configuration and De-initialize the Class process*/
-
- if (pdev->pClass[i]->DeInit != NULL)
- {
- if (pdev->pClass[i]->DeInit(pdev, (uint8_t)pdev->dev_config) != USBD_OK)
- {
- ret = USBD_FAIL;
- }
- }
- }
- }
- }
-#else
-
- if (pdev->pClass[0] != NULL)
- {
- if (pdev->pClass[0]->DeInit != NULL)
- {
- if (pdev->pClass[0]->DeInit(pdev, (uint8_t)pdev->dev_config) != USBD_OK)
- {
- ret = USBD_FAIL;
- }
- }
- }
-#endif /* USE_USBD_COMPOSITE */
-
- /* Open EP0 OUT */
- (void)USBD_LL_OpenEP(pdev, 0x00U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
- pdev->ep_out[0x00U & 0xFU].is_used = 1U;
-
- pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
-
- /* Open EP0 IN */
- (void)USBD_LL_OpenEP(pdev, 0x80U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
- pdev->ep_in[0x80U & 0xFU].is_used = 1U;
-
- pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
-
- return ret;
-}
-
-/**
- * @brief USBD_LL_SetSpeed
- * Handle Reset event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
- USBD_SpeedTypeDef speed)
-{
- pdev->dev_speed = speed;
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_Suspend
- * Handle Suspend event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
-{
- if (pdev->dev_state != USBD_STATE_SUSPENDED)
- {
- pdev->dev_old_state = pdev->dev_state;
- }
-
- pdev->dev_state = USBD_STATE_SUSPENDED;
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_Resume
- * Handle Resume event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
-{
- if (pdev->dev_state == USBD_STATE_SUSPENDED)
- {
- pdev->dev_state = pdev->dev_old_state;
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_SOF
- * Handle SOF event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
-{
- /* The SOF event can be distributed for all classes that support it */
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- if (pdev->pClass[i]->SOF != NULL)
- {
- pdev->classId = i;
- (void)pdev->pClass[i]->SOF(pdev);
- }
- }
- }
- }
-#else
- if (pdev->pClass[0] != NULL)
- {
- if (pdev->pClass[0]->SOF != NULL)
- {
- (void)pdev->pClass[0]->SOF(pdev);
- }
- }
-#endif /* USE_USBD_COMPOSITE */
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_IsoINIncomplete
- * Handle iso in incomplete event
- * @param pdev: device instance
- * @param epnum: Endpoint number
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
- uint8_t epnum)
-{
- if (pdev->pClass[pdev->classId] == NULL)
- {
- return USBD_FAIL;
- }
-
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[pdev->classId]->IsoINIncomplete != NULL)
- {
- (void)pdev->pClass[pdev->classId]->IsoINIncomplete(pdev, epnum);
- }
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_IsoOUTIncomplete
- * Handle iso out incomplete event
- * @param pdev: device instance
- * @param epnum: Endpoint number
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
- uint8_t epnum)
-{
- if (pdev->pClass[pdev->classId] == NULL)
- {
- return USBD_FAIL;
- }
-
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- if (pdev->pClass[pdev->classId]->IsoOUTIncomplete != NULL)
- {
- (void)pdev->pClass[pdev->classId]->IsoOUTIncomplete(pdev, epnum);
- }
- }
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_DevConnected
- * Handle device connection event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)
-{
- /* Prevent unused argument compilation warning */
- UNUSED(pdev);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_LL_DevDisconnected
- * Handle device disconnection event
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)
-{
- USBD_StatusTypeDef ret = USBD_OK;
-
- /* Free Class Resources */
- pdev->dev_state = USBD_STATE_DEFAULT;
-
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- if (pdev->pClass[i] != NULL)
- {
- pdev->classId = i;
- /* Clear configuration and De-initialize the Class process*/
- if (pdev->pClass[i]->DeInit(pdev, (uint8_t)pdev->dev_config) != 0U)
- {
- ret = USBD_FAIL;
- }
- }
- }
- }
-#else
- if (pdev->pClass[0] != NULL)
- {
- if (pdev->pClass[0]->DeInit(pdev, (uint8_t)pdev->dev_config) != 0U)
- {
- ret = USBD_FAIL;
- }
- }
-#endif /* USE_USBD_COMPOSITE */
-
- return ret;
-}
-
-/**
- * @brief USBD_CoreFindIF
- * return the class index relative to the selected interface
- * @param pdev: device instance
- * @param index : selected interface number
- * @retval index of the class using the selected interface number. OxFF if no class found.
- */
-uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index)
-{
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- /* Parse all interfaces listed in the current class */
- for (uint32_t j = 0U; j < pdev->tclasslist[i].NumIf; j++)
- {
- /* Check if requested Interface matches the current class interface */
- if (pdev->tclasslist[i].Ifs[j] == index)
- {
- if (pdev->pClass[i]->Setup != NULL)
- {
- return (uint8_t)i;
- }
- }
- }
- }
- }
-
- return 0xFFU;
-#else
- UNUSED(pdev);
- UNUSED(index);
-
- return 0x00U;
-#endif /* USE_USBD_COMPOSITE */
-}
-
-/**
- * @brief USBD_CoreFindEP
- * return the class index relative to the selected endpoint
- * @param pdev: device instance
- * @param index : selected endpoint number
- * @retval index of the class using the selected endpoint number. 0xFF if no class found.
- */
-uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index)
-{
-#ifdef USE_USBD_COMPOSITE
- /* Parse the table of classes in use */
- for (uint32_t i = 0U; i < USBD_MAX_SUPPORTED_CLASS; i++)
- {
- /* Check if current class is in use */
- if ((pdev->tclasslist[i].Active) == 1U)
- {
- /* Parse all endpoints listed in the current class */
- for (uint32_t j = 0U; j < pdev->tclasslist[i].NumEps; j++)
- {
- /* Check if requested endpoint matches the current class endpoint */
- if (pdev->tclasslist[i].Eps[j].add == index)
- {
- if (pdev->pClass[i]->Setup != NULL)
- {
- return (uint8_t)i;
- }
- }
- }
- }
- }
-
- return 0xFFU;
-#else
- UNUSED(pdev);
- UNUSED(index);
-
- return 0x00U;
-#endif /* USE_USBD_COMPOSITE */
-}
-
-#ifdef USE_USBD_COMPOSITE
-/**
- * @brief USBD_CoreGetEPAdd
- * Get the endpoint address relative to a selected class
- * @param pdev: device instance
- * @param ep_dir: USBD_EP_IN or USBD_EP_OUT
- * @param ep_type: USBD_EP_TYPE_CTRL, USBD_EP_TYPE_ISOC, USBD_EP_TYPE_BULK or USBD_EP_TYPE_INTR
- * @param ClassId: The Class ID
- * @retval Address of the selected endpoint or 0xFFU if no endpoint found.
- */
-uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId)
-{
- uint8_t idx;
-
- /* Find the EP address in the selected class table */
- for (idx = 0; idx < pdev->tclasslist[ClassId].NumEps; idx++)
- {
- if (((pdev->tclasslist[ClassId].Eps[idx].add & USBD_EP_IN) == ep_dir) && \
- (pdev->tclasslist[ClassId].Eps[idx].type == ep_type) && \
- (pdev->tclasslist[ClassId].Eps[idx].is_used != 0U))
- {
- return (pdev->tclasslist[ClassId].Eps[idx].add);
- }
- }
-
- /* If reaching this point, then no endpoint was found */
- return 0xFFU;
-}
-#endif /* USE_USBD_COMPOSITE */
-
-/**
- * @brief USBD_GetEpDesc
- * This function return the Endpoint descriptor
- * @param pdev: device instance
- * @param pConfDesc: pointer to Bos descriptor
- * @param EpAddr: endpoint address
- * @retval pointer to video endpoint descriptor
- */
-void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr)
-{
- USBD_DescHeaderTypeDef *pdesc = (USBD_DescHeaderTypeDef *)(void *)pConfDesc;
- USBD_ConfigDescTypeDef *desc = (USBD_ConfigDescTypeDef *)(void *)pConfDesc;
- USBD_EpDescTypeDef *pEpDesc = NULL;
- uint16_t ptr;
-
- if (desc->wTotalLength > desc->bLength)
- {
- ptr = desc->bLength;
-
- while (ptr < desc->wTotalLength)
- {
- pdesc = USBD_GetNextDesc((uint8_t *)pdesc, &ptr);
-
- if (pdesc->bDescriptorType == USB_DESC_TYPE_ENDPOINT)
- {
- pEpDesc = (USBD_EpDescTypeDef *)(void *)pdesc;
-
- if (pEpDesc->bEndpointAddress == EpAddr)
- {
- break;
- }
- else
- {
- pEpDesc = NULL;
- }
- }
- }
- }
-
- return (void *)pEpDesc;
-}
-
-/**
- * @brief USBD_GetNextDesc
- * This function return the next descriptor header
- * @param buf: Buffer where the descriptor is available
- * @param ptr: data pointer inside the descriptor
- * @retval next header
- */
-USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
-{
- USBD_DescHeaderTypeDef *pnext = (USBD_DescHeaderTypeDef *)(void *)pbuf;
-
- *ptr += pnext->bLength;
- pnext = (USBD_DescHeaderTypeDef *)(void *)(pbuf + pnext->bLength);
-
- return (pnext);
-}
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_req.c
- * @author MCD Application Team
- * @brief This file provides the standard USB requests following chapter 9.
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_ctlreq.h"
-#include "usbd_ioreq.h"
-
-#ifdef USE_USBD_COMPOSITE
-#include "usbd_composite_builder.h"
-#endif /* USE_USBD_COMPOSITE */
-
-/** @addtogroup STM32_USBD_STATE_DEVICE_LIBRARY
- * @{
- */
-
-
-/** @defgroup USBD_REQ
- * @brief USB standard requests module
- * @{
- */
-
-/** @defgroup USBD_REQ_Private_TypesDefinitions
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Private_Defines
- * @{
- */
-#ifndef USBD_MAX_STR_DESC_SIZ
-#define USBD_MAX_STR_DESC_SIZ 64U
-#endif /* USBD_MAX_STR_DESC_SIZ */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Private_Macros
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Private_Variables
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Private_FunctionPrototypes
- * @{
- */
-static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static uint8_t USBD_GetLen(uint8_t *buf);
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_REQ_Private_Functions
- * @{
- */
-
-
-/**
- * @brief USBD_StdDevReq
- * Handle standard usb device requests
- * @param pdev: device instance
- * @param req: usb request
- * @retval status
- */
-USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- USBD_StatusTypeDef ret = USBD_OK;
-
- switch (req->bmRequest & USB_REQ_TYPE_MASK)
- {
- case USB_REQ_TYPE_CLASS:
- case USB_REQ_TYPE_VENDOR:
- ret = (USBD_StatusTypeDef)pdev->pClass[pdev->classId]->Setup(pdev, req);
- break;
-
- case USB_REQ_TYPE_STANDARD:
- switch (req->bRequest)
- {
- case USB_REQ_GET_DESCRIPTOR:
- USBD_GetDescriptor(pdev, req);
- break;
-
- case USB_REQ_SET_ADDRESS:
- USBD_SetAddress(pdev, req);
- break;
-
- case USB_REQ_SET_CONFIGURATION:
- ret = USBD_SetConfig(pdev, req);
- break;
-
- case USB_REQ_GET_CONFIGURATION:
- USBD_GetConfig(pdev, req);
- break;
-
- case USB_REQ_GET_STATUS:
- USBD_GetStatus(pdev, req);
- break;
-
- case USB_REQ_SET_FEATURE:
- USBD_SetFeature(pdev, req);
- break;
-
- case USB_REQ_CLEAR_FEATURE:
- USBD_ClrFeature(pdev, req);
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
-
- return ret;
-}
-
-/**
- * @brief USBD_StdItfReq
- * Handle standard usb interface requests
- * @param pdev: device instance
- * @param req: usb request
- * @retval status
- */
-USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- USBD_StatusTypeDef ret = USBD_OK;
- uint8_t idx;
-
- switch (req->bmRequest & USB_REQ_TYPE_MASK)
- {
- case USB_REQ_TYPE_CLASS:
- case USB_REQ_TYPE_VENDOR:
- case USB_REQ_TYPE_STANDARD:
- switch (pdev->dev_state)
- {
- case USBD_STATE_DEFAULT:
- case USBD_STATE_ADDRESSED:
- case USBD_STATE_CONFIGURED:
-
- if (LOBYTE(req->wIndex) <= USBD_MAX_NUM_INTERFACES)
- {
- /* Get the class index relative to this interface */
- idx = USBD_CoreFindIF(pdev, LOBYTE(req->wIndex));
- if (((uint8_t)idx != 0xFFU) && (idx < USBD_MAX_SUPPORTED_CLASS))
- {
- /* Call the class data out function to manage the request */
- if (pdev->pClass[idx]->Setup != NULL)
- {
- pdev->classId = idx;
- ret = (USBD_StatusTypeDef)(pdev->pClass[idx]->Setup(pdev, req));
- }
- else
- {
- /* should never reach this condition */
- ret = USBD_FAIL;
- }
- }
- else
- {
- /* No relative interface found */
- ret = USBD_FAIL;
- }
-
- if ((req->wLength == 0U) && (ret == USBD_OK))
- {
- (void)USBD_CtlSendStatus(pdev);
- }
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
-
- return ret;
-}
-
-/**
- * @brief USBD_StdEPReq
- * Handle standard usb endpoint requests
- * @param pdev: device instance
- * @param req: usb request
- * @retval status
- */
-USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- USBD_EndpointTypeDef *pep;
- uint8_t ep_addr;
- uint8_t idx;
- USBD_StatusTypeDef ret = USBD_OK;
-
- ep_addr = LOBYTE(req->wIndex);
-
- switch (req->bmRequest & USB_REQ_TYPE_MASK)
- {
- case USB_REQ_TYPE_CLASS:
- case USB_REQ_TYPE_VENDOR:
- /* Get the class index relative to this endpoint */
- idx = USBD_CoreFindEP(pdev, ep_addr);
- if (((uint8_t)idx != 0xFFU) && (idx < USBD_MAX_SUPPORTED_CLASS))
- {
- pdev->classId = idx;
- /* Call the class data out function to manage the request */
- if (pdev->pClass[idx]->Setup != NULL)
- {
- ret = (USBD_StatusTypeDef)pdev->pClass[idx]->Setup(pdev, req);
- }
- }
- break;
-
- case USB_REQ_TYPE_STANDARD:
- switch (req->bRequest)
- {
- case USB_REQ_SET_FEATURE:
- switch (pdev->dev_state)
- {
- case USBD_STATE_ADDRESSED:
- if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
- {
- (void)USBD_LL_StallEP(pdev, ep_addr);
- (void)USBD_LL_StallEP(pdev, 0x80U);
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
- break;
-
- case USBD_STATE_CONFIGURED:
- if (req->wValue == USB_FEATURE_EP_HALT)
- {
- if ((ep_addr != 0x00U) && (ep_addr != 0x80U) && (req->wLength == 0x00U))
- {
- (void)USBD_LL_StallEP(pdev, ep_addr);
- }
- }
- (void)USBD_CtlSendStatus(pdev);
-
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- case USB_REQ_CLEAR_FEATURE:
-
- switch (pdev->dev_state)
- {
- case USBD_STATE_ADDRESSED:
- if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
- {
- (void)USBD_LL_StallEP(pdev, ep_addr);
- (void)USBD_LL_StallEP(pdev, 0x80U);
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
- break;
-
- case USBD_STATE_CONFIGURED:
- if (req->wValue == USB_FEATURE_EP_HALT)
- {
- if ((ep_addr & 0x7FU) != 0x00U)
- {
- (void)USBD_LL_ClearStallEP(pdev, ep_addr);
- }
- (void)USBD_CtlSendStatus(pdev);
-
- /* Get the class index relative to this interface */
- idx = USBD_CoreFindEP(pdev, ep_addr);
- if (((uint8_t)idx != 0xFFU) && (idx < USBD_MAX_SUPPORTED_CLASS))
- {
- pdev->classId = idx;
- /* Call the class data out function to manage the request */
- if (pdev->pClass[idx]->Setup != NULL)
- {
- ret = (USBD_StatusTypeDef)(pdev->pClass[idx]->Setup(pdev, req));
- }
- }
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- case USB_REQ_GET_STATUS:
- switch (pdev->dev_state)
- {
- case USBD_STATE_ADDRESSED:
- if ((ep_addr != 0x00U) && (ep_addr != 0x80U))
- {
- USBD_CtlError(pdev, req);
- break;
- }
- pep = ((ep_addr & 0x80U) == 0x80U) ? &pdev->ep_in[ep_addr & 0x7FU] : \
- &pdev->ep_out[ep_addr & 0x7FU];
-
- pep->status = 0x0000U;
-
- (void)USBD_CtlSendData(pdev, (uint8_t *)&pep->status, 2U);
- break;
-
- case USBD_STATE_CONFIGURED:
- if ((ep_addr & 0x80U) == 0x80U)
- {
- if (pdev->ep_in[ep_addr & 0xFU].is_used == 0U)
- {
- USBD_CtlError(pdev, req);
- break;
- }
- }
- else
- {
- if (pdev->ep_out[ep_addr & 0xFU].is_used == 0U)
- {
- USBD_CtlError(pdev, req);
- break;
- }
- }
-
- pep = ((ep_addr & 0x80U) == 0x80U) ? &pdev->ep_in[ep_addr & 0x7FU] : \
- &pdev->ep_out[ep_addr & 0x7FU];
-
- if ((ep_addr == 0x00U) || (ep_addr == 0x80U))
- {
- pep->status = 0x0000U;
- }
- else if (USBD_LL_IsStallEP(pdev, ep_addr) != 0U)
- {
- pep->status = 0x0001U;
- }
- else
- {
- pep->status = 0x0000U;
- }
-
- (void)USBD_CtlSendData(pdev, (uint8_t *)&pep->status, 2U);
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
-
- return ret;
-}
-
-
-/**
- * @brief USBD_GetDescriptor
- * Handle Get Descriptor requests
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_GetDescriptor(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- uint16_t len = 0U;
- uint8_t *pbuf = NULL;
- uint8_t err = 0U;
-
- switch (req->wValue >> 8)
- {
-#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1U))
- case USB_DESC_TYPE_BOS:
- if (pdev->pDesc->GetBOSDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetBOSDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-#endif /* (USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1U) */
- case USB_DESC_TYPE_DEVICE:
- pbuf = pdev->pDesc->GetDeviceDescriptor(pdev->dev_speed, &len);
- break;
-
- case USB_DESC_TYPE_CONFIGURATION:
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
-#ifdef USE_USBD_COMPOSITE
- if ((uint8_t)(pdev->NumClasses) > 0U)
- {
- pbuf = (uint8_t *)USBD_CMPSIT.GetHSConfigDescriptor(&len);
- }
- else
-#endif /* USE_USBD_COMPOSITE */
- {
- pbuf = (uint8_t *)pdev->pClass[0]->GetHSConfigDescriptor(&len);
- }
- pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
- }
- else
- {
-#ifdef USE_USBD_COMPOSITE
- if ((uint8_t)(pdev->NumClasses) > 0U)
- {
- pbuf = (uint8_t *)USBD_CMPSIT.GetFSConfigDescriptor(&len);
- }
- else
-#endif /* USE_USBD_COMPOSITE */
- {
- pbuf = (uint8_t *)pdev->pClass[0]->GetFSConfigDescriptor(&len);
- }
- pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
- }
- break;
-
- case USB_DESC_TYPE_STRING:
- switch ((uint8_t)(req->wValue))
- {
- case USBD_IDX_LANGID_STR:
- if (pdev->pDesc->GetLangIDStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetLangIDStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USBD_IDX_MFC_STR:
- if (pdev->pDesc->GetManufacturerStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetManufacturerStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USBD_IDX_PRODUCT_STR:
- if (pdev->pDesc->GetProductStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetProductStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USBD_IDX_SERIAL_STR:
- if (pdev->pDesc->GetSerialStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetSerialStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USBD_IDX_CONFIG_STR:
- if (pdev->pDesc->GetConfigurationStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetConfigurationStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USBD_IDX_INTERFACE_STR:
- if (pdev->pDesc->GetInterfaceStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetInterfaceStrDescriptor(pdev->dev_speed, &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- default:
-#if (USBD_SUPPORT_USER_STRING_DESC == 1U)
- pbuf = NULL;
-
- for (uint32_t idx = 0U; (idx < pdev->NumClasses); idx++)
- {
- if (pdev->pClass[idx]->GetUsrStrDescriptor != NULL)
- {
- pdev->classId = idx;
- pbuf = pdev->pClass[idx]->GetUsrStrDescriptor(pdev, LOBYTE(req->wValue), &len);
-
- if (pbuf == NULL) /* This means that no class recognized the string index */
- {
- continue;
- }
- else
- {
- break;
- }
- }
- }
-#endif /* USBD_SUPPORT_USER_STRING_DESC */
-
-#if (USBD_CLASS_USER_STRING_DESC == 1U)
- if (pdev->pDesc->GetUserStrDescriptor != NULL)
- {
- pbuf = pdev->pDesc->GetUserStrDescriptor(pdev->dev_speed, LOBYTE(req->wValue), &len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
-#endif /* USBD_SUPPORT_USER_STRING_DESC */
-
-#if ((USBD_CLASS_USER_STRING_DESC == 0U) && (USBD_SUPPORT_USER_STRING_DESC == 0U))
- USBD_CtlError(pdev, req);
- err++;
-#endif /* (USBD_CLASS_USER_STRING_DESC == 0U) && (USBD_SUPPORT_USER_STRING_DESC == 0U) */
- break;
- }
- break;
-
- case USB_DESC_TYPE_DEVICE_QUALIFIER:
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
-#ifdef USE_USBD_COMPOSITE
- if ((uint8_t)(pdev->NumClasses) > 0U)
- {
- pbuf = (uint8_t *)USBD_CMPSIT.GetDeviceQualifierDescriptor(&len);
- }
- else
-#endif /* USE_USBD_COMPOSITE */
- {
- pbuf = (uint8_t *)pdev->pClass[0]->GetDeviceQualifierDescriptor(&len);
- }
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- case USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION:
- if (pdev->dev_speed == USBD_SPEED_HIGH)
- {
-#ifdef USE_USBD_COMPOSITE
- if ((uint8_t)(pdev->NumClasses) > 0U)
- {
- pbuf = (uint8_t *)USBD_CMPSIT.GetOtherSpeedConfigDescriptor(&len);
- }
- else
-#endif /* USE_USBD_COMPOSITE */
- {
- pbuf = (uint8_t *)pdev->pClass[0]->GetOtherSpeedConfigDescriptor(&len);
- }
- pbuf[1] = USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION;
- }
- else
- {
- USBD_CtlError(pdev, req);
- err++;
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- err++;
- break;
- }
-
- if (err != 0U)
- {
- return;
- }
-
- if (req->wLength != 0U)
- {
- if (len != 0U)
- {
- len = MIN(len, req->wLength);
- (void)USBD_CtlSendData(pdev, pbuf, len);
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
- }
- else
- {
- (void)USBD_CtlSendStatus(pdev);
- }
-}
-
-
-/**
- * @brief USBD_SetAddress
- * Set device address
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_SetAddress(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- uint8_t dev_addr;
-
- if ((req->wIndex == 0U) && (req->wLength == 0U) && (req->wValue < 128U))
- {
- dev_addr = (uint8_t)(req->wValue) & 0x7FU;
-
- if (pdev->dev_state == USBD_STATE_CONFIGURED)
- {
- USBD_CtlError(pdev, req);
- }
- else
- {
- pdev->dev_address = dev_addr;
- (void)USBD_LL_SetUSBAddress(pdev, dev_addr);
- (void)USBD_CtlSendStatus(pdev);
-
- if (dev_addr != 0U)
- {
- pdev->dev_state = USBD_STATE_ADDRESSED;
- }
- else
- {
- pdev->dev_state = USBD_STATE_DEFAULT;
- }
- }
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
-}
-
-/**
- * @brief USBD_SetConfig
- * Handle Set device configuration request
- * @param pdev: device instance
- * @param req: usb request
- * @retval status
- */
-static USBD_StatusTypeDef USBD_SetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- USBD_StatusTypeDef ret = USBD_OK;
- static uint8_t cfgidx;
-
- cfgidx = (uint8_t)(req->wValue);
-
- if (cfgidx > USBD_MAX_NUM_CONFIGURATION)
- {
- USBD_CtlError(pdev, req);
- return USBD_FAIL;
- }
-
- switch (pdev->dev_state)
- {
- case USBD_STATE_ADDRESSED:
- if (cfgidx != 0U)
- {
- pdev->dev_config = cfgidx;
-
- ret = USBD_SetClassConfig(pdev, cfgidx);
-
- if (ret != USBD_OK)
- {
- USBD_CtlError(pdev, req);
- pdev->dev_state = USBD_STATE_ADDRESSED;
- }
- else
- {
- (void)USBD_CtlSendStatus(pdev);
- pdev->dev_state = USBD_STATE_CONFIGURED;
-
-#if (USBD_USER_REGISTER_CALLBACK == 1U)
- if (pdev->DevStateCallback != NULL)
- {
- pdev->DevStateCallback(USBD_STATE_CONFIGURED, cfgidx);
- }
-#endif /* USBD_USER_REGISTER_CALLBACK */
- }
- }
- else
- {
- (void)USBD_CtlSendStatus(pdev);
- }
- break;
-
- case USBD_STATE_CONFIGURED:
- if (cfgidx == 0U)
- {
- pdev->dev_state = USBD_STATE_ADDRESSED;
- pdev->dev_config = cfgidx;
- (void)USBD_ClrClassConfig(pdev, cfgidx);
- (void)USBD_CtlSendStatus(pdev);
- }
- else if (cfgidx != pdev->dev_config)
- {
- /* Clear old configuration */
- (void)USBD_ClrClassConfig(pdev, (uint8_t)pdev->dev_config);
-
- /* set new configuration */
- pdev->dev_config = cfgidx;
-
- ret = USBD_SetClassConfig(pdev, cfgidx);
-
- if (ret != USBD_OK)
- {
- USBD_CtlError(pdev, req);
- (void)USBD_ClrClassConfig(pdev, (uint8_t)pdev->dev_config);
- pdev->dev_state = USBD_STATE_ADDRESSED;
- }
- else
- {
- (void)USBD_CtlSendStatus(pdev);
- }
- }
- else
- {
- (void)USBD_CtlSendStatus(pdev);
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- (void)USBD_ClrClassConfig(pdev, cfgidx);
- ret = USBD_FAIL;
- break;
- }
-
- return ret;
-}
-
-/**
- * @brief USBD_GetConfig
- * Handle Get device configuration request
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_GetConfig(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- if (req->wLength != 1U)
- {
- USBD_CtlError(pdev, req);
- }
- else
- {
- switch (pdev->dev_state)
- {
- case USBD_STATE_DEFAULT:
- case USBD_STATE_ADDRESSED:
- pdev->dev_default_config = 0U;
- (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_default_config, 1U);
- break;
-
- case USBD_STATE_CONFIGURED:
- (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_config, 1U);
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
- }
-}
-
-/**
- * @brief USBD_GetStatus
- * Handle Get Status request
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_GetStatus(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- switch (pdev->dev_state)
- {
- case USBD_STATE_DEFAULT:
- case USBD_STATE_ADDRESSED:
- case USBD_STATE_CONFIGURED:
- if (req->wLength != 0x2U)
- {
- USBD_CtlError(pdev, req);
- break;
- }
-
-#if (USBD_SELF_POWERED == 1U)
- pdev->dev_config_status = USB_CONFIG_SELF_POWERED;
-#else
- pdev->dev_config_status = 0U;
-#endif /* USBD_SELF_POWERED */
-
- if (pdev->dev_remote_wakeup != 0U)
- {
- pdev->dev_config_status |= USB_CONFIG_REMOTE_WAKEUP;
- }
-
- (void)USBD_CtlSendData(pdev, (uint8_t *)&pdev->dev_config_status, 2U);
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
-}
-
-
-/**
- * @brief USBD_SetFeature
- * Handle Set device feature request
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_SetFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
- {
- pdev->dev_remote_wakeup = 1U;
- (void)USBD_CtlSendStatus(pdev);
- }
- else if (req->wValue == USB_FEATURE_TEST_MODE)
- {
- pdev->dev_test_mode = (uint8_t)(req->wIndex >> 8);
- (void)USBD_CtlSendStatus(pdev);
- }
- else
- {
- USBD_CtlError(pdev, req);
- }
-}
-
-
-/**
- * @brief USBD_ClrFeature
- * Handle clear device feature request
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-static void USBD_ClrFeature(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- switch (pdev->dev_state)
- {
- case USBD_STATE_DEFAULT:
- case USBD_STATE_ADDRESSED:
- case USBD_STATE_CONFIGURED:
- if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
- {
- pdev->dev_remote_wakeup = 0U;
- (void)USBD_CtlSendStatus(pdev);
- }
- break;
-
- default:
- USBD_CtlError(pdev, req);
- break;
- }
-}
-
-
-/**
- * @brief USBD_ParseSetupRequest
- * Copy buffer into setup structure
- * @param req: usb request
- * @param pdata: setup data pointer
- * @retval None
- */
-void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
-{
- uint8_t *pbuff = pdata;
-
- req->bmRequest = *(uint8_t *)(pbuff);
-
- pbuff++;
- req->bRequest = *(uint8_t *)(pbuff);
-
- pbuff++;
- req->wValue = SWAPBYTE(pbuff);
-
- pbuff++;
- pbuff++;
- req->wIndex = SWAPBYTE(pbuff);
-
- pbuff++;
- pbuff++;
- req->wLength = SWAPBYTE(pbuff);
-}
-
-
-/**
- * @brief USBD_CtlError
- * Handle USB low level Error
- * @param pdev: device instance
- * @param req: usb request
- * @retval None
- */
-void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
-{
- UNUSED(req);
-
- (void)USBD_LL_StallEP(pdev, 0x80U);
- (void)USBD_LL_StallEP(pdev, 0U);
-}
-
-
-/**
- * @brief USBD_GetString
- * Convert Ascii string into unicode one
- * @param desc : descriptor buffer
- * @param unicode : Formatted string buffer (unicode)
- * @param len : descriptor length
- * @retval None
- */
-void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len)
-{
- uint8_t idx = 0U;
- uint8_t *pdesc;
-
- if (desc == NULL)
- {
- return;
- }
-
- pdesc = desc;
- *len = MIN(USBD_MAX_STR_DESC_SIZ, ((uint16_t)USBD_GetLen(pdesc) * 2U) + 2U);
-
- unicode[idx] = *(uint8_t *)len;
- idx++;
- unicode[idx] = USB_DESC_TYPE_STRING;
- idx++;
-
- while (*pdesc != (uint8_t)'\0')
- {
- unicode[idx] = *pdesc;
- pdesc++;
- idx++;
-
- unicode[idx] = 0U;
- idx++;
- }
-}
-
-
-/**
- * @brief USBD_GetLen
- * return the string length
- * @param buf : pointer to the ascii string buffer
- * @retval string length
- */
-static uint8_t USBD_GetLen(uint8_t *buf)
-{
- uint8_t len = 0U;
- uint8_t *pbuff = buf;
-
- while (*pbuff != (uint8_t)'\0')
- {
- len++;
- pbuff++;
- }
-
- return len;
-}
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
+++ /dev/null
-/**
- ******************************************************************************
- * @file usbd_ioreq.c
- * @author MCD Application Team
- * @brief This file provides the IO requests APIs for control endpoints.
- ******************************************************************************
- * @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.
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_ioreq.h"
-
-/** @addtogroup STM32_USB_DEVICE_LIBRARY
- * @{
- */
-
-
-/** @defgroup USBD_IOREQ
- * @brief control I/O requests module
- * @{
- */
-
-/** @defgroup USBD_IOREQ_Private_TypesDefinitions
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Private_Defines
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Private_Macros
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Private_Variables
- * @{
- */
-
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
- * @{
- */
-/**
- * @}
- */
-
-
-/** @defgroup USBD_IOREQ_Private_Functions
- * @{
- */
-
-/**
- * @brief USBD_CtlSendData
- * send data on the ctl pipe
- * @param pdev: device instance
- * @param buff: pointer to data buffer
- * @param len: length of data to be sent
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len)
-{
- /* Set EP0 State */
- pdev->ep0_state = USBD_EP0_DATA_IN;
- pdev->ep_in[0].total_length = len;
-
-#ifdef USBD_AVOID_PACKET_SPLIT_MPS
- pdev->ep_in[0].rem_length = 0U;
-#else
- pdev->ep_in[0].rem_length = len;
-#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
-
- /* Start the transfer */
- (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_CtlContinueSendData
- * continue sending data on the ctl pipe
- * @param pdev: device instance
- * @param buff: pointer to data buffer
- * @param len: length of data to be sent
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len)
-{
- /* Start the next transfer */
- (void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_CtlPrepareRx
- * receive data on the ctl pipe
- * @param pdev: device instance
- * @param buff: pointer to data buffer
- * @param len: length of data to be received
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len)
-{
- /* Set EP0 State */
- pdev->ep0_state = USBD_EP0_DATA_OUT;
- pdev->ep_out[0].total_length = len;
-
-#ifdef USBD_AVOID_PACKET_SPLIT_MPS
- pdev->ep_out[0].rem_length = 0U;
-#else
- pdev->ep_out[0].rem_length = len;
-#endif /* USBD_AVOID_PACKET_SPLIT_MPS */
-
- /* Start the transfer */
- (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_CtlContinueRx
- * continue receive data on the ctl pipe
- * @param pdev: device instance
- * @param buff: pointer to data buffer
- * @param len: length of data to be received
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
- uint8_t *pbuf, uint32_t len)
-{
- (void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_CtlSendStatus
- * send zero lzngth packet on the ctl pipe
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
-{
- /* Set EP0 State */
- pdev->ep0_state = USBD_EP0_STATUS_IN;
-
- /* Start the transfer */
- (void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_CtlReceiveStatus
- * receive zero lzngth packet on the ctl pipe
- * @param pdev: device instance
- * @retval status
- */
-USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
-{
- /* Set EP0 State */
- pdev->ep0_state = USBD_EP0_STATUS_OUT;
-
- /* Start the transfer */
- (void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
-
- return USBD_OK;
-}
-
-/**
- * @brief USBD_GetRxCount
- * returns the received data length
- * @param pdev: device instance
- * @param ep_addr: endpoint address
- * @retval Rx Data blength
- */
-uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- return USBD_LL_GetRxDataSize(pdev, ep_addr);
-}
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usb_device.c
- * @version : v1.0_Cube
- * @brief : This file implements the USB Device
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 "usb_device.h"
-#include "usbd_core.h"
-#include "usbd_desc.h"
-#include "usbd_cdc.h"
-#include "usbd_cdc_if.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* USER CODE BEGIN PV */
-/* Private variables ---------------------------------------------------------*/
-
-/* USER CODE END PV */
-
-/* USER CODE BEGIN PFP */
-/* Private function prototypes -----------------------------------------------*/
-
-/* USER CODE END PFP */
-
-/* USB Device Core handle declaration. */
-USBD_HandleTypeDef hUsbDeviceFS;
-
-/*
- * -- Insert your variables declaration here --
- */
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/*
- * -- Insert your external function declaration here --
- */
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
-
-/**
- * Init USB device Library, add supported class and start the library
- * @retval None
- */
-void MX_USB_DEVICE_Init(void)
-{
- /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
-
- /* USER CODE END USB_DEVICE_Init_PreTreatment */
-
- /* Init Device Library, add supported class and start the library. */
- if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
- {
- Error_Handler();
- }
- if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
- {
- Error_Handler();
- }
- if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
- {
- Error_Handler();
- }
- if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
- {
- Error_Handler();
- }
-
- /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
-
- /* USER CODE END USB_DEVICE_Init_PostTreatment */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usb_device.h
- * @version : v1.0_Cube
- * @brief : Header for usb_device.c file.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USB_DEVICE__H__
-#define __USB_DEVICE__H__
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32f4xx.h"
-#include "stm32f4xx_hal.h"
-#include "usbd_def.h"
-
-/* USER CODE BEGIN INCLUDE */
-
-/* USER CODE END INCLUDE */
-
-/** @addtogroup USBD_OTG_DRIVER
- * @{
- */
-
-/** @defgroup USBD_DEVICE USBD_DEVICE
- * @brief Device file for Usb otg low level driver.
- * @{
- */
-
-/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
- * @brief Public variables.
- * @{
- */
-
-/* Private variables ---------------------------------------------------------*/
-/* USER CODE BEGIN PV */
-
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/*
- * -- Insert your variables declaration here --
- */
-/* USER CODE BEGIN VARIABLES */
-
-/* USER CODE END VARIABLES */
-/**
- * @}
- */
-
-/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
- * @brief Declaration of public functions for Usb device.
- * @{
- */
-
-/** USB Device initialization function. */
-void MX_USB_DEVICE_Init(void);
-
-/*
- * -- Insert functions declaration here --
- */
-/* USER CODE BEGIN FD */
-
-/* USER CODE END FD */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USB_DEVICE__H__ */
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usbd_cdc_if.c
- * @version : v1.0_Cube
- * @brief : Usb device for Virtual Com Port.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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_cdc_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_CDC_IF
- * @{
- */
-
-/** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions
- * @brief Private types.
- * @{
- */
-
-/* USER CODE BEGIN PRIVATE_TYPES */
-
-/* USER CODE END PRIVATE_TYPES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines
- * @brief Private defines.
- * @{
- */
-
-/* USER CODE BEGIN PRIVATE_DEFINES */
-/* USER CODE END PRIVATE_DEFINES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros
- * @brief Private macros.
- * @{
- */
-
-/* USER CODE BEGIN PRIVATE_MACRO */
-
-/* USER CODE END PRIVATE_MACRO */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables
- * @brief Private variables.
- * @{
- */
-/* Create buffer for reception and transmission */
-/* It's up to user to redefine and/or remove those define */
-/** Received data over USB are stored in this buffer */
-uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
-
-/** Data to send over USB CDC are stored in this buffer */
-uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
-
-/* USER CODE BEGIN PRIVATE_VARIABLES */
-
-/* USER CODE END PRIVATE_VARIABLES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
- * @brief Public variables.
- * @{
- */
-
-extern USBD_HandleTypeDef hUsbDeviceFS;
-
-/* USER CODE BEGIN EXPORTED_VARIABLES */
-
-/* USER CODE END EXPORTED_VARIABLES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes
- * @brief Private functions declaration.
- * @{
- */
-
-static int8_t CDC_Init_FS(void);
-static int8_t CDC_DeInit_FS(void);
-static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length);
-static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len);
-static int8_t CDC_TransmitCplt_FS(uint8_t *pbuf, uint32_t *Len, uint8_t epnum);
-
-/* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
-
-/* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
-
-/**
- * @}
- */
-
-USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
-{
- CDC_Init_FS,
- CDC_DeInit_FS,
- CDC_Control_FS,
- CDC_Receive_FS,
- CDC_TransmitCplt_FS
-};
-
-/* Private functions ---------------------------------------------------------*/
-/**
- * @brief Initializes the CDC media low layer over the FS USB IP
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
-static int8_t CDC_Init_FS(void)
-{
- /* USER CODE BEGIN 3 */
- /* Set Application Buffers */
- USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
- USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
- return (USBD_OK);
- /* USER CODE END 3 */
-}
-
-/**
- * @brief DeInitializes the CDC media low layer
- * @retval USBD_OK if all operations are OK else USBD_FAIL
- */
-static int8_t CDC_DeInit_FS(void)
-{
- /* USER CODE BEGIN 4 */
- return (USBD_OK);
- /* USER CODE END 4 */
-}
-
-/**
- * @brief Manage the CDC class requests
- * @param cmd: Command code
- * @param pbuf: Buffer containing command data (request parameters)
- * @param length: Number of data to be sent (in bytes)
- * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
- */
-static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
-{
- /* USER CODE BEGIN 5 */
- switch(cmd)
- {
- case CDC_SEND_ENCAPSULATED_COMMAND:
-
- break;
-
- case CDC_GET_ENCAPSULATED_RESPONSE:
-
- break;
-
- case CDC_SET_COMM_FEATURE:
-
- break;
-
- case CDC_GET_COMM_FEATURE:
-
- break;
-
- case CDC_CLEAR_COMM_FEATURE:
-
- break;
-
- /*******************************************************************************/
- /* Line Coding Structure */
- /*-----------------------------------------------------------------------------*/
- /* Offset | Field | Size | Value | Description */
- /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
- /* 4 | bCharFormat | 1 | Number | Stop bits */
- /* 0 - 1 Stop bit */
- /* 1 - 1.5 Stop bits */
- /* 2 - 2 Stop bits */
- /* 5 | bParityType | 1 | Number | Parity */
- /* 0 - None */
- /* 1 - Odd */
- /* 2 - Even */
- /* 3 - Mark */
- /* 4 - Space */
- /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
- /*******************************************************************************/
- case CDC_SET_LINE_CODING:
-
- break;
-
- case CDC_GET_LINE_CODING:
-
- break;
-
- case CDC_SET_CONTROL_LINE_STATE:
-
- break;
-
- case CDC_SEND_BREAK:
-
- break;
-
- default:
- break;
- }
-
- return (USBD_OK);
- /* USER CODE END 5 */
-}
-
-/**
- * @brief Data received over USB OUT endpoint are sent over CDC interface
- * through this function.
- *
- * @note
- * This function will issue a NAK packet on any OUT packet received on
- * USB endpoint until exiting this function. If you exit this function
- * before transfer is complete on CDC interface (ie. using DMA controller)
- * it will result in receiving more data while previous ones are still
- * not sent.
- *
- * @param Buf: Buffer of data to be received
- * @param Len: Number of data received (in bytes)
- * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
- */
-static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
-{
- /* USER CODE BEGIN 6 */
- USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
- USBD_CDC_ReceivePacket(&hUsbDeviceFS);
- return (USBD_OK);
- /* USER CODE END 6 */
-}
-
-/**
- * @brief CDC_Transmit_FS
- * Data to send over USB IN endpoint are sent over CDC interface
- * through this function.
- * @note
- *
- *
- * @param Buf: Buffer of data to be sent
- * @param Len: Number of data to be sent (in bytes)
- * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY
- */
-uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
-{
- uint8_t result = USBD_OK;
- /* USER CODE BEGIN 7 */
- USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
- if (hcdc->TxState != 0){
- return USBD_BUSY;
- }
- USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
- result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
- /* USER CODE END 7 */
- return result;
-}
-
-/**
- * @brief CDC_TransmitCplt_FS
- * Data transmitted callback
- *
- * @note
- * This function is IN transfer complete callback used to inform user that
- * the submitted Data is successfully sent over USB.
- *
- * @param Buf: Buffer of data to be received
- * @param Len: Number of data received (in bytes)
- * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
- */
-static int8_t CDC_TransmitCplt_FS(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
-{
- uint8_t result = USBD_OK;
- /* USER CODE BEGIN 13 */
- UNUSED(Buf);
- UNUSED(Len);
- UNUSED(epnum);
- /* USER CODE END 13 */
- return result;
-}
-
-/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
-
-/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usbd_cdc_if.h
- * @version : v1.0_Cube
- * @brief : Header for usbd_cdc_if.c file.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USBD_CDC_IF_H__
-#define __USBD_CDC_IF_H__
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_cdc.h"
-
-/* USER CODE BEGIN INCLUDE */
-
-/* USER CODE END INCLUDE */
-
-/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
- * @brief For Usb device.
- * @{
- */
-
-/** @defgroup USBD_CDC_IF USBD_CDC_IF
- * @brief Usb VCP device module
- * @{
- */
-
-/** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
- * @brief Defines.
- * @{
- */
-/* Define size for the receive and transmit buffer over CDC */
-#define APP_RX_DATA_SIZE 2048
-#define APP_TX_DATA_SIZE 2048
-/* USER CODE BEGIN EXPORTED_DEFINES */
-
-/* USER CODE END EXPORTED_DEFINES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
- * @brief Types.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_TYPES */
-
-/* USER CODE END EXPORTED_TYPES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
- * @brief Aliases.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_MACRO */
-
-/* USER CODE END EXPORTED_MACRO */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
- * @brief Public variables.
- * @{
- */
-
-/** CDC Interface callback. */
-extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
-
-/* USER CODE BEGIN EXPORTED_VARIABLES */
-
-/* USER CODE END EXPORTED_VARIABLES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
- * @brief Public functions declaration.
- * @{
- */
-
-uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
-
-/* USER CODE BEGIN EXPORTED_FUNCTIONS */
-
-/* USER CODE END EXPORTED_FUNCTIONS */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_CDC_IF_H__ */
-
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : App/usbd_desc.c
- * @version : v1.0_Cube
- * @brief : This file implements the USB device descriptors.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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_core.h"
-#include "usbd_desc.h"
-#include "usbd_conf.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
- * @{
- */
-
-/** @addtogroup USBD_DESC
- * @{
- */
-
-/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
- * @brief Private types.
- * @{
- */
-
-/* USER CODE BEGIN PRIVATE_TYPES */
-
-/* USER CODE END PRIVATE_TYPES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
- * @brief Private defines.
- * @{
- */
-
-#define USBD_VID 1155
-#define USBD_LANGID_STRING 1033
-#define USBD_MANUFACTURER_STRING "STMicroelectronics"
-#define USBD_PID_FS 22336
-#define USBD_PRODUCT_STRING_FS "STM32 Virtual ComPort"
-#define USBD_CONFIGURATION_STRING_FS "CDC Config"
-#define USBD_INTERFACE_STRING_FS "CDC Interface"
-
-#define USB_SIZ_BOS_DESC 0x0C
-
-/* USER CODE BEGIN PRIVATE_DEFINES */
-
-/* USER CODE END PRIVATE_DEFINES */
-
-/**
- * @}
- */
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
- * @brief Private macros.
- * @{
- */
-
-/* USER CODE BEGIN PRIVATE_MACRO */
-
-/* USER CODE END PRIVATE_MACRO */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
- * @brief Private functions declaration.
- * @{
- */
-
-static void Get_SerialNum(void);
-static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
- * @brief Private functions declaration for FS.
- * @{
- */
-
-uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-#if (USBD_LPM_ENABLED == 1)
-uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
-#endif /* (USBD_LPM_ENABLED == 1) */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
- * @brief Private variables.
- * @{
- */
-
-USBD_DescriptorsTypeDef FS_Desc =
-{
- USBD_FS_DeviceDescriptor
-, USBD_FS_LangIDStrDescriptor
-, USBD_FS_ManufacturerStrDescriptor
-, USBD_FS_ProductStrDescriptor
-, USBD_FS_SerialStrDescriptor
-, USBD_FS_ConfigStrDescriptor
-, USBD_FS_InterfaceStrDescriptor
-#if (USBD_LPM_ENABLED == 1)
-, USBD_FS_USR_BOSDescriptor
-#endif /* (USBD_LPM_ENABLED == 1) */
-};
-
-#if defined ( __ICCARM__ ) /* IAR Compiler */
- #pragma data_alignment=4
-#endif /* defined ( __ICCARM__ ) */
-/** USB standard device descriptor. */
-__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
-{
- 0x12, /*bLength */
- USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
-#if (USBD_LPM_ENABLED == 1)
- 0x01, /*bcdUSB */ /* changed to USB version 2.01
- in order to support LPM L1 suspend
- resume test of USBCV3.0*/
-#else
- 0x00, /*bcdUSB */
-#endif /* (USBD_LPM_ENABLED == 1) */
- 0x02,
- 0x02, /*bDeviceClass*/
- 0x02, /*bDeviceSubClass*/
- 0x00, /*bDeviceProtocol*/
- USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
- LOBYTE(USBD_VID), /*idVendor*/
- HIBYTE(USBD_VID), /*idVendor*/
- LOBYTE(USBD_PID_FS), /*idProduct*/
- HIBYTE(USBD_PID_FS), /*idProduct*/
- 0x00, /*bcdDevice rel. 2.00*/
- 0x02,
- USBD_IDX_MFC_STR, /*Index of manufacturer string*/
- USBD_IDX_PRODUCT_STR, /*Index of product string*/
- USBD_IDX_SERIAL_STR, /*Index of serial number string*/
- USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/
-};
-
-/* USB_DeviceDescriptor */
-/** BOS descriptor. */
-#if (USBD_LPM_ENABLED == 1)
-#if defined ( __ICCARM__ ) /* IAR Compiler */
- #pragma data_alignment=4
-#endif /* defined ( __ICCARM__ ) */
-__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
-{
- 0x5,
- USB_DESC_TYPE_BOS,
- 0xC,
- 0x0,
- 0x1, /* 1 device capability*/
- /* device capability*/
- 0x7,
- USB_DEVICE_CAPABITY_TYPE,
- 0x2,
- 0x2, /* LPM capability bit set*/
- 0x0,
- 0x0,
- 0x0
-};
-#endif /* (USBD_LPM_ENABLED == 1) */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
- * @brief Private variables.
- * @{
- */
-
-#if defined ( __ICCARM__ ) /* IAR Compiler */
- #pragma data_alignment=4
-#endif /* defined ( __ICCARM__ ) */
-
-/** USB lang identifier descriptor. */
-__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
-{
- USB_LEN_LANGID_STR_DESC,
- USB_DESC_TYPE_STRING,
- LOBYTE(USBD_LANGID_STRING),
- HIBYTE(USBD_LANGID_STRING)
-};
-
-#if defined ( __ICCARM__ ) /* IAR Compiler */
- #pragma data_alignment=4
-#endif /* defined ( __ICCARM__ ) */
-/* Internal string descriptor. */
-__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
-
-#if defined ( __ICCARM__ ) /*!< IAR Compiler */
- #pragma data_alignment=4
-#endif
-__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
- USB_SIZ_STRING_SERIAL,
- USB_DESC_TYPE_STRING,
-};
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions
- * @brief Private functions.
- * @{
- */
-
-/**
- * @brief Return the device descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- UNUSED(speed);
- *length = sizeof(USBD_FS_DeviceDesc);
- return USBD_FS_DeviceDesc;
-}
-
-/**
- * @brief Return the LangID string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- UNUSED(speed);
- *length = sizeof(USBD_LangIDDesc);
- return USBD_LangIDDesc;
-}
-
-/**
- * @brief Return the product string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- if(speed == 0)
- {
- USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
- }
- else
- {
- USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
- }
- return USBD_StrDesc;
-}
-
-/**
- * @brief Return the manufacturer string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- UNUSED(speed);
- USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
- return USBD_StrDesc;
-}
-
-/**
- * @brief Return the serial number string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- UNUSED(speed);
- *length = USB_SIZ_STRING_SERIAL;
-
- /* Update the serial number string descriptor with the data from the unique
- * ID */
- Get_SerialNum();
- /* USER CODE BEGIN USBD_FS_SerialStrDescriptor */
-
- /* USER CODE END USBD_FS_SerialStrDescriptor */
- return (uint8_t *) USBD_StringSerial;
-}
-
-/**
- * @brief Return the configuration string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- if(speed == USBD_SPEED_HIGH)
- {
- USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
- }
- else
- {
- USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length);
- }
- return USBD_StrDesc;
-}
-
-/**
- * @brief Return the interface string descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- if(speed == 0)
- {
- USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
- }
- else
- {
- USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
- }
- return USBD_StrDesc;
-}
-
-#if (USBD_LPM_ENABLED == 1)
-/**
- * @brief Return the BOS descriptor
- * @param speed : Current device speed
- * @param length : Pointer to data length variable
- * @retval Pointer to descriptor buffer
- */
-uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
-{
- UNUSED(speed);
- *length = sizeof(USBD_FS_BOSDesc);
- return (uint8_t*)USBD_FS_BOSDesc;
-}
-#endif /* (USBD_LPM_ENABLED == 1) */
-
-/**
- * @brief Create the serial number string descriptor
- * @param None
- * @retval None
- */
-static void Get_SerialNum(void)
-{
- uint32_t deviceserial0;
- uint32_t deviceserial1;
- uint32_t deviceserial2;
-
- deviceserial0 = *(uint32_t *) DEVICE_ID1;
- deviceserial1 = *(uint32_t *) DEVICE_ID2;
- deviceserial2 = *(uint32_t *) DEVICE_ID3;
-
- deviceserial0 += deviceserial2;
-
- if (deviceserial0 != 0)
- {
- IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
- IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
- }
-}
-
-/**
- * @brief Convert Hex 32Bits value into char
- * @param value: value to convert
- * @param pbuf: pointer to the buffer
- * @param len: buffer length
- * @retval None
- */
-static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
-{
- uint8_t idx = 0;
-
- for (idx = 0; idx < len; idx++)
- {
- if (((value >> 28)) < 0xA)
- {
- pbuf[2 * idx] = (value >> 28) + '0';
- }
- else
- {
- pbuf[2 * idx] = (value >> 28) + 'A' - 10;
- }
-
- value = value << 4;
-
- pbuf[2 * idx + 1] = 0;
- }
-}
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usbd_desc.c
- * @version : v1.0_Cube
- * @brief : Header for usbd_conf.c file.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 */
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USBD_DESC__C__
-#define __USBD_DESC__C__
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "usbd_def.h"
-
-/* USER CODE BEGIN INCLUDE */
-
-/* USER CODE END INCLUDE */
-
-/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
- * @{
- */
-
-/** @defgroup USBD_DESC USBD_DESC
- * @brief Usb device descriptors module.
- * @{
- */
-
-/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
- * @brief Constants.
- * @{
- */
-#define DEVICE_ID1 (UID_BASE)
-#define DEVICE_ID2 (UID_BASE + 0x4)
-#define DEVICE_ID3 (UID_BASE + 0x8)
-
-#define USB_SIZ_STRING_SERIAL 0x1A
-
-/* USER CODE BEGIN EXPORTED_CONSTANTS */
-
-/* USER CODE END EXPORTED_CONSTANTS */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
- * @brief Defines.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_DEFINES */
-
-/* USER CODE END EXPORTED_DEFINES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
- * @brief Types.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_TYPES */
-
-/* USER CODE END EXPORTED_TYPES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
- * @brief Aliases.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_MACRO */
-
-/* USER CODE END EXPORTED_MACRO */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
- * @brief Public variables.
- * @{
- */
-
-/** Descriptor for the Usb device. */
-extern USBD_DescriptorsTypeDef FS_Desc;
-
-/* USER CODE BEGIN EXPORTED_VARIABLES */
-
-/* USER CODE END EXPORTED_VARIABLES */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
- * @brief Public functions declaration.
- * @{
- */
-
-/* USER CODE BEGIN EXPORTED_FUNCTIONS */
-
-/* USER CODE END EXPORTED_FUNCTIONS */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_DESC__C__ */
-
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : Target/usbd_conf.c
- * @version : v1.0_Cube
- * @brief : This file implements the board support package for the USB device library
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 "stm32f4xx.h"
-#include "stm32f4xx_hal.h"
-#include "usbd_def.h"
-#include "usbd_core.h"
-
-#include "usbd_cdc.h"
-
-/* USER CODE BEGIN Includes */
-
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-
-/* USER CODE BEGIN PV */
-/* Private variables ---------------------------------------------------------*/
-
-/* USER CODE END PV */
-
-PCD_HandleTypeDef hpcd_USB_OTG_FS;
-void Error_Handler(void);
-
-/* External functions --------------------------------------------------------*/
-void SystemClock_Config(void);
-
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/* USER CODE BEGIN PFP */
-/* Private function prototypes -----------------------------------------------*/
-USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status);
-
-/* USER CODE END PFP */
-
-/* Private functions ---------------------------------------------------------*/
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
-
-/*******************************************************************************
- LL Driver Callbacks (PCD -> USB Device Library)
-*******************************************************************************/
-/* MSP Init */
-
-void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(pcdHandle->Instance==USB_OTG_FS)
- {
- /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
-
- /* USER CODE END USB_OTG_FS_MspInit 0 */
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**USB_OTG_FS GPIO Configuration
- PA11 ------> USB_OTG_FS_DM
- PA12 ------> USB_OTG_FS_DP
- */
- GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* Peripheral clock enable */
- __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
-
- /* Peripheral interrupt init */
- HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
- HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
- /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
-
- /* USER CODE END USB_OTG_FS_MspInit 1 */
- }
-}
-
-void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
-{
- if(pcdHandle->Instance==USB_OTG_FS)
- {
- /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
-
- /* USER CODE END USB_OTG_FS_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USB_OTG_FS_CLK_DISABLE();
-
- /**USB_OTG_FS GPIO Configuration
- PA11 ------> USB_OTG_FS_DM
- PA12 ------> USB_OTG_FS_DP
- */
- HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
-
- /* Peripheral interrupt Deinit*/
- HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
-
- /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
-
- /* USER CODE END USB_OTG_FS_MspDeInit 1 */
- }
-}
-
-/**
- * @brief Setup stage callback
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup);
-}
-
-/**
- * @brief Data Out stage callback.
- * @param hpcd: PCD handle
- * @param epnum: Endpoint number
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#else
-void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
-}
-
-/**
- * @brief Data In stage callback.
- * @param hpcd: PCD handle
- * @param epnum: Endpoint number
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#else
-void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
-}
-
-/**
- * @brief SOF callback.
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData);
-}
-
-/**
- * @brief Reset callback.
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
-
- if ( hpcd->Init.speed == PCD_SPEED_HIGH)
- {
- speed = USBD_SPEED_HIGH;
- }
- else if ( hpcd->Init.speed == PCD_SPEED_FULL)
- {
- speed = USBD_SPEED_FULL;
- }
- else
- {
- Error_Handler();
- }
- /* Set Speed. */
- USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed);
-
- /* Reset Device. */
- USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData);
-}
-
-/**
- * @brief Suspend callback.
- * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- /* Inform USB library that core enters in suspend Mode. */
- USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
- __HAL_PCD_GATE_PHYCLOCK(hpcd);
- /* Enter in STOP mode. */
- /* USER CODE BEGIN 2 */
- if (hpcd->Init.low_power_enable)
- {
- /* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
- SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
- }
- /* USER CODE END 2 */
-}
-
-/**
- * @brief Resume callback.
- * When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- /* USER CODE BEGIN 3 */
-
- /* USER CODE END 3 */
- USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData);
-}
-
-/**
- * @brief ISOOUTIncomplete callback.
- * @param hpcd: PCD handle
- * @param epnum: Endpoint number
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#else
-void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
-}
-
-/**
- * @brief ISOINIncomplete callback.
- * @param hpcd: PCD handle
- * @param epnum: Endpoint number
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#else
-void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
-}
-
-/**
- * @brief Connect callback.
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData);
-}
-
-/**
- * @brief Disconnect callback.
- * @param hpcd: PCD handle
- * @retval None
- */
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
-static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
-#else
-void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
-{
- USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData);
-}
-
-/*******************************************************************************
- LL Driver Interface (USB Device Library --> PCD)
-*******************************************************************************/
-
-/**
- * @brief Initializes the low level portion of the device driver.
- * @param pdev: Device handle
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
-{
- /* Init USB Ip. */
- if (pdev->id == DEVICE_FS) {
- /* Link the driver to the stack. */
- hpcd_USB_OTG_FS.pData = pdev;
- pdev->pData = &hpcd_USB_OTG_FS;
-
- hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
- hpcd_USB_OTG_FS.Init.dev_endpoints = 4;
- hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
- hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
- hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;
- hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
- if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)
- {
- Error_Handler( );
- }
-
-#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
- /* Register USB PCD CallBacks */
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback);
- HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback);
-
- HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback);
- HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback);
- HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback);
- HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback);
-#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
- HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
- HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
- HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
- }
- return USBD_OK;
-}
-
-/**
- * @brief De-Initializes the low level portion of the device driver.
- * @param pdev: Device handle
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_DeInit(pdev->pData);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Starts the low level portion of the device driver.
- * @param pdev: Device handle
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_Start(pdev->pData);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Stops the low level portion of the device driver.
- * @param pdev: Device handle
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_Stop(pdev->pData);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Opens an endpoint of the low level driver.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @param ep_type: Endpoint type
- * @param ep_mps: Endpoint max packet size
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Closes an endpoint of the low level driver.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Flushes an endpoint of the Low Level Driver.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Sets a Stall condition on an endpoint of the Low Level Driver.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Clears a Stall condition on an endpoint of the Low Level Driver.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Returns Stall condition.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval Stall (1: Yes, 0: No)
- */
-uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData;
-
- if((ep_addr & 0x80) == 0x80)
- {
- return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
- }
- else
- {
- return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
- }
-}
-
-/**
- * @brief Assigns a USB address to the device.
- * @param pdev: Device handle
- * @param dev_addr: Device address
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Transmits data over an endpoint.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @param pbuf: Pointer to data to be sent
- * @param size: Data size
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Prepares an endpoint for reception.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @param pbuf: Pointer to data to be received
- * @param size: Data size
- * @retval USBD status
- */
-USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
-{
- HAL_StatusTypeDef hal_status = HAL_OK;
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
-
- usb_status = USBD_Get_USB_Status(hal_status);
-
- return usb_status;
-}
-
-/**
- * @brief Returns the last transferred packet size.
- * @param pdev: Device handle
- * @param ep_addr: Endpoint number
- * @retval Received Data Size
- */
-uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
-{
- return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr);
-}
-
-#ifdef USBD_HS_TESTMODE_ENABLE
-/**
- * @brief Set High speed Test mode.
- * @param pdev: Device handle
- * @param testmode: test mode
- * @retval USBD Status
- */
-USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode)
-{
- UNUSED(pdev);
- UNUSED(testmode);
-
- return USBD_OK;
-}
-#endif /* USBD_HS_TESTMODE_ENABLE */
-
-/**
- * @brief Static single allocation.
- * @param size: Size of allocated memory
- * @retval None
- */
-void *USBD_static_malloc(uint32_t size)
-{
- static uint32_t mem[(sizeof(USBD_CDC_HandleTypeDef)/4)+1];/* On 32-bit boundary */
- return mem;
-}
-
-/**
- * @brief Dummy memory free
- * @param p: Pointer to allocated memory address
- * @retval None
- */
-void USBD_static_free(void *p)
-{
-
-}
-
-/**
- * @brief Delays routine for the USB Device Library.
- * @param Delay: Delay in ms
- * @retval None
- */
-void USBD_LL_Delay(uint32_t Delay)
-{
- HAL_Delay(Delay);
-}
-
-/**
- * @brief Returns the USB status depending on the HAL status:
- * @param hal_status: HAL status
- * @retval USB status
- */
-USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status)
-{
- USBD_StatusTypeDef usb_status = USBD_OK;
-
- switch (hal_status)
- {
- case HAL_OK :
- usb_status = USBD_OK;
- break;
- case HAL_ERROR :
- usb_status = USBD_FAIL;
- break;
- case HAL_BUSY :
- usb_status = USBD_BUSY;
- break;
- case HAL_TIMEOUT :
- usb_status = USBD_FAIL;
- break;
- default :
- usb_status = USBD_FAIL;
- break;
- }
- return usb_status;
-}
+++ /dev/null
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file : usbd_conf.h
- * @version : v1.0_Cube
- * @brief : Header for usbd_conf.c file.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 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 */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __USBD_CONF__H__
-#define __USBD_CONF__H__
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "main.h"
-#include "stm32f4xx.h"
-#include "stm32f4xx_hal.h"
-
-/* USER CODE BEGIN INCLUDE */
-
-/* USER CODE END INCLUDE */
-
-/** @addtogroup USBD_OTG_DRIVER
- * @brief Driver for Usb device.
- * @{
- */
-
-/** @defgroup USBD_CONF USBD_CONF
- * @brief Configuration file for Usb otg low level driver.
- * @{
- */
-
-/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
- * @brief Public variables.
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
- * @brief Defines for configuration of the Usb device.
- * @{
- */
-
-/*---------- -----------*/
-#define USBD_MAX_NUM_INTERFACES 1U
-/*---------- -----------*/
-#define USBD_MAX_NUM_CONFIGURATION 1U
-/*---------- -----------*/
-#define USBD_MAX_STR_DESC_SIZ 512U
-/*---------- -----------*/
-#define USBD_DEBUG_LEVEL 0U
-/*---------- -----------*/
-#define USBD_LPM_ENABLED 0U
-/*---------- -----------*/
-#define USBD_SELF_POWERED 1U
-
-/****************************************/
-/* #define for FS and HS identification */
-#define DEVICE_FS 0
-#define DEVICE_HS 1
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
- * @brief Aliases.
- * @{
- */
-/* Memory management macros make sure to use static memory allocation */
-/** Alias for memory allocation. */
-
-#define USBD_malloc (void *)USBD_static_malloc
-
-/** Alias for memory release. */
-#define USBD_free USBD_static_free
-
-/** Alias for memory set. */
-#define USBD_memset memset
-
-/** Alias for memory copy. */
-#define USBD_memcpy memcpy
-
-/** Alias for delay. */
-#define USBD_Delay HAL_Delay
-
-/* DEBUG macros */
-
-#if (USBD_DEBUG_LEVEL > 0)
-#define USBD_UsrLog(...) printf(__VA_ARGS__);\
- printf("\n");
-#else
-#define USBD_UsrLog(...)
-#endif /* (USBD_DEBUG_LEVEL > 0U) */
-
-#if (USBD_DEBUG_LEVEL > 1)
-
-#define USBD_ErrLog(...) printf("ERROR: ");\
- printf(__VA_ARGS__);\
- printf("\n");
-#else
-#define USBD_ErrLog(...)
-#endif /* (USBD_DEBUG_LEVEL > 1U) */
-
-#if (USBD_DEBUG_LEVEL > 2)
-#define USBD_DbgLog(...) printf("DEBUG : ");\
- printf(__VA_ARGS__);\
- printf("\n");
-#else
-#define USBD_DbgLog(...)
-#endif /* (USBD_DEBUG_LEVEL > 2U) */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
- * @brief Types.
- * @{
- */
-
-/**
- * @}
- */
-
-/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
- * @brief Declaration of public functions for Usb device.
- * @{
- */
-
-/* Exported functions -------------------------------------------------------*/
-void *USBD_static_malloc(uint32_t size);
-void USBD_static_free(void *p);
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __USBD_CONF__H__ */
-
ETH.MediaInterface=HAL_ETH_RMII_MODE
FREERTOS.FootprintOK=true
FREERTOS.IPParameters=Tasks01,FootprintOK
-FREERTOS.Tasks01=defaultTask,24,128,main_task,As weak,NULL,Dynamic,NULL,NULL;bdTask,8,128,bd_task,As weak,NULL,Dynamic,NULL,NULL
+FREERTOS.Tasks01=defaultTask,24,512,main_task,As weak,NULL,Dynamic,NULL,NULL;bdTask,8,128,bd_task,As weak,NULL,Dynamic,NULL,NULL
File.Version=6
GPIO.groupedBy=Group By Peripherals
KeepUserPlacement=false
LWIP.BSP.number=1
+LWIP.GATEWAY_ADDRESS=192.168.001.001
+LWIP.IPParameters=LWIP_DHCP,LWIP_DBG_MIN_LEVEL,IP_ADDRESS,NETMASK_ADDRESS,GATEWAY_ADDRESS
+LWIP.IP_ADDRESS=192.168.001.200
+LWIP.LWIP_DBG_MIN_LEVEL=LWIP_DBG_LEVEL_ALL
+LWIP.LWIP_DHCP=0
+LWIP.NETMASK_ADDRESS=255.255.255.000
LWIP.Version=v2.1.2_Cube
LWIP0.BSP.STBoard=false
LWIP0.BSP.api=BSP_COMPONENT_DRIVER
Mcu.Family=STM32F4
Mcu.IP0=ADC1
Mcu.IP1=DMA
-Mcu.IP10=UART4
-Mcu.IP11=UART5
-Mcu.IP12=USART1
-Mcu.IP13=USART2
-Mcu.IP14=USART3
-Mcu.IP15=USART6
-Mcu.IP16=USB_DEVICE
-Mcu.IP17=USB_OTG_FS
+Mcu.IP10=TIM3
+Mcu.IP11=UART4
+Mcu.IP12=UART5
+Mcu.IP13=USART1
+Mcu.IP14=USART2
+Mcu.IP15=USART3
+Mcu.IP16=USART6
Mcu.IP2=ETH
Mcu.IP3=FREERTOS
Mcu.IP4=I2C3
Mcu.IP7=RCC
Mcu.IP8=SYS
Mcu.IP9=TIM2
-Mcu.IPNb=18
+Mcu.IPNb=17
Mcu.Name=STM32F407V(E-G)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PE3
Mcu.Pin31=PA8
Mcu.Pin32=PA9
Mcu.Pin33=PA10
-Mcu.Pin34=PA11
-Mcu.Pin35=PA12
-Mcu.Pin36=PA13
-Mcu.Pin37=PA14
-Mcu.Pin38=PC10
-Mcu.Pin39=PC11
+Mcu.Pin34=PA13
+Mcu.Pin35=PA14
+Mcu.Pin36=PC10
+Mcu.Pin37=PC11
+Mcu.Pin38=PC12
+Mcu.Pin39=PD2
Mcu.Pin4=PH1-OSC_OUT
-Mcu.Pin40=PC12
-Mcu.Pin41=PD2
-Mcu.Pin42=PD4
-Mcu.Pin43=PD5
-Mcu.Pin44=PD6
-Mcu.Pin45=PD7
-Mcu.Pin46=PB5
-Mcu.Pin47=PE1
-Mcu.Pin48=VP_FREERTOS_VS_CMSIS_V2
-Mcu.Pin49=VP_LWIP_VS_Enabled
+Mcu.Pin40=PD4
+Mcu.Pin41=PD5
+Mcu.Pin42=PD6
+Mcu.Pin43=PD7
+Mcu.Pin44=PB5
+Mcu.Pin45=PE1
+Mcu.Pin46=VP_FREERTOS_VS_CMSIS_V2
+Mcu.Pin47=VP_LWIP_VS_Enabled
+Mcu.Pin48=VP_SYS_VS_tim1
+Mcu.Pin49=VP_TIM2_VS_ClockSourceINT
Mcu.Pin5=PC1
-Mcu.Pin50=VP_SYS_VS_tim1
-Mcu.Pin51=VP_TIM2_VS_ClockSourceINT
-Mcu.Pin52=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
+Mcu.Pin50=VP_TIM3_VS_ClockSourceINT
Mcu.Pin6=PA1
Mcu.Pin7=PA2
Mcu.Pin8=PA4
Mcu.Pin9=PA5
-Mcu.PinsNb=53
+Mcu.PinsNb=51
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0
Mcu.ThirdPartyNb=1
Mcu.UserConstants=
NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.ETH_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
+NVIC.EXTI3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
-NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false
NVIC.TIM1_UP_TIM10_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
NVIC.TimeBase=TIM1_UP_TIM10_IRQn
NVIC.TimeBaseIP=TIM1
+NVIC.UART4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
+NVIC.UART5_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.USART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.USART2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
PA10.Locked=true
PA10.Mode=Asynchronous
PA10.Signal=USART1_RX
-PA11.Mode=Device_Only
-PA11.Signal=USB_OTG_FS_DM
-PA12.Mode=Device_Only
-PA12.Signal=USB_OTG_FS_DP
PA13.Locked=true
PA13.Mode=Serial_Wire
PA13.Signal=SYS_JTMS-SWDIO
PD13.GPIOParameters=PinState,GPIO_Label
PD13.GPIO_Label=PD13_GPS_RST_EN
PD13.Locked=true
-PD13.PinState=GPIO_PIN_SET
+PD13.PinState=GPIO_PIN_RESET
PD13.Signal=GPIO_Output
PD14.GPIOParameters=GPIO_Label
PD14.GPIO_Label=PD14_LORA_M0
PE1.GPIO_Label=SYS_LED
PE1.Locked=true
PE1.Signal=GPIO_Output
-PE3.GPIOParameters=GPIO_Label
+PE3.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
PE3.GPIO_Label=DQ_IN
+PE3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
PE3.Locked=true
-PE3.Signal=GPIO_Input
+PE3.Signal=GPXTI3
PH0-OSC_IN.Locked=true
PH0-OSC_IN.Mode=HSE-External-Oscillator
PH0-OSC_IN.Signal=RCC_OSC_IN
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_UART4_Init-UART4-false-HAL-true,7-MX_UART5_Init-UART5-false-HAL-true,8-MX_USART1_UART_Init-USART1-false-HAL-true,9-MX_USART2_UART_Init-USART2-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_USART6_UART_Init-USART6-false-HAL-true,12-MX_LWIP_Init-LWIP-false-HAL-false,13-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,14-MX_TIM2_Init-TIM2-false-HAL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_UART4_Init-UART4-false-HAL-true,7-MX_UART5_Init-UART5-false-HAL-true,8-MX_USART1_UART_Init-USART1-false-HAL-true,9-MX_USART2_UART_Init-USART2-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_USART6_UART_Init-USART6-false-HAL-true,12-MX_LWIP_Init-LWIP-false-HAL-false,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true
RCC.48MHZClocksFreq_Value=48000000
RCC.AHBFreq_Value=168000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
RCC.HSE_VALUE=8000000
RCC.HSI_VALUE=16000000
RCC.I2SClocksFreq_Value=96000000
-RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
+RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQ,PLLQCLKFreq_Value,PLLSourceVirtual,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S
RCC.LSI_VALUE=32000
RCC.MCO2PinFreq_Value=168000000
RCC.PLLCLKFreq_Value=168000000
RCC.PLLN=336
RCC.PLLQ=7
RCC.PLLQCLKFreq_Value=48000000
+RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
RCC.RTCFreq_Value=32000
RCC.RTCHSEDivFreq_Value=4000000
RCC.SYSCLKFreq_VALUE=168000000
SH.GPXTI12.ConfNb=1
SH.GPXTI14.0=GPIO_EXTI14
SH.GPXTI14.ConfNb=1
+SH.GPXTI3.0=GPIO_EXTI3
+SH.GPXTI3.ConfNb=1
STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0_SwParameter=LibraryCcDSPOoLibraryJjDSPOoLibrary\:true;
TIM2.IPParameters=TIM_MasterOutputTrigger,Prescaler,Period
TIM2.Period=100
USART6.BaudRate=9600
USART6.IPParameters=VirtualMode,BaudRate
USART6.VirtualMode=VM_ASYNC
-USB_DEVICE.CLASS_NAME_FS=CDC
-USB_DEVICE.IPParameters=VirtualMode-CDC_FS,VirtualModeFS,CLASS_NAME_FS
-USB_DEVICE.VirtualMode-CDC_FS=Cdc
-USB_DEVICE.VirtualModeFS=Cdc_FS
-USB_OTG_FS.IPParameters=VirtualMode
-USB_OTG_FS.VirtualMode=Device_Only
VP_FREERTOS_VS_CMSIS_V2.Mode=CMSIS_V2
VP_FREERTOS_VS_CMSIS_V2.Signal=FREERTOS_VS_CMSIS_V2
VP_LWIP_VS_Enabled.Mode=Enabled
VP_SYS_VS_tim1.Signal=SYS_VS_tim1
VP_TIM2_VS_ClockSourceINT.Mode=Internal
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
-VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS
-VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS
+VP_TIM3_VS_ClockSourceINT.Mode=Internal
+VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
board=custom
rtos.0.ip=FREERTOS
p_sound.setTitle(u"声音数据波形图")
p_sound.addLegend()
self.curve_sound = p_sound.plot(pen="r",name="声音数据")
- self.curve_sound_2 = p_sound.plot(pen="b",name="声音数据2")
- self.curve_sound_3 = p_sound.plot(pen="g",name="声音数据2")
+ self.curve_sound2 = p_sound.plot(pen="g",name="声音数据2")
+ self.curve_sound3 = p_sound.plot(pen="b",name="声音数据2")
self.sound_x = []
self.sound_y = []
- self.sound_y_2 = []
- self.sound_y_3 = []
+ self.sound_y2 = []
+ self.sound_y3 = []
self.sound_y_last = 0
def on_rx_pkt( self, pkt_raw ):
if len(pkt_raw)==4:
- if( len(self.sound_y) > 10*300):
+ if( len(self.sound_y) > 240):
self.sound_y = self.sound_y[1:]
+ if( len(self.sound_y2) > 240):
+ self.sound_y2 = self.sound_y2[1:]
y = struct.unpack( "<L", pkt_raw[0:4])[0]
#filter_y = signal.filtfilt(b, a, y ) #data为要过滤的信号
#print( "filter y type:", type( filter_y ) )
self.sound_y += [y]
- self.sound_x = list( map( lambda x:x/10.0, range( len( self.sound_y ) )))
+ self.sound_x = list( map( lambda x:x/2.0, range( len( self.sound_y ) )))
+ self.curve_sound.setData( np.array( self.sound_x), np.array( self.sound_y))
+ elif len(pkt_raw)==8:
+ if( len(self.sound_y) > 240):
+ self.sound_y = self.sound_y[1:]
+ self.sound_y2 = self.sound_y2[1:]
+ y = struct.unpack( "<L", pkt_raw[0:4])[0]
+ y2 = struct.unpack( "<L", pkt_raw[4:8])[0]
+ #filter_y = signal.filtfilt(b, a, y ) #data为要过滤的信号
+ #print( "filter y type:", type( filter_y ) )
+ self.sound_y += [y]
+ self.sound_x = list( map( lambda x:x/2.0, range( len( self.sound_y ) )))
self.curve_sound.setData( np.array( self.sound_x), np.array( self.sound_y))
+ self.sound_y2 += [y2]
+ self.curve_sound2.setData( np.array( self.sound_x), np.array( self.sound_y2))
elif len(pkt_raw)==2048:
#b, a = signal.butter( 8 , 500*2/10000 , 'lowpass' ) #配置滤波器 8 表示滤波器的阶数
#print( "B,A:", b, a )
self.rx_buf += data
if len(self.rx_buf) == 4: #2048:
self.trigger_rx_pkt.emit( self.rx_buf )
+ elif len(self.rx_buf) == 8: #2048:
+ self.trigger_rx_pkt.emit( self.rx_buf )
if len(self.rx_buf) >= 4: #2048:
self.rx_buf = b''
return
#include "main.h"
#include "cmsis_os.h"
#include "lwip.h"
-#include "usb_device.h"
#include "user_noise_sensor.h"
+typedef osMutexId_t user_lock_t;
+
+typedef struct{
+ uint8_t state;
+ float db;
+}noise_t;
+typedef struct{
+ uint8_t state;
+ float freq;
+}sound_t;
+typedef struct{
+ uint8_t state;
+ float lat;
+ float lon;
+}position_t;
+
+typedef struct{
+ noise_t noise;
+ sound_t sound;
+ position_t pos;
+}sensor_info_t;
+
+typedef struct{
+ sensor_info_t sensor;
+ user_lock_t lock;
+}dev_t;
+
//adc
void user_adc_init( void );
void user_adc_start( void );
+//
+void user_noise_info_update( float db );
+void user_sound_info_update( float freq );
+void user_sensor_info_read( sensor_info_t *info );
//modbus crc16
uint16_t usMBCRC16( uint8_t* pucFrame, uint32_t usLen );
#define PIN_HIGH( PIN ) HAL_GPIO_WritePin( PIN##_GPIO_Port, PIN##_Pin, GPIO_PIN_SET)
#define PIN_LOW( PIN ) HAL_GPIO_WritePin( PIN##_GPIO_Port, PIN##_Pin, GPIO_PIN_RESET)
#define PIN_READ( PIN ) HAL_GPIO_ReadPin( PIN##_GPIO_Port, PIN##_Pin )
+
+extern dev_t g_dev;
uint16_t adc_raw[FFT_SIZE];
uint16_t out_u16[FFT_SIZE];
-
+void arm_max_f32_2( const float32_t * pSrc, uint32_t blockSize, float32_t * pResult, uint32_t * pIndex)
+{
+ float *p = (float*)pSrc;
+ int i=10;
+ float max_v = *pSrc;
+ for( i=10; i<blockSize; i++ ){
+ if( pSrc[i] < max_v )
+ break;
+ max_v = pSrc[i];
+ }
+ *pResult = max_v;
+ *pIndex = i;
+}
extern void user_data_lp( uint16_t *in, uint16_t *out, int len );
-volatile float signalFreq;
-volatile float32_t maxValue;
-volatile uint32_t maxIndex;
+float signalFreq;
+float32_t maxValue;
+uint32_t maxIndex;
static float32_t input[FFT_SIZE*2]; // ʵ²¿+Ð鲿
static float32_t output[FFT_SIZE];
uint32_t adc_finished = 0;
-void adc_fft( void )
+//ÓÃfft¼ÆË㵱ǰÉùÒôADCÊý¾ÝµÄ400HzÒÔϵÄÉùÒôƵÂÊ£¬µ¥Î»Hz
+uint32_t adc_fft( uint16_t * sound_freq, uint16_t *sound_amplitude )
{
-static float last_freq_f = 0;
-uint32_t freq;
+ static float last_freq_f = 0;
+ uint32_t freq;
#if 1
+ //ÏȵÍͨÂ˲¨´¦Àí£¬È¥µô¸ßƵÐÅÏ¢
user_data_lp(adc_raw, out_u16,1024 );
//CDC_Transmit_FS( (uint8_t*)out_u16, 1024*2 );
#else
memcpy( out_u16, adc_raw, 1024*2 );
#endif
-
+
#if 1
- uint32_t start = HAL_GetTick();
-
- // ³õʼ»¯FFTʵÀý
- arm_cfft_init_f32(&fft_inst, FFT_SIZE);
-
- // Ìî³äÊý¾Ý£¨Êµ²¿ÎªADCÖµ£¬Ð鲿ÖÃ0£©
- for(int i=0; i<FFT_SIZE; i++) {
- input[2*i] = (float32_t)(out_u16[i]?out_u16[i]:1);
- input[2*i+1] = 0;
- }
-
- // Ö´ÐÐFFT
- arm_cfft_f32(&fft_inst, input, 0, 1);
-
- // ¼ÆËã·ùÖµ
- arm_cmplx_mag_f32(input, output, FFT_SIZE);
-
- // ѰÕÒ×î´ó·ùÖµ¶ÔÓ¦µÄƵÂÊ
- //float32_t maxValue;
- //uint32_t maxIndex;
- arm_max_f32(&output[1], 50, &maxValue, &maxIndex);
-
- // ¼ÆËãʵ¼ÊƵÂÊ
- signalFreq = (maxIndex * SAMPLE_RATE) / FFT_SIZE;
-// printf("Dominant Frequency: %.2f Hz\r\n", signalFreq);
- if( maxIndex < 2 ){
-/// printf( "aaa\n" );
- }
+ uint32_t start = HAL_GetTick();
- fft_ticks += HAL_GetTick() - start;
-#endif
-
- last_freq_f = (last_freq_f*9 + maxIndex*1)/10;
- //last_freq_f = maxIndex;
- freq = (uint32_t)last_freq_f;
-
- CDC_Transmit_FS( (uint8_t*)&freq, 4 );
+ // ³õʼ»¯FFTʵÀý
+ arm_cfft_init_f32(&fft_inst, FFT_SIZE);
+
+ // Ìî³äÊý¾Ý£¨Êµ²¿ÎªADCÖµ£¬Ð鲿ÖÃ0£©
+ for(int i=0; i<FFT_SIZE; i++) {
+ input[2*i] = (float32_t)(out_u16[i]?out_u16[i]:1);
+ input[2*i+1] = 0;
+ }
+
+ // Ö´ÐÐFFT
+ arm_cfft_f32(&fft_inst, input, 0, 1);
+
+ // ¼ÆËã·ùÖµ
+ arm_cmplx_mag_f32(input, output, FFT_SIZE);
+
+ // ѰÕÒ×î´ó·ùÖµ¶ÔÓ¦µÄƵÂÊ
+ //ÕâÀï²ÉÑùÂÊÊÇ10Khz£¬²ÉÑùÊý¾ÝÊÇ0.1Ãë 1000¸öµã£¬
+ //FFTÊä³öÊý¾Ý·Ö±æÂÊÊÇ10Hz£¬µÚÒ»¸öµãÊÇÖ±Á÷·ÖÁ¿£¬ ÕâÀïֻͳ¼ÆÇ°Ãæ50¸öµã¾ÍÊÇ500HzÊý¾Ý
+ arm_max_f32(&output[1], 42, &maxValue, &maxIndex);
+
+ // ¼ÆËãʵ¼ÊƵÂÊ
+ signalFreq = (maxIndex * SAMPLE_RATE) / FFT_SIZE;
+ //printf("Dominant Frequency: %.2f Hz\r\n", signalFreq);
+ if( *sound_freq ) *sound_freq = signalFreq;
+ if( *sound_amplitude ) *sound_amplitude = maxValue;
+
+ fft_ticks += HAL_GetTick() - start;
+ #endif
+
+ last_freq_f = (last_freq_f*9 + signalFreq*1)/10;
+ //last_freq_f = maxIndex;
+ freq = (uint32_t)last_freq_f;
+ uint32_t buf[2];
+ buf[0] = freq=maxIndex*10;
+ buf[1] = maxValue;
+ if(1){
+ uint32_t s=0;
+ uint32_t a = 0;
+ for( int i=0; i<1000; i++ ){
+ if( i>0 && out_u16[i]>out_u16[i-1] )
+ s+=out_u16[i];
+ }
+ buf[1] = s/1000;
+ }
+ //CDC_Transmit_FS( (uint8_t*)&buf[0], 8 );
+ return freq;
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
HAL_TIM_Base_Start( &htim2);
}
+
+static void user_sound_task(void *argument)
+{
+ uint16_t freq;
+ uint16_t amplitude;
+ static uint16_t last_freq = 0;
+ TickType_t ticks;
+ user_adc_init();
+
+ ticks = xTaskGetTickCount();
+ while(1){
+ ticks += 500;
+ osDelayUntil( ticks );
+ user_adc_start();
+ for( int i=0; i<50&&!adc_finished; i++ ){
+ osDelay(10);
+ }
+ if( adc_finished ){
+ adc_fft( &freq, &litude );
+ //user_sound_info_update( freq );
+ }
+ }
+}
+
+/*
+1ÃëÊý¾ÝÖ±½Ó·¢Ë͵½
+*/
+void sound_scan( uint16_t *ferq_data, uint16_t freq_data_cnt )
+{
+ //ƵÂÊÊý¾Ý×î´ó180¸öµã£¬ ÿ¸öµãÒ»Ã룬Ϊ²É¼¯µ½×î½ü180Ãëʱ¼äµÄÉùÒôƵÂÊ£¬
+ //°´Õâ¸öÊý¾ÝÅжϵ±Ç°±¨¾¯Æ÷µÄÉùÒôÀàÐÍ
+ //±¨¾¯Æ÷ÃùÏìΪ 400Hz£¬ ¹Ø±ÕΪ400HzÖð½¥½µµÍ¡£
+ //1.Ô¤ÏÈ£ºÏì36Ã룬ͣ24Ãë£¬ÖØ¸´Èý´Î
+ //2.¿ÕÏ®£ºÏì6Ã룬ͣ6Ãë£¬ÖØ¸´15´Î
+ //3.½â³ý£ºÏì180Ãë
+ //ÔÖÇéºÍ½âÔÖÎÞ¹ú¼Ò±ê×¼ÒÔϰ´º¼Öݶ¨Ò壺https://www.hangzhou.gov.cn/art/2024/5/6/art_812262_59096570.html
+ //4.ÔÖÇ飺Ïì60Ã룬ͣ30Ã룬·´¸´Á½±é£¬Ê±¼äÈý·ÖÖÓ
+ //5.½â³ýÔÖÇ飺·ÀÔÖ½â³ý¾¯±¨Ðźţ¨Á¬ÐøÃùÏìËÄ·ÖÖÓ£©
+
+
+
+}
+
+/* Definitions for defaultTask */
+osThreadId_t soundTaskHandle;
+const osThreadAttr_t soundTask_attributes = {
+ .name = "soundTask",
+ .stack_size = 1024*4,
+ .priority = (osPriority_t) osPriorityNormal,
+};
+
+void user_sound_task_start( void )
+{
+ soundTaskHandle = osThreadNew(user_sound_task, NULL, &soundTask_attributes);
+}
#include "user.h"
+
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern void user_shell_start( void );
+extern void user_sound_task_start( void );
+extern void user_noise_task_start( void );
extern void bd_rx_cb( void );
extern void shell_uart_rx_cb( void );
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
- if( huart->Instance == SENSOR_UART.Instance ){
- noise_sensor_rx_cb();
+ if( huart->Instance == USART1 ){
+ //USART1 debug shell
+ shell_uart_rx_cb();
+ }else if( huart->Instance == USART2 ){
+ //USART2 BD Tx/Rx
+
}else if( huart->Instance == USART3 ){
+ //USART3 Laki
+
+ }else if( huart->Instance == UART4 ){
+ //UART4 BD Location
bd_rx_cb();
- }else if( huart->Instance == USART2 ){
- shell_uart_rx_cb();
+ }else if( huart->Instance == UART5 ){
+ //UART5 Noise
+ noise_sensor_rx_cb();
+ }else if( huart->Instance == USART6 ){
+ //USART6 Lora
}
}
extern int user_noise_sensor_read_req( void );
extern void user_noise_sensor_rx_handle( void );
extern int user_noise_sensor_init( void );
+extern uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
+extern uint32_t adc_finished;
+extern void Tcp_Server_Init(void);
-void Tcp_Server_Init(void);
+dev_t g_dev;
int fputc( int ch, FILE *fd )
{
return 0;
}
-extern uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
-extern uint32_t adc_finished;
+user_lock_t user_lock_new( void )
+{
+ return osMutexNew(NULL);
+}
+
+void user_lock( user_lock_t lock )
+{
+ osMutexAcquire(lock, portMAX_DELAY );
+}
+void user_unlock( user_lock_t lock )
+{
+ osMutexRelease(lock);
+}
+
+void user_noise_info_update( float db )
+{
+ user_lock( g_dev.lock );
+ g_dev.sensor.noise.db = db;
+ user_unlock( g_dev.lock );
+}
+
+void user_sound_info_update( float freq )
+{
+ user_lock( g_dev.lock );
+ g_dev.sensor.sound.freq = freq;
+ user_unlock( g_dev.lock );
+}
+
+float user_noise_read( void )
+{
+ float db;
+ user_lock( g_dev.lock );
+ db = g_dev.sensor.noise.db;
+ user_unlock( g_dev.lock );
+ return db;
+}
+
+void user_sensor_info_read( sensor_info_t *info )
+{
+ user_lock( g_dev.lock );
+ memcpy( info, &g_dev.sensor, sizeof( *info ) );
+ user_unlock( g_dev.lock );
+}
+
+void user_dev_init( void )
+{
+ memset( &g_dev, 0, sizeof(g_dev ) );
+ g_dev.lock = user_lock_new();
+}
+
+extern int user_temperature_read( float *tem, float * hum );
void main_task(void *argument)
{
float noise;
char buf[100];
- /* init code for LWIP */
- //MX_LWIP_Init();
-
- /* init code for USB_DEVICE */
- MX_USB_DEVICE_Init();
- /* USER CODE BEGIN 5 */
- user_noise_sensor_init();
- user_adc_init();
+ uint32_t delay_ticks;
- //Tcp_Server_Init();
+ user_dev_init();
+ /* init code for LWIP */
+ MX_LWIP_Init();
+
+
+ Tcp_Server_Init();
+
user_shell_start();
- for(;;)
- {
-#if 0
-osDelay(110);
- if( user_noise_sensor_read( &noise ) == 0 ){
- sprintf( buf, "NOISE: %0.1f dB\n", noise );
- //CDC_Transmit_FS( (uint8_t*)buf, strlen(buf) );
-
- }else{
- sprintf( buf, "NOISE: read fail\n" );
- //CDC_Transmit_FS( (uint8_t*)buf, strlen(buf) );
- }
-#endif
- user_adc_start();
- while( !adc_finished ){
- osDelay(1);
- }
- adc_fft();
- osDelay(10);
- //user_noise_sensor_read_req();
- }
+ user_noise_task_start();
+ user_sound_task_start();
+
+ delay_ticks = xTaskGetTickCount();
+ for(;;)
+ {
+ delay_ticks += 1000;
+ osDelayUntil( delay_ticks );
+ {
+ //float tem,hum;
+ //user_temperature_read( &tem, &hum );
+ }
+ }
/* USER CODE END 5 */
}
void bd_rx_cb( void );
void bd_rx_start( void );
-extern UART_HandleTypeDef huart3;
+extern UART_HandleTypeDef huart4;
static uint8_t rx_byte;
static uint8_t bd_rx_buf[100];
void bd_rx_start( void )
{
- HAL_UART_Receive_IT( &huart3, &rx_byte, 1 );
+ HAL_UART_Receive_IT( &huart4, &rx_byte, 1 );
}
void bd_reset( uint32_t ms )
{
- PIN_LOW(PD13_GPS_RST_EN);
- osDelay(ms);
PIN_HIGH(PD13_GPS_RST_EN);
+ osDelay(ms);
+ PIN_LOW(PD13_GPS_RST_EN);
+
}
int32_t get_pos_info( double *lon, double *lat )
void bd_task(void *argument)
{
- huart3.Instance = USART3;
- huart3.Init.BaudRate = 9600;
- huart3.Init.WordLength = UART_WORDLENGTH_8B;
- huart3.Init.StopBits = UART_STOPBITS_1;
- huart3.Init.Parity = UART_PARITY_NONE;
- huart3.Init.Mode = UART_MODE_TX_RX;
- huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart3.Init.OverSampling = UART_OVERSAMPLING_16;
-
- if (HAL_UART_Init(&huart3) != HAL_OK)
+ huart4.Instance = UART4;
+ huart4.Init.BaudRate = 9600;
+ huart4.Init.WordLength = UART_WORDLENGTH_8B;
+ huart4.Init.StopBits = UART_STOPBITS_1;
+ huart4.Init.Parity = UART_PARITY_NONE;
+ huart4.Init.Mode = UART_MODE_TX_RX;
+ huart4.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ huart4.Init.OverSampling = UART_OVERSAMPLING_16;
+
+ if (HAL_UART_Init(&huart4) != HAL_OK)
{
Error_Handler();
}
#include <main.h>
#include "user.h"
+extern void user_noise_update( uint32_t noise );
+
float noise_value = 0;
static uint8_t recv_byte;
sensor_recv_start();
}
-int user_noise_sensor_read( float * noise )
+int user_noise_sensor_read( uint16_t * noise_x10 )
{
while( rx_cnt >= 7 ){
if(rx_buf[0] == 1 && rx_buf[1] == 3 && rx_buf[2] == 2 ){
if( usMBCRC16( rx_buf, 5 ) == rx_buf[5]|rx_buf[6]<<8 ){
- *noise = ((rx_buf[3]<<8)| rx_buf[4])/10.0f;
+ //*noise = ((rx_buf[3]<<8)| rx_buf[4])/10.0f;
+ *noise_x10 = ((rx_buf[3]<<8)| rx_buf[4]);
return 0;
}
}
int user_noise_sensor_init( void )
{
- //init huart6
- SENSOR_UART.Instance = USART6;
+ //init huart5
+ SENSOR_UART.Instance = UART5;
SENSOR_UART.Init.BaudRate = 9600;
SENSOR_UART.Init.WordLength = UART_WORDLENGTH_8B;
SENSOR_UART.Init.StopBits = UART_STOPBITS_1;
return 0;
}
+static void user_noise_task(void *argument)
+{
+ uint16_t noise;
+
+ user_noise_sensor_init();
+
+ while(1){
+ osDelay(1000);
+ user_noise_sensor_read_req();
+ osDelay(10);
+ for( int i=0; i<10; i++ ){
+ if( user_noise_sensor_read( &noise ) == 0 ){
+ printf( "NOISE: %0.1f dB\n", noise );
+ user_noise_info_update( noise );
+ break;
+ }
+ osDelay(10);
+ }
+ }
+}
+
+/* Definitions for defaultTask */
+osThreadId_t noiseTaskHandle;
+const osThreadAttr_t noiseTask_attributes = {
+ .name = "noiseTask",
+ .stack_size = 128,
+ .priority = (osPriority_t) osPriorityNormal,
+};
+
+void user_noise_task_start( void )
+{
+ noiseTaskHandle = osThreadNew(user_noise_task, NULL, &noiseTask_attributes);
+}
+
+#ifndef __USER_NOISE_SENSOR_H__
+#define __USER_NOISE_SENSOR_H__
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
-#define SENSOR_UART huart6
+#define SENSOR_UART huart5
-extern UART_HandleTypeDef huart6;
+extern UART_HandleTypeDef huart5;
extern float noise_value;
void sensor_recv_start( void );
void noise_sensor_rx_cb( void );
int user_noise_sensor_init( void );
int user_noise_sensor_read_req( void );
-int user_noise_sensor_read( float * noise );
+int user_noise_sensor_read( uint16_t * noise_x10 );
+
+#endif //__USER_NOISE_SENSOR_H__
* ·µ»ØÖµ : ÎÞ;
*
**/
+
+struct tcp_pcb *tcp_server_pcb;
+
void Tcp_Server_Init(void)
{
- struct tcp_pcb *tcp_server_pcb;
/* Ϊtcp·þÎñÆ÷·ÖÅäÒ»¸ötcp_pcb½á¹¹Ìå */
tcp_server_pcb = tcp_new();
/* ³õʼ»¯½á¹¹Ìå½ÓÊջص÷º¯Êý */
tcp_accept(tcp_server_pcb, tcp_server_accept);
+
+ tcp_listen( tcp_server_pcb );
}
/***
tcp_arg(pcb, mem_calloc(sizeof(struct name), 1));
/* ·¢ËÍÒ»¸ö½¨Á¢Á¬½ÓµÄ×Ö·û´® */
- tcp_write(pcb, "hello my dream \n\r",strlen("hello my dream \n\r "), 1);
+ //tcp_write(pcb, "hello my dream \n\r",strlen("hello my dream \n\r "), 1);
/* ÅäÖýÓÊջص÷º¯Êý */
tcp_recv(pcb, tcp_server_recv);
* ·µ»ØÖµ : ERR_ARG ·Ç·¨Âß¼£¬ERR_OKÎÞ´íÎó;
*
**/
+int32_t tcp_recv_cb(struct tcp_pcb *pcb, uint8_t *data, uint32_t len );
+
+/*
+ TX Pkt
+ FLAG SN CMD LEN DATA CRC
+ 55AA 0002 0001 0008 XX... XXXX
+
+ RX PKT
+ FLAG SN CMD LEN DATA CRC
+ 55AA 0002 0001 0008 XX... XXXX
+CMD:
+ 0001: query LEN 0 query period:5s
+ 0002: resp LEN 8 , DATA: noise + alarm
+ 1001: Lora Tx
+ 1002: Lora Rx
+ 2001: BD Tx
+ 2002: BD Rx
+ 3001: Laki Tx
+ 3002: Laki Rx
+
+*/
+static uint16_t pkt_sn;
+int wrap_resp_data( uint8_t *buf, uint16_t cmd, uint8_t *data, uint16_t data_sz )
+{
+ uint8_t *p = buf;
+ uint16_t crc;
+
+ *p++ = (0x55AA>>8)&0xff;
+ *p++ = (0x55AA>>0)&0xff;
+ *p++ = (pkt_sn>>8)&0xff;
+ *p++ = (pkt_sn>>0)&0xff;
+ *p++ = (cmd>>8)&0xff;
+ *p++ = (cmd>>0)&0xff;
+ *p++ = (data_sz>>8)&0xff;
+ *p++ = (data_sz>>0)&0xff;
+ if( data_sz )
+ memcpy( p, data, data_sz );
+ p+=data_sz;
+ crc = usMBCRC16( buf, data_sz+8);
+ *p++ = (crc>>8)&0xff;
+ *p++ = (crc>>0)&0xff;
+
+ return 8+data_sz+2;
+}
+
+int32_t tcp_recv_cb(struct tcp_pcb *pcb, uint8_t *data, uint32_t len )
+{
+ uint8_t *p = data;
+ uint16_t recv_pkt_sn;
+ uint16_t cmd;
+ uint16_t pkt_data_sz;
+ //uint8_t *pkt_data;
+ uint16_t pkt_crc;
+ uint8_t resp[64];
+ uint16_t resp_sz = 0;
+ uint8_t resp_data[32];
+
+ uint16_t noise;
+ uint16_t sound_freq;
+ uint16_t sound_amplitude;
+
+ resp_sz = 0;
+ if( len >= 10 && p[0]==0x55 && p[1]==0xAA ){
+ recv_pkt_sn = (p[2]<<8)|p[3];
+ cmd = (p[4]<<8)|p[5];
+ pkt_data_sz = (p[6]<<8)|p[7];
+ //pkt_data = p+8;
+ pkt_crc = (p[8+pkt_data_sz]<<8)|p[8+pkt_data_sz+1];
+ if( recv_pkt_sn > pkt_sn /*&& pkt_crc == usMBCRC16(p, 8+pkt_data_sz)*/ ){
+ pkt_sn = recv_pkt_sn;
+ switch( cmd ){
+ case 0x0001: //query LEN 0 query period:5s
+/* user_sensor_info_read( &sound_freq, &sound_amplitude, &noise );
+ //0002: resp LEN 8 , DATA: noise + alarm
+ resp_data[0] = (sound_freq>>8)&0xff;
+ resp_data[1] = (sound_freq>>0)&0xff;
+ resp_data[2] = (sound_amplitude>>8)&0xff;
+ resp_data[3] = (sound_amplitude>>0)&0xff;
+ resp_data[4] = (noise>>8)&0xff;
+ resp_data[5] = (noise>>0)&0xff;
+*/
+ resp_sz = wrap_resp_data( resp, 0x0101, resp_data, 6 );
+ break;
+ }
+ if( resp_sz ){
+ tcp_write( pcb, resp, resp_sz, TCP_WRITE_FLAG_COPY );
+ }
+ return 0;
+ }
+ }
+ return -1;
+}
+
static err_t tcp_server_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *tcp_recv_pbuf, err_t err)
{
- struct pbuf *tcp_send_pbuf;
+ //struct pbuf *tcp_send_pbuf;
struct name *name = (struct name *)arg;
+ uint8_t *rx_data;
if (tcp_recv_pbuf != NULL)
{
return ERR_ARG;
}
+#if 0
/* ½«½ÓÊÕµÄÊý¾Ý¿½±´¸ø·¢ËͽṹÌå */
tcp_send_pbuf = tcp_recv_pbuf;
tcp_write(pcb, "\r\n", strlen("\r\n"), 1);
/* ½«½ÓÊÕµ½µÄÊý¾ÝÔÙת·¢³öÈ¥ */
tcp_write(pcb, tcp_send_pbuf->payload, tcp_send_pbuf->len, 1);
-
+#else
+ //todo handle rx_data
+ rx_data = pvPortMalloc( tcp_recv_pbuf->tot_len );
+ if( rx_data ){
+ if( pbuf_copy_partial( tcp_recv_pbuf, rx_data, tcp_recv_pbuf->tot_len, 0 ) == tcp_recv_pbuf->tot_len ){
+ tcp_recv_cb(pcb, rx_data, tcp_recv_pbuf->tot_len );
+ }
+ vPortFree( rx_data );
+ }else{
+ printf( "tcp_server_recv: out of memorry!\n" );
+ }
+#endif
pbuf_free(tcp_recv_pbuf);
}
else if (err == ERR_OK)
return ERR_OK;
}
+
+/*
+ struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, sz, PBUF_RAM);
+ if( p ){
+ pbuf_take( p, data, sz );
+ udp_sendto( g_dbg_udp.upcb, p, &g_dbg_udp.remote_addr, g_dbg_udp.remote_port );
+ pbuf_free( p );
+ }
+
+ #if 1
+ //todo handle rx_data
+ uint8_t *rx_data = pvPortMalloc( p->tot_len );
+ if( rx_data ){
+ if( pbuf_copy_partial( p, rx_data, p->tot_len, 0 ) == p->tot_len ){
+ udp_recv_cb(upcb, addr, port, rx_data, p->tot_len );
+ }
+ vPortFree( rx_data );
+ }
+ #endif
+*/
*********************************************************************************************************
*/
-#endif /* TCP_SERVER_H */
\ No newline at end of file
+#endif /* TCP_SERVER_H */
--- /dev/null
+
+#include "user.h"
+
+#if 0
+
+/*
+ÅäÖÃTIM3µÄCOUNTER À´×ö¼ÆÊ± µ¥Î»us¡£
+GPIO PE3 ÅäÖÃΪÖжϴ¥·¢£¬ÖжϺ¯ÊýÖмǼ¸ßµçƽ±£³Öʱ¼ä
+
+¶ÁȡָÁ ·¢ËÍÆô¶¯Ö¸ÁÆô¶¯TIM3 Æô¶¯IOÖжϣ¬ÖжÏÖжÁÈ¡TIM3µÄcounter¼Ä´æÆ÷£¬¼Ç¼¸ßµçƽ±£³Öʱ¼ä
+¶ÁȡָÁîºóÑÓ³Ù10ms £¬¼ì²é¼Ç¼Êý¾Ý£¬½âÎöζÈÄ£¿éµÄ»ØÓ¦±¨ÎÄÀ´»ñÈ¡ÎÂʪ¶ÈÊý¾Ý
+*/
+
+extern TIM_HandleTypeDef htim3;
+
+int user_temperature_read( float *tem, float * hum );
+
+static void temp_read_start( void );
+static void temp_read_stop( void );
+
+static float s_tem;
+static float s_hum;
+
+struct tem_bit{
+ uint8_t h_us;
+};
+
+struct tem_bit tem_bit_data[ 50 ]; //ack + bit x 40 + end
+int tem_bit_count;
+
+
+void tem_int_cb( void )
+{
+ int us;
+ int level;
+
+ level = HAL_GPIO_ReadPin( DQ_IN_GPIO_Port, DQ_IN_Pin )==GPIO_PIN_SET?1:0;
+ us = __HAL_TIM_GET_COUNTER( &htim3 );
+
+ if( tem_bit_count > 42 )
+ return;
+
+ if( level==0 ){
+ tem_bit_data[tem_bit_count].h_us = us;
+ }else{
+ tem_bit_count++;
+ }
+
+ __HAL_TIM_SET_COUNTER( &htim3, 0 );
+}
+
+void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
+{
+ if( GPIO_Pin==DQ_IN_Pin ){
+ tem_int_cb();
+ }
+}
+
+void tem_pin_cfg_out( int level )
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ HAL_NVIC_DisableIRQ(EXTI3_IRQn);
+ HAL_GPIO_WritePin(SYS_LED_GPIO_Port, SYS_LED_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin : DQ_IN_Pin */
+ GPIO_InitStruct.Pin = DQ_IN_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(DQ_IN_GPIO_Port, &GPIO_InitStruct);
+
+
+}
+
+void tem_pin_cfg_input( void )
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ /*Configure GPIO pin : DQ_IN_Pin */
+ GPIO_InitStruct.Pin = DQ_IN_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(DQ_IN_GPIO_Port, &GPIO_InitStruct);
+ __HAL_GPIO_EXTI_CLEAR_IT(DQ_IN_Pin);
+
+}
+
+void temp_read_start( void )
+{
+ tem_pin_cfg_out( 0 );
+ osDelay(20);
+ tem_pin_cfg_input();
+
+ tem_bit_count = 0;
+ __HAL_TIM_SET_COUNTER( &htim3, 0 );
+ HAL_TIM_Base_Start( &htim3 );
+
+ HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(EXTI3_IRQn);
+}
+
+void temp_read_stop( void )
+{
+ HAL_NVIC_DisableIRQ(EXTI3_IRQn);
+ HAL_TIM_Base_Stop( &htim3 );
+ __HAL_TIM_SET_COUNTER( &htim3, 0 );
+
+}
+
+int user_temperature_read( float *tem, float * hum )
+{
+ temp_read_start();
+ osDelay(10*100);
+ temp_read_stop();
+
+ if( tem_bit_count > 42 ){
+
+ *tem = s_tem;
+ *hum = s_hum;
+ return 0;
+ }
+ return -1;
+}
+
+#endif
#define SW_VER_MINOR 2
extern UART_HandleTypeDef huart1;
-extern UART_HandleTypeDef huart2; //PD5/6
-#define huart_shell huart2
+#define huart_shell huart1
static Shell shell;
static char shellBuffer[512];
void version( void )
{
- printf( "Version:%d.%d\n", SW_VER_MAJOR, SW_VER_MINOR );
+ printf( "Version: V%d.%d\n", SW_VER_MAJOR, SW_VER_MINOR );
}
+
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version );
void fan( int enable )
{
- if( enable ){
+ if( enable==1 ){
//fan power on
- }else{
+ HAL_GPIO_WritePin( FAN_EN_GPIO_Port, FAN_EN_Pin, GPIO_PIN_SET );
+ printf( "fan power on\n" );
+ }else if( enable==0 ){
//fan power off
+ HAL_GPIO_WritePin( FAN_EN_GPIO_Port, FAN_EN_Pin, GPIO_PIN_RESET );
+ printf( "fan power off\n" );
}
}
shellTaskHandle = osThreadNew(user_shell_task, NULL, &shellTask_attributes);
}
+
void user_shell_task(void *argument)
{
shell.write = shell_uart_write;