[bsp][nuvoton][rsoc] Fix compilation issues with bsp of nuvoton series

This commit is contained in:
hydevcode
2024-09-27 20:49:04 +08:00
committed by Meco Man
parent e6a3b30993
commit e7e44ec7e8
47 changed files with 9109 additions and 831 deletions

View File

@@ -238,6 +238,21 @@ jobs:
- "renesas/rzn2l_rsk"
- "frdm-k64f"
- "xplorer4330/M4"
- RTT_BSP: "nuvoton"
RTT_TOOL_CHAIN: "sourcery-arm"
SUB_RTT_BSP:
- "nuvoton/numaker-pfm-m487"
- "nuvoton/numaker-hmi-ma35d1"
- "nuvoton/numaker-iot-m487"
- "nuvoton/numaker-m032ki"
- "nuvoton/numaker-iot-m467"
- "nuvoton/numaker-m467hj"
- "nuvoton/nk-n9h30"
- "nuvoton/nk-rtu980"
- "nuvoton/ma35-rtp"
- "nuvoton/nk-980iot"
- "nuvoton/numaker-iot-ma35d1"
- "nuvoton/numaker-m2354"
- RTT_BSP: "gd32_n32_apm32"
RTT_TOOL_CHAIN: "sourcery-arm"
SUB_RTT_BSP:

View File

@@ -270,7 +270,19 @@ jobs:
# - {RTT_BSP_NAME: "yichip_yc3121-pos", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "yichip/yc3121-pos"} #编译问题
# - {RTT_BSP_NAME: "yichip_yc3122-pos", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "yichip/yc3122-pos"} #编译问题
- {RTT_BSP_NAME: "zynqmp-r5-axu4ev", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "zynqmp-r5-axu4ev"}
- {RTT_BSP_NAME: "nuvoton_numaker-pfm-m487", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-pfm-m487"}
- {RTT_BSP_NAME: "nuvoton_numaker-hmi-ma35d1", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-hmi-ma35d1"}
- {RTT_BSP_NAME: "nuvoton_numaker-iot-m487", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-iot-m487"}
- {RTT_BSP_NAME: "nuvoton_numaker-m032ki", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-m032ki"}
- {RTT_BSP_NAME: "nuvoton_numaker-iot-m467", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-iot-m467"}
- {RTT_BSP_NAME: "nuvoton_numaker-m467hj", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-m467hj"}
- {RTT_BSP_NAME: "nuvoton_nk-n9h30", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/nk-n9h30"}
- {RTT_BSP_NAME: "nuvoton_nk-rtu980", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/nk-rtu980"}
- {RTT_BSP_NAME: "nuvoton_ma35-rtp", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/ma35-rtp"}
- {RTT_BSP_NAME: "nuvoton_nk-980iot", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/nk-980iot"}
- {RTT_BSP_NAME: "nuvoton_numaker-iot-ma35d1", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-iot-ma35d1"}
- {RTT_BSP_NAME: "nuvoton_numaker-m2354 ", RTT_TOOL_CHAIN: "sourcery-arm", RTT_BSP: "nuvoton/numaker-m2354"}
steps:
- uses: actions/checkout@v4
- name: Set up Python

View File

@@ -30,8 +30,8 @@ struct nu_adc
typedef struct nu_adc *nu_adc_t;
/* Private functions ------------------------------------------------------------*/
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
/* Public functions ------------------------------------------------------------*/
int rt_hw_adc_init(void);
@@ -60,7 +60,7 @@ typedef struct rt_adc_ops *rt_adc_ops_t;
/* nu_adc_enabled - Enable ADC clock and wait for ready */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
{
ADC_T *adc_base = ((nu_adc_t)device)->adc_base;
@@ -96,7 +96,7 @@ static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel
return RT_EOK;
}
static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
{
RT_ASSERT(device != RT_NULL);
@@ -111,7 +111,7 @@ static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_uint32_t chann
return -(RT_EINVAL);
}
if ((*padc_reg_tab & (1 << channel)) == 0)
if ((*padc_reg_tab & (0x1 << channel)) == 0)
{
*value = 0xFFFFFFFF;
return -(RT_EBUSY);
@@ -127,7 +127,7 @@ static rt_err_t nu_get_adc_value(struct rt_adc_device *device, rt_uint32_t chann
while (ADC_GET_INT_FLAG(adc_base, ADC_ADF_INT) == 0);
*value = ADC_GET_CONVERSION_DATA(adc_base, channel);
*value = ADC_GET_CONVERSION_DATA(adc_base,channel);
return RT_EOK;
}
@@ -151,4 +151,4 @@ int rt_hw_adc_init(void)
INIT_BOARD_EXPORT(rt_hw_adc_init);
#endif //#if defined(BSP_USING_ADC)
#endif /* #if defined(BSP_USING_ADC) */

View File

@@ -117,13 +117,6 @@ void SysTick_Handler(void)
rt_interrupt_leave();
}
void rt_hw_cpu_reset(void)
{
SYS_UnlockReg();
SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
}
#ifdef RT_USING_CPU_FFS
int __rt_ffs(int value)
{
@@ -136,7 +129,9 @@ int __rt_ffs(int value)
#include <finsh.h>
static void reboot(uint8_t argc, char **argv)
{
rt_hw_cpu_reset();
SYS_UnlockReg();
SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
}
MSH_CMD_EXPORT(reboot, Reboot System);
#endif /* RT_USING_FINSH */

View File

@@ -101,9 +101,9 @@ static void soft_time_setup(uint32_t wanted_sec, uint32_t hz, soft_time_handle_t
static void soft_time_feed_dog(soft_time_handle_t *const soft_time);
#if defined(RT_USING_PM)
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode);
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static void soft_time_freqeucy_change(uint32_t new_hz, soft_time_handle_t *const soft_time);
#endif
@@ -132,7 +132,7 @@ static struct rt_device_pm_ops device_pm_ops =
#if defined(RT_USING_PM)
/* device pm suspend() entry. */
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
{
switch (mode)
{
@@ -184,7 +184,7 @@ static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode)
/* device pm frequency_change() entry. */
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
{
uint32_t clk, new_hz;

View File

@@ -29,7 +29,7 @@
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
#endif
#define NU_MAX_USBH_PORT 1 //USB1.1 port
#define NU_MAX_USBH_PORT 1 /* USB1.1 port */
#define NU_MAX_USBH_PIPE 16
#define NU_USBH_THREAD_STACK_SIZE 2048
@@ -37,17 +37,20 @@
#define NU_USBHOST_HUB_POLLING_LOCK
#if defined(NU_USBHOST_HUB_POLLING_LOCK)
#define NU_USBHOST_MUTEX_INIT() { \
#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() { \
#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() { \
#define NU_USBHOST_UNLOCK() \
{ \
rt_err_t result = rt_mutex_release(s_sUSBHDev.lock); \
RT_ASSERT(result == RT_EOK); \
}
@@ -57,7 +60,7 @@
#define NU_USBHOST_UNLOCK()
#endif
/* Private typedef --------------------------------------------------------------*/
/* Private typedef -------------------------------------------------------------- */
typedef struct nu_port_dev
{
rt_bool_t bRHParent;
@@ -86,7 +89,7 @@ struct nu_usbh_dev
S_NU_RH_PORT_CTRL asPortCtrl[NU_MAX_USBH_PORT];
};
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static struct nu_usbh_dev s_sUSBHDev;
static S_NU_RH_PORT_CTRL *
@@ -97,13 +100,13 @@ GetRHPortControlFromPipe(
int port;
if (pipe->inst->parent_hub->is_roothub)
{
//case: device ---> root hub
/* case: device ---> root hub */
inst = pipe->inst;
port = inst->port;
}
else
{
//case: device ---> hub ---> root hub
/* case: device ---> hub ---> root hub */
inst = pipe->inst->parent_hub->self;
port = inst->port;
}
@@ -129,11 +132,11 @@ GetPortDevFromPipe(
if (pipe->inst->parent_hub->is_roothub)
{
//case: device ---> root hub
/* case: device ---> root hub */
return &psRHPortCtrl->sRHPortDev;
}
//case: device ---> hub ---> root hub
/* case: device ---> hub ---> root hub */
for (i = 0 ; i < NU_MAX_USBH_HUB_PORT_DEV; i ++)
{
if (psRHPortCtrl->asHubPortDev[i].port_num == pipe->inst->port)
@@ -263,7 +266,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
if ((psPortDev == NULL) || (psPortDev->pUDev == NULL))
{
//allocate new dev for hub device
/* allocate new dev for hub device */
psPortDev = AllocateNewUDev(psPortCtrl);
if (psPortDev == RT_NULL)
@@ -288,7 +291,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
psPortDev->bEnumDone = FALSE;
}
//For ep0 control transfer
/* For ep0 control transfer */
if ((pipe->ep.bEndpointAddress & 0x7F) == 0)
{
pipe->pipe_index = 0;
@@ -336,7 +339,7 @@ static rt_err_t nu_close_pipe(upipe_t pipe)
psPortDev = GetPortDevFromPipe(pipe);
//For ep0 control transfer
/* For ep0 control transfer */
if ((pipe->ep.bEndpointAddress & 0x7F) == 0)
{
if ((psPortDev) && (psPortDev->bRHParent == FALSE) && (psPortDev->bEnumDone == TRUE))
@@ -407,7 +410,7 @@ static int nu_bulk_xfer(
if (ret < 0)
return ret;
//wait transfer done
/* wait transfer done */
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) < 0)
{
rt_kprintf("Request Timeout in %d ms!! (bulk_xfer)\n", timeouts);
@@ -462,7 +465,7 @@ static void xfer_done_cb(UTR_T *psUTR)
{
S_NU_PORT_DEV *psPortDev = (S_NU_PORT_DEV *)psUTR->context;
//transfer done, signal utr_completion
/* transfer done, signal utr_completion */
rt_completion_done(&(psPortDev->utr_completion));
}
@@ -490,7 +493,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
goto exit_nu_pipe_xfer;
}
//ctrl xfer
/* ctrl xfer */
if (pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL)
{
int ret;
@@ -504,13 +507,13 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
/* Read data from USB device. */
if (psSetup->request_type & USB_REQ_TYPE_DIR_IN)
{
//Store setup request
/* Store setup request */
rt_memcpy(&psPortCtrl->asHubPortDev->asSetupReq[pipe->pipe_index], psSetup, sizeof(struct urequest));
}
else
{
/* Write data to USB device. */
//Trigger USBHostLib Ctrl_Xfer
/* Trigger USBHostLib Ctrl_Xfer */
ret = nu_ctrl_xfer(psPortDev, psSetup, NULL, timeouts);
if (ret != psSetup->wLength)
goto exit_nu_pipe_xfer;
@@ -518,13 +521,13 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
}
else
{
//token == USBH_PID_DATA
/* token == USBH_PID_DATA */
if (buffer_nonch && ((pipe->ep.bEndpointAddress & USB_DIR_MASK) == USB_DIR_IN))
{
struct urequest *psSetup = &psPortCtrl->asHubPortDev->asSetupReq[pipe->pipe_index];
/* Read data from USB device. */
//Trigger USBHostLib Ctril_Xfer
/* Trigger USBHostLib Ctril_Xfer */
/*
* Workaround: HCD driver can readback all bytes of setup.wLength, but not support single packet transferring.
*/
@@ -553,10 +556,10 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
}
} //else
} /* else */
i32XferLen = nbytes;
goto exit_nu_pipe_xfer;
} // if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL )
} /* if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL ) */
else
{
@@ -577,7 +580,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
psUTR->bIsTransferDone = 0;
psUTR->status = 0;
//others xfer
/* others xfer */
rt_completion_init(&(psPortDev->utr_completion));
if (pipe->ep.bmAttributes == USB_EP_ATTR_BULK)
@@ -593,7 +596,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
{
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
//goto exit_nu_pipe_xfer;
/* goto exit_nu_pipe_xfer; */
}
else
{
@@ -603,25 +606,25 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
}
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
{
//TODO: ISO transfer
/* TODO: ISO transfer */
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
goto exit_nu_pipe_xfer;
}
} //else
} /* else */
failreport_nu_pipe_xfer:
if (psUTR->bIsTransferDone == 0)
{
//Timeout
/* Timeout */
LOG_D("nu_pipe_xfer ERROR: timeout");
pipe->status = UPIPE_STATUS_ERROR;
usbh_quit_utr(psUTR);
}
else
{
// Transfer Done. Get status
/* Transfer Done. Get status */
if (psUTR->status == 0)
{
pipe->status = UPIPE_STATUS_OK;
@@ -640,7 +643,7 @@ failreport_nu_pipe_xfer:
exit_nu_pipe_xfer:
//Call callback
/* Call callback */
if (pipe->callback != RT_NULL)
{
pipe->callback(pipe);
@@ -739,7 +742,7 @@ static void nu_hcd_disconnect_callback(
}
/* USB host operations -----------------------------------------------------------*/
/* USB host operations ----------------------------------------------------------- */
static struct uhcd_ops nu_uhcd_ops =
{
nu_reset_port,
@@ -754,10 +757,10 @@ static rt_err_t nu_hcd_init(rt_device_t device)
usbh_core_init();
//install connect/disconnect callback
/* install connect/disconnect callback */
usbh_install_conn_callback(nu_hcd_connect_callback, nu_hcd_disconnect_callback);
//create thread for polling usbh port status
/* create thread for polling usbh port status */
/* create usb hub thread */
pNuUSBHDev->polling_thread = rt_thread_create("usbh_drv", nu_usbh_rh_thread_entry, RT_NULL,
NU_USBH_THREAD_STACK_SIZE, 8, 20);
@@ -769,7 +772,7 @@ static rt_err_t nu_hcd_init(rt_device_t device)
return RT_EOK;
}
/* global function for USB host library -----------------------------*/
/* global function for USB host library ----------------------------- */
uint32_t usbh_get_ticks(void)
{
return rt_tick_get();
@@ -788,7 +791,7 @@ uint32_t usbh_tick_from_millisecond(uint32_t msec)
#if defined(RT_USING_PM)
/* device pm suspend() entry. */
static int usbhost_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t usbhost_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
{
rt_err_t result;
@@ -877,7 +880,7 @@ int nu_usbh_register(void)
res = rt_device_register(&psUHCD->parent, "usbh", RT_DEVICE_FLAG_DEACTIVATE);
RT_ASSERT(res == RT_EOK);
/*initialize the usb host function */
/* initialize the usb host function */
res = rt_usb_host_init("usbh");
RT_ASSERT(res == RT_EOK);

View File

@@ -101,9 +101,9 @@ static void soft_time_setup(uint32_t wanted_sec, uint32_t hz, soft_time_handle_t
static void soft_time_feed_dog(soft_time_handle_t *const soft_time);
#if defined(RT_USING_PM)
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode);
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static void soft_time_freqeucy_change(uint32_t new_hz, soft_time_handle_t *const soft_time);
#endif
@@ -132,7 +132,7 @@ static struct rt_device_pm_ops device_pm_ops =
#if defined(RT_USING_PM)
/* device pm suspend() entry. */
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
{
switch (mode)
{
@@ -184,7 +184,7 @@ static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode)
/* device pm frequency_change() entry. */
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
{
uint32_t clk, new_hz;

View File

@@ -127,7 +127,7 @@ void nu_pin_set_function(rt_base_t pin, int data)
GPx_MFPx_org = *GPx_MFPx;
*GPx_MFPx = (GPx_MFPx_org & (~MFP_Msk)) | data;
//rt_kprintf("Port[%d]-Pin[%d] Addr[%08x] Data[%08x] %08x -> %08x\n", port_index, pin_index, GPx_MFPx, data, GPx_MFPx_org, *GPx_MFPx);
/* rt_kprintf("Port[%d]-Pin[%d] Addr[%08x] Data[%08x] %08x -> %08x\n", port_index, pin_index, GPx_MFPx, data, GPx_MFPx_org, *GPx_MFPx); */
}
/**
@@ -145,16 +145,12 @@ void SysTick_Handler(void)
rt_interrupt_leave();
}
void rt_hw_cpu_reset(void)
int reboot(int argc, char **argv)
{
SYS_UnlockReg();
SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
}
int reboot(int argc, char **argv)
{
rt_hw_cpu_reset();
return 0;
}
MSH_CMD_EXPORT(reboot, Reboot System);
@@ -173,7 +169,7 @@ void devmem(int argc, char *argv[])
{
if (sscanf(argv[2], "0x%x", &value) != 1)
goto exit_devmem;
mode = 1; //Write
mode = 1; /*Write*/
}
if (sscanf(argv[1], "0x%x", &u32Addr) != 1)
@@ -207,7 +203,7 @@ void devmem2(int argc, char *argv[])
if (argc == 3)
{
if (sscanf(argv[2], "%d", &value) != 1)
if (sscanf(argv[2], "%u", &value) != 1)
goto exit_devmem;
word_count = value;
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-03-21 shelton first version
*/
/*
* NOTE: DO NOT include this file on the header file.
*/
#ifndef LOG_TAG
#define DBG_TAG "drv"
#else
#define DBG_TAG LOG_TAG
#endif /* LOG_TAG */
#ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */
#include <rtdbg.h>

View File

@@ -117,16 +117,12 @@ void SysTick_Handler(void)
rt_interrupt_leave();
}
void rt_hw_cpu_reset(void)
int reboot(int argc, char **argv)
{
SYS_UnlockReg();
SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk;
}
int reboot(int argc, char **argv)
{
rt_hw_cpu_reset();
return 0;
}
MSH_CMD_EXPORT(reboot, Reboot System);

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-03-21 shelton first version
*/
/*
* NOTE: DO NOT include this file on the header file.
*/
#ifndef LOG_TAG
#define DBG_TAG "drv"
#else
#define DBG_TAG LOG_TAG
#endif /* LOG_TAG */
#ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */
#include <rtdbg.h>

View File

@@ -28,6 +28,7 @@ struct nu_spi
struct rt_spi_bus dev;
char *name;
SPI_T *spi_base;
uint32_t rstidx;
uint32_t dummy;
#if defined(BSP_USING_SPI_PDMA)
int16_t pdma_perp_tx;
@@ -48,4 +49,4 @@ void nu_spi_transfer(struct nu_spi *spi_bus, uint8_t *tx, uint8_t *rx, int lengt
rt_err_t nu_hw_spi_pdma_allocate(struct nu_spi *spi_bus);
#endif
#endif // __DRV_SPI_H___
#endif /* __DRV_SPI_H___ */

View File

@@ -31,7 +31,7 @@
#define NU_USBHOST_HUB_POLLING_INTERVAL (100)
#endif
#define NU_MAX_USBH_PORT 2 //USB1.1 + USB2.0 port
#define NU_MAX_USBH_PORT 2 /* USB1.1 + USB2.0 port */
#define NU_MAX_USBH_PIPE 16
#define NU_USBH_THREAD_STACK_SIZE 2048
@@ -39,17 +39,20 @@
#define NU_USBHOST_HUB_POLLING_LOCK
#if defined(NU_USBHOST_HUB_POLLING_LOCK)
#define NU_USBHOST_MUTEX_INIT() { \
#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() { \
#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() { \
#define NU_USBHOST_UNLOCK() \
{ \
rt_err_t result = rt_mutex_release(s_sUSBHDev.lock); \
RT_ASSERT(result == RT_EOK); \
}
@@ -59,7 +62,7 @@
#define NU_USBHOST_UNLOCK()
#endif
/* Private typedef --------------------------------------------------------------*/
/* Private typedef -------------------------------------------------------------- */
typedef struct nu_port_dev
{
rt_bool_t bRHParent;
@@ -88,7 +91,7 @@ struct nu_usbh_dev
S_NU_RH_PORT_CTRL asPortCtrl[NU_MAX_USBH_PORT];
};
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static struct nu_usbh_dev s_sUSBHDev;
static S_NU_RH_PORT_CTRL *
@@ -99,13 +102,13 @@ GetRHPortControlFromPipe(
int port;
if (pipe->inst->parent_hub->is_roothub)
{
//case: device ---> root hub
/* case: device ---> root hub */
inst = pipe->inst;
port = inst->port;
}
else
{
//case: device ---> hub ---> root hub
/* case: device ---> hub ---> root hub */
inst = pipe->inst->parent_hub->self;
port = inst->port;
}
@@ -131,11 +134,11 @@ GetPortDevFromPipe(
if (pipe->inst->parent_hub->is_roothub)
{
//case: device ---> root hub
/* case: device ---> root hub */
return &psRHPortCtrl->sRHPortDev;
}
//case: device ---> hub ---> root hub
/* case: device ---> hub ---> root hub */
for (i = 0 ; i < NU_MAX_USBH_HUB_PORT_DEV; i ++)
{
if (psRHPortCtrl->asHubPortDev[i].port_num == pipe->inst->port)
@@ -265,7 +268,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
if ((psPortDev == NULL) || (psPortDev->pUDev == NULL))
{
//allocate new dev for hub device
/* allocate new dev for hub device */
psPortDev = AllocateNewUDev(psPortCtrl);
if (psPortDev == RT_NULL)
@@ -290,7 +293,7 @@ static rt_err_t nu_open_pipe(upipe_t pipe)
psPortDev->bEnumDone = FALSE;
}
//For ep0 control transfer
/* For ep0 control transfer */
if ((pipe->ep.bEndpointAddress & 0x7F) == 0)
{
pipe->pipe_index = 0;
@@ -338,7 +341,7 @@ static rt_err_t nu_close_pipe(upipe_t pipe)
psPortDev = GetPortDevFromPipe(pipe);
//For ep0 control transfer
/* For ep0 control transfer */
if ((pipe->ep.bEndpointAddress & 0x7F) == 0)
{
if ((psPortDev) && (psPortDev->bRHParent == FALSE) && (psPortDev->bEnumDone == TRUE))
@@ -409,7 +412,7 @@ static int nu_bulk_xfer(
if (ret < 0)
return ret;
//wait transfer done
/* wait transfer done */
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) < 0)
{
rt_kprintf("Request Timeout in %d ms!! (bulk_xfer)\n", timeouts);
@@ -464,7 +467,7 @@ static void xfer_done_cb(UTR_T *psUTR)
{
S_NU_PORT_DEV *psPortDev = (S_NU_PORT_DEV *)psUTR->context;
//transfer done, signal utr_completion
/* transfer done, signal utr_completion */
rt_completion_done(&(psPortDev->utr_completion));
}
@@ -492,7 +495,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
goto exit_nu_pipe_xfer;
}
//ctrl xfer
/* ctrl xfer */
if (pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL)
{
int ret;
@@ -506,13 +509,13 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
/* Read data from USB device. */
if (psSetup->request_type & USB_REQ_TYPE_DIR_IN)
{
//Store setup request
/* Store setup request */
rt_memcpy(&psPortCtrl->asHubPortDev->asSetupReq[pipe->pipe_index], psSetup, sizeof(struct urequest));
}
else
{
/* Write data to USB device. */
//Trigger USBHostLib Ctrl_Xfer
/* Trigger USBHostLib Ctrl_Xfer */
ret = nu_ctrl_xfer(psPortDev, psSetup, NULL, timeouts);
if (ret != psSetup->wLength)
goto exit_nu_pipe_xfer;
@@ -520,13 +523,13 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
}
else
{
//token == USBH_PID_DATA
/* token == USBH_PID_DATA */
if (buffer_nonch && ((pipe->ep.bEndpointAddress & USB_DIR_MASK) == USB_DIR_IN))
{
struct urequest *psSetup = &psPortCtrl->asHubPortDev->asSetupReq[pipe->pipe_index];
/* Read data from USB device. */
//Trigger USBHostLib Ctril_Xfer
/* Trigger USBHostLib Ctril_Xfer */
/*
* Workaround: HCD driver can readback all bytes of setup.wLength, but not support single packet transferring.
*/
@@ -555,10 +558,10 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
LOG_D("%d == USBH_PID_DATA, nil buf-%d", token, nbytes);
}
} //else
} /* else */
i32XferLen = nbytes;
goto exit_nu_pipe_xfer;
} // if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL )
} /* if ( pipe->ep.bmAttributes == USB_EP_ATTR_CONTROL ) */
else
{
@@ -579,7 +582,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
psUTR->bIsTransferDone = 0;
psUTR->status = 0;
//others xfer
/* others xfer */
rt_completion_init(&(psPortDev->utr_completion));
if (pipe->ep.bmAttributes == USB_EP_ATTR_BULK)
@@ -595,7 +598,7 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
if (nu_int_xfer(pipe, psPortDev, psUTR, timeouts) < 0)
{
LOG_D("nu_pipe_xfer ERROR: int transfer failed");
//goto exit_nu_pipe_xfer;
/* goto exit_nu_pipe_xfer; */
}
else
{
@@ -605,25 +608,25 @@ static int nu_pipe_xfer(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes
}
else if (pipe->ep.bmAttributes == USB_EP_ATTR_ISOC)
{
//TODO: ISO transfer
/* TODO: ISO transfer */
LOG_D("nu_pipe_xfer ERROR: isoc transfer not support");
goto exit_nu_pipe_xfer;
}
} //else
} /* else */
failreport_nu_pipe_xfer:
if (psUTR->bIsTransferDone == 0)
{
//Timeout
/* Timeout */
LOG_D("nu_pipe_xfer ERROR: timeout");
pipe->status = UPIPE_STATUS_ERROR;
usbh_quit_utr(psUTR);
}
else
{
// Transfer Done. Get status
/* Transfer Done. Get status*/
if (psUTR->status == 0)
{
pipe->status = UPIPE_STATUS_OK;
@@ -642,7 +645,7 @@ failreport_nu_pipe_xfer:
exit_nu_pipe_xfer:
//Call callback
/* Call callback */
if (pipe->callback != RT_NULL)
{
pipe->callback(pipe);
@@ -741,7 +744,7 @@ static void nu_hcd_disconnect_callback(
}
/* USB host operations -----------------------------------------------------------*/
/* USB host operations ----------------------------------------------------------- */
static struct uhcd_ops nu_uhcd_ops =
{
nu_reset_port,
@@ -756,10 +759,10 @@ static rt_err_t nu_hcd_init(rt_device_t device)
usbh_core_init();
//install connect/disconnect callback
/* install connect/disconnect callback */
usbh_install_conn_callback(nu_hcd_connect_callback, nu_hcd_disconnect_callback);
//create thread for polling usbh port status
/* create thread for polling usbh port status */
/* create usb hub thread */
pNuUSBHDev->polling_thread = rt_thread_create("usbh_drv", nu_usbh_rh_thread_entry, RT_NULL,
NU_USBH_THREAD_STACK_SIZE, 8, 20);
@@ -771,7 +774,7 @@ static rt_err_t nu_hcd_init(rt_device_t device)
return RT_EOK;
}
/* global function for USB host library -----------------------------*/
/* global function for USB host library ----------------------------- */
uint32_t usbh_get_ticks(void)
{
return rt_tick_get();
@@ -790,7 +793,7 @@ uint32_t usbh_tick_from_millisecond(uint32_t msec)
#if defined(RT_USING_PM)
/* device pm suspend() entry. */
static int usbhost_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t usbhost_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
{
rt_err_t result;
@@ -890,7 +893,7 @@ int nu_usbh_register(void)
res = rt_device_register(&psUHCD->parent, "usbh", RT_DEVICE_FLAG_DEACTIVATE);
RT_ASSERT(res == RT_EOK);
/*initialize the usb host function */
/* initialize the usb host function */
res = rt_usb_host_init("usbh");
RT_ASSERT(res == RT_EOK);

View File

@@ -98,9 +98,9 @@ static void soft_time_setup(uint32_t wanted_sec, uint32_t hz, soft_time_handle_t
static void soft_time_feed_dog(soft_time_handle_t *const soft_time);
#if defined(RT_USING_PM)
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode);
static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode);
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode);
static void soft_time_freqeucy_change(uint32_t new_hz, soft_time_handle_t *const soft_time);
#endif
@@ -129,7 +129,7 @@ static struct rt_device_pm_ops device_pm_ops =
#if defined(RT_USING_PM)
/* device pm suspend() entry. */
static int wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_suspend(const struct rt_device *device, rt_uint8_t mode)
{
switch (mode)
{
@@ -181,7 +181,7 @@ static void wdt_pm_resume(const struct rt_device *device, rt_uint8_t mode)
/* device pm frequency_change() entry. */
static int wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
static rt_err_t wdt_pm_frequency_change(const struct rt_device *device, rt_uint8_t mode)
{
uint32_t clk, new_hz;

View File

@@ -59,8 +59,8 @@ typedef struct nu_adc_touch_data *nu_adc_touch_data_t;
#endif
/* Private functions ------------------------------------------------------------*/
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args);
/* Public functions ------------------------------------------------------------*/
@@ -86,7 +86,7 @@ static void nu_adc_isr(int vector, void *param)
rt_int32_t irqidx;
ADC_T *adc = psNuAdc->base;
//rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR);
/* rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR); */
isr = adc->ISR;
wkisr = adc->WKISR;
@@ -99,13 +99,13 @@ static void nu_adc_isr(int vector, void *param)
if (psNuAdc->m_isr[irqidx].cbfunc != RT_NULL)
{
// rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc);
/* rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc); */
psNuAdc->m_isr[irqidx].cbfunc(isr, psNuAdc->m_isr[irqidx].private_data);
}
/* Clear sent bit */
isr &= ~(u32IsrBitMask);
} //while
} /* while */
while ((irqidx = nu_ctz(wkisr)) < eAdc_WKISR_CNT)
{
@@ -117,7 +117,7 @@ static void nu_adc_isr(int vector, void *param)
}
wkisr &= ~(u32IsrBitMask);
} //while
} /* while */
}
static rt_err_t _nu_adc_init(rt_device_t dev)
@@ -125,7 +125,7 @@ static rt_err_t _nu_adc_init(rt_device_t dev)
nu_adc_t psNuAdc = (nu_adc_t)dev;
/* ADC Engine Clock is set to freq Khz */
CLK_SetModuleClock(psNuAdc->modid, 0, CLK_CLKDIV4_ADC(180)); // Set ADC clock rate to 9MHz
CLK_SetModuleClock(psNuAdc->modid, 0, CLK_CLKDIV4_ADC(180)); /* Set ADC clock rate to 9MHz */
/* Install interrupt service routine */
rt_hw_interrupt_install(psNuAdc->irqn, nu_adc_isr, (void *)psNuAdc, psNuAdc->name);
@@ -152,7 +152,7 @@ static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
point.u32Z0 = ADC_GET_CONVERSION_Z1DATA(adc);
point.u32Z1 = ADC_GET_CONVERSION_Z2DATA(adc);
//rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1);
/* rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1); */
/* Trigger next or not. */
if (point.u32Z0 < ADC_TOUCH_Z0_ACTIVE)
{
@@ -198,7 +198,7 @@ static void nu_adc_touch_antiglitch(ADC_T *adc)
int count = 10;
do
{
rt_hw_us_delay(1000); // 1ms
rt_hw_us_delay(1000); /* 1ms */
ADC_CLR_INT_FLAG(adc, adc->ISR);
if (adc->ISR == 0)
break;
@@ -277,10 +277,10 @@ rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
adc->CONF = 0x0;
rt_adc_enable((rt_adc_device_t)psNuAdc, 4); //Channel number 4
rt_adc_enable((rt_adc_device_t)psNuAdc, 5); //Channel number 5
rt_adc_enable((rt_adc_device_t)psNuAdc, 6); //Channel number 6
rt_adc_enable((rt_adc_device_t)psNuAdc, 7); //Channel number 7
rt_adc_enable((rt_adc_device_t)psNuAdc, 4); /* Channel number 4 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 5); /* Channel number 5 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 6); /* Channel number 6 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 7); /* Channel number 7 */
/* Register touch device. */
psNuAdc->psRtTouch = psRtTouch;
@@ -305,10 +305,10 @@ rt_err_t nu_adc_touch_disable(void)
_nu_adc_control((rt_device_t)psNuAdc, Z_OFF, RT_NULL);
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_OFF, RT_NULL);
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); //Channel number 4
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); //Channel number 5
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); //Channel number 6
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); //Channel number 7
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); /* Channel number 4 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); /* Channel number 5 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); /* Channel number 6 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); /* Channel number 7 */
return RT_EOK;
}
@@ -364,7 +364,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL |= ADC_CTL_WKTEN_Msk;
adc->IER |= ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26)); */
}
break;
@@ -373,7 +373,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL &= ~ADC_CTL_WKTEN_Msk;
adc->IER &= ~ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26)); */
}
break;
@@ -524,7 +524,7 @@ static const struct rt_adc_ops nu_adc_ops =
};
/* nu_adc_enabled - Enable ADC clock and wait for ready */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
{
nu_adc_t psNuADC = (nu_adc_t)device;
RT_ASSERT(device);
@@ -554,7 +554,7 @@ static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel
return RT_EOK;
}
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
{
rt_err_t ret = RT_EOK;
@@ -566,7 +566,7 @@ static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel
ret = -RT_EINVAL;
goto exit_nu_adc_convert;
}
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)channel)) != RT_EOK)
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)(intptr_t)channel)) != RT_EOK)
{
goto exit_nu_adc_convert;
}
@@ -612,4 +612,4 @@ int rt_hw_adc_init(void)
}
INIT_BOARD_EXPORT(rt_hw_adc_init);
#endif //#if defined(BSP_USING_ADC)
#endif /* #if defined(BSP_USING_ADC) */

View File

@@ -16,7 +16,7 @@
#include <rtdevice.h>
#include "NuMicro.h"
/* Private define ---------------------------------------------------------------*/
/* Private define --------------------------------------------------------------- */
#define DEF_EADC_MAX_CHANNEL_NUM 8
enum
@@ -28,7 +28,7 @@ enum
EADC_CNT
};
/* Private Typedef --------------------------------------------------------------*/
/* Private Typedef -------------------------------------------------------------- */
struct nu_eadc
{
struct rt_adc_device parent;
@@ -40,15 +40,14 @@ struct nu_eadc
};
typedef struct nu_eadc *nu_eadc_t;
/* Private functions ------------------------------------------------------------*/
static rt_err_t nu_eadc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
static rt_err_t nu_get_eadc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
static rt_err_t nu_get_eadc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
/* Private functions ------------------------------------------------------------ */
static rt_err_t nu_eadc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
static rt_err_t nu_get_eadc_value(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
/* Public functions ------------------------------------------------------------*/
/* Public functions ------------------------------------------------------------ */
int rt_hw_eadc_init(void);
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static struct nu_eadc nu_eadc_arr [] =
{
@@ -66,7 +65,7 @@ typedef struct rt_adc_ops *rt_adc_ops_t;
/* nu_adc_enabled - Enable ADC clock and wait for ready */
static rt_err_t nu_eadc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
static rt_err_t nu_eadc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
{
nu_eadc_t psNuEadc = (nu_eadc_t)device;
RT_ASSERT(device != RT_NULL);
@@ -97,7 +96,7 @@ static rt_err_t nu_eadc_enabled(struct rt_adc_device *device, rt_uint32_t channe
return RT_EOK;
}
static rt_err_t nu_get_eadc_value(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
static rt_err_t nu_get_eadc_value(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
{
nu_eadc_t psNuEadc = (nu_eadc_t)device;
@@ -151,4 +150,4 @@ int rt_hw_eadc_init(void)
}
INIT_BOARD_EXPORT(rt_hw_eadc_init);
#endif //#if defined(BSP_USING_EADC)
#endif /* #if defined(BSP_USING_EADC) */

View File

@@ -19,7 +19,7 @@
#include <drv_i2c.h>
#include <drv_sys.h>
/* Private define ---------------------------------------------------------------*/
/* Private define --------------------------------------------------------------- */
#define LOG_TAG "drv.i2c"
#define DBG_ENABLE
#define DBG_SECTION_NAME LOG_TAG
@@ -51,7 +51,7 @@ enum
I2C_CNT
};
/* Private typedef --------------------------------------------------------------*/
/* Private typedef -------------------------------------------------------------- */
typedef struct _nu_i2c_bus
{
struct rt_i2c_bus_device parent;
@@ -60,7 +60,7 @@ typedef struct _nu_i2c_bus
char *device_name;
} nu_i2c_bus_t;
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static nu_i2c_bus_t nu_i2c_arr [ ] =
@@ -97,7 +97,7 @@ static nu_i2c_bus_t nu_i2c_arr [ ] =
#endif
};
/* Private functions ------------------------------------------------------------*/
/* Private functions ------------------------------------------------------------ */
#if defined(BSP_USING_I2C)
static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
struct rt_i2c_msg msgs[],
@@ -120,7 +120,7 @@ static rt_err_t nu_i2c_bus_control(struct rt_i2c_bus_device *bus, int u32Cmd, vo
RT_ASSERT(bus != RT_NULL);
nu_i2c = (nu_i2c_bus_t *) bus;
switch (cmd)
switch (u32Cmd)
{
case RT_I2C_DEV_CTRL_CLK:
I2C_SetBusClockFreq(nu_i2c->I2C, *(rt_uint32_t *)args);
@@ -204,7 +204,7 @@ static rt_err_t nu_i2c_send_address(nu_i2c_bus_t *nu_i2c,
if ((I2C_GET_STATUS(nu_i2c->I2C) != NU_I2C_MASTER_STATUS_REPEAT_START) && !ignore_nack)
{
//LOG_E("sending repeated START failed\n");
/* LOG_E("sending repeated START failed\n"); */
return -RT_EIO;
}
@@ -294,7 +294,7 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
if (I2C_GET_STATUS(nu_i2c->I2C) != NU_I2C_MASTER_STATUS_REPEAT_START)
{
i = 0;
//LOG_E("Send repeat START Fail");
/* LOG_E("Send repeat START Fail"); */
break;
}
}
@@ -382,7 +382,7 @@ static rt_ssize_t nu_i2c_mst_xfer(struct rt_i2c_bus_device *bus,
}
#endif
/* Public functions -------------------------------------------------------------*/
/* Public functions ------------------------------------------------------------- */
int rt_hw_i2c_init(void)
{
int i;

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-03-21 shelton first version
*/
/*
* NOTE: DO NOT include this file on the header file.
*/
#ifndef LOG_TAG
#define DBG_TAG "drv"
#else
#define DBG_TAG LOG_TAG
#endif /* LOG_TAG */
#ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */
#include <rtdbg.h>

View File

@@ -19,11 +19,11 @@
#include "nu_bitutil.h"
#include "drv_adc.h"
/* Private define ---------------------------------------------------------------*/
/* Private define --------------------------------------------------------------- */
#define DEF_ADC_TOUCH_SMPL_TICK 40
#define TOUCH_MQ_LENGTH 64
/* Private Typedef --------------------------------------------------------------*/
/* Private Typedef -------------------------------------------------------------- */
struct nu_adc
{
struct rt_adc_device dev;
@@ -58,15 +58,15 @@ struct nu_adc_touch_data
typedef struct nu_adc_touch_data *nu_adc_touch_data_t;
#endif
/* Private functions ------------------------------------------------------------*/
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
/* Private functions ------------------------------------------------------------ */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args);
/* Public functions ------------------------------------------------------------*/
/* Public functions ------------------------------------------------------------ */
int rt_hw_adc_init(void);
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static struct nu_adc g_sNuADC =
{
@@ -86,7 +86,7 @@ static void nu_adc_isr(int vector, void *param)
rt_int32_t irqidx;
ADC_T *adc = psNuAdc->base;
//rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR);
/* rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR); */
isr = adc->ISR;
wkisr = adc->WKISR;
@@ -99,13 +99,13 @@ static void nu_adc_isr(int vector, void *param)
if (psNuAdc->m_isr[irqidx].cbfunc != RT_NULL)
{
// rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc);
/* rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc); */
psNuAdc->m_isr[irqidx].cbfunc(isr, psNuAdc->m_isr[irqidx].private_data);
}
/* Clear sent bit */
isr &= ~(u32IsrBitMask);
} //while
} /* while */
while ((irqidx = nu_ctz(wkisr)) < eAdc_WKISR_CNT)
{
@@ -117,7 +117,7 @@ static void nu_adc_isr(int vector, void *param)
}
wkisr &= ~(u32IsrBitMask);
} //while
} /* while */
}
@@ -155,7 +155,7 @@ static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
point.u32Z0 = ADC_GET_CONVERSION_Z1DATA(adc);
point.u32Z1 = ADC_GET_CONVERSION_Z2DATA(adc);
//rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1);
/* rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1); */
/* Trigger next or not. */
if (point.u32Z0 < ADC_TOUCH_Z0_ACTIVE)
{
@@ -306,10 +306,10 @@ rt_err_t nu_adc_touch_disable(void)
_nu_adc_control((rt_device_t)psNuAdc, Z_OFF, RT_NULL);
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_OFF, RT_NULL);
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); //Channel number 4
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); //Channel number 5
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); //Channel number 6
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); //Channel number 7
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); /* Channel number 4 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); /* Channel number 5 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); /* Channel number 6 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); /* Channel number 7 */
return RT_EOK;
}
@@ -365,7 +365,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL |= ADC_CTL_WKTEN_Msk;
adc->IER |= ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26)); */
}
break;
@@ -374,7 +374,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL &= ~ADC_CTL_WKTEN_Msk;
adc->IER &= ~ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26)); */
}
break;
@@ -525,7 +525,7 @@ static const struct rt_adc_ops nu_adc_ops =
};
/* nu_adc_enabled - Enable ADC clock and wait for ready */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
{
nu_adc_t psNuADC = (nu_adc_t)device;
RT_ASSERT(device);
@@ -555,7 +555,7 @@ static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel
return RT_EOK;
}
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
{
rt_err_t ret = RT_EOK;
@@ -567,7 +567,7 @@ static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel
ret = -RT_EINVAL;
goto exit_nu_adc_convert;
}
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)channel)) != RT_EOK)
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)(intptr_t)channel)) != RT_EOK)
{
goto exit_nu_adc_convert;
}
@@ -613,4 +613,4 @@ int rt_hw_adc_init(void)
}
INIT_BOARD_EXPORT(rt_hw_adc_init);
#endif //#if defined(BSP_USING_ADC)
#endif /* #if defined(BSP_USING_ADC) */

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-03-21 shelton first version
*/
/*
* NOTE: DO NOT include this file on the header file.
*/
#ifndef LOG_TAG
#define DBG_TAG "drv"
#else
#define DBG_TAG LOG_TAG
#endif /* LOG_TAG */
#ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */
#include <rtdbg.h>

View File

@@ -19,11 +19,11 @@
#include "nu_bitutil.h"
#include "drv_adc.h"
/* Private define ---------------------------------------------------------------*/
/* Private define --------------------------------------------------------------- */
#define DEF_ADC_TOUCH_SMPL_TICK 40
#define TOUCH_MQ_LENGTH 64
/* Private Typedef --------------------------------------------------------------*/
/* Private Typedef -------------------------------------------------------------- */
struct nu_adc
{
struct rt_adc_device dev;
@@ -58,15 +58,15 @@ struct nu_adc_touch_data
typedef struct nu_adc_touch_data *nu_adc_touch_data_t;
#endif
/* Private functions ------------------------------------------------------------*/
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value);
/* Private functions ------------------------------------------------------------ */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled);
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value);
static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args);
/* Public functions ------------------------------------------------------------*/
/* Public functions ------------------------------------------------------------ */
int rt_hw_adc_init(void);
/* Private variables ------------------------------------------------------------*/
/* Private variables ------------------------------------------------------------ */
static struct nu_adc g_sNuADC =
{
@@ -86,7 +86,7 @@ static void nu_adc_isr(int vector, void *param)
rt_int32_t irqidx;
ADC_T *adc = psNuAdc->base;
//rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR);
/* rt_kprintf("[%s %d] CTL: %08x CONF:%08x IER:%08x ISR:%08x\n", __func__, __LINE__, adc->CTL, adc->CONF, adc->IER, adc->ISR); */
isr = adc->ISR;
wkisr = adc->WKISR;
@@ -99,13 +99,13 @@ static void nu_adc_isr(int vector, void *param)
if (psNuAdc->m_isr[irqidx].cbfunc != RT_NULL)
{
// rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc);
/* rt_kprintf("[%s] %d %x\n", __func__, irqidx, psNuAdc->m_isr[irqidx].cbfunc); */
psNuAdc->m_isr[irqidx].cbfunc(isr, psNuAdc->m_isr[irqidx].private_data);
}
/* Clear sent bit */
isr &= ~(u32IsrBitMask);
} //while
} /* while */
while ((irqidx = nu_ctz(wkisr)) < eAdc_WKISR_CNT)
{
@@ -117,7 +117,7 @@ static void nu_adc_isr(int vector, void *param)
}
wkisr &= ~(u32IsrBitMask);
} //while
} /* while */
}
@@ -155,7 +155,7 @@ static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
point.u32Z0 = ADC_GET_CONVERSION_Z1DATA(adc);
point.u32Z1 = ADC_GET_CONVERSION_Z2DATA(adc);
//rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1);
/* rt_kprintf("x=%d y=%d z0=%d z1=%d\n", point.u32X, point.u32Y, point.u32Z0, point.u32Z1); */
/* Trigger next or not. */
if (point.u32Z0 < ADC_TOUCH_Z0_ACTIVE)
{
@@ -199,7 +199,7 @@ static void nu_adc_touch_antiglitch(ADC_T *adc)
int count = 10;
do
{
rt_hw_us_delay(1000); // 1ms
rt_hw_us_delay(1000); /* 1ms */
ADC_CLR_INT_FLAG(adc, adc->ISR);
if (adc->ISR == 0)
break;
@@ -278,10 +278,10 @@ rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
adc->CONF = 0x0;
rt_adc_enable((rt_adc_device_t)psNuAdc, 4); //Channel number 4
rt_adc_enable((rt_adc_device_t)psNuAdc, 5); //Channel number 5
rt_adc_enable((rt_adc_device_t)psNuAdc, 6); //Channel number 6
rt_adc_enable((rt_adc_device_t)psNuAdc, 7); //Channel number 7
rt_adc_enable((rt_adc_device_t)psNuAdc, 4); /* Channel number 4 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 5); /* Channel number 5 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 6); /* Channel number 6 */
rt_adc_enable((rt_adc_device_t)psNuAdc, 7); /* Channel number 7 */
/* Register touch device. */
psNuAdc->psRtTouch = psRtTouch;
@@ -306,10 +306,10 @@ rt_err_t nu_adc_touch_disable(void)
_nu_adc_control((rt_device_t)psNuAdc, Z_OFF, RT_NULL);
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_OFF, RT_NULL);
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); //Channel number 4
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); //Channel number 5
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); //Channel number 6
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); //Channel number 7
rt_adc_disable((rt_adc_device_t)psNuAdc, 4); /* Channel number 4 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 5); /* Channel number 5 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 6); /* Channel number 6 */
rt_adc_disable((rt_adc_device_t)psNuAdc, 7); /* Channel number 7 */
return RT_EOK;
}
@@ -365,7 +365,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL |= ADC_CTL_WKTEN_Msk;
adc->IER |= ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26)); */
}
break;
@@ -374,7 +374,7 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
adc->CTL &= ~ADC_CTL_WKTEN_Msk;
adc->IER &= ~ADC_IER_WKTIEN_Msk;
//TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26));
/* TODO outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26)); */
}
break;
@@ -525,7 +525,7 @@ static const struct rt_adc_ops nu_adc_ops =
};
/* nu_adc_enabled - Enable ADC clock and wait for ready */
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel, rt_bool_t enabled)
static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled)
{
nu_adc_t psNuADC = (nu_adc_t)device;
RT_ASSERT(device);
@@ -555,7 +555,7 @@ static rt_err_t nu_adc_enabled(struct rt_adc_device *device, rt_uint32_t channel
return RT_EOK;
}
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel, rt_uint32_t *value)
static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_int8_t channel, rt_uint32_t *value)
{
rt_err_t ret = RT_EOK;
@@ -567,7 +567,7 @@ static rt_err_t nu_adc_convert(struct rt_adc_device *device, rt_uint32_t channel
ret = -RT_EINVAL;
goto exit_nu_adc_convert;
}
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)channel)) != RT_EOK)
else if ((ret = _nu_adc_control((rt_device_t)device, SWITCH_CH, (void *)(intptr_t)channel)) != RT_EOK)
{
goto exit_nu_adc_convert;
}
@@ -613,4 +613,4 @@ int rt_hw_adc_init(void)
}
INIT_BOARD_EXPORT(rt_hw_adc_init);
#endif //#if defined(BSP_USING_ADC)
#endif /* #if defined(BSP_USING_ADC) */

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-03-21 shelton first version
*/
/*
* NOTE: DO NOT include this file on the header file.
*/
#ifndef LOG_TAG
#define DBG_TAG "drv"
#else
#define DBG_TAG LOG_TAG
#endif /* LOG_TAG */
#ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG
#else
#define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */
#include <rtdbg.h>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,412 @@
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__
#define USE_MA35D1_SUBM
/* RT-Thread Kernel */
#define RT_NAME_MAX 8
#define RT_CPUS_NR 1
#define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_USING_HOOK
#define RT_HOOK_USING_FUNC_PTR
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 2048
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 2048
/* kservice optimization */
/* end of kservice optimization */
/* klibc optimization */
/* end of klibc optimization */
#define RT_USING_DEBUG
#define RT_DEBUGING_ASSERT
#define RT_DEBUGING_COLOR
#define RT_DEBUGING_CONTEXT
#define RT_USING_OVERFLOW_CHECK
/* Inter-Thread communication */
#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* end of Inter-Thread communication */
/* Memory Management */
#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP
#define RT_USING_HEAP
/* end of Memory Management */
#define RT_USING_DEVICE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 256
#define RT_CONSOLE_DEVICE_NAME "uart16"
#define RT_VER_NUM 0x50200
#define RT_BACKTRACE_LEVEL_MAX_NR 32
/* end of RT-Thread Kernel */
#define RT_USING_HW_ATOMIC
#define RT_USING_CPU_FFS
#define ARCH_ARM
#define ARCH_ARM_CORTEX_M
#define ARCH_ARM_CORTEX_M4
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
#define RT_USING_MSH
#define RT_USING_FINSH
#define FINSH_USING_MSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_CMD_SIZE 80
#define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10
#define FINSH_USING_OPTION_COMPLETION
/* DFS: device virtual file system */
/* end of DFS: device virtual file system */
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_UNAMED_PIPE_NUMBER 64
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_RB_BUFSZ 256
#define RT_USING_PIN
/* end of Device Drivers */
/* C/C++ and POSIX layer */
/* ISO-ANSI C layer */
/* Timezone and Daylight Saving Time */
#define RT_LIBC_USING_LIGHT_TZ_DST
#define RT_LIBC_TZ_DEFAULT_HOUR 8
#define RT_LIBC_TZ_DEFAULT_MIN 0
#define RT_LIBC_TZ_DEFAULT_SEC 0
/* end of Timezone and Daylight Saving Time */
/* end of ISO-ANSI C layer */
/* POSIX (Portable Operating System Interface) layer */
/* Interprocess Communication (IPC) */
/* Socket is in the 'Network' category */
/* end of Interprocess Communication (IPC) */
/* end of POSIX (Portable Operating System Interface) layer */
/* end of C/C++ and POSIX layer */
/* Network */
/* end of Network */
/* Memory protection */
/* end of Memory protection */
/* Utilities */
#define RT_USING_ULOG
#define ULOG_OUTPUT_LVL_D
#define ULOG_OUTPUT_LVL 7
#define ULOG_USING_ISR_LOG
#define ULOG_ASSERT_ENABLE
#define ULOG_LINE_BUF_SIZE 128
/* log format */
#define ULOG_USING_COLOR
#define ULOG_OUTPUT_TIME
#define ULOG_OUTPUT_LEVEL
#define ULOG_OUTPUT_TAG
/* end of log format */
#define ULOG_BACKEND_USING_CONSOLE
#define RT_USING_UTEST
#define UTEST_THR_STACK_SIZE 4096
#define UTEST_THR_PRIORITY 20
/* end of Utilities */
/* Using USB legacy version */
/* end of Using USB legacy version */
/* end of RT-Thread Components */
/* RT-Thread Utestcases */
#define RT_USING_UTESTCASES
/* Utest Self Testcase */
#define UTEST_SELF_PASS_TC
/* end of Utest Self Testcase */
/* Kernel Testcase */
#define UTEST_SMALL_MEM_TC
/* end of Kernel Testcase */
/* CPP11 Testcase */
/* end of CPP11 Testcase */
/* Utest Serial Testcase */
/* end of Utest Serial Testcase */
/* Utest IPC Testcase */
/* end of Utest IPC Testcase */
/* RTT Posix Testcase */
/* end of RTT Posix Testcase */
/* Memory Management Subsytem Testcase */
/* end of Memory Management Subsytem Testcase */
/* Tmpfs Testcase */
/* end of Tmpfs Testcase */
/* SMP Testcase */
/* end of SMP Testcase */
/* end of RT-Thread Utestcases */
/* RT-Thread online packages */
/* IoT - internet of things */
/* Wi-Fi */
/* Marvell WiFi */
/* end of Marvell WiFi */
/* Wiced WiFi */
/* end of Wiced WiFi */
/* CYW43012 WiFi */
/* end of CYW43012 WiFi */
/* BL808 WiFi */
/* end of BL808 WiFi */
/* CYW43439 WiFi */
/* end of CYW43439 WiFi */
/* end of Wi-Fi */
/* IoT Cloud */
/* end of IoT Cloud */
/* end of IoT - internet of things */
/* security packages */
/* end of security packages */
/* language packages */
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */
/* XML: Extensible Markup Language */
/* end of XML: Extensible Markup Language */
/* end of language packages */
/* multimedia packages */
/* LVGL: powerful and easy-to-use embedded GUI library */
/* end of LVGL: powerful and easy-to-use embedded GUI library */
/* u8g2: a monochrome graphic library */
/* end of u8g2: a monochrome graphic library */
/* end of multimedia packages */
/* tools packages */
/* end of tools packages */
/* system packages */
/* enhanced kernel services */
/* end of enhanced kernel services */
/* acceleration: Assembly language or algorithmic acceleration packages */
/* end of acceleration: Assembly language or algorithmic acceleration packages */
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* Micrium: Micrium software products porting for RT-Thread */
/* end of Micrium: Micrium software products porting for RT-Thread */
/* end of system packages */
/* peripheral libraries and drivers */
/* HAL & SDK Drivers */
/* STM32 HAL & SDK Drivers */
/* end of STM32 HAL & SDK Drivers */
/* Infineon HAL Packages */
/* end of Infineon HAL Packages */
/* Kendryte SDK */
/* end of Kendryte SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */
/* end of sensors drivers */
/* touch drivers */
/* end of touch drivers */
/* end of peripheral libraries and drivers */
/* AI packages */
/* end of AI packages */
/* Signal Processing and Control Algorithm Packages */
/* end of Signal Processing and Control Algorithm Packages */
/* miscellaneous packages */
/* project laboratory */
/* end of project laboratory */
/* samples: kernel and components samples */
/* end of samples: kernel and components samples */
/* entertainment: terminal games and other interesting software packages */
/* end of entertainment: terminal games and other interesting software packages */
/* end of miscellaneous packages */
/* Arduino libraries */
/* Projects and Demos */
/* end of Projects and Demos */
/* Sensors */
/* end of Sensors */
/* Display */
/* end of Display */
/* Timing */
/* end of Timing */
/* Data Processing */
/* end of Data Processing */
/* Data Storage */
/* Communication */
/* end of Communication */
/* Device Control */
/* end of Device Control */
/* Other */
/* end of Other */
/* Signal IO */
/* end of Signal IO */
/* Uncategorized */
/* end of Arduino libraries */
/* end of RT-Thread online packages */
/* Hardware Drivers Config */
/* On-chip Peripheral Drivers */
#define SOC_SERIES_MA35D1
#define BSP_USING_PDMA
#define BSP_USING_PDMA2
#define BSP_USING_PDMA3
#define NU_PDMA_MEMFUN_ACTOR_MAX 2
#define BSP_USING_GPIO
#define BSP_USING_UART
#define BSP_USING_UART16
#define BSP_USING_HWSEM
#define BSP_USING_HWSEM0
#define BSP_USING_WHC
#define BSP_USING_WHC0
/* end of On-chip Peripheral Drivers */
/* On-board Peripheral Drivers */
#define BSP_USING_NULINKME
/* end of On-board Peripheral Drivers */
/* Board extended module drivers */
/* Nuvoton Packages Config */
#define NU_PKG_USING_UTILS
#define NU_PKG_USING_DEMO
/* end of Nuvoton Packages Config */
/* end of Hardware Drivers Config */
#endif

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -53,11 +53,19 @@ unsigned long rwflag;
const void *data;
*/
const struct dfs_mount_tbl mount_table[] =
{
{ RAMDISK_UDC, "/mnt/ram_usbd", "elm", 0, RT_NULL },
{0},
};
#if defined(PKG_USING_RAMDISK)
const struct dfs_mount_tbl mount_table[] =
{
{ RAMDISK_UDC, "/mnt/ram_usbd", "elm", 0, RT_NULL },
{0},
};
#else
const struct dfs_mount_tbl mount_table[] =
{
{0},
};
#endif
#endif
@@ -155,7 +163,7 @@ int filesystem_init(void)
{
rt_err_t result = RT_EOK;
// ramdisk as root
/* ramdisk as root */
if (!rt_device_find(RAMDISK_NAME))
{
LOG_E("cannot find %s device", RAMDISK_NAME);

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

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

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,442 @@
#ifndef RT_CONFIG_H__
#define RT_CONFIG_H__
/* RT-Thread Kernel */
#define RT_NAME_MAX 8
#define RT_CPUS_NR 1
#define RT_ALIGN_SIZE 8
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 1000
#define RT_USING_HOOK
#define RT_HOOK_USING_FUNC_PTR
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 512
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
/* kservice optimization */
/* end of kservice optimization */
/* klibc optimization */
/* end of klibc optimization */
#define RT_USING_DEBUG
#define RT_DEBUGING_ASSERT
#define RT_DEBUGING_COLOR
#define RT_DEBUGING_CONTEXT
#define RT_USING_OVERFLOW_CHECK
/* Inter-Thread communication */
#define RT_USING_SEMAPHORE
#define RT_USING_MUTEX
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* end of Inter-Thread communication */
/* Memory Management */
#define RT_USING_MEMPOOL
#define RT_USING_SMALL_MEM
#define RT_USING_SMALL_MEM_AS_HEAP
#define RT_USING_HEAP
/* end of Memory Management */
#define RT_USING_DEVICE
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 256
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x50200
#define RT_BACKTRACE_LEVEL_MAX_NR 32
/* end of RT-Thread Kernel */
#define ARCH_ARM
#define ARCH_ARM_CORTEX_M
#define ARCH_ARM_CORTEX_M0
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 10
#define RT_USING_MSH
#define RT_USING_FINSH
#define FINSH_USING_MSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_CMD_SIZE 80
#define MSH_USING_BUILT_IN_COMMANDS
#define FINSH_USING_DESCRIPTION
#define FINSH_ARG_MAX 10
#define FINSH_USING_OPTION_COMPLETION
/* DFS: device virtual file system */
#define RT_USING_DFS
#define DFS_USING_POSIX
#define DFS_USING_WORKDIR
#define DFS_FD_MAX 16
#define RT_USING_DFS_V1
#define DFS_FILESYSTEMS_MAX 2
#define DFS_FILESYSTEM_TYPES_MAX 2
#define RT_USING_DFS_DEVFS
/* end of DFS: device virtual file system */
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_UNAMED_PIPE_NUMBER 64
#define RT_USING_SERIAL
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_ADC
#define RT_USING_PWM
#define RT_USING_PM
#define PM_TICKLESS_THRESHOLD_TIME 2
#define RT_USING_RTC
#define RT_USING_WDT
#define RT_USING_PIN
#define RT_USING_HWTIMER
/* end of Device Drivers */
/* C/C++ and POSIX layer */
/* ISO-ANSI C layer */
/* Timezone and Daylight Saving Time */
#define RT_LIBC_USING_LIGHT_TZ_DST
#define RT_LIBC_TZ_DEFAULT_HOUR 8
#define RT_LIBC_TZ_DEFAULT_MIN 0
#define RT_LIBC_TZ_DEFAULT_SEC 0
/* end of Timezone and Daylight Saving Time */
/* end of ISO-ANSI C layer */
/* POSIX (Portable Operating System Interface) layer */
/* Interprocess Communication (IPC) */
/* Socket is in the 'Network' category */
/* end of Interprocess Communication (IPC) */
/* end of POSIX (Portable Operating System Interface) layer */
/* end of C/C++ and POSIX layer */
/* Network */
/* end of Network */
/* Memory protection */
/* end of Memory protection */
/* Utilities */
#define RT_USING_UTEST
#define UTEST_THR_STACK_SIZE 4096
#define UTEST_THR_PRIORITY 20
/* end of Utilities */
/* Using USB legacy version */
#define RT_USING_USB
#define RT_USING_USB_DEVICE
#define RT_USBD_THREAD_STACK_SZ 4096
#define USB_VENDOR_ID 0x0FFE
#define USB_PRODUCT_ID 0x0001
#define RT_USB_DEVICE_COMPOSITE
#define RT_USB_DEVICE_NONE
#define RT_USB_DEVICE_HID
#define RT_USB_DEVICE_HID_MOUSE
/* end of Using USB legacy version */
/* end of RT-Thread Components */
/* RT-Thread Utestcases */
#define RT_USING_UTESTCASES
/* Utest Self Testcase */
#define UTEST_SELF_PASS_TC
/* end of Utest Self Testcase */
/* Kernel Testcase */
#define UTEST_SMALL_MEM_TC
/* end of Kernel Testcase */
/* CPP11 Testcase */
/* end of CPP11 Testcase */
/* Utest Serial Testcase */
/* end of Utest Serial Testcase */
/* Utest IPC Testcase */
/* end of Utest IPC Testcase */
/* RTT Posix Testcase */
/* end of RTT Posix Testcase */
/* Memory Management Subsytem Testcase */
/* end of Memory Management Subsytem Testcase */
/* Tmpfs Testcase */
/* end of Tmpfs Testcase */
/* SMP Testcase */
/* end of SMP Testcase */
/* end of RT-Thread Utestcases */
/* RT-Thread online packages */
/* IoT - internet of things */
/* Wi-Fi */
/* Marvell WiFi */
/* end of Marvell WiFi */
/* Wiced WiFi */
/* end of Wiced WiFi */
/* CYW43012 WiFi */
/* end of CYW43012 WiFi */
/* BL808 WiFi */
/* end of BL808 WiFi */
/* CYW43439 WiFi */
/* end of CYW43439 WiFi */
/* end of Wi-Fi */
/* IoT Cloud */
/* end of IoT Cloud */
/* end of IoT - internet of things */
/* security packages */
/* end of security packages */
/* language packages */
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */
/* XML: Extensible Markup Language */
/* end of XML: Extensible Markup Language */
/* end of language packages */
/* multimedia packages */
/* LVGL: powerful and easy-to-use embedded GUI library */
/* end of LVGL: powerful and easy-to-use embedded GUI library */
/* u8g2: a monochrome graphic library */
/* end of u8g2: a monochrome graphic library */
/* end of multimedia packages */
/* tools packages */
/* end of tools packages */
/* system packages */
/* enhanced kernel services */
/* end of enhanced kernel services */
/* acceleration: Assembly language or algorithmic acceleration packages */
/* end of acceleration: Assembly language or algorithmic acceleration packages */
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
/* Micrium: Micrium software products porting for RT-Thread */
/* end of Micrium: Micrium software products porting for RT-Thread */
/* end of system packages */
/* peripheral libraries and drivers */
/* HAL & SDK Drivers */
/* STM32 HAL & SDK Drivers */
/* end of STM32 HAL & SDK Drivers */
/* Infineon HAL Packages */
/* end of Infineon HAL Packages */
/* Kendryte SDK */
/* end of Kendryte SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */
/* end of sensors drivers */
/* touch drivers */
/* end of touch drivers */
/* end of peripheral libraries and drivers */
/* AI packages */
/* end of AI packages */
/* Signal Processing and Control Algorithm Packages */
/* end of Signal Processing and Control Algorithm Packages */
/* miscellaneous packages */
/* project laboratory */
/* end of project laboratory */
/* samples: kernel and components samples */
/* end of samples: kernel and components samples */
/* entertainment: terminal games and other interesting software packages */
/* end of entertainment: terminal games and other interesting software packages */
/* end of miscellaneous packages */
/* Arduino libraries */
/* Projects and Demos */
/* end of Projects and Demos */
/* Sensors */
/* end of Sensors */
/* Display */
/* end of Display */
/* Timing */
/* end of Timing */
/* Data Processing */
/* end of Data Processing */
/* Data Storage */
/* Communication */
/* end of Communication */
/* Device Control */
/* end of Device Control */
/* Other */
/* end of Other */
/* Signal IO */
/* end of Signal IO */
/* Uncategorized */
/* end of Arduino libraries */
/* end of RT-Thread online packages */
/* Hardware Drivers Config */
/* On-chip Peripheral Drivers */
#define SOC_SERIES_M032
#define BSP_USE_STDDRIVER_SOURCE
#define BSP_USING_PDMA
#define NU_PDMA_MEMFUN_ACTOR_MAX 4
#define NU_PDMA_SGTBL_POOL_SIZE 16
#define BSP_USING_GPIO
#define BSP_USING_CLK
#define NU_CLK_INVOKE_WKTMR
#define BSP_USING_RTC
#define NU_RTC_SUPPORT_IO_RW
#define NU_RTC_SUPPORT_MSH_CMD
#define BSP_USING_ADC
#define BSP_USING_ADC0
#define BSP_USING_TMR
#define BSP_USING_TIMER
#define BSP_USING_TMR0
#define BSP_USING_TIMER0
#define BSP_USING_TMR1
#define BSP_USING_TIMER1
#define BSP_USING_TMR2
#define BSP_USING_TIMER2
#define BSP_USING_UART
#define BSP_USING_UART0
#define BSP_USING_UART1
#define BSP_USING_UART1_TX_DMA
#define BSP_USING_UART1_RX_DMA
#define BSP_USING_UART2
#define BSP_USING_UART3
#define BSP_USING_UART4
#define BSP_USING_UART5
#define BSP_USING_UART6
#define BSP_USING_UART7
#define BSP_USING_WDT
#define BSP_USING_USBD
/* end of On-chip Peripheral Drivers */
/* On-board Peripheral Drivers */
#define BSP_USING_NULINKME
/* end of On-board Peripheral Drivers */
/* Board extended module drivers */
/* end of Board extended module drivers */
/* Nuvoton Packages Config */
#define NU_PKG_USING_UTILS
#define NU_PKG_USING_DEMO
/* end of Nuvoton Packages Config */
/* end of Hardware Drivers Config */
#endif

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

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