mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
shared/tinyusb: Remove USBD_RHPORT constant.
TinyUSB defines TUD_OPT_RHPORT which is the same thing, make shorter definition RHPORT in the two files which use it. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
committed by
Damien George
parent
83131c106d
commit
521b2f86be
@@ -42,6 +42,8 @@
|
|||||||
|
|
||||||
#define HAS_BUILTIN_DRIVERS (MICROPY_HW_USB_CDC || MICROPY_HW_USB_MSC)
|
#define HAS_BUILTIN_DRIVERS (MICROPY_HW_USB_CDC || MICROPY_HW_USB_MSC)
|
||||||
|
|
||||||
|
#define RHPORT TUD_OPT_RHPORT
|
||||||
|
|
||||||
const mp_obj_type_t machine_usb_device_type;
|
const mp_obj_type_t machine_usb_device_type;
|
||||||
|
|
||||||
static mp_obj_t usb_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
static mp_obj_t usb_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
||||||
@@ -111,11 +113,11 @@ static mp_obj_t usb_device_submit_xfer(mp_obj_t self, mp_obj_t ep, mp_obj_t buff
|
|||||||
mp_raise_ValueError(MP_ERROR_TEXT("ep"));
|
mp_raise_ValueError(MP_ERROR_TEXT("ep"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usbd_edpt_claim(USBD_RHPORT, ep_addr)) {
|
if (!usbd_edpt_claim(RHPORT, ep_addr)) {
|
||||||
mp_raise_OSError(MP_EBUSY);
|
mp_raise_OSError(MP_EBUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = usbd_edpt_xfer(USBD_RHPORT, ep_addr, buf_info.buf, buf_info.len);
|
result = usbd_edpt_xfer(RHPORT, ep_addr, buf_info.buf, buf_info.len);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// Store the buffer object until the transfer completes
|
// Store the buffer object until the transfer completes
|
||||||
@@ -168,14 +170,14 @@ static mp_obj_t usb_device_stall(size_t n_args, const mp_obj_t *args) {
|
|||||||
|
|
||||||
usb_device_check_active(self);
|
usb_device_check_active(self);
|
||||||
|
|
||||||
mp_obj_t res = mp_obj_new_bool(usbd_edpt_stalled(USBD_RHPORT, epnum));
|
mp_obj_t res = mp_obj_new_bool(usbd_edpt_stalled(RHPORT, epnum));
|
||||||
|
|
||||||
if (n_args == 3) { // Set stall state
|
if (n_args == 3) { // Set stall state
|
||||||
mp_obj_t stall = args[2];
|
mp_obj_t stall = args[2];
|
||||||
if (mp_obj_is_true(stall)) {
|
if (mp_obj_is_true(stall)) {
|
||||||
usbd_edpt_stall(USBD_RHPORT, epnum);
|
usbd_edpt_stall(RHPORT, epnum);
|
||||||
} else {
|
} else {
|
||||||
usbd_edpt_clear_stall(USBD_RHPORT, epnum);
|
usbd_edpt_clear_stall(RHPORT, epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define RHPORT TUD_OPT_RHPORT
|
||||||
|
|
||||||
static bool in_usbd_task; // Flags if mp_usbd_task() is currently running
|
static bool in_usbd_task; // Flags if mp_usbd_task() is currently running
|
||||||
|
|
||||||
// Some top-level functions that manage global TinyUSB USBD state, not the
|
// Some top-level functions that manage global TinyUSB USBD state, not the
|
||||||
@@ -233,7 +235,7 @@ static uint16_t _runtime_dev_claim_itfs(tusb_desc_interface_t const *itf_desc, u
|
|||||||
} else if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
|
} else if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
|
||||||
// Open any endpoints that we come across
|
// Open any endpoints that we come across
|
||||||
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
|
if (tu_desc_type(p_desc) == TUSB_DESC_ENDPOINT) {
|
||||||
bool r = usbd_edpt_open(USBD_RHPORT, (const void *)p_desc);
|
bool r = usbd_edpt_open(RHPORT, (const void *)p_desc);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(MP_ENODEV));
|
mp_obj_t exc = mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(MP_ENODEV));
|
||||||
usbd_pend_exception(exc);
|
usbd_pend_exception(exc);
|
||||||
@@ -322,7 +324,7 @@ static bool runtime_dev_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_cont
|
|||||||
|
|
||||||
// Check if callback returned any data to submit
|
// Check if callback returned any data to submit
|
||||||
if (mp_get_buffer(cb_res, &buf_info, dir == TUSB_DIR_IN ? MP_BUFFER_READ : MP_BUFFER_RW)) {
|
if (mp_get_buffer(cb_res, &buf_info, dir == TUSB_DIR_IN ? MP_BUFFER_READ : MP_BUFFER_RW)) {
|
||||||
result = tud_control_xfer(USBD_RHPORT,
|
result = tud_control_xfer(RHPORT,
|
||||||
request,
|
request,
|
||||||
buf_info.buf,
|
buf_info.buf,
|
||||||
buf_info.len);
|
buf_info.len);
|
||||||
@@ -468,7 +470,7 @@ static void mp_usbd_disconnect(mp_obj_usb_device_t *usbd) {
|
|||||||
for (int epnum = 0; epnum < CFG_TUD_ENDPPOINT_MAX; epnum++) {
|
for (int epnum = 0; epnum < CFG_TUD_ENDPPOINT_MAX; epnum++) {
|
||||||
for (int dir = 0; dir < 2; dir++) {
|
for (int dir = 0; dir < 2; dir++) {
|
||||||
if (usbd->xfer_data[epnum][dir] != mp_const_none) {
|
if (usbd->xfer_data[epnum][dir] != mp_const_none) {
|
||||||
usbd_edpt_stall(USBD_RHPORT, tu_edpt_addr(epnum, dir));
|
usbd_edpt_stall(RHPORT, tu_edpt_addr(epnum, dir));
|
||||||
usbd->xfer_data[epnum][dir] = mp_const_none;
|
usbd->xfer_data[epnum][dir] = mp_const_none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,7 +481,7 @@ static void mp_usbd_disconnect(mp_obj_usb_device_t *usbd) {
|
|||||||
// Ensure no pending static CDC writes, as these can cause TinyUSB to crash
|
// Ensure no pending static CDC writes, as these can cause TinyUSB to crash
|
||||||
tud_cdc_write_clear();
|
tud_cdc_write_clear();
|
||||||
// Prevent cdc write flush from initiating any new transfers while disconnecting
|
// Prevent cdc write flush from initiating any new transfers while disconnecting
|
||||||
usbd_edpt_stall(USBD_RHPORT, USBD_CDC_EP_IN);
|
usbd_edpt_stall(RHPORT, USBD_CDC_EP_IN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool was_connected = tud_connected();
|
bool was_connected = tud_connected();
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
#ifndef CFG_TUD_CDC_TX_BUFSIZE
|
#ifndef CFG_TUD_CDC_TX_BUFSIZE
|
||||||
#define CFG_TUD_CDC_TX_BUFSIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256)
|
#define CFG_TUD_CDC_TX_BUFSIZE ((CFG_TUD_MAX_SPEED == OPT_MODE_HIGH_SPEED) ? 512 : 256)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // CFG_TUD_CDC
|
||||||
|
|
||||||
// MSC Configuration
|
// MSC Configuration
|
||||||
#if CFG_TUD_MSC
|
#if CFG_TUD_MSC
|
||||||
@@ -92,9 +92,7 @@
|
|||||||
#endif
|
#endif
|
||||||
// Set MSC EP buffer size to FatFS block size to avoid partial read/writes (offset arg).
|
// Set MSC EP buffer size to FatFS block size to avoid partial read/writes (offset arg).
|
||||||
#define CFG_TUD_MSC_BUFSIZE (MICROPY_FATFS_MAX_SS)
|
#define CFG_TUD_MSC_BUFSIZE (MICROPY_FATFS_MAX_SS)
|
||||||
#endif
|
#endif // CFG_TUD_MSC
|
||||||
|
|
||||||
#define USBD_RHPORT (0) // Currently only one port is supported
|
|
||||||
|
|
||||||
// Define built-in interface, string and endpoint numbering based on the above config
|
// Define built-in interface, string and endpoint numbering based on the above config
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user