- wrap up hcd max3421, work well with nrf52840
- also add usbh_defer_func()
This commit is contained in:
@@ -753,29 +753,33 @@ bool tuh_edpt_abort_xfer(uint8_t daddr, uint8_t ep_addr) {
|
||||
// USBH API For Class Driver
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
uint8_t usbh_get_rhport(uint8_t dev_addr)
|
||||
{
|
||||
usbh_device_t* dev = get_device(dev_addr);
|
||||
uint8_t usbh_get_rhport(uint8_t dev_addr) {
|
||||
usbh_device_t *dev = get_device(dev_addr);
|
||||
return dev ? dev->rhport : _dev0.rhport;
|
||||
}
|
||||
|
||||
uint8_t* usbh_get_enum_buf(void)
|
||||
{
|
||||
uint8_t *usbh_get_enum_buf(void) {
|
||||
return _usbh_ctrl_buf;
|
||||
}
|
||||
|
||||
void usbh_int_set(bool enabled)
|
||||
{
|
||||
void usbh_int_set(bool enabled) {
|
||||
// TODO all host controller if multiple are used since they shared the same event queue
|
||||
if (enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
hcd_int_enable(_usbh_controller);
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
hcd_int_disable(_usbh_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_defer_func(osal_task_func_t func, void *param, bool in_isr) {
|
||||
hcd_event_t event = { 0 };
|
||||
event.event_id = USBH_EVENT_FUNC_CALL;
|
||||
event.func_call.func = func;
|
||||
event.func_call.param = param;
|
||||
|
||||
osal_queue_send(_usbh_q, &event, in_isr);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Endpoint API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef _TUSB_USBH_CLASSDRIVER_H_
|
||||
#define _TUSB_USBH_CLASSDRIVER_H_
|
||||
#ifndef _TUSB_USBH_PVT_H_
|
||||
#define _TUSB_USBH_PVT_H_
|
||||
|
||||
#include "osal/osal.h"
|
||||
#include "common/tusb_fifo.h"
|
||||
@@ -76,6 +76,8 @@ uint8_t* usbh_get_enum_buf(void);
|
||||
|
||||
void usbh_int_set(bool enabled);
|
||||
|
||||
void usbh_defer_func(osal_task_func_t func, void *param, bool in_isr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH Endpoint API
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -85,12 +87,10 @@ bool usbh_edpt_xfer_with_callback(uint8_t dev_addr, uint8_t ep_addr, uint8_t * b
|
||||
tuh_xfer_cb_t complete_cb, uintptr_t user_data);
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE
|
||||
static inline bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||
{
|
||||
static inline bool usbh_edpt_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) {
|
||||
return usbh_edpt_xfer_with_callback(dev_addr, ep_addr, buffer, total_bytes, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
// Claim an endpoint before submitting a transfer.
|
||||
// If caller does not make any transfer, it must release endpoint for others.
|
||||
bool usbh_edpt_claim(uint8_t dev_addr, uint8_t ep_addr);
|
||||
|
||||
Reference in New Issue
Block a user