mirror of https://github.com/ARMmbed/mbed-os.git
M467: support fullspeed usb device
parent
196d10662e
commit
2f8b60d501
|
@ -24,7 +24,7 @@ static USBPhyHw *instance;
|
||||||
#if defined (TARGET_M451)
|
#if defined (TARGET_M451)
|
||||||
#undef MBED_CONF_TARGET_USB_DEVICE_HSUSBD
|
#undef MBED_CONF_TARGET_USB_DEVICE_HSUSBD
|
||||||
#define MBED_CONF_TARGET_USB_DEVICE_HSUSBD 0 /* USB 1.1 Only */
|
#define MBED_CONF_TARGET_USB_DEVICE_HSUSBD 0 /* USB 1.1 Only */
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined(TARGET_M460)
|
||||||
#define USBD_SET_ADDRESS 0x05ul
|
#define USBD_SET_ADDRESS 0x05ul
|
||||||
#elif defined (TARGET_M2351) || defined(TARGET_M261)
|
#elif defined (TARGET_M2351) || defined(TARGET_M261)
|
||||||
#undef MBED_CONF_TARGET_USB_DEVICE_HSUSBD
|
#undef MBED_CONF_TARGET_USB_DEVICE_HSUSBD
|
||||||
|
@ -43,8 +43,12 @@ static USBPhyHw *instance;
|
||||||
|
|
||||||
extern "C" void USBD_IRQHandler(void);
|
extern "C" void USBD_IRQHandler(void);
|
||||||
|
|
||||||
|
//#define NVT_USB_Debug(x) { mbed_error_printf x;}
|
||||||
|
#define NVT_USB_Debug(x)
|
||||||
|
|
||||||
void chip_config(void)
|
void chip_config(void)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
#if defined(TARGET_M451)
|
#if defined(TARGET_M451)
|
||||||
/* Enable USBD module clock */
|
/* Enable USBD module clock */
|
||||||
CLK_EnableModuleClock(USBD_MODULE);
|
CLK_EnableModuleClock(USBD_MODULE);
|
||||||
|
@ -67,7 +71,7 @@ void chip_config(void)
|
||||||
|
|
||||||
/* Enable IP clock */
|
/* Enable IP clock */
|
||||||
CLK_EnableModuleClock(USBD_MODULE);
|
CLK_EnableModuleClock(USBD_MODULE);
|
||||||
|
|
||||||
/* Configure pins for USB 1.1 port: VBUS/D+/D-/ID */
|
/* Configure pins for USB 1.1 port: VBUS/D+/D-/ID */
|
||||||
pin_function(PA_12, SYS_GPA_MFPH_PA12MFP_USB_VBUS);
|
pin_function(PA_12, SYS_GPA_MFPH_PA12MFP_USB_VBUS);
|
||||||
pin_function(PA_13, SYS_GPA_MFPH_PA13MFP_USB_D_N);
|
pin_function(PA_13, SYS_GPA_MFPH_PA13MFP_USB_D_N);
|
||||||
|
@ -117,6 +121,51 @@ void chip_config(void)
|
||||||
/* Enable USB PHY's LDO33. Run as USB device. */
|
/* Enable USB PHY's LDO33. Run as USB device. */
|
||||||
SYS->USBPHY = SYS_USBPHY_USBROLE_OTG_V33_EN | SYS_USBPHY_USBROLE_STD_USBD;
|
SYS->USBPHY = SYS_USBPHY_USBROLE_OTG_V33_EN | SYS_USBPHY_USBROLE_STD_USBD;
|
||||||
|
|
||||||
|
#elif defined(TARGET_M460)
|
||||||
|
#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 0)
|
||||||
|
#if MBED_CONF_TARGET_HXT_PRESENT /* CLK src from HXT/PLL */
|
||||||
|
/* Enable HXT clock */
|
||||||
|
//CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk);
|
||||||
|
/* Wait for HXT clock ready */
|
||||||
|
//CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk);
|
||||||
|
/* Select USB clock source as PLL/2 and USB clock divider as 2 */
|
||||||
|
CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL0_USBSEL_PLL_DIV2, CLK_CLKDIV0_USB(2));
|
||||||
|
#else /* For CRYSTAL_LESS */
|
||||||
|
/* Enable HIRC48M clock */
|
||||||
|
CLK_EnableXtalRC(CLK_PWRCTL_HIRC48MEN_Msk);
|
||||||
|
/* Waiting for HIRC48M clock ready */
|
||||||
|
CLK_WaitClockReady(CLK_STATUS_HIRC48MSTB_Msk);
|
||||||
|
/* Select USB clock source as HIRC48M and USB clock divider as 1 */
|
||||||
|
CLK_SetModuleClock(USBD_MODULE, CLK_CLKSEL0_USBSEL_HIRC48M, CLK_CLKDIV0_USB(1));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Configure USB to Device mode */
|
||||||
|
SYS->USBPHY = (SYS->USBPHY & ~SYS_USBPHY_USBROLE_Msk) | SYS_USBPHY_USBROLE_STD_USBD;
|
||||||
|
|
||||||
|
/* Enable USB PHY */
|
||||||
|
SYS->USBPHY |= SYS_USBPHY_USBEN_Msk | SYS_USBPHY_SBO_Msk;
|
||||||
|
|
||||||
|
/* Enable IP clock */
|
||||||
|
CLK_EnableModuleClock(USBD_MODULE);
|
||||||
|
|
||||||
|
/* Configure pins for USB 1.1 port: VBUS/D+/D-/ID */
|
||||||
|
SET_USB_VBUS_PA12();
|
||||||
|
SET_USB_D_N_PA13();
|
||||||
|
SET_USB_D_P_PA14();
|
||||||
|
SET_USB_OTG_ID_PA15();
|
||||||
|
#else
|
||||||
|
/* Configure HSUSB to Device mode */
|
||||||
|
SYS->USBPHY = (SYS->USBPHY & ~SYS_USBPHY_HSUSBROLE_Msk) | SYS_USBPHY_HSUSBROLE_STD_USBD;
|
||||||
|
/* Enable HSUSB PHY */
|
||||||
|
SYS->USBPHY = (SYS->USBPHY & ~(SYS_USBPHY_HSUSBEN_Msk | SYS_USBPHY_HSUSBACT_Msk)) | SYS_USBPHY_HSUSBEN_Msk;
|
||||||
|
/* Delay >10 us and then switch HSUSB PHY from reset state to active state */
|
||||||
|
wait_us(10);
|
||||||
|
SYS->USBPHY |= SYS_USBPHY_HSUSBACT_Msk;
|
||||||
|
|
||||||
|
/* Enable USBD module clock */
|
||||||
|
CLK_EnableModuleClock(HSUSBD_MODULE);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +210,7 @@ volatile uint32_t frame_cnt = 0;
|
||||||
USBPhy *get_usb_phy()
|
USBPhy *get_usb_phy()
|
||||||
{
|
{
|
||||||
static USBPhyHw usbphy;
|
static USBPhyHw usbphy;
|
||||||
|
NVT_USB_Debug(("### %s\n", __FUNCTION__));
|
||||||
return &usbphy;
|
return &usbphy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +230,7 @@ USBPhyHw::~USBPhyHw()
|
||||||
*/
|
*/
|
||||||
void USBPhyHw::init(USBPhyEvents *events)
|
void USBPhyHw::init(USBPhyEvents *events)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
if (this->events == NULL) {
|
if (this->events == NULL) {
|
||||||
sleep_manager_lock_deep_sleep();
|
sleep_manager_lock_deep_sleep();
|
||||||
}
|
}
|
||||||
|
@ -209,6 +260,7 @@ void USBPhyHw::init(USBPhyEvents *events)
|
||||||
|
|
||||||
void USBPhyHw::deinit()
|
void USBPhyHw::deinit()
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
NVIC_DisableIRQ(USBD_IRQn);
|
NVIC_DisableIRQ(USBD_IRQn);
|
||||||
USBD_SET_SE0();
|
USBD_SET_SE0();
|
||||||
USBD_DISABLE_PHY();
|
USBD_DISABLE_PHY();
|
||||||
|
@ -233,7 +285,8 @@ void EpInit(void);
|
||||||
|
|
||||||
void USBPhyHw::connect()
|
void USBPhyHw::connect()
|
||||||
{
|
{
|
||||||
int volatile i = 0;
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
|
|
||||||
memset(read_buffers, 0, sizeof(read_buffers));
|
memset(read_buffers, 0, sizeof(read_buffers));
|
||||||
memset(read_sizes, 0, sizeof(read_sizes));
|
memset(read_sizes, 0, sizeof(read_sizes));
|
||||||
|
|
||||||
|
@ -255,6 +308,7 @@ void USBPhyHw::connect()
|
||||||
void USBPhyHw::disconnect()
|
void USBPhyHw::disconnect()
|
||||||
{
|
{
|
||||||
uint32_t volatile i = 0;
|
uint32_t volatile i = 0;
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
#if 1
|
#if 1
|
||||||
#if defined (TARGET_NANO100)
|
#if defined (TARGET_NANO100)
|
||||||
SYS->IPRST_CTL2 = SYS_IPRST_CTL2_USBD_RST_Msk;
|
SYS->IPRST_CTL2 = SYS_IPRST_CTL2_USBD_RST_Msk;
|
||||||
|
@ -301,7 +355,7 @@ void USBPhyHw::disconnect()
|
||||||
void EpInit(void)
|
void EpInit(void)
|
||||||
{
|
{
|
||||||
uint32_t volatile i = 0;
|
uint32_t volatile i = 0;
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
#if defined (TARGET_NANO100)
|
#if defined (TARGET_NANO100)
|
||||||
USBD->BUFSEG = 0;
|
USBD->BUFSEG = 0;
|
||||||
#else
|
#else
|
||||||
|
@ -437,6 +491,7 @@ void USBPhyHw::ep0_read(uint8_t *data, uint32_t size)
|
||||||
*/
|
*/
|
||||||
uint32_t USBPhyHw::ep0_read_result()
|
uint32_t USBPhyHw::ep0_read_result()
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint8_t *buf = (uint8_t *)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP1));
|
uint8_t *buf = (uint8_t *)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP1));
|
||||||
uint8_t *buffer = read_buffers[0];
|
uint8_t *buffer = read_buffers[0];
|
||||||
|
@ -457,6 +512,7 @@ uint32_t USBPhyHw::ep0_read_result()
|
||||||
/* Write a packet on endpoint 0. */
|
/* Write a packet on endpoint 0. */
|
||||||
void USBPhyHw::ep0_write(uint8_t *buffer, uint32_t size)
|
void USBPhyHw::ep0_write(uint8_t *buffer, uint32_t size)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
if (buffer && size)
|
if (buffer && size)
|
||||||
{
|
{
|
||||||
if(s_ep_data_bit[0] & 1)
|
if(s_ep_data_bit[0] & 1)
|
||||||
|
@ -483,6 +539,7 @@ void USBPhyHw::ep0_write(uint8_t *buffer, uint32_t size)
|
||||||
|
|
||||||
void stallEndpoint(uint8_t endpoint)
|
void stallEndpoint(uint8_t endpoint)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
if (ep_logic_index >= NUMBER_OF_LOGICAL_ENDPOINTS)
|
if (ep_logic_index >= NUMBER_OF_LOGICAL_ENDPOINTS)
|
||||||
return;
|
return;
|
||||||
|
@ -496,6 +553,7 @@ void stallEndpoint(uint8_t endpoint)
|
||||||
*/
|
*/
|
||||||
void USBPhyHw::ep0_stall()
|
void USBPhyHw::ep0_stall()
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
stallEndpoint(0);
|
stallEndpoint(0);
|
||||||
stallEndpoint(1);
|
stallEndpoint(1);
|
||||||
}
|
}
|
||||||
|
@ -509,6 +567,7 @@ void USBPhyHw::ep0_stall()
|
||||||
*/
|
*/
|
||||||
bool USBPhyHw::endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type)
|
bool USBPhyHw::endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t ep_type = 0;
|
uint32_t ep_type = 0;
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
|
@ -539,6 +598,7 @@ void USBPhyHw::endpoint_remove(usb_ep_t endpoint)
|
||||||
*/
|
*/
|
||||||
void USBPhyHw::endpoint_stall(usb_ep_t endpoint)
|
void USBPhyHw::endpoint_stall(usb_ep_t endpoint)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
USBD_SetStall(DESC_TO_LOG(endpoint));
|
USBD_SetStall(DESC_TO_LOG(endpoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,6 +608,7 @@ void USBPhyHw::endpoint_stall(usb_ep_t endpoint)
|
||||||
*/
|
*/
|
||||||
void USBPhyHw::endpoint_unstall(usb_ep_t endpoint)
|
void USBPhyHw::endpoint_unstall(usb_ep_t endpoint)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
if (ep_logic_index >= NUMBER_OF_LOGICAL_ENDPOINTS)
|
if (ep_logic_index >= NUMBER_OF_LOGICAL_ENDPOINTS)
|
||||||
|
@ -561,6 +622,7 @@ void USBPhyHw::endpoint_unstall(usb_ep_t endpoint)
|
||||||
/* Start a read on the given endpoint. */
|
/* Start a read on the given endpoint. */
|
||||||
bool USBPhyHw::endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
bool USBPhyHw::endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
/* Store the buffer address & length */
|
/* Store the buffer address & length */
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
|
@ -576,6 +638,7 @@ bool USBPhyHw::endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
*/
|
*/
|
||||||
uint32_t USBPhyHw::endpoint_read_result(usb_ep_t endpoint)
|
uint32_t USBPhyHw::endpoint_read_result(usb_ep_t endpoint)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint8_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint8_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t bytes_read = 0;
|
uint32_t bytes_read = 0;
|
||||||
endpoint_read_result_core(endpoint, read_buffers[ep_logic_index], read_sizes[ep_logic_index], &bytes_read);
|
endpoint_read_result_core(endpoint, read_buffers[ep_logic_index], read_sizes[ep_logic_index], &bytes_read);
|
||||||
|
@ -586,6 +649,7 @@ uint32_t USBPhyHw::endpoint_read_result(usb_ep_t endpoint)
|
||||||
|
|
||||||
bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint32_t size, uint32_t *bytes_read)
|
bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint32_t size, uint32_t *bytes_read)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint8_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint8_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
|
@ -603,6 +667,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
*/
|
*/
|
||||||
bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
|
|
||||||
|
@ -631,6 +696,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
/* Abort the current transfer if it has not yet been sent. */
|
/* Abort the current transfer if it has not yet been sent. */
|
||||||
void USBPhyHw::endpoint_abort(usb_ep_t endpoint)
|
void USBPhyHw::endpoint_abort(usb_ep_t endpoint)
|
||||||
{
|
{
|
||||||
|
NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
uint32_t ep_logic_index = DESC_TO_LOG(endpoint);
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
uint32_t ep_hw_index = NU_EPL2EPH(ep_logic_index);
|
||||||
USBD_STOP_TRANSACTION(ep_hw_index);
|
USBD_STOP_TRANSACTION(ep_hw_index);
|
||||||
|
@ -644,6 +710,7 @@ void USBPhyHw::endpoint_abort(usb_ep_t endpoint)
|
||||||
*/
|
*/
|
||||||
void USBPhyHw::process()
|
void USBPhyHw::process()
|
||||||
{
|
{
|
||||||
|
// NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
uint32_t u32IntSts = USBD_GET_INT_FLAG();
|
uint32_t u32IntSts = USBD_GET_INT_FLAG();
|
||||||
uint32_t u32State = USBD_GET_BUS_STATE();
|
uint32_t u32State = USBD_GET_BUS_STATE();
|
||||||
|
|
||||||
|
@ -741,7 +808,7 @@ void USBPhyHw::process()
|
||||||
/* Control IN */
|
/* Control IN */
|
||||||
events->ep0_in();
|
events->ep0_in();
|
||||||
/* In ACK for Set address */
|
/* In ACK for Set address */
|
||||||
#if defined(TARGET_M480) || defined(TARGET_M451)
|
#if defined(TARGET_M480) || defined(TARGET_M451) || defined(TARGET_M460)
|
||||||
if((g_usbd_SetupPacket[0] == REQ_STANDARD) && (g_usbd_SetupPacket[1] == USBD_SET_ADDRESS))
|
if((g_usbd_SetupPacket[0] == REQ_STANDARD) && (g_usbd_SetupPacket[1] == USBD_SET_ADDRESS))
|
||||||
#else
|
#else
|
||||||
if((g_usbd_SetupPacket[0] == REQ_STANDARD) && (g_usbd_SetupPacket[1] == SET_ADDRESS))
|
if((g_usbd_SetupPacket[0] == REQ_STANDARD) && (g_usbd_SetupPacket[1] == SET_ADDRESS))
|
||||||
|
@ -776,7 +843,7 @@ void USBPhyHw::process()
|
||||||
ep_status = (USBD->EPSTS >> (ep_hw_index * 4 + 8)) & 0xF;
|
ep_status = (USBD->EPSTS >> (ep_hw_index * 4 + 8)) & 0xF;
|
||||||
else
|
else
|
||||||
ep_status = (USBD->EPSTS2 >> ((ep_hw_index - 6) * 4)) & 0x7;
|
ep_status = (USBD->EPSTS2 >> ((ep_hw_index - 6) * 4)) & 0x7;
|
||||||
#elif defined(TARGET_M480) || defined(TARGET_M2351) || defined(TARGET_M261)
|
#elif defined(TARGET_M480) || defined(TARGET_M2351) || defined(TARGET_M261) || defined(TARGET_M460)
|
||||||
if(ep_hw_index < 8)
|
if(ep_hw_index < 8)
|
||||||
ep_status = (USBD->EPSTS0 >> (ep_hw_index * 4)) & 0xF;
|
ep_status = (USBD->EPSTS0 >> (ep_hw_index * 4)) & 0xF;
|
||||||
else
|
else
|
||||||
|
@ -808,6 +875,7 @@ void USBPhyHw::process()
|
||||||
|
|
||||||
extern "C" void USBD_IRQHandler(void)
|
extern "C" void USBD_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
// NVT_USB_Debug(("### %s[%d]\n", __FUNCTION__, __LINE__));
|
||||||
instance->events->start_process();
|
instance->events->start_process();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -823,7 +891,7 @@ static volatile int epComplete = 0;
|
||||||
#define EP_DIR_OUT 0x00
|
#define EP_DIR_OUT 0x00
|
||||||
#define EP_DIR_IN 0x80
|
#define EP_DIR_IN 0x80
|
||||||
|
|
||||||
#if defined (TARGET_M480)
|
#if defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
#define HSUSBD_GET_EP_MAX_PAYLOAD(ep) HSUSBD->EP[ep].EPMPS
|
#define HSUSBD_GET_EP_MAX_PAYLOAD(ep) HSUSBD->EP[ep].EPMPS
|
||||||
#define HSUSBD_GET_EP_DATA_COUNT(ep) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF)
|
#define HSUSBD_GET_EP_DATA_COUNT(ep) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF)
|
||||||
#define HSUSBD_SET_EP_SHORT_PACKET(ep) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10) | 0x40)
|
#define HSUSBD_SET_EP_SHORT_PACKET(ep) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10) | 0x40)
|
||||||
|
@ -843,7 +911,7 @@ static volatile uint32_t s_ep_buf_ind = 0;
|
||||||
static volatile uint32_t s_ep0_max_packet_size = 64;
|
static volatile uint32_t s_ep0_max_packet_size = 64;
|
||||||
static volatile uint8_t s_usb_addr = 0;
|
static volatile uint8_t s_usb_addr = 0;
|
||||||
|
|
||||||
#if defined (TARGET_M480)
|
#if defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
static volatile S_HSUSBD_CMD_T s_setup;
|
static volatile S_HSUSBD_CMD_T s_setup;
|
||||||
#elif defined (TARGET_NUC472)
|
#elif defined (TARGET_NUC472)
|
||||||
static volatile S_USBD_CMD_T s_setup;
|
static volatile S_USBD_CMD_T s_setup;
|
||||||
|
@ -879,7 +947,7 @@ void USBD_CtrlInput(void)
|
||||||
g_usb_CtrlInSize = 0;
|
g_usb_CtrlInSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
void HSUSBD_CtrlInput(void)
|
void HSUSBD_CtrlInput(void)
|
||||||
{
|
{
|
||||||
unsigned volatile i;
|
unsigned volatile i;
|
||||||
|
@ -954,7 +1022,7 @@ void USBPhyHw::init(USBPhyEvents *events)
|
||||||
NVIC_SetVector(USBD_IRQn, (uint32_t) &USBD_IRQHandler);
|
NVIC_SetVector(USBD_IRQn, (uint32_t) &USBD_IRQHandler);
|
||||||
NVIC_EnableIRQ(USBD_IRQn);
|
NVIC_EnableIRQ(USBD_IRQn);
|
||||||
|
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_ENABLE_PHY();
|
HSUSBD_ENABLE_PHY();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -985,7 +1053,7 @@ void USBPhyHw::deinit()
|
||||||
USBD_SET_SE0();
|
USBD_SET_SE0();
|
||||||
USBD_DISABLE_PHY();
|
USBD_DISABLE_PHY();
|
||||||
|
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
|
|
||||||
NVIC_DisableIRQ(USBD20_IRQn);
|
NVIC_DisableIRQ(USBD20_IRQn);
|
||||||
|
|
||||||
|
@ -1043,7 +1111,7 @@ void USBPhyHw::connect()
|
||||||
/* Clear SE0 (connect) */
|
/* Clear SE0 (connect) */
|
||||||
USBD_CLR_SE0();
|
USBD_CLR_SE0();
|
||||||
|
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_ResetDMA();
|
HSUSBD_ResetDMA();
|
||||||
HSUSBD_SET_ADDR(0);
|
HSUSBD_SET_ADDR(0);
|
||||||
|
|
||||||
|
@ -1081,7 +1149,7 @@ void USBPhyHw::disconnect()
|
||||||
/* Set SE0 (disconnect) */
|
/* Set SE0 (disconnect) */
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD_SET_SE0();
|
USBD_SET_SE0();
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SET_SE0();
|
HSUSBD_SET_SE0();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1175,7 @@ void USBPhyHw::sof_enable()
|
||||||
{
|
{
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD->BUSINTEN |= USBD_BUSINTEN_SOFIEN_Msk;
|
USBD->BUSINTEN |= USBD_BUSINTEN_SOFIEN_Msk;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->BUSINTEN |= HSUSBD_BUSINTEN_SOFIEN_Msk;
|
HSUSBD->BUSINTEN |= HSUSBD_BUSINTEN_SOFIEN_Msk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1117,7 +1185,7 @@ void USBPhyHw::sof_disable()
|
||||||
{
|
{
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD->BUSINTEN &= ~USBD_BUSINTEN_SOFIEN_Msk;
|
USBD->BUSINTEN &= ~USBD_BUSINTEN_SOFIEN_Msk;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->BUSINTEN &= ~HSUSBD_BUSINTEN_SOFIEN_Msk;
|
HSUSBD->BUSINTEN &= ~HSUSBD_BUSINTEN_SOFIEN_Msk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1133,7 +1201,7 @@ void USBPhyHw::remote_wakeup()
|
||||||
{
|
{
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD->OPER |= USBD_OPER_RESUMEEN_Msk;
|
USBD->OPER |= USBD_OPER_RESUMEEN_Msk;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->OPER |= HSUSBD_OPER_RESUMEEN_Msk;
|
HSUSBD->OPER |= HSUSBD_OPER_RESUMEEN_Msk;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1190,7 +1258,7 @@ void USBPhyHw::ep0_setup_read_result(uint8_t *buffer, uint32_t size)
|
||||||
s_setup.wValue = (uint16_t) USBD->SETUP3_2;
|
s_setup.wValue = (uint16_t) USBD->SETUP3_2;
|
||||||
s_setup.wIndex = (uint16_t) USBD->SETUP5_4;
|
s_setup.wIndex = (uint16_t) USBD->SETUP5_4;
|
||||||
s_setup.wLength = (uint16_t) USBD->SETUP7_6;
|
s_setup.wLength = (uint16_t) USBD->SETUP7_6;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
*((uint16_t *) (buffer + 0)) = (uint16_t) HSUSBD->SETUP1_0;
|
*((uint16_t *) (buffer + 0)) = (uint16_t) HSUSBD->SETUP1_0;
|
||||||
*((uint16_t *) (buffer + 2)) = (uint16_t) HSUSBD->SETUP3_2;
|
*((uint16_t *) (buffer + 2)) = (uint16_t) HSUSBD->SETUP3_2;
|
||||||
*((uint16_t *) (buffer + 4)) = (uint16_t) HSUSBD->SETUP5_4;
|
*((uint16_t *) (buffer + 4)) = (uint16_t) HSUSBD->SETUP5_4;
|
||||||
|
@ -1224,7 +1292,7 @@ void USBPhyHw::ep0_read(uint8_t *data, uint32_t size)
|
||||||
USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR);
|
USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR);
|
||||||
USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk|USBD_CEPINTEN_INTKIEN_Msk);
|
USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk|USBD_CEPINTEN_INTKIEN_Msk);
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if (s_setup.wLength && ! (s_setup.bmRequestType & 0x80))
|
if (s_setup.wLength && ! (s_setup.bmRequestType & 0x80))
|
||||||
{
|
{
|
||||||
/* Control OUT */
|
/* Control OUT */
|
||||||
|
@ -1256,7 +1324,7 @@ uint32_t USBPhyHw::ep0_read_result()
|
||||||
|
|
||||||
for (i = 0; i < ceprxcnt; i ++)
|
for (i = 0; i < ceprxcnt; i ++)
|
||||||
ep0_data[i] = USBD->CEPDAT_BYTE;
|
ep0_data[i] = USBD->CEPDAT_BYTE;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
uint32_t ceprxcnt = HSUSBD->CEPRXCNT;
|
uint32_t ceprxcnt = HSUSBD->CEPRXCNT;
|
||||||
|
|
||||||
for (i = 0; i < ceprxcnt; i ++)
|
for (i = 0; i < ceprxcnt; i ++)
|
||||||
|
@ -1283,7 +1351,7 @@ void USBPhyHw::ep0_write(uint8_t *buffer, uint32_t size)
|
||||||
USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR);
|
USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR);
|
||||||
USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk);
|
USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk);
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if (buffer && size)
|
if (buffer && size)
|
||||||
{
|
{
|
||||||
g_usbd_CtrlInPointer = buffer;
|
g_usbd_CtrlInPointer = buffer;
|
||||||
|
@ -1308,7 +1376,7 @@ void stallEndpoint(uint8_t endpoint)
|
||||||
return;
|
return;
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD_SetStall(ep_hw_index);
|
USBD_SetStall(ep_hw_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SetStall(ep_hw_index);
|
HSUSBD_SetStall(ep_hw_index);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1321,7 +1389,7 @@ void USBPhyHw::ep0_stall()
|
||||||
{
|
{
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD_SetStall(0);
|
USBD_SetStall(0);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SetStall(0);
|
HSUSBD_SetStall(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1435,7 @@ bool USBPhyHw::endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_
|
||||||
|
|
||||||
if (ep_dir != 0)
|
if (ep_dir != 0)
|
||||||
USBD_ENABLE_EP_INT(ep_hw_index, USBD_EPINTEN_TXPKIEN_Msk);
|
USBD_ENABLE_EP_INT(ep_hw_index, USBD_EPINTEN_TXPKIEN_Msk);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SetEpBufAddr(ep_hw_index, s_ep_buf_ind, max_packet);
|
HSUSBD_SetEpBufAddr(ep_hw_index, s_ep_buf_ind, max_packet);
|
||||||
s_ep_buf_ind += max_packet;
|
s_ep_buf_ind += max_packet;
|
||||||
HSUSBD_SET_MAX_PAYLOAD(ep_hw_index, max_packet);
|
HSUSBD_SET_MAX_PAYLOAD(ep_hw_index, max_packet);
|
||||||
|
@ -1402,7 +1470,7 @@ void USBPhyHw::endpoint_remove(usb_ep_t endpoint)
|
||||||
uint32_t ep_hw_index = NU_EPL2EPH(DESC_TO_LOG(endpoint));
|
uint32_t ep_hw_index = NU_EPL2EPH(DESC_TO_LOG(endpoint));
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
*((__IO uint32_t *) ((uint32_t)&USBD->EPACFG + (uint32_t)(ep_hw_index*0x28))) = (*((__IO uint32_t *)((uint32_t)&USBD->EPACFG+(uint32_t)(ep_hw_index*0x28))) & ~USB_EP_CFG_VALID);
|
*((__IO uint32_t *) ((uint32_t)&USBD->EPACFG + (uint32_t)(ep_hw_index*0x28))) = (*((__IO uint32_t *)((uint32_t)&USBD->EPACFG+(uint32_t)(ep_hw_index*0x28))) & ~USB_EP_CFG_VALID);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->EP[ep_hw_index].EPCFG = HSUSBD->EP[ep_hw_index].EPCFG & ~HSUSBD_EP_CFG_VALID;
|
HSUSBD->EP[ep_hw_index].EPCFG = HSUSBD->EP[ep_hw_index].EPCFG & ~HSUSBD_EP_CFG_VALID;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1420,7 +1488,7 @@ void USBPhyHw::endpoint_stall(usb_ep_t endpoint)
|
||||||
USBD_SetStall(0);
|
USBD_SetStall(0);
|
||||||
else
|
else
|
||||||
USBD_SetStall(ep_logic_index);
|
USBD_SetStall(ep_logic_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if(ep_logic_index == 0)
|
if(ep_logic_index == 0)
|
||||||
HSUSBD_SetEpStall(CEP);
|
HSUSBD_SetEpStall(CEP);
|
||||||
else
|
else
|
||||||
|
@ -1439,7 +1507,7 @@ void USBPhyHw::endpoint_unstall(usb_ep_t endpoint)
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
if(ep_logic_index != 0)
|
if(ep_logic_index != 0)
|
||||||
USBD_ClearStall(ep_logic_index);
|
USBD_ClearStall(ep_logic_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if(ep_logic_index != 0)
|
if(ep_logic_index != 0)
|
||||||
HSUSBD_ClearEpStall(ep_hw_index);
|
HSUSBD_ClearEpStall(ep_hw_index);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1455,7 +1523,7 @@ bool USBPhyHw::endpoint_read(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
read_sizes[ep_logic_index] = size;
|
read_sizes[ep_logic_index] = size;
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
USBD_ENABLE_EP_INT(ep_hw_index, USBD_GET_EP_INT_EN(ep_hw_index) | USBD_EPINTEN_RXPKIEN_Msk);
|
USBD_ENABLE_EP_INT(ep_hw_index, USBD_GET_EP_INT_EN(ep_hw_index) | USBD_EPINTEN_RXPKIEN_Msk);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_RXPKIEN_Msk;
|
HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_RXPKIEN_Msk;
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -1485,7 +1553,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
uint32_t mps = USBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
uint32_t mps = USBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
||||||
|
|
||||||
gEpReadCnt = USBD_GET_EP_DATA_COUNT(ep_hw_index);
|
gEpReadCnt = USBD_GET_EP_DATA_COUNT(ep_hw_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
uint32_t mps = HSUSBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
uint32_t mps = HSUSBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
||||||
|
|
||||||
gEpReadCnt = HSUSBD_GET_EP_DATA_COUNT(ep_hw_index);
|
gEpReadCnt = HSUSBD_GET_EP_DATA_COUNT(ep_hw_index);
|
||||||
|
@ -1512,7 +1580,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
break;
|
break;
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
||||||
break;
|
break;
|
||||||
else if (!HSUSBD_IS_ATTACHED())
|
else if (!HSUSBD_IS_ATTACHED())
|
||||||
|
@ -1524,7 +1592,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
USBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
USBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
||||||
USBD_SET_DMA_WRITE(ep_logic_index);
|
USBD_SET_DMA_WRITE(ep_logic_index);
|
||||||
USBD_ENABLE_DMA();
|
USBD_ENABLE_DMA();
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SET_DMA_LEN(len);
|
HSUSBD_SET_DMA_LEN(len);
|
||||||
HSUSBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
HSUSBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
||||||
HSUSBD_SET_DMA_WRITE(ep_logic_index);
|
HSUSBD_SET_DMA_WRITE(ep_logic_index);
|
||||||
|
@ -1538,7 +1606,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
break;
|
break;
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
||||||
break;
|
break;
|
||||||
else if (!HSUSBD_IS_ATTACHED())
|
else if (!HSUSBD_IS_ATTACHED())
|
||||||
|
@ -1568,7 +1636,7 @@ bool USBPhyHw::endpoint_read_result_core(usb_ep_t endpoint, uint8_t *data, uint3
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SET_DMA_LEN(len);
|
HSUSBD_SET_DMA_LEN(len);
|
||||||
HSUSBD_SET_DMA_ADDR(buffer);
|
HSUSBD_SET_DMA_ADDR(buffer);
|
||||||
HSUSBD_SET_DMA_WRITE(ep_logic_index);
|
HSUSBD_SET_DMA_WRITE(ep_logic_index);
|
||||||
|
@ -1603,7 +1671,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
{
|
{
|
||||||
#if defined (TARGET_NUC472)
|
#if defined (TARGET_NUC472)
|
||||||
uint32_t mps = USBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
uint32_t mps = USBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
uint32_t mps = HSUSBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
uint32_t mps = HSUSBD_GET_EP_MAX_PAYLOAD(ep_hw_index);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1617,7 +1685,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
USBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
USBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if(HSUSBD->EP[ep_hw_index].EPDATCNT & 0xFFFF)
|
if(HSUSBD->EP[ep_hw_index].EPDATCNT & 0xFFFF)
|
||||||
{
|
{
|
||||||
HSUSBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
HSUSBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
||||||
|
@ -1635,7 +1703,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
break;
|
break;
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
if (!(HSUSBD->DMACTL & HSUSBD_DMACTL_DMAEN_Msk))
|
||||||
break;
|
break;
|
||||||
else if (!HSUSBD_IS_ATTACHED())
|
else if (!HSUSBD_IS_ATTACHED())
|
||||||
|
@ -1664,7 +1732,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SET_DMA_LEN(len);
|
HSUSBD_SET_DMA_LEN(len);
|
||||||
HSUSBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
HSUSBD_SET_DMA_ADDR((uint32_t)tmp_buffer);
|
||||||
HSUSBD_SET_DMA_READ(ep_logic_index);
|
HSUSBD_SET_DMA_READ(ep_logic_index);
|
||||||
|
@ -1697,7 +1765,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
else if (!USBD_IS_ATTACHED())
|
else if (!USBD_IS_ATTACHED())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD_SET_DMA_LEN(len);
|
HSUSBD_SET_DMA_LEN(len);
|
||||||
HSUSBD_SET_DMA_ADDR((uint32_t)buffer);
|
HSUSBD_SET_DMA_ADDR((uint32_t)buffer);
|
||||||
HSUSBD_SET_DMA_READ(ep_logic_index);
|
HSUSBD_SET_DMA_READ(ep_logic_index);
|
||||||
|
@ -1716,7 +1784,7 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
|
||||||
if(g_usb_ShortPacket)
|
if(g_usb_ShortPacket)
|
||||||
USBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
USBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
||||||
USBD_ENABLE_EP_INT(ep_hw_index, USBD_GET_EP_INT_EN(ep_hw_index) | USBD_EPINTEN_TXPKIEN_Msk);
|
USBD_ENABLE_EP_INT(ep_hw_index, USBD_GET_EP_INT_EN(ep_hw_index) | USBD_EPINTEN_TXPKIEN_Msk);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
if(g_usb_ShortPacket)
|
if(g_usb_ShortPacket)
|
||||||
HSUSBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
HSUSBD_SET_EP_SHORT_PACKET(ep_hw_index);
|
||||||
HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_TXPKIEN_Msk;
|
HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_TXPKIEN_Msk;
|
||||||
|
@ -1734,7 +1802,7 @@ void USBPhyHw::endpoint_abort(usb_ep_t endpoint)
|
||||||
USBD_CLR_EP_INT(ep_hw_index, USBD_GET_EP_INT(ep_hw_index));
|
USBD_CLR_EP_INT(ep_hw_index, USBD_GET_EP_INT(ep_hw_index));
|
||||||
USBD_ENABLE_EP_INT(ep_hw_index, 0);
|
USBD_ENABLE_EP_INT(ep_hw_index, 0);
|
||||||
USBD_SET_EP_BUF_FLUSH(ep_hw_index);
|
USBD_SET_EP_BUF_FLUSH(ep_hw_index);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
HSUSBD->EP[ep_hw_index].EPINTEN = 0;
|
HSUSBD->EP[ep_hw_index].EPINTEN = 0;
|
||||||
HSUSBD->EP[ep_hw_index].EPINTSTS = HSUSBD->EP[ep_hw_index].EPINTSTS;
|
HSUSBD->EP[ep_hw_index].EPINTSTS = HSUSBD->EP[ep_hw_index].EPINTSTS;
|
||||||
HSUSBD->EP[ep_hw_index].EPRSPCTL = HSUSBD_EPRSPCTL_FLUSH_Msk;
|
HSUSBD->EP[ep_hw_index].EPRSPCTL = HSUSBD_EPRSPCTL_FLUSH_Msk;
|
||||||
|
@ -2045,7 +2113,7 @@ void USBPhyHw::process()
|
||||||
gintsts_epx = gintsts_epx >> 1;
|
gintsts_epx = gintsts_epx >> 1;
|
||||||
ep_hw_index++;
|
ep_hw_index++;
|
||||||
}
|
}
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
uint32_t gintsts = HSUSBD->GINTSTS & HSUSBD->GINTEN;
|
uint32_t gintsts = HSUSBD->GINTSTS & HSUSBD->GINTEN;
|
||||||
uint32_t gintsts_epx = gintsts >> 2; /* EPA, EPB, EPC, ... EPL interrupts */
|
uint32_t gintsts_epx = gintsts >> 2; /* EPA, EPB, EPC, ... EPL interrupts */
|
||||||
uint32_t ep_hw_index = 0;
|
uint32_t ep_hw_index = 0;
|
||||||
|
@ -2366,7 +2434,7 @@ extern "C" void USBD_IRQHandler(void)
|
||||||
|
|
||||||
NVIC_ClearPendingIRQ(USBD_IRQn);
|
NVIC_ClearPendingIRQ(USBD_IRQn);
|
||||||
NVIC_EnableIRQ(USBD_IRQn);
|
NVIC_EnableIRQ(USBD_IRQn);
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined (TARGET_M460)
|
||||||
NVIC_DisableIRQ(USBD20_IRQn);
|
NVIC_DisableIRQ(USBD20_IRQn);
|
||||||
|
|
||||||
instance->events->start_process();
|
instance->events->start_process();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#if defined(TARGET_M451)
|
#if defined(TARGET_M451)
|
||||||
#define NUMBER_OF_LOGICAL_ENDPOINTS (8)
|
#define NUMBER_OF_LOGICAL_ENDPOINTS (8)
|
||||||
#define NUMBER_OF_PHYSICAL_ENDPOINTS (NUMBER_OF_LOGICAL_ENDPOINTS)
|
#define NUMBER_OF_PHYSICAL_ENDPOINTS (NUMBER_OF_LOGICAL_ENDPOINTS)
|
||||||
#elif defined (TARGET_M480)
|
#elif defined (TARGET_M480) || defined(TARGET_M460)
|
||||||
#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 0)
|
#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 0)
|
||||||
#define NUMBER_OF_LOGICAL_ENDPOINTS (12)
|
#define NUMBER_OF_LOGICAL_ENDPOINTS (12)
|
||||||
#define NUMBER_OF_PHYSICAL_ENDPOINTS (NUMBER_OF_LOGICAL_ENDPOINTS)
|
#define NUMBER_OF_PHYSICAL_ENDPOINTS (NUMBER_OF_LOGICAL_ENDPOINTS)
|
||||||
|
|
|
@ -7428,6 +7428,10 @@
|
||||||
},
|
},
|
||||||
"hbi-mfp-reg-val-list": {
|
"hbi-mfp-reg-val-list": {
|
||||||
"help": "Comma separated multi-function pin register value list to enable HBI for HyperRAM"
|
"help": "Comma separated multi-function pin register value list to enable HBI for HyperRAM"
|
||||||
|
},
|
||||||
|
"usb-device-hsusbd": {
|
||||||
|
"help": "Select high-speed USB device or not",
|
||||||
|
"value": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"inherits": [
|
"inherits": [
|
||||||
|
@ -7463,7 +7467,8 @@
|
||||||
"MPU",
|
"MPU",
|
||||||
"WATCHDOG",
|
"WATCHDOG",
|
||||||
"RESET_REASON",
|
"RESET_REASON",
|
||||||
"EMAC"
|
"EMAC",
|
||||||
|
"USBDEVICE"
|
||||||
],
|
],
|
||||||
"components_add": [
|
"components_add": [
|
||||||
"FLASHIAP"
|
"FLASHIAP"
|
||||||
|
|
Loading…
Reference in New Issue