clean up
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC)
|
||||
|
||||
#include "host/usbh.h"
|
||||
#include "host/usbh_classdriver.h"
|
||||
|
||||
#include "cdc_host.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -71,13 +73,13 @@ bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid)
|
||||
switch (pipeid)
|
||||
{
|
||||
case CDC_PIPE_NOTIFICATION:
|
||||
return hcd_edpt_busy(dev_addr, p_cdc->ep_notif );
|
||||
return usbh_edpt_busy(dev_addr, p_cdc->ep_notif );
|
||||
|
||||
case CDC_PIPE_DATA_IN:
|
||||
return hcd_edpt_busy(dev_addr, p_cdc->ep_in );
|
||||
return usbh_edpt_busy(dev_addr, p_cdc->ep_in );
|
||||
|
||||
case CDC_PIPE_DATA_OUT:
|
||||
return hcd_edpt_busy(dev_addr, p_cdc->ep_out );
|
||||
return usbh_edpt_busy(dev_addr, p_cdc->ep_out );
|
||||
|
||||
default:
|
||||
return false;
|
||||
@@ -101,7 +103,7 @@ bool tuh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool i
|
||||
TU_VERIFY( p_data != NULL && length, TUSB_ERROR_INVALID_PARA);
|
||||
|
||||
uint8_t const ep_out = cdch_data[dev_addr-1].ep_out;
|
||||
if ( hcd_edpt_busy(dev_addr, ep_out) ) return false;
|
||||
if ( usbh_edpt_busy(dev_addr, ep_out) ) return false;
|
||||
|
||||
return usbh_edpt_xfer(dev_addr, ep_out, (void *) p_data, length);
|
||||
}
|
||||
@@ -113,7 +115,7 @@ bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is
|
||||
TU_VERIFY( p_buffer != NULL && length, TUSB_ERROR_INVALID_PARA);
|
||||
|
||||
uint8_t const ep_in = cdch_data[dev_addr-1].ep_in;
|
||||
if ( hcd_edpt_busy(dev_addr, ep_in) ) return false;
|
||||
if ( usbh_edpt_busy(dev_addr, ep_in) ) return false;
|
||||
|
||||
return usbh_edpt_xfer(dev_addr, ep_in, p_buffer, length);
|
||||
}
|
||||
|
||||
@@ -201,30 +201,73 @@ typedef struct TU_ATTR_PACKED
|
||||
int8_t rx; ///< Delta Rx movement of analog left trigger
|
||||
int8_t ry; ///< Delta Ry movement of analog right trigger
|
||||
uint8_t hat; ///< Buttons mask for currently pressed buttons in the DPad/hat
|
||||
uint16_t buttons; ///< Buttons mask for currently pressed buttons
|
||||
uint32_t buttons; ///< Buttons mask for currently pressed buttons
|
||||
}hid_gamepad_report_t;
|
||||
|
||||
/// Standard Gamepad Buttons Bitmap (from Linux input event codes)
|
||||
/// Standard Gamepad Buttons Bitmap
|
||||
typedef enum
|
||||
{
|
||||
GAMEPAD_BUTTON_A = TU_BIT(0), ///< A/South button
|
||||
GAMEPAD_BUTTON_B = TU_BIT(1), ///< B/East button
|
||||
GAMEPAD_BUTTON_C = TU_BIT(2), ///< C button
|
||||
GAMEPAD_BUTTON_X = TU_BIT(3), ///< X/North button
|
||||
GAMEPAD_BUTTON_Y = TU_BIT(4), ///< Y/West button
|
||||
GAMEPAD_BUTTON_Z = TU_BIT(5), ///< Z button
|
||||
GAMEPAD_BUTTON_TL = TU_BIT(6), ///< L1 button
|
||||
GAMEPAD_BUTTON_TR = TU_BIT(7), ///< R1 button
|
||||
GAMEPAD_BUTTON_TL2 = TU_BIT(8), ///< L2 button
|
||||
GAMEPAD_BUTTON_TR2 = TU_BIT(9), ///< R2 button
|
||||
GAMEPAD_BUTTON_SELECT = TU_BIT(10), ///< Select button
|
||||
GAMEPAD_BUTTON_START = TU_BIT(11), ///< Start button
|
||||
GAMEPAD_BUTTON_MODE = TU_BIT(12), ///< Mode button
|
||||
GAMEPAD_BUTTON_THUMBL = TU_BIT(13), ///< L3 button
|
||||
GAMEPAD_BUTTON_THUMBR = TU_BIT(14), ///< R3 button
|
||||
//GAMEPAD_BUTTON_ = TU_BIT(15), ///< Undefined button
|
||||
GAMEPAD_BUTTON_0 = TU_BIT(0),
|
||||
GAMEPAD_BUTTON_1 = TU_BIT(1),
|
||||
GAMEPAD_BUTTON_2 = TU_BIT(2),
|
||||
GAMEPAD_BUTTON_3 = TU_BIT(3),
|
||||
GAMEPAD_BUTTON_4 = TU_BIT(4),
|
||||
GAMEPAD_BUTTON_5 = TU_BIT(5),
|
||||
GAMEPAD_BUTTON_6 = TU_BIT(6),
|
||||
GAMEPAD_BUTTON_7 = TU_BIT(7),
|
||||
GAMEPAD_BUTTON_8 = TU_BIT(8),
|
||||
GAMEPAD_BUTTON_9 = TU_BIT(9),
|
||||
GAMEPAD_BUTTON_10 = TU_BIT(10),
|
||||
GAMEPAD_BUTTON_11 = TU_BIT(11),
|
||||
GAMEPAD_BUTTON_12 = TU_BIT(12),
|
||||
GAMEPAD_BUTTON_13 = TU_BIT(13),
|
||||
GAMEPAD_BUTTON_14 = TU_BIT(14),
|
||||
GAMEPAD_BUTTON_15 = TU_BIT(15),
|
||||
GAMEPAD_BUTTON_16 = TU_BIT(16),
|
||||
GAMEPAD_BUTTON_17 = TU_BIT(17),
|
||||
GAMEPAD_BUTTON_18 = TU_BIT(18),
|
||||
GAMEPAD_BUTTON_19 = TU_BIT(19),
|
||||
GAMEPAD_BUTTON_20 = TU_BIT(20),
|
||||
GAMEPAD_BUTTON_21 = TU_BIT(21),
|
||||
GAMEPAD_BUTTON_22 = TU_BIT(22),
|
||||
GAMEPAD_BUTTON_23 = TU_BIT(23),
|
||||
GAMEPAD_BUTTON_24 = TU_BIT(24),
|
||||
GAMEPAD_BUTTON_25 = TU_BIT(25),
|
||||
GAMEPAD_BUTTON_26 = TU_BIT(26),
|
||||
GAMEPAD_BUTTON_27 = TU_BIT(27),
|
||||
GAMEPAD_BUTTON_28 = TU_BIT(28),
|
||||
GAMEPAD_BUTTON_29 = TU_BIT(29),
|
||||
GAMEPAD_BUTTON_30 = TU_BIT(30),
|
||||
GAMEPAD_BUTTON_31 = TU_BIT(31),
|
||||
}hid_gamepad_button_bm_t;
|
||||
|
||||
/// Standard Gamepad Buttons Naming from Linux input event codes
|
||||
/// https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h
|
||||
#define GAMEPAD_BUTTON_A GAMEPAD_BUTTON_0
|
||||
#define GAMEPAD_BUTTON_SOUTH GAMEPAD_BUTTON_0
|
||||
|
||||
#define GAMEPAD_BUTTON_B GAMEPAD_BUTTON_1
|
||||
#define GAMEPAD_BUTTON_EAST GAMEPAD_BUTTON_1
|
||||
|
||||
#define GAMEPAD_BUTTON_C GAMEPAD_BUTTON_2
|
||||
|
||||
#define GAMEPAD_BUTTON_X GAMEPAD_BUTTON_3
|
||||
#define GAMEPAD_BUTTON_NORTH GAMEPAD_BUTTON_3
|
||||
|
||||
#define GAMEPAD_BUTTON_Y GAMEPAD_BUTTON_4
|
||||
#define GAMEPAD_BUTTON_WEST GAMEPAD_BUTTON_4
|
||||
|
||||
#define GAMEPAD_BUTTON_Z GAMEPAD_BUTTON_5
|
||||
#define GAMEPAD_BUTTON_TL GAMEPAD_BUTTON_6
|
||||
#define GAMEPAD_BUTTON_TR GAMEPAD_BUTTON_7
|
||||
#define GAMEPAD_BUTTON_TL2 GAMEPAD_BUTTON_8
|
||||
#define GAMEPAD_BUTTON_TR2 GAMEPAD_BUTTON_9
|
||||
#define GAMEPAD_BUTTON_SELECT GAMEPAD_BUTTON_10
|
||||
#define GAMEPAD_BUTTON_START GAMEPAD_BUTTON_11
|
||||
#define GAMEPAD_BUTTON_MODE GAMEPAD_BUTTON_12
|
||||
#define GAMEPAD_BUTTON_THUMBL GAMEPAD_BUTTON_13
|
||||
#define GAMEPAD_BUTTON_THUMBR GAMEPAD_BUTTON_14
|
||||
|
||||
/// Standard Gamepad HAT/DPAD Buttons (from Linux input event codes)
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -149,7 +149,7 @@ bool tud_hid_n_mouse_report(uint8_t instance, uint8_t report_id,
|
||||
}
|
||||
|
||||
bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id,
|
||||
int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons)
|
||||
int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons)
|
||||
{
|
||||
hid_gamepad_report_t report =
|
||||
{
|
||||
|
||||
@@ -72,9 +72,9 @@ bool tud_hid_n_keyboard_report(uint8_t instance, uint8_t report_id, uint8_t modi
|
||||
// use template layout report as defined by hid_mouse_report_t
|
||||
bool tud_hid_n_mouse_report(uint8_t instance, uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
|
||||
// Gamepad: convenient helper to send mouse report if application
|
||||
// Gamepad: convenient helper to send gamepad report if application
|
||||
// use template layout report TUD_HID_REPORT_DESC_GAMEPAD
|
||||
bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons);
|
||||
bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Single Port)
|
||||
@@ -85,7 +85,7 @@ static inline uint8_t tud_hid_get_protocol(void);
|
||||
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
|
||||
static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
|
||||
static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons);
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Callbacks (Weak is optional)
|
||||
@@ -152,7 +152,7 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
|
||||
return tud_hid_n_mouse_report(0, report_id, buttons, x, y, vertical, horizontal);
|
||||
}
|
||||
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons)
|
||||
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons)
|
||||
{
|
||||
return tud_hid_n_gamepad_report(0, report_id, x, y, z, rz, rx, ry, hat, buttons);
|
||||
}
|
||||
@@ -344,10 +344,10 @@ static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y
|
||||
/* 16 bit Button Map */ \
|
||||
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ) ,\
|
||||
HID_USAGE_MIN ( 1 ) ,\
|
||||
HID_USAGE_MAX ( 16 ) ,\
|
||||
HID_USAGE_MAX ( 32 ) ,\
|
||||
HID_LOGICAL_MIN ( 0 ) ,\
|
||||
HID_LOGICAL_MAX ( 1 ) ,\
|
||||
HID_REPORT_COUNT ( 16 ) ,\
|
||||
HID_REPORT_COUNT ( 32 ) ,\
|
||||
HID_REPORT_SIZE ( 1 ) ,\
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
|
||||
HID_COLLECTION_END \
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HID)
|
||||
|
||||
#include "host/usbh.h"
|
||||
#include "host/usbh_classdriver.h"
|
||||
|
||||
#include "hid_host.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -199,7 +201,7 @@ bool tuh_hid_set_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, u
|
||||
// TU_VERIFY(tuh_n_hid_n_mounted(dev_addr, instance));
|
||||
//
|
||||
// hidh_interface_t* hid_itf = get_instance(dev_addr, instance);
|
||||
// return !hcd_edpt_busy(dev_addr, hid_itf->ep_in);
|
||||
// return !usbh_edpt_busy(dev_addr, hid_itf->ep_in);
|
||||
//}
|
||||
|
||||
//void tuh_hid_send_report(uint8_t dev_addr, uint8_t instance, uint8_t report_id, uint8_t const* report, uint16_t len);
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC
|
||||
|
||||
#include "host/usbh.h"
|
||||
#include "host/usbh_classdriver.h"
|
||||
|
||||
#include "msc_host.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -109,7 +111,7 @@ bool tuh_msc_mounted(uint8_t dev_addr)
|
||||
bool tuh_msc_ready(uint8_t dev_addr)
|
||||
{
|
||||
msch_interface_t* p_msc = get_itf(dev_addr);
|
||||
return p_msc->mounted && !hcd_edpt_busy(dev_addr, p_msc->ep_in);
|
||||
return p_msc->mounted && !usbh_edpt_busy(dev_addr, p_msc->ep_in);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user