mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
[nuvoton] Update porting drivers and configurations.
This commit is contained in:
1 parent
9b44e57a60
commit
d74c785d00
34 files changed
+1618
-1272
No files matched your search
@@ -72,20 +72,32 @@ static nu_i2c_bus_t nu_i2c1 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -290,24 +302,28 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
SYS_LockReg();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1144,6 +1144,9 @@ void USBH_IRQHandler(void)
|
||||
TD_T *td, *td_prev, *td_next;
|
||||
uint32_t int_sts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
int_sts = _ohci->HcInterruptStatus;
|
||||
|
||||
//USB_debug("ohci int_sts = 0x%x\n", int_sts);
|
||||
@@ -1199,6 +1202,10 @@ void USBH_IRQHandler(void)
|
||||
}
|
||||
|
||||
_ohci->HcInterruptStatus = int_sts;
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG_MSG
|
||||
|
||||
@@ -81,20 +81,32 @@ static nu_i2c_bus_t nu_i2c2 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -354,33 +366,38 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#if defined(BSP_USING_I2C2)
|
||||
SYS_UnlockReg();
|
||||
SYS_ResetModule(I2C2_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c2);
|
||||
I2C_Close(nu_i2c2.I2C);
|
||||
I2C_Open(nu_i2c2.I2C, 100000);
|
||||
nu_i2c2.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c2.parent, nu_i2c2.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
SYS_LockReg();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1113,6 +1113,9 @@ void EHCI_IRQHandler(void)
|
||||
{
|
||||
uint32_t intsts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
intsts = _ehci->USTSR;
|
||||
_ehci->USTSR = intsts; /* clear interrupt status */
|
||||
|
||||
@@ -1136,6 +1139,9 @@ void EHCI_IRQHandler(void)
|
||||
{
|
||||
iaad_remove_qh();
|
||||
}
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
static UDEV_T *ehci_find_device_by_port(int port)
|
||||
|
||||
@@ -1154,6 +1154,9 @@ void OHCI_IRQHandler(void)
|
||||
TD_T *td, *td_prev, *td_next;
|
||||
uint32_t int_sts;
|
||||
|
||||
/* enter interrupt */
|
||||
rt_interrupt_enter();
|
||||
|
||||
int_sts = _ohci->HcInterruptStatus;
|
||||
|
||||
//USB_debug("ohci int_sts = 0x%x\n", int_sts);
|
||||
@@ -1209,6 +1212,9 @@ void OHCI_IRQHandler(void)
|
||||
}
|
||||
|
||||
_ohci->HcInterruptStatus = int_sts;
|
||||
|
||||
/* leave interrupt */
|
||||
rt_interrupt_leave();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DEBUG_MSG
|
||||
|
||||
@@ -81,20 +81,32 @@ static nu_i2c_bus_t nu_i2c2 =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -354,36 +366,38 @@ static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
int rt_hw_i2c_init(void)
|
||||
{
|
||||
rt_err_t ret = RT_ERROR;
|
||||
#if defined(BSP_USING_I2C0)
|
||||
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C0 clock */
|
||||
SYS_ResetModule(I2C0_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c0);
|
||||
|
||||
#if defined(BSP_USING_I2C0)
|
||||
I2C_Close(nu_i2c0.I2C);
|
||||
I2C_Open(nu_i2c0.I2C, 100000);
|
||||
nu_i2c0.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c0.parent, nu_i2c0.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C0 */
|
||||
|
||||
#if defined(BSP_USING_I2C1)
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C1 clock */
|
||||
SYS_ResetModule(I2C1_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c1);
|
||||
I2C_Close(nu_i2c1.I2C);
|
||||
I2C_Open(nu_i2c1.I2C, 100000);
|
||||
nu_i2c1.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c1.parent, nu_i2c1.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C1 */
|
||||
|
||||
#if defined(BSP_USING_I2C2)
|
||||
SYS_UnlockReg();
|
||||
/* Enable I2C2 clock */
|
||||
SYS_ResetModule(I2C2_RST);
|
||||
SYS_LockReg();
|
||||
nu_i2c_configure(&nu_i2c2);
|
||||
I2C_Close(nu_i2c2.I2C);
|
||||
I2C_Open(nu_i2c2.I2C, 100000);
|
||||
nu_i2c2.parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c2.parent, nu_i2c2.device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
#endif /* BSP_USING_I2C2 */
|
||||
|
||||
SYS_LockReg();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -297,6 +297,8 @@ static int ehci_init(void)
|
||||
_ehci->UCFGR = 0x1; /* enable port routing to EHCI */
|
||||
_ehci->UIENR = HSUSBH_UIENR_USBIEN_Msk | HSUSBH_UIENR_UERRIEN_Msk | HSUSBH_UIENR_HSERREN_Msk | HSUSBH_UIENR_IAAEN_Msk;
|
||||
|
||||
_ehci->UASSTR = 0xfff;
|
||||
|
||||
usbh_delay_ms(1); /* delay 1 ms */
|
||||
|
||||
_ehci->UPSCR[0] = HSUSBH_UPSCR_PP_Msk; /* enable port 1 port power */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -67,7 +67,7 @@ void usbh_core_init()
|
||||
#ifdef ENABLE_OHCI
|
||||
//sysInstallISR(IRQ_LEVEL_1, IRQ_OHCI, (PVOID)OHCI_IRQHandler);
|
||||
rt_hw_interrupt_install(IRQ_OHCI, nu_ohci_isr, NULL, "ohci");
|
||||
rt_hw_interrupt_set_priority(IRQ_OHCI, IRQ_LEVEL_1);
|
||||
//rt_hw_interrupt_set_priority(IRQ_OHCI, IRQ_LEVEL_1);
|
||||
|
||||
ohci_driver.init();
|
||||
ENABLE_OHCI_IRQ();
|
||||
@@ -76,7 +76,7 @@ void usbh_core_init()
|
||||
#ifdef ENABLE_EHCI
|
||||
//sysInstallISR(IRQ_LEVEL_1, IRQ_EHCI, (PVOID)EHCI_IRQHandler);
|
||||
rt_hw_interrupt_install(IRQ_EHCI, nu_ehci_isr, NULL, "ehci");
|
||||
rt_hw_interrupt_set_priority(IRQ_EHCI, IRQ_LEVEL_1);
|
||||
//rt_hw_interrupt_set_priority(IRQ_EHCI, IRQ_LEVEL_1);
|
||||
|
||||
ehci_driver.init();
|
||||
ENABLE_EHCI_IRQ();
|
||||
|
||||
@@ -244,6 +244,11 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
i2sIoctl(I2S_SET_I2S_FORMAT, I2S_FORMAT_I2S, 0);
|
||||
|
||||
if (psNuI2s->AcodecOps->role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pconfig->samplerate % 11025)
|
||||
{
|
||||
@@ -284,11 +289,6 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
// Set as master
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_MASTER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
|
||||
LOG_I("Open I2S.");
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ void rt_interrupt_dispatch(rt_uint32_t fiq_irq)
|
||||
isr_func = irq_desc[_mISNR].handler;
|
||||
param = irq_desc[_mISNR].param;
|
||||
|
||||
#ifdef RT_USING_INTERRUPT_INFO
|
||||
irq_desc[_mISNR].counter ++;
|
||||
#endif
|
||||
#ifdef RT_USING_INTERRUPT_INFO
|
||||
irq_desc[_mISNR].counter ++;
|
||||
#endif
|
||||
|
||||
/* Turn to interrupt service routine */
|
||||
isr_func(_mISNR, param);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,7 +40,7 @@ static rt_err_t nau8822_mixer_query(rt_uint32_t ui32Units, rt_uint32_t *ui32Valu
|
||||
nu_acodec_ops nu_acodec_ops_nau8822 =
|
||||
{
|
||||
.name = "NAU8822",
|
||||
.role = NU_ACODEC_ROLE_SLAVE,
|
||||
.role = NU_ACODEC_ROLE_MASTER,
|
||||
.config = { // Default settings.
|
||||
.samplerate = 16000,
|
||||
.channels = 2,
|
||||
@@ -117,6 +117,20 @@ static int I2C_WriteNAU8822(uint8_t u8addr, uint16_t u16data)
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static void nau8822_phonejack_set(S_NU_NAU8822_CONFIG *psCodecConfig, int bEnable)
|
||||
{
|
||||
rt_pin_mode(psCodecConfig->pin_phonejack_en, PIN_MODE_OUTPUT);
|
||||
|
||||
if (bEnable)
|
||||
{
|
||||
rt_pin_write(psCodecConfig->pin_phonejack_en, PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_pin_write(psCodecConfig->pin_phonejack_en, PIN_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static rt_err_t nau8822_probe(void)
|
||||
{
|
||||
@@ -180,8 +194,6 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
}
|
||||
u16AudIf = (u16AudIf & 0x19F) | (u8WLEN << 5);
|
||||
|
||||
I2C_WriteNAU8822(4, u16AudIf);
|
||||
|
||||
if (ui32SamplRate % 11025)
|
||||
{
|
||||
I2C_WriteNAU8822(36, 0x008); //12.288Mhz
|
||||
@@ -189,6 +201,10 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
I2C_WriteNAU8822(38, 0x093);
|
||||
I2C_WriteNAU8822(39, 0x0E9);
|
||||
|
||||
/* FIXME */
|
||||
if (ui32SamplRate > 48000)
|
||||
ui32SamplRate = 8000;
|
||||
|
||||
mClkDiv = (48000 * 256 * u8ChNum) / (ui32SamplRate * 256);
|
||||
bClkDiv = (ui32SamplRate * 256) / (ui32SamplRate * u8ChNum * u8SamplBit);
|
||||
}
|
||||
@@ -199,6 +215,10 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
I2C_WriteNAU8822(38, 0x161);
|
||||
I2C_WriteNAU8822(39, 0x026);
|
||||
|
||||
/* FIXME */
|
||||
if (ui32SamplRate > 44100)
|
||||
ui32SamplRate = 11025;
|
||||
|
||||
mClkDiv = (44100 * 256 * u8ChNum) / (ui32SamplRate * 256);
|
||||
bClkDiv = (ui32SamplRate * 256) / (ui32SamplRate * u8ChNum * u8SamplBit);
|
||||
}
|
||||
@@ -258,11 +278,16 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
u16ClkCtrl = (1 << 8) | (1 << 0); //Use internal PLL, FS/BCLK
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
u16ClkCtrl = (1 << 8) | (1 << 0); //Use internal PLL, FS/BCLK
|
||||
}
|
||||
|
||||
u16ClkCtrl = (u16ClkCtrl & 0x11F) | (mClkDiv << 5);
|
||||
u16ClkCtrl = (u16ClkCtrl & 0x1E3) | (bClkDiv << 2);
|
||||
|
||||
I2C_WriteNAU8822(4, u16AudIf);
|
||||
|
||||
I2C_WriteNAU8822(6, u16ClkCtrl);
|
||||
|
||||
return RT_EOK;
|
||||
@@ -271,27 +296,35 @@ static rt_err_t nau8822_dsp_config(rt_uint32_t ui32SamplRate, rt_uint8_t u8ChNum
|
||||
static rt_err_t nau8822_init(void)
|
||||
{
|
||||
//input source is MIC
|
||||
I2C_WriteNAU8822(1, 0x03F);
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
I2C_WriteNAU8822(1, 0x03F); /* PLLEN, MICBIASEN, ABIASEN, IOBUFEN, REFIMP(3kohm) */
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_WriteNAU8822(1, 0x01F); /* MICBIASEN, ABIASEN, IOBUFEN, REFIMP(3kohm) */
|
||||
}
|
||||
|
||||
I2C_WriteNAU8822(2, 0x1BF); /* Enable L/R Headphone, ADC Mix/Boost, ADC */
|
||||
I2C_WriteNAU8822(3, 0x07F); /* Enable L/R main mixer, DAC */
|
||||
I2C_WriteNAU8822(4, 0x010); /* 16-bit word length, I2S format, Stereo */
|
||||
I2C_WriteNAU8822(5, 0x000); /* Companding control and loop back mode (all disable) */
|
||||
nau8822_delay_ms(30);
|
||||
|
||||
if (nu_acodec_ops_nau8822.role == NU_ACODEC_ROLE_SLAVE)
|
||||
{
|
||||
I2C_WriteNAU8822(6, 0x1AD); /* Divide by 6, 16K */
|
||||
I2C_WriteNAU8822(7, 0x006); /* 16K for internal filter coefficients */
|
||||
}
|
||||
|
||||
I2C_WriteNAU8822(6, 0x1AD); /* Divide by 6, 16K */
|
||||
I2C_WriteNAU8822(7, 0x006); /* 16K for internal filter coefficients */
|
||||
I2C_WriteNAU8822(10, 0x008); /* DAC soft mute is disabled, DAC oversampling rate is 128x */
|
||||
I2C_WriteNAU8822(14, 0x108); /* ADC HP filter is disabled, ADC oversampling rate is 128x */
|
||||
I2C_WriteNAU8822(15, 0x1EF); /* ADC left digital volume control */
|
||||
I2C_WriteNAU8822(16, 0x1EF); /* ADC right digital volume control */
|
||||
I2C_WriteNAU8822(44, 0x033); /* LMICN/LMICP is connected to PGA */
|
||||
I2C_WriteNAU8822(49, 0x042);
|
||||
I2C_WriteNAU8822(47, 0x100); /* Gain value */
|
||||
I2C_WriteNAU8822(48, 0x100); /* Gain value */
|
||||
I2C_WriteNAU8822(50, 0x001); /* Left DAC connected to LMIX */
|
||||
I2C_WriteNAU8822(51, 0x001); /* Right DAC connected to RMIX */
|
||||
|
||||
I2C_WriteNAU8822(0x34, 0x13F);
|
||||
I2C_WriteNAU8822(0x35, 0x13F);
|
||||
|
||||
nu_acodec_ops_nau8822.config.samplerate = 16000;
|
||||
nu_acodec_ops_nau8822.config.channels = 2;
|
||||
@@ -326,10 +359,12 @@ static rt_err_t nau8822_mixer_control(rt_uint32_t ui32Units, rt_uint32_t ui32Val
|
||||
if (ui32Value)
|
||||
{
|
||||
I2C_WriteNAU8822(10, u16Data | (1 << 6));
|
||||
nau8822_phonejack_set(g_psCodecConfig, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
I2C_WriteNAU8822(10, u16Data & ~(1 << 6));
|
||||
nau8822_phonejack_set(g_psCodecConfig, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#if defined(NU_PKG_USING_BMX055)
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include "sensor_bmx055.h"
|
||||
|
||||
|
||||
@@ -29,6 +29,11 @@ menu "Nuvoton Packages Config"
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
config NU_PKG_USING_DA9062
|
||||
bool "DA9062 PMIC."
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
config NU_PKG_USING_ILI9341
|
||||
bool "ILI9341 LCD Panel"
|
||||
select BSP_USING_GPIO
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#if defined(NU_PKG_USING_MAX31875)
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "sensor.h"
|
||||
#include "max31875_c.h"
|
||||
|
||||
|
||||
@@ -498,7 +498,8 @@ rt_err_t rt_hw_mtd_spinand_init(void)
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
result = spinand_flash_init(SPINAND_FLASH_QSPI);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
if (result != RT_EOK)
|
||||
return -RT_ERROR;
|
||||
|
||||
for (i = 0; i < MTD_SPINAND_PARTITION_NUM; i++)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,48 @@
|
||||
const struct nu_spinand_info g_spinandflash_list[] =
|
||||
{
|
||||
/* Winbond */
|
||||
{ 0xEFAA21, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 1024, 64, 0, "Winbond 128MB: 2048+64@64@1024" }, /* Only tested */
|
||||
/* Only tested */
|
||||
{
|
||||
0xEFAA21, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 1024, 64, 0, "Winbond 128MB: 2048+64@64@1024",
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
{
|
||||
/* For storing Seal-byte at 0x37. Need 15-Bytes */
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x03, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
/* For storing Seal-byte at 0x37 and not report latest ECC part in Spare-3 */
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, /*0x38, 0x08,*/ 0xFF, 0x00
|
||||
}
|
||||
#else
|
||||
{
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x04, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, 0x38, 0x08, 0xFF, 0x00
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
{
|
||||
0xEFBF22, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 2048, 64, 0, "Winbond 256MB: 2048+64@64@2048",
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
{
|
||||
/* For storing Seal-byte at 0x39. Need 15-Bytes */
|
||||
0x08, 0x04, 0x18, 0x04, 0x28, 0x04, 0x38, 0x03, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
/* For storing Seal-byte at 0x39 and not report latest ECC part in Spare-3 */
|
||||
0x0C, 0x04, 0x1C, 0x04, 0x2C, 0x04, /*0x3C, 0x04,*/ 0xFF, 0x00
|
||||
}
|
||||
#else
|
||||
{
|
||||
0x08, 0x04, 0x18, 0x04, 0x28, 0x04, 0x38, 0x04, 0xFF, 0x00
|
||||
},
|
||||
{
|
||||
0x0C, 0x04, 0x1C, 0x04, 0x2C, 0x04, 0x3C, 0x04, 0xFF, 0x00
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
#if 0
|
||||
{ 0xEFAA22, 2048, 64, 0x6b, 0xff, 0xff, 0xff, 0x1, 2048, 64, 0, "Winbond 256MB: 2048+64@64@1024" },
|
||||
@@ -61,6 +102,7 @@ const struct nu_spinand_info g_spinandflash_list[] =
|
||||
|
||||
|
||||
/*
|
||||
========================================================
|
||||
For 0xEFAA21 description:
|
||||
|
||||
Data Area(2048-Byte)
|
||||
@@ -112,27 +154,66 @@ ECC Spare: ECC for spare 4-D.
|
||||
| 0 1 2 3 | 4 5 6 7 | 8 9 A B C D | E F |
|
||||
-----------------------------------------------
|
||||
| NO ECC | ECC PROTECTED | ECC 34-3D |
|
||||
|
||||
========================================================
|
||||
|
||||
========================================================
|
||||
For 0xEFBF22 description:
|
||||
|
||||
Data Area(2048-Byte)
|
||||
-----------------------------
|
||||
|Sect-0|Sect-1|Sect-2|Sect-3|
|
||||
|(512B)|(512B)|(512B)|(512B)|
|
||||
-----------------------------
|
||||
|
||||
Spare Area(64-Byte)
|
||||
---------------------------------
|
||||
|Spare-0|Spare-1|Spare-2|Spare-3|
|
||||
| (16B) | (16B) | (16B) | (16B) |
|
||||
---------------------------------
|
||||
|
||||
----------------- Spare-0 -------------------
|
||||
/ \
|
||||
-----------------------------------------
|
||||
| BBM | UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 | 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
-----------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
BBM: Bad block marker.
|
||||
UD1: User Data 1.
|
||||
UD2: User Data 2.
|
||||
ECC UD1: ECC for UD1.
|
||||
|
||||
---------------- Spare-1 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
---------------- Spare-2 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
---------------- Spare-3 -------------------
|
||||
/ \
|
||||
---------------------------------------
|
||||
| UD2 | UD1 | ECC UD1 |
|
||||
| 0 1 2 3 4 5 6 7 | 8 9 A B | C D E F |
|
||||
---------------------------------------
|
||||
| NO ECC | ECC PROTECTED |
|
||||
|
||||
========================================================
|
||||
*/
|
||||
|
||||
rt_uint8_t spinand_flash_data_layout[SPINAND_SPARE_LAYOUT_SIZE] =
|
||||
{
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
/* For storing Seal-byte at 0x37. */
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x03, 0xFF, 0x00
|
||||
#else
|
||||
0x04, 0x04, 0x14, 0x04, 0x24, 0x04, 0x34, 0x04, 0xFF, 0x00
|
||||
#endif
|
||||
};
|
||||
|
||||
rt_uint8_t spinand_flash_ecc_layout[SPINAND_SPARE_LAYOUT_SIZE] =
|
||||
{
|
||||
#if defined(RT_USING_DFS_UFFS)
|
||||
/* For storing Seal-byte at 0x37 and not report latest ECC part in Spare-3 */
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, /*0x38, 0x08,*/ 0xFF, 0x00
|
||||
#else
|
||||
0x08, 0x08, 0x18, 0x08, 0x28, 0x08, 0x38, 0x08, 0xFF, 0x00
|
||||
#endif
|
||||
};
|
||||
rt_uint8_t spinand_flash_data_layout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
rt_uint8_t spinand_flash_ecc_layout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
|
||||
static rt_err_t spinand_info_read(struct rt_qspi_device *qspi);
|
||||
|
||||
@@ -186,7 +267,6 @@ static rt_err_t spinand_program_dataload(
|
||||
uint8_t *pu8SpareBuff,
|
||||
uint32_t u32SpareCount)
|
||||
{
|
||||
uint32_t volatile i = 0;
|
||||
uint8_t u8WECmd = 0x06;
|
||||
rt_err_t result = RT_EOK;
|
||||
|
||||
@@ -667,6 +747,9 @@ static rt_err_t spinand_info_read(struct rt_qspi_device *qspi)
|
||||
{
|
||||
if (u32JedecId == g_spinandflash_list[i].u32JEDECID) /* Match JEDECID? */
|
||||
{
|
||||
rt_memcpy((void *)&spinand_flash_data_layout[0], (void *)&g_spinandflash_list[i].au8DataLayout[0], SPINAND_SPARE_LAYOUT_SIZE);
|
||||
rt_memcpy((void *)&spinand_flash_ecc_layout[0], (void *)&g_spinandflash_list[i].au8EccLayout[0], SPINAND_SPARE_LAYOUT_SIZE);
|
||||
|
||||
rt_memcpy(SPINAND_FLASH_INFO, &g_spinandflash_list[i], sizeof(struct nu_spinand_info));
|
||||
LOG_I("Found: [%08X] %s.", u32JedecId, SPINAND_FLASH_DESCRIPTION);
|
||||
|
||||
|
||||
@@ -19,24 +19,6 @@
|
||||
#include "drv_spi.h"
|
||||
#include <board.h>
|
||||
|
||||
/* SPI NAND flash information */
|
||||
struct nu_spinand_info
|
||||
{
|
||||
uint32_t u32JEDECID;
|
||||
uint16_t u16PageSize;
|
||||
uint16_t u16OOBSize;
|
||||
uint8_t u8QuadReadCmdId;
|
||||
uint8_t u8ReadStatusCmdId;
|
||||
uint8_t u8WriteStatusCmdid;
|
||||
uint8_t u8StatusValue;
|
||||
uint8_t u8DummyByte;
|
||||
uint32_t u32BlockPerFlash;
|
||||
uint32_t u32PagePerBlock;
|
||||
uint8_t u8IsDieSelect;
|
||||
const char *szDescription;
|
||||
};
|
||||
typedef struct nu_spinand_info *nu_spinand_info_t;
|
||||
|
||||
struct spinand_ops
|
||||
{
|
||||
rt_err_t (*block_erase)(struct rt_qspi_device *qspi, uint8_t u8Addr2, uint8_t u8Addr1, uint8_t u8Addr0);
|
||||
@@ -53,15 +35,6 @@ struct spinand_ops
|
||||
};
|
||||
typedef struct spinand_ops *nu_spinand_ops_t;
|
||||
|
||||
struct nu_spinand
|
||||
{
|
||||
struct nu_spinand_info info;
|
||||
struct rt_qspi_device *qspi_device;
|
||||
nu_spinand_ops_t ops;
|
||||
struct rt_mutex lock;
|
||||
};
|
||||
typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
#define SPINAND_FLASH_JEDECID g_spinandflash_dev.info.u32JEDECID
|
||||
#define SPINAND_FLASH_PAGE_SIZE g_spinandflash_dev.info.u16PageSize
|
||||
#define SPINAND_FLASH_OOB_SIZE g_spinandflash_dev.info.u16OOBSize
|
||||
@@ -82,6 +55,36 @@ typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
#define SPINAND_SPARE_LAYOUT_SIZE 16
|
||||
|
||||
/* SPI NAND flash information */
|
||||
struct nu_spinand_info
|
||||
{
|
||||
uint32_t u32JEDECID;
|
||||
uint16_t u16PageSize;
|
||||
uint16_t u16OOBSize;
|
||||
uint8_t u8QuadReadCmdId;
|
||||
uint8_t u8ReadStatusCmdId;
|
||||
uint8_t u8WriteStatusCmdid;
|
||||
uint8_t u8StatusValue;
|
||||
uint8_t u8DummyByte;
|
||||
uint32_t u32BlockPerFlash;
|
||||
uint32_t u32PagePerBlock;
|
||||
uint8_t u8IsDieSelect;
|
||||
const char *szDescription;
|
||||
|
||||
uint8_t au8DataLayout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
uint8_t au8EccLayout[SPINAND_SPARE_LAYOUT_SIZE];
|
||||
};
|
||||
typedef struct nu_spinand_info *nu_spinand_info_t;
|
||||
|
||||
struct nu_spinand
|
||||
{
|
||||
struct nu_spinand_info info;
|
||||
struct rt_qspi_device *qspi_device;
|
||||
nu_spinand_ops_t ops;
|
||||
struct rt_mutex lock;
|
||||
};
|
||||
typedef struct nu_spinand *nu_spinand_t;
|
||||
|
||||
rt_err_t rt_hw_mtd_spinand_register(const char *device_name);
|
||||
rt_size_t nu_qspi_transfer_message(struct rt_qspi_device *device, struct rt_qspi_message *message);
|
||||
rt_err_t nu_qspi_send_then_recv(struct rt_qspi_device *device, const void *send_buf, rt_size_t send_length, void *recv_buf, rt_size_t recv_length);
|
||||
|
||||
@@ -30,8 +30,8 @@ extern "C"
|
||||
*/
|
||||
|
||||
#define EMAC_PHY_ADDR 1UL /*!< PHY address, this address is board dependent \hideinitializer */
|
||||
#define EMAC_RX_DESC_SIZE 64UL /*!< Number of Rx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_TX_DESC_SIZE 32UL /*!< Number of Tx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_RX_DESC_SIZE 128UL /*!< Number of Rx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_TX_DESC_SIZE 64UL /*!< Number of Tx Descriptors, should be 2 at least \hideinitializer */
|
||||
#define EMAC_CAMENTRY_NB 16UL /*!< Number of CAM \hideinitializer */
|
||||
#define EMAC_MAX_PKT_SIZE 1536UL /*!< Number of HDR + EXTRA + VLAN_TAG + PAYLOAD + CRC \hideinitializer */
|
||||
|
||||
@@ -53,6 +53,8 @@ typedef struct
|
||||
uint32_t u32Next; /*!< Pointer to next descriptor */
|
||||
uint32_t u32Backup1; /*!< For backup descriptor fields over written by time stamp */
|
||||
uint32_t u32Backup2; /*!< For backup descriptor fields over written by time stamp */
|
||||
uint32_t u32Reserved1; /*!< For Reserved */
|
||||
uint32_t u32Reserved2; /*!< For Reserved */
|
||||
} EMAC_DESCRIPTOR_T;
|
||||
|
||||
/** Tx/Rx buffer structure */
|
||||
@@ -379,7 +381,8 @@ int32_t EMAC_FillCamEntry(EMAC_T *EMAC, uint8_t pu8MacAddr[]);
|
||||
uint8_t *EMAC_ClaimFreeTXBuf(EMAC_MEMMGR_T *psMemMgr);
|
||||
uint32_t EMAC_GetAvailRXBufSize(EMAC_MEMMGR_T *psMemMgr, uint8_t **ppuDataBuf);
|
||||
uint32_t EMAC_SendPktWoCopy(EMAC_MEMMGR_T *psMemMgr, uint32_t u32Size);
|
||||
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr);
|
||||
EMAC_DESCRIPTOR_T * EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr);
|
||||
void EMAC_RxTrigger(EMAC_MEMMGR_T *psMemMgr, EMAC_DESCRIPTOR_T * rx_desc);
|
||||
|
||||
/*@}*/ /* end of group EMAC_EXPORTED_FUNCTIONS */
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ static void EMAC_RxDescInit(EMAC_MEMMGR_T *psMemMgr)
|
||||
for (i = 0UL; i < psMemMgr->u32RxDescSize; i++)
|
||||
{
|
||||
psMemMgr->psRXDescs[i].u32Status1 = EMAC_DESC_OWN_EMAC;
|
||||
psMemMgr->psRXDescs[i].u32Data = (uint32_t)&psMemMgr->psRXFrames[i] | BIT31;
|
||||
psMemMgr->psRXDescs[i].u32Data = (uint32_t)&psMemMgr->psRXFrames[i];
|
||||
psMemMgr->psRXDescs[i].u32Status2 = 0UL;
|
||||
psMemMgr->psRXDescs[i].u32Next = (uint32_t)(&psMemMgr->psRXDescs[(i + 1UL) % EMAC_RX_DESC_SIZE]) | BIT31;
|
||||
psMemMgr->psRXDescs[i].u32Backup1 = psMemMgr->psRXDescs[i].u32Data;
|
||||
@@ -1129,25 +1129,37 @@ uint32_t EMAC_GetAvailRXBufSize(EMAC_MEMMGR_T *psMemMgr, uint8_t **ppuDataBuf)
|
||||
* @note Application can only call this function once every time \ref EMAC_RecvPkt or \ref EMAC_RecvPktTS returns 1
|
||||
* @note This function is without doing EMAC_TRIGGER_RX.
|
||||
*/
|
||||
void EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
||||
EMAC_DESCRIPTOR_T * EMAC_RecvPktDoneWoRxTrigger(EMAC_MEMMGR_T *psMemMgr)
|
||||
{
|
||||
/* Get Rx Frame Descriptor */
|
||||
EMAC_DESCRIPTOR_T *desc = (EMAC_DESCRIPTOR_T *)psMemMgr->psCurrentRxDesc;
|
||||
|
||||
EMAC_DESCRIPTOR_T *ret = desc;
|
||||
|
||||
/* Restore descriptor link list and data pointer they will be overwrite if time stamp enabled */
|
||||
desc->u32Data = desc->u32Backup1;
|
||||
desc->u32Next = desc->u32Backup2;
|
||||
|
||||
/* Change ownership to DMA for next use */
|
||||
desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
// desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
|
||||
/* Get Next Frame Descriptor pointer to process */
|
||||
desc = (EMAC_DESCRIPTOR_T *)desc->u32Next;
|
||||
|
||||
/* Save last processed Rx descriptor */
|
||||
psMemMgr->psCurrentRxDesc = desc;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EMAC_RxTrigger(EMAC_MEMMGR_T *psMemMgr, EMAC_DESCRIPTOR_T * rx_desc)
|
||||
{
|
||||
EMAC_T *EMAC = psMemMgr->psEmac;
|
||||
|
||||
rx_desc->u32Status1 |= EMAC_DESC_OWN_EMAC;
|
||||
|
||||
/* Trigger EMAC to send the packet */
|
||||
EMAC_TRIGGER_RX(EMAC);
|
||||
}
|
||||
|
||||
/*@}*/ /* end of group EMAC_EXPORTED_FUNCTIONS */
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include "nuc980.h"
|
||||
#include "nu_pdma.h"
|
||||
|
||||
|
||||
static uint8_t u32ChSelect[PDMA_CH_MAX];
|
||||
|
||||
/** @addtogroup Standard_Driver Standard Driver
|
||||
@{
|
||||
*/
|
||||
@@ -44,7 +41,6 @@ void PDMA_Open(PDMA_T *pdma, uint32_t u32Mask)
|
||||
if ((1 << i) & u32Mask)
|
||||
{
|
||||
pdma->DSCT[i].CTL = 0UL;
|
||||
u32ChSelect[i] = PDMA_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,54 +184,27 @@ void PDMA_SetTransferAddr(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32SrcAddr, uin
|
||||
*/
|
||||
void PDMA_SetTransferMode(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr)
|
||||
{
|
||||
u32ChSelect[u32Ch] = u32Peripheral;
|
||||
switch (u32Ch)
|
||||
if (u32Ch < PDMA_CH_MAX)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC0_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 1ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC1_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC1_Pos);
|
||||
break;
|
||||
case 2ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC2_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC2_Pos);
|
||||
break;
|
||||
case 3ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC3_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC3_Pos);
|
||||
break;
|
||||
case 4ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC4_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 5ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC5_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC5_Pos);
|
||||
break;
|
||||
case 6ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC6_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC6_Pos);
|
||||
break;
|
||||
case 7ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC7_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC7_Pos);
|
||||
break;
|
||||
case 8ul:
|
||||
pdma->REQSEL8_11 = (pdma->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC8_Msk) | u32Peripheral;
|
||||
break;
|
||||
case 9ul:
|
||||
pdma->REQSEL8_11 = (pdma->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC9_Msk) | (u32Peripheral << PDMA_REQSEL8_11_REQSRC9_Pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk;
|
||||
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
pau32REQSEL[u32Ch / 4] = (pau32REQSEL[u32Ch / 4] & ~u32REQSEL_Msk) | (u32Peripheral << u32REQSEL_Pos);
|
||||
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
}
|
||||
}
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set PDMA Burst Type and Size
|
||||
*
|
||||
@@ -310,45 +279,21 @@ void PDMA_DisableTimeout(PDMA_T *pdma, uint32_t u32Mask)
|
||||
*/
|
||||
void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt)
|
||||
{
|
||||
switch (u32Ch)
|
||||
if (u32Ch < PDMA_CH_MAX)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC0_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 1ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC1_Msk) | (u32TimeOutCnt << PDMA_TOC0_1_TOC1_Pos);
|
||||
break;
|
||||
case 2ul:
|
||||
pdma->TOC2_3 = (pdma->TOC2_3 & ~PDMA_TOC2_3_TOC2_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 3ul:
|
||||
pdma->TOC2_3 = (pdma->TOC2_3 & ~PDMA_TOC2_3_TOC3_Msk) | (u32TimeOutCnt << PDMA_TOC0_1_TOC1_Pos);
|
||||
break;
|
||||
case 4ul:
|
||||
pdma->TOC4_5 = (pdma->TOC4_5 & ~PDMA_TOC4_5_TOC4_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 5ul:
|
||||
pdma->TOC4_5 = (pdma->TOC4_5 & ~PDMA_TOC4_5_TOC5_Msk) | (u32TimeOutCnt << PDMA_TOC4_5_TOC5_Pos);
|
||||
break;
|
||||
case 6ul:
|
||||
pdma->TOC6_7 = (pdma->TOC6_7 & ~PDMA_TOC6_7_TOC6_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 7ul:
|
||||
pdma->TOC6_7 = (pdma->TOC6_7 & ~PDMA_TOC6_7_TOC7_Msk) | (u32TimeOutCnt << PDMA_TOC6_7_TOC7_Pos);
|
||||
break;
|
||||
case 8ul:
|
||||
pdma->TOC8_9 = (pdma->TOC8_9 & ~PDMA_TOC8_9_TOC8_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
case 9ul:
|
||||
pdma->TOC8_9 = (pdma->TOC8_9 & ~PDMA_TOC8_9_TOC9_Msk) | (u32TimeOutCnt << PDMA_TOC8_9_TOC9_Pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
__IO uint32_t *pau32TOC = (__IO uint32_t *)&pdma->TOC0_1;
|
||||
uint32_t u32TOC_Pos, u32TOC_Msk;
|
||||
|
||||
u32TOC_Pos = (u32Ch % 2) * 16 ;
|
||||
u32TOC_Msk = PDMA_TOC0_1_TOC0_Msk << u32TOC_Pos;
|
||||
pau32TOC[u32Ch / 2] = (pau32TOC[u32Ch / 2] & ~u32TOC_Msk) | (u32TimeOutCnt << u32TOC_Pos);
|
||||
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1 << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1 << u32Ch);
|
||||
}
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1 << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1 << u32Ch);
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -363,7 +308,15 @@ void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u
|
||||
*/
|
||||
void PDMA_Trigger(PDMA_T *pdma, uint32_t u32Ch)
|
||||
{
|
||||
if (u32ChSelect[u32Ch] == PDMA_MEM)
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk, u32ChReq;
|
||||
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
|
||||
u32ChReq = (pau32REQSEL[u32Ch / 4] & u32REQSEL_Msk) >> u32REQSEL_Pos;
|
||||
|
||||
if (u32ChReq == PDMA_MEM)
|
||||
{
|
||||
pdma->SWREQ = (1ul << u32Ch);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define DISABLE_EHCI_IRQ() rt_hw_interrupt_mask(IRQ_EHCI)
|
||||
#define IS_EHCI_IRQ_ENABLED() ((inpw(REG_AIC_INTMSK0)>>IRQ_EHCI) & 0x1)
|
||||
|
||||
//#define ENABLE_OHCI /* Enable OHCI host controller */
|
||||
#define ENABLE_OHCI /* Enable OHCI host controller */
|
||||
#define ENABLE_EHCI /* Enable EHCI host controller */
|
||||
|
||||
#define EHCI_PORT_CNT 2 /* Number of EHCI roothub ports */
|
||||
@@ -50,7 +50,7 @@
|
||||
unconditionally reclaim iTD/isTD scheduled
|
||||
in just elapsed EHCI_ISO_RCLM_RANGE ms. */
|
||||
|
||||
#define MAX_DESC_BUFF_SIZE 1024 /* To hold the configuration descriptor, USB
|
||||
#define MAX_DESC_BUFF_SIZE 4096 /* To hold the configuration descriptor, USB
|
||||
core will allocate a buffer with this size
|
||||
for each connected device. USB core does
|
||||
not release it until device disconnected. */
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -100,20 +100,32 @@ static nu_i2c_bus_t nu_i2c_arr [ ] =
|
||||
static rt_size_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
|
||||
struct rt_i2c_msg msgs[],
|
||||
rt_uint32_t num);
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus,
|
||||
rt_uint32_t u32Cmd,
|
||||
rt_uint32_t u32Value);
|
||||
|
||||
static const struct rt_i2c_bus_device_ops nu_i2c_ops =
|
||||
{
|
||||
.master_xfer = nu_i2c_mst_xfer,
|
||||
.slave_xfer = NULL,
|
||||
.i2c_bus_control = NULL,
|
||||
.i2c_bus_control = nu_i2c_bus_control
|
||||
};
|
||||
|
||||
static rt_err_t nu_i2c_configure(nu_i2c_bus_t *bus)
|
||||
static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, rt_uint32_t u32Cmd, rt_uint32_t u32Value)
|
||||
{
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c_bus_t *nu_i2c;
|
||||
|
||||
bus->parent.ops = &nu_i2c_ops;
|
||||
I2C_Open(bus->I2C, 100000);
|
||||
RT_ASSERT(bus != RT_NULL);
|
||||
nu_i2c = (nu_i2c_bus_t *) bus;
|
||||
|
||||
switch (RT_I2C_DEV_CTRL_CLK)
|
||||
{
|
||||
case RT_I2C_DEV_CTRL_CLK:
|
||||
I2C_SetBusClockFreq(nu_i2c->I2C, u32Value);
|
||||
break;
|
||||
default:
|
||||
return -RT_EIO;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
@@ -376,11 +388,14 @@ int rt_hw_i2c_init(void)
|
||||
|
||||
for (i = (I2C_START + 1); i < I2C_CNT; i++)
|
||||
{
|
||||
|
||||
nu_sys_ipclk_enable(nu_i2c_arr[i].clkidx);
|
||||
nu_sys_ip_reset(nu_i2c_arr[i].rstidx);
|
||||
|
||||
nu_i2c_configure(&nu_i2c_arr[i]);
|
||||
/* Reset and initial IP engine. */
|
||||
I2C_Close(nu_i2c_arr[i].I2C);
|
||||
I2C_Open(nu_i2c_arr[i].I2C, 100000);
|
||||
nu_i2c_arr[i].parent.ops = &nu_i2c_ops;
|
||||
|
||||
ret = rt_i2c_bus_device_register(&nu_i2c_arr[i].parent, nu_i2c_arr[i].device_name);
|
||||
RT_ASSERT(RT_EOK == ret);
|
||||
}
|
||||
|
||||
@@ -244,6 +244,11 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
i2sIoctl(I2S_SET_I2S_FORMAT, I2S_FORMAT_I2S, 0);
|
||||
|
||||
if (psNuI2s->AcodecOps->role == NU_ACODEC_ROLE_MASTER)
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pconfig->samplerate % 11025)
|
||||
{
|
||||
@@ -284,11 +289,6 @@ static rt_err_t nu_i2s_dai_setup(nu_i2s_t psNuI2s, struct rt_audio_configure *pc
|
||||
// Set as master
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_MASTER, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set as slave, source clock is XIN (12MHz)
|
||||
i2sIoctl(I2S_SET_MODE, I2S_MODE_SLAVE, 0);
|
||||
}
|
||||
|
||||
LOG_I("Open I2S.");
|
||||
|
||||
|
||||
@@ -302,7 +302,6 @@ E_SYS_USB0_ID nu_sys_usb0_role(void)
|
||||
#ifdef RT_USING_FINSH
|
||||
|
||||
#include <finsh.h>
|
||||
FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_cpu_reset, reset, restart the system);
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
int cmd_reset(int argc, char **argv)
|
||||
|
||||
@@ -30,6 +30,21 @@
|
||||
|
||||
#define NU_MAX_USBH_HUB_PORT_DEV USB_HUB_PORT_NUM
|
||||
|
||||
#define NU_USBHOST_MUTEX_INIT() { \
|
||||
s_sUSBHDev.lock = rt_mutex_create("usbhost_lock", RT_IPC_FLAG_PRIO); \
|
||||
RT_ASSERT(s_sUSBHDev.lock != RT_NULL); \
|
||||
}
|
||||
|
||||
#define NU_USBHOST_LOCK() { \
|
||||
rt_err_t result = rt_mutex_take(s_sUSBHDev.lock, RT_WAITING_FOREVER); \
|
||||
RT_ASSERT(result == RT_EOK); \
|
||||
}
|
||||
|
||||
#define NU_USBHOST_UNLOCK() { \
|
||||
rt_err_t result = rt_mutex_release(s_sUSBHDev.lock); \
|
||||
RT_ASSERT(result == RT_EOK); \
|
||||
}
|
||||
|
||||
/* Private typedef --------------------------------------------------------------*/
|
||||
typedef struct nu_port_dev
|
||||
{
|
||||
@@ -59,6 +74,7 @@ struct nu_usbh_dev
|
||||
E_SYS_IPRST rstidx;
|
||||
E_SYS_IPCLK clkidx;
|
||||
rt_thread_t polling_thread;
|
||||
rt_mutex_t lock;
|
||||
S_NU_RH_PORT_CTRL asPortCtrl[NU_MAX_USBH_PORT];
|
||||
};
|
||||
|
||||
@@ -398,15 +414,25 @@ static int nu_bulk_xfer(
|
||||
UTR_T *psUTR,
|
||||
int timeouts)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = usbh_bulk_xfer(psUTR);
|
||||
|
||||
int ret = usbh_bulk_xfer(psUTR);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
//wait transfer done
|
||||
rt_completion_wait(&(psPortDev->utr_completion), timeouts);
|
||||
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) < 0)
|
||||
{
|
||||
rt_kprintf("Request Timeout in %d ms!! (bulk_xfer)\n", timeouts);
|
||||
|
||||
rt_kprintf("psUTR->buff: %08x\n", psUTR->buff);
|
||||
rt_kprintf("psUTR->data_len: %d\n", psUTR->data_len);
|
||||
rt_kprintf("psUTR->xfer_len: %d\n", psUTR->xfer_len);
|
||||
rt_kprintf("psUTR->ep: %08x\n", psUTR->ep);
|
||||
rt_kprintf("psUTR->bIsTransferDone: %08x\n", psUTR->bIsTransferDone);
|
||||
rt_kprintf("psUTR->status: %08x\n", psUTR->status);
|
||||
rt_kprintf("psUTR->td_cnt: %08x\n", psUTR->td_cnt);
|
||||
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -477,6 +503,8 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
|
||||
void *buffer_nonch = buffer;
|
||||
|
||||
NU_USBHOST_LOCK();
|
||||
|
||||
psPortCtrl = GetRHPortControlFromPipe(pipe);
|
||||
if (psPortCtrl == RT_NULL)
|
||||
{
|
||||
@@ -494,8 +522,11 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
if (buffer_nonch && nbytes)
|
||||
{
|
||||
buffer_nonch = psPortDev->asPipePktBuf[pipe->pipe_index];
|
||||
rt_memcpy(buffer_nonch, buffer, nbytes);
|
||||
mmu_clean_invalidated_dcache((uint32_t)buffer_nonch, nbytes);
|
||||
if ((pipe->ep.bEndpointAddress & USB_DIR_MASK) == USB_DIR_OUT)
|
||||
{
|
||||
rt_memcpy(buffer_nonch, buffer, nbytes);
|
||||
mmu_clean_dcache((uint32_t)buffer_nonch, nbytes);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -503,6 +534,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
if (pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (token == USBH_PID_SETUP)
|
||||
{
|
||||
struct urequest *psSetup = (struct urequest *)buffer_nonch;
|
||||
@@ -517,7 +549,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
else
|
||||
{
|
||||
/* Write data to USB device. */
|
||||
//Trigger USBHostLib Ctril_Xfer
|
||||
//Trigger USBHostLib Ctrl_Xfer
|
||||
ret = nu_ctrl_xfer(psPortDev, psSetup, NULL, timeouts);
|
||||
if (ret != psSetup->wLength)
|
||||
goto exit_nu_pipe_xfer;
|
||||
@@ -571,7 +603,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
if (nu_bulk_xfer(psPortDev, psUTR, timeouts) < 0)
|
||||
{
|
||||
RT_DEBUG_LOG(RT_DEBUG_USB, ("nu_pipe_xfer ERROR: bulk transfer failed\n"));
|
||||
goto exit_nu_pipe_xfer;
|
||||
goto failreport_nu_pipe_xfer;
|
||||
}
|
||||
}
|
||||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_INT)
|
||||
@@ -588,7 +620,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
{
|
||||
i32XferLen = nbytes;
|
||||
}
|
||||
return i32XferLen;
|
||||
goto exit2_nu_pipe_xfer;
|
||||
}
|
||||
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
|
||||
{
|
||||
@@ -599,6 +631,8 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
|
||||
} //else
|
||||
|
||||
failreport_nu_pipe_xfer:
|
||||
|
||||
if (psUTR->bIsTransferDone == 0)
|
||||
{
|
||||
//Timeout
|
||||
@@ -628,29 +662,29 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
|
||||
//Call callback
|
||||
if (pipe->callback != RT_NULL)
|
||||
{
|
||||
struct uhost_msg msg;
|
||||
msg.type = USB_MSG_CALLBACK;
|
||||
msg.content.cb.function = pipe->callback;
|
||||
msg.content.cb.context = pipe->user_data;
|
||||
rt_usbh_event_signal(&msg);
|
||||
pipe->callback(pipe);
|
||||
}
|
||||
|
||||
if (pipe->status != UPIPE_STATUS_OK)
|
||||
goto exit_nu_pipe_xfer;
|
||||
|
||||
exit_nu_pipe_xfer:
|
||||
|
||||
if (psUTR)
|
||||
free_utr(psUTR);
|
||||
|
||||
exit2_nu_pipe_xfer:
|
||||
|
||||
#if defined(BSP_USING_MMU)
|
||||
if ((nbytes) &&
|
||||
(buffer_nonch != buffer))
|
||||
{
|
||||
mmu_invalidate_dcache((uint32_t)buffer_nonch, nbytes);
|
||||
rt_memcpy(buffer, buffer_nonch, nbytes);
|
||||
if ((pipe->ep.bEndpointAddress & USB_DIR_MASK) == USB_DIR_IN)
|
||||
{
|
||||
mmu_invalidate_dcache((uint32_t)buffer_nonch, nbytes);
|
||||
rt_memcpy(buffer, buffer_nonch, nbytes);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (psUTR)
|
||||
free_utr(psUTR);
|
||||
NU_USBHOST_UNLOCK();
|
||||
|
||||
return i32XferLen;
|
||||
}
|
||||
@@ -660,7 +694,10 @@ static void nu_usbh_rh_thread_entry(void *parameter)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
NU_USBHOST_LOCK();
|
||||
usbh_polling_root_hubs();
|
||||
NU_USBHOST_UNLOCK();
|
||||
|
||||
rt_thread_mdelay(NU_USBHOST_HUB_POLLING_INTERVAL);
|
||||
}
|
||||
}
|
||||
@@ -871,6 +908,8 @@ int nu_usbh_register(void)
|
||||
psUHCD->ops = &nu_uhcd_ops;
|
||||
psUHCD->num_ports = NU_MAX_USBH_PORT;
|
||||
|
||||
NU_USBHOST_MUTEX_INIT();
|
||||
|
||||
res = rt_device_register(&psUHCD->parent, "usbh", RT_DEVICE_FLAG_DEACTIVATE);
|
||||
RT_ASSERT(res == RT_EOK);
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user