mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Pretty major update of the USB HID core. Removed a lot of old code related to custom drivers and BSL (which will be brought back under HID). Device enumerates but still not communicating. Hopefully nothing broken, lots changed.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1155 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2621d07574
commit
c46dcea73a
@ -38,7 +38,7 @@ USE_BOOTLOADER ?= NO
|
||||
|
||||
|
||||
# Set to YES when using Code Sourcery toolchain
|
||||
CODE_SOURCERY ?= YES
|
||||
CODE_SOURCERY ?= NO
|
||||
|
||||
# Toolchain prefix (i.e arm-elf- -> arm-elf-gcc.exe)
|
||||
TCHAIN_PREFIX ?= arm-none-eabi-
|
||||
@ -57,7 +57,7 @@ FLASH_TOOL = OPENOCD
|
||||
USE_THUMB_MODE = YES
|
||||
|
||||
# List of modules to include
|
||||
MODULES = Telemetry GPS ManualControl Actuator Altitude AHRSComms Stabilization
|
||||
#MODULES = Telemetry GPS ManualControl Actuator Altitude AHRSComms Stabilization
|
||||
#MODULES = Telemetry Example
|
||||
#MODULES = Telemetry MK/MKSerial
|
||||
|
||||
@ -183,12 +183,20 @@ SRC += $(PIOSSTM32F10X)/pios_spi.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_ppm.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_pwm.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_spektrum.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_debug.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_gpio.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_exti.c
|
||||
|
||||
# PIOS USB related files (seperated to make code maintenance more easy)
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_desc.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_endp.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_istr.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_prop.c
|
||||
SRC += $(PIOSSTM32F10X)/pios_usb_hid_pwr.c
|
||||
|
||||
|
||||
|
||||
## PIOS Hardware (Common)
|
||||
SRC += $(PIOSCOMMON)/pios_sdcard.c
|
||||
SRC += $(PIOSCOMMON)/pios_com.c
|
||||
@ -225,6 +233,7 @@ SRC += $(STMUSBSRCDIR)/usb_init.c
|
||||
SRC += $(STMUSBSRCDIR)/usb_int.c
|
||||
SRC += $(STMUSBSRCDIR)/usb_mem.c
|
||||
SRC += $(STMUSBSRCDIR)/usb_regs.c
|
||||
SRC += $(STMUSBSRCDIR)/usb_sil.c
|
||||
|
||||
## RTOS
|
||||
SRC += $(RTOSSRCDIR)/list.c
|
||||
@ -240,12 +249,12 @@ SRC += $(DOSFSDIR)/dosfs.c
|
||||
SRC += $(DOSFSDIR)/dfs_sdcard.c
|
||||
|
||||
## Mass Storage Device
|
||||
SRC += $(MSDDIR)/msd.c
|
||||
SRC += $(MSDDIR)/msd_bot.c
|
||||
SRC += $(MSDDIR)/msd_desc.c
|
||||
SRC += $(MSDDIR)/msd_memory.c
|
||||
SRC += $(MSDDIR)/msd_scsi.c
|
||||
SRC += $(MSDDIR)/msd_scsi_data.c
|
||||
#SRC += $(MSDDIR)/msd.c
|
||||
#SRC += $(MSDDIR)/msd_bot.c
|
||||
#SRC += $(MSDDIR)/msd_desc.c
|
||||
#SRC += $(MSDDIR)/msd_memory.c
|
||||
#SRC += $(MSDDIR)/msd_scsi.c
|
||||
#SRC += $(MSDDIR)/msd_scsi_data.c
|
||||
|
||||
# List C source files here which must be compiled in ARM-Mode (no -mthumb).
|
||||
# use file-extension c for "c-only"-files
|
||||
@ -386,9 +395,7 @@ CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
|
||||
|
||||
CFLAGS += -mapcs-frame
|
||||
CFLAGS += -fomit-frame-pointer
|
||||
ifeq ($(CODE_SOURCERY), YES)
|
||||
CFLAGS += -fpromote-loop-indices
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall
|
||||
CFLAGS += -Werror
|
||||
|
@ -35,9 +35,6 @@
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "telemetrysettings.h"
|
||||
|
||||
// Set this to 1 to enable telemetry via the USB HID interface
|
||||
#define ALLOW_HID_TELEMETRY 0
|
||||
|
||||
// Private constants
|
||||
#define MAX_QUEUE_SIZE 20
|
||||
#define STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
@ -313,7 +310,7 @@ static void telemetryRxTask(void* parameters)
|
||||
// Task loop
|
||||
while (1)
|
||||
{
|
||||
#if ALLOW_HID_TELEMETRY
|
||||
#if defined(PIOS_INCLUDE_USB_HID)
|
||||
// Determine input port (USB takes priority over telemetry port)
|
||||
if(PIOS_USB_HID_CheckAvailable(0))
|
||||
{
|
||||
@ -349,7 +346,7 @@ static int32_t transmitData(uint8_t* data, int32_t length)
|
||||
uint8_t outputPort;
|
||||
|
||||
// Determine input port (USB takes priority over telemetry port)
|
||||
#if ALLOW_HID_TELEMETRY
|
||||
#if defined(PIOS_INCLUDE_USB_HID)
|
||||
if(PIOS_USB_HID_CheckAvailable(0))
|
||||
{
|
||||
outputPort = PIOS_COM_TELEM_USB;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_core.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Standard protocol processing functions prototypes
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -173,7 +173,10 @@ typedef struct _DEVICE_PROP
|
||||
uint8_t* (*GetConfigDescriptor)(uint16_t Length);
|
||||
uint8_t* (*GetStringDescriptor)(uint16_t Length);
|
||||
|
||||
uint8_t* RxEP_buffer;
|
||||
/* This field is not used in current library version. It is kept only for
|
||||
compatibility with previous versions */
|
||||
void* RxEP_buffer;
|
||||
|
||||
uint8_t MaxPacketSize;
|
||||
|
||||
}DEVICE_PROP;
|
||||
@ -229,10 +232,10 @@ RESULT Standard_ClearFeature(void);
|
||||
void SetDeviceAddress(uint8_t);
|
||||
void NOP_Process(void);
|
||||
|
||||
extern DEVICE_PROP Device_Property;
|
||||
extern USER_STANDARD_REQUESTS User_Standard_Requests;
|
||||
extern DEVICE Device_Table;
|
||||
extern DEVICE_INFO Device_Info;
|
||||
/*extern*/ DEVICE_PROP Device_Property;
|
||||
/*extern*/ USER_STANDARD_REQUESTS User_Standard_Requests;
|
||||
/*extern*/ DEVICE Device_Table;
|
||||
/*extern*/ DEVICE_INFO Device_Info;
|
||||
|
||||
/* cells saving status during interrupt servicing */
|
||||
extern __IO uint16_t SaveRState;
|
||||
@ -240,4 +243,4 @@ extern __IO uint16_t SaveTState;
|
||||
|
||||
#endif /* __USB_CORE_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_def.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Definitions related to USB Core
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -77,4 +77,4 @@ typedef enum _FEATURE_SELECTOR
|
||||
|
||||
#endif /* __USB_DEF_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_init.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Initialization routines & global variables
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -46,4 +46,4 @@ extern uint16_t wInterrupt_Mask;
|
||||
|
||||
#endif /* __USB_INIT_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_int.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Endpoint CTR (Low and High) interrupt's service routines
|
||||
* prototypes
|
||||
********************************************************************************
|
||||
@ -30,4 +30,4 @@ void CTR_HP(void);
|
||||
|
||||
#endif /* __USB_INT_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_lib.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : USB library include files
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -29,6 +29,8 @@
|
||||
#include "usb_int.h"
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
#include "usb_sil.h"
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
#include "otgd_fs_cal.h"
|
||||
#include "otgd_fs_pcd.h"
|
||||
@ -45,4 +47,4 @@
|
||||
|
||||
#endif /* __USB_LIB_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_mem.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Utility prototypes functions for memory/PMA transfers
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -29,4 +29,4 @@ void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNByt
|
||||
|
||||
#endif /*__USB_MEM_H*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_regs.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Interface prototype functions to USB cell registers
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -668,4 +668,4 @@ uint16_t ByteSwap(uint16_t);
|
||||
|
||||
#endif /* __USB_REGS_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,34 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_sil.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Simplified Interface Layer function prototypes.
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_SIL_H
|
||||
#define __USB_SIL_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
uint32_t USB_SIL_Init(void);
|
||||
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
|
||||
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer);
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
|
||||
#endif /* __USB_SIL_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_type.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Type definitions used by the USB Library
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -18,7 +18,7 @@
|
||||
#define __USB_TYPE_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
//#include "usb_conf.h"
|
||||
#include "usb_conf.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
@ -71,4 +71,4 @@ typedef enum { ERROR = 0, SUCCESS = !ERROR} ErrorStatus;
|
||||
|
||||
#endif /* __USB_TYPE_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_core.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Standard protocol processing (USB v2.0)
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -22,7 +22,7 @@
|
||||
#define ClrBit(VAR,Place) (VAR &= ((1 << Place) ^ 255))
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
#define Send0LengthData() {OTGD_FS_PCD_EP_Write (0, 0, 0) ; vSetEPTxStatus(EP_TX_VALID);}
|
||||
#define Send0LengthData() {PCD_EP_Write (0, 0, 0) ; vSetEPTxStatus(EP_TX_VALID);}
|
||||
#else
|
||||
#define Send0LengthData() { _SetEPTxCount(ENDP0, 0); \
|
||||
vSetEPTxStatus(EP_TX_VALID); \
|
||||
@ -308,8 +308,7 @@ RESULT Standard_ClearFeature(void)
|
||||
if (Related_Endpoint == ENDP0)
|
||||
{
|
||||
/* After clear the STALL, enable the default endpoint receiver */
|
||||
//SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
|
||||
SetEPRxCount(Related_Endpoint, pProperty->MaxPacketSize);
|
||||
SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
|
||||
_SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
|
||||
}
|
||||
else
|
||||
@ -460,7 +459,7 @@ void DataStageOut(void)
|
||||
pEPinfo->Usb_rOffset += Length;
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_PCD_EP_Read(ENDP0, Buffer, Length);
|
||||
PCD_EP_Read(ENDP0, Buffer, Length);
|
||||
#else
|
||||
PMAToUserBufferCopy(Buffer, GetEPRxAddr(ENDP0), Length);
|
||||
#endif /* STM32F10X_CL */
|
||||
@ -522,7 +521,7 @@ void DataStageIn(void)
|
||||
ControlState = WAIT_STATUS_OUT;
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_PCD_EP_Read (ENDP0, 0, 0);
|
||||
PCD_EP_Read (ENDP0, 0, 0);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
@ -544,7 +543,7 @@ void DataStageIn(void)
|
||||
DataBuffer = (*pEPinfo->CopyData)(Length);
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_PCD_EP_Write (ENDP0, DataBuffer, Length);
|
||||
PCD_EP_Write (ENDP0, DataBuffer, Length);
|
||||
#else
|
||||
UserToPMABufferCopy(DataBuffer, GetEPTxAddr(ENDP0), Length);
|
||||
#endif /* STM32F10X_CL */
|
||||
@ -888,10 +887,8 @@ uint8_t Setup0_Process(void)
|
||||
USB_OTG_EP *ep;
|
||||
uint16_t offset = 0;
|
||||
|
||||
ep = OTGD_FS_PCD_GetOutEP(ENDP0);
|
||||
ep = PCD_GetOutEP(ENDP0);
|
||||
pBuf.b = ep->xfer_buff;
|
||||
|
||||
OTGD_FS_EP0StartXfer(ep);
|
||||
#else
|
||||
uint16_t offset = 1;
|
||||
|
||||
@ -1020,8 +1017,7 @@ uint8_t Post0_Process(void)
|
||||
USB_OTG_EP *ep;
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
//SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
||||
SetEPRxCount(ENDP0, pProperty->MaxPacketSize);
|
||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
||||
|
||||
if (pInformation->ControlState == STALLED)
|
||||
{
|
||||
@ -1033,7 +1029,7 @@ uint8_t Post0_Process(void)
|
||||
else if ((pInformation->ControlState == OUT_DATA) ||
|
||||
(pInformation->ControlState == WAIT_STATUS_OUT))
|
||||
{
|
||||
ep = OTGD_FS_PCD_GetInEP(0);
|
||||
ep = PCD_GetInEP(0);
|
||||
ep->is_in = 0;
|
||||
OTGD_FS_EP0StartXfer(ep);
|
||||
|
||||
@ -1043,7 +1039,7 @@ uint8_t Post0_Process(void)
|
||||
else if ((pInformation->ControlState == IN_DATA) ||
|
||||
(pInformation->ControlState == WAIT_STATUS_IN))
|
||||
{
|
||||
ep = OTGD_FS_PCD_GetInEP(0);
|
||||
ep = PCD_GetInEP(0);
|
||||
ep->is_in = 1;
|
||||
OTGD_FS_EP0StartXfer(ep);
|
||||
}
|
||||
@ -1062,7 +1058,7 @@ uint8_t Post0_Process(void)
|
||||
void SetDeviceAddress(uint8_t Val)
|
||||
{
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_PCD_EP_SetAddress ((uint8_t)Val);
|
||||
PCD_EP_SetAddress ((uint8_t)Val);
|
||||
#else
|
||||
uint32_t i;
|
||||
uint32_t nEP = Device_Table.Total_Endpoint;
|
||||
@ -1087,4 +1083,4 @@ void NOP_Process(void)
|
||||
{
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_init.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Initialization routines & global variables
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -60,4 +60,4 @@ void USB_Init(void)
|
||||
pProperty->Init();
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_int.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Endpoint CTR (Low and High) interrupt's service routines
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -41,7 +41,6 @@ extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
|
||||
*******************************************************************************/
|
||||
void CTR_LP(void)
|
||||
{
|
||||
uint16_t wIstr;
|
||||
__IO uint16_t wEPVal = 0;
|
||||
/* stay in loop while pending ints */
|
||||
while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
|
||||
@ -152,7 +151,6 @@ void CTR_LP(void)
|
||||
*******************************************************************************/
|
||||
void CTR_HP(void)
|
||||
{
|
||||
uint16_t wIstr;
|
||||
uint32_t wEPVal = 0;
|
||||
|
||||
while (((wIstr = _GetISTR()) & ISTR_CTR) != 0)
|
||||
@ -187,4 +185,4 @@ void CTR_HP(void)
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_mem.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Utility functions for memory transfers to/from PMA
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -72,4 +72,4 @@ void PMAToUserBufferCopy(uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNByt
|
||||
}
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -1,8 +1,8 @@
|
||||
/******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_regs.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.1.0
|
||||
* Date : 10/30/2009
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Interface functions to USB cell registers
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
@ -747,4 +747,4 @@ uint16_t ByteSwap(uint16_t wSwW)
|
||||
}
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -0,0 +1,126 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_sil.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Simplified Interface Layer for Global Initialization and
|
||||
* Endpoint Rea/Write operations.
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_lib.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : USB_SIL_Init
|
||||
* Description : Initialize the USB Device IP and the Endpoint 0.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : Status.
|
||||
*******************************************************************************/
|
||||
uint32_t USB_SIL_Init(void)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
|
||||
/* USB interrupts initialization */
|
||||
/* clear pending interrupts */
|
||||
_SetISTR(0);
|
||||
wInterrupt_Mask = IMR_MSK;
|
||||
/* set interrupts mask */
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
|
||||
#else
|
||||
|
||||
/* Perform OTG Device initialization procedure (including EP0 init) */
|
||||
OTG_DEV_Init();
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : USB_SIL_Write
|
||||
* Description : Write a buffer of data to a selected endpoint.
|
||||
* Input : - bEpAddr: The address of the non control endpoint.
|
||||
* - pBufferPointer: The pointer to the buffer of data to be written
|
||||
* to the endpoint.
|
||||
* - wBufferSize: Number of data to be written (in bytes).
|
||||
* Output : None.
|
||||
* Return : Status.
|
||||
*******************************************************************************/
|
||||
uint32_t USB_SIL_Write(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
|
||||
/* Use the memory interface function to write to the selected endpoint */
|
||||
UserToPMABufferCopy(pBufferPointer, GetEPTxAddr(bEpAddr & 0x7F), wBufferSize);
|
||||
|
||||
/* Update the data length in the control register */
|
||||
SetEPTxCount((bEpAddr & 0x7F), wBufferSize);
|
||||
|
||||
#else
|
||||
|
||||
/* Use the PCD interface layer function to write to the selected endpoint */
|
||||
PCD_EP_Write (bEpAddr, pBufferPointer, wBufferSize);
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : USB_SIL_Read
|
||||
* Description : Write a buffer of data to a selected endpoint.
|
||||
* Input : - bEpAddr: The address of the non control endpoint.
|
||||
* - pBufferPointer: The pointer to which will be saved the
|
||||
* received data buffer.
|
||||
* Output : None.
|
||||
* Return : Number of received data (in Bytes).
|
||||
*******************************************************************************/
|
||||
uint32_t USB_SIL_Read(uint8_t bEpAddr, uint8_t* pBufferPointer)
|
||||
{
|
||||
uint32_t DataLength = 0;
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
|
||||
/* Get the number of received data on the selected Endpoint */
|
||||
DataLength = GetEPRxCount(bEpAddr & 0x7F);
|
||||
|
||||
/* Use the memory interface function to write to the selected endpoint */
|
||||
PMAToUserBufferCopy(pBufferPointer, GetEPRxAddr(bEpAddr & 0x7F), DataLength);
|
||||
|
||||
#else
|
||||
|
||||
USB_OTG_EP *ep;
|
||||
|
||||
/* Get the structure pointer of the selected Endpoint */
|
||||
ep = PCD_GetOutEP(bEpAddr);
|
||||
|
||||
/* Get the number of received data */
|
||||
DataLength = ep->xfer_len;
|
||||
|
||||
/* Use the PCD interface layer function to read the selected endpoint */
|
||||
PCD_EP_Read (bEpAddr, pBufferPointer, DataLength);
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* Return the number of received data */
|
||||
return DataLength;
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
@ -1,582 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_USB USB Functions
|
||||
* @brief PIOS USB interface code
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* Parts by Thorsten Klose (tk@midibox.org)
|
||||
* @brief USB functions (STM32 dependent)
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB)
|
||||
|
||||
|
||||
/* Local definitions */
|
||||
#define DSCR_DEVICE 1 /* Descriptor type: Device */
|
||||
#define DSCR_CONFIG 2 /* Descriptor type: Configuration */
|
||||
#define DSCR_STRING 3 /* Descriptor type: String */
|
||||
#define DSCR_INTRFC 4 /* Descriptor type: Interface */
|
||||
#define DSCR_ENDPNT 5 /* Descriptor type: Endpoint */
|
||||
#define CS_INTERFACE 0x24 /* Class-specific type: Interface */
|
||||
#define CS_ENDPOINT 0x25 /* Class-specific type: Endpoint */
|
||||
|
||||
/* ISTR events */
|
||||
/* mask defining which events has to be handled by the device application software */
|
||||
#define IMR_MSK (CNTR_RESETM | CNTR_SOFM | CNTR_CTRM)
|
||||
|
||||
/* Local types */
|
||||
typedef enum _DEVICE_STATE {
|
||||
UNCONNECTED,
|
||||
ATTACHED,
|
||||
POWERED,
|
||||
SUSPENDED,
|
||||
ADDRESSED,
|
||||
CONFIGURED
|
||||
} DEVICE_STATE;
|
||||
|
||||
/* Global Variables used by STM32 USB Driver */
|
||||
/* (unfortunately no unique names are used...) */
|
||||
/* Points to the DEVICE_INFO/DEVICE_PROP_USER_STANDARD_REQUESTS structure of current device */
|
||||
/* The purpose of this register is to speed up the execution */
|
||||
DEVICE_INFO *pInformation;
|
||||
DEVICE Device_Table;
|
||||
DEVICE_PROP *pProperty;
|
||||
USER_STANDARD_REQUESTS *pUser_Standard_Requests;
|
||||
|
||||
/* Stored in RAM, vectors can be changed on-the-fly */
|
||||
void (*pEpInt_IN[7])(void) = {
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process
|
||||
};
|
||||
void (*pEpInt_OUT[7])(void) = {
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process,
|
||||
NOP_Process
|
||||
};
|
||||
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
|
||||
#define PIOS_USB_HID_NUM_INTERFACES 1
|
||||
#define PIOS_USB_HID_SIZ_CLASS_DESC 18
|
||||
#define PIOS_USB_HID_SIZ_CONFIG_DESC 32
|
||||
|
||||
#define PIOS_USB_NUM_INTERFACES (PIOS_USB_HID_NUM_INTERFACES)
|
||||
#define PIOS_USB_SIZ_CONFIG_DESC (9 + PIOS_USB_HID_SIZ_CONFIG_DESC)
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
#define PIOS_USB_SIZ_DEVICE_DESC 18
|
||||
static const uint8_t PIOS_USB_DeviceDescriptor[PIOS_USB_SIZ_DEVICE_DESC] = {
|
||||
(uint8_t)(PIOS_USB_SIZ_DEVICE_DESC & 0xff), /* Device Descriptor length */
|
||||
DSCR_DEVICE, /* Descriptor type */
|
||||
(uint8_t)(0x0200 & 0xff), /* Specification Version (BCD, LSB) */
|
||||
(uint8_t)(0x0200 >> 8), /* Specification Version (BCD, MSB) */
|
||||
0x00, /* Device class "Communication" */
|
||||
0x00, /* Device sub-class */
|
||||
0x00, /* Device sub-sub-class */
|
||||
0x40, /* Maximum packet size */
|
||||
(uint8_t)((PIOS_USB_VENDOR_ID) & 0xff), /* Vendor ID (LSB) */
|
||||
(uint8_t)((PIOS_USB_VENDOR_ID) >> 8), /* Vendor ID (MSB) */
|
||||
(uint8_t)((PIOS_USB_PRODUCT_ID) & 0xff), /* Product ID (LSB) */
|
||||
(uint8_t)((PIOS_USB_PRODUCT_ID) >> 8), /* Product ID (MSB) */
|
||||
(uint8_t)((PIOS_USB_VERSION_ID) & 0xff), /* Product version ID (LSB) */
|
||||
(uint8_t)((PIOS_USB_VERSION_ID) >> 8), /* Product version ID (MSB) */
|
||||
0x01, /* Manufacturer string index */
|
||||
0x02, /* Product string index */
|
||||
0x03, /* Serial number string index */
|
||||
0x01 /* Number of configurations */
|
||||
};
|
||||
|
||||
/* USB Configuration Descriptor */
|
||||
static const uint8_t PIOS_USB_ConfigDescriptor[PIOS_USB_SIZ_CONFIG_DESC] = {
|
||||
/* Configuration Descriptor */
|
||||
9, /* Descriptor length */
|
||||
DSCR_CONFIG, // Descriptor type */
|
||||
(PIOS_USB_SIZ_CONFIG_DESC) & 0xff, /* Config + End Points length (LSB) */
|
||||
(PIOS_USB_SIZ_CONFIG_DESC) >> 8, /* Config + End Points length (LSB) */
|
||||
PIOS_USB_NUM_INTERFACES, /* Number of interfaces */
|
||||
0x01, /* Configuration Value */
|
||||
0x00, /* Configuration string */
|
||||
0x80, /* Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu) */
|
||||
0x32, /* Power requirement (div 2 ma) */
|
||||
|
||||
/* HID */
|
||||
/************** Descriptor of Custom HID interface ****************/
|
||||
/* 09 */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
0x04,/* bDescriptorType: Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints */
|
||||
0x03, /* bInterfaceClass: HID */
|
||||
0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
|
||||
0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
|
||||
0, /* iInterface: Index of string descriptor */
|
||||
|
||||
/******************** Descriptor of Custom HID HID ********************/
|
||||
/* 18 */
|
||||
0x09, /* bLength: HID Descriptor size */
|
||||
0x21, /* bDescriptorType: HID */
|
||||
0x10, 0x01, /* bcdHID: HID Class Spec release number */
|
||||
0x00, /* bCountryCode: Hardware target country */
|
||||
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
||||
0x22, /* bDescriptorType */
|
||||
PIOS_USB_HID_SIZ_REPORT_DESC, 0x00, /* wItemLength: Total length of Report descriptor */
|
||||
|
||||
/******************** Descriptor of Custom HID endpoints ******************/
|
||||
/* 27 */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
|
||||
0x81, /* bEndpointAddress: Endpoint Address (IN) */
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
(PIOS_USB_HID_DATA_LENGTH), 0x00, /* wMaxPacketSize */
|
||||
0x02, /* bInterval: Polling Interval (2 ms) */
|
||||
/* 34 */
|
||||
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
/* Endpoint descriptor type */
|
||||
0x01, /* bEndpointAddress: */
|
||||
/* Endpoint Address (OUT) */
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
(PIOS_USB_HID_DATA_LENGTH), /* wMaxPacketSize */
|
||||
0x00, 8,//0x20, /* bInterval: Polling Interval (8 ms) */
|
||||
/* 41 */
|
||||
};
|
||||
|
||||
/* Local prototypes */
|
||||
static void PIOS_USB_CB_Reset(void);
|
||||
static void PIOS_USB_CB_SetConfiguration(void);
|
||||
static void PIOS_USB_CB_SetDeviceAddress(void);
|
||||
static void PIOS_USB_CB_Status_In(void);
|
||||
static void PIOS_USB_CB_Status_Out(void);
|
||||
static RESULT PIOS_USB_CB_Data_Setup(uint8_t RequestNo);
|
||||
static RESULT PIOS_USB_CB_NoData_Setup(uint8_t RequestNo);
|
||||
static uint8_t *PIOS_USB_CB_GetDeviceDescriptor(uint16_t Length);
|
||||
static uint8_t *PIOS_USB_CB_GetConfigDescriptor(uint16_t Length);
|
||||
static uint8_t *PIOS_USB_CB_GetStringDescriptor(uint16_t Length);
|
||||
static RESULT PIOS_USB_CB_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting);
|
||||
|
||||
|
||||
/* USB callback vectors */
|
||||
static const DEVICE My_Device_Table = {PIOS_USB_EP_NUM, 1};
|
||||
static const DEVICE_PROP My_Device_Property = {
|
||||
0, /* PIOS_USB_CB_Init, */
|
||||
PIOS_USB_CB_Reset,
|
||||
PIOS_USB_CB_Status_In,
|
||||
PIOS_USB_CB_Status_Out,
|
||||
PIOS_USB_CB_Data_Setup,
|
||||
PIOS_USB_CB_NoData_Setup,
|
||||
PIOS_USB_CB_Get_Interface_Setting,
|
||||
PIOS_USB_CB_GetDeviceDescriptor,
|
||||
PIOS_USB_CB_GetConfigDescriptor,
|
||||
PIOS_USB_CB_GetStringDescriptor,
|
||||
0,
|
||||
0x40 /*MAX PACKET SIZE*/
|
||||
};
|
||||
static const USER_STANDARD_REQUESTS My_User_Standard_Requests = {
|
||||
NOP_Process, /* PIOS_USB_CB_GetConfiguration, */
|
||||
PIOS_USB_CB_SetConfiguration,
|
||||
NOP_Process, /* PIOS_USB_CB_GetInterface, */
|
||||
NOP_Process, /* PIOS_USB_CB_SetInterface, */
|
||||
NOP_Process, /* PIOS_USB_CB_GetStatus, */
|
||||
NOP_Process, /* PIOS_USB_CB_ClearFeature, */
|
||||
NOP_Process, /* PIOS_USB_CB_SetEndPointFeature, */
|
||||
NOP_Process, /* PIOS_USB_CB_SetDeviceFeature, */
|
||||
PIOS_USB_CB_SetDeviceAddress};
|
||||
|
||||
/* Local Variables */
|
||||
/* USB Device informations */
|
||||
static DEVICE_INFO My_Device_Info;
|
||||
/* USB device status */
|
||||
static volatile uint32_t bDeviceState = UNCONNECTED;
|
||||
__IO uint8_t bIntPackSOF = 0;
|
||||
|
||||
/**
|
||||
* Initialises USB interface
|
||||
* \param[in] mode
|
||||
* <UL>
|
||||
* <LI>if 0, USB peripheral won't be initialised if this has already been done before
|
||||
* <LI>if 1, USB peripheral re-initialisation will be forced
|
||||
* <LI>if 2, USB peripheral re-initialisation will be forced, STM32 driver hooks won't be overwritten.<BR>
|
||||
* This mode can be used for a local USB driver which installs it's own hooks during runtime.<BR>
|
||||
* The application can switch back to PIOS drivers by calling PIOS_USB_Init(1)
|
||||
* </UL>
|
||||
* \return < 0 if initialisation failed
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
int32_t PIOS_USB_Init(uint32_t mode)
|
||||
{
|
||||
/* Currently only mode 0..2 supported */
|
||||
if(mode >= 3) {
|
||||
/* Unsupported mode */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Clear all USB interrupt requests */
|
||||
PIOS_IRQ_Disable();
|
||||
/* Interrupt Mask */
|
||||
_SetCNTR(0);
|
||||
PIOS_IRQ_Enable();
|
||||
|
||||
/* If mode != 2: install PIOS hooks */
|
||||
/* A local driver can install it's own hooks and call PIOS_USB_Init(2) to force re-enumeration */
|
||||
if(mode != 2) {
|
||||
/* Note: usually no need to duplicate this for external drivers */
|
||||
pInformation = &My_Device_Info;
|
||||
pInformation->Ctrl_Info.Usb_wLength = (PIOS_USB_HID_DATA_LENGTH); /* TODO: Is this required? */
|
||||
|
||||
/* Following hooks/pointers should be replaced by external drivers */
|
||||
memcpy(&Device_Table, (DEVICE *) &My_Device_Table, sizeof(Device_Table));
|
||||
pProperty = (DEVICE_PROP *) &My_Device_Property;
|
||||
pUser_Standard_Requests = (USER_STANDARD_REQUESTS *) &My_User_Standard_Requests;
|
||||
|
||||
pEpInt_OUT[0] = PIOS_USB_HID_EP1_OUT_Callback;
|
||||
}
|
||||
|
||||
PIOS_USB_HID_ChangeConnectionState(0);
|
||||
|
||||
pInformation->ControlState = 2;
|
||||
pInformation->Current_Configuration = 0;
|
||||
|
||||
/* If mode == 0: don't initialise USB if not required (important for BSL) */
|
||||
if(mode == 0 && PIOS_USB_IsInitialized()) {
|
||||
pInformation->Current_Feature = PIOS_USB_ConfigDescriptor[7];
|
||||
pInformation->Current_Configuration = 1;
|
||||
pUser_Standard_Requests->User_SetConfiguration();
|
||||
} else {
|
||||
/* Force USB reset and power-down (this will also release the USB pins for direct GPIO control) */
|
||||
_SetCNTR(CNTR_FRES | CNTR_PDWN);
|
||||
|
||||
/* Using a "dirty" method to force a re-enumeration: */
|
||||
/* Force DPM (Pin PA12) low for ca. 10 mS before USB Tranceiver will be enabled */
|
||||
/* This overrules the external Pull-Up at PA12, and at least Windows & MacOS will enumerate again */
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_StructInit(&GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
PIOS_DELAY_WaitmS(50);
|
||||
|
||||
/* Release power-down, still hold reset */
|
||||
_SetCNTR(CNTR_PDWN);
|
||||
PIOS_DELAY_WaituS(5);
|
||||
|
||||
/* CNTR_FRES = 0 */
|
||||
_SetCNTR(0);
|
||||
|
||||
/* Clear pending interrupts */
|
||||
_SetISTR(0);
|
||||
|
||||
/* Configure USB clock */
|
||||
/* USBCLK = PLLCLK / 1.5 */
|
||||
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
|
||||
/* Enable USB clock */
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
|
||||
}
|
||||
|
||||
/* Don't set interrupt mask on custom driver installation */
|
||||
if(mode != 2) {
|
||||
/* Clear pending interrupts (again) */
|
||||
_SetISTR(0);
|
||||
|
||||
/* Set interrupts mask */
|
||||
_SetCNTR(IMR_MSK);
|
||||
}
|
||||
|
||||
bDeviceState = UNCONNECTED;
|
||||
|
||||
/* Enable USB interrupts */
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_USB_PRIORITY;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
/* No error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt handler for USB
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void)
|
||||
{
|
||||
uint16_t wIstr = _GetISTR();
|
||||
|
||||
if(wIstr & ISTR_RESET) {
|
||||
_SetISTR((uint16_t)CLR_RESET);
|
||||
pProperty->Reset();
|
||||
}
|
||||
|
||||
if(wIstr & ISTR_SOF) {
|
||||
_SetISTR((uint16_t)CLR_SOF);
|
||||
}
|
||||
|
||||
if(wIstr & ISTR_CTR) {
|
||||
/* Servicing of the endpoint correct transfer interrupt */
|
||||
/* Clear of the CTR flag into the sub */
|
||||
CTR_LP();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to query, if the USB interface has already been initialised.<BR>
|
||||
* This function is used by the bootloader to avoid a reconnection, it isn't
|
||||
* relevant for typical applications!
|
||||
* \return 1 if USB already initialised, 0 if not initialised
|
||||
*/
|
||||
int32_t PIOS_USB_IsInitialized(void)
|
||||
{
|
||||
/* We assume that initialisation has been done when endpoint 0 contains a value */
|
||||
return GetEPType(ENDP0) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the USB detect pin to determine if a USB cable is connected
|
||||
* \return 0 if cable not connected
|
||||
* \return 1 if cable is connected
|
||||
*/
|
||||
int32_t PIOS_USB_CableConnected(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(PIOS_USB_DETECT_GPIO_PORT, PIOS_USB_DETECT_GPIO_PIN);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Hooks of STM32 USB library
|
||||
* \note Applications shouldn't call this function directly, instead please use \ref PIOS_COM layer functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset Routine
|
||||
*/
|
||||
static void PIOS_USB_CB_Reset(void)
|
||||
{
|
||||
/* Set PIOS Device as not configured */
|
||||
pInformation->Current_Configuration = 0;
|
||||
|
||||
/* Current Feature initialisation */
|
||||
pInformation->Current_Feature = PIOS_USB_ConfigDescriptor[7];
|
||||
|
||||
/* Set PIOS Device with the default Interface */
|
||||
pInformation->Current_Interface = 0;
|
||||
SetBTABLE(PIOS_USB_BTABLE_ADDRESS);
|
||||
|
||||
/* Initialise Endpoint 0 */
|
||||
SetEPType(ENDP0, EP_CONTROL);
|
||||
SetEPTxStatus(ENDP0, EP_TX_STALL);
|
||||
SetEPRxAddr(ENDP0, PIOS_USB_ENDP0_RXADDR);
|
||||
SetEPTxAddr(ENDP0, PIOS_USB_ENDP0_TXADDR);
|
||||
Clear_Status_Out(ENDP0);
|
||||
SetEPRxCount(ENDP0, pProperty->MaxPacketSize);
|
||||
SetEPRxValid(ENDP0);
|
||||
|
||||
/* Initialise Endpoint 1 */
|
||||
SetEPType(ENDP1, EP_INTERRUPT);
|
||||
SetEPTxAddr(ENDP1, PIOS_USB_ENDP1_TXADDR);
|
||||
SetEPRxAddr(ENDP1, PIOS_USB_ENDP1_RXADDR);
|
||||
SetEPTxCount(ENDP1, (PIOS_USB_HID_DATA_LENGTH));
|
||||
SetEPRxCount(ENDP1, (PIOS_USB_HID_DATA_LENGTH));
|
||||
SetEPTxStatus(ENDP1, EP_TX_NAK);
|
||||
SetEPRxStatus(ENDP1, EP_RX_VALID);
|
||||
|
||||
/* Propagate connection state to USB HID driver */
|
||||
PIOS_USB_HID_ChangeConnectionState(0);
|
||||
|
||||
/* Set this device to response on default address */
|
||||
SetDeviceAddress(0);
|
||||
|
||||
bDeviceState = ATTACHED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the device state to configured
|
||||
*/
|
||||
static void PIOS_USB_CB_SetConfiguration(void)
|
||||
{
|
||||
if(pInformation->Current_Configuration != 0) {
|
||||
/* Propagate connection state to USB HID driver */
|
||||
PIOS_USB_HID_ChangeConnectionState(1); /* Connected */
|
||||
bDeviceState = CONFIGURED;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the device state to addressed
|
||||
*/
|
||||
static void PIOS_USB_CB_SetDeviceAddress(void)
|
||||
{
|
||||
bDeviceState = ADDRESSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status IN routine
|
||||
*/
|
||||
static void PIOS_USB_CB_Status_In(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Status OUT routine
|
||||
*/
|
||||
static void PIOS_USB_CB_Status_Out(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Data setup routine
|
||||
*/
|
||||
static RESULT PIOS_USB_CB_Data_Setup(uint8_t RequestNo)
|
||||
{
|
||||
RESULT Result;
|
||||
if((Result = PIOS_USB_HID_CB_Data_Setup(RequestNo)) != USB_UNSUPPORT) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the non data class specific requests
|
||||
*/
|
||||
static RESULT PIOS_USB_CB_NoData_Setup(uint8_t RequestNo)
|
||||
{
|
||||
RESULT res;
|
||||
if((res = PIOS_USB_HID_CB_NoData_Setup(RequestNo)) != USB_UNSUPPORT) {
|
||||
return res;
|
||||
}
|
||||
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the device descriptor
|
||||
*/
|
||||
static uint8_t *PIOS_USB_CB_GetDeviceDescriptor(uint16_t Length)
|
||||
{
|
||||
ONE_DESCRIPTOR desc = {(uint8_t *) PIOS_USB_DeviceDescriptor, PIOS_USB_SIZ_DEVICE_DESC};
|
||||
return Standard_GetDescriptorData(Length, &desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration descriptor
|
||||
*/
|
||||
static uint8_t *PIOS_USB_CB_GetConfigDescriptor(uint16_t Length)
|
||||
{
|
||||
ONE_DESCRIPTOR desc = {(uint8_t *) PIOS_USB_ConfigDescriptor, PIOS_USB_SIZ_CONFIG_DESC};
|
||||
return Standard_GetDescriptorData(Length, &desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the string descriptors according to the needed index
|
||||
*/
|
||||
static uint8_t *PIOS_USB_CB_GetStringDescriptor(uint16_t Length)
|
||||
{
|
||||
const uint8_t vendor_str[] = PIOS_USB_VENDOR_STR;
|
||||
const uint8_t product_str[] = PIOS_USB_PRODUCT_STR;
|
||||
|
||||
uint8_t buffer[200];
|
||||
uint16_t len;
|
||||
int i;
|
||||
|
||||
switch(pInformation->USBwValue0) {
|
||||
case 0: /* Language */
|
||||
/* buffer[0] and [1] initialised below */
|
||||
buffer[2] = 0x09; // CharSet
|
||||
buffer[3] = 0x04; // U.S.
|
||||
len = 4;
|
||||
break;
|
||||
|
||||
case 1: /* Vendor */
|
||||
/* buffer[0] and [1] initialised below */
|
||||
for(i = 0, len = 2; vendor_str[i] != '\0' && len < 200; ++i) {
|
||||
buffer[len++] = vendor_str[i];
|
||||
buffer[len++] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* Product */
|
||||
/* buffer[0] and [1] initialised below */
|
||||
for(i = 0, len = 2; product_str[i] != '\0' && len < 200; ++i) {
|
||||
buffer[len++] = product_str[i];
|
||||
buffer[len++] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3: { /* Serial Number */
|
||||
uint8_t serial_number_str[40];
|
||||
if(PIOS_SYS_SerialNumberGet((char *) serial_number_str) >= 0) {
|
||||
for(i = 0, len = 2; serial_number_str[i] != '\0' && len < 200; ++i) {
|
||||
buffer[len++] = serial_number_str[i];
|
||||
buffer[len++] = 0;
|
||||
}
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
break;
|
||||
default: /* string ID not supported */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer[0] = len; /* Descriptor Length */
|
||||
buffer[1] = DSCR_STRING; /* Descriptor Type */
|
||||
ONE_DESCRIPTOR desc = {(uint8_t *) buffer, len};
|
||||
return Standard_GetDescriptorData(Length, &desc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the interface and the alternate setting according to the supported one.
|
||||
*/
|
||||
static RESULT PIOS_USB_CB_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting)
|
||||
{
|
||||
if(AlternateSetting > 0) {
|
||||
return USB_UNSUPPORT;
|
||||
} else if(Interface >= PIOS_USB_NUM_INTERFACES) {
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
@ -33,6 +33,8 @@
|
||||
|
||||
/* Project Includes */
|
||||
#include "pios.h"
|
||||
#include "usb_lib.h"
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#if defined(PIOS_INCLUDE_USB_HID)
|
||||
|
||||
@ -108,6 +110,29 @@ int32_t PIOS_USB_HID_Init(uint32_t mode)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Enable the USB Interrupts */
|
||||
/* 2 bit for pre-emption priority, 2 bits for subpriority */
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
|
||||
/* Select USBCLK source */
|
||||
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
|
||||
/* Enable the USB clock */
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
|
||||
|
||||
PIOS_LED_On(LED1);
|
||||
// Set_System();
|
||||
// USB_Interrupts_Config();
|
||||
// Set_USBClock();
|
||||
USB_Init();
|
||||
PIOS_LED_On(LED2);
|
||||
|
||||
return 0; /* No error */
|
||||
}
|
||||
|
||||
@ -158,7 +183,7 @@ int32_t PIOS_USB_HID_TxBufferPutMoreNonBlocking(uint8_t id, const uint8_t *buffe
|
||||
|
||||
/* Copy bytes to be transmitted into transmit buffer */
|
||||
UserToPMABufferCopy((uint8_t*) buffer, GetEPTxAddr(EP1_IN & 0x7F), len);
|
||||
SetEPTxCount(ENDP1, len);
|
||||
SetEPTxCount((EP1_IN & 0x7F), len);
|
||||
|
||||
/* Send Buffer */
|
||||
SetEPTxValid(ENDP1);
|
||||
|
272
flight/PiOS/STM32F10x/pios_usb_hid_desc.c
Normal file
272
flight/PiOS/STM32F10x/pios_usb_hid_desc.c
Normal file
@ -0,0 +1,272 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_desc.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Descriptors for Custom HID Demo
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_lib.h"
|
||||
#include "pios_usb_desc.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
|
||||
{
|
||||
0x12, /*bLength */
|
||||
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
|
||||
0x00, /*bcdUSB */
|
||||
0x02,
|
||||
0x00, /*bDeviceClass*/
|
||||
0x00, /*bDeviceSubClass*/
|
||||
0x00, /*bDeviceProtocol*/
|
||||
0x40, /*bMaxPacketSize40*/
|
||||
0x83, /*idVendor (0x0483)*/
|
||||
0x04,
|
||||
0x50, /*idProduct = 0x5750*/
|
||||
0x57,
|
||||
0x00, /*bcdDevice rel. 2.00*/
|
||||
0x02,
|
||||
1, /*Index of string descriptor describing
|
||||
manufacturer */
|
||||
2, /*Index of string descriptor describing
|
||||
product*/
|
||||
3, /*Index of string descriptor describing the
|
||||
device serial number */
|
||||
0x01 /*bNumConfigurations*/
|
||||
}
|
||||
; /* CustomHID_DeviceDescriptor */
|
||||
|
||||
|
||||
/* USB Configuration Descriptor */
|
||||
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
||||
const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
|
||||
{
|
||||
0x09, /* bLength: Configuation Descriptor size */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
|
||||
CUSTOMHID_SIZ_CONFIG_DESC,
|
||||
/* wTotalLength: Bytes returned */
|
||||
0x00,
|
||||
0x01, /* bNumInterfaces: 1 interface */
|
||||
0x01, /* bConfigurationValue: Configuration value */
|
||||
0x00, /* iConfiguration: Index of string descriptor describing
|
||||
the configuration*/
|
||||
0xC0, /* bmAttributes: Bus powered */
|
||||
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
|
||||
|
||||
/************** Descriptor of Custom HID interface ****************/
|
||||
/* 09 */
|
||||
0x09, /* bLength: Interface Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: Number of Interface */
|
||||
0x00, /* bAlternateSetting: Alternate setting */
|
||||
0x02, /* bNumEndpoints */
|
||||
0x03, /* bInterfaceClass: HID */
|
||||
0x00, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
|
||||
0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
|
||||
0, /* iInterface: Index of string descriptor */
|
||||
/******************** Descriptor of Custom HID HID ********************/
|
||||
/* 18 */
|
||||
0x09, /* bLength: HID Descriptor size */
|
||||
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
|
||||
0x10, /* bcdHID: HID Class Spec release number */
|
||||
0x01,
|
||||
0x00, /* bCountryCode: Hardware target country */
|
||||
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
|
||||
0x22, /* bDescriptorType */
|
||||
CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
|
||||
0x00,
|
||||
/******************** Descriptor of Custom HID endpoints ******************/
|
||||
/* 27 */
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
|
||||
0x81, /* bEndpointAddress: Endpoint Address (IN) */
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
0x02, /* wMaxPacketSize: 2 Bytes max */
|
||||
0x00,
|
||||
0x20, /* bInterval: Polling Interval (32 ms) */
|
||||
/* 34 */
|
||||
|
||||
0x07, /* bLength: Endpoint Descriptor size */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
|
||||
/* Endpoint descriptor type */
|
||||
0x01, /* bEndpointAddress: */
|
||||
/* Endpoint Address (OUT) */
|
||||
0x03, /* bmAttributes: Interrupt endpoint */
|
||||
0x02, /* wMaxPacketSize: 2 Bytes max */
|
||||
0x00,
|
||||
0x20, /* bInterval: Polling Interval (20 ms) */
|
||||
/* 41 */
|
||||
}
|
||||
; /* CustomHID_ConfigDescriptor */
|
||||
const uint8_t CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] =
|
||||
{
|
||||
0x06, 0xFF, 0x00, /* USAGE_PAGE (Vendor Page: 0xFF00) */
|
||||
0x09, 0x01, /* USAGE (Demo Kit) */
|
||||
0xa1, 0x01, /* COLLECTION (Application) */
|
||||
/* 6 */
|
||||
|
||||
/* Led 1 */
|
||||
0x85, 0x01, /* REPORT_ID (1) */
|
||||
0x09, 0x01, /* USAGE (LED 1) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x85, 0x01, /* REPORT_ID (1) */
|
||||
0x09, 0x01, /* USAGE (LED 1) */
|
||||
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
|
||||
/* 26 */
|
||||
|
||||
/* Led 2 */
|
||||
0x85, 0x02, /* REPORT_ID 2 */
|
||||
0x09, 0x02, /* USAGE (LED 2) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x85, 0x02, /* REPORT_ID (2) */
|
||||
0x09, 0x02, /* USAGE (LED 2) */
|
||||
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
|
||||
/* 46 */
|
||||
|
||||
/* Led 3 */
|
||||
0x85, 0x03, /* REPORT_ID (3) */
|
||||
0x09, 0x03, /* USAGE (LED 3) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x85, 0x03, /* REPORT_ID (3) */
|
||||
0x09, 0x03, /* USAGE (LED 3) */
|
||||
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
|
||||
/* 66 */
|
||||
|
||||
/* Led 4 */
|
||||
0x85, 0x04, /* REPORT_ID 4) */
|
||||
0x09, 0x04, /* USAGE (LED 4) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x95, 0x01, /* REPORT_COUNT (1) */
|
||||
0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x85, 0x04, /* REPORT_ID (4) */
|
||||
0x09, 0x04, /* USAGE (LED 4) */
|
||||
0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
|
||||
/* 86 */
|
||||
|
||||
/* key Push Button */
|
||||
0x85, 0x05, /* REPORT_ID (5) */
|
||||
0x09, 0x05, /* USAGE (Push Button) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */
|
||||
|
||||
0x09, 0x05, /* USAGE (Push Button) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x75, 0x07, /* REPORT_SIZE (7) */
|
||||
0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */
|
||||
0x85, 0x05, /* REPORT_ID (2) */
|
||||
|
||||
0x75, 0x07, /* REPORT_SIZE (7) */
|
||||
0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */
|
||||
/* 114 */
|
||||
|
||||
/* Tamper Push Button */
|
||||
0x85, 0x06, /* REPORT_ID (6) */
|
||||
0x09, 0x06, /* USAGE (Tamper Push Button) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */
|
||||
|
||||
0x09, 0x06, /* USAGE (Tamper Push Button) */
|
||||
0x75, 0x01, /* REPORT_SIZE (1) */
|
||||
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
|
||||
0x75, 0x07, /* REPORT_SIZE (7) */
|
||||
0x81, 0x83, /* INPUT (Cnst,Var,Abs,Vol) */
|
||||
0x85, 0x06, /* REPORT_ID (6) */
|
||||
|
||||
0x75, 0x07, /* REPORT_SIZE (7) */
|
||||
0xb1, 0x83, /* FEATURE (Cnst,Var,Abs,Vol) */
|
||||
/* 142 */
|
||||
|
||||
/* ADC IN */
|
||||
0x85, 0x07, /* REPORT_ID (7) */
|
||||
0x09, 0x07, /* USAGE (ADC IN) */
|
||||
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
|
||||
0x26, 0xff, 0x00, /* LOGICAL_MAXIMUM (255) */
|
||||
0x75, 0x08, /* REPORT_SIZE (8) */
|
||||
0x81, 0x82, /* INPUT (Data,Var,Abs,Vol) */
|
||||
0x85, 0x07, /* REPORT_ID (7) */
|
||||
0x09, 0x07, /* USAGE (ADC in) */
|
||||
0xb1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
|
||||
/* 161 */
|
||||
|
||||
0xc0 /* END_COLLECTION */
|
||||
}; /* CustomHID_ReportDescriptor */
|
||||
|
||||
/* USB String Descriptors (optional) */
|
||||
const uint8_t CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID] =
|
||||
{
|
||||
CUSTOMHID_SIZ_STRING_LANGID,
|
||||
USB_STRING_DESCRIPTOR_TYPE,
|
||||
0x09,
|
||||
0x04
|
||||
}
|
||||
; /* LangID = 0x0409: U.S. English */
|
||||
|
||||
const uint8_t CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR] =
|
||||
{
|
||||
CUSTOMHID_SIZ_STRING_VENDOR, /* Size of Vendor string */
|
||||
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/
|
||||
/* Manufacturer: "STMicroelectronics" */
|
||||
'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
|
||||
'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
|
||||
'c', 0, 's', 0
|
||||
};
|
||||
|
||||
const uint8_t CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT] =
|
||||
{
|
||||
CUSTOMHID_SIZ_STRING_PRODUCT, /* bLength */
|
||||
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
'A', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'C', 0,
|
||||
'u', 0, 's', 0, 't', 0, 'm', 0, ' ', 0, 'H', 0, 'I', 0,
|
||||
'D', 0
|
||||
};
|
||||
uint8_t CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL] =
|
||||
{
|
||||
CUSTOMHID_SIZ_STRING_SERIAL, /* bLength */
|
||||
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
'S', 0, 'T', 0, 'M', 0,'3', 0,'2', 0, '1', 0, '0', 0
|
||||
};
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
54
flight/PiOS/STM32F10x/pios_usb_hid_endp.c
Normal file
54
flight/PiOS/STM32F10x/pios_usb_hid_endp.c
Normal file
@ -0,0 +1,54 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_endp.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Endpoint routines
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x.h"
|
||||
#include "usb_lib.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
uint8_t Receive_Buffer[2];
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/*******************************************************************************
|
||||
* Function Name : EP1_OUT_Callback.
|
||||
* Description : EP1 OUT Callback Routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void EP1_OUT_Callback(void)
|
||||
{
|
||||
|
||||
/* Read recieved data (2 bytes) */
|
||||
USB_SIL_Read(EP1_OUT, Receive_Buffer);
|
||||
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
SetEPRxStatus(ENDP1, EP_RX_VALID);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
char Send_Buffer[2];
|
||||
Send_Buffer[0] = 0xff;
|
||||
Send_Buffer[1] = 0xff;
|
||||
USB_SIL_Write(EP1_IN, (uint8_t*) Send_Buffer, 2);
|
||||
//SetEPTxValid(ENDP1);
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
382
flight/PiOS/STM32F10x/pios_usb_hid_istr.c
Normal file
382
flight/PiOS/STM32F10x/pios_usb_hid_istr.c
Normal file
@ -0,0 +1,382 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_istr.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : ISTR events interrupt service routines
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_lib.h"
|
||||
#include "pios_usb_pwr.h"
|
||||
#include "pios_usb_istr.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
__IO uint16_t wIstr; /* ISTR register last read value */
|
||||
__IO uint8_t bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
|
||||
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* function pointers to non-control endpoints service routines */
|
||||
void (*pEpInt_IN[7])(void) =
|
||||
{
|
||||
EP1_IN_Callback,
|
||||
EP2_IN_Callback,
|
||||
EP3_IN_Callback,
|
||||
EP4_IN_Callback,
|
||||
EP5_IN_Callback,
|
||||
EP6_IN_Callback,
|
||||
EP7_IN_Callback,
|
||||
};
|
||||
|
||||
void (*pEpInt_OUT[7])(void) =
|
||||
{
|
||||
EP1_OUT_Callback,
|
||||
EP2_OUT_Callback,
|
||||
EP3_OUT_Callback,
|
||||
EP4_OUT_Callback,
|
||||
EP5_OUT_Callback,
|
||||
EP6_OUT_Callback,
|
||||
EP7_OUT_Callback,
|
||||
};
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : USB_Istr
|
||||
* Description : STR events interrupt service routine
|
||||
* Input :
|
||||
* Output :
|
||||
* Return :
|
||||
*******************************************************************************/
|
||||
void USB_LP_CAN1_RX0_IRQHandler(void) //USB_Istr(void)
|
||||
{
|
||||
|
||||
wIstr = _GetISTR();
|
||||
|
||||
#if (IMR_MSK & ISTR_CTR)
|
||||
if (wIstr & ISTR_CTR & wInterrupt_Mask)
|
||||
{
|
||||
/* servicing of the endpoint correct transfer interrupt */
|
||||
/* clear of the CTR flag into the sub */
|
||||
CTR_LP();
|
||||
#ifdef CTR_CALLBACK
|
||||
CTR_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_RESET)
|
||||
if (wIstr & ISTR_RESET & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_RESET);
|
||||
Device_Property.Reset();
|
||||
#ifdef RESET_CALLBACK
|
||||
RESET_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_DOVR)
|
||||
if (wIstr & ISTR_DOVR & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_DOVR);
|
||||
#ifdef DOVR_CALLBACK
|
||||
DOVR_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_ERR)
|
||||
if (wIstr & ISTR_ERR & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_ERR);
|
||||
#ifdef ERR_CALLBACK
|
||||
ERR_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_WKUP)
|
||||
if (wIstr & ISTR_WKUP & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_WKUP);
|
||||
Resume(RESUME_EXTERNAL);
|
||||
#ifdef WKUP_CALLBACK
|
||||
WKUP_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_SUSP)
|
||||
if (wIstr & ISTR_SUSP & wInterrupt_Mask)
|
||||
{
|
||||
|
||||
/* check if SUSPEND is possible */
|
||||
if (fSuspendEnabled)
|
||||
{
|
||||
Suspend();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if not possible then resume after xx ms */
|
||||
Resume(RESUME_LATER);
|
||||
}
|
||||
/* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
|
||||
_SetISTR((uint16_t)CLR_SUSP);
|
||||
#ifdef SUSP_CALLBACK
|
||||
SUSP_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_SOF)
|
||||
if (wIstr & ISTR_SOF & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_SOF);
|
||||
bIntPackSOF++;
|
||||
|
||||
#ifdef SOF_CALLBACK
|
||||
SOF_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#if (IMR_MSK & ISTR_ESOF)
|
||||
if (wIstr & ISTR_ESOF & wInterrupt_Mask)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_ESOF);
|
||||
/* resume handling timing is made with ESOFs */
|
||||
Resume(RESUME_ESOF); /* request without change of the machine state */
|
||||
|
||||
#ifdef ESOF_CALLBACK
|
||||
ESOF_Callback();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} /* USB_Istr */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
#else /* STM32F10X_CL */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : STM32_PCD_OTG_ISR_Handler
|
||||
* Description : Handles all USB Device Interrupts
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : status
|
||||
*******************************************************************************/
|
||||
u32 STM32_PCD_OTG_ISR_Handler (void)
|
||||
{
|
||||
USB_OTG_GINTSTS_TypeDef gintr_status;
|
||||
u32 retval = 0;
|
||||
|
||||
if (USBD_FS_IsDeviceMode()) /* ensure that we are in device mode */
|
||||
{
|
||||
gintr_status.d32 = OTGD_FS_ReadCoreItr();
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
|
||||
/* If there is no interrupt pending exit the interrupt routine */
|
||||
if (!gintr_status.d32)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Early Suspend interrupt */
|
||||
#ifdef INTR_ERLYSUSPEND
|
||||
if (gintr_status.b.erlysuspend)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_EarlySuspend_ISR();
|
||||
}
|
||||
#endif /* INTR_ERLYSUSPEND */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* End of Periodic Frame interrupt */
|
||||
#ifdef INTR_EOPFRAME
|
||||
if (gintr_status.b.eopframe)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_EOPF_ISR();
|
||||
}
|
||||
#endif /* INTR_EOPFRAME */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Non Periodic Tx FIFO Emty interrupt */
|
||||
#ifdef INTR_NPTXFEMPTY
|
||||
if (gintr_status.b.nptxfempty)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_NPTxFE_ISR();
|
||||
}
|
||||
#endif /* INTR_NPTXFEMPTY */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Wakeup or RemoteWakeup interrupt */
|
||||
#ifdef INTR_WKUPINTR
|
||||
if (gintr_status.b.wkupintr)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_Wakeup_ISR();
|
||||
}
|
||||
#endif /* INTR_WKUPINTR */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Suspend interrupt */
|
||||
#ifdef INTR_USBSUSPEND
|
||||
if (gintr_status.b.usbsuspend)
|
||||
{
|
||||
/* check if SUSPEND is possible */
|
||||
if (fSuspendEnabled)
|
||||
{
|
||||
Suspend();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if not possible then resume after xx ms */
|
||||
Resume(RESUME_LATER); /* This case shouldn't happen in OTG Device mode because
|
||||
there's no ESOF interrupt to increment the ResumeS.bESOFcnt in the Resume state machine */
|
||||
}
|
||||
|
||||
retval |= OTGD_FS_Handle_USBSuspend_ISR();
|
||||
}
|
||||
#endif /* INTR_USBSUSPEND */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Start of Frame interrupt */
|
||||
#ifdef INTR_SOFINTR
|
||||
if (gintr_status.b.sofintr)
|
||||
{
|
||||
/* Update the frame number variable */
|
||||
bIntPackSOF++;
|
||||
|
||||
retval |= OTGD_FS_Handle_Sof_ISR();
|
||||
}
|
||||
#endif /* INTR_SOFINTR */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Receive FIFO Queue Status Level interrupt */
|
||||
#ifdef INTR_RXSTSQLVL
|
||||
if (gintr_status.b.rxstsqlvl)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_RxStatusQueueLevel_ISR();
|
||||
}
|
||||
#endif /* INTR_RXSTSQLVL */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Enumeration Done interrupt */
|
||||
#ifdef INTR_ENUMDONE
|
||||
if (gintr_status.b.enumdone)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_EnumDone_ISR();
|
||||
}
|
||||
#endif /* INTR_ENUMDONE */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Reset interrutp */
|
||||
#ifdef INTR_USBRESET
|
||||
if (gintr_status.b.usbreset)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_UsbReset_ISR();
|
||||
}
|
||||
#endif /* INTR_USBRESET */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* IN Endpoint interrupt */
|
||||
#ifdef INTR_INEPINTR
|
||||
if (gintr_status.b.inepint)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_InEP_ISR();
|
||||
}
|
||||
#endif /* INTR_INEPINTR */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* OUT Endpoint interrupt */
|
||||
#ifdef INTR_OUTEPINTR
|
||||
if (gintr_status.b.outepintr)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_OutEP_ISR();
|
||||
}
|
||||
#endif /* INTR_OUTEPINTR */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Mode Mismatch interrupt */
|
||||
#ifdef INTR_MODEMISMATCH
|
||||
if (gintr_status.b.modemismatch)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_ModeMismatch_ISR();
|
||||
}
|
||||
#endif /* INTR_MODEMISMATCH */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Global IN Endpoints NAK Effective interrupt */
|
||||
#ifdef INTR_GINNAKEFF
|
||||
if (gintr_status.b.ginnakeff)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_GInNakEff_ISR();
|
||||
}
|
||||
#endif /* INTR_GINNAKEFF */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Global OUT Endpoints NAK effective interrupt */
|
||||
#ifdef INTR_GOUTNAKEFF
|
||||
if (gintr_status.b.goutnakeff)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_GOutNakEff_ISR();
|
||||
}
|
||||
#endif /* INTR_GOUTNAKEFF */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Isochrounous Out packet Dropped interrupt */
|
||||
#ifdef INTR_ISOOUTDROP
|
||||
if (gintr_status.b.isooutdrop)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_IsoOutDrop_ISR();
|
||||
}
|
||||
#endif /* INTR_ISOOUTDROP */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Endpoint Mismatch error interrupt */
|
||||
#ifdef INTR_EPMISMATCH
|
||||
if (gintr_status.b.epmismatch)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_EPMismatch_ISR();
|
||||
}
|
||||
#endif /* INTR_EPMISMATCH */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Incomplete Isochrous IN tranfer error interrupt */
|
||||
#ifdef INTR_INCOMPLISOIN
|
||||
if (gintr_status.b.incomplisoin)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_IncomplIsoIn_ISR();
|
||||
}
|
||||
#endif /* INTR_INCOMPLISOIN */
|
||||
|
||||
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
|
||||
/* Incomplete Isochrous OUT tranfer error interrupt */
|
||||
#ifdef INTR_INCOMPLISOOUT
|
||||
if (gintr_status.b.outepintr)
|
||||
{
|
||||
retval |= OTGD_FS_Handle_IncomplIsoOut_ISR();
|
||||
}
|
||||
#endif /* INTR_INCOMPLISOOUT */
|
||||
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
424
flight/PiOS/STM32F10x/pios_usb_hid_prop.c
Normal file
424
flight/PiOS/STM32F10x/pios_usb_hid_prop.c
Normal file
@ -0,0 +1,424 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_prop.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : All processings related to Custom HID Demo
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x.h"
|
||||
#include "usb_lib.h"
|
||||
#include "usb_conf.h"
|
||||
#include "pios_usb_prop.h"
|
||||
#include "pios_usb_desc.h"
|
||||
#include "pios_usb_pwr.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
uint32_t ProtocolValue;
|
||||
__IO uint8_t EXTI_Enable;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Structures initializations */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
DEVICE Device_Table =
|
||||
{
|
||||
EP_NUM,
|
||||
1
|
||||
};
|
||||
|
||||
DEVICE_PROP Device_Property =
|
||||
{
|
||||
CustomHID_init,
|
||||
CustomHID_Reset,
|
||||
CustomHID_Status_In,
|
||||
CustomHID_Status_Out,
|
||||
CustomHID_Data_Setup,
|
||||
CustomHID_NoData_Setup,
|
||||
CustomHID_Get_Interface_Setting,
|
||||
CustomHID_GetDeviceDescriptor,
|
||||
CustomHID_GetConfigDescriptor,
|
||||
CustomHID_GetStringDescriptor,
|
||||
0,
|
||||
0x40 /*MAX PACKET SIZE*/
|
||||
};
|
||||
USER_STANDARD_REQUESTS User_Standard_Requests =
|
||||
{
|
||||
CustomHID_GetConfiguration,
|
||||
CustomHID_SetConfiguration,
|
||||
CustomHID_GetInterface,
|
||||
CustomHID_SetInterface,
|
||||
CustomHID_GetStatus,
|
||||
CustomHID_ClearFeature,
|
||||
CustomHID_SetEndPointFeature,
|
||||
CustomHID_SetDeviceFeature,
|
||||
CustomHID_SetDeviceAddress
|
||||
};
|
||||
|
||||
ONE_DESCRIPTOR Device_Descriptor =
|
||||
{
|
||||
(uint8_t*)CustomHID_DeviceDescriptor,
|
||||
CUSTOMHID_SIZ_DEVICE_DESC
|
||||
};
|
||||
|
||||
ONE_DESCRIPTOR Config_Descriptor =
|
||||
{
|
||||
(uint8_t*)CustomHID_ConfigDescriptor,
|
||||
CUSTOMHID_SIZ_CONFIG_DESC
|
||||
};
|
||||
|
||||
ONE_DESCRIPTOR CustomHID_Report_Descriptor =
|
||||
{
|
||||
(uint8_t *)CustomHID_ReportDescriptor,
|
||||
CUSTOMHID_SIZ_REPORT_DESC
|
||||
};
|
||||
|
||||
ONE_DESCRIPTOR CustomHID_Hid_Descriptor =
|
||||
{
|
||||
(uint8_t*)CustomHID_ConfigDescriptor + CUSTOMHID_OFF_HID_DESC,
|
||||
CUSTOMHID_SIZ_HID_DESC
|
||||
};
|
||||
|
||||
ONE_DESCRIPTOR String_Descriptor[4] =
|
||||
{
|
||||
{(uint8_t*)CustomHID_StringLangID, CUSTOMHID_SIZ_STRING_LANGID},
|
||||
{(uint8_t*)CustomHID_StringVendor, CUSTOMHID_SIZ_STRING_VENDOR},
|
||||
{(uint8_t*)CustomHID_StringProduct, CUSTOMHID_SIZ_STRING_PRODUCT},
|
||||
{(uint8_t*)CustomHID_StringSerial, CUSTOMHID_SIZ_STRING_SERIAL}
|
||||
};
|
||||
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Extern function prototypes ------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_init.
|
||||
* Description : Custom HID init routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_init(void)
|
||||
{
|
||||
/* Update the serial number string descriptor with the data from the unique
|
||||
ID*/
|
||||
//Get_SerialNum();
|
||||
|
||||
pInformation->Current_Configuration = 0;
|
||||
/* Connect the device */
|
||||
PowerOn();
|
||||
|
||||
/* Perform basic device initialization operations */
|
||||
USB_SIL_Init();
|
||||
|
||||
bDeviceState = UNCONNECTED;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_Reset.
|
||||
* Description : Custom HID reset routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_Reset(void)
|
||||
{
|
||||
/* Set Joystick_DEVICE as not configured */
|
||||
pInformation->Current_Configuration = 0;
|
||||
pInformation->Current_Interface = 0;/*the default Interface*/
|
||||
|
||||
/* Current Feature initialization */
|
||||
pInformation->Current_Feature = CustomHID_ConfigDescriptor[7];
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
/* EP0 is already configured in DFU_Init() by USB_SIL_Init() function */
|
||||
|
||||
/* Init EP1 IN as Interrupt endpoint */
|
||||
OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_INT, 2);
|
||||
|
||||
/* Init EP1 OUT as Interrupt endpoint */
|
||||
OTG_DEV_EP_Init(EP1_OUT, OTG_DEV_EP_TYPE_INT, 2);
|
||||
#else
|
||||
SetBTABLE(BTABLE_ADDRESS);
|
||||
|
||||
/* Initialize Endpoint 0 */
|
||||
SetEPType(ENDP0, EP_CONTROL);
|
||||
SetEPTxStatus(ENDP0, EP_TX_STALL);
|
||||
SetEPRxAddr(ENDP0, ENDP0_RXADDR);
|
||||
SetEPTxAddr(ENDP0, ENDP0_TXADDR);
|
||||
Clear_Status_Out(ENDP0);
|
||||
SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
|
||||
SetEPRxValid(ENDP0);
|
||||
|
||||
/* Initialize Endpoint 1 */
|
||||
SetEPType(ENDP1, EP_INTERRUPT);
|
||||
SetEPTxAddr(ENDP1, ENDP1_TXADDR);
|
||||
SetEPRxAddr(ENDP1, ENDP1_RXADDR);
|
||||
SetEPTxCount(ENDP1, 2);
|
||||
SetEPRxCount(ENDP1, 2);
|
||||
SetEPRxStatus(ENDP1, EP_RX_VALID);
|
||||
SetEPTxStatus(ENDP1, EP_TX_NAK);
|
||||
|
||||
/* Set this device to response on default address */
|
||||
SetDeviceAddress(0);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
bDeviceState = ATTACHED;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_SetConfiguration.
|
||||
* Description : Udpade the device state to configured and command the ADC
|
||||
* conversion.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_SetConfiguration(void)
|
||||
{
|
||||
if (pInformation->Current_Configuration != 0)
|
||||
{
|
||||
/* Device configured */
|
||||
bDeviceState = CONFIGURED;
|
||||
|
||||
/* Start ADC1 Software Conversion */
|
||||
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_SetConfiguration.
|
||||
* Description : Udpade the device state to addressed.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_SetDeviceAddress (void)
|
||||
{
|
||||
bDeviceState = ADDRESSED;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_Status_In.
|
||||
* Description : Joystick status IN routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_Status_In(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_Status_Out
|
||||
* Description : Joystick status OUT routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void CustomHID_Status_Out (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_Data_Setup
|
||||
* Description : Handle the data class specific requests.
|
||||
* Input : Request Nb.
|
||||
* Output : None.
|
||||
* Return : USB_UNSUPPORT or USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
RESULT CustomHID_Data_Setup(uint8_t RequestNo)
|
||||
{
|
||||
uint8_t *(*CopyRoutine)(uint16_t);
|
||||
|
||||
CopyRoutine = NULL;
|
||||
|
||||
if ((RequestNo == GET_DESCRIPTOR)
|
||||
&& (Type_Recipient == (STANDARD_REQUEST | INTERFACE_RECIPIENT))
|
||||
&& (pInformation->USBwIndex0 == 0))
|
||||
{
|
||||
|
||||
if (pInformation->USBwValue1 == REPORT_DESCRIPTOR)
|
||||
{
|
||||
CopyRoutine = CustomHID_GetReportDescriptor;
|
||||
}
|
||||
else if (pInformation->USBwValue1 == HID_DESCRIPTOR_TYPE)
|
||||
{
|
||||
CopyRoutine = CustomHID_GetHIDDescriptor;
|
||||
}
|
||||
|
||||
} /* End of GET_DESCRIPTOR */
|
||||
|
||||
/*** GET_PROTOCOL ***/
|
||||
else if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
&& RequestNo == GET_PROTOCOL)
|
||||
{
|
||||
CopyRoutine = CustomHID_GetProtocolValue;
|
||||
}
|
||||
|
||||
if (CopyRoutine == NULL)
|
||||
{
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
pInformation->Ctrl_Info.CopyData = CopyRoutine;
|
||||
pInformation->Ctrl_Info.Usb_wOffset = 0;
|
||||
(*CopyRoutine)(0);
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_NoData_Setup
|
||||
* Description : handle the no data class specific requests
|
||||
* Input : Request Nb.
|
||||
* Output : None.
|
||||
* Return : USB_UNSUPPORT or USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
RESULT CustomHID_NoData_Setup(uint8_t RequestNo)
|
||||
{
|
||||
if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
&& (RequestNo == SET_PROTOCOL))
|
||||
{
|
||||
return CustomHID_SetProtocol();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetDeviceDescriptor.
|
||||
* Description : Gets the device descriptor.
|
||||
* Input : Length
|
||||
* Output : None.
|
||||
* Return : The address of the device descriptor.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetDeviceDescriptor(uint16_t Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &Device_Descriptor);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetConfigDescriptor.
|
||||
* Description : Gets the configuration descriptor.
|
||||
* Input : Length
|
||||
* Output : None.
|
||||
* Return : The address of the configuration descriptor.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetConfigDescriptor(uint16_t Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &Config_Descriptor);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetStringDescriptor
|
||||
* Description : Gets the string descriptors according to the needed index
|
||||
* Input : Length
|
||||
* Output : None.
|
||||
* Return : The address of the string descriptors.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetStringDescriptor(uint16_t Length)
|
||||
{
|
||||
uint8_t wValue0 = pInformation->USBwValue0;
|
||||
if (wValue0 > 4)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetReportDescriptor.
|
||||
* Description : Gets the HID report descriptor.
|
||||
* Input : Length
|
||||
* Output : None.
|
||||
* Return : The address of the configuration descriptor.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetReportDescriptor(uint16_t Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &CustomHID_Report_Descriptor);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetHIDDescriptor.
|
||||
* Description : Gets the HID descriptor.
|
||||
* Input : Length
|
||||
* Output : None.
|
||||
* Return : The address of the configuration descriptor.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length)
|
||||
{
|
||||
return Standard_GetDescriptorData(Length, &CustomHID_Hid_Descriptor);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_Get_Interface_Setting.
|
||||
* Description : tests the interface and the alternate setting according to the
|
||||
* supported one.
|
||||
* Input : - Interface : interface number.
|
||||
* - AlternateSetting : Alternate Setting number.
|
||||
* Output : None.
|
||||
* Return : USB_SUCCESS or USB_UNSUPPORT.
|
||||
*******************************************************************************/
|
||||
RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting)
|
||||
{
|
||||
if (AlternateSetting > 0)
|
||||
{
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
else if (Interface > 0)
|
||||
{
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_SetProtocol
|
||||
* Description : Joystick Set Protocol request routine.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : USB SUCCESS.
|
||||
*******************************************************************************/
|
||||
RESULT CustomHID_SetProtocol(void)
|
||||
{
|
||||
uint8_t wValue0 = pInformation->USBwValue0;
|
||||
ProtocolValue = wValue0;
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : CustomHID_GetProtocolValue
|
||||
* Description : get the protocol value
|
||||
* Input : Length.
|
||||
* Output : None.
|
||||
* Return : address of the protcol value.
|
||||
*******************************************************************************/
|
||||
uint8_t *CustomHID_GetProtocolValue(uint16_t Length)
|
||||
{
|
||||
if (Length == 0)
|
||||
{
|
||||
pInformation->Ctrl_Info.Usb_wLength = 1;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (uint8_t *)(&ProtocolValue);
|
||||
}
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
299
flight/PiOS/STM32F10x/pios_usb_hid_pwr.c
Executable file
299
flight/PiOS/STM32F10x/pios_usb_hid_pwr.c
Executable file
@ -0,0 +1,299 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_pwr.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Connection/disconnection & power management
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f10x.h"
|
||||
#include "usb_lib.h"
|
||||
#include "usb_conf.h"
|
||||
#include "pios_usb_pwr.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
__IO uint32_t bDeviceState = UNCONNECTED; /* USB device status */
|
||||
__IO bool fSuspendEnabled = TRUE; /* true when suspend is possible */
|
||||
|
||||
struct
|
||||
{
|
||||
__IO RESUME_STATE eState;
|
||||
__IO uint8_t bESOFcnt;
|
||||
}ResumeS;
|
||||
|
||||
/* Extern variables ----------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Extern function prototypes ------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : USB_Cable_Config.
|
||||
* Description : Software Connection/Disconnection of USB Cable.
|
||||
* Input : NewState: new state.
|
||||
* Output : None.
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void USB_Cable_Config (FunctionalState NewState)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : PowerOn
|
||||
* Description :
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
RESULT PowerOn(void)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
uint16_t wRegVal;
|
||||
|
||||
/*** cable plugged-in ? ***/
|
||||
USB_Cable_Config(ENABLE);
|
||||
|
||||
/*** CNTR_PWDN = 0 ***/
|
||||
wRegVal = CNTR_FRES;
|
||||
_SetCNTR(wRegVal);
|
||||
|
||||
/*** CNTR_FRES = 0 ***/
|
||||
wInterrupt_Mask = 0;
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
/*** Clear pending interrupts ***/
|
||||
_SetISTR(0);
|
||||
/*** Set interrupt mask ***/
|
||||
wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : PowerOff
|
||||
* Description : handles switch-off conditions
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
RESULT PowerOff()
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
/* disable all ints and force USB reset */
|
||||
_SetCNTR(CNTR_FRES);
|
||||
/* clear interrupt status register */
|
||||
_SetISTR(0);
|
||||
/* Disable the Pull-Up*/
|
||||
USB_Cable_Config(DISABLE);
|
||||
/* switch-off device */
|
||||
_SetCNTR(CNTR_FRES + CNTR_PDWN);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* sw variables reset */
|
||||
/* ... */
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Enter_LowPowerMode.
|
||||
* Description : Power-off system clocks and power while entering suspend mode.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void Enter_LowPowerMode(void)
|
||||
{
|
||||
/* Set the device state to suspend */
|
||||
bDeviceState = SUSPENDED;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Suspend
|
||||
* Description : sets suspend mode operating conditions
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
void Suspend(void)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
uint16_t wCNTR;
|
||||
/* suspend preparation */
|
||||
/* ... */
|
||||
|
||||
/* macrocell enters suspend mode */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_FSUSP;
|
||||
_SetCNTR(wCNTR);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
||||
/* power reduction */
|
||||
/* ... on connected devices */
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
/* force low-power mode in the macrocell */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_LPMODE;
|
||||
_SetCNTR(wCNTR);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* switch-off the clocks */
|
||||
/* ... */
|
||||
Enter_LowPowerMode();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Leave_LowPowerMode.
|
||||
* Description : Restores system clocks and power while exiting suspend mode.
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void Leave_LowPowerMode(void)
|
||||
{
|
||||
DEVICE_INFO *pInfo = &Device_Info;
|
||||
|
||||
/* Set the device state to the correct state */
|
||||
if (pInfo->Current_Configuration != 0)
|
||||
{
|
||||
/* Device configured */
|
||||
bDeviceState = CONFIGURED;
|
||||
}
|
||||
else
|
||||
{
|
||||
bDeviceState = ATTACHED;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Resume_Init
|
||||
* Description : Handles wake-up restoring normal operations
|
||||
* Input : None.
|
||||
* Output : None.
|
||||
* Return : USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
void Resume_Init(void)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
uint16_t wCNTR;
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
|
||||
/* restart the clocks */
|
||||
/* ... */
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
/* CNTR_LPMODE = 0 */
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR &= (~CNTR_LPMODE);
|
||||
_SetCNTR(wCNTR);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* restore full power */
|
||||
/* ... on connected devices */
|
||||
Leave_LowPowerMode();
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
/* reset FSUSP bit */
|
||||
_SetCNTR(IMR_MSK);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* reverse suspend preparation */
|
||||
/* ... */
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Resume
|
||||
* Description : This is the state machine handling resume operations and
|
||||
* timing sequence. The control is based on the Resume structure
|
||||
* variables and on the ESOF interrupt calling this subroutine
|
||||
* without changing machine state.
|
||||
* Input : a state machine value (RESUME_STATE)
|
||||
* RESUME_ESOF doesn't change ResumeS.eState allowing
|
||||
* decrementing of the ESOF counter in different states.
|
||||
* Output : None.
|
||||
* Return : None.
|
||||
*******************************************************************************/
|
||||
void Resume(RESUME_STATE eResumeSetVal)
|
||||
{
|
||||
#ifndef STM32F10X_CL
|
||||
uint16_t wCNTR;
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
if (eResumeSetVal != RESUME_ESOF)
|
||||
ResumeS.eState = eResumeSetVal;
|
||||
|
||||
switch (ResumeS.eState)
|
||||
{
|
||||
case RESUME_EXTERNAL:
|
||||
Resume_Init();
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
break;
|
||||
case RESUME_INTERNAL:
|
||||
Resume_Init();
|
||||
ResumeS.eState = RESUME_START;
|
||||
break;
|
||||
case RESUME_LATER:
|
||||
ResumeS.bESOFcnt = 2;
|
||||
ResumeS.eState = RESUME_WAIT;
|
||||
break;
|
||||
case RESUME_WAIT:
|
||||
ResumeS.bESOFcnt--;
|
||||
if (ResumeS.bESOFcnt == 0)
|
||||
ResumeS.eState = RESUME_START;
|
||||
break;
|
||||
case RESUME_START:
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_SetRemoteWakeup();
|
||||
#else
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR |= CNTR_RESUME;
|
||||
_SetCNTR(wCNTR);
|
||||
#endif /* STM32F10X_CL */
|
||||
ResumeS.eState = RESUME_ON;
|
||||
ResumeS.bESOFcnt = 10;
|
||||
break;
|
||||
case RESUME_ON:
|
||||
#ifndef STM32F10X_CL
|
||||
ResumeS.bESOFcnt--;
|
||||
if (ResumeS.bESOFcnt == 0)
|
||||
{
|
||||
#endif /* STM32F10X_CL */
|
||||
#ifdef STM32F10X_CL
|
||||
OTGD_FS_ResetRemoteWakeup();
|
||||
#else
|
||||
wCNTR = _GetCNTR();
|
||||
wCNTR &= (~CNTR_RESUME);
|
||||
_SetCNTR(wCNTR);
|
||||
#endif /* STM32F10X_CL */
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
#ifndef STM32F10X_CL
|
||||
}
|
||||
#endif /* STM32F10X_CL */
|
||||
break;
|
||||
case RESUME_OFF:
|
||||
case RESUME_ESOF:
|
||||
default:
|
||||
ResumeS.eState = RESUME_OFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
||||
* @{
|
||||
* @addtogroup PIOS_SYS System Functions
|
||||
* @brief PIOS USB communication code
|
||||
* @{
|
||||
*
|
||||
* @file pios_usb_com.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2009.
|
||||
* @brief USB_COM functions header.
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef PIOS_USB_COM_H
|
||||
#define PIOS_USB_COM_H
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Global definitions
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// number of USB_COM interfaces (0..1)
|
||||
#ifndef PIOS_USB_COM_NUM
|
||||
#define PIOS_USB_COM_NUM 1
|
||||
#endif
|
||||
|
||||
|
||||
// size of IN/OUT pipe
|
||||
#ifndef PIOS_USB_COM_DATA_IN_SIZE
|
||||
#define PIOS_USB_COM_DATA_IN_SIZE 64
|
||||
#endif
|
||||
|
||||
#ifndef PIOS_USB_COM_DATA_OUT_SIZE
|
||||
#define PIOS_USB_COM_DATA_OUT_SIZE 64
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PIOS_USB_COM_INT_IN_SIZE
|
||||
#define PIOS_USB_COM_INT_IN_SIZE 64
|
||||
#endif
|
||||
|
||||
/* Public Functions */
|
||||
extern s32 PIOS_USB_COM_Init(u32 mode);
|
||||
extern s32 PIOS_USB_COM_CheckAvailable(void);
|
||||
extern s32 PIOS_USB_COM_ChangeConnectionState(u8 connected);
|
||||
extern void PIOS_USB_COM_EP4_IN_Callback(void);
|
||||
extern void PIOS_USB_COM_EP3_OUT_Callback(void);
|
||||
extern void PIOS_USB_COM_CB_StatusIn(void);
|
||||
extern s32 PIOS_USB_COM_CB_Data_Setup(u8 RequestNo);
|
||||
extern s32 PIOS_USB_COM_CB_NoData_Setup(u8 RequestNo);
|
||||
extern s32 PIOS_USB_COM_RxBufferFree(u8 usb_com);
|
||||
extern s32 PIOS_USB_COM_RxBufferUsed(u8 usb_com);
|
||||
extern s32 PIOS_USB_COM_RxBufferGet(u8 usb_com);
|
||||
extern s32 PIOS_USB_COM_TxBufferFree(u8 usb_com);
|
||||
extern s32 PIOS_USB_COM_TxBufferUsed(u8 usb_com);
|
||||
extern s32 PIOS_USB_COM_TxBufferPut_NonBlocking(u8 usb_com, u8 b);
|
||||
extern s32 PIOS_USB_COM_TxBufferPut(u8 usb_com, u8 b);
|
||||
extern s32 PIOS_USB_COM_TxBufferPutMore_NonBlocking(u8 usb_com, u8 *buffer, u16 len);
|
||||
extern s32 PIOS_USB_COM_TxBufferPutMore(u8 usb_com, u8 *buffer, u16 len);
|
||||
|
||||
#endif /* PIOS_USB_COM_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
56
flight/PiOS/inc/pios_usb_desc.h
Normal file
56
flight/PiOS/inc/pios_usb_desc.h
Normal file
@ -0,0 +1,56 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_desc.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Descriptor Header for Custom HID Demo
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_DESC_H
|
||||
#define __USB_DESC_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported define -----------------------------------------------------------*/
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
||||
|
||||
#define HID_DESCRIPTOR_TYPE 0x21
|
||||
#define CUSTOMHID_SIZ_HID_DESC 0x09
|
||||
#define CUSTOMHID_OFF_HID_DESC 0x12
|
||||
|
||||
#define CUSTOMHID_SIZ_DEVICE_DESC 18
|
||||
#define CUSTOMHID_SIZ_CONFIG_DESC 41
|
||||
#define CUSTOMHID_SIZ_REPORT_DESC 163
|
||||
#define CUSTOMHID_SIZ_STRING_LANGID 4
|
||||
#define CUSTOMHID_SIZ_STRING_VENDOR 38
|
||||
#define CUSTOMHID_SIZ_STRING_PRODUCT 32
|
||||
#define CUSTOMHID_SIZ_STRING_SERIAL 26
|
||||
|
||||
#define STANDARD_ENDPOINT_DESC_SIZE 0x09
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
extern const uint8_t CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC];
|
||||
extern const uint8_t CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC];
|
||||
extern const uint8_t CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC];
|
||||
extern const uint8_t CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID];
|
||||
extern const uint8_t CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR];
|
||||
extern const uint8_t CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT];
|
||||
extern uint8_t CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL];
|
||||
|
||||
#endif /* __USB_DESC_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
@ -39,6 +39,7 @@
|
||||
#define PIOS_USB_HID_SIZ_HID_DESC 0x09
|
||||
|
||||
#define PIOS_USB_HID_DATA_LENGTH 63
|
||||
//63
|
||||
|
||||
/* Global functions */
|
||||
extern int32_t PIOS_USB_HID_Init(uint32_t mode);
|
||||
|
121
flight/PiOS/inc/pios_usb_istr.h
Normal file
121
flight/PiOS/inc/pios_usb_istr.h
Normal file
@ -0,0 +1,121 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_istr.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : This file includes the peripherals header files in the
|
||||
* user application.
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_ISTR_H
|
||||
#define __USB_ISTR_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "usb_conf.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
void USB_Istr(void);
|
||||
#else /* STM32F10X_CL */
|
||||
u32 STM32_PCD_OTG_ISR_Handler(void);
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
/* function prototypes Automatically built defining related macros */
|
||||
|
||||
void EP1_IN_Callback(void);
|
||||
void EP2_IN_Callback(void);
|
||||
void EP3_IN_Callback(void);
|
||||
void EP4_IN_Callback(void);
|
||||
void EP5_IN_Callback(void);
|
||||
void EP6_IN_Callback(void);
|
||||
void EP7_IN_Callback(void);
|
||||
|
||||
void EP1_OUT_Callback(void);
|
||||
void EP2_OUT_Callback(void);
|
||||
void EP3_OUT_Callback(void);
|
||||
void EP4_OUT_Callback(void);
|
||||
void EP5_OUT_Callback(void);
|
||||
void EP6_OUT_Callback(void);
|
||||
void EP7_OUT_Callback(void);
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
|
||||
#ifdef CTR_CALLBACK
|
||||
void CTR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef DOVR_CALLBACK
|
||||
void DOVR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef ERR_CALLBACK
|
||||
void ERR_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef WKUP_CALLBACK
|
||||
void WKUP_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef SUSP_CALLBACK
|
||||
void SUSP_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef RESET_CALLBACK
|
||||
void RESET_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef SOF_CALLBACK
|
||||
void SOF_Callback(void);
|
||||
#endif
|
||||
|
||||
#ifdef ESOF_CALLBACK
|
||||
void ESOF_Callback(void);
|
||||
#endif
|
||||
|
||||
#else /* STM32F10X_CL */
|
||||
|
||||
/* Interrupt subroutines user callbacks prototypes.
|
||||
These callbacks are called into the respective interrupt sunroutine functinos
|
||||
and can be tailored for various user application purposes.
|
||||
Note: Make sure that the correspondant interrupt is enabled through the
|
||||
definition in usb_conf.h file */
|
||||
void INTR_MODEMISMATCH_Callback(void);
|
||||
void INTR_SOFINTR_Callback(void);
|
||||
void INTR_RXSTSQLVL_Callback(void);
|
||||
void INTR_NPTXFEMPTY_Callback(void);
|
||||
void INTR_GINNAKEFF_Callback(void);
|
||||
void INTR_GOUTNAKEFF_Callback(void);
|
||||
void INTR_ERLYSUSPEND_Callback(void);
|
||||
void INTR_USBSUSPEND_Callback(void);
|
||||
void INTR_USBRESET_Callback(void);
|
||||
void INTR_ENUMDONE_Callback(void);
|
||||
void INTR_ISOOUTDROP_Callback(void);
|
||||
void INTR_EOPFRAME_Callback(void);
|
||||
void INTR_EPMISMATCH_Callback(void);
|
||||
void INTR_INEPINTR_Callback(void);
|
||||
void INTR_OUTEPINTR_Callback(void);
|
||||
void INTR_INCOMPLISOIN_Callback(void);
|
||||
void INTR_INCOMPLISOOUT_Callback(void);
|
||||
void INTR_WKUPINTR_Callback(void);
|
||||
|
||||
/* Isochronous data update */
|
||||
void INTR_RXSTSQLVL_ISODU_Callback(void);
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
|
||||
#endif /*__USB_ISTR_H*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
70
flight/PiOS/inc/pios_usb_prop.h
Normal file
70
flight/PiOS/inc/pios_usb_prop.h
Normal file
@ -0,0 +1,70 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_prop.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : All processings related to Custom HID demo
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_PROP_H
|
||||
#define __USB_PROP_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum _HID_REQUESTS
|
||||
{
|
||||
GET_REPORT = 1,
|
||||
GET_IDLE,
|
||||
GET_PROTOCOL,
|
||||
|
||||
SET_REPORT = 9,
|
||||
SET_IDLE,
|
||||
SET_PROTOCOL
|
||||
} HID_REQUESTS;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void CustomHID_init(void);
|
||||
void CustomHID_Reset(void);
|
||||
void CustomHID_SetConfiguration(void);
|
||||
void CustomHID_SetDeviceAddress (void);
|
||||
void CustomHID_Status_In (void);
|
||||
void CustomHID_Status_Out (void);
|
||||
RESULT CustomHID_Data_Setup(uint8_t);
|
||||
RESULT CustomHID_NoData_Setup(uint8_t);
|
||||
RESULT CustomHID_Get_Interface_Setting(uint8_t Interface, uint8_t AlternateSetting);
|
||||
uint8_t *CustomHID_GetDeviceDescriptor(uint16_t );
|
||||
uint8_t *CustomHID_GetConfigDescriptor(uint16_t);
|
||||
uint8_t *CustomHID_GetStringDescriptor(uint16_t);
|
||||
RESULT CustomHID_SetProtocol(void);
|
||||
uint8_t *CustomHID_GetProtocolValue(uint16_t Length);
|
||||
RESULT CustomHID_SetProtocol(void);
|
||||
uint8_t *CustomHID_GetReportDescriptor(uint16_t Length);
|
||||
uint8_t *CustomHID_GetHIDDescriptor(uint16_t Length);
|
||||
|
||||
|
||||
/* Exported define -----------------------------------------------------------*/
|
||||
#define CustomHID_GetConfiguration NOP_Process
|
||||
//#define CustomHID_SetConfiguration NOP_Process
|
||||
#define CustomHID_GetInterface NOP_Process
|
||||
#define CustomHID_SetInterface NOP_Process
|
||||
#define CustomHID_GetStatus NOP_Process
|
||||
#define CustomHID_ClearFeature NOP_Process
|
||||
#define CustomHID_SetEndPointFeature NOP_Process
|
||||
#define CustomHID_SetDeviceFeature NOP_Process
|
||||
//#define CustomHID_SetDeviceAddress NOP_Process
|
||||
|
||||
#define REPORT_DESCRIPTOR 0x22
|
||||
|
||||
#endif /* __USB_PROP_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
58
flight/PiOS/inc/pios_usb_pwr.h
Normal file
58
flight/PiOS/inc/pios_usb_pwr.h
Normal file
@ -0,0 +1,58 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_pwr.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Connection/disconnection & power management header
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_PWR_H
|
||||
#define __USB_PWR_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
typedef enum _RESUME_STATE
|
||||
{
|
||||
RESUME_EXTERNAL,
|
||||
RESUME_INTERNAL,
|
||||
RESUME_LATER,
|
||||
RESUME_WAIT,
|
||||
RESUME_START,
|
||||
RESUME_ON,
|
||||
RESUME_OFF,
|
||||
RESUME_ESOF
|
||||
} RESUME_STATE;
|
||||
|
||||
typedef enum _DEVICE_STATE
|
||||
{
|
||||
UNCONNECTED,
|
||||
ATTACHED,
|
||||
POWERED,
|
||||
SUSPENDED,
|
||||
ADDRESSED,
|
||||
CONFIGURED
|
||||
} DEVICE_STATE;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
void Suspend(void);
|
||||
void Resume_Init(void);
|
||||
void Resume(RESUME_STATE eResumeSetVal);
|
||||
RESULT PowerOn(void);
|
||||
RESULT PowerOff(void);
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern __IO uint32_t bDeviceState; /* USB device status */
|
||||
extern __IO bool fSuspendEnabled; /* true when suspend is possible */
|
||||
|
||||
#endif /*__USB_PWR_H*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
186
flight/PiOS/inc/usb_conf.h
Normal file
186
flight/PiOS/inc/usb_conf.h
Normal file
@ -0,0 +1,186 @@
|
||||
/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
|
||||
* File Name : usb_conf.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V3.2.1
|
||||
* Date : 07/05/2010
|
||||
* Description : Custom HID demo configuration file
|
||||
********************************************************************************
|
||||
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
||||
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
|
||||
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
|
||||
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*******************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __USB_CONF_H
|
||||
#define __USB_CONF_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* EP_NUM */
|
||||
/* defines how many endpoints are used by the device */
|
||||
/*-------------------------------------------------------------*/
|
||||
#define EP_NUM (2)
|
||||
|
||||
#ifndef STM32F10X_CL
|
||||
/*-------------------------------------------------------------*/
|
||||
/* -------------- Buffer Description Table -----------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* buffer table base address */
|
||||
/* buffer table base address */
|
||||
#define BTABLE_ADDRESS (0x00)
|
||||
|
||||
/* EP0 */
|
||||
/* rx/tx buffer base address */
|
||||
#define ENDP0_RXADDR (0x18)
|
||||
#define ENDP0_TXADDR (0x58)
|
||||
|
||||
/* EP1 */
|
||||
/* tx buffer base address */
|
||||
#define ENDP1_TXADDR (0x100)
|
||||
#define ENDP1_RXADDR (0x104)
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* ------------------- ISTR events -------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* IMR_MSK */
|
||||
/* mask defining which events has to be handled */
|
||||
/* by the device application software */
|
||||
#define IMR_MSK (CNTR_CTRM | CNTR_WKUPM | CNTR_SUSPM | CNTR_ERRM | CNTR_SOFM \
|
||||
| CNTR_ESOFM | CNTR_RESETM )
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
#ifdef STM32F10X_CL
|
||||
|
||||
/*******************************************************************************
|
||||
* FIFO Size Configuration
|
||||
*
|
||||
* (i) Dedicated data FIFO SPRAM of 1.25 Kbytes = 1280 bytes = 320 32-bits words
|
||||
* available for the endpoints IN and OUT.
|
||||
* Device mode features:
|
||||
* -1 bidirectional CTRL EP 0
|
||||
* -3 IN EPs to support any kind of Bulk, Interrupt or Isochronous transfer
|
||||
* -3 OUT EPs to support any kind of Bulk, Interrupt or Isochronous transfer
|
||||
*
|
||||
* ii) Receive data FIFO size = RAM for setup packets +
|
||||
* OUT endpoint control information +
|
||||
* data OUT packets + miscellaneous
|
||||
* Space = ONE 32-bits words
|
||||
* --> RAM for setup packets = 4 * n + 6 space
|
||||
* (n is the nbr of CTRL EPs the device core supports)
|
||||
* --> OUT EP CTRL info = 1 space
|
||||
* (one space for status information written to the FIFO along with each
|
||||
* received packet)
|
||||
* --> data OUT packets = (Largest Packet Size / 4) + 1 spaces
|
||||
* (MINIMUM to receive packets)
|
||||
* --> OR data OUT packets = at least 2*(Largest Packet Size / 4) + 1 spaces
|
||||
* (if high-bandwidth EP is enabled or multiple isochronous EPs)
|
||||
* --> miscellaneous = 1 space per OUT EP
|
||||
* (one space for transfer complete status information also pushed to the
|
||||
* FIFO with each endpoint's last packet)
|
||||
*
|
||||
* (iii)MINIMUM RAM space required for each IN EP Tx FIFO = MAX packet size for
|
||||
* that particular IN EP. More space allocated in the IN EP Tx FIFO results
|
||||
* in a better performance on the USB and can hide latencies on the AHB.
|
||||
*
|
||||
* (iv) TXn min size = 16 words. (n : Transmit FIFO index)
|
||||
* (v) When a TxFIFO is not used, the Configuration should be as follows:
|
||||
* case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
|
||||
* --> Txm can use the space allocated for Txn.
|
||||
* case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
|
||||
* --> Txn should be configured with the minimum space of 16 words
|
||||
* (vi) The FIFO is used optimally when used TxFIFOs are allocated in the top
|
||||
* of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
|
||||
*******************************************************************************/
|
||||
|
||||
#define RX_FIFO_SIZE 128
|
||||
#define TX0_FIFO_SIZE 64
|
||||
#define TX1_FIFO_SIZE 64
|
||||
#define TX2_FIFO_SIZE 16
|
||||
#define TX3_FIFO_SIZE 16
|
||||
|
||||
/* OTGD-FS-DEVICE IP interrupts Enable definitions */
|
||||
/* Uncomment the define to enable the selected interrupt */
|
||||
//#define INTR_MODEMISMATCH
|
||||
#define INTR_SOFINTR
|
||||
#define INTR_RXSTSQLVL /* Mandatory */
|
||||
//#define INTR_NPTXFEMPTY
|
||||
//#define INTR_GINNAKEFF
|
||||
//#define INTR_GOUTNAKEFF
|
||||
//#define INTR_ERLYSUSPEND
|
||||
#define INTR_USBSUSPEND /* Mandatory */
|
||||
#define INTR_USBRESET /* Mandatory */
|
||||
#define INTR_ENUMDONE /* Mandatory */
|
||||
//#define INTR_ISOOUTDROP
|
||||
//#define INTR_EOPFRAME
|
||||
//#define INTR_EPMISMATCH
|
||||
#define INTR_INEPINTR /* Mandatory */
|
||||
#define INTR_OUTEPINTR /* Mandatory */
|
||||
//#define INTR_INCOMPLISOIN
|
||||
//#define INTR_INCOMPLISOOUT
|
||||
#define INTR_WKUPINTR /* Mandatory */
|
||||
|
||||
/* OTGD-FS-DEVICE IP interrupts subroutines */
|
||||
/* Comment the define to enable the selected interrupt subroutine and replace it
|
||||
by user code */
|
||||
#define INTR_MODEMISMATCH_Callback NOP_Process
|
||||
#define INTR_SOFINTR_Callback NOP_Process
|
||||
#define INTR_RXSTSQLVL_Callback NOP_Process
|
||||
#define INTR_NPTXFEMPTY_Callback NOP_Process
|
||||
#define INTR_NPTXFEMPTY_Callback NOP_Process
|
||||
#define INTR_GINNAKEFF_Callback NOP_Process
|
||||
#define INTR_GOUTNAKEFF_Callback NOP_Process
|
||||
#define INTR_ERLYSUSPEND_Callback NOP_Process
|
||||
#define INTR_USBSUSPEND_Callback NOP_Process
|
||||
#define INTR_USBRESET_Callback NOP_Process
|
||||
#define INTR_ENUMDONE_Callback NOP_Process
|
||||
#define INTR_ISOOUTDROP_Callback NOP_Process
|
||||
#define INTR_EOPFRAME_Callback NOP_Process
|
||||
#define INTR_EPMISMATCH_Callback NOP_Process
|
||||
#define INTR_INEPINTR_Callback NOP_Process
|
||||
#define INTR_OUTEPINTR_Callback NOP_Process
|
||||
#define INTR_INCOMPLISOIN_Callback NOP_Process
|
||||
#define INTR_INCOMPLISOOUT_Callback NOP_Process
|
||||
#define INTR_WKUPINTR_Callback NOP_Process
|
||||
|
||||
/* Isochronous data update */
|
||||
#define INTR_RXSTSQLVL_ISODU_Callback NOP_Process
|
||||
|
||||
/* Isochronous transfer parameters */
|
||||
/* Size of a single Isochronous buffer (size of a single transfer) */
|
||||
#define ISOC_BUFFER_SZE 1
|
||||
/* Number of sub-buffers (number of single buffers/transfers), should be even */
|
||||
#define NUM_SUB_BUFFERS 2
|
||||
|
||||
#endif /* STM32F10X_CL */
|
||||
|
||||
|
||||
/* CTR service routines */
|
||||
/* associated to defined endpoints */
|
||||
#define EP1_IN_Callback NOP_Process
|
||||
#define EP2_IN_Callback NOP_Process
|
||||
#define EP3_IN_Callback NOP_Process
|
||||
#define EP4_IN_Callback NOP_Process
|
||||
#define EP5_IN_Callback NOP_Process
|
||||
#define EP6_IN_Callback NOP_Process
|
||||
#define EP7_IN_Callback NOP_Process
|
||||
|
||||
//#define EP1_OUT_Callback NOP_Process
|
||||
#define EP2_OUT_Callback NOP_Process
|
||||
#define EP3_OUT_Callback NOP_Process
|
||||
#define EP4_OUT_Callback NOP_Process
|
||||
#define EP5_OUT_Callback NOP_Process
|
||||
#define EP6_OUT_Callback NOP_Process
|
||||
#define EP7_OUT_Callback NOP_Process
|
||||
|
||||
#endif /*__USB_CONF_H*/
|
||||
|
||||
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -75,7 +75,6 @@
|
||||
#include <pios_ppm.h>
|
||||
#include <pios_pwm.h>
|
||||
#include <pios_spektrum.h>
|
||||
#include <pios_usb.h>
|
||||
#include <pios_usb_hid.h>
|
||||
#include <pios_debug.h>
|
||||
#include <pios_gpio.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user