summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-04-02 16:38:40 +0700
committerhathach <[email protected]>2024-04-02 16:38:40 +0700
commit7d3d60f96de3f6e15291c9302463c294e2dc98de (patch)
tree9066cd077fd07703326391c46c3e55f165b1db5b /src/host
parente802fe0677c901a444e7c9b5d67be2a1f400adee (diff)
add hcd_configure() to change max NAK dynamically
Diffstat (limited to 'src/host')
-rw-r--r--src/host/hcd.h2
-rw-r--r--src/host/usbh.c13
-rw-r--r--src/host/usbh.h14
3 files changed, 21 insertions, 8 deletions
diff --git a/src/host/hcd.h b/src/host/hcd.h
index d5804c608..5547c7cc5 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -125,7 +125,7 @@ bool hcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
//--------------------------------------------------------------------+
// optional hcd configuration, called by tuh_configure()
-bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) TU_ATTR_WEAK;
+bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param);
// Initialize controller to host mode
bool hcd_init(uint8_t rhport);
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 05091736e..aa0603d47 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -52,6 +52,13 @@ TU_ATTR_WEAK bool hcd_deinit(uint8_t rhport) {
return false;
}
+TU_ATTR_WEAK bool hcd_configure(uint8_t rhport, uint32_t cfg_id, const void* cfg_param) {
+ (void) rhport;
+ (void) cfg_id;
+ (void) cfg_param;
+ return false;
+}
+
TU_ATTR_WEAK void tuh_event_hook_cb(uint8_t rhport, uint32_t eventid, bool in_isr) {
(void) rhport;
(void) eventid;
@@ -332,11 +339,7 @@ bool tuh_rhport_reset_bus(uint8_t rhport, bool active) {
//--------------------------------------------------------------------+
bool tuh_configure(uint8_t rhport, uint32_t cfg_id, const void *cfg_param) {
- if ( hcd_configure ) {
- return hcd_configure(rhport, cfg_id, cfg_param);
- } else {
- return false;
- }
+ return hcd_configure(rhport, cfg_id, cfg_param);
}
static void clear_device(usbh_device_t* dev) {
diff --git a/src/host/usbh.h b/src/host/usbh.h
index 0e31e80a7..57362c778 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -73,11 +73,21 @@ typedef struct {
tusb_desc_interface_t desc;
} tuh_itf_info_t;
-// ConfigID for tuh_config()
+// ConfigID for tuh_configure()
enum {
- TUH_CFGID_RPI_PIO_USB_CONFIGURATION = OPT_MCU_RP2040 << 8 // cfg_param: pio_usb_configuration_t
+ TUH_CFGID_INVALID = 0,
+ TUH_CFGID_RPI_PIO_USB_CONFIGURATION = 100, // cfg_param: pio_usb_configuration_t
+ TUH_CFGID_MAX3421 = 200,
};
+typedef union {
+ // For TUH_CFGID_RPI_PIO_USB_CONFIGURATION use pio_usb_configuration_t
+
+ struct {
+ uint8_t max_nak;
+ } max3421;
+} tuh_configure_param_t;
+
//--------------------------------------------------------------------+
// APPLICATION CALLBACK
//--------------------------------------------------------------------+