mirror of
https://github.com/STMicroelectronics/stm32-mw-usb-device.git
synced 2026-02-08 20:18:07 -05:00
Release v2.6.0
This commit is contained in:
255
Class/CDC_ECM/Inc/usbd_cdc_ecm.h
Normal file
255
Class/CDC_ECM/Inc/usbd_cdc_ecm.h
Normal file
@@ -0,0 +1,255 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file usbd_cdc_ecm.h
|
||||
* @author MCD Application Team
|
||||
* @brief header file for the usbd_cdc_ecm.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_CDC_ECM_H
|
||||
#define __USB_CDC_ECM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_ioreq.h"
|
||||
|
||||
/** @addtogroup STM32_USB_DEVICE_LIBRARY
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup usbd_cdc_ecm
|
||||
* @brief This file is the Header file for usbd_cdc_ecm.c
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup usbd_cdc_ecm_Exported_Defines
|
||||
* @{
|
||||
*/
|
||||
/* Comment this define in order to disable the CDC ECM Notification pipe */
|
||||
|
||||
|
||||
#define CDC_ECM_IN_EP 0x81U /* EP1 for data IN */
|
||||
#define CDC_ECM_OUT_EP 0x01U /* EP1 for data OUT */
|
||||
#define CDC_ECM_CMD_EP 0x82U /* EP2 for CDC ECM commands */
|
||||
|
||||
#ifndef CDC_ECM_CMD_ITF_NBR
|
||||
#define CDC_ECM_CMD_ITF_NBR 0x00U /* Command Interface Number 0 */
|
||||
#endif /* CDC_ECM_CMD_ITF_NBR */
|
||||
|
||||
#ifndef CDC_ECM_COM_ITF_NBR
|
||||
#define CDC_ECM_COM_ITF_NBR 0x01U /* Communication Interface Number 0 */
|
||||
#endif /* CDC_ECM_CMD_ITF_NBR */
|
||||
|
||||
#ifndef CDC_ECM_HS_BINTERVAL
|
||||
#define CDC_ECM_HS_BINTERVAL 0x10U
|
||||
#endif /* CDC_ECM_HS_BINTERVAL */
|
||||
|
||||
#ifndef CDC_ECM_FS_BINTERVAL
|
||||
#define CDC_ECM_FS_BINTERVAL 0x10U
|
||||
#endif /* CDC_ECM_FS_BINTERVAL */
|
||||
|
||||
#ifndef USBD_SUPPORT_USER_STRING_DESC
|
||||
#define USBD_SUPPORT_USER_STRING_DESC 1U
|
||||
#endif /* USBD_SUPPORT_USER_STRING_DESC */
|
||||
|
||||
/* CDC_ECM Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
||||
#define CDC_ECM_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
|
||||
#define CDC_ECM_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
|
||||
#define CDC_ECM_CMD_PACKET_SIZE 16U /* Control Endpoint Packet size */
|
||||
|
||||
#define CDC_ECM_CONFIG_DESC_SIZ 79U
|
||||
|
||||
#define CDC_ECM_DATA_HS_IN_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
||||
#define CDC_ECM_DATA_HS_OUT_PACKET_SIZE CDC_ECM_DATA_HS_MAX_PACKET_SIZE
|
||||
|
||||
#define CDC_ECM_DATA_FS_IN_PACKET_SIZE CDC_ECM_DATA_FS_MAX_PACKET_SIZE
|
||||
#define CDC_ECM_DATA_FS_OUT_PACKET_SIZE CDC_ECM_DATA_FS_MAX_PACKET_SIZE
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
/* CDC_ECM definitions */
|
||||
/*---------------------------------------------------------------------*/
|
||||
#define CDC_ECM_SEND_ENCAPSULATED_COMMAND 0x00U
|
||||
#define CDC_ECM_GET_ENCAPSULATED_RESPONSE 0x01U
|
||||
#define CDC_ECM_SET_ETH_MULTICAST_FILTERS 0x40U
|
||||
#define CDC_ECM_SET_ETH_PWRM_PATTERN_FILTER 0x41U
|
||||
#define CDC_ECM_GET_ETH_PWRM_PATTERN_FILTER 0x42U
|
||||
#define CDC_ECM_SET_ETH_PACKET_FILTER 0x43U
|
||||
#define CDC_ECM_GET_ETH_STATISTIC 0x44U
|
||||
|
||||
#define CDC_ECM_NET_DISCONNECTED 0x00U
|
||||
#define CDC_ECM_NET_CONNECTED 0x01U
|
||||
|
||||
|
||||
/* Ethernet statistics definitions */
|
||||
#define CDC_ECM_XMIT_OK_VAL CDC_ECM_ETH_STATS_VAL_ENABLED
|
||||
#define CDC_ECM_XMIT_OK 0x01U
|
||||
#define CDC_ECM_RVC_OK 0x02U
|
||||
#define CDC_ECM_XMIT_ERROR 0x04U
|
||||
#define CDC_ECM_RCV_ERROR 0x08U
|
||||
#define CDC_ECM_RCV_NO_BUFFER 0x10U
|
||||
#define CDC_ECM_DIRECTED_BYTES_XMIT 0x20U
|
||||
#define CDC_ECM_DIRECTED_FRAMES_XMIT 0x40U
|
||||
#define CDC_ECM_MULTICAST_BYTES_XMIT 0x80U
|
||||
|
||||
#define CDC_ECM_MULTICAST_FRAMES_XMIT 0x01U
|
||||
#define CDC_ECM_BROADCAST_BYTES_XMIT 0x02U
|
||||
#define CDC_ECM_BROADCAST_FRAMES_XMIT 0x04U
|
||||
#define CDC_ECM_DIRECTED_BYTES_RCV 0x08U
|
||||
#define CDC_ECM_DIRECTED_FRAMES_RCV 0x10U
|
||||
#define CDC_ECM_MULTICAST_BYTES_RCV 0x20U
|
||||
#define CDC_ECM_MULTICAST_FRAMES_RCV 0x40U
|
||||
#define CDC_ECM_BROADCAST_BYTES_RCV 0x80U
|
||||
|
||||
#define CDC_ECM_BROADCAST_FRAMES_RCV 0x01U
|
||||
#define CDC_ECM_RCV_CRC_ERROR 0x02U
|
||||
#define CDC_ECM_TRANSMIT_QUEUE_LENGTH 0x04U
|
||||
#define CDC_ECM_RCV_ERROR_ALIGNMENT 0x08U
|
||||
#define CDC_ECM_XMIT_ONE_COLLISION 0x10U
|
||||
#define CDC_ECM_XMIT_MORE_COLLISIONS 0x20U
|
||||
#define CDC_ECM_XMIT_DEFERRED 0x40U
|
||||
#define CDC_ECM_XMIT_MAX_COLLISIONS 0x80U
|
||||
|
||||
#define CDC_ECM_RCV_OVERRUN 0x40U
|
||||
#define CDC_ECM_XMIT_UNDERRUN 0x40U
|
||||
#define CDC_ECM_XMIT_HEARTBEAT_FAILURE 0x40U
|
||||
#define CDC_ECM_XMIT_TIMES_CRS_LOST 0x40U
|
||||
#define CDC_ECM_XMIT_LATE_COLLISIONS 0x40U
|
||||
|
||||
#define CDC_ECM_ETH_STATS_RESERVED 0xE0U
|
||||
#define CDC_ECM_BMREQUEST_TYPE_ECM 0xA1U
|
||||
|
||||
/* MAC String index */
|
||||
#define CDC_ECM_MAC_STRING_INDEX 6U
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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);
|
||||
int8_t (* Process)(USBD_HandleTypeDef *pdev);
|
||||
const uint8_t *pStrDesc;
|
||||
} USBD_CDC_ECM_ItfTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bmRequest;
|
||||
uint8_t bRequest;
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
uint8_t data[8];
|
||||
} USBD_CDC_ECM_NotifTypeDef;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t data[2000 / 4]; /* Force 32bits alignment */
|
||||
uint8_t CmdOpCode;
|
||||
uint8_t CmdLength;
|
||||
uint8_t Reserved1; /* Reserved Byte to force 4 bytes alignment of following fields */
|
||||
uint8_t Reserved2; /* Reserved Byte to force 4 bytes alignment of following fields */
|
||||
uint8_t *RxBuffer;
|
||||
uint8_t *TxBuffer;
|
||||
uint32_t RxLength;
|
||||
uint32_t TxLength;
|
||||
|
||||
__IO uint32_t TxState;
|
||||
__IO uint32_t RxState;
|
||||
|
||||
__IO uint32_t MaxPcktLen;
|
||||
__IO uint32_t LinkStatus;
|
||||
__IO uint32_t NotificationStatus;
|
||||
USBD_CDC_ECM_NotifTypeDef Req;
|
||||
} USBD_CDC_ECM_HandleTypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NETWORK_CONNECTION = 0x00,
|
||||
RESPONSE_AVAILABLE = 0x01,
|
||||
CONNECTION_SPEED_CHANGE = 0x2A
|
||||
} USBD_CDC_ECM_NotifCodeTypeDef;
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_CORE_Exported_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern USBD_ClassTypeDef USBD_CDC_ECM;
|
||||
#define USBD_CDC_ECM_CLASS &USBD_CDC_ECM
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup USB_CORE_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
uint8_t USBD_CDC_ECM_RegisterInterface(USBD_HandleTypeDef *pdev,
|
||||
USBD_CDC_ECM_ItfTypeDef *fops);
|
||||
|
||||
uint8_t USBD_CDC_ECM_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
|
||||
uint32_t length);
|
||||
|
||||
uint8_t USBD_CDC_ECM_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
|
||||
|
||||
uint8_t USBD_CDC_ECM_ReceivePacket(USBD_HandleTypeDef *pdev);
|
||||
|
||||
uint8_t USBD_CDC_ECM_TransmitPacket(USBD_HandleTypeDef *pdev);
|
||||
|
||||
uint8_t USBD_CDC_ECM_SendNotification(USBD_HandleTypeDef *pdev,
|
||||
USBD_CDC_ECM_NotifCodeTypeDef Notif,
|
||||
uint16_t bVal, uint8_t *pData);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USB_CDC_ECM_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
82
Class/CDC_ECM/Inc/usbd_cdc_ecm_if_template.h
Normal file
82
Class/CDC_ECM/Inc/usbd_cdc_ecm_if_template.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Inc/usbd_cdc_ecm_if_template.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for usbd_cdc_ecm_if_template.c file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USBD_CDC_ECM_IF_H
|
||||
#define __USBD_CDC_ECM_IF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usbd_cdc_ecm.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/* Ensure this MAC address value is same as MAC_ADDRx declared in STM32xxx_conf.h */
|
||||
#define CDC_ECM_MAC_STR_DESC (uint8_t *)"000202030000"
|
||||
#define CDC_ECM_MAC_ADDR0 0x00U /* 01 */
|
||||
#define CDC_ECM_MAC_ADDR1 0x02U /* 02 */
|
||||
#define CDC_ECM_MAC_ADDR2 0x02U /* 03 */
|
||||
#define CDC_ECM_MAC_ADDR3 0x03U /* 00 */
|
||||
#define CDC_ECM_MAC_ADDR4 0x00U /* 00 */
|
||||
#define CDC_ECM_MAC_ADDR5 0x00U /* 00 */
|
||||
|
||||
/* Max Number of Trials waiting for Tx ready */
|
||||
#define CDC_ECM_MAX_TX_WAIT_TRIALS 1000000U
|
||||
|
||||
#define CDC_ECM_ETH_STATS_BYTE0 0U
|
||||
/*(uint8_t)(CDC_ECM_XMIT_OK_VAL | CDC_ECM_RVC_OK_VAL | CDC_ECM_XMIT_ERROR_VAL | \
|
||||
CDC_ECM_RCV_ERROR_VAL | CDC_ECM_RCV_NO_BUFFER_VAL | CDC_ECM_DIRECTED_BYTES_XMIT_VAL | \
|
||||
CDC_ECM_DIRECTED_FRAMES_XMIT_VAL | CDC_ECM_MULTICAST_BYTES_XMIT_VAL) */
|
||||
|
||||
#define CDC_ECM_ETH_STATS_BYTE1 0U
|
||||
/*(uint8_t)(CDC_ECM_MULTICAST_FRAMES_XMIT_VAL | CDC_ECM_BROADCAST_BYTES_XMIT_VAL | \
|
||||
CDC_ECM_BROADCAST_FRAMES_XMIT_VAL | CDC_ECM_DIRECTED_BYTES_RCV_VAL | \
|
||||
CDC_ECM_DIRECTED_FRAMES_RCV_VAL | CDC_ECM_MULTICAST_BYTES_RCV_VAL | \
|
||||
CDC_ECM_MULTICAST_FRAMES_RCV_VAL | CDC_ECM_BROADCAST_BYTES_RCV_VAL) */
|
||||
|
||||
#define CDC_ECM_ETH_STATS_BYTE2 0U
|
||||
/*(uint8_t)(CDC_ECM_BROADCAST_FRAMES_RCV_VAL | CDC_ECM_RCV_CRC_ERROR_VAL | \
|
||||
CDC_ECM_TRANSMIT_QUEUE_LENGTH_VAL | CDC_ECM_RCV_ERROR_ALIGNMENT_VAL | \
|
||||
CDC_ECM_XMIT_ONE_COLLISION_VAL | CDC_ECM_XMIT_MORE_COLLISIONS_VAL | \
|
||||
CDC_ECM_XMIT_DEFERRED_VAL | CDC_ECM_XMIT_MAX_COLLISIONS_VAL) */
|
||||
|
||||
#define CDC_ECM_ETH_STATS_BYTE3 0U
|
||||
/*(uint8_t)(CDC_ECM_RCV_OVERRUN_VAL | CDC_ECM_XMIT_UNDERRUN_VAL | CDC_ECM_XMIT_HEARTBEAT_FAILURE_VAL | \
|
||||
CDC_ECM_XMIT_TIMES_CRS_LOST_VAL | CDC_ECM_XMIT_LATE_COLLISIONS_VAL | CDC_ECM_ETH_STATS_RESERVED) */
|
||||
|
||||
/* Ethernet Maximum Segment size, typically 1514 bytes */
|
||||
#define CDC_ECM_ETH_MAX_SEGSZE 1514U
|
||||
|
||||
/* Number of Ethernet multicast filters */
|
||||
#define CDC_ECM_ETH_NBR_MACFILTERS 0U
|
||||
|
||||
/* Number of wakeup power filters */
|
||||
#define CDC_ECM_ETH_NBR_PWRFILTERS 0U
|
||||
|
||||
|
||||
#define CDC_ECM_CONNECT_SPEED_UPSTREAM 0x004C4B40U /* 5Mbps */
|
||||
#define CDC_ECM_CONNECT_SPEED_DOWNSTREAM 0x004C4B40U /* 5Mbps */
|
||||
|
||||
extern USBD_CDC_ECM_ItfTypeDef USBD_CDC_ECM_fops;
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
#endif /* __USBD_CDC_ECM_IF_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
1091
Class/CDC_ECM/Src/usbd_cdc_ecm.c
Normal file
1091
Class/CDC_ECM/Src/usbd_cdc_ecm.c
Normal file
File diff suppressed because it is too large
Load Diff
247
Class/CDC_ECM/Src/usbd_cdc_ecm_if_template.c
Normal file
247
Class/CDC_ECM/Src/usbd_cdc_ecm_if_template.c
Normal file
@@ -0,0 +1,247 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Src/usbd_cdc_ecm_if_template.c
|
||||
* @author MCD Application Team
|
||||
* @brief Source file for USBD CDC_ECM interface
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include "main.h"
|
||||
/*
|
||||
|
||||
Include here LwIP files if used
|
||||
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
__ALIGN_BEGIN static uint8_t UserRxBuffer[CDC_ECM_ETH_MAX_SEGSZE + 100]__ALIGN_END; /* Received Data over USB are stored in this buffer */
|
||||
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
__ALIGN_BEGIN static uint8_t UserTxBuffer[CDC_ECM_ETH_MAX_SEGSZE + 100]__ALIGN_END; /* Received Data over CDC_ECM (CDC_ECM interface) are stored in this buffer */
|
||||
|
||||
static uint8_t CDC_ECMInitialized = 0U;
|
||||
|
||||
/* USB handler declaration */
|
||||
extern USBD_HandleTypeDef USBD_Device;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static int8_t CDC_ECM_Itf_Init(void);
|
||||
static int8_t CDC_ECM_Itf_DeInit(void);
|
||||
static int8_t CDC_ECM_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length);
|
||||
static int8_t CDC_ECM_Itf_Receive(uint8_t *pbuf, uint32_t *Len);
|
||||
static int8_t CDC_ECM_Itf_TransmitCplt(uint8_t *pbuf, uint32_t *Len, uint8_t epnum);
|
||||
static int8_t CDC_ECM_Itf_Process(USBD_HandleTypeDef *pdev);
|
||||
|
||||
USBD_CDC_ECM_ItfTypeDef USBD_CDC_ECM_fops =
|
||||
{
|
||||
CDC_ECM_Itf_Init,
|
||||
CDC_ECM_Itf_DeInit,
|
||||
CDC_ECM_Itf_Control,
|
||||
CDC_ECM_Itf_Receive,
|
||||
CDC_ECM_Itf_TransmitCplt,
|
||||
CDC_ECM_Itf_Process,
|
||||
(uint8_t *)CDC_ECM_MAC_STR_DESC,
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_Init
|
||||
* Initializes the CDC_ECM media low layer
|
||||
* @param None
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_ECM_Itf_Init(void)
|
||||
{
|
||||
if (CDC_ECMInitialized == 0U)
|
||||
{
|
||||
/*
|
||||
Initialize the TCP/IP stack here
|
||||
*/
|
||||
|
||||
CDC_ECMInitialized = 1U;
|
||||
}
|
||||
|
||||
/* Set Application Buffers */
|
||||
(void)USBD_CDC_ECM_SetTxBuffer(&USBD_Device, UserTxBuffer, 0U);
|
||||
(void)USBD_CDC_ECM_SetRxBuffer(&USBD_Device, UserRxBuffer);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_DeInit
|
||||
* DeInitializes the CDC_ECM media low layer
|
||||
* @param None
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_ECM_Itf_DeInit(void)
|
||||
{
|
||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||
|
||||
/* Notify application layer that link is down */
|
||||
hcdc_cdc_ecm->LinkStatus = 0U;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_Control
|
||||
* Manage the CDC_ECM class requests
|
||||
* @param Cmd: Command code
|
||||
* @param Buf: Buffer containing command data (request parameters)
|
||||
* @param Len: 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_ECM_Itf_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
|
||||
{
|
||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case CDC_ECM_SEND_ENCAPSULATED_COMMAND:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_GET_ENCAPSULATED_RESPONSE:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_SET_ETH_MULTICAST_FILTERS:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_SET_ETH_PWRM_PATTERN_FILTER:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_GET_ETH_PWRM_PATTERN_FILTER:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_SET_ETH_PACKET_FILTER:
|
||||
/* Check if this is the first time we enter */
|
||||
if (hcdc_cdc_ecm->LinkStatus == 0U)
|
||||
{
|
||||
/*
|
||||
Setup the Link up at TCP/IP level
|
||||
*/
|
||||
hcdc_cdc_ecm->LinkStatus = 1U;
|
||||
|
||||
/* Modification for MacOS which doesn't send SetInterface before receiving INs */
|
||||
if (hcdc_cdc_ecm->NotificationStatus == 0U)
|
||||
{
|
||||
/* Send notification: NETWORK_CONNECTION Event */
|
||||
(void)USBD_CDC_ECM_SendNotification(&USBD_Device, NETWORK_CONNECTION,
|
||||
CDC_ECM_NET_CONNECTED, NULL);
|
||||
|
||||
/* Prepare for sending Connection Speed Change notification */
|
||||
hcdc_cdc_ecm->NotificationStatus = 1U;
|
||||
}
|
||||
}
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
case CDC_ECM_GET_ETH_STATISTIC:
|
||||
/* Add your code here */
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
UNUSED(length);
|
||||
UNUSED(pbuf);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_Receive
|
||||
* Data received over USB OUT endpoint are sent over CDC_ECM interface
|
||||
* through this function.
|
||||
* @param Buf: Buffer of data to be transmitted
|
||||
* @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_ECM_Itf_Receive(uint8_t *Buf, uint32_t *Len)
|
||||
{
|
||||
/* Get the CDC_ECM handler pointer */
|
||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(USBD_Device.pClassData);
|
||||
|
||||
/* Call Eth buffer processing */
|
||||
hcdc_cdc_ecm->RxState = 1U;
|
||||
|
||||
UNUSED(Len);
|
||||
UNUSED(Buf);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_TransmitCplt
|
||||
* Data transmited 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_ECM_Itf_TransmitCplt(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
|
||||
{
|
||||
UNUSED(Buf);
|
||||
UNUSED(Len);
|
||||
UNUSED(epnum);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CDC_ECM_Itf_Process
|
||||
* Data received over USB OUT endpoint are sent over CDC_ECM interface
|
||||
* through this function.
|
||||
* @param pdef: pointer to the USB Device Handle
|
||||
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
|
||||
*/
|
||||
static int8_t CDC_ECM_Itf_Process(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
/* Get the CDC_ECM handler pointer */
|
||||
USBD_CDC_ECM_HandleTypeDef *hcdc_cdc_ecm = (USBD_CDC_ECM_HandleTypeDef *)(pdev->pClassData);
|
||||
|
||||
if ((hcdc_cdc_ecm != NULL) && (hcdc_cdc_ecm->LinkStatus != 0U))
|
||||
{
|
||||
/*
|
||||
Read a received packet from the Ethernet buffers and send it
|
||||
to the lwIP for handling
|
||||
Call here the TCP/IP background tasks.
|
||||
*/
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user