597 lines
17 KiB
C
597 lines
17 KiB
C
/**
|
|
******************************************************************************
|
|
* @file : usbd_conf.c
|
|
* @brief : This file implements the board support package for the USB device library
|
|
******************************************************************************
|
|
*
|
|
* COPYRIGHT(c) 2015 STMicroelectronics
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
* are permitted provided that the following conditions are met:
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "usbd_def.h"
|
|
#include "usbd_core.h"
|
|
|
|
#include "os_io_seproxyhal.h"
|
|
//#include "usbd_hid.h"
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private define ------------------------------------------------------------*/
|
|
/* Private macro -------------------------------------------------------------*/
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
/* USER CODE END 0 */
|
|
/* Exported function prototypes -----------------------------------------------*/
|
|
extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev);
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
/* Private functions ---------------------------------------------------------*/
|
|
//void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state);
|
|
|
|
/*******************************************************************************
|
|
LL Driver Callbacks (PCD USB Device Library)
|
|
*******************************************************************************/
|
|
|
|
#if 0
|
|
/**
|
|
* @brief Setup Stage callback
|
|
* @param hpcd: PCD handle
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
|
|
USBD_LL_SetupStage(hpcd->pData, (uint8_t *)hpcd->Setup);
|
|
}
|
|
|
|
/**
|
|
* @brief Data Out Stage callback.
|
|
* @param hpcd: PCD handle
|
|
* @param epnum: Endpoint Number
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
|
{
|
|
USBD_LL_DataOutStage(hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
|
|
}
|
|
|
|
/**
|
|
* @brief Data In Stage callback..
|
|
* @param hpcd: PCD handle
|
|
* @param epnum: Endpoint Number
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
|
{
|
|
USBD_LL_DataInStage(hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
|
|
}
|
|
|
|
/**
|
|
* @brief SOF callback.
|
|
* @param hpcd: PCD handle
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_LL_SOF(hpcd->pData);
|
|
}
|
|
|
|
/**
|
|
* @brief Reset callback.
|
|
* @param hpcd: PCD handle
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
|
|
|
|
/*Set USB Current Speed*/
|
|
switch (hpcd->Init.speed)
|
|
{
|
|
case PCD_SPEED_FULL:
|
|
speed = USBD_SPEED_FULL;
|
|
break;
|
|
|
|
default:
|
|
speed = USBD_SPEED_FULL;
|
|
break;
|
|
}
|
|
USBD_LL_SetSpeed(hpcd->pData, speed);
|
|
|
|
/*Reset Device*/
|
|
USBD_LL_Reset(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
|
|
*/
|
|
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_LL_Suspend(hpcd->pData);
|
|
}
|
|
|
|
/**
|
|
* @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
|
|
*/
|
|
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_LL_Resume(hpcd->pData);
|
|
}
|
|
|
|
/**
|
|
* @brief ISOOUTIncomplete callback.
|
|
* @param hpcd: PCD handle
|
|
* @param epnum: Endpoint Number
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
|
{
|
|
USBD_LL_IsoOUTIncomplete(hpcd->pData, epnum);
|
|
}
|
|
|
|
/**
|
|
* @brief ISOINIncomplete callback.
|
|
* @param hpcd: PCD handle
|
|
* @param epnum: Endpoint Number
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
|
|
{
|
|
USBD_LL_IsoINIncomplete(hpcd->pData, epnum);
|
|
}
|
|
|
|
/**
|
|
* @brief ConnectCallback callback.
|
|
* @param hpcd: PCD handle
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_LL_DevConnected(hpcd->pData);
|
|
}
|
|
|
|
/**
|
|
* @brief Disconnect callback.
|
|
* @param hpcd: PCD handle
|
|
* @retval None
|
|
*/
|
|
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
|
|
{
|
|
USBD_LL_DevDisconnected(hpcd->pData);
|
|
}
|
|
#endif
|
|
|
|
|
|
/*******************************************************************************
|
|
LL Driver Interface (USB Device Library --> PCD)
|
|
*******************************************************************************/
|
|
unsigned int ep_in_stall;
|
|
unsigned int ep_out_stall;
|
|
/**
|
|
* @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)
|
|
{
|
|
ep_in_stall = 0;
|
|
ep_out_stall = 0;
|
|
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)
|
|
{
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[5];
|
|
|
|
// reset address
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 2;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_ADDR;
|
|
buffer[4] = 0;
|
|
io_seproxyhal_spi_send(buffer, 5);
|
|
|
|
// start usb operation
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 1;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_CONNECT;
|
|
io_seproxyhal_spi_send(buffer, 4);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[4];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 1;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_DISCONNECT;
|
|
io_seproxyhal_spi_send(buffer, 4);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[8];
|
|
|
|
ep_in_stall = 0;
|
|
ep_out_stall = 0;
|
|
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 5;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_ENDPOINTS;
|
|
buffer[4] = 1;
|
|
buffer[5] = ep_addr;
|
|
buffer[6] = 0;
|
|
switch(ep_type) {
|
|
case USBD_EP_TYPE_CTRL:
|
|
buffer[6] = SEPROXYHAL_TAG_USB_CONFIG_TYPE_CONTROL;
|
|
break;
|
|
case USBD_EP_TYPE_ISOC:
|
|
buffer[6] = SEPROXYHAL_TAG_USB_CONFIG_TYPE_ISOCHRONOUS;
|
|
break;
|
|
case USBD_EP_TYPE_BULK:
|
|
buffer[6] = SEPROXYHAL_TAG_USB_CONFIG_TYPE_BULK;
|
|
break;
|
|
case USBD_EP_TYPE_INTR:
|
|
buffer[6] = SEPROXYHAL_TAG_USB_CONFIG_TYPE_INTERRUPT;
|
|
break;
|
|
}
|
|
buffer[7] = ep_mps;
|
|
io_seproxyhal_spi_send(buffer, 8);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[8];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 5;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_ENDPOINTS;
|
|
buffer[4] = 1;
|
|
buffer[5] = ep_addr;
|
|
buffer[6] = SEPROXYHAL_TAG_USB_CONFIG_TYPE_DISABLED;
|
|
buffer[7] = 0;
|
|
io_seproxyhal_spi_send(buffer, 8);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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_PCD_EP_Flush(pdev->pData, ep_addr);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[6];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_EP_PREPARE;
|
|
buffer[1] = 0;
|
|
buffer[2] = 3;
|
|
buffer[3] = ep_addr;
|
|
buffer[4] = SEPROXYHAL_TAG_USB_EP_PREPARE_DIR_STALL;
|
|
buffer[5] = 0;
|
|
io_seproxyhal_spi_send(buffer, 6);
|
|
if (ep_addr & 0x80) {
|
|
ep_in_stall |= (1<<(ep_addr&0x7F));
|
|
}
|
|
else {
|
|
ep_out_stall |= (1<<(ep_addr&0x7F));
|
|
}
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
uint8_t buffer[6];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_EP_PREPARE;
|
|
buffer[1] = 0;
|
|
buffer[2] = 3;
|
|
buffer[3] = ep_addr;
|
|
buffer[4] = SEPROXYHAL_TAG_USB_EP_PREPARE_DIR_UNSTALL;
|
|
buffer[5] = 0;
|
|
io_seproxyhal_spi_send(buffer, 6);
|
|
if (ep_addr & 0x80) {
|
|
ep_in_stall &= ~(1<<(ep_addr&0x7F));
|
|
}
|
|
else {
|
|
ep_out_stall &= ~(1<<(ep_addr&0x7F));
|
|
}
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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)
|
|
{
|
|
if((ep_addr & 0x80) == 0x80)
|
|
{
|
|
return ep_in_stall & (1<<(ep_addr&0x7F));
|
|
}
|
|
else
|
|
{
|
|
return ep_out_stall & (1<<(ep_addr&0x7F));
|
|
}
|
|
}
|
|
/**
|
|
* @brief Assigns a USB address to the device.
|
|
* @param pdev: Device handle
|
|
* @param ep_addr: Endpoint Number
|
|
* @retval USBD Status
|
|
*/
|
|
USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr)
|
|
{
|
|
uint8_t buffer[5];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_CONFIG;
|
|
buffer[1] = 0;
|
|
buffer[2] = 2;
|
|
buffer[3] = SEPROXYHAL_TAG_USB_CONFIG_ADDR;
|
|
buffer[4] = dev_addr;
|
|
io_seproxyhal_spi_send(buffer, 5);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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,
|
|
uint16_t size)
|
|
{
|
|
uint8_t buffer[6];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_EP_PREPARE;
|
|
buffer[1] = (3+size)>>8;
|
|
buffer[2] = (3+size);
|
|
buffer[3] = ep_addr;
|
|
buffer[4] = SEPROXYHAL_TAG_USB_EP_PREPARE_DIR_IN;
|
|
buffer[5] = size;
|
|
io_seproxyhal_spi_send(buffer, 6);
|
|
io_seproxyhal_spi_send(pbuf, size);
|
|
return USBD_OK;
|
|
}
|
|
|
|
/**
|
|
* @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,
|
|
uint16_t size)
|
|
{
|
|
uint8_t buffer[6];
|
|
buffer[0] = SEPROXYHAL_TAG_USB_EP_PREPARE;
|
|
buffer[1] = (3/*+size*/)>>8;
|
|
buffer[2] = (3/*+size*/);
|
|
buffer[3] = ep_addr;
|
|
buffer[4] = SEPROXYHAL_TAG_USB_EP_PREPARE_DIR_OUT;
|
|
buffer[5] = size;
|
|
io_seproxyhal_spi_send(buffer, 6);
|
|
return USBD_OK;
|
|
}
|
|
|
|
|
|
#if 0
|
|
/**
|
|
* @brief GPIO EXTI Callback function
|
|
* Handle USB VBUS detection upon External interrupt
|
|
* @param GPIO_Pin
|
|
* @retval None
|
|
*/
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
|
{
|
|
if (GPIO_Pin == GPIO_PIN_9)
|
|
{
|
|
HAL_PCDEx_BCD_VBUSDetect (&hpcd_USB_OTG_FS);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief Returns the last transfered packet size.
|
|
* @param pdev: Device handle
|
|
* @param ep_addr: Endpoint Number
|
|
* @retval Recived Data Size
|
|
*/
|
|
uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
|
{
|
|
// unused
|
|
return 0; //HAL_PCD_EP_GetRxCount(pdev->pData, ep_addr);
|
|
}
|
|
|
|
/**
|
|
* @brief Delays routine for the USB Device Library.
|
|
* @param Delay: Delay in ms
|
|
* @retval None
|
|
*/
|
|
void USBD_LL_Delay (uint32_t Delay)
|
|
{
|
|
// TODO
|
|
}
|
|
#endif //0
|
|
|
|
#if 0
|
|
/**
|
|
* @brief Software Device Connection
|
|
* @param hpcd: PCD handle
|
|
* @param state: connection state (0 : disconnected / 1: connected)
|
|
* @retval None
|
|
*/
|
|
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
|
|
{
|
|
/* USER CODE BEGIN 6 */
|
|
if (state == 1)
|
|
{
|
|
/* Configure Low Connection State */
|
|
|
|
}
|
|
else
|
|
{
|
|
/* Configure High Connection State */
|
|
|
|
}
|
|
/* USER CODE END 6 */
|
|
}
|
|
|
|
/**
|
|
* @brief Verify if the Battery Charging Detection mode (BCD) is used :
|
|
* return USBD_OK if true
|
|
* else return USBD_FAIL if false
|
|
* @param pdev: Device handle
|
|
* @retval USBD Status
|
|
*/
|
|
USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev)
|
|
{
|
|
return USBD_FAIL;
|
|
}
|
|
#endif // 0
|
|
|
|
|
|
|
|
#include "usbd_def.h"
|
|
#include "usbd_core.h"
|
|
#include "os_io_seproxyhal.h"
|
|
#include "usbd_desc.h"
|
|
#include "usbd_customhid.h"
|
|
// the USB device
|
|
USBD_HandleTypeDef USBD_Device;
|
|
|
|
// endpoints transport length
|
|
volatile unsigned char G_io_usb_ep_xfer_len[IO_USB_MAX_ENDPOINTS];
|
|
|
|
// interaction variable with io seproxyhal to get the total length transferred when all RX packets have been processed.
|
|
extern volatile unsigned short G_io_apdu_length;
|
|
int8_t CUSTOM_HID_OutEvent (uint8_t* hid_report)
|
|
{
|
|
if (hid_report) {
|
|
// add to the hid transport
|
|
switch(io_usb_hid_receive(io_usb_send_apdu_data, hid_report, G_io_usb_ep_xfer_len[2])) {
|
|
default:
|
|
break;
|
|
|
|
case IO_USB_APDU_RECEIVED:
|
|
G_io_apdu_length = G_io_usb_hid_total_length;
|
|
break;
|
|
}
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
void io_usb_enable(unsigned char enabled) {
|
|
if (enabled) {
|
|
os_memset(&USBD_Device, 0, sizeof(USBD_Device));
|
|
/* Init Device Library */
|
|
USBD_Init(&USBD_Device, &HID_Desc, 0);
|
|
|
|
/* Register the HID class */
|
|
USBD_RegisterClass(&USBD_Device, &USBD_CUSTOM_HID);
|
|
|
|
USBD_CUSTOM_HID_RegisterInterface(&USBD_Device, &USBD_CustomHID_template_fops);
|
|
|
|
/* Start Device Process */
|
|
USBD_Start(&USBD_Device);
|
|
}
|
|
else {
|
|
USBD_DeInit(&USBD_Device);
|
|
}
|
|
}
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|