mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
update host example, add pio-pico-usb for rp2040
This commit is contained in:
parent
f349ae7702
commit
317177c83d
@ -25,3 +25,8 @@ target_include_directories(${PROJECT} PUBLIC
|
|||||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||||
# in hw/bsp/FAMILY/family.cmake for details.
|
# in hw/bsp/FAMILY/family.cmake for details.
|
||||||
family_configure_host_example(${PROJECT})
|
family_configure_host_example(${PROJECT})
|
||||||
|
|
||||||
|
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
|
||||||
|
if(FAMILY STREQUAL "rp2040")
|
||||||
|
family_add_pico_pio_usb(${PROJECT})
|
||||||
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||||
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
// max device support (excluding hub device)
|
// max device support (excluding hub device)
|
||||||
// 1 hub typically has 4 ports
|
// 1 hub typically has 4 ports
|
||||||
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
|
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
|
||||||
|
|
||||||
// Max endpoint per device
|
// Max endpoint per device
|
||||||
#define CFG_TUH_ENDPOINT_MAX 8
|
#define CFG_TUH_ENDPOINT_MAX 8
|
||||||
|
@ -28,3 +28,8 @@ target_include_directories(${PROJECT} PUBLIC
|
|||||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||||
# in hw/bsp/FAMILY/family.cmake for details.
|
# in hw/bsp/FAMILY/family.cmake for details.
|
||||||
family_configure_host_example(${PROJECT})
|
family_configure_host_example(${PROJECT})
|
||||||
|
|
||||||
|
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
|
||||||
|
if(FAMILY STREQUAL "rp2040")
|
||||||
|
family_add_pico_pio_usb(${PROJECT})
|
||||||
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||||
@ -101,8 +101,8 @@
|
|||||||
#define CFG_TUH_MSC 1
|
#define CFG_TUH_MSC 1
|
||||||
#define CFG_TUH_VENDOR 0
|
#define CFG_TUH_VENDOR 0
|
||||||
|
|
||||||
// max device support (excluding hub device)
|
// max device support (excluding hub device): 1 hub typically has 4 ports
|
||||||
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports
|
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
|
||||||
|
|
||||||
//------------- HID -------------//
|
//------------- HID -------------//
|
||||||
#define CFG_TUH_HID_EPIN_BUFSIZE 64
|
#define CFG_TUH_HID_EPIN_BUFSIZE 64
|
||||||
|
@ -26,3 +26,8 @@ target_include_directories(${PROJECT} PUBLIC
|
|||||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||||
# in hw/bsp/FAMILY/family.cmake for details.
|
# in hw/bsp/FAMILY/family.cmake for details.
|
||||||
family_configure_host_example(${PROJECT})
|
family_configure_host_example(${PROJECT})
|
||||||
|
|
||||||
|
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
|
||||||
|
if(FAMILY STREQUAL "rp2040")
|
||||||
|
family_add_pico_pio_usb(${PROJECT})
|
||||||
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||||
@ -101,9 +101,8 @@
|
|||||||
#define CFG_TUH_MSC 0
|
#define CFG_TUH_MSC 0
|
||||||
#define CFG_TUH_VENDOR 0
|
#define CFG_TUH_VENDOR 0
|
||||||
|
|
||||||
// max device support (excluding hub device)
|
// max device support (excluding hub device): 1 hub typically has 4 ports
|
||||||
// 1 hub typically has 4 ports
|
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
|
||||||
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
|
|
||||||
|
|
||||||
//------------- HID -------------//
|
//------------- HID -------------//
|
||||||
|
|
||||||
|
@ -32,3 +32,7 @@ target_include_directories(${PROJECT} PUBLIC
|
|||||||
# in hw/bsp/FAMILY/family.cmake for details.
|
# in hw/bsp/FAMILY/family.cmake for details.
|
||||||
family_configure_host_example(${PROJECT})
|
family_configure_host_example(${PROJECT})
|
||||||
|
|
||||||
|
# Add pico-pio-usb for rp2040 since user can choose to run on bit-banging host
|
||||||
|
if(FAMILY STREQUAL "rp2040")
|
||||||
|
family_add_pico_pio_usb(${PROJECT})
|
||||||
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||||
@ -101,8 +101,8 @@
|
|||||||
#define CFG_TUH_HID 0 // typical keyboard + mouse device can have 3-4 HID interfaces
|
#define CFG_TUH_HID 0 // typical keyboard + mouse device can have 3-4 HID interfaces
|
||||||
#define CFG_TUH_VENDOR 0
|
#define CFG_TUH_VENDOR 0
|
||||||
|
|
||||||
// max device support (excluding hub device)
|
// max device support (excluding hub device): 1 hub typically has 4 ports
|
||||||
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1) // hub typically has 4 ports
|
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
|
||||||
|
|
||||||
//------------- MSC -------------//
|
//------------- MSC -------------//
|
||||||
#define CFG_TUH_MSC_MAXLUN 4 // typical for most card reader
|
#define CFG_TUH_MSC_MAXLUN 4 // typical for most card reader
|
||||||
|
@ -13,9 +13,6 @@ $(BUILD):
|
|||||||
all: $(BUILD)
|
all: $(BUILD)
|
||||||
$(MAKE) -C $(BUILD)
|
$(MAKE) -C $(BUILD)
|
||||||
|
|
||||||
clean:
|
|
||||||
$(RM) -rf $(BUILD)
|
|
||||||
|
|
||||||
flash: flash-pyocd
|
flash: flash-pyocd
|
||||||
flash-uf2:
|
flash-uf2:
|
||||||
@$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
|
@$(CP) $(BUILD)/$(PROJECT).uf2 /media/$(USER)/RPI-RP2
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License (MIT)
|
* The MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||||
@ -97,7 +97,7 @@ static inline uint8_t get_idx_by_ep_addr(uint8_t daddr, uint8_t ep_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TUSB_INDEX_INVALID;
|
return TU_INDEX_INVALID_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ uint8_t tuh_cdc_itf_get_index(uint8_t daddr, uint8_t itf_num)
|
|||||||
if (p_cdc->daddr == daddr && p_cdc->bInterfaceNumber == itf_num) return i;
|
if (p_cdc->daddr == daddr && p_cdc->bInterfaceNumber == itf_num) return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TUSB_INDEX_INVALID;
|
return TU_INDEX_INVALID_8;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info)
|
bool tuh_cdc_itf_get_info(uint8_t idx, tuh_cdc_itf_info_t* info)
|
||||||
@ -533,7 +533,7 @@ static void process_cdc_config(tuh_xfer_t* xfer)
|
|||||||
uintptr_t const state = xfer->user_data;
|
uintptr_t const state = xfer->user_data;
|
||||||
uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
|
uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
|
||||||
uint8_t const idx = tuh_cdc_itf_get_index(xfer->daddr, itf_num);
|
uint8_t const idx = tuh_cdc_itf_get_index(xfer->daddr, itf_num);
|
||||||
TU_ASSERT(idx != TUSB_INDEX_INVALID, );
|
TU_ASSERT(idx != TU_INDEX_INVALID_8, );
|
||||||
|
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,12 @@
|
|||||||
|
|
||||||
#include "tusb_timeout.h" // TODO remove
|
#include "tusb_timeout.h" // TODO remove
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TU_INDEX_INVALID_8 = 0xFFu
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Optional API implemented by application if needed
|
// Optional API implemented by application if needed
|
||||||
// TODO move to a more ovious place/file
|
// TODO move to a more ovious place/file
|
||||||
|
@ -273,11 +273,6 @@ enum
|
|||||||
CONTROL_STAGE_ACK
|
CONTROL_STAGE_ACK
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
TUSB_INDEX_INVALID = 0xff
|
|
||||||
};
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB Descriptors
|
// USB Descriptors
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user