Initial import of NFC GNSS SDK project
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
MODULE := usb
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "reg.h"
|
||||
#include "syscall-arom.h"
|
||||
#include "usb_serial.h"
|
||||
|
||||
/* Ep address used by use serial device */
|
||||
#define EPIN 0x81
|
||||
#define USB_DIR_OUT 0 /* to device */
|
||||
#define USB_DIR_IN 0x80 /* to host */
|
||||
#define EP_HW_NUM(addr) ((addr) & 0x7f)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if AROM_VERSION == AROM_VER_2024_04_30_LAPWING_CR5
|
||||
#define USB_REG_BASE 0xC0000000
|
||||
#define DWC3_DALEPENA (USB_REG_BASE + 0xC720)
|
||||
#define DWC3_DALEPENA_EP(n) (1 << n)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned int
|
||||
dwc3_get_ep_hardware_num(unsigned char addr)
|
||||
{
|
||||
return 2 * EP_HW_NUM(addr) + ((addr & USB_DIR_IN) >> 7);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#else
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define USB_REG_BASE 0xD4208000
|
||||
#define EP_CTRL(X) (USB_REG_BASE + 0x1C0 + 4 * (X))
|
||||
#define CTRL_RXE (1 << 7)
|
||||
#define CTRL_TXE (1 << 23)
|
||||
#endif /* AROM_VERSION == AROM_VER_2024_04_30_LAPWING_CR5 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static bool
|
||||
ep_is_enabled(unsigned addr)
|
||||
{
|
||||
#if AROM_VERSION == AROM_VER_2024_04_30_LAPWING_CR5
|
||||
unsigned ep_num = dwc3_get_ep_hardware_num(addr);
|
||||
return (readl(DWC3_DALEPENA) & DWC3_DALEPENA_EP(ep_num));
|
||||
#else
|
||||
uint32_t val = readl(EP_CTRL(EP_HW_NUM(addr)));
|
||||
return (addr & USB_DIR_IN) ? (val & CTRL_TXE) : (val & CTRL_RXE);
|
||||
#endif /* AROM_VERSION == AROM_VER_2024_04_30_LAPWING_CR5 */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* When the enumeration is complete, the bulk eps are enabled(in the setting
|
||||
* configuration phase). Determine whether enumeration is complete by checking
|
||||
* if the bulk ep is enabled.
|
||||
*/
|
||||
bool
|
||||
usb_enumeration_is_complete(void)
|
||||
{
|
||||
return ep_is_enabled(EPIN);
|
||||
}
|
||||
Reference in New Issue
Block a user