From 0210956fa083523312ba284ba896bb44299b1461 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 23 Nov 2020 01:46:28 -0600 Subject: [PATCH] Sonix SN32 USB cleanup --- os/hal/ports/SN32/LLD/USB/driver.mk | 1 - os/hal/ports/SN32/LLD/USB/hal_usb_lld.c | 19 +- os/hal/ports/SN32/LLD/USB/hid.h | 376 ----------- os/hal/ports/SN32/LLD/USB/hidram.c | 19 - os/hal/ports/SN32/LLD/USB/hidram.h | 30 - os/hal/ports/SN32/LLD/USB/usb.h | 14 - os/hal/ports/SN32/LLD/USB/usbhw.c | 675 +------------------ os/hal/ports/SN32/LLD/USB/usbram.c | 9 - os/hal/ports/SN32/LLD/USB/usbuser.c | 735 +-------------------- os/hal/ports/SN32/SN32F240/hal_lld.c | 2 +- os/hal/ports/SN32/SN32F240/sn32_registry.h | 2 +- os/hal/ports/SN32/SN32F260/hal_lld.c | 2 +- 12 files changed, 14 insertions(+), 1870 deletions(-) delete mode 100644 os/hal/ports/SN32/LLD/USB/hid.h delete mode 100644 os/hal/ports/SN32/LLD/USB/hidram.c delete mode 100644 os/hal/ports/SN32/LLD/USB/hidram.h delete mode 100644 os/hal/ports/SN32/LLD/USB/usb.h diff --git a/os/hal/ports/SN32/LLD/USB/driver.mk b/os/hal/ports/SN32/LLD/USB/driver.mk index 36a40711..437a13d0 100644 --- a/os/hal/ports/SN32/LLD/USB/driver.mk +++ b/os/hal/ports/SN32/LLD/USB/driver.mk @@ -1,5 +1,4 @@ PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c -PLATFORMSRC += $(CHIBIOS_CONTRIB)/os/hal/ports/SN32/LLD/USB/hidram.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 diff --git a/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c b/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c index 4bf67794..3415d7db 100644 --- a/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c +++ b/os/hal/ports/SN32/LLD/USB/hal_usb_lld.c @@ -25,7 +25,6 @@ #include #include #include "hal.h" -#include "usb.h" #include "usbhw.h" #include "usbuser.h" #include "usbram.h" @@ -143,7 +142,7 @@ static void sn32_usb_read_fifo(usbep_t ep, uint8_t *buf, size_t sz, bool intr) { data = SN_USB->RWDATA2; } - + memcpy(buf, &data, chunk); off += chunk; @@ -200,7 +199,7 @@ static void sn32_usb_write_fifo(usbep_t ep, const uint8_t *buf, size_t sz, bool SN_USB->RWSTATUS2 = 0x01; while (SN_USB->RWSTATUS2 & 0x01); } - + off += chunk; buf += chunk; @@ -279,7 +278,7 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) /* IN */ __USB_CLRINSTS(mskEP0_IN); - // The address + // The address if (address) { SN_USB->ADDR = address; address = 0; @@ -304,10 +303,10 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) else { USB_EPnAck(USB_EP0,0); - + _usb_isr_invoke_in_cb(usbp, 0); } - + } else if (iwIntFlag & mskEP0_OUT) { @@ -415,9 +414,9 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) else { USB_EPnNak(ep); - + _usb_isr_invoke_in_cb(usbp, ep); - } + } } } else if (iwIntFlag & (mskEP4_NAK|mskEP3_NAK|mskEP2_NAK|mskEP1_NAK)) @@ -466,7 +465,7 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) _usb_isr_invoke_in_cb(usbp, ep); } - + } ///////////////////////////////////////////////// @@ -828,7 +827,7 @@ void usb_lld_start_in(USBDriver *usbp, usbep_t ep) { _usb_isr_invoke_in_cb(usbp, ep); } - + } /** diff --git a/os/hal/ports/SN32/LLD/USB/hid.h b/os/hal/ports/SN32/LLD/USB/hid.h deleted file mode 100644 index b68933cd..00000000 --- a/os/hal/ports/SN32/LLD/USB/hid.h +++ /dev/null @@ -1,376 +0,0 @@ -/*---------------------------------------------------------------------------- - * U S B - K e r n e l - *---------------------------------------------------------------------------- - * Name: HID.H - * Purpose: USB HID (Human Interface Device) Definitions - * Version: V1.20 - *----------------------------------------------------------------------------*/ - -#ifndef __HID_H__ -#define __HID_H__ - - -/* HID Subclass Codes */ -#define HID_SUBCLASS_NONE 0x00 -#define HID_SUBCLASS_BOOT 0x01 - -/* HID Protocol Codes */ -#define HID_PROTOCOL_NONE 0x00 -#define HID_PROTOCOL_KEYBOARD 0x01 -#define HID_PROTOCOL_MOUSE 0x02 - - -/* HID Descriptor Types */ -#define HID_HID_DESCRIPTOR_TYPE 0x21 -#define HID_REPORT_DESCRIPTOR_TYPE 0x22 -#define HID_PHYSICAL_DESCRIPTOR_TYPE 0x23 - -/* HID Request Types */ -#define HID_REQUEST_SET 0x21 -#define HID_REQUEST_GET 0xA1 - -/* HID Request Codes */ -#define HID_REQUEST_GET_REPORT 0x01 -#define HID_REQUEST_GET_IDLE 0x02 -#define HID_REQUEST_GET_PROTOCOL 0x03 -#define HID_REQUEST_SET_REPORT 0x09 -#define HID_REQUEST_SET_IDLE 0x0A -#define HID_REQUEST_SET_PROTOCOL 0x0B - -/* HID Report Types */ -#define HID_REPORT_INPUT 0x01 -#define HID_REPORT_OUTPUT 0x02 -#define HID_REPORT_FEATURE 0x03 - - -/* Usage Pages */ -#define HID_USAGE_PAGE_UNDEFINED 0x00 -#define HID_USAGE_PAGE_GENERIC 0x01 -#define HID_USAGE_PAGE_SIMULATION 0x02 -#define HID_USAGE_PAGE_VR 0x03 -#define HID_USAGE_PAGE_SPORT 0x04 -#define HID_USAGE_PAGE_GAME 0x05 -#define HID_USAGE_PAGE_DEV_CONTROLS 0x06 -#define HID_USAGE_PAGE_KEYBOARD 0x07 -#define HID_USAGE_PAGE_LED 0x08 -#define HID_USAGE_PAGE_BUTTON 0x09 -#define HID_USAGE_PAGE_ORDINAL 0x0A -#define HID_USAGE_PAGE_TELEPHONY 0x0B -#define HID_USAGE_PAGE_CONSUMER 0x0C -#define HID_USAGE_PAGE_DIGITIZER 0x0D -#define HID_USAGE_PAGE_UNICODE 0x10 -#define HID_USAGE_PAGE_ALPHANUMERIC 0x14 -/* ... */ - - -/* Generic Desktop Page (0x01) */ -#define HID_USAGE_GENERIC_POINTER 0x01 -#define HID_USAGE_GENERIC_MOUSE 0x02 -#define HID_USAGE_GENERIC_JOYSTICK 0x04 -#define HID_USAGE_GENERIC_GAMEPAD 0x05 -#define HID_USAGE_GENERIC_KEYBOARD 0x06 -#define HID_USAGE_GENERIC_KEYPAD 0x07 -#define HID_USAGE_GENERIC_X 0x30 -#define HID_USAGE_GENERIC_Y 0x31 -#define HID_USAGE_GENERIC_Z 0x32 -#define HID_USAGE_GENERIC_RX 0x33 -#define HID_USAGE_GENERIC_RY 0x34 -#define HID_USAGE_GENERIC_RZ 0x35 -#define HID_USAGE_GENERIC_SLIDER 0x36 -#define HID_USAGE_GENERIC_DIAL 0x37 -#define HID_USAGE_GENERIC_WHEEL 0x38 -#define HID_USAGE_GENERIC_HATSWITCH 0x39 -#define HID_USAGE_GENERIC_COUNTED_BUFFER 0x3A -#define HID_USAGE_GENERIC_BYTE_COUNT 0x3B -#define HID_USAGE_GENERIC_MOTION_WAKEUP 0x3C -#define HID_USAGE_GENERIC_VX 0x40 -#define HID_USAGE_GENERIC_VY 0x41 -#define HID_USAGE_GENERIC_VZ 0x42 -#define HID_USAGE_GENERIC_VBRX 0x43 -#define HID_USAGE_GENERIC_VBRY 0x44 -#define HID_USAGE_GENERIC_VBRZ 0x45 -#define HID_USAGE_GENERIC_VNO 0x46 -#define HID_USAGE_GENERIC_SYSTEM_CTL 0x80 -#define HID_USAGE_GENERIC_SYSCTL_POWER 0x81 -#define HID_USAGE_GENERIC_SYSCTL_SLEEP 0x82 -#define HID_USAGE_GENERIC_SYSCTL_WAKE 0x83 -#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU 0x84 -#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU 0x85 -#define HID_USAGE_GENERIC_SYSCTL_APP_MENU 0x86 -#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU 0x87 -#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT 0x88 -#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT 0x89 -#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT 0x8A -#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT 0x8B -#define HID_USAGE_GENERIC_SYSCTL_MENU_UP 0x8C -#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN 0x8D -/* ... */ - -/* Simulation Controls Page (0x02) */ -/* ... */ -#define HID_USAGE_SIMULATION_RUDDER 0xBA -#define HID_USAGE_SIMULATION_THROTTLE 0xBB -/* ... */ - -/* Virtual Reality Controls Page (0x03) */ -/* ... */ - -/* Sport Controls Page (0x04) */ -/* ... */ - -/* Game Controls Page (0x05) */ -/* ... */ - -/* Generic Device Controls Page (0x06) */ -/* ... */ - -/* Keyboard/Keypad Page (0x07) */ -/* nUsb_HidStatus Register Definitions */ -#define mskSET_REPORTFEATURE_FLAG (0x01<<0) -#define mskSET_REPROTFEATURE_ARRIVAL (0x01<<1) -#define mskSET_REPROTFEATURE_DONE (0x01<<2) - -/* Error "keys" */ -#define HID_USAGE_KEYBOARD_NOEVENT 0x00 -#define HID_USAGE_KEYBOARD_ROLLOVER 0x01 -#define HID_USAGE_KEYBOARD_POSTFAIL 0x02 -#define HID_USAGE_KEYBOARD_UNDEFINED 0x03 - -/* Letters */ -#define HID_USAGE_KEYBOARD_aA 0x04 -#define HID_USAGE_KEYBOARD_zZ 0x1D - -/* Numbers */ -#define HID_USAGE_KEYBOARD_ONE 0x1E -#define HID_USAGE_KEYBOARD_ZERO 0x27 - -#define HID_USAGE_KEYBOARD_RETURN 0x28 -#define HID_USAGE_KEYBOARD_ESCAPE 0x29 -#define HID_USAGE_KEYBOARD_DELETE 0x2A - -/* Funtion keys */ -#define HID_USAGE_KEYBOARD_F1 0x3A -#define HID_USAGE_KEYBOARD_F12 0x45 - -#define HID_USAGE_KEYBOARD_PRINT_SCREEN 0x46 -#define HID_USAGE_KEYBOARD_APPLICATION 0x65 - -/* Modifier Keys */ -#define HID_USAGE_KEYBOARD_LCTRL 0xE0 -#define HID_USAGE_KEYBOARD_LSHFT 0xE1 -#define HID_USAGE_KEYBOARD_LALT 0xE2 -#define HID_USAGE_KEYBOARD_LGUI 0xE3 -#define HID_USAGE_KEYBOARD_RCTRL 0xE4 -#define HID_USAGE_KEYBOARD_RSHFT 0xE5 -#define HID_USAGE_KEYBOARD_RALT 0xE6 -#define HID_USAGE_KEYBOARD_RGUI 0xE7 -#define HID_USAGE_KEYBOARD_SCROLL_LOCK 0x47 -#define HID_USAGE_KEYBOARD_NUM_LOCK 0x53 -#define HID_USAGE_KEYBOARD_CAPS_LOCK 0x39 - -/* ... */ - -/* LED Page (0x08) */ -#define HID_USAGE_LED_NUM_LOCK 0x01 -#define HID_USAGE_LED_CAPS_LOCK 0x02 -#define HID_USAGE_LED_SCROLL_LOCK 0x03 -#define HID_USAGE_LED_COMPOSE 0x04 -#define HID_USAGE_LED_KANA 0x05 -#define HID_USAGE_LED_POWER 0x06 -#define HID_USAGE_LED_SHIFT 0x07 -#define HID_USAGE_LED_DO_NOT_DISTURB 0x08 -#define HID_USAGE_LED_MUTE 0x09 -#define HID_USAGE_LED_TONE_ENABLE 0x0A -#define HID_USAGE_LED_HIGH_CUT_FILTER 0x0B -#define HID_USAGE_LED_LOW_CUT_FILTER 0x0C -#define HID_USAGE_LED_EQUALIZER_ENABLE 0x0D -#define HID_USAGE_LED_SOUND_FIELD_ON 0x0E -#define HID_USAGE_LED_SURROUND_FIELD_ON 0x0F -#define HID_USAGE_LED_REPEAT 0x10 -#define HID_USAGE_LED_STEREO 0x11 -#define HID_USAGE_LED_SAMPLING_RATE_DETECT 0x12 -#define HID_USAGE_LED_SPINNING 0x13 -#define HID_USAGE_LED_CAV 0x14 -#define HID_USAGE_LED_CLV 0x15 -#define HID_USAGE_LED_RECORDING_FORMAT_DET 0x16 -#define HID_USAGE_LED_OFF_HOOK 0x17 -#define HID_USAGE_LED_RING 0x18 -#define HID_USAGE_LED_MESSAGE_WAITING 0x19 -#define HID_USAGE_LED_DATA_MODE 0x1A -#define HID_USAGE_LED_BATTERY_OPERATION 0x1B -#define HID_USAGE_LED_BATTERY_OK 0x1C -#define HID_USAGE_LED_BATTERY_LOW 0x1D -#define HID_USAGE_LED_SPEAKER 0x1E -#define HID_USAGE_LED_HEAD_SET 0x1F -#define HID_USAGE_LED_HOLD 0x20 -#define HID_USAGE_LED_MICROPHONE 0x21 -#define HID_USAGE_LED_COVERAGE 0x22 -#define HID_USAGE_LED_NIGHT_MODE 0x23 -#define HID_USAGE_LED_SEND_CALLS 0x24 -#define HID_USAGE_LED_CALL_PICKUP 0x25 -#define HID_USAGE_LED_CONFERENCE 0x26 -#define HID_USAGE_LED_STAND_BY 0x27 -#define HID_USAGE_LED_CAMERA_ON 0x28 -#define HID_USAGE_LED_CAMERA_OFF 0x29 -#define HID_USAGE_LED_ON_LINE 0x2A -#define HID_USAGE_LED_OFF_LINE 0x2B -#define HID_USAGE_LED_BUSY 0x2C -#define HID_USAGE_LED_READY 0x2D -#define HID_USAGE_LED_PAPER_OUT 0x2E -#define HID_USAGE_LED_PAPER_JAM 0x2F -#define HID_USAGE_LED_REMOTE 0x30 -#define HID_USAGE_LED_FORWARD 0x31 -#define HID_USAGE_LED_REVERSE 0x32 -#define HID_USAGE_LED_STOP 0x33 -#define HID_USAGE_LED_REWIND 0x34 -#define HID_USAGE_LED_FAST_FORWARD 0x35 -#define HID_USAGE_LED_PLAY 0x36 -#define HID_USAGE_LED_PAUSE 0x37 -#define HID_USAGE_LED_RECORD 0x38 -#define HID_USAGE_LED_ERROR 0x39 -#define HID_USAGE_LED_SELECTED_INDICATOR 0x3A -#define HID_USAGE_LED_IN_USE_INDICATOR 0x3B -#define HID_USAGE_LED_MULTI_MODE_INDICATOR 0x3C -#define HID_USAGE_LED_INDICATOR_ON 0x3D -#define HID_USAGE_LED_INDICATOR_FLASH 0x3E -#define HID_USAGE_LED_INDICATOR_SLOW_BLINK 0x3F -#define HID_USAGE_LED_INDICATOR_FAST_BLINK 0x40 -#define HID_USAGE_LED_INDICATOR_OFF 0x41 -#define HID_USAGE_LED_FLASH_ON_TIME 0x42 -#define HID_USAGE_LED_SLOW_BLINK_ON_TIME 0x43 -#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME 0x44 -#define HID_USAGE_LED_FAST_BLINK_ON_TIME 0x45 -#define HID_USAGE_LED_FAST_BLINK_OFF_TIME 0x46 -#define HID_USAGE_LED_INDICATOR_COLOR 0x47 -#define HID_USAGE_LED_RED 0x48 -#define HID_USAGE_LED_GREEN 0x49 -#define HID_USAGE_LED_AMBER 0x4A -#define HID_USAGE_LED_GENERIC_INDICATOR 0x4B - -/* Button Page (0x09) */ -/* There is no need to label these usages. */ - -/* Ordinal Page (0x0A) */ -/* There is no need to label these usages. */ - -/* Telephony Device Page (0x0B) */ -#define HID_USAGE_TELEPHONY_PHONE 0x01 -#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE 0x02 -#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS 0x03 -#define HID_USAGE_TELEPHONY_HANDSET 0x04 -#define HID_USAGE_TELEPHONY_HEADSET 0x05 -#define HID_USAGE_TELEPHONY_KEYPAD 0x06 -#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON 0x07 -/* ... */ - -/* Consumer Page (0x0C) */ -#define HID_USAGE_CONSUMER_CONTROL 0x01 -#define HID_USAGE_CONSUMER_PLAY 0xB0 -#define HID_USAGE_CONSUMER_PAUSE 0xB1 -#define HID_USAGE_CONSUMER_SCAN_NEXT_TRACK 0xB5 -#define HID_USAGE_CONSUMER_SCAN_PREVIOUS_TRACK 0xB6 -#define HID_USAGE_CONSUMER_STOP 0xB7 -#define HID_USAGE_CONSUMER_EJECT 0xB8 -#define HID_USAGE_CONSUMER_PLAYPAUSE 0xCD -#define HID_USAGE_CONSUMER_VOLUME 0xE0 -#define HID_USAGE_CONSUMER_MUTE 0xE2 -#define HID_USAGE_CONSUMER_BASS 0xE3 -#define HID_USAGE_CONSUMER_TREBLE 0xE4 -#define HID_USAGE_CONSUMER_BASS_BOOST 0xE5 -#define HID_USAGE_CONSUMER_VOLUME_INC 0xE9 -#define HID_USAGE_CONSUMER_VOLUME_DEC 0xEA -#define HID_USAGE_CONSUMER_BASS_INC 0x152 -#define HID_USAGE_CONSUMER_BASS_DEC 0x153 -#define HID_USAGE_CONSUMER_TREBLE_INC 0x154 -#define HID_USAGE_CONSUMER_TREBLE_DEC 0x155 -#define HID_USAGE_CONSUMER_CONSUMER_CONTROL 0x183 -#define HID_USAGE_CONSUMER_EMAIL 0x18A -#define HID_USAGE_CONSUMER_CALCULATOR 0x192 -#define HID_USAGE_CONSUMER_BROWSER 0x194 -#define HID_USAGE_CONSUMER_OPEN 0x202 -#define HID_USAGE_CONSUMER_CLOSE 0x203 -#define HID_USAGE_CONSUMER_SAVE 0x207 -#define HID_USAGE_CONSUMER_USER 0x218 -#define HID_USAGE_CONSUMER_UNDO 0x21A -#define HID_USAGE_CONSUMER_WWW_SEARCH 0x221 -#define HID_USAGE_CONSUMER_WWW_HOME 0x223 -#define HID_USAGE_CONSUMER_WWW_BACK 0x224 -#define HID_USAGE_CONSUMER_WWW_FORWARD 0x225 -#define HID_USAGE_CONSUMER_WWW_STOP 0x226 -#define HID_USAGE_CONSUMER_WWW_REFRESH 0x227 -#define HID_USAGE_CONSUMER_WWW_BOOKMARKS 0x22A -/* ... */ - -/* and others ... */ - - -/* HID Report Item Macros */ - -/* Main Items */ -#define HID_Input(x) 0x81,x -#define HID_Output(x) 0x91,x -#define HID_Feature(x) 0xB1,x -#define HID_Collection(x) 0xA1,x -#define HID_EndCollection 0xC0 - -/* Data (Input, Output, Feature) */ -#define HID_Data 0<<0 -#define HID_Constant 1<<0 -#define HID_Array 0<<1 -#define HID_Variable 1<<1 -#define HID_Absolute 0<<2 -#define HID_Relative 1<<2 -#define HID_NoWrap 0<<3 -#define HID_Wrap 1<<3 -#define HID_Linear 0<<4 -#define HID_NonLinear 1<<4 -#define HID_PreferredState 0<<5 -#define HID_NoPreferred 1<<5 -#define HID_NoNullPosition 0<<6 -#define HID_NullState 1<<6 -#define HID_NonVolatile 0<<7 -#define HID_Volatile 1<<7 - -/* Collection Data */ -#define HID_Physical 0x00 -#define HID_Application 0x01 -#define HID_Logical 0x02 -#define HID_Report 0x03 -#define HID_NamedArray 0x04 -#define HID_UsageSwitch 0x05 -#define HID_UsageModifier 0x06 - -/* Global Items */ -#define HID_UsagePage(x) 0x05,x -#define HID_UsagePageVendor(x) 0x06,x,0xFF -#define HID_LogicalMin(x) 0x15,x -#define HID_LogicalMinS(x) 0x16,(x&0xFF),((x>>8)&0xFF) -#define HID_LogicalMinL(x) 0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF) -#define HID_LogicalMax(x) 0x25,x -#define HID_LogicalMaxS(x) 0x26,(x&0xFF),((x>>8)&0xFF) -#define HID_LogicalMaxL(x) 0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF) -#define HID_PhysicalMin(x) 0x35,x -#define HID_PhysicalMinS(x) 0x36,(x&0xFF),((x>>8)&0xFF) -#define HID_PhysicalMinL(x) 0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF) -#define HID_PhysicalMax(x) 0x45,x -#define HID_PhysicalMaxS(x) 0x46,(x&0xFF),((x>>8)&0xFF) -#define HID_PhysicalMaxL(x) 0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF) -#define HID_UnitExponent(x) 0x55,x -#define HID_Unit(x) 0x65,x -#define HID_UnitS(x) 0x66,(x&0xFF),((x>>8)&0xFF) -#define HID_UnitL(x) 0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF) -#define HID_ReportSize(x) 0x75,x -#define HID_ReportID(x) 0x85,x -#define HID_ReportCount(x) 0x95,x -#define HID_Push 0xA0 -#define HID_Pop 0xB0 - -/* Local Items */ -#define HID_Usage(x) 0x09,x -#define HID_UsageS(x) 0x0A,(x&0xFF),((x>>8)&0xFF) -#define HID_UsageMin(x) 0x19,x -#define HID_UsageMinS(x) 0x1A,(x&0xFF),((x>>8)&0xFF) -#define HID_UsageMax(x) 0x29,x -#define HID_UsageMaxS(x) 0x2A,(x&0xFF),((x>>8)&0xFF) - -#endif /* __HID_H__ */ diff --git a/os/hal/ports/SN32/LLD/USB/hidram.c b/os/hal/ports/SN32/LLD/USB/hidram.c deleted file mode 100644 index b2c881e5..00000000 --- a/os/hal/ports/SN32/LLD/USB/hidram.c +++ /dev/null @@ -1,19 +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 -#include "hidram.h" - -/*_____ D E C L A R A T I O N S ____________________________________________*/ -/*_____________ USB Variable ____________________________________________*/ - - - -S_HID_DATA sHID_Data; - - diff --git a/os/hal/ports/SN32/LLD/USB/hidram.h b/os/hal/ports/SN32/LLD/USB/hidram.h deleted file mode 100644 index 0050a8c9..00000000 --- a/os/hal/ports/SN32/LLD/USB/hidram.h +++ /dev/null @@ -1,30 +0,0 @@ -/*---------------------------------------------------------------------------- - * U S B - K e r n e l - *---------------------------------------------------------------------------- - * Name: usbuser.h - * Purpose: USB Custom User Definitions - * Version: V1.20 - *---------------------------------------------------------------------------- - *---------------------------------------------------------------------------*/ - -#ifndef __HIDRAM_H__ -#define __HIDRAM_H__ - - -typedef struct -{ - volatile uint8_t wHID_SetRptByte[16]; - volatile uint8_t wHID_IdleTimeIf0ID; - volatile uint8_t wHID_Protocol; - volatile uint8_t wHID_SetReportFeature; - volatile uint32_t wHID_Setreportfeature[16]; - volatile uint32_t wHID_Status; -}S_HID_DATA; - -extern S_HID_DATA sHID_Data; - -/*_____ D E C L A R A T I O N S ____________________________________________*/ - - - -#endif /* __HIDRAM_H__ */ diff --git a/os/hal/ports/SN32/LLD/USB/usb.h b/os/hal/ports/SN32/LLD/USB/usb.h deleted file mode 100644 index 2fae7d5b..00000000 --- a/os/hal/ports/SN32/LLD/USB/usb.h +++ /dev/null @@ -1,14 +0,0 @@ -/*---------------------------------------------------------------------------- - * U S B - K e r n e l - *---------------------------------------------------------------------------- - * Name: usb.h - * Purpose: USB Definitions - * Version: V1.20 - *----------------------------------------------------------------------------*/ - -#ifndef __USB_H__ -#define __USB_H__ - -// #include "..\compiler.h" - -#endif /* __USB_H__ */ diff --git a/os/hal/ports/SN32/LLD/USB/usbhw.c b/os/hal/ports/SN32/LLD/USB/usbhw.c index 990a303e..5196fd4b 100644 --- a/os/hal/ports/SN32/LLD/USB/usbhw.c +++ b/os/hal/ports/SN32/LLD/USB/usbhw.c @@ -8,8 +8,6 @@ *------------------------------------------------------------------------------*/ #include #include "SN32F200_Def.h" -// #include "..\type.h" -// #include "..\Utility\Utility.h" #include "usbram.h" #include "usbhw.h" @@ -111,468 +109,6 @@ void USB_Init (void) } -/***************************************************************************** -* Function : P0_IRQHandler -* Description : P0_IRQHandler -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -#if (REMOTE_WAKEUP_IO_P0) -void P0_IRQHandler (void) -{ - NVIC_ClearPendingIRQ(P0_IRQn); - SN_GPIO0->IC = REMOTE_WAKEUP_IO_P0_BIT; //** Clear wakeup I/O interrupt - sUSB_EumeData.wUSB_Status |= mskREMOTE_WAKEUP_ACT; - NVIC_DisableIRQ(P0_IRQn); -} -#endif - - -/***************************************************************************** -* Function : P1_IRQHandler -* Description : P1_IRQHandler -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -#if (REMOTE_WAKEUP_IO_P1) -void P1_IRQHandler (void) -{ - NVIC_ClearPendingIRQ(P1_IRQn); - SN_GPIO1->IC = REMOTE_WAKEUP_IO_P1_BIT; //** Clear wakeup I/O interrupt - sUSB_EumeData.wUSB_Status |= mskREMOTE_WAKEUP_ACT; - NVIC_DisableIRQ(P1_IRQn); -} -#endif - - -/***************************************************************************** -* Function : P2_IRQHandler -* Description : P2_IRQHandler -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -#if (REMOTE_WAKEUP_IO_P2) -void P2_IRQHandler (void) -{ - NVIC_ClearPendingIRQ(P2_IRQn); - SN_GPIO2->IC = REMOTE_WAKEUP_IO_P2_BIT; //** Clear wakeup I/O interrupt - sUSB_EumeData.wUSB_Status |= mskREMOTE_WAKEUP_ACT; - NVIC_DisableIRQ(P2_IRQn); -} -#endif - - -/***************************************************************************** -* Function : P3_IRQHandler -* Description : P3_IRQHandler -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -#if (REMOTE_WAKEUP_IO_P3) -void P3_IRQHandler (void) -{ - NVIC_ClearPendingIRQ(P3_IRQn); - SN_GPIO3->IC = REMOTE_WAKEUP_IO_P3_BIT; //** Clear wakeup I/O interrupt - sUSB_EumeData.wUSB_Status |= mskREMOTE_WAKEUP_ACT; - NVIC_DisableIRQ(P3_IRQn); -} -#endif - - -/***************************************************************************** -* Function : Remote_Wakeup_Setting -* Description : Setting Remote Wakeup IO -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void Remote_Wakeup_Setting (void) -{ - #if (REMOTE_WAKEUP_IO_P0 == ENABLE) - SN_GPIO0->CFG = 0; //** P0 Input mode Pull up - SN_GPIO0->MODE &= (~REMOTE_WAKEUP_IO_P0_BIT); - UT_MAIN_DelayNx10us(10); - //** set Wakeup I/O edge falling trigger - SN_GPIO0->IS = 0x00; - SN_GPIO0->IEV = REMOTE_WAKEUP_IO_P0_BIT; - SN_GPIO0->IC =0xFFFFFFFF; - //** Enable wakeup I/O interrupt - SN_GPIO0->IE = REMOTE_WAKEUP_IO_P0_BIT; - NVIC_ClearPendingIRQ(P0_IRQn); - NVIC_EnableIRQ(P0_IRQn); - #endif - - #if (REMOTE_WAKEUP_IO_P1 == ENABLE) - SN_GPIO1->CFG = 0; //** P1 Input mode Pull up - SN_GPIO1->MODE &= (~REMOTE_WAKEUP_IO_P1_BIT); - // UT_MAIN_DelayNx10us(10); - // chThdSleepMilliseconds(10); - //** set Wakeup I/O edge falling trigger - SN_GPIO1->IS = 0x00; - SN_GPIO1->IEV = REMOTE_WAKEUP_IO_P1_BIT; - SN_GPIO1->IC =0xFFFFFFFF; - //** Enable wakeup I/O interrupt - SN_GPIO1->IE = REMOTE_WAKEUP_IO_P1_BIT; - NVIC_ClearPendingIRQ(P1_IRQn); - NVIC_EnableIRQ(P1_IRQn); - #endif - - #if (REMOTE_WAKEUP_IO_P2 == ENABLE) - SN_GPIO2->CFG = 0; //** P2 Input mode Pull up - SN_GPIO2->MODE &= (~REMOTE_WAKEUP_IO_P2_BIT); - UT_MAIN_DelayNx10us(10); - //** set Wakeup I/O edge falling trigger - SN_GPIO2->IS = 0x00; - SN_GPIO2->IEV = REMOTE_WAKEUP_IO_P2_BIT; - SN_GPIO2->IC =0xFFFFFFFF; - //** Enable wakeup I/O interrupt - SN_GPIO2->IE = REMOTE_WAKEUP_IO_P2_BIT; - NVIC_ClearPendingIRQ(P2_IRQn); - NVIC_EnableIRQ(P2_IRQn); - #endif - - #if (REMOTE_WAKEUP_IO_P3 == ENABLE) - SN_GPIO3->CFG = 0; //** P3 Input mode Pull up - SN_GPIO3->MODE &= (~REMOTE_WAKEUP_IO_P3_BIT); - UT_MAIN_DelayNx10us(10); - //** set Wakeup I/O edge falling trigger - SN_GPIO3->IS = 0x00; - SN_GPIO3->IEV = REMOTE_WAKEUP_IO_P3_BIT; - SN_GPIO3->IC =0xFFFFFFFF; - //** Enable wakeup I/O interrupt - SN_GPIO3->IE = REMOTE_WAKEUP_IO_P3_BIT; - NVIC_ClearPendingIRQ(P3_IRQn); - NVIC_EnableIRQ(P3_IRQn); - #endif -} - - -/***************************************************************************** -* Function : USB_IRQHandler -* Description : USB Interrupt USB_BUS, USB SOF, USB_IE -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_IRQHandler (void) -{ - uint32_t iwIntFlag; - - //** Get Interrupt Status and clear immediately. - iwIntFlag = SN_USB->INSTS; - SN_USB->INSTSC = 0xFEFBFFFF; //** Don't clear PRESETUP & ERR_SETUP flag - - if(iwIntFlag == 0) - { - //@20160902 add for EMC protection - USB_ReturntoNormal(); - return; - } - - ///////////////////////////////////////////////// - /* Device Status Interrupt (BusReset, Suspend) */ - ///////////////////////////////////////////////// - if (iwIntFlag & (mskBUS_RESET | mskBUS_SUSPEND | mskBUS_RESUME)) - { - if (iwIntFlag & mskBUS_RESET) - { - /* BusReset */ - USB_ReturntoNormal(); - USB_ResetEvent(); - } - else if (iwIntFlag & mskBUS_SUSPEND) - { - /* Suspend */ - USB_SuspendEvent(); - } - else if(iwIntFlag & mskBUS_RESUME) - { - /* Resume */ - USB_ReturntoNormal(); - USB_ResumeEvent(); - } - } - ///////////////////////////////////////////////// - /* Device Status Interrupt (SETUP, IN, OUT) */ - ///////////////////////////////////////////////// - else if (iwIntFlag & (mskEP0_SETUP|mskEP0_IN|mskEP0_OUT|mskEP0_IN_STALL|mskEP0_OUT_STALL)) - { - if (iwIntFlag & mskEP0_SETUP) - { - /* SETUP */ - USB_EP0SetupEvent(); - } - else if (iwIntFlag & mskEP0_IN) - { - /* IN */ - USB_EP0InEvent(); - } - else if (iwIntFlag & mskEP0_OUT) - { - /* OUT */ - USB_EP0OutEvent(); - } - else if (iwIntFlag & (mskEP0_IN_STALL|mskEP0_OUT_STALL)) - { - /* EP0_IN_OUT_STALL */ - SN_USB->INSTSC = (mskEP0_IN_STALL|mskEP0_OUT_STALL); - USB_EPnStall(USB_EP0); - } - } - ///////////////////////////////////////////////// - /* Device Status Interrupt (EPnACK) */ - ///////////////////////////////////////////////// - else if (iwIntFlag & (mskEP4_ACK|mskEP3_ACK|mskEP2_ACK|mskEP1_ACK)) - { - if (iwIntFlag & mskEP1_ACK) - { - /* EP1 ACK */ - USB_EP1AckEvent(); - } - if (iwIntFlag & mskEP2_ACK) - { - /* EP2 ACK */ - USB_EP2AckEvent(); - } - if (iwIntFlag & mskEP3_ACK) - { - /* EP3 ACK */ - USB_EP3AckEvent(); - } - if (iwIntFlag & mskEP4_ACK) - { - /* EP4 ACK */ - USB_EP4AckEvent(); - } - } - - ///////////////////////////////////////////////// - /* Device Status Interrupt (EPnNAK) */ - ///////////////////////////////////////////////// - else if (iwIntFlag & (mskEP4_NAK|mskEP3_NAK|mskEP2_NAK|mskEP1_NAK)) - { - if (iwIntFlag & mskEP1_NAK) - { - /* EP1 NAK */ - USB_EP1NakEvent(); - } - if (iwIntFlag & mskEP2_NAK) - { - /* EP2 NAK */ - USB_EP2NakEvent(); - } - if (iwIntFlag & mskEP3_NAK) - { - /* EP3 NAK */ - USB_EP3NakEvent(); - } - if (iwIntFlag & mskEP4_NAK) - { - /* EP4 NAK */ - USB_EP4NakEvent(); - } - } - - ///////////////////////////////////////////////// - /* Device Status Interrupt (SOF) */ - ///////////////////////////////////////////////// - if ((iwIntFlag & mskUSB_SOF) && (SN_USB->INTEN & mskUSB_SOF_IE)) - { - /* SOF */ - USB_SOFEvent(); - } -} - - -// /***************************************************************************** -// * Function : USB_Suspend -// * Description : USB Suspend state SYS_CLK is runing slow mode. -// * Input : None -// * Output : None -// * Return : None -// * Note : None -// *****************************************************************************/ -// void USB_Suspend (void) -// { -// uint32_t i; - -// #define SuspendMode Sleep -// #define Slow 1 -// #define Sleep 2 - -// #if (SuspendMode == Slow) -// #if (REMOTE_WAKEUP_IO_P0 == ENABLE) -// uint32_t wWakeupStatus0; -// #endif -// #if (REMOTE_WAKEUP_IO_P1 == ENABLE) -// uint32_t wWakeupStatus1; -// #endif -// #if (REMOTE_WAKEUP_IO_P2 == ENABLE) -// uint32_t wWakeupStatus2; -// #endif -// #if (REMOTE_WAKEUP_IO_P3 == ENABLE) -// uint32_t wWakeupStatus3; -// #endif -// #endif - -// //** Clear BusSuspend -// sUSB_EumeData.wUSB_Status &= ~mskBUSSUSPEND; - -// if(bNDT_Flag == 1) // Check NDT status -// { -// return; -// } - -// for(i=0; i < 620000; i++ ) -// { -// SN_WDT->FEED = 0x5AFA55AA; -// if(!(SN_USB->INSTS & mskBUS_SUSPEND)) // double check Suspend flag -// { -// return; -// } -// } - -// //** double check Suspend flag for EMC protect -// if(!(SN_USB->INSTS & mskBUS_SUSPEND)) -// { -// return; -// } - -// //** Disable ESD_EN & PHY_EN -// __USB_PHY_DISABLE; - -// //** If system support remote wakeup, setting Remote wakeup GPIOs -// if (sUSB_EumeData.wUSB_Status & mskREMOTE_WAKEUP) -// { -// //** Sleep mode setting -// #if (SuspendMode == Sleep) -// Remote_Wakeup_Setting(); -// //** Slow mode setting -// #elif (SuspendMode == Slow) -// #if (REMOTE_WAKEUP_IO_P0 == ENABLE) -// SN_GPIO0->CFG = 0; //** P0 Input mode Pull up -// SN_GPIO0->MODE &= (~REMOTE_WAKEUP_IO_P0_BIT); -// UT_MAIN_DelayNx10us(10); -// wWakeupStatus0 = SN_GPIO0->DATA & REMOTE_WAKEUP_IO_P0_BIT; //** Record P0 wakeup pin -// #endif -// #if (REMOTE_WAKEUP_IO_P1 == ENABLE) -// SN_GPIO1->CFG = 0; //** P1 Input mode Pull up -// SN_GPIO1->MODE &= (~REMOTE_WAKEUP_IO_P1_BIT); -// UT_MAIN_DelayNx10us(10); -// wWakeupStatus1 = SN_GPIO1->DATA & REMOTE_WAKEUP_IO_P1_BIT; //** Record P1 wakeup pin -// #endif -// #if (REMOTE_WAKEUP_IO_P2 == ENABLE) -// SN_GPIO2->CFG = 0; //** P2 Input mode Pull up -// SN_GPIO2->MODE &= (~REMOTE_WAKEUP_IO_P2_BIT); -// UT_MAIN_DelayNx10us(10); -// wWakeupStatus2 = SN_GPIO2->DATA & REMOTE_WAKEUP_IO_P2_BIT; //** Record P2 wakeup pin -// #endif -// #if (REMOTE_WAKEUP_IO_P3 == ENABLE) -// SN_GPIO3->CFG = 0; //** P3 Input mode Pull up -// SN_GPIO3->MODE &= (~REMOTE_WAKEUP_IO_P3_BIT); -// UT_MAIN_DelayNx10us(10); -// wWakeupStatus3 = SN_GPIO3->DATA & REMOTE_WAKEUP_IO_P3_BIT; //** Record P3 wakeup pin -// #endif -// #endif -// } - -// //** Delay for waitting IO stable, then go into sleep mode -// // UT_MAIN_DelayNx10us(10); -// // chThdSleepMilliseconds(10); - -// //** System switch into Slow mode(ILRC) -// USB_SwitchtoSlow(); - -// // double check Suspend flag for EMC protect -// if(!(SN_USB->INSTS & mskBUS_SUSPEND)) -// { -// USB_ReturntoNormal(); -// return; -// } - -// #if (SuspendMode == Sleep) -// //** Into Sleep mode, for saving power consumption in suspend (<500uA) -// SN_PMU->CTRL = 0x04; -// __WFI(); - -// //** system wakeup from sleep mode, system clock(ILRC) switch into IHRC -// USB_ReturntoNormal(); -// if ((sUSB_EumeData.wUSB_Status & (mskREMOTE_WAKEUP | mskREMOTE_WAKEUP_ACT)) == (mskREMOTE_WAKEUP | mskREMOTE_WAKEUP_ACT) ) -// { -// sUSB_EumeData.wUSB_Status &= ~mskREMOTE_WAKEUP_ACT; -// if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) -// { -// USB_RemoteWakeUp(); -// return; -// } -// } -// #elif (SuspendMode == Slow) -// //** ILRC mode -// while (SN_USB->INSTS & mskBUS_SUSPEND) -// { -// if (sUSB_EumeData.wUSB_Status & mskREMOTE_WAKEUP) -// { -// #if (REMOTE_WAKEUP_IO_P0 == ENABLE) -// if ((SN_GPIO0->DATA & REMOTE_WAKEUP_IO_P0_BIT) != wWakeupStatus0) -// { -// if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) -// { -// USB_ReturntoNormal(); -// USB_RemoteWakeUp(); -// return; -// } -// } -// #endif -// #if (REMOTE_WAKEUP_IO_P1 == ENABLE) -// if ((SN_GPIO1->DATA & REMOTE_WAKEUP_IO_P1_BIT) != wWakeupStatus1) -// { -// if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) -// { -// USB_ReturntoNormal(); -// USB_RemoteWakeUp(); -// return; -// } -// } -// #endif -// #if (REMOTE_WAKEUP_IO_P2 == ENABLE) -// if ((SN_GPIO2->DATA & REMOTE_WAKEUP_IO_P2_BIT) != wWakeupStatus2) -// { -// if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) -// { -// USB_ReturntoNormal(); -// USB_RemoteWakeUp(); -// return; -// } -// } -// #endif -// #if (REMOTE_WAKEUP_IO_P3 == ENABLE) -// if ((SN_GPIO3->DATA & REMOTE_WAKEUP_IO_P3_BIT) != wWakeupStatus3) -// { -// if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) -// { -// USB_ReturntoNormal(); -// USB_RemoteWakeUp(); -// return; -// } -// } -// #endif -// } -// } -// #endif -// USB_ReturntoNormal(); -// } - - /***************************************************************************** * Function : USB_EP1AckEvent * Description : USB Clear EP1 ACK interrupt status @@ -849,170 +385,6 @@ void USB_EPnBufferOffset(uint32_t wEPNum, uint32_t wAddr) } -/***************************************************************************** -* Function : USB_EPnReadByteData -* Description : EP1~EP4 Read RAM data by Bytes -* Input : wEPNum: EP1~EP4 -* wByteIndex: Read Bytes count 0~63 -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -uint32_t USB_EPnReadByteData(uint32_t wEPNum, uint32_t wByteIndex) -{ - uint32_t i, wVal; - if (wByteIndex < 64) //** 0~63 Byte index - { - i = wUSB_EPnOffset[wEPNum-1] + (wByteIndex>>2); - fnUSBMAIN_ReadFIFO(i); - wVal = ((wUSBMAIN_ReadDataBuf)>>((wByteIndex&0x3)<<3))&0xFF; - return(wVal); - } - return 0; -} - - -/***************************************************************************** -* Function : USB_EPnReadWordData -* Description : EP1~EP4 Read RAM data by Words -* Input : wEPNum: EP1~EP4 -* wWordIndex: Read Words count 0~15 -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -uint32_t USB_EPnReadWordData(uint32_t wEPNum, uint32_t wWordIndex) -{ - uint32_t i, wVal; - if (wWordIndex < 16) //** 0~15 Word index - { - i = wUSB_EPnOffset[wEPNum-1] + (wWordIndex<<2); - fnUSBMAIN_ReadFIFO(i); - wVal = wUSBMAIN_ReadDataBuf; - return (wVal); - } - return 0; -} - - -/***************************************************************************** -* Function : USB_EPnWriteByteData -* Description : EP1~EP4 Write RAM data by Bytes -* Input : wEPNum: EP1~EP4 -* wByteindex: Write Bytes count 0~63 -* wBytedata: Write Data by Bytes -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_EPnWriteByteData(uint32_t wEPNum, uint32_t wByteIndex, uint32_t wBytedata) -{ - uint32_t i, wVal; - if (wByteIndex < 64) //** 0~63 Byte index - { - i = wUSB_EPnOffset[wEPNum-1] + (wByteIndex>>2); - //** Read from USB FIFO - fnUSBMAIN_ReadFIFO(i); - //** copy FIFO word data - wVal = wUSBMAIN_ReadDataBuf; - //** clear the byte data and rewrite - wVal &= ~(0xFF<<((wByteIndex&0x3)<<3)); //** (wByteindex%4)*8 - wVal |= (wBytedata<<((wByteIndex&0x3)<<3)); - //** write new data into USB FIFO - fnUSBMAIN_WriteFIFO(i, wVal); - } -} - - -/***************************************************************************** -* Function : USB_EPnWriteWordData -* Description : EP1~EP4 Write RAM data by Words -* Input : wEPNum: EP1~EP4 -* wByteindex: Write Words count 0~15 -* wBytedata: Write Data by Words -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_EPnWriteWordData(uint32_t wEPNum, uint32_t wWordIndex, uint32_t wWorddata) -{ - uint32_t i; - if (wWordIndex < 16) //** 0~15 Word index - { - i = wUSB_EPnOffset[wEPNum-1] + (wWordIndex<<2); - fnUSBMAIN_WriteFIFO(i, wWorddata); - } -} - - -/***************************************************************************** -* Function : fnUSBINT_ReadFIFO -* Description : -* Input : FIFO_Address -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void fnUSBINT_ReadFIFO(uint32_t FIFO_Address) -{ - SN_USB->RWADDR = FIFO_Address; - SN_USB->RWSTATUS = 0x02; - while (SN_USB->RWSTATUS &0x02); - wUSBINT_ReadDataBuf = SN_USB->RWDATA; -} - - -/***************************************************************************** -* Function : fnUSBINT_WriteFIFO -* Description : -* Input : FIFO_Address, FIFO_WriteData -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void fnUSBINT_WriteFIFO(uint32_t FIFO_Address, uint32_t FIFO_WriteData) -{ - SN_USB->RWADDR = FIFO_Address; - SN_USB->RWDATA = FIFO_WriteData; - SN_USB->RWSTATUS = 0x01; - while (SN_USB->RWSTATUS &0x01); -} - - -/***************************************************************************** -* Function : fnUSBMAIN_ReadFIFO -* Description : -* Input : FIFO_Address2 -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void fnUSBMAIN_ReadFIFO(uint32_t FIFO_Address2) -{ - SN_USB->RWADDR2 = FIFO_Address2; - SN_USB->RWSTATUS2 = 0x02; - while (SN_USB->RWSTATUS2 &0x02); - wUSBMAIN_ReadDataBuf = SN_USB->RWDATA2; -} - - -/***************************************************************************** -* Function : fnUSBMAIN_WriteFIFO -* Description : -* Input : FIFO_Address2, FIFO_WriteData2 -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void fnUSBMAIN_WriteFIFO(uint32_t FIFO_Address2, uint32_t FIFO_WriteData2) -{ - SN_USB->RWADDR2 = FIFO_Address2; - SN_USB->RWDATA2 = FIFO_WriteData2; - SN_USB->RWSTATUS2 = 0x01; - while (SN_USB->RWSTATUS2 &0x01); -} - - /***************************************************************************** * Function : USB_ReturntoNormal * Description : Enable USB IHRC and switch system into IHRC @@ -1028,49 +400,4 @@ void USB_ReturntoNormal (void) SystemInit(); SystemCoreClockUpdate(); USB_WakeupEvent(); -} - - -// /***************************************************************************** -// * Function : USB_SwitchtoSlow -// * Description : System switch into ILRC, and wait for stable -// * Input : None -// * Output : None -// * Return : None -// * Note : None -// *****************************************************************************/ -// void USB_SwitchtoSlow (void) -// { -// SN_USB->INTEN = 0; - -// //** switch ILRC -// SN_SYS0->CLKCFG = 0x01; -// //** check ILRC status -// while((SN_SYS0->CLKCFG & 0x10) != 0x10); -// //** switch SYSCLK / 4 DO NOT set SYSCLK / 1 or SYSCLK / 2!!!! -// SN_SYS0->AHBCP = 2; -// #if (SuspendMode == Slow) -// //** Setting Flash mode to slow mode -// SN_FLASH->LPCTRL = 0x5AFA0002; -// #endif -// //** disable IHRC -// SN_SYS0->ANBCTRL = 0; - -// SN_USB->INTEN = (mskBUS_IE|mskUSB_IE|mskEPnACK_EN|mskBUSWK_IE); -// #if (EP1_NAK_IE == ENABLE) -// SN_USB->INTEN |= mskEP1_NAK_EN; -// #endif -// #if (EP2_NAK_IE == ENABLE) -// SN_USB->INTEN |= mskEP2_NAK_EN; -// #endif -// #if (EP3_NAK_IE == ENABLE) -// SN_USB->INTEN |= mskEP3_NAK_EN; -// #endif -// #if (EP4_NAK_IE == ENABLE) -// SN_USB->INTEN |= mskEP4_NAK_EN; -// #endif -// #if (SOF_IE == ENABLE) -// SN_USB->INTEN |= mskUSB_SOF_IE; -// #endif -// } - +} \ No newline at end of file diff --git a/os/hal/ports/SN32/LLD/USB/usbram.c b/os/hal/ports/SN32/LLD/USB/usbram.c index 83d42150..b56dbe69 100644 --- a/os/hal/ports/SN32/LLD/USB/usbram.c +++ b/os/hal/ports/SN32/LLD/USB/usbram.c @@ -23,15 +23,6 @@ uint32_t wUSB_PreTableLength; uint16_t mode; uint32_t cnt; -uint32_t wUSB_MouseData; -//USB Interrupt FIFO Read/Write Data buffer -volatile uint32_t wUSBINT_ReadDataBuf; -volatile uint32_t wUSBINT_WriteDataBuf; - -//USB Main Loop FIFO Read/Write Data buffer -volatile uint32_t wUSBMAIN_ReadDataBuf; -volatile uint32_t wUSBMAIN_WriteDataBuf; - SUSB_EUME_DATA sUSB_EumeData; diff --git a/os/hal/ports/SN32/LLD/USB/usbuser.c b/os/hal/ports/SN32/LLD/USB/usbuser.c index 297f9619..7319b9b1 100644 --- a/os/hal/ports/SN32/LLD/USB/usbuser.c +++ b/os/hal/ports/SN32/LLD/USB/usbuser.c @@ -7,16 +7,12 @@ * Date: 2017/07 *------------------------------------------------------------------------------*/ #include -// #include "..\type.h" -// #include "..\Utility\Utility.h" -#include +#include #include "usbhw.h" #include "usbuser.h" #include "usbram.h" #include "usbdesc.h" -#include "hid.h" -#include "hidram.h" /***************************************************************************** @@ -117,719 +113,6 @@ void USB_SOFEvent (void) } -/***************************************************************************** -* Function : USB_EP0SetupEvent -* Description : 1. Clear SETUP Interrupt event status. -* 2. Save SETUP CMD to parameter. -* 3. Determine SETUP is Standard or HID request. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_EP0SetupEvent (void) -{ - volatile uint32_t USB_SRAM_EP0_W0, USB_SRAM_EP0_W1; - uint32_t wCmd; - - //** Clear ENDP0_SETUP & ENDP0_PRESETUP = 0 - __USB_CLRINSTS((mskEP0_SETUP|mskEP0_PRESETUP|mskEP0_OUT_STALL|mskEP0_IN_STALL)); - //** keep EP0 NAK - USB_EPnNak(USB_EP0); - - if (!(SN_USB->INSTS & mskERR_SETUP)) - { - sUSB_EumeData.wUSB_Status &= ~(mskSETUP_IN | mskSETUP_OUT); //** Clear Setup_IN & Setup_OUT = 0 - /*save SETUP cmd data*/ - fnUSBINT_ReadFIFO(0x00); - USB_SRAM_EP0_W0 = wUSBINT_ReadDataBuf; - fnUSBINT_ReadFIFO(0x04); - USB_SRAM_EP0_W1 = wUSBINT_ReadDataBuf; - - //** save EP0 SETUP DATA to sUSB_EumeData - sUSB_EumeData.bUSB_bmRequestType = (USB_SRAM_EP0_W0& 0x000000FF); - sUSB_EumeData.bUSB_bRequest = (USB_SRAM_EP0_W0& 0x0000FF00)>>8; - sUSB_EumeData.bUSB_wValueL = (USB_SRAM_EP0_W0& 0x00FF0000)>>16; - sUSB_EumeData.bUSB_wValueH = (USB_SRAM_EP0_W0& 0xFF000000)>>24; - sUSB_EumeData.bUSB_wIndexL = (USB_SRAM_EP0_W1& 0x000000FF); - sUSB_EumeData.bUSB_wIndexH = (USB_SRAM_EP0_W1& 0x0000FF00)>>8; - sUSB_EumeData.bUSB_wLength = (USB_SRAM_EP0_W1& 0xFFFF0000)>>16; - - //** Check the CMD request type - wCmd = (sUSB_EumeData.bUSB_bmRequestType) & REQUEST_TYPE_MASK; - if (wCmd == REQUEST_STANDARD) - { - USB_StandardRequest(); - return; - } - else if ( wCmd == REQUEST_CLASS) - { - USB_HIDRequest(); - return; - } - } - else - __USB_CLRINSTS(mskERR_SETUP); //** Clear ERR_SETUP - USB_EPnStall(USB_EP0); //** EP0 SETUP token Wrong or SETUP Cmd Wrong -} - - -/***************************************************************************** -* Function : USB_EP0InEvent -* Description : 1. check set reprot feature cmd. -* 2. check set address cmd. -* 3. return IN token data. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_EP0InEvent(void) -{ - uint32_t i; - __USB_CLRINSTS(mskEP0_IN); //** Clear ENDP0_IN = 0 - if(sHID_Data.wHID_SetReportFeature == mskSET_REPROTFEATURE_ARRIVAL) - { - //** The IN token of set report feature command END. - sHID_Data.wHID_SetReportFeature = 0x00; - if( (sHID_Data.wHID_Setreportfeature[0] == RETURN_KERNEL_0) &&(sHID_Data.wHID_Setreportfeature[1] == RETURN_KERNEL_1)) - { - //** check ISP password - //** Clear USB FIFO - for(i=0; i<64 ; i++) - { - fnUSBINT_WriteFIFO(i<<2 , 0); - } - // Goto_Bootloader(); //** go to bootloader - } - sHID_Data.wHID_SetReportFeature = mskSET_REPROTFEATURE_DONE; - } - - if (sUSB_EumeData.wUSB_Status & mskSETADDRESSCMD) - { - //** The IN token of set address command END. - sUSB_EumeData.wUSB_Status &= ~mskSETADDRESSCMD; //** Clear SetAddressCmd = 0 - __USB_SETADDRESS(sUSB_EumeData.bUSB_DeviceAddr); - USB_EPnStall(USB_EP0); - sUSB_EumeData.wUSB_Status &= ~mskSETUP_IN; //** Clear Setup_IN = 0 - return; - } - else - { - //** The IN toekn of device return IN toekn data - if ((sUSB_EumeData.bUSB_wLength != 0) && ((sUSB_EumeData.wUSB_Status & mskSETUP_IN) == 0))// Check Setup_IN == 0 - { - USB_TableTransmit(); - sUSB_EumeData.wUSB_Status &= ~mskSETUP_IN; //** Clear Setup_IN = 0 - return; - } - } - USB_EPnStall(USB_EP0); //** EP0 STALL -} - - -/***************************************************************************** -* Function : USB_EP0OutEvent -* Description : 1. set report Feature data. -* 2. set report Output cmd data. -* 3. OUT toekn return ACK or STALL -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_EP0OutEvent(void) -{ - uint32_t i; - - __USB_CLRINSTS(mskEP0_OUT); //** Clear ENDP0_OUT = 0 - - if(sHID_Data.wHID_SetReportFeature == mskSET_REPORTFEATURE_FLAG) //** Check Set_report_feature == 1 - { - //** Read only the first 8 byte data to check whether matach RETURN_KERNEL pattern - for(i=0; i<16 ; i++) - { - fnUSBINT_ReadFIFO(i<<2); - sHID_Data.wHID_Setreportfeature[i] = wUSBINT_ReadDataBuf; - } - sHID_Data.wHID_SetReportFeature = mskSET_REPROTFEATURE_ARRIVAL; - - } - else if (sHID_Data.wHID_Status & mskSET_REPORT_FLAG) //** Check Set_report_flag == 1 - { - sHID_Data.wHID_Status &= ~mskSET_REPORT_FLAG; //** Clear Set_report_flag = 0 - fnUSBINT_ReadFIFO(0x00); - sHID_Data.wHID_SetRptByte[0] = wUSBINT_ReadDataBuf; //** save data - sHID_Data.wHID_Status |= mskSET_REPORT_DONE; //** Ser Set_report_done = 1 - } - if (!(sUSB_EumeData.wUSB_Status & mskSETUP_OUT)) //** Check Setup_OUT == 0 - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - else - { - if (!(SN_USB->INSTS & mskEP0_PRESETUP)) - __USB_EP0OUTSTALL_EN; //** OUT token return STALL - } - sUSB_EumeData.wUSB_Status &= ~mskSETUP_OUT; //** Clear Setup_OUT = 0 -} - - -/***************************************************************************** -* Function : USB_StandardRequest -* Description : sUSB_EumeData.bUSB_bRequest of SETUP request type. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_StandardRequest(void) -{ - switch(sUSB_EumeData.bUSB_bRequest) - { - case USB_GET_STATUS: //** 0 - { - USB_GetStatusEvent(); - break; - } - case USB_CLEAR_FEATURE: //** 1 - { - USB_ClearFeatureEvent(); - break; - } - case USB_SET_FEATURE: //** 3 - { - USB_SetFeatureEvent(); - break; - } - case USB_SET_ADDRESS: //** 5 - { - USB_SetAddressEvent(); - break; - } - case USB_GET_DESCRIPTOR: //** 6 - { - USB_GetDescriptorEvent(); - break; - } - case USB_SET_DESCRIPTOR: //** 7 - { - USB_SetDescriptorEvent(); - break; - } - case USB_GET_CONFIGURATION: //** 8 - { - USB_GetConfigurationEvent(); - break; - } - case USB_SET_CONFIGURATION: //** 9 - { - USB_SetConfigurationEvent(); - break; - } - case USB_GET_INTERFACE: //** 10 - { - USB_GetInterfaceEvent(); - break; - } - case USB_SET_INTERFACE: //** 11 - { - USB_SetInterfaceEvent(); - break; - } - default: //** others - { - USB_EPnStall(USB_EP0); - break; - } - } -} - - -/***************************************************************************** -* Function : USB_GetStatusEvent -* Description : return Remote_Wakeup and EPn Halt status. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_GetStatusEvent(void) -{ - uint32_t wCmdtype = sUSB_EumeData.bUSB_bmRequestType & USB_ENDPOINT_NUM; - uint32_t wEPNum, i; - - if ((sUSB_EumeData.bUSB_bmRequestType & REQUEST_DIR_MASK) != REQUEST_DEVICE_TO_HOST) - USB_EPnStall(0); //** EP0 STALL - - if (wCmdtype == REQUEST_TO_DEVICE) //** Device - { - if (sUSB_EumeData.wUSB_Status & mskREMOTE_WAKEUP) //** Remote Wakeup enable - fnUSBINT_WriteFIFO(0x00, USB_GETSTATUS_REMOTE_WAKEUP ); - else { //** Remote Wakeup disable - fnUSBINT_WriteFIFO(0x00, 0); - sUSB_EumeData.wUSB_Status |= mskSETUP_OUT; //** Set Setup_OUT = 1 - USB_EPnAck(USB_EP0,2); //** EP0 ACK 2 byte - return; - } - } - else if (wCmdtype == REQUEST_TO_INTERFACE) //** Interface - { - if ((sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) && (sUSB_EumeData.bUSB_wIndexH == 0)) - { - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_3) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_1) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_2) - #endif - { - fnUSBINT_WriteFIFO(0x00, 0); - sUSB_EumeData.wUSB_Status |= mskSETUP_OUT; //** Set Setup_OUT = 1 - USB_EPnAck(USB_EP0,2); //** EP0 ACK 2 byte - return; - } - } - } - else if (wCmdtype == REQUEST_TO_ENDPOINT) //** Endpoint - { - wEPNum = sUSB_EumeData.bUSB_wIndexL & USB_ENDPOINT_NUM; - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - if (wEPNum <= USB_EP4) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - if ((wEPNum == USB_EP1)||(wEPNum == USB_EP4)) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - if ((wEPNum <= USB_EP2)||(wEPNum == USB_EP4)) - #endif - { - i = *(&wUSB_EndpHalt[0] + wEPNum); - fnUSBINT_WriteFIFO(0x00, i); - - sUSB_EumeData.wUSB_Status |= mskSETUP_OUT; //** Setup_OUT = 1 - USB_EPnAck(USB_EP0,2); //** EP0 ACK 2 byte - return; - } - } -} - - -/***************************************************************************** -* Function : USB_ClearFeatureEvent -* Description : disable Remote_Wakeup and EPn Halt=1. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_ClearFeatureEvent(void) -{ - uint32_t wCmdtype = sUSB_EumeData.bUSB_bmRequestType & USB_ENDPOINT_NUM; - uint32_t wEPNum; - - if ((sUSB_EumeData.bUSB_bmRequestType & REQUEST_DIR_MASK) != REQUEST_HOST_TO_DEVICE) - USB_EPnStall(USB_EP0); //** EP0 STALL - - if (wCmdtype == REQUEST_TO_DEVICE) //** Device - { - if (sUSB_EumeData.bUSB_wValueL == USB_FEATURE_REMOTE_WAKEUP) - { - sUSB_EumeData.wUSB_Status &= ~mskREMOTE_WAKEUP; //** Clear Remote_Wakeup = 0 - //** Set Dev_Feature_Cmd & Setup_IN = 1 - sUSB_EumeData.wUSB_Status |= (mskDEV_FEATURE_CMD | mskSETUP_IN); - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - return; - } - } - else if (wCmdtype == REQUEST_TO_ENDPOINT) //** Endpoint - { - if (sUSB_EumeData.bUSB_wValueL == USB_FEATURE_ENDPOINT_STALL) - { - wEPNum = sUSB_EumeData.bUSB_wIndexL & USB_ENDPOINT_NUM; - if (wEPNum == USB_EP0) - { - if (sUSB_EumeData.wUSB_Status & mskSETADDRESS) //** Check SetAddress - { - wUSB_EndpHalt[0] = USB_EPn_NON_HALT; - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; //** Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - return; - } - } - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - else if (wEPNum <= USB_EP4) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - else if ((wEPNum == USB_EP1)||(wEPNum == USB_EP4)) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - else if ((wEPNum <= USB_EP2)||(wEPNum == USB_EP4)) - #endif - { - if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) - { - *(&wUSB_EndpHalt[0] + wEPNum) = USB_EPn_NON_HALT; - - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; //** Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - return; - } - } - } - } -} - - -/***************************************************************************** -* Function : USB_SetFeatureEvent -* Description : Enable Remote_Wakeup and EPn Halt=1. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_SetFeatureEvent(void) -{ - uint32_t wCmdtype = sUSB_EumeData.bUSB_bmRequestType & USB_ENDPOINT_NUM; - uint32_t wEPNum; - - if ((sUSB_EumeData.bUSB_bmRequestType & REQUEST_DIR_MASK) != REQUEST_HOST_TO_DEVICE) - USB_EPnStall(USB_EP0); //** EP0 STALL - - - if (wCmdtype == REQUEST_TO_DEVICE) //** Device - { - if (sUSB_EumeData.bUSB_wValueL == USB_FEATURE_REMOTE_WAKEUP) - { - //** Set Remote_Wakeup & Dev_Feature_Cmd & Setup_IN = 1 - sUSB_EumeData.wUSB_Status |= (mskREMOTE_WAKEUP | mskDEV_FEATURE_CMD | mskSETUP_IN); - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - return; - } - } - else if (wCmdtype == REQUEST_TO_ENDPOINT) //** Endpoint - { - if (sUSB_EumeData.bUSB_wValueL == USB_FEATURE_ENDPOINT_STALL) - { - wEPNum = sUSB_EumeData.bUSB_wIndexL & USB_ENDPOINT_NUM; - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - if ((wEPNum >= USB_EP1) && (wEPNum <= USB_EP4)) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - if ((wEPNum == USB_EP1)||(wEPNum == USB_EP4)) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - if (((wEPNum >= USB_EP1) && (wEPNum <= USB_EP2))||(wEPNum == USB_EP4)) - #endif - { - if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) - { - *(&wUSB_EndpHalt[0] + wEPNum) = USB_EPn_HALT; - USB_EPnStall(wEPNum); - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; //** Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - return; - } - } - } - } - else - { - USB_EPnStall(USB_EP0); //** EP0 STALL - } -} - - -/***************************************************************************** -* Function : USB_SetAddressEvent -* Description : Set device address. -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_SetAddressEvent(void) -{ - sUSB_EumeData.wUSB_Status &= ~mskSETADDRESS; // Clear SetAddress = 0 - sUSB_EumeData.wUSB_Status |= mskSETADDRESSCMD; // Set SetAddressCmd = 1 - if (sUSB_EumeData.bUSB_wValueL != 0) - sUSB_EumeData.wUSB_Status |= mskSETADDRESS; // Set SetAddress = 1 - - sUSB_EumeData.bUSB_DeviceAddr = sUSB_EumeData.bUSB_wValueL; - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; // Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); // EP0 ACK 0 byte -} - - -/***************************************************************************** -* Function : USB_GetDescriptorEvent -* Description : Get descriptor length & index -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_GetDescriptorEvent(void) -{ - // uint32_t unsupport, i; - uint32_t unsupport; - unsupport = GET_DESCRIPTOR_STALL; - - // for(i=0; i USB_EP0) - { - USB_EPnNak(i); // Enable EP1~EP4 - if ( (SN_USB->CFG>>(i-1)) & mskEP1_DIR) //if EP1~EP4 is OUT direction - USB_EPnAck(i, 0); // set EP1~EP4 ACK - } - } - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; // Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); // EP0 ACK 0 byte - return; - } - } - USB_EPnStall(USB_EP0); // EP0 STALL -} - - -/***************************************************************************** -* Function : USB_GetInterfaceEvent -* Description : return AlternateSet status -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_GetInterfaceEvent(void) -{ - uint32_t i; - - if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) - { - if (sUSB_EumeData.bUSB_bmRequestType == (REQUEST_DEVICE_TO_HOST|REQUEST_TO_INTERFACE)) - { - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_3) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_1) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_2) - #endif - { - i = *(&wUSB_IfAlternateSet[0]+sUSB_EumeData.bUSB_wIndexL); - fnUSBINT_WriteFIFO(0x00, i); - - sUSB_EumeData.wUSB_Status |= mskSETUP_OUT; // Set Setup_OUT = 1 - USB_EPnAck(USB_EP0,1); // EP0 ACK 1 byte - return; - } - } - } - USB_EPnStall(USB_EP0); // EP0 STALL -} - - -/***************************************************************************** -* Function : USB_SetInterfaceEvent -* Description : Set AlternateSet status -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_SetInterfaceEvent(void) -{ - uint32_t i; - volatile uint8_t *pUsbRam; - - if (sUSB_EumeData.wUSB_SetConfiguration == USB_CONFIG_VALUE) - { - pUsbRam = &wUSB_EndpHalt[0]; - for (i=USB_EP0; i<=USB_EP4; i++) - { - *(pUsbRam+i) = USB_EPn_NON_HALT; // wUsb_EndpHalt0~wUsb_EndpHalt4 = 0 - } - #if (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE1) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_3) - #elif (USB_LIBRARY_TYPE == USB_MOUSE_TYPE) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_1) - #elif (USB_LIBRARY_TYPE == USB_KB_MOUSE_TYPE2) - if (sUSB_EumeData.bUSB_wIndexL <= USB_INTERFACE_2) - #endif - { - if (sUSB_EumeData.bUSB_wValueL == 0) - { - *(&wUSB_IfAlternateSet[0] + sUSB_EumeData.bUSB_wIndexL) = 0; - USB_ClrEPnToggle(sUSB_EumeData.bUSB_wIndexL); // EPn Data toggle = DATA0 - sUSB_EumeData.wUSB_Status |= mskSETUP_IN; // Set Setup_IN = 1 - USB_EPnAck(USB_EP0,0); // EP0 ACK 0 byte - return; - } - } - } - USB_EPnStall(USB_EP0); // EP0 STALL -} - - -/***************************************************************************** -* Function : USB_TableTransmit -* Description : set USB data to EP0 RAM -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -void USB_TableTransmit(void) -{ - uint8_t i; - uint32_t wUSB_TableTemp; - const uint8_t *pUsbIndex = pUSB_TableIndex ; - - if (sUSB_EumeData.bUSB_wLength < wUSB_TableLength) - wUSB_TableLength = sUSB_EumeData.bUSB_wLength; - - if (wUSB_TableLength == 0) - { - USB_EPnAck(USB_EP0,0); //** EP0 ACK 0 byte - if (wUSB_PreTableLength == USB_EP0_PACKET_SIZE) - { - wUSB_PreTableLength = 0; //** Previous IN Token data length = USB_EP0_PACKET_SIZE - //** Next IN Token ACK 0 byte - } - else - { - __USB_EP0INSTALL_EN; //** Before IN Token data length = 1 ~ (USB_EP0_PACKET_SIZE-1) - //** Next IN Token response STALL for CH8 - } - } - else - { - for (i=0; i<(USB_EP0_PACKET_SIZE>>2); i++) - { - wUSB_TableTemp = USB_Comb_Bytetoword((*pUsbIndex),*(pUsbIndex+1),*(pUsbIndex+2),*(pUsbIndex+3)); - fnUSBINT_WriteFIFO((i<<2),wUSB_TableTemp); - pUsbIndex += 4; - } - wUSB_PreTableLength = wUSB_TableLength; //** Temp IN Token data length - if (wUSB_TableLength >= USB_EP0_PACKET_SIZE) - { - USB_EPnAck(USB_EP0,USB_EP0_PACKET_SIZE); //** EP0 ACK USB_SETUP_PACKET_SIZE byte - pUSB_TableIndex += USB_EP0_PACKET_SIZE; - wUSB_TableLength -= USB_EP0_PACKET_SIZE; - } - else - { - USB_EPnAck(USB_EP0,wUSB_TableLength); - wUSB_TableLength = 0; - } - } -} - - /***************************************************************************** * Function : USB_StandardVar_Init * Description : USB Standard Variable initialtion @@ -862,19 +145,3 @@ void USB_StandardVar_Init(void) sUSB_EumeData.wUSB_Status |= mskINITREPEAT; } - -/***************************************************************************** -* Function : USB_Comb_Bytetoword -* Description : Byte array memory copy to Word array -* Input : None -* Output : None -* Return : None -* Note : None -*****************************************************************************/ -uint32_t USB_Comb_Bytetoword (uint8_t data0, uint8_t data1, uint8_t data2, uint8_t data3) -{ - uint32_t data; - data = ((((uint32_t)data3<<24)&((uint32_t)0xFF<<24)) | ((data2<<16)&(0xFF<<16)) | ((data1<<8)&(0xFF<<8)) | (data0&0xFF)); - return (data); -} - diff --git a/os/hal/ports/SN32/SN32F240/hal_lld.c b/os/hal/ports/SN32/SN32F240/hal_lld.c index b1dadcd4..6ffa485d 100644 --- a/os/hal/ports/SN32/SN32F240/hal_lld.c +++ b/os/hal/ports/SN32/SN32F240/hal_lld.c @@ -50,7 +50,7 @@ /*===========================================================================*/ /** - * @brief STM32L4xx clocks and PLL initialization. + * @brief SN32F240 clocks and PLL initialization. * @note All the involved constants come from the file @p board.h. * @note This function should be invoked just after the system reset. * diff --git a/os/hal/ports/SN32/SN32F240/sn32_registry.h b/os/hal/ports/SN32/SN32F240/sn32_registry.h index e2d983e7..362e4046 100644 --- a/os/hal/ports/SN32/SN32F240/sn32_registry.h +++ b/os/hal/ports/SN32/SN32F240/sn32_registry.h @@ -15,7 +15,7 @@ */ /** - * @file SN32F24xx/stm32_registry.h + * @file sn32_registry.h * @brief SN32F24xx capabilities registry. * * @addtogroup HAL diff --git a/os/hal/ports/SN32/SN32F260/hal_lld.c b/os/hal/ports/SN32/SN32F260/hal_lld.c index 9d38ddce..3c192369 100644 --- a/os/hal/ports/SN32/SN32F260/hal_lld.c +++ b/os/hal/ports/SN32/SN32F260/hal_lld.c @@ -50,7 +50,7 @@ /*===========================================================================*/ /** - * @brief STM32L4xx clocks and PLL initialization. + * @brief SN32F260 clocks and PLL initialization. * @note All the involved constants come from the file @p board.h. * @note This function should be invoked just after the system reset. *