mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-25 03:02:26 +00:00
dcd_set_address include status response, usbd control stall both control in and out
This commit is contained in:
parent
195a44172a
commit
eda56769b9
@ -45,9 +45,10 @@ Currently the following OS are supported with tinyusb out of the box with a simp
|
|||||||
|
|
||||||
The stack supports the following MCUs
|
The stack supports the following MCUs
|
||||||
|
|
||||||
|
- **Nordic:** nRF52840
|
||||||
- **NXP:** LPC11Uxx, LPC13xx, LPC175x_6x, LPC177x_8x, LPC40xx, LPC43xx
|
- **NXP:** LPC11Uxx, LPC13xx, LPC175x_6x, LPC177x_8x, LPC40xx, LPC43xx
|
||||||
- **MicroChip:** SAMD21, SAMD51 (device only)
|
- **MicroChip:** SAMD21, SAMD51 (device only)
|
||||||
- **Nordic:** nRF52840
|
- **ST* STM32F4
|
||||||
|
|
||||||
[Here is the list of supported Boards](hw/bsp/readme.md)
|
[Here is the list of supported Boards](hw/bsp/readme.md)
|
||||||
|
|
||||||
@ -64,8 +65,8 @@ The stack is developed with GCC compiler, and should be compilable with others.
|
|||||||
TinyUSB is currently used by these other projects:
|
TinyUSB is currently used by these other projects:
|
||||||
|
|
||||||
* [Adafruit nRF52 Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
|
* [Adafruit nRF52 Arduino](https://github.com/adafruit/Adafruit_nRF52_Arduino)
|
||||||
|
* [Adafruit nRF52 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
|
||||||
* [CircuitPython](https://github.com/adafruit/circuitpython)
|
* [CircuitPython](https://github.com/adafruit/circuitpython)
|
||||||
* [nRF52840 UF2 Bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader)
|
|
||||||
|
|
||||||
## Porting
|
## Porting
|
||||||
|
|
||||||
|
@ -9,4 +9,5 @@
|
|||||||
<import file_name="lpc11u6x/lpc11u6x.emProject" />
|
<import file_name="lpc11u6x/lpc11u6x.emProject" />
|
||||||
<import file_name="lpc18xx/lpc18xx.emProject" />
|
<import file_name="lpc18xx/lpc18xx.emProject" />
|
||||||
<import file_name="lpc40xx/lpc40xx.emProject" />
|
<import file_name="lpc40xx/lpc40xx.emProject" />
|
||||||
|
<import file_name="stm32f4/stm32f4.emProject" />
|
||||||
</solution>
|
</solution>
|
||||||
|
@ -97,7 +97,7 @@
|
|||||||
// #define CFG_TUD_DESC_PID 0x0001
|
// #define CFG_TUD_DESC_PID 0x0001
|
||||||
|
|
||||||
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
|
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
|
||||||
// Therefor we need to force endpoint number to correct type on lpc17xx
|
// Therefore we need to force endpoint number to correct type on lpc17xx
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
|
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
|
||||||
#define CFG_TUD_DESC_CDC_EPNUM_NOTIF 1
|
#define CFG_TUD_DESC_CDC_EPNUM_NOTIF 1
|
||||||
#define CFG_TUD_DESC_CDC_EPNUM 2
|
#define CFG_TUD_DESC_CDC_EPNUM 2
|
||||||
|
@ -92,7 +92,7 @@ void SystemInit(void)
|
|||||||
Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
|
Chip_SCU_SetPinMuxing(pinmuxing, sizeof(pinmuxing) / sizeof(PINMUX_GRP_T));
|
||||||
|
|
||||||
/* Clock pins only, group field not used */
|
/* Clock pins only, group field not used */
|
||||||
for (int i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
|
for (uint32_t i = 0; i < (sizeof(pinclockmuxing) / sizeof(pinclockmuxing[0])); i++)
|
||||||
{
|
{
|
||||||
Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
|
Chip_SCU_ClockPinMuxSet(pinclockmuxing[i].pinnum, pinclockmuxing[i].modefunc);
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ void board_init(void)
|
|||||||
const uint8_t ledports[] = {6, 6, 6, 6, 6, 4, 4, 4};
|
const uint8_t ledports[] = {6, 6, 6, 6, 6, 4, 4, 4};
|
||||||
const uint8_t ledbits[] = {24, 25, 26, 27, 28, 12, 13, 14};
|
const uint8_t ledbits[] = {24, 25, 26, 27, 28, 12, 13, 14};
|
||||||
|
|
||||||
for (int i = 0; i < (sizeof(ledports) / sizeof(ledports[0])); i++)
|
for (uint32_t i = 0; i < (sizeof(ledports) / sizeof(ledports[0])); i++)
|
||||||
{
|
{
|
||||||
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, ledports[i], ledbits[i]);
|
Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, ledports[i], ledbits[i]);
|
||||||
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, false);
|
Chip_GPIO_SetPinState(LPC_GPIO_PORT, LED_PORT, LED_PIN, false);
|
||||||
@ -197,10 +197,14 @@ void board_led_control(bool state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------- Buttons -------------//
|
//------------- Buttons -------------//
|
||||||
|
/*
|
||||||
static bool button_read(uint8_t id)
|
static bool button_read(uint8_t id)
|
||||||
{
|
{
|
||||||
|
(void) id;
|
||||||
// return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
|
// return !TU_BIT_TEST( GPIO_ReadValue(buttons[id].gpio_port), buttons[id].gpio_pin ); // button is active low
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
uint32_t board_buttons(void)
|
uint32_t board_buttons(void)
|
||||||
{
|
{
|
||||||
@ -216,9 +220,12 @@ uint32_t board_buttons(void)
|
|||||||
uint8_t board_uart_getchar(void)
|
uint8_t board_uart_getchar(void)
|
||||||
{
|
{
|
||||||
//return UART_ReceiveByte(BOARD_UART_PORT);
|
//return UART_ReceiveByte(BOARD_UART_PORT);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void board_uart_putchar(uint8_t c)
|
void board_uart_putchar(uint8_t c)
|
||||||
{
|
{
|
||||||
|
(void) c;
|
||||||
//UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
|
//UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
This code base already had supported for a handful of following boards
|
This code base already had supported for a handful of following boards
|
||||||
|
|
||||||
### NXP MCU ###
|
### Nordic nRF5x ###
|
||||||
|
|
||||||
|
- [nRF52840-DK (aka pca10056)](https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52840-DK)
|
||||||
|
|
||||||
|
### NXP LPC ###
|
||||||
|
|
||||||
- [LPCXpresso 11U68](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc11u68:OM13058)
|
- [LPCXpresso 11U68](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc11u68:OM13058)
|
||||||
- [LPCXpresso 1347](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc1347:OM13045)
|
- [LPCXpresso 1347](https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/lpcxpresso-boards/lpcxpresso-board-for-lpc1347:OM13045)
|
||||||
@ -18,9 +22,9 @@ This code base already had supported for a handful of following boards
|
|||||||
- [Adafruit Metro M0 Express](https://www.adafruit.com/product/3505)
|
- [Adafruit Metro M0 Express](https://www.adafruit.com/product/3505)
|
||||||
- [Adafruit Metro M4 Express](https://www.adafruit.com/product/3382)
|
- [Adafruit Metro M4 Express](https://www.adafruit.com/product/3382)
|
||||||
|
|
||||||
### Nordic nRF52840 ###
|
### ST STM32 ###
|
||||||
|
|
||||||
- [nRF52840-DK (aka pca10056)](https://www.nordicsemi.com/eng/Products/nRF52840-DK)
|
- [STM32F4DISCOVERY](https://www.st.com/en/evaluation-tools/stm32f4discovery.html)
|
||||||
|
|
||||||
## Add your own board ##
|
## Add your own board ##
|
||||||
|
|
||||||
|
@ -94,10 +94,16 @@ TU_VERIFY_STATIC(sizeof(dcd_event_t) <= 12, "size is not correct");
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
bool dcd_init (uint8_t rhport);
|
bool dcd_init (uint8_t rhport);
|
||||||
|
|
||||||
|
// Enable device interrupt
|
||||||
void dcd_int_enable (uint8_t rhport);
|
void dcd_int_enable (uint8_t rhport);
|
||||||
|
|
||||||
|
// Disable device interrupt
|
||||||
void dcd_int_disable(uint8_t rhport);
|
void dcd_int_disable(uint8_t rhport);
|
||||||
|
|
||||||
|
// Receive Set Address request, mcu port must also include status IN response
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr);
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr);
|
||||||
|
|
||||||
|
// Receive Set Config request
|
||||||
void dcd_set_config (uint8_t rhport, uint8_t config_num);
|
void dcd_set_config (uint8_t rhport, uint8_t config_num);
|
||||||
|
|
||||||
// Get current frame number
|
// Get current frame number
|
||||||
@ -118,15 +124,13 @@ void dcd_event_setup_received(uint8_t rhport, uint8_t const * setup, bool in_isr
|
|||||||
// helper to send transfer complete event
|
// helper to send transfer complete event
|
||||||
void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr);
|
void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr);
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Endpoint API
|
/* Endpoint API
|
||||||
* - open : Configure endpoint's registers
|
* - open : Configure endpoint's registers
|
||||||
* - xfer : Submit a transfer. When complete dcd_event_xfer_complete
|
* - xfer : Submit a transfer. When complete dcd_event_xfer_complete
|
||||||
* must be called to notify the stack
|
* must be called to notify the stack
|
||||||
* - busy : Check if endpoint transferring is complete (TODO remove)
|
* - busy : Check if endpoint transferring is complete (TODO remove)
|
||||||
* - stall : stall ep. When control endpoint (addr = 0) is stalled,
|
* - stall : stall endpoint
|
||||||
* both direction (IN & OUT) of control ep must be stalled.
|
|
||||||
* - clear_stall : clear stall
|
* - clear_stall : clear stall
|
||||||
* - stalled : check if stalled ( TODO remove )
|
* - stalled : check if stalled ( TODO remove )
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
@ -336,8 +336,8 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
|||||||
switch ( p_request->bRequest )
|
switch ( p_request->bRequest )
|
||||||
{
|
{
|
||||||
case TUSB_REQ_SET_ADDRESS:
|
case TUSB_REQ_SET_ADDRESS:
|
||||||
// response with status first before changing device address
|
// DCD must include zero-length status response since depending on mcu,
|
||||||
usbd_control_status(rhport, p_request);
|
// status could be sent either before or after changing device address
|
||||||
dcd_set_address(rhport, (uint8_t) p_request->wValue);
|
dcd_set_address(rhport, (uint8_t) p_request->wValue);
|
||||||
return true; // skip the rest
|
return true; // skip the rest
|
||||||
break;
|
break;
|
||||||
|
@ -74,7 +74,9 @@ void usbd_control_reset (uint8_t rhport)
|
|||||||
|
|
||||||
void usbd_control_stall(uint8_t rhport)
|
void usbd_control_stall(uint8_t rhport)
|
||||||
{
|
{
|
||||||
dcd_edpt_stall(rhport, 0);
|
// when stalling control endpoint both IN and OUt will be stalled
|
||||||
|
dcd_edpt_stall(rhport, EDPT_CTRL_OUT);
|
||||||
|
dcd_edpt_stall(rhport, EDPT_CTRL_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request)
|
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request)
|
||||||
|
@ -61,7 +61,7 @@ bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, v
|
|||||||
// Send STATUS (zero length) packet
|
// Send STATUS (zero length) packet
|
||||||
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
||||||
|
|
||||||
// Stall control endpoint until new setup packet arrived
|
// Stall control endpoint (both IN and OUT) until new setup packet arrived
|
||||||
void usbd_control_stall(uint8_t rhport);
|
void usbd_control_stall(uint8_t rhport);
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
@ -110,10 +110,12 @@ void dcd_int_disable(uint8_t rhport)
|
|||||||
|
|
||||||
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
// Wait for EP0 to finish before switching the address.
|
// Wait for EP0 to finish before switching the address.
|
||||||
while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {}
|
while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {}
|
||||||
|
|
||||||
USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN;
|
USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +232,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
||||||
} else {
|
} else {
|
||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
|
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
|
||||||
|
|
||||||
// for control, stall both IN & OUT
|
|
||||||
if (ep_addr == 0) {
|
|
||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,10 +115,12 @@ void dcd_int_disable(uint8_t rhport)
|
|||||||
|
|
||||||
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
// Wait for EP0 to finish before switching the address.
|
// Wait for EP0 to finish before switching the address.
|
||||||
while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {}
|
while (USB->DEVICE.DeviceEndpoint[0].EPSTATUS.bit.BK1RDY == 1) {}
|
||||||
|
|
||||||
USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN;
|
USB->DEVICE.DADD.reg = USB_DEVICE_DADD_DADD(dev_addr) | USB_DEVICE_DADD_ADDEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,11 +236,6 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
||||||
} else {
|
} else {
|
||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
|
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ0;
|
||||||
|
|
||||||
// for control, stall both IN & OUT
|
|
||||||
if (ep_addr == 0) {
|
|
||||||
ep->EPSTATUSSET.reg = USB_DEVICE_EPSTATUSSET_STALLRQ1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
|||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) dev_addr;
|
(void) dev_addr;
|
||||||
// Set Address is automatically update by hw controller
|
// Set Address is automatically update by hw controller, nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
||||||
|
@ -159,7 +159,8 @@ void dcd_set_config(uint8_t rhport, uint8_t config_num)
|
|||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK;
|
LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK;
|
||||||
LPC_USB->DEVCMDSTAT |= dev_addr;
|
LPC_USB->DEVCMDSTAT |= dev_addr;
|
||||||
@ -196,17 +197,10 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
|||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
|
||||||
if ( tu_edpt_number(ep_addr) == 0 )
|
|
||||||
{
|
|
||||||
// TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around
|
// TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around
|
||||||
_dcd.ep[0][0].stall = _dcd.ep[1][0].stall = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint8_t const ep_id = ep_addr2id(ep_addr);
|
uint8_t const ep_id = ep_addr2id(ep_addr);
|
||||||
_dcd.ep[ep_id][0].stall = 1;
|
_dcd.ep[ep_id][0].stall = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool dcd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
|
bool dcd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
|
@ -199,7 +199,7 @@ bool dcd_init(uint8_t rhport)
|
|||||||
NVIC_ClearPendingIRQ(USB_IRQn);
|
NVIC_ClearPendingIRQ(USB_IRQn);
|
||||||
NVIC_EnableIRQ(USB_IRQn);
|
NVIC_EnableIRQ(USB_IRQn);
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
@ -216,7 +216,9 @@ void dcd_int_disable(uint8_t rhport)
|
|||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
sie_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
|
sie_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +164,9 @@ void dcd_int_disable(uint8_t rhport)
|
|||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
{
|
{
|
||||||
|
// Response with status first before changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
|
|
||||||
LPC_USB[rhport]->DEVICEADDR = (dev_addr << 25) | TU_BIT(24);
|
LPC_USB[rhport]->DEVICEADDR = (dev_addr << 25) | TU_BIT(24);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,15 +217,8 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
|||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
uint8_t const dir = tu_edpt_dir(ep_addr);
|
||||||
|
|
||||||
if ( epnum == 0)
|
|
||||||
{
|
|
||||||
// Stall both Control IN and OUT
|
|
||||||
LPC_USB[rhport]->ENDPTCTRL[epnum] |= ( (ENDPTCTRL_MASK_STALL << 16) || (ENDPTCTRL_MASK_STALL << 0) );
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0);
|
LPC_USB[rhport]->ENDPTCTRL[epnum] |= ENDPTCTRL_MASK_STALL << (dir ? 16 : 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr)
|
bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +182,9 @@ void dcd_set_address (uint8_t rhport, uint8_t dev_addr)
|
|||||||
USB_OTG_DeviceTypeDef * dev = DEVICE_BASE;
|
USB_OTG_DeviceTypeDef * dev = DEVICE_BASE;
|
||||||
|
|
||||||
dev->DCFG |= (dev_addr << USB_OTG_DCFG_DAD_Pos) & USB_OTG_DCFG_DAD_Msk;
|
dev->DCFG |= (dev_addr << USB_OTG_DCFG_DAD_Pos) & USB_OTG_DCFG_DAD_Msk;
|
||||||
|
|
||||||
|
// Response with status after changing device address
|
||||||
|
dcd_edpt_xfer(rhport, tu_edpt_addr(0, TUSB_DIR_IN), NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
void dcd_set_config (uint8_t rhport, uint8_t config_num)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user