SN32: Remove unused code and cleanup USB LLD

This commit is contained in:
stdvar 2021-03-01 01:18:11 -05:00 committed by Dimitris Mantzouranis
parent 05d3a4f4d1
commit 4d74459654
11 changed files with 263 additions and 898 deletions

View File

@ -1,6 +1,3 @@
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/usbhw.c
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/usbram.c
PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/usbuser.c
PLATFORMINC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB

View File

@ -26,9 +26,6 @@
#include <string.h>
#include "hal.h"
#include "usbhw.h"
#include "usbuser.h"
#include "usbram.h"
#include "usbdesc.h"
#if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
@ -255,14 +252,13 @@ static void usb_lld_serve_interrupt(USBDriver *usbp)
else if (iwIntFlag & mskBUS_SUSPEND)
{
/* Suspend */
USB_SuspendEvent();
_usb_suspend(usbp);
}
else if(iwIntFlag & mskBUS_RESUME)
{
/* Resume */
USB_ReturntoNormal();
USB_ResumeEvent();
__USB_CLRINSTS(mskBUS_RESUME);
_usb_wakeup(usbp);
}
}
@ -559,7 +555,7 @@ static void usb_lld_serve_interrupt(USBDriver *usbp)
if ((iwIntFlag & mskUSB_SOF) && (SN_USB->INTEN & mskUSB_SOF_IE))
{
/* SOF */
USB_SOFEvent();
__USB_CLRINSTS(mskUSB_SOF);
_usb_isr_invoke_sof_cb(usbp);
}
}
@ -762,7 +758,7 @@ void usb_lld_disable_endpoints(USBDriver *usbp) {
unsigned i;
/* Disabling all endpoints.*/
for (i = 1; i <= USB_ENDOPOINTS_NUMBER; i++) {
for (i = 1; i <= USB_MAX_ENDPOINTS; i++) {
USB_EPnDisable(i);
}
}

View File

@ -33,11 +33,6 @@
/* Driver constants. */
/*===========================================================================*/
/**
* @brief Maximum endpoint address.
*/
#define USB_MAX_ENDPOINTS 4
/**
* @brief Status stage handling method.
*/
@ -373,6 +368,27 @@ struct USBDriver {
/* External declarations. */
/*===========================================================================*/
/* Descriptor related */
/* bmAttributes in Endpoint Descriptor */
#define USB_ENDPOINT_TYPE_MASK 0x03
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
#define USB_ENDPOINT_SYNC_MASK 0x0C
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C
#define USB_ENDPOINT_USAGE_MASK 0x30
#define USB_ENDPOINT_USAGE_DATA 0x00
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20
#define USB_ENDPOINT_USAGE_RESERVED 0x30
/* bEndpointAddress in Endpoint Descriptor */
#define USB_ENDPOINT_DIRECTION_MASK 0x80
#if (PLATFORM_USB_USE_USB1 == TRUE) && !defined(__DOXYGEN__)
extern USBDriver USBD1;
#endif

View File

@ -27,31 +27,32 @@
#ifndef SN32_USB_H
#define SN32_USB_H
// TODO: ENDPOINTS nubmer is chip dependent and needs to be organized better
/**
* @brief Number of the available endpoints.
* @details This value does not include the endpoint 0 which is always present.
*/
#define USB_ENDOPOINTS_NUMBER 4
#define USB_MAX_ENDPOINTS 4
/**
* @brief USB registers block numeric address.
*/
#define SN32_USB_BASE SN_USB_BASE
#define SN32_USB_BASE SN_USB_BASE
/**
* @brief USB RAM numeric address.
*/
#define SN32_USBRAM_BASE SN_USB_BASE + 0x100
#define SN32_USBRAM_BASE SN_USB_BASE + 0x100
/**
* @brief Pointer to the USB registers block.
*/
// #define SN32_USB ((sn32_usb_t *)SN32_USB_BASE)
// #define SN32_USB ((sn32_usb_t *)SN32_USB_BASE)
/**
* @brief Pointer to the USB RAM.
*/
#define SN32_USBRAM ((sn32_usb_pma_t *)SN32_USBRAM_BASE)
#define SN32_USBRAM ((sn32_usb_pma_t *)SN32_USBRAM_BASE)
#endif /* SN32_USB_H */

View File

@ -1,210 +0,0 @@
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbdesc.h
* Purpose: USB Descriptors Definitions
* Version: V1.20
*----------------------------------------------------------------------------*/
#ifndef __USBDESC_H__
#define __USBDESC_H__
/*****************************************************************************
* Description : USB_LIBRARY_TYPE SELECTION
*****************************************************************************/
#define USB_KB_MOUSE_TYPE1 1 // KB+Mouse(EP1 Standard + EP2 Mouse + EP3 hot key)
#define USB_MOUSE_TYPE 2 // Mouse(EP1)
#define USB_KB_MOUSE_TYPE2 3 // KB+Mouse(EP1 Standard + EP2 Mouse/Consumer page)
#define USB_LIBRARY_TYPE USB_KB_MOUSE_TYPE2
/*****************************************************************************
* Description : USB_VID
*****************************************************************************/
#define USB_VID 0x0C45
/*****************************************************************************
* Description : USB_PID
*****************************************************************************/
#if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1)
#define USB_PID 0x7043
#elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE)
#define USB_PID 0x7041
#elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2)
#define USB_PID 0x7044
#endif
/*****************************************************************************
* Description : USB_REV
*****************************************************************************/
#define USB_REV 0x0104
/*****************************************************************************
* Description : USB EPn Buffer Offset Register
*****************************************************************************/
#define EP1_BUFFER_OFFSET_VALUE 0x40
#define EP2_BUFFER_OFFSET_VALUE 0x80
#define EP3_BUFFER_OFFSET_VALUE 0xC0
#define EP4_BUFFER_OFFSET_VALUE 0xE0
/*****************************************************************************
* Description : USB EPn Settings
*****************************************************************************/
#define USB_EP0_PACKET_SIZE 64 // only 8, 64
#define USB_ENDPOINT_NUM 0x7F
#define USB_SETREPORT_SIZE USB_SETUP_PACKET_SIZE/4
/* USB Endpoint Max Packet Size */
#define USB_EP1_PACKET_SIZE 0x40
#define USB_EP2_PACKET_SIZE 0x08
#define USB_EP3_PACKET_SIZE 0x08
#define USB_EP4_PACKET_SIZE 0x08
/* EP1~EP4 Direction define */
#define USB_EP1_DIRECTION 1 // IN = 1; OUT = 0
#define USB_EP2_DIRECTION 1 // IN = 1; OUT = 0
#define USB_EP3_DIRECTION 1 // IN = 1; OUT = 0
#define USB_EP4_DIRECTION 0 // IN = 1; OUT = 0
/* USB Endpoint Direction */
#define USB_DIRECTION_OUT 0
#define USB_DIRECTION_IN 1
/* EP1~EP6 Transfer mode define */
#define USB_INTERRUPT_MODE 0 // INTERRUPT Transfer
#define USB_BULK_MODE 1 // BULK Transfer
#define USB_ISOCHRONOUS_MODE 2 // ISOCHRONOUS Transfer
/* USB Protocol Value */
#define USB_BOOT_PROTOCOL 0
#define USB_REPORT_PROTOCOL 1
#define USB_IDLE_TIME_INITIAL 0x7D // 125*4 = 500ms
/* USB Endpoint Halt Value */
#define USB_EPn_NON_HALT 0x0
#define USB_EPn_HALT 0x1
#define LANG_ID_H 0x09
#define LANG_ID_L 0X04
#define USB_WBVAL(x) ((x) & 0xFF),(((x) >> 8) & 0xFF)
#define USB_DEVICE_DESC_SIZE 0x12//(sizeof(USB_DEVICE_DESCRIPTOR))
#define USB_CONFIGUARTION_DESC_SIZE 0x09//(sizeof(USB_CONFIGURATION_DESCRIPTOR))
#define USB_INTERFACE_DESC_SIZE 0x09//(sizeof(USB_INTERFACE_DESCRIPTOR))
#define USB_ENDPOINT_DESC_SIZE 0x07//(sizeof(USB_ENDPOINT_DESCRIPTOR))
#define USB_HID_DESC_SIZE 0x09//(sizeof(HID_DESCRIPTOR))
/* USB Device Classes */
#define USB_DEVICE_CLASS_RESERVED 0x00
#define USB_DEVICE_CLASS_AUDIO 0x01
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
#define USB_DEVICE_CLASS_MONITOR 0x04
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
#define USB_DEVICE_CLASS_POWER 0x06
#define USB_DEVICE_CLASS_PRINTER 0x07
#define USB_DEVICE_CLASS_STORAGE 0x08
#define USB_DEVICE_CLASS_HUB 0x09
#define USB_DEVICE_CLASS_MISCELLANEOUS 0xEF
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
/* USB Device String Index */
#define USB_DEVICE_STRING_RESERVED 0x00
#define USB_DEVICE_STRING_MANUFACTURER 0x01
#define USB_DEVICE_STRING_PRODUCT 0x02
#define USB_DEVICE_STRING_SERIALNUMBER 0x03
/* bmAttributes in Configuration Descriptor */
#define USB_CONFIG_VALUE 0x01
/* bmAttributes in Configuration Descriptor */
#define USB_CONFIG_POWERED_MASK 0x40
#define USB_CONFIG_BUS_POWERED 0x80
#define USB_CONFIG_SELF_POWERED 0xC0
#define USB_CONFIG_REMOTE_WAKEUP 0x20
/* bMaxPower in Configuration Descriptor */
#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
/* bmAttributes in Endpoint Descriptor */
#define USB_ENDPOINT_TYPE_MASK 0x03
#define USB_ENDPOINT_TYPE_CONTROL 0x00
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
#define USB_ENDPOINT_TYPE_BULK 0x02
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
#define USB_ENDPOINT_SYNC_MASK 0x0C
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C
#define USB_ENDPOINT_USAGE_MASK 0x30
#define USB_ENDPOINT_USAGE_DATA 0x00
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20
#define USB_ENDPOINT_USAGE_RESERVED 0x30
/* bEndpointAddress in Endpoint Descriptor */
#define USB_ENDPOINT_DIRECTION_MASK 0x80
// #define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
// #define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
/* USB String Descriptor Types */
#define USB_STRING_LANGUAGE 0x00
#define USB_STRING_MANUFACTURER 0x01
#define USB_STRING_PRODUCT 0x02
#define USB_STRING_SERIALNUMBER 0x03
#define USB_STRING_CONFIGURATION 0x04
#define USB_STRING_INTERFACE 0x05
#define ENDPOINT_DESCRIPTOR_INDEX (USB_ConfigDescriptor+USB_CONFIGUARTION_DESC_SIZE+USB_INTERFACE_DESC_SIZE+USB_HID_DESC_SIZE)
#define HID_DESCRIPTOR_INDEX0 (USB_ConfigDescriptor+USB_CONFIGUARTION_DESC_SIZE+USB_INTERFACE_DESC_SIZE+((USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE+USB_INTERFACE_DESC_SIZE)*(0x00)))
#define HID_DESCRIPTOR_INDEX1 (USB_ConfigDescriptor+USB_CONFIGUARTION_DESC_SIZE+USB_INTERFACE_DESC_SIZE+((USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE+USB_INTERFACE_DESC_SIZE)*(0x01)))
#define HID_DESCRIPTOR_INDEX2 (USB_ConfigDescriptor+USB_CONFIGUARTION_DESC_SIZE+USB_INTERFACE_DESC_SIZE+((USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE+USB_INTERFACE_DESC_SIZE)*(0x02)))
#define HID_DESCRIPTOR_INDEX3 (USB_ConfigDescriptor+USB_CONFIGUARTION_DESC_SIZE+USB_INTERFACE_DESC_SIZE+((USB_HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE+USB_INTERFACE_DESC_SIZE)*(0x03)))
typedef struct STRUCT_DESCRIPTOR_INFO{
uint8_t wValue_H;
uint8_t wIndex_L;
uint8_t wValue_L;
uint16_t wTable_length;
const uint8_t *pTable_Index;
}STRUCT_DESCRIPTOR_INFO_A;
extern const STRUCT_DESCRIPTOR_INFO_A DesInfo[];
#define USB_GETDESCRIPTOR_MAX 18 //by DesInfo size
#define USB_DES_STRING_MAX 3 //by DesInfo size
#define GET_DESCRIPTOR_ACK 1
#define GET_DESCRIPTOR_STALL 0
//extern struct STRUCT_DESCRIPTOR_INFO;
extern const uint8_t USB_DeviceDescriptor[];
extern const uint8_t USB_ConfigDescriptor[];
extern const uint8_t USB_LanguageStringDescriptor[];
extern const uint8_t USB_ManufacturerStringDescriptor[];
extern const uint8_t USB_ProductStringDescriptor[];
extern const uint8_t USB_SerialNumberStringDescriptor[];
extern const uint8_t HID_ReportDescriptor[];
extern const uint8_t HID_ReportDescriptor2[];
extern const uint8_t HID_ReportDescriptor3[];
extern const uint16_t HID_ReportDescSize;
extern const uint16_t HID_ReportDescSize2;
extern const uint16_t HID_ReportDescSize3;
extern const uint16_t USB_LangStrDescSize;
extern const uint16_t USB_ManufStrDescSize;
extern const uint16_t USB_ProdStrDescSize;
extern const uint16_t USB_SerNumStrDescSize;
extern const uint16_t nUsb_TotalLength;
extern const uint8_t nUsb_NumInterfaces;
#endif /* __USBDESC_H__ */

View File

@ -9,17 +9,18 @@
#include <SN32F240B.h>
#include "SN32F200_Def.h"
#include "usbram.h"
#include "usbhw.h"
#include "usbuser.h"
#include "usbdesc.h"
volatile uint32_t wUSB_EPnOffset[4];
volatile uint32_t wUSB_EPnPacketsize[5];
/*****************************************************************************
* Description :Setting USB for different Power domain
*****************************************************************************/
#define System_Power_Supply System_Work_at_5_0V // only 3.3V, 5V
#define System_Work_at_3_3V 0
#define System_Work_at_5_0V 1
#define System_Work_at_3_3V 0
#define System_Work_at_5_0V 1
/*****************************************************************************
@ -40,8 +41,6 @@ void USB_Init (void)
{
volatile uint32_t *pRam;
uint32_t wTmp;
USB_StandardVar_Init();
//USB_HidVar_Init();
/* Initialize clock and Enable USB PHY. */
SystemInit();
@ -109,118 +108,6 @@ void USB_Init (void)
}
/*****************************************************************************
* Function : USB_EP1AckEvent
* Description : USB Clear EP1 ACK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP1AckEvent (void)
{
__USB_CLRINSTS(mskEP1_ACK);
}
/*****************************************************************************
* Function : USB_EP2AckEvent
* Description : USB Clear EP2 ACK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP2AckEvent (void)
{
__USB_CLRINSTS(mskEP2_ACK);
}
/*****************************************************************************
* Function : USB_EP3AckEvent
* Description : USB Clear EP3 ACK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP3AckEvent (void)
{
__USB_CLRINSTS(mskEP3_ACK);
}
/*****************************************************************************
* Function : USB_EP4AckEvent
* Description : USB Clear EP4 ACK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP4AckEvent (void)
{
__USB_CLRINSTS(mskEP4_ACK);
}
/*****************************************************************************
* Function : USB_EP1NakEvent
* Description : USB Clear EP1 NAK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP1NakEvent (void)
{
__USB_CLRINSTS(mskEP1_NAK);
}
/*****************************************************************************
* Function : USB_EP2NakEvent
* Description : USB Clear EP2 NAK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP2NakEvent (void)
{
__USB_CLRINSTS(mskEP2_NAK);
}
/*****************************************************************************
* Function : USB_EP3NakEvent
* Description : USB Clear EP3 NAK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP3NakEvent (void)
{
__USB_CLRINSTS(mskEP3_NAK);
}
/*****************************************************************************
* Function : USB_EP4NakEvent
* Description : USB Clear EP4 NAK interrupt status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_EP4NakEvent (void)
{
__USB_CLRINSTS(mskEP4_NAK);
}
/*****************************************************************************
* Function : USB_ClrEPnToggle
* Description : USB Clear EP1~EP6 toggle bit to DATA0
@ -400,4 +287,40 @@ void USB_ReturntoNormal (void)
SystemInit();
SystemCoreClockUpdate();
USB_WakeupEvent();
}
}
/*****************************************************************************
* Function : USB_ResetEvent
* Description : recevice USB bus reset to Initial parameter
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_ResetEvent (void)
{
uint32_t wLoop;
__USB_CLRINSTS(0xFFFFFFFF); //** Clear all USB Event status
__USB_SETADDRESS(0); //** Set USB address = 0
USB_EPnStall(USB_EP0); //** Set EP0 enable & INOUTSTALL
for (wLoop=USB_EP1; wLoop<=USB_EP4; wLoop++)
USB_EPnDisable(wLoop); //** Set EP1~EP4 disable & NAK
}
/*****************************************************************************
* Function : USB_WakeupEvent
* Description : Enable USB CLK and PHY
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_WakeupEvent (void)
{
__USB_PHY_ENABLE; //** enable ESD_EN & PHY_EN
__USB_CLRINSTS(mskBUS_WAKEUP); //** Clear BUS_WAKEUP
}

View File

@ -4,220 +4,221 @@
#ifndef __USBHW_H__
#define __USBHW_H__
//** USB Remote Wakeup I/O Define
//** USB Remote Wakeup I/O Port Define, Default P1.5
#define REMOTE_WAKEUP_IO_P0 DISABLE
#define REMOTE_WAKEUP_IO_P1 ENABLE
#define REMOTE_WAKEUP_IO_P2 DISABLE
#define REMOTE_WAKEUP_IO_P3 DISABLE
/* USB Remote Wakeup I/O Define */
/* USB Remote Wakeup I/O Port Define, Default P1.5 */
#define REMOTE_WAKEUP_IO_P0 DISABLE
#define REMOTE_WAKEUP_IO_P1 ENABLE
#define REMOTE_WAKEUP_IO_P2 DISABLE
#define REMOTE_WAKEUP_IO_P3 DISABLE
//** USB Remote Wakeup I/O Bit Define
#define REMOTE_WAKEUP_IO_P0_BIT 0x0000
#define REMOTE_WAKEUP_IO_P1_BIT 0x0020
#define REMOTE_WAKEUP_IO_P2_BIT 0x0000
#define REMOTE_WAKEUP_IO_P3_BIT 0x0000
/* USB Remote Wakeup I/O Bit Define */
#define REMOTE_WAKEUP_IO_P0_BIT 0x0000
#define REMOTE_WAKEUP_IO_P1_BIT 0x0020
#define REMOTE_WAKEUP_IO_P2_BIT 0x0000
#define REMOTE_WAKEUP_IO_P3_BIT 0x0000
//** USB EPn NAK interrupt
#define EP1_NAK_IE DISABLE
#define EP2_NAK_IE DISABLE
#define EP3_NAK_IE DISABLE
#define EP4_NAK_IE DISABLE
/* USB EPn NAK interrupt */
#define EP1_NAK_IE DISABLE
#define EP2_NAK_IE DISABLE
#define EP3_NAK_IE DISABLE
#define EP4_NAK_IE DISABLE
//** USB SOF interrupt
#define SOF_IE DISABLE
/* USB SOF interrupt */
#define SOF_IE DISABLE
/* AHB Clock Enable register <SYS1_AHBCLKEN> */
#define mskP0CLK_EN (0x1<<0)
#define mskP1CLK_EN (0x1<<1)
#define mskP2CLK_EN (0x1<<2)
#define mskP3CLK_EN (0x1<<3)
#define mskUSBCLK_EN (0x1<<4)
#define mskCT16B0CLK_EN (0x1<<6)
#define mskCT16B1CLK_EN (0x1<<7)
#define mskADCCLK_EN (0x1<<11)
#define mskSPI0CLK_EN (0x1<<12)
#define mskUART0CLK_EN (0x1<<16)
#define mskUART1CLK_EN (0x1<<17)
#define mskUART2CLK_EN (0x1<<18)
#define mskI2C0CLK_EN (0x1<<21)
#define mskWDTCLK_EN (0x1<<24)
/* AHB Clock Enable register <SYS1_AHBCLKEN> */
#define mskP0CLK_EN (0x1<<0)
#define mskP1CLK_EN (0x1<<1)
#define mskP2CLK_EN (0x1<<2)
#define mskP3CLK_EN (0x1<<3)
#define mskUSBCLK_EN (0x1<<4)
#define mskCT16B0CLK_EN (0x1<<6)
#define mskCT16B1CLK_EN (0x1<<7)
#define mskADCCLK_EN (0x1<<11)
#define mskSPI0CLK_EN (0x1<<12)
#define mskUART0CLK_EN (0x1<<16)
#define mskUART1CLK_EN (0x1<<17)
#define mskUART2CLK_EN (0x1<<18)
#define mskI2C0CLK_EN (0x1<<21)
#define mskWDTCLK_EN (0x1<<24)
/* USB Interrupt Enable Bit Definitions <USB_INTEN> */
#define mskEP1_NAK_EN (0x1<<0)
#define mskEP2_NAK_EN (0x1<<1)
#define mskEP3_NAK_EN (0x1<<2)
#define mskEP4_NAK_EN (0x1<<3)
#define mskEPnACK_EN (0x1<<4)
/* USB Interrupt Enable Bit Definitions <USB_INTEN> */
#define mskEP1_NAK_EN (0x1<<0)
#define mskEP2_NAK_EN (0x1<<1)
#define mskEP3_NAK_EN (0x1<<2)
#define mskEP4_NAK_EN (0x1<<3)
#define mskEPnACK_EN (0x1<<4)
#define mskBUSWK_IE (0x1<<28)
#define mskUSB_IE (0x1<<29)
#define mskUSB_SOF_IE (0x1<<30)
#define mskBUS_IE (0x1U<<31)
#define mskBUSWK_IE (0x1<<28)
#define mskUSB_IE (0x1<<29)
#define mskUSB_SOF_IE (0x1<<30)
#define mskBUS_IE (0x1U<<31)
/* USB Interrupt Event Status Bit Definitions <USB_INSTS/USB_INSTSC> */
#define mskEP1_NAK (0x1<<0)
#define mskEP2_NAK (0x1<<1)
#define mskEP3_NAK (0x1<<2)
#define mskEP4_NAK (0x1<<3)
#define mskEP1_ACK (0x1<<8)
#define mskEP2_ACK (0x1<<9)
#define mskEP3_ACK (0x1<<10)
#define mskEP4_ACK (0x1<<11)
#define mskERR_TIMEOUT (0x1<<17)
#define mskERR_SETUP (0x1<<18)
#define mskEP0_OUT_STALL (0x1<<19)
#define mskEP0_IN_STALL (0x1<<20)
#define mskEP0_OUT (0x1<<21)
#define mskEP0_IN (0x1<<22)
#define mskEP0_SETUP (0x1<<23)
#define mskEP0_PRESETUP (0x1<<24)
#define mskBUS_WAKEUP (0x1<<25)
#define mskUSB_SOF (0x1<<26)
#define mskBUS_RESUME (0x1<<29)
#define mskBUS_SUSPEND (0x1<<30)
#define mskBUS_RESET (0x1U<<31)
/* USB Interrupt Event Status Bit Definitions <USB_INSTS/USB_INSTSC> */
#define mskEP1_NAK (0x1<<0)
#define mskEP2_NAK (0x1<<1)
#define mskEP3_NAK (0x1<<2)
#define mskEP4_NAK (0x1<<3)
/* USB Device Address Bit Definitions <USB_ADDR> */
#define mskUADDR (0x7F<<0)
#define mskEP1_ACK (0x1<<8)
#define mskEP2_ACK (0x1<<9)
#define mskEP3_ACK (0x1<<10)
#define mskEP4_ACK (0x1<<11)
/* USB Configuration Bit Definitions <USB_CFG> */
#define mskEP1_DIR (0x1<<0)
#define mskEP2_DIR (0x1<<1)
#define mskEP3_DIR (0x1<<2)
#define mskEP4_DIR (0x1<<3)
#define mskDIS_PDEN (0x1<<26)
#define mskESD_EN (0x1<<27)
#define mskSIE_EN (0x1<<28)
#define mskDPPU_EN (0x1<<29)
#define mskPHY_EN (0x1<<30)
#define mskVREG33_EN (0x1U<<31)
#define mskERR_TIMEOUT (0x1<<17)
#define mskERR_SETUP (0x1<<18)
#define mskEP0_OUT_STALL (0x1<<19)
#define mskEP0_IN_STALL (0x1<<20)
#define mskEP0_OUT (0x1<<21)
#define mskEP0_IN (0x1<<22)
#define mskEP0_SETUP (0x1<<23)
#define mskEP0_PRESETUP (0x1<<24)
#define mskBUS_WAKEUP (0x1<<25)
#define mskUSB_SOF (0x1<<26)
#define mskBUS_RESUME (0x1<<29)
#define mskBUS_SUSPEND (0x1<<30)
#define mskBUS_RESET (0x1U<<31)
/* USB Signal Control Bit Definitions <USB_SGCTL> */
#define mskBUS_DRVEN (0x1<<2)
#define mskBUS_DPDN_STATE (0x3<<0)
#define mskBUS_J_STATE (0x2<<0) // D+ = 1, D- = 0
#define mskBUS_K_STATE (0x1<<0) // D+ = 0, D- = 1
#define mskBUS_SE0_STATE (0x0<<0) // D+ = 0, D- = 0
#define mskBUS_SE1_STATE (0x3<<0) // D+ = 1, D- = 1
#define mskBUS_IDLE_STATE mskBUS_J_STATE
/* USB Device Address Bit Definitions <USB_ADDR> */
#define mskUADDR (0x7F<<0)
/* USB Configuration Bit Definitions <USB_EPnCTL> */
#define mskEPn_CNT (0x1FF<<0)
#define mskEP0_OUT_STALL_EN (0x1<<27)
#define mskEP0_IN_STALL_EN (0x1<<28)
#define mskEPn_ENDP_STATE (0x3<<29)
#define mskEPn_ENDP_STATE_ACK (0x1<<29)
#define mskEPn_ENDP_STATE_NAK (0x0<<29)
#define mskEPn_ENDP_STATE_STALL (0x3<<29)
#define mskEPn_ENDP_EN (0x1U<<31)
/* USB Configuration Bit Definitions <USB_CFG> */
#define mskEP1_DIR (0x1<<0)
#define mskEP2_DIR (0x1<<1)
#define mskEP3_DIR (0x1<<2)
#define mskEP4_DIR (0x1<<3)
/* USB Endpoint Data Toggle Bit Definitions <USB_EPTOGGLE> */
#define mskEP1_CLEAR_DATA0 (0x1<<0)
#define mskEP2_CLEAR_DATA0 (0x1<<1)
#define mskEP3_CLEAR_DATA0 (0x1<<2)
#define mskEP4_CLEAR_DATA0 (0x1<<3)
#define mskDIS_PDEN (0x1<<26)
#define mskESD_EN (0x1<<27)
#define mskSIE_EN (0x1<<28)
#define mskDPPU_EN (0x1<<29)
#define mskPHY_EN (0x1<<30)
#define mskVREG33_EN (0x1U<<31)
/* USB Endpoint n Buffer Offset Bit Definitions <USB_EPnBUFOS> */
#define mskEPn_OFFSET (0x1FF<<0)
/* USB Signal Control Bit Definitions <USB_SGCTL> */
#define mskBUS_DRVEN (0x1<<2)
#define mskBUS_DPDN_STATE (0x3<<0)
#define mskBUS_J_STATE (0x2<<0) // D+ = 1, D- = 0
#define mskBUS_K_STATE (0x1<<0) // D+ = 0, D- = 1
#define mskBUS_SE0_STATE (0x0<<0) // D+ = 0, D- = 0
#define mskBUS_SE1_STATE (0x3<<0) // D+ = 1, D- = 1
#define mskBUS_IDLE_STATE mskBUS_J_STATE
/* USB Frame Number Bit Definitions <USB_FRMNO> */
#define mskFRAME_NO (0x7FF<<0)
/* USB Configuration Bit Definitions <USB_EPnCTL> */
#define mskEPn_CNT (0x1FF<<0)
#define mskEP0_OUT_STALL_EN (0x1<<27)
#define mskEP0_IN_STALL_EN (0x1<<28)
#define mskEPn_ENDP_STATE (0x3<<29)
#define mskEPn_ENDP_STATE_ACK (0x1<<29)
#define mskEPn_ENDP_STATE_NAK (0x0<<29)
#define mskEPn_ENDP_STATE_STALL (0x3<<29)
#define mskEPn_ENDP_EN (0x1U<<31)
/* Rx & Tx Packet Length Definitions */
#define PKT_LNGTH_MASK 0x000003FF
/* nUsb_Status Register Definitions */
/* USB Endpoint Data Toggle Bit Definitions <USB_EPTOGGLE> */
#define mskEP1_CLEAR_DATA0 (0x1<<0)
#define mskEP2_CLEAR_DATA0 (0x1<<1)
#define mskEP3_CLEAR_DATA0 (0x1<<2)
#define mskEP4_CLEAR_DATA0 (0x1<<3)
#define mskBUSRESET (0x1<<0)
#define mskBUSSUSPEND (0x1<<1)
#define mskBUSRESUME (0x1<<2)
#define mskREMOTEWAKEUP (0x1<<3)
#define mskSETCONFIGURATION0CMD (0x1<<4)
#define mskSETADDRESS (0x1<<5)
#define mskSETADDRESSCMD (0x1<<6)
#define mskREMOTE_WAKEUP (0x1<<7)
#define mskDEV_FEATURE_CMD (0x1<<8)
#define mskSET_REPORT_FLAG (0x1<<9)
#define mskPROTOCOL_GET_REPORT (0x1<<10)
#define mskPROTOCOL_SET_IDLE (0x1<<11)
#define mskPROTOCOL_ARRIVAL (0x1<<12)
#define mskSET_REPORT_DONE (0x1<<13)
#define mskNOT_8BYTE_ENDDING (0x1<<14)
#define mskSETUP_OUT (0x1<<15)
#define mskSETUP_IN (0x1<<16)
#define mskINITREPEAT (0x1<<17)
#define mskREMOTE_WAKEUP_ACT (0x1<<18)
/* USB Endpoint n Buffer Offset Bit Definitions <USB_EPnBUFOS> */
#define mskEPn_OFFSET (0x1FF<<0)
/* USB Frame Number Bit Definitions <USB_FRMNO> */
#define mskFRAME_NO (0x7FF<<0)
/* Rx & Tx Packet Length Definitions */
#define PKT_LNGTH_MASK 0x000003FF
/* nUsb_Status Register Definitions */
#define mskBUSRESET (0x1<<0)
#define mskBUSSUSPEND (0x1<<1)
#define mskBUSRESUME (0x1<<2)
#define mskREMOTEWAKEUP (0x1<<3)
#define mskSETCONFIGURATION0CMD (0x1<<4)
#define mskSETADDRESS (0x1<<5)
#define mskSETADDRESSCMD (0x1<<6)
#define mskREMOTE_WAKEUP (0x1<<7)
#define mskDEV_FEATURE_CMD (0x1<<8)
#define mskSET_REPORT_FLAG (0x1<<9)
#define mskPROTOCOL_GET_REPORT (0x1<<10)
#define mskPROTOCOL_SET_IDLE (0x1<<11)
#define mskPROTOCOL_ARRIVAL (0x1<<12)
#define mskSET_REPORT_DONE (0x1<<13)
#define mskNOT_8BYTE_ENDDING (0x1<<14)
#define mskSETUP_OUT (0x1<<15)
#define mskSETUP_IN (0x1<<16)
#define mskINITREPEAT (0x1<<17)
#define mskREMOTE_WAKEUP_ACT (0x1<<18)
//ISP KERNEL MODE
#define RETURN_KERNEL_0 0x5AA555AA
#define RETURN_KERNEL_1 0xCC3300FF
//ISP KERNEL MODE
#define RETURN_KERNEL_0 0x5AA555AA
#define RETURN_KERNEL_1 0xCC3300FF
/*********Marco function***************/
//USB device address set
#define __USB_SETADDRESS(addr) (SN_USB->ADDR = addr)
//USB INT status register clear
#define __USB_CLRINSTS(Clrflag) (SN_USB->INSTSC = Clrflag)
//USB EP0_IN token set STALL
#define __USB_EP0INSTALL_EN (SN_USB->EP0CTL |= mskEP0_IN_STALL_EN)
//USB EP0_OUT token set STALL
#define __USB_EP0OUTSTALL_EN (SN_USB->EP0CTL |= mskEP0_OUT_STALL_EN)
//USB bus driver J state
#define __USB_JSTATE_DRIVER (SN_USB->SGCTL = (mskBUS_DRVEN|mskBUS_J_STATE))
//USB bus driver K state
#define __USB_KSTATE_DRIVER (SN_USB->SGCTL = (mskBUS_DRVEN|mskBUS_K_STATE))
//USB PHY set enable
#define __USB_PHY_ENABLE (SN_USB->CFG |= (mskESD_EN|mskPHY_EN))
//USB PHY set Disable
#define __USB_PHY_DISABLE (SN_USB->CFG &= ~(mskESD_EN|mskPHY_EN))
//USB device address set
#define __USB_SETADDRESS(addr) (SN_USB->ADDR = addr)
//USB INT status register clear
#define __USB_CLRINSTS(Clrflag) (SN_USB->INSTSC = Clrflag)
//USB EP0_IN token set STALL
#define __USB_EP0INSTALL_EN (SN_USB->EP0CTL |= mskEP0_IN_STALL_EN)
//USB EP0_OUT token set STALL
#define __USB_EP0OUTSTALL_EN (SN_USB->EP0CTL |= mskEP0_OUT_STALL_EN)
//USB bus driver J state
#define __USB_JSTATE_DRIVER (SN_USB->SGCTL = (mskBUS_DRVEN|mskBUS_J_STATE))
//USB bus driver K state
#define __USB_KSTATE_DRIVER (SN_USB->SGCTL = (mskBUS_DRVEN|mskBUS_K_STATE))
//USB PHY set enable
#define __USB_PHY_ENABLE (SN_USB->CFG |= (mskESD_EN|mskPHY_EN))
//USB PHY set Disable
#define __USB_PHY_DISABLE (SN_USB->CFG &= ~(mskESD_EN|mskPHY_EN))
/***************************************/
/* USB IRQ Functions*/
extern void USB_IRQHandler(void);
extern void USB_SOFEvent(void);
extern void USB_ResetEvent(void);
extern void USB_SuspendEvent(void);
extern void USB_ResumeEvent(void);
extern void USB_WakeupEvent(void);
extern void USB_EP0SetupEvent(void);
extern void USB_EP0InEvent(void);
extern void USB_EP0OutEvent(void);
extern void USB_EP1AckEvent(void);
extern void USB_EP2AckEvent(void);
extern void USB_EP3AckEvent(void);
extern void USB_EP4AckEvent(void);
extern void USB_EP1NakEvent(void);
extern void USB_EP2NakEvent(void);
extern void USB_EP3NakEvent(void);
extern void USB_EP4NakEvent(void);
/* TODO: orgaize better since this is MCU dependent:
* 240b has 1+4 EPs/256 Bytes USB SRAM
* 240 has 1+6 EPs/512 Bytes USB SRAM
* 260 has 1+4 EPs/256 Bytes USB SRAM
* */
// USB EPn Buffer Offset Register
#define EP1_BUFFER_OFFSET_VALUE 0x40
#define EP2_BUFFER_OFFSET_VALUE 0x80
#define EP3_BUFFER_OFFSET_VALUE 0xC0
#define EP4_BUFFER_OFFSET_VALUE 0xE0
/* USB Endpoint Max Packet Size */
#define USB_EP0_PACKET_SIZE 64 // only 8, 64
#define USB_EP1_PACKET_SIZE 0x40
#define USB_EP2_PACKET_SIZE 0x40
#define USB_EP3_PACKET_SIZE 0x20
#define USB_EP4_PACKET_SIZE 0x20
/* USB Endpoint Direction */
#define USB_DIRECTION_OUT 0
#define USB_DIRECTION_IN 1
/* USB Endpoint Address */
#define USB_EP0 0x0
#define USB_EP1 0x1
#define USB_EP2 0x2
#define USB_EP3 0x3
#define USB_EP4 0x4
/* USB IRQ Functions*/
extern void USB_ResetEvent(void);
extern void USB_WakeupEvent(void);
/* USB Hardware Functions */
extern void USB_Init(void);
//extern void USB_ClrInsts(uint32_t wClrflag);
extern void USB_EPnDisable(uint32_t wEPNum);
extern void USB_EPnNak(uint32_t wEPNum);
extern void USB_EPnAck(uint32_t wEPNum, uint8_t bBytecnt);
extern void USB_EPnStall(uint32_t wEPNum);
extern void USB_Init(void);
extern void USB_EPnDisable(uint32_t wEPNum);
extern void USB_EPnNak(uint32_t wEPNum);
extern void USB_EPnAck(uint32_t wEPNum, uint8_t bBytecnt);
extern void USB_EPnStall(uint32_t wEPNum);
extern void USB_Suspend(void);
extern void USB_RemoteWakeUp(void);
extern void USB_DelayJstate(void);
extern void USB_DelayKstate(void);
extern void USB_ClrEPnToggle(uint32_t wEPNum);
extern void USB_EPnBufferOffset(uint32_t wEPNum, uint32_t wAddr);
void USB_ReturntoNormal (void);
void USB_SwitchtoSlow (void);
extern void USB_RemoteWakeUp(void);
extern void USB_DelayJstate(void);
extern void USB_DelayKstate(void);
extern void USB_ClrEPnToggle(uint32_t wEPNum);
extern void USB_EPnBufferOffset(uint32_t wEPNum, uint32_t wAddr);
void USB_ReturntoNormal(void);
extern uint32_t USB_EPnReadByteData(uint32_t wEPNum, uint32_t wByteIndex);
extern uint32_t USB_EPnReadWordData(uint32_t wEPNum, uint32_t wWordIndex);
extern void USB_EPnWriteByteData(uint32_t wEPNum, uint32_t wByteIndex, uint32_t wBytedata);
extern void USB_EPnWriteWordData(uint32_t wEPNum, uint32_t wWordIndex, uint32_t wWorddata);
extern volatile uint32_t wUSB_EPnOffset[];
extern volatile uint32_t wUSB_EPnPacketsize[];
extern void fnUSBINT_ReadFIFO(uint32_t FIFO_Address);
extern void fnUSBINT_WriteFIFO(uint32_t FIFO_Address, uint32_t FIFO_WriteData );
extern void fnUSBMAIN_ReadFIFO(uint32_t FIFO_Address2);
extern void fnUSBMAIN_WriteFIFO(uint32_t FIFO_Address2, uint32_t FIFO_WriteData2 );
#endif /* __USBHW_H__ */

View File

@ -1,28 +0,0 @@
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbram.c
* Purpose: USB Custom User Module
* Version: V1.01
* Date: 2017/07
*------------------------------------------------------------------------------*/
#include <SN32F240B.h>
#include "usbram.h"
/*_____ D E C L A R A T I O N S ____________________________________________*/
/*_____________ USB Variable ____________________________________________*/
volatile uint32_t wUSB_EPnOffset[4];
volatile uint32_t wUSB_EPnPacketsize[5];
volatile uint8_t wUSB_EndpHalt[5];
const uint8_t *pUSB_TableIndex;
volatile uint32_t wUSB_TableLength;
volatile uint8_t wUSB_IfAlternateSet[4];
uint8_t bNDT_Flag;
uint16_t dbNDT_Cnt;
uint32_t wUSB_PreTableLength;
uint16_t mode;
uint32_t cnt;
SUSB_EUME_DATA sUSB_EumeData;

View File

@ -1,57 +0,0 @@
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbuser.h
* Purpose: USB Custom User Definitions
* Version: V1.20
*----------------------------------------------------------------------------*/
#ifndef __USBRAM_H__
#define __USBRAM_H__
typedef struct
{
uint8_t bUSB_bmRequestType;
uint8_t bUSB_bRequest;
uint8_t bUSB_wValueL;
uint8_t bUSB_wValueH;
uint8_t bUSB_wIndexL;
uint8_t bUSB_wIndexH;
uint16_t bUSB_wLength;
volatile uint32_t wUSB_SetConfiguration;
uint8_t bUSB_DeviceAddr;
volatile uint32_t wUSB_Status;
}SUSB_EUME_DATA;
extern SUSB_EUME_DATA sUSB_EumeData;
//extern S_USB_SETUP_DATA S_USB_EP0setupdata;
//USB FIFO Read/Write Data buffer
extern volatile uint32_t wUSBINT_ReadDataBuf;
extern volatile uint32_t wUSBINT_WriteDataBuf;
//USB Main Loop FIFO Read/Write Data buffer
extern volatile uint32_t wUSBMAIN_ReadDataBuf;
extern volatile uint32_t wUSBMAIN_WriteDataBuf;
/*_____ D E C L A R A T I O N S ____________________________________________*/
extern volatile uint32_t wUSB_EPnOffset[];
extern volatile uint32_t wUSB_EPnPacketsize[];
extern volatile uint8_t wUSB_EndpHalt[];
extern const uint8_t *pUSB_TableIndex;
extern volatile uint32_t wUSB_TableLength;
extern volatile uint8_t wUSB_IfAlternateSet[];
extern uint8_t bNDT_Flag;
extern uint16_t dbNDT_Cnt;
extern uint32_t wUSB_PreTableLength;
extern uint16_t mode;
extern uint32_t cnt;
extern uint32_t wUSB_MouseData;
#endif /* __USBRAM_H__ */

View File

@ -1,147 +0,0 @@
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbuser.c
* Purpose: USB Custom User Module
* Version: V1.01
* Date: 2017/07
*------------------------------------------------------------------------------*/
#include <SN32F240B.h>
#include <string.h>
#include "usbhw.h"
#include "usbuser.h"
#include "usbram.h"
#include "usbdesc.h"
/*****************************************************************************
* Function : Goto_Bootloader
* Description : ISP use for user code jump to Bootloader
* Input : None
* Output : None
* Return : None
* Note : NEVER REMOVE!!!!!
*****************************************************************************/
// __asm void Goto_Bootloader(void)
// {
// LDR r0,=0x40060024 //**<2A>IMap to BL
// STR r1,[r0]
// LDR r0, =0x1FFF0301 //** bootloader address = 0x1FFF0300, under Thumb mode usage LSB=1
// BX r0
// }
/*****************************************************************************
* Function : USB_ResetEvent
* Description : recevice USB bus reset to Initial parameter
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_ResetEvent (void)
{
uint32_t wLoop;
__USB_CLRINSTS(0xFFFFFFFF); //** Clear all USB Event status
sUSB_EumeData.wUSB_Status = mskBUSRESET; //** Set BusReset = 1
sUSB_EumeData.wUSB_SetConfiguration = 0; //** Clear Set Configuration
__USB_SETADDRESS(0); //** Set USB address = 0
USB_EPnStall(USB_EP0); //** Set EP0 enable & INOUTSTALL
for (wLoop=USB_EP1; wLoop<=USB_EP4; wLoop++)
USB_EPnDisable(wLoop); //** Set EP1~EP4 disable & NAK
}
/*****************************************************************************
* Function : USB_SuspendEvent
* Description : SET USB_Status = SUSPEND
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_SuspendEvent (void)
{
sUSB_EumeData.wUSB_Status |= mskBUSSUSPEND; //** Set BusSuspend = 1
}
/*****************************************************************************
* Function : USB_ResumeEvent
* Description : SET USB_Status = BUSRESUME
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_ResumeEvent (void)
{
sUSB_EumeData.wUSB_Status |= mskBUSRESUME; //** sUSB_EumeData.wUSB_Status record Bus resume status
__USB_CLRINSTS(mskBUS_RESUME); //** Clear BUS_RESUME
}
/*****************************************************************************
* Function : USB_WakeupEvent
* Description : Enable USB CLK and PHY
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_WakeupEvent (void)
{
__USB_PHY_ENABLE; //** enable ESD_EN & PHY_EN
__USB_CLRINSTS(mskBUS_WAKEUP); //** Clear BUS_WAKEUP
}
/*****************************************************************************
* Function : USB_SOFEvent
* Description : Clear SOF Interrupt Event Status
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_SOFEvent (void)
{
__USB_CLRINSTS(mskUSB_SOF); //** Clear USB_SOF
}
/*****************************************************************************
* Function : USB_StandardVar_Init
* Description : USB Standard Variable initialtion
* Input : None
* Output : None
* Return : None
* Note : None
*****************************************************************************/
void USB_StandardVar_Init(void)
{
uint32_t i;
for(i=0; i<5; i++)
{
wUSB_EndpHalt[i]=0;
}
for(i=0; i<4; i++)
{
wUSB_IfAlternateSet[i]=0;
}
sUSB_EumeData.bUSB_bmRequestType = 0;
sUSB_EumeData.bUSB_bRequest=0;
sUSB_EumeData.bUSB_wValueL=0;
sUSB_EumeData.bUSB_wValueH=0;
sUSB_EumeData.bUSB_wIndexL=0;
sUSB_EumeData.bUSB_wIndexH=0;
sUSB_EumeData.bUSB_wLength=0;
sUSB_EumeData.wUSB_SetConfiguration = 0;
sUSB_EumeData.bUSB_DeviceAddr=0;
sUSB_EumeData.wUSB_Status |= mskINITREPEAT;
}

View File

@ -1,127 +0,0 @@
/*----------------------------------------------------------------------------
* U S B - K e r n e l
*----------------------------------------------------------------------------
* Name: usbuser.h
* Purpose: USB Custom User Definitions
* Version: V1.20
*-----------------------------------------------------------------------------*/
#ifndef __USBUSER_H__
#define __USBUSER_H__
/* USB Endpoint Address */
#define USB_EP0 0x0
#define USB_EP1 0x1
#define USB_EP2 0x2
#define USB_EP3 0x3
#define USB_EP4 0x4
/* USB Interface Address */
#define USB_INTERFACE_0 0x0
#define USB_INTERFACE_1 0x1
#define USB_INTERFACE_2 0x2
#define USB_INTERFACE_3 0x3
#define USB_INTERFACE_4 0x4
#define USB_INTERFACE_5 0x5
/* USB Standard Device Requests */
#define USB_GET_STATUS 0
#define USB_CLEAR_FEATURE 1
#define USB_SET_FEATURE 3
#define USB_SET_ADDRESS 5
#define USB_GET_DESCRIPTOR 6
#define USB_SET_DESCRIPTOR 7
#define USB_GET_CONFIGURATION 8
#define USB_SET_CONFIGURATION 9
#define USB_GET_INTERFACE 10
#define USB_SET_INTERFACE 11
#define USB_SYNCH_FRAME 12
/* bmRequestType.Dir */
#define REQUEST_HOST_TO_DEVICE (0<<7)
#define REQUEST_DEVICE_TO_HOST (1<<7)
#define REQUEST_DIR_MASK (1<<7)
/* bmRequestType.Type */
#define REQUEST_STANDARD (0<<5)
#define REQUEST_CLASS (1<<5)
#define REQUEST_VENDOR (2<<5)
#define REQUEST_RESERVED (3<<5)
#define REQUEST_TYPE_MASK (3<<5)
/* bmRequestType.Recipient */
#define REQUEST_TO_DEVICE 0
#define REQUEST_TO_INTERFACE 1
#define REQUEST_TO_ENDPOINT 2
#define REQUEST_TO_OTHER 3
#define REQUEST_MASK 3
/* USB Standard Request Codes */
#define USB_REQUEST_GET_STATUS 0
#define USB_REQUEST_CLEAR_FEATURE 1
#define USB_REQUEST_SET_FEATURE 3
#define USB_REQUEST_SET_ADDRESS 5
#define USB_REQUEST_GET_DESCRIPTOR 6
#define USB_REQUEST_SET_DESCRIPTOR 7
#define USB_REQUEST_GET_CONFIGURATION 8
#define USB_REQUEST_SET_CONFIGURATION 9
#define USB_REQUEST_GET_INTERFACE 10
#define USB_REQUEST_SET_INTERFACE 11
#define USB_REQUEST_SYNC_FRAME 12
/* USB GET_STATUS Bit Values */
#define USB_GETSTATUS_SELF_POWERED 0x01
#define USB_GETSTATUS_REMOTE_WAKEUP 0x02
#define USB_GETSTATUS_ENDPOINT_STALL 0x01
/* USB Standard Feature selectors */
#define USB_FEATURE_ENDPOINT_STALL 0
#define USB_FEATURE_REMOTE_WAKEUP 1
/* USB Descriptor Types */
#define USB_DEVICE_DESCRIPTOR_TYPE 1
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
#define USB_STRING_DESCRIPTOR_TYPE 3
#define USB_INTERFACE_DESCRIPTOR_TYPE 4
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8
#define USB_OTG_DESCRIPTOR_TYPE 9
#define USB_DEBUG_DESCRIPTOR_TYPE 10
#define USB_INTERFACE_ASSOCIATION_DESCRIPTOR_TYPE 11
/* Wireless USB extension Descriptor Type. */
#define USB_SECURITY_TYPE 12
#define USB_KEY_TYPE 13
#define USB_ENCRIPTION_TYPE 14
#define USB_BOS_TYPE 15
#define USB_DEVICE_CAPABILITY_TYPE 16
#define USB_WIRELESS_ENDPOINT_COMPANION_TYPE 17
extern void USB_StandardRequest(void);
extern void USB_HIDRequest(void);
extern void USB_TableTransmit(void);
extern void USB_StandardVar_Init(void);
extern void USB_GetStatusEvent(void);
extern void USB_ClearFeatureEvent(void);
extern void USB_SetFeatureEvent(void);
extern void USB_SetAddressEvent(void);
extern void USB_GetDescriptorEvent(void);
extern void USB_SetDescriptorEvent(void);
extern void USB_GetConfigurationEvent(void);
extern void USB_SetConfigurationEvent(void);
extern void USB_GetInterfaceEvent(void);
extern void USB_SetInterfaceEvent(void);
extern void USB_SynchFrameEvent(void);
extern void USB_EP0InEvent(void);
extern void USB_EP0OutEvent(void);
extern uint32_t USB_Comb_Bytetoword (uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3);
#endif /* __USBUSER_H__ */