mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
[bsp][nuvoton][rsoc] Fix compilation issues with bsp of nuvoton series
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
@@ -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___ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
@@ -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) */
|
||||
|
||||
@@ -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>
|
||||
@@ -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) */
|
||||
|
||||
@@ -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>
|
||||
+157
-24
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+163
-68
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+163
-79
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+162
-59
File diff suppressed because it is too large
Load Diff
@@ -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
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
Reference in New Issue
Block a user