mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
change dcd_init() return from void to bool
This commit is contained in:
parent
1f18be93db
commit
e83e08343a
@ -108,7 +108,7 @@ void dcd_dcache_clean_invalidate(void const* addr, uint32_t data_size) TU_ATTR_W
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init);
|
||||||
|
|
||||||
// Deinitialize controller, unset device mode.
|
// Deinitialize controller, unset device mode.
|
||||||
bool dcd_deinit(uint8_t rhport);
|
bool dcd_deinit(uint8_t rhport);
|
||||||
|
@ -454,7 +454,7 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
}
|
}
|
||||||
TU_ASSERT(rh_init);
|
TU_ASSERT(rh_init);
|
||||||
|
|
||||||
TU_LOG_USBD("USBD init on controller %u, speed = %s\r\n", rh_init->rhport,
|
TU_LOG_USBD("USBD init on controller %u, speed = %s\r\n", rhport,
|
||||||
rh_init->speed == TUSB_SPEED_HIGH ? "High" : "Full");
|
rh_init->speed == TUSB_SPEED_HIGH ? "High" : "Full");
|
||||||
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
|
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(usbd_device_t));
|
||||||
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
|
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(dcd_event_t));
|
||||||
@ -490,15 +490,16 @@ bool tud_rhport_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
_usbd_rhport = rhport;
|
_usbd_rhport = rhport;
|
||||||
|
|
||||||
// Init device controller driver
|
// Init device controller driver
|
||||||
dcd_init(rhport, rh_init);
|
TU_ASSERT(dcd_init(rhport, rh_init));
|
||||||
dcd_int_enable(rhport);
|
dcd_int_enable(rhport);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_deinit(uint8_t rhport) {
|
bool tud_deinit(uint8_t rhport) {
|
||||||
// skip if not initialized
|
if (!tud_inited()) {
|
||||||
if (!tud_inited()) return true;
|
return true; // skip if not initialized
|
||||||
|
}
|
||||||
|
|
||||||
TU_LOG_USBD("USBD deinit on controller %u\r\n", rhport);
|
TU_LOG_USBD("USBD deinit on controller %u\r\n", rhport);
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ static uint16_t _ft9xx_dusb_out(uint8_t ep_number, uint8_t *buffer, uint16_t len
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
TU_LOG2("FT9xx initialisation\r\n");
|
TU_LOG2("FT9xx initialisation\r\n");
|
||||||
|
|
||||||
@ -526,6 +526,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
interrupt_attach(interrupt_usb_device, (int8_t)interrupt_usb_device, _ft9xx_usbd_ISR);
|
interrupt_attach(interrupt_usb_device, (int8_t)interrupt_usb_device, _ft9xx_usbd_ISR);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -267,7 +267,7 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -296,6 +296,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
// NVIC_ClearPendingIRQ(CIFS_IRQN);
|
// NVIC_ClearPendingIRQ(CIFS_IRQN);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
|
@ -234,13 +234,13 @@ static void bus_reset(uint8_t rhport)
|
|||||||
dcd_dcache_clean_invalidate(&_dcd_data, sizeof(dcd_data_t));
|
dcd_dcache_clean_invalidate(&_dcd_data, sizeof(dcd_data_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
tu_memclr(&_dcd_data, sizeof(dcd_data_t));
|
tu_memclr(&_dcd_data, sizeof(dcd_data_t));
|
||||||
|
|
||||||
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);
|
ci_hs_regs_t* dcd_reg = CI_HS_REG(rhport);
|
||||||
|
|
||||||
TU_ASSERT(ci_ep_count(dcd_reg) <= TUP_DCD_ENDPOINT_MAX, );
|
TU_ASSERT(ci_ep_count(dcd_reg) <= TUP_DCD_ENDPOINT_MAX);
|
||||||
|
|
||||||
// Reset controller
|
// Reset controller
|
||||||
dcd_reg->USBCMD |= USBCMD_RESET;
|
dcd_reg->USBCMD |= USBCMD_RESET;
|
||||||
@ -268,6 +268,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
usbcmd |= USBCMD_RUN_STOP; // run
|
usbcmd |= USBCMD_RUN_STOP; // run
|
||||||
|
|
||||||
dcd_reg->USBCMD = usbcmd;
|
dcd_reg->USBCMD = usbcmd;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -804,15 +804,16 @@ static void handle_ep0_nak(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
_dcd.init_called = true;
|
_dcd.init_called = true;
|
||||||
if (_dcd.vbus_present)
|
if (_dcd.vbus_present) {
|
||||||
{
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -172,7 +172,7 @@ static void enum_done_processing(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
ESP_LOGV(TAG, "DCD init - Start");
|
ESP_LOGV(TAG, "DCD init - Start");
|
||||||
|
|
||||||
@ -211,6 +211,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
USB_DISCONNINTMSK_M; // host most only
|
USB_DISCONNINTMSK_M; // host most only
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
void dcd_set_address(uint8_t rhport, uint8_t dev_addr)
|
||||||
|
@ -582,7 +582,7 @@ void print_musb_info(musb_regs_t* musb_regs) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
musb_regs_t* musb_regs = MUSB_REGS(rhport);
|
musb_regs_t* musb_regs = MUSB_REGS(rhport);
|
||||||
|
|
||||||
@ -594,6 +594,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
musb_dcd_int_clear(rhport);
|
musb_dcd_int_clear(rhport);
|
||||||
musb_dcd_phy_init(rhport);
|
musb_dcd_phy_init(rhport);
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -470,7 +470,7 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
intr_disable(rhport);
|
intr_disable(rhport);
|
||||||
intr_clear(rhport);
|
intr_clear(rhport);
|
||||||
@ -502,6 +502,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
U1IE = _U1IE_URSTIE_MASK;
|
U1IE = _U1IE_URSTIE_MASK;
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -120,7 +120,7 @@ static ep0_stage_t ep0_get_stage(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
// Disable endpoint interrupts for now
|
// Disable endpoint interrupts for now
|
||||||
USB_REGS->INTRRXEbits.w = 0;
|
USB_REGS->INTRRXEbits.w = 0;
|
||||||
@ -129,6 +129,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
USB_REGS->INTRUSBEbits.w = 7;
|
USB_REGS->INTRUSBEbits.w = 7;
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -78,8 +78,9 @@ static void bus_reset(void)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport; (void) rh_init;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
|
|
||||||
// Reset to get in a clean state.
|
// Reset to get in a clean state.
|
||||||
USB->DEVICE.CTRLA.bit.SWRST = true;
|
USB->DEVICE.CTRLA.bit.SWRST = true;
|
||||||
@ -101,6 +102,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
|
USB->DEVICE.INTFLAG.reg |= USB->DEVICE.INTFLAG.reg; // clear pending
|
||||||
USB->DEVICE.INTENSET.reg = /* USB_DEVICE_INTENSET_SOF | */ USB_DEVICE_INTENSET_EORST;
|
USB->DEVICE.INTENSET.reg = /* USB_DEVICE_INTENSET_SOF | */ USB_DEVICE_INTENSET_EORST;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X
|
#if CFG_TUSB_MCU == OPT_MCU_SAMD51 || CFG_TUSB_MCU == OPT_MCU_SAME5X
|
||||||
|
@ -155,11 +155,13 @@ static void bus_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
tu_memclr(_dcd_xfer, sizeof(_dcd_xfer));
|
tu_memclr(_dcd_xfer, sizeof(_dcd_xfer));
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -104,9 +104,10 @@ TU_ATTR_ALWAYS_INLINE static inline void CleanInValidateCache(uint32_t *addr, in
|
|||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -245,7 +245,7 @@ static void process_bus_active(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -256,6 +256,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
NVIC_ClearPendingIRQ(USB_FS_IRQn);
|
NVIC_ClearPendingIRQ(USB_FS_IRQn);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#define USB_DEVICE_INTERRUPT_PRIORITY (3U)
|
#define USB_DEVICE_INTERRUPT_PRIORITY (3U)
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -230,10 +230,11 @@ static void xact_in_dma(uint8_t epnum) {
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Controller API
|
// Controller API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
TU_LOG2("dcd init\r\n");
|
TU_LOG2("dcd init\r\n");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -201,7 +201,7 @@ static const uint32_t enabled_irqs = USBD_INTSTS_FLDET_STS_Msk | USBD_INTSTS_BUS
|
|||||||
NUC100/NUC120 TinyUSB API driver implementation
|
NUC100/NUC120 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -215,6 +215,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
USBD->INTSTS = enabled_irqs;
|
USBD->INTSTS = enabled_irqs;
|
||||||
USBD->INTEN = enabled_irqs;
|
USBD->INTEN = enabled_irqs;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -209,7 +209,7 @@ enum {
|
|||||||
NUC121/NUC125/NUC126 TinyUSB API driver implementation
|
NUC121/NUC125/NUC126 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -227,6 +227,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
USBD->INTSTS = ENABLED_IRQS;
|
USBD->INTSTS = ENABLED_IRQS;
|
||||||
USBD->INTEN = ENABLED_IRQS;
|
USBD->INTEN = ENABLED_IRQS;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -279,7 +279,7 @@ static const uint32_t enabled_irqs = USBD_GINTEN_USBIEN_Msk | \
|
|||||||
NUC505 TinyUSB API driver implementation
|
NUC505 TinyUSB API driver implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -291,6 +291,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
bus_reset();
|
bus_reset();
|
||||||
|
|
||||||
usb_attach();
|
usb_attach();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -265,7 +265,7 @@ static void process_bus_resume(uint8_t rhport)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Device API
|
/* Device API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -294,6 +294,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
NVIC_ClearPendingIRQ(USB0_IRQn);
|
NVIC_ClearPendingIRQ(USB0_IRQn);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -167,7 +167,7 @@ static void bus_reset(void)
|
|||||||
tu_memclr(&_dcd, sizeof(dcd_data_t));
|
tu_memclr(&_dcd, sizeof(dcd_data_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -186,6 +186,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
// Clear pending IRQ
|
// Clear pending IRQ
|
||||||
NVIC_ClearPendingIRQ(USB_IRQn);
|
NVIC_ClearPendingIRQ(USB_IRQn);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -289,7 +289,7 @@ static void edpt_reset_all(uint8_t rhport)
|
|||||||
}
|
}
|
||||||
prepare_setup_packet(rhport);
|
prepare_setup_packet(rhport);
|
||||||
}
|
}
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
edpt_reset_all(rhport);
|
edpt_reset_all(rhport);
|
||||||
|
|
||||||
@ -303,6 +303,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
DEVCMDSTAT_RESET_CHANGE_MASK | DEVCMDSTAT_CONNECT_CHANGE_MASK | DEVCMDSTAT_SUSPEND_CHANGE_MASK;
|
DEVCMDSTAT_RESET_CHANGE_MASK | DEVCMDSTAT_CONNECT_CHANGE_MASK | DEVCMDSTAT_SUSPEND_CHANGE_MASK;
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ(_dcd_controller[rhport].irqnum);
|
NVIC_ClearPendingIRQ(_dcd_controller[rhport].irqnum);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport)
|
void dcd_int_enable(uint8_t rhport)
|
||||||
|
@ -50,11 +50,13 @@ static usb_descriptor_buffers_t desc;
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
static pio_usb_configuration_t config = PIO_USB_DEFAULT_CONFIG;
|
static pio_usb_configuration_t config = PIO_USB_DEFAULT_CONFIG;
|
||||||
usb_device = pio_usb_device_init(&config, &desc);
|
usb_device = pio_usb_device_init(&config, &desc);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -369,7 +369,7 @@ static void __tusb_irq_path_func(dcd_rp2040_irq)(void) {
|
|||||||
#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
|
#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
assert(rhport == 0);
|
assert(rhport == 0);
|
||||||
|
|
||||||
@ -406,6 +406,7 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
(FORCE_VBUS_DETECT ? 0 : USB_INTS_DEV_CONN_DIS_BITS);
|
(FORCE_VBUS_DETECT ? 0 : USB_INTS_DEV_CONN_DIS_BITS);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_deinit(uint8_t rhport) {
|
bool dcd_deinit(uint8_t rhport) {
|
||||||
|
@ -657,7 +657,7 @@ static void enable_interrupt(uint32_t pswi)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
rusb2_reg_t* rusb = RUSB2_REG(rhport);
|
||||||
rusb2_module_start(rhport, true);
|
rusb2_module_start(rhport, true);
|
||||||
@ -719,6 +719,8 @@ _dcd.sof_enabled = false;
|
|||||||
if (rusb->INTSTS0_b.VBSTS) {
|
if (rusb->INTSTS0_b.VBSTS) {
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -201,7 +201,7 @@ static void _dcd_resume(FAR struct usbdevclass_driver_s *driver, FAR struct usbd
|
|||||||
dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
|
dcd_event_bus_signal(0, DCD_EVENT_RESUME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -211,6 +211,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
usbdcd_driver.setup_queue = osal_queue_create(&_setup_queue_def);
|
usbdcd_driver.setup_queue = osal_queue_create(&_setup_queue_def);
|
||||||
|
|
||||||
usbdev_register(&usbdcd_driver.usbdevclass_driver);
|
usbdev_register(&usbdcd_driver.usbdevclass_driver);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -184,7 +184,7 @@ TU_ATTR_ALWAYS_INLINE static inline xfer_ctl_t *xfer_ctl_ptr(uint8_t epnum, uint
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Controller API
|
// Controller API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
// Follow the RM mentions to use a special ordering of PDWN and FRES
|
// Follow the RM mentions to use a special ordering of PDWN and FRES
|
||||||
for (volatile uint32_t i = 0; i < 200; i++) { // should be a few us
|
for (volatile uint32_t i = 0; i < 200; i++) { // should be a few us
|
||||||
@ -224,6 +224,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
// Enable pull-up if supported
|
// Enable pull-up if supported
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_sof_enable(uint8_t rhport, bool en) {
|
void dcd_sof_enable(uint8_t rhport, bool en) {
|
||||||
|
@ -867,8 +867,9 @@ static void usb_isr_handler(void) {
|
|||||||
dcd_int_handler(0);
|
dcd_int_handler(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
dcd_disconnect(rhport);
|
dcd_disconnect(rhport);
|
||||||
USBC_HardwareReset();
|
USBC_HardwareReset();
|
||||||
USBC_PhyConfig();
|
USBC_PhyConfig();
|
||||||
@ -895,6 +896,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
f1c100s_intc_set_isr(F1C100S_IRQ_USBOTG, usb_isr_handler);
|
f1c100s_intc_set_isr(F1C100S_IRQ_USBOTG, usb_isr_handler);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect by enabling internal pull-up resistor on D+/D-
|
// Connect by enabling internal pull-up resistor on D+/D-
|
||||||
|
@ -650,14 +650,15 @@ static bool check_dwc2(dwc2_regs_t* dwc2) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport; (void) rh_init;
|
(void) rhport;
|
||||||
|
(void) rh_init;
|
||||||
// Programming model begins in the last section of the chapter on the USB
|
// Programming model begins in the last section of the chapter on the USB
|
||||||
// peripheral in each Reference Manual.
|
// peripheral in each Reference Manual.
|
||||||
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
|
dwc2_regs_t* dwc2 = DWC2_REG(rhport);
|
||||||
|
|
||||||
// Check Synopsys ID register, failed if controller clock/power is not enabled
|
// Check Synopsys ID register, failed if controller clock/power is not enabled
|
||||||
TU_ASSERT(check_dwc2(dwc2), );
|
TU_ASSERT(check_dwc2(dwc2));
|
||||||
dcd_disconnect(rhport);
|
dcd_disconnect(rhport);
|
||||||
|
|
||||||
if (phy_hs_supported(dwc2)) {
|
if (phy_hs_supported(dwc2)) {
|
||||||
@ -726,6 +727,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
// TU_LOG_HEX(DWC2_DEBUG, dwc2->gahbcfg);
|
// TU_LOG_HEX(DWC2_DEBUG, dwc2->gahbcfg);
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -40,8 +40,9 @@
|
|||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// Initialize controller to device mode
|
// Initialize controller to device mode
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport; (void) rh_init;
|
(void) rhport; (void) rh_init;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable device interrupt
|
// Enable device interrupt
|
||||||
|
@ -130,7 +130,7 @@ static void enable_functional_reset(const bool enable)
|
|||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Controller API
|
/* Controller API
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport; (void) rh_init;
|
(void) rhport; (void) rh_init;
|
||||||
|
|
||||||
USBKEYPID = USBKEY;
|
USBKEYPID = USBKEY;
|
||||||
@ -163,6 +163,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
USBKEYPID = 0;
|
USBKEYPID = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is no "USB peripheral interrupt disable" bit on MSP430, so we have
|
// There is no "USB peripheral interrupt disable" bit on MSP430, so we have
|
||||||
|
@ -336,7 +336,7 @@ static void dcd_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initializes the USB peripheral for device mode and enables it.
|
// Initializes the USB peripheral for device mode and enables it.
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -352,6 +352,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
// Turn on the external pullup
|
// Turn on the external pullup
|
||||||
usb_pullup_out_write(1);
|
usb_pullup_out_write(1);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enables or disables the USB device interrupt(s). May be used to
|
// Enables or disables the USB device interrupt(s). May be used to
|
||||||
|
@ -123,7 +123,7 @@ static void update_out(uint8_t rhport, uint8_t ep, size_t rx_len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
// init registers
|
// init registers
|
||||||
USBOTG_FS->BASE_CTRL = USBFS_CTRL_SYS_CTRL | USBFS_CTRL_INT_BUSY | USBFS_CTRL_DMA_EN;
|
USBOTG_FS->BASE_CTRL = USBFS_CTRL_SYS_CTRL | USBFS_CTRL_INT_BUSY | USBFS_CTRL_DMA_EN;
|
||||||
@ -154,6 +154,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
EP_DMA(3) = (uint32_t) &data.ep3_buffer.out[0];
|
EP_DMA(3) = (uint32_t) &data.ep3_buffer.out[0];
|
||||||
|
|
||||||
dcd_connect(rhport);
|
dcd_connect(rhport);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_handler(uint8_t rhport) {
|
void dcd_int_handler(uint8_t rhport) {
|
||||||
|
@ -131,7 +131,7 @@ static void xfer_data_packet(uint8_t ep_num, tusb_dir_t ep_dir, xfer_ctl_t* xfer
|
|||||||
ep_set_response_and_toggle(ep_num, ep_dir, USBHS_EP_R_RES_ACK);
|
ep_set_response_and_toggle(ep_num, ep_dir, USBHS_EP_R_RES_ACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
(void) rh_init;
|
(void) rh_init;
|
||||||
|
|
||||||
@ -171,6 +171,8 @@ void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
|||||||
|
|
||||||
USBHSD->DEV_AD = 0;
|
USBHSD->DEV_AD = 0;
|
||||||
USBHSD->CONTROL |= USBHS_DEV_PU_EN;
|
USBHSD->CONTROL |= USBHS_DEV_PU_EN;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_enable(uint8_t rhport) {
|
void dcd_int_enable(uint8_t rhport) {
|
||||||
|
@ -46,10 +46,10 @@ tu_static State state = {false, 0, 0};
|
|||||||
// All no-ops as we are fuzzing.
|
// All no-ops as we are fuzzing.
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
extern "C" {
|
extern "C" {
|
||||||
void dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
bool dcd_init(uint8_t rhport, const tusb_rhport_init_t* rh_init) {
|
||||||
UNUSED(rhport);
|
UNUSED(rhport);
|
||||||
UNUSED(rh_init);
|
UNUSED(rh_init);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dcd_int_handler(uint8_t rhport) {
|
void dcd_int_handler(uint8_t rhport) {
|
||||||
|
@ -203,7 +203,7 @@ void setUp(void)
|
|||||||
.speed = TUSB_SPEED_AUTO
|
.speed = TUSB_SPEED_AUTO
|
||||||
};
|
};
|
||||||
|
|
||||||
dcd_init_Expect(0, &dev_init);
|
dcd_init_ExpectAndReturn(0, &dev_init, true);
|
||||||
tusb_init(0, &dev_init);
|
tusb_init(0, &dev_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void setUp(void) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
mscd_init_Expect();
|
mscd_init_Expect();
|
||||||
dcd_init_Expect(0, &dev_init);
|
dcd_init_ExpectAndReturn(0, &dev_init, true);
|
||||||
|
|
||||||
tusb_init(0, &dev_init);
|
tusb_init(0, &dev_init);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user