Add sdk_dist.py and ADC touching calibration function.
This commit is contained in:
parent
0b99eee439
commit
f7ba146a01
|
@ -35,24 +35,27 @@ struct nu_adc
|
|||
uint32_t chn_mask;
|
||||
rt_sem_t m_psSem;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
rt_touch_t psRtTouch;
|
||||
rt_timer_t psRtTouchMenuTimer;
|
||||
rt_mq_t m_pmqTouchXYZ;
|
||||
#endif
|
||||
|
||||
nu_adc_cb m_isr[eAdc_ISR_CNT];
|
||||
nu_adc_cb m_wkisr[eAdc_WKISR_CNT];
|
||||
|
||||
rt_mq_t m_pmqTouchXYZ;
|
||||
};
|
||||
typedef struct nu_adc *nu_adc_t;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
struct nu_adc_touch_data
|
||||
{
|
||||
uint16_t u16X;
|
||||
uint16_t u16Y;
|
||||
uint16_t u16Z0;
|
||||
uint16_t u16Z1;
|
||||
uint32_t u32X;
|
||||
uint32_t u32Y;
|
||||
uint32_t u32Z0;
|
||||
uint32_t u32Z1;
|
||||
};
|
||||
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);
|
||||
|
@ -134,6 +137,64 @@ static rt_err_t _nu_adc_init(rt_device_t dev)
|
|||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)userData;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
||||
static struct nu_adc_touch_data point;
|
||||
static rt_bool_t bDrop = RT_FALSE;
|
||||
static uint32_t u32LastZ0 = 0xffffu;
|
||||
|
||||
if (psNuAdc->psRtTouch != RT_NULL)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
value = inpw(REG_ADC_XYDATA);
|
||||
point.u32X = (value & 0x0ffful);
|
||||
point.u32Y = ((value >> 16) & 0x0ffful);
|
||||
|
||||
value = inpw(REG_ADC_ZDATA);
|
||||
point.u32Z0 = (value & 0x0ffful);
|
||||
point.u32Z1 = ((value >> 16) & 0x0ffful);
|
||||
|
||||
/* Trigger next or not. */
|
||||
if (point.u32Z0 == 0)
|
||||
{
|
||||
/* Stop sampling procedure. */
|
||||
rt_timer_stop(g_sNuADC.psRtTouchMenuTimer);
|
||||
|
||||
/* Re-start pendown detection */
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
bDrop = RT_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bDrop = RT_FALSE;
|
||||
}
|
||||
|
||||
/* Notify upper layer. */
|
||||
if ((!bDrop || (u32LastZ0 != 0)) && rt_mq_send(psNuAdc->m_pmqTouchXYZ, (const void *)&point, sizeof(struct nu_adc_touch_data)) == RT_EOK)
|
||||
{
|
||||
rt_hw_touch_isr(psNuAdc->psRtTouch);
|
||||
}
|
||||
|
||||
u32LastZ0 = point.u32Z0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
rt_err_t result = rt_sem_release(psNuAdc->m_psSem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
|
@ -150,60 +211,6 @@ void nu_adc_touch_detect(rt_bool_t bStartDetect)
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
|
||||
{
|
||||
static struct nu_adc_touch_data point;
|
||||
static rt_bool_t bDrop = RT_FALSE;
|
||||
static uint16_t u16LastZ0 = 0xfffful;
|
||||
|
||||
nu_adc_t psNuAdc = (nu_adc_t)userData;
|
||||
|
||||
if (psNuAdc->psRtTouch != RT_NULL)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
value = inpw(REG_ADC_XYDATA);
|
||||
point.u16X = (uint16_t)(value & 0x0ffful);
|
||||
point.u16Y = (uint16_t)((value >> 16) & 0x0ffful);
|
||||
|
||||
value = inpw(REG_ADC_ZDATA);
|
||||
point.u16Z0 = (uint16_t)(value & 0x0ffful);
|
||||
point.u16Z1 = (uint16_t)((value >> 16) & 0x0ffful);
|
||||
|
||||
/* Trigger next or not. */
|
||||
if (point.u16Z0 == 0)
|
||||
{
|
||||
/* Stop sampling procedure. */
|
||||
rt_timer_stop(g_sNuADC.psRtTouchMenuTimer);
|
||||
|
||||
/* Re-start pendown detection */
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
bDrop = RT_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bDrop = RT_FALSE;
|
||||
}
|
||||
|
||||
/* Notify upper layer. */
|
||||
if ((!bDrop || (u16LastZ0 != 0)) && rt_mq_send(psNuAdc->m_pmqTouchXYZ, (const void *)&point, sizeof(struct nu_adc_touch_data)) == RT_EOK)
|
||||
{
|
||||
rt_hw_touch_isr(psNuAdc->psRtTouch);
|
||||
}
|
||||
|
||||
u16LastZ0 = point.u16Z0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_err_t result = rt_sem_release(psNuAdc->m_psSem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int32_t PenDownCallback(uint32_t status, uint32_t userData)
|
||||
{
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
|
@ -213,7 +220,7 @@ static int32_t PenDownCallback(uint32_t status, uint32_t userData)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t nu_adc_read_touch_xyz(uint16_t *bufX, uint16_t *bufY, uint16_t *bufZ0, uint16_t *bufZ1, int32_t dataCnt)
|
||||
int32_t nu_adc_touch_read_xyz(uint32_t *bufX, uint32_t *bufY, uint32_t *bufZ0, uint32_t *bufZ1, int32_t dataCnt)
|
||||
{
|
||||
int i;
|
||||
struct nu_adc_touch_data value;
|
||||
|
@ -223,14 +230,71 @@ int32_t nu_adc_read_touch_xyz(uint16_t *bufX, uint16_t *bufY, uint16_t *bufZ0, u
|
|||
if (rt_mq_recv(g_sNuADC.m_pmqTouchXYZ, (void *)&value, sizeof(struct nu_adc_touch_data), 0) == -RT_ETIMEOUT)
|
||||
break;
|
||||
|
||||
bufX[i] = value.u16X;
|
||||
bufY[i] = value.u16Y;
|
||||
bufZ0[i] = value.u16Z0;
|
||||
bufZ1[i] = value.u16Z1;
|
||||
bufX[i] = value.u32X;
|
||||
bufY[i] = value.u32Y;
|
||||
bufZ0[i] = value.u32Z0;
|
||||
bufZ1[i] = value.u32Z1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void nu_adc_touch_start_conv(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, START_MST, RT_NULL);
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
nu_adc_cb sNuAdcCb;
|
||||
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 4);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
outpw(REG_ADC_CONF, (inpw(REG_ADC_CONF) & ~(0xfful << 24)) | 0xfful << 24);
|
||||
|
||||
/* Register touch device. */
|
||||
psNuAdc->psRtTouch = psRtTouch;
|
||||
|
||||
/* Enable TouchXY. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_ON, RT_NULL);
|
||||
|
||||
/* Enable TouchZZ. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, Z_ON, RT_NULL);
|
||||
|
||||
/* Register PenDown callback. */
|
||||
sNuAdcCb.cbfunc = PenDownCallback;
|
||||
sNuAdcCb.private_data = (rt_uint32_t)psRtTouch;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_ON, (void *)&sNuAdcCb);
|
||||
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_disable(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_OFF, RT_NULL);
|
||||
_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);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
rt_err_t ret = RT_EINVAL ;
|
||||
|
@ -443,7 +507,9 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
|
|||
case Z_OFF: /* Disable Press measure function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_ZEN);
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
rt_mq_control(psNuAdc->m_pmqTouchXYZ, RT_IPC_CMD_RESET, RT_NULL);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -522,61 +588,6 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
|
|||
return RT_EOK;
|
||||
}
|
||||
|
||||
void nu_adc_touch_start_conv(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, START_MST, RT_NULL);
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
nu_adc_cb sNuAdcCb;
|
||||
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 4);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
outpw(REG_ADC_CONF, (inpw(REG_ADC_CONF) & ~(0xfful << 24)) | 0xfful << 24);
|
||||
|
||||
/* Register touch device. */
|
||||
psNuAdc->psRtTouch = psRtTouch;
|
||||
|
||||
/* Enable TouchXY. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_ON, RT_NULL);
|
||||
|
||||
/* Enable TouchZZ. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, Z_ON, RT_NULL);
|
||||
|
||||
/* Register PenDown callback. */
|
||||
sNuAdcCb.cbfunc = PenDownCallback;
|
||||
sNuAdcCb.private_data = (rt_uint32_t)psRtTouch;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_ON, (void *)&sNuAdcCb);
|
||||
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_disable(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_OFF, RT_NULL);
|
||||
_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);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t _nu_adc_open(rt_device_t dev, rt_uint16_t oflag)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)dev;
|
||||
|
@ -709,11 +720,13 @@ int rt_hw_adc_init(void)
|
|||
g_sNuADC.m_psSem = rt_sem_create("adc_mst_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(g_sNuADC.m_psSem != RT_NULL);
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
g_sNuADC.m_pmqTouchXYZ = rt_mq_create("ADC_TOUCH_XYZ", sizeof(struct nu_adc_touch_data), TOUCH_MQ_LENGTH, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(g_sNuADC.m_pmqTouchXYZ != RT_NULL);
|
||||
|
||||
g_sNuADC.psRtTouchMenuTimer = rt_timer_create("TOUCH_SMPL_TIMER", nu_adc_touch_smpl, (void *)&g_sNuADC, DEF_ADC_TOUCH_SMPL_TICK, RT_TIMER_FLAG_PERIODIC);
|
||||
RT_ASSERT(g_sNuADC.psRtTouchMenuTimer != RT_NULL);
|
||||
#endif
|
||||
|
||||
rt_memset(&g_sNuADC.m_isr, 0, sizeof(g_sNuADC.m_isr));
|
||||
rt_memset(&g_sNuADC.m_wkisr, 0, sizeof(g_sNuADC.m_wkisr));
|
||||
|
|
|
@ -15,9 +15,13 @@
|
|||
|
||||
#include <rtthread.h>
|
||||
#include "nu_adc.h"
|
||||
#include "touch.h"
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
#include "touch.h"
|
||||
#endif
|
||||
|
||||
#define TOUCH_MQ_LENGTH 128
|
||||
#define TOUCH_MQ_LENGTH 64
|
||||
|
||||
#define DEF_CAL_POINT_NUM 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -52,13 +56,29 @@ typedef struct
|
|||
|
||||
typedef nu_adc_cb *nu_adc_cb_t;
|
||||
|
||||
int32_t nu_adc_read_touch_xyz(uint16_t *bufX, uint16_t *bufY, uint16_t *bufZ0, uint16_t *bufZ1, int32_t dataCnt);
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
typedef struct
|
||||
{
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
} S_COORDINATE_POINT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t a;
|
||||
int32_t b;
|
||||
int32_t c;
|
||||
int32_t d;
|
||||
int32_t e;
|
||||
int32_t f;
|
||||
int32_t div;
|
||||
} S_CALIBRATION_MATRIX;
|
||||
|
||||
int32_t nu_adc_touch_read_xyz(uint32_t *bufX, uint32_t *bufY, uint32_t *bufZ0, uint32_t *bufZ1, int32_t dataCnt);
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch);
|
||||
rt_err_t nu_adc_touch_disable(void);
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect);
|
||||
void nu_adc_touch_start_conv(void);
|
||||
|
||||
void nu_adc_touch_update_caldata(int *psi32NewValue);
|
||||
void nu_adc_touch_reset_caldata(int *psi32NewValue);
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_ADC_H__ */
|
||||
|
|
|
@ -15,9 +15,15 @@
|
|||
|
||||
#include "NuMicro.h"
|
||||
#include <rtdevice.h>
|
||||
#include <dfs_posix.h>
|
||||
#include "drv_adc.h"
|
||||
#include "touch.h"
|
||||
|
||||
#if !defined(PATH_CALIBRATION_FILE)
|
||||
#define PATH_CALIBRATION_FILE "/mnt/filesystem/ts_calibration"
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct rt_touch_device dev;
|
||||
|
@ -28,35 +34,135 @@ typedef nu_adc_touch *nu_adc_touch_t;
|
|||
|
||||
static nu_adc_touch s_NuAdcTouch = {0};
|
||||
|
||||
#define DEF_CALDATA_LENGTH 7
|
||||
|
||||
#if (BSP_LCD_WIDTH==480) && (BSP_LCD_HEIGHT==272)
|
||||
static int cal_data_a[DEF_CALDATA_LENGTH] = { 8824, -34, -2261272, -70, -6302, 21805816, 65536 };
|
||||
static S_CALIBRATION_MATRIX g_sCalMat = { 8824, -34, -2261272, -70, -6302, 21805816, 65536 };
|
||||
static volatile uint32_t g_u32Calibrated = 1;
|
||||
#elif (BSP_LCD_WIDTH==800) && (BSP_LCD_HEIGHT==480)
|
||||
static int cal_data_a[DEF_CALDATA_LENGTH] = { 13230, -66, -1161952, -85, 8600, -1636996, 65536 };
|
||||
static S_CALIBRATION_MATRIX g_sCalMat = { 13230, -66, -1161952, -85, 8600, -1636996, 65536 };
|
||||
static volatile uint32_t g_u32Calibrated = 1;
|
||||
#else
|
||||
static int cal_data_a[DEF_CALDATA_LENGTH] = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
static S_CALIBRATION_MATRIX g_sCalMat = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
static volatile uint32_t g_u32Calibrated = 0;
|
||||
#endif
|
||||
|
||||
static const int cal_zero[DEF_CALDATA_LENGTH] = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
static int nu_adc_touch_readfile(void);
|
||||
|
||||
static void nu_adc_touch_cal(int *sumx, int *sumy)
|
||||
static const S_CALIBRATION_MATRIX g_sCalZero = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
|
||||
static int nu_adc_cal_mat_get(const S_COORDINATE_POINT *psDispCP, S_COORDINATE_POINT *psADCCP, S_CALIBRATION_MATRIX *psCM)
|
||||
{
|
||||
int xtemp, ytemp;
|
||||
#if (DEF_CAL_POINT_NUM==3)
|
||||
|
||||
psCM->div = ((psADCCP[0].x - psADCCP[2].x) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psADCCP[1].x - psADCCP[2].x) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
if (psCM->div == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
psCM->a = ((psDispCP[0].x - psDispCP[2].x) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psDispCP[1].x - psDispCP[2].x) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
psCM->b = ((psADCCP[0].x - psADCCP[2].x) * (psDispCP[1].x - psDispCP[2].x)) -
|
||||
((psDispCP[0].x - psDispCP[2].x) * (psADCCP[1].x - psADCCP[2].x)) ;
|
||||
|
||||
psCM->c = (psADCCP[2].x * psDispCP[1].x - psADCCP[1].x * psDispCP[2].x) * psADCCP[0].y +
|
||||
(psADCCP[0].x * psDispCP[2].x - psADCCP[2].x * psDispCP[0].x) * psADCCP[1].y +
|
||||
(psADCCP[1].x * psDispCP[0].x - psADCCP[0].x * psDispCP[1].x) * psADCCP[2].y ;
|
||||
|
||||
psCM->d = ((psDispCP[0].y - psDispCP[2].y) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psDispCP[1].y - psDispCP[2].y) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
psCM->e = ((psADCCP[0].x - psADCCP[2].x) * (psDispCP[1].y - psDispCP[2].y)) -
|
||||
((psDispCP[0].y - psDispCP[2].y) * (psADCCP[1].x - psADCCP[2].x)) ;
|
||||
|
||||
psCM->f = (psADCCP[2].x * psDispCP[1].y - psADCCP[1].x * psDispCP[2].y) * psADCCP[0].y +
|
||||
(psADCCP[0].x * psDispCP[2].y - psADCCP[2].x * psDispCP[0].y) * psADCCP[1].y +
|
||||
(psADCCP[1].x * psDispCP[0].y - psADCCP[0].x * psDispCP[1].y) * psADCCP[2].y ;
|
||||
}
|
||||
|
||||
#elif (DEF_CAL_POINT_NUM==5)
|
||||
|
||||
int i;
|
||||
float n, x, y, xx, yy, xy, z, zx, zy;
|
||||
float a, b, c, d, e, f, g;
|
||||
float scaling = 65536.0f;
|
||||
|
||||
n = x = y = xx = yy = xy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
n += 1.0;
|
||||
x += (float)psADCCP[i].x;
|
||||
y += (float)psADCCP[i].y;
|
||||
xx += (float)psADCCP[i].x * psADCCP[i].x;
|
||||
yy += (float)psADCCP[i].y * psADCCP[i].y;
|
||||
xy += (float)psADCCP[i].x * psADCCP[i].y;
|
||||
}
|
||||
|
||||
d = n * (xx * yy - xy * xy) + x * (xy * y - x * yy) + y * (x * xy - y * xx);
|
||||
if (d < 0.1 && d > -0.1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
a = (xx * yy - xy * xy) / d;
|
||||
b = (xy * y - x * yy) / d;
|
||||
c = (x * xy - y * xx) / d;
|
||||
e = (n * yy - y * y) / d;
|
||||
f = (x * y - n * xy) / d;
|
||||
g = (n * xx - x * x) / d;
|
||||
|
||||
z = zx = zy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
z += (float)psDispCP[i].x;
|
||||
zx += (float)psDispCP[i].x * psADCCP[i].x;
|
||||
zy += (float)psDispCP[i].x * psADCCP[i].y;
|
||||
}
|
||||
|
||||
psCM->c = (int32_t)((a * z + b * zx + c * zy) * scaling);
|
||||
psCM->a = (int32_t)((b * z + e * zx + f * zy) * scaling);
|
||||
psCM->b = (int32_t)((c * z + f * zx + g * zy) * scaling);
|
||||
|
||||
z = zx = zy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
z += (float)psDispCP[i].y;
|
||||
zx += (float)psDispCP[i].y * psADCCP[i].x;
|
||||
zy += (float)psDispCP[i].y * psADCCP[i].y;
|
||||
}
|
||||
|
||||
psCM->f = (int32_t)((a * z + b * zx + c * zy) * scaling);
|
||||
psCM->d = (int32_t)((b * z + e * zx + f * zy) * scaling);
|
||||
psCM->e = (int32_t)((c * z + f * zx + g * zy) * scaling);
|
||||
|
||||
psCM->div = (int32_t)scaling;
|
||||
|
||||
#else
|
||||
#error "Not supported calibration method"
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nu_adc_touch_cal(int32_t *sumx, int32_t *sumy)
|
||||
{
|
||||
int32_t xtemp, ytemp;
|
||||
|
||||
xtemp = *sumx;
|
||||
ytemp = *sumy;
|
||||
*sumx = (cal_data_a[2] +
|
||||
cal_data_a[0] * xtemp +
|
||||
cal_data_a[1] * ytemp) / cal_data_a[6];
|
||||
*sumy = (cal_data_a[5] +
|
||||
cal_data_a[3] * xtemp +
|
||||
cal_data_a[4] * ytemp) / cal_data_a[6];
|
||||
*sumx = (g_sCalMat.c +
|
||||
g_sCalMat.a * xtemp +
|
||||
g_sCalMat.b * ytemp) / g_sCalMat.div;
|
||||
*sumy = (g_sCalMat.f +
|
||||
g_sCalMat.d * xtemp +
|
||||
g_sCalMat.e * ytemp) / g_sCalMat.div;
|
||||
}
|
||||
|
||||
static rt_size_t nu_adc_touch_readpoint(struct rt_touch_device *device, void *buf, rt_size_t read_num)
|
||||
{
|
||||
static int last_report_x = 0, last_report_y = 0;
|
||||
static uint32_t last_report_x = 0, last_report_y = 0;
|
||||
struct rt_touch_data *pPoint = (struct rt_touch_data *)buf;
|
||||
nu_adc_touch_t psNuAdcTouch = (nu_adc_touch_t)device;
|
||||
|
||||
|
@ -67,38 +173,44 @@ static rt_size_t nu_adc_touch_readpoint(struct rt_touch_device *device, void *bu
|
|||
|
||||
for (i = 0; i < read_num; i++)
|
||||
{
|
||||
int bufZ0 = 0, bufZ1 = 0;
|
||||
int sumx = 0, sumy = 0;
|
||||
uint32_t bufZ0 = 0, bufZ1 = 0;
|
||||
int32_t sumx = 0, sumy = 0;
|
||||
pPoint[i].timestamp = rt_touch_get_ts();
|
||||
pPoint[i].track_id = 0;
|
||||
|
||||
if (nu_adc_read_touch_xyz((uint16_t *)&sumx, (uint16_t *)&sumy, (uint16_t *)&bufZ0, (uint16_t *)&bufZ1, 1) != 1)
|
||||
if (nu_adc_touch_read_xyz((uint32_t *)&sumx, (uint32_t *)&sumy, &bufZ0, &bufZ1, 1) != 1)
|
||||
break;
|
||||
|
||||
if (bufZ0 == 0)
|
||||
{
|
||||
/* Workaround: In this case, x, y values are unstable. so, report last point's coordinate.*/
|
||||
pPoint[i].event = RT_TOUCH_EVENT_UP;
|
||||
pPoint[i].x_coordinate = last_report_x;
|
||||
pPoint[i].y_coordinate = last_report_y;
|
||||
pPoint[i].x_coordinate = (uint16_t)last_report_x;
|
||||
pPoint[i].y_coordinate = (uint16_t)last_report_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
nu_adc_touch_cal(&sumx, &sumy);
|
||||
pPoint[i].event = RT_TOUCH_EVENT_DOWN;
|
||||
pPoint[i].x_coordinate = sumx;
|
||||
pPoint[i].y_coordinate = sumy;
|
||||
if (g_u32Calibrated)
|
||||
{
|
||||
nu_adc_touch_cal(&sumx, &sumy);
|
||||
}
|
||||
last_report_x = sumx;
|
||||
last_report_y = sumy;
|
||||
|
||||
pPoint[i].event = RT_TOUCH_EVENT_DOWN;
|
||||
pPoint[i].x_coordinate = (uint16_t)sumx;
|
||||
pPoint[i].y_coordinate = (uint16_t)sumy;
|
||||
}
|
||||
|
||||
bufZ0 = bufZ0 >> 3;
|
||||
if (g_u32Calibrated)
|
||||
{
|
||||
bufZ0 = bufZ0 >> 3;
|
||||
pPoint[i].width = (bufZ0 > 255) ? 255 : bufZ0;
|
||||
|
||||
pPoint[i].width = (bufZ0 > 255) ? 255 : bufZ0;
|
||||
|
||||
//Limit max x, y coordinate if value is over its range.
|
||||
pPoint[i].x_coordinate = (pPoint[i].x_coordinate > psNuAdcTouch->x_range) ? psNuAdcTouch->x_range : pPoint[i].x_coordinate;
|
||||
pPoint[i].y_coordinate = (pPoint[i].y_coordinate > psNuAdcTouch->y_range) ? psNuAdcTouch->y_range : pPoint[i].y_coordinate;
|
||||
//Limit max x, y coordinate if value is over its range.
|
||||
pPoint[i].x_coordinate = (pPoint[i].x_coordinate > psNuAdcTouch->x_range) ? psNuAdcTouch->x_range : pPoint[i].x_coordinate;
|
||||
pPoint[i].y_coordinate = (pPoint[i].y_coordinate > psNuAdcTouch->y_range) ? psNuAdcTouch->y_range : pPoint[i].y_coordinate;
|
||||
}
|
||||
}
|
||||
return (rt_size_t)i;
|
||||
}
|
||||
|
@ -144,14 +256,29 @@ static struct rt_touch_ops touch_ops =
|
|||
.touch_control = nu_adc_touch_control,
|
||||
};
|
||||
|
||||
void nu_adc_touch_update_caldata(int *psi32NewValue)
|
||||
static void nu_adc_touch_update_calmat(S_CALIBRATION_MATRIX *psNewCalMat)
|
||||
{
|
||||
rt_memcpy(&cal_data_a[0], &psi32NewValue[0], sizeof(cal_data_a));
|
||||
if (psNewCalMat &&
|
||||
psNewCalMat->div != 0)
|
||||
{
|
||||
rt_memcpy(&g_sCalMat, psNewCalMat, sizeof(S_CALIBRATION_MATRIX));
|
||||
g_u32Calibrated = 1;
|
||||
rt_kprintf("Applied calibration data: %d, %d, %d, %d, %d, %d, %d\n",
|
||||
g_sCalMat.a,
|
||||
g_sCalMat.b,
|
||||
g_sCalMat.c,
|
||||
g_sCalMat.d,
|
||||
g_sCalMat.e,
|
||||
g_sCalMat.f,
|
||||
g_sCalMat.div);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void nu_adc_touch_reset_caldata(int *psi32NewValue)
|
||||
static void nu_adc_touch_reset_calmat(void)
|
||||
{
|
||||
rt_memcpy(&cal_data_a[0], &cal_zero[0], sizeof(cal_data_a));
|
||||
rt_memcpy(&g_sCalMat, &g_sCalZero, sizeof(S_CALIBRATION_MATRIX));
|
||||
g_u32Calibrated = 0;
|
||||
}
|
||||
|
||||
int rt_hw_adc_touch_init(void)
|
||||
|
@ -173,10 +300,268 @@ INIT_DEVICE_EXPORT(rt_hw_adc_touch_init);
|
|||
static rt_thread_t adc_touch_thread = RT_NULL;
|
||||
static rt_sem_t adc_touch_sem = RT_NULL;
|
||||
static int adc_touch_worker_run = 0;
|
||||
|
||||
static rt_err_t adc_touch_rx_callback(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
rt_sem_release(adc_touch_sem);
|
||||
//rt_kprintf("[%s %d] %d\n", __func__, __LINE__, size);
|
||||
return rt_sem_release(adc_touch_sem);
|
||||
}
|
||||
|
||||
static rt_err_t adc_request_point(rt_device_t pdev, struct rt_touch_data *psTouchPoint)
|
||||
{
|
||||
rt_err_t ret = -RT_ERROR;
|
||||
|
||||
if ((ret = rt_sem_take(adc_touch_sem, rt_tick_from_millisecond(500))) == RT_EOK)
|
||||
{
|
||||
rt_memset(psTouchPoint, 0, sizeof(struct rt_touch_data));
|
||||
|
||||
if (rt_device_read(pdev, 0, psTouchPoint, s_NuAdcTouch.dev.info.point_num) == s_NuAdcTouch.dev.info.point_num)
|
||||
{
|
||||
ret = RT_EOK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RT_WEAK void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t event)
|
||||
{
|
||||
}
|
||||
|
||||
static rt_device_t lcd_device = 0;
|
||||
static struct rt_device_graphic_info info;
|
||||
|
||||
static void lcd_cleanscreen(void)
|
||||
{
|
||||
if (info.framebuffer != RT_NULL)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
|
||||
rt_memset(info.framebuffer, 0, (info.pitch * info.height));
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = info.width;
|
||||
rect.height = info.height;
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
#define DEF_DOT_NUMBER 9
|
||||
#define DOTS_NUMBER (DEF_DOT_NUMBER*DEF_DOT_NUMBER)
|
||||
static void nu_draw_bots(int x, int y)
|
||||
{
|
||||
if (info.framebuffer != RT_NULL)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
int i, j;
|
||||
int start_x = x - (DEF_DOT_NUMBER / 2);
|
||||
int start_y = y - (DEF_DOT_NUMBER / 2);
|
||||
|
||||
if (info.pixel_format == RTGRAPHIC_PIXEL_FORMAT_RGB565)
|
||||
{
|
||||
uint16_t *pu16Start = (uint16_t *)((uint32_t)info.framebuffer + (start_y) * info.pitch + (start_x * 2));
|
||||
for (j = 0; j < DEF_DOT_NUMBER; j++)
|
||||
{
|
||||
for (i = 0; i < DEF_DOT_NUMBER; i++)
|
||||
pu16Start[i] = 0x07E0; //Green, RGB
|
||||
pu16Start += info.width;
|
||||
}
|
||||
}
|
||||
else if (info.pixel_format == RTGRAPHIC_PIXEL_FORMAT_ARGB888)
|
||||
{
|
||||
uint32_t *pu32Start = (uint32_t *)((uint32_t)info.framebuffer + (start_y) * info.pitch + (start_x * 4));
|
||||
for (j = 0; j < DEF_DOT_NUMBER; j++)
|
||||
{
|
||||
for (i = 0; i < DEF_DOT_NUMBER; i++)
|
||||
pu32Start[i] = 0xff00ff00; //Green, ARGB
|
||||
pu32Start += info.width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Not supported
|
||||
}
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = info.width;
|
||||
rect.height = info.height;
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
#if (DEF_CAL_POINT_NUM==3)
|
||||
const S_COORDINATE_POINT sDispPoints[DEF_CAL_POINT_NUM] =
|
||||
{
|
||||
{BSP_LCD_WIDTH / 4, BSP_LCD_HEIGHT / 2},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / 4, BSP_LCD_HEIGHT / 4},
|
||||
{BSP_LCD_WIDTH / 2, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / 4}
|
||||
};
|
||||
#elif (DEF_CAL_POINT_NUM==5)
|
||||
const static S_COORDINATE_POINT sDispPoints[DEF_CAL_POINT_NUM] =
|
||||
{
|
||||
#define DEF_CUT_PIECES 8
|
||||
{BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
|
||||
{BSP_LCD_WIDTH / 2, BSP_LCD_HEIGHT / 2}
|
||||
};
|
||||
#endif
|
||||
|
||||
static int nu_adc_touch_readfile(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
S_CALIBRATION_MATRIX sCalMat;
|
||||
|
||||
if ((fd = open(PATH_CALIBRATION_FILE, O_RDONLY, 0)) < 0)
|
||||
{
|
||||
goto exit_nu_adc_touch_readfile;
|
||||
}
|
||||
else if (read(fd, &sCalMat, sizeof(S_CALIBRATION_MATRIX)) == sizeof(S_CALIBRATION_MATRIX))
|
||||
{
|
||||
rt_kprintf("[%s] %s\n", __func__, PATH_CALIBRATION_FILE);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
nu_adc_touch_update_calmat(&sCalMat);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_nu_adc_touch_readfile:
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int nu_adc_touch_writefile(void *buf, int buf_len)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(PATH_CALIBRATION_FILE, O_WRONLY | O_CREAT, 0)) < 0)
|
||||
{
|
||||
goto exit_nu_adc_touch_writefile;
|
||||
}
|
||||
else if (write(fd, buf, buf_len) == buf_len)
|
||||
{
|
||||
rt_kprintf("[%s] %s\n", __func__, PATH_CALIBRATION_FILE);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_nu_adc_touch_writefile:
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void nu_touch_do_calibration(rt_device_t pdev)
|
||||
{
|
||||
int i;
|
||||
rt_err_t result;
|
||||
|
||||
S_CALIBRATION_MATRIX sCalMat;
|
||||
S_COORDINATE_POINT sADCPoints[DEF_CAL_POINT_NUM];
|
||||
|
||||
lcd_device = rt_device_find("lcd");
|
||||
if (!lcd_device)
|
||||
{
|
||||
rt_kprintf("Not supported graphics ops\n");
|
||||
return;
|
||||
}
|
||||
|
||||
result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
rt_kprintf("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
rt_kprintf("opened?");
|
||||
}
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_PAN_DISPLAY, info.framebuffer);
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_POWERON, RT_NULL);
|
||||
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
struct rt_touch_data sTouchPoint;
|
||||
int count = 0;
|
||||
|
||||
lcd_cleanscreen();
|
||||
|
||||
/* Drain RX queue before doing calibrate. */
|
||||
while (adc_request_point(pdev, &sTouchPoint) == RT_EOK);
|
||||
|
||||
rt_thread_mdelay(100);
|
||||
|
||||
/* Ready to calibrate */
|
||||
nu_draw_bots(sDispPoints[i].x, sDispPoints[i].y);
|
||||
|
||||
#define DEF_MAX_GET_POINT_NUM 5
|
||||
|
||||
sADCPoints[i].x = 0;
|
||||
sADCPoints[i].y = 0;
|
||||
|
||||
while (count < DEF_MAX_GET_POINT_NUM)
|
||||
{
|
||||
if (adc_request_point(pdev, &sTouchPoint) == RT_EOK)
|
||||
{
|
||||
sADCPoints[i].x += (int32_t)sTouchPoint.x_coordinate;
|
||||
sADCPoints[i].y += (int32_t)sTouchPoint.y_coordinate;
|
||||
rt_kprintf("[%d %d] - Disp:[%d, %d] -> ADC:[%d, %d]\n", i, count, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
sADCPoints[i].x = (int32_t)((float)sADCPoints[i].x / DEF_MAX_GET_POINT_NUM);
|
||||
sADCPoints[i].y = (int32_t)((float)sADCPoints[i].y / DEF_MAX_GET_POINT_NUM);
|
||||
rt_kprintf("[%d] - Disp:[%d, %d], ADC:[%d, %d]\n", i, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
|
||||
rt_thread_mdelay(300);
|
||||
}
|
||||
|
||||
lcd_cleanscreen();
|
||||
|
||||
/* Get calibration matrix. */
|
||||
if (nu_adc_cal_mat_get(&sDispPoints[0], &sADCPoints[0], &sCalMat) == 0)
|
||||
{
|
||||
/* Finally, update calibration matrix to drivers. */
|
||||
nu_adc_touch_update_calmat(&sCalMat);
|
||||
|
||||
nu_adc_touch_writefile(&sCalMat, sizeof(sCalMat));
|
||||
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
rt_kprintf("[%d] - Disp:[%d, %d], ADC:[%d, %d]\n", i, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Failed to calibrate.\n");
|
||||
}
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_POWEROFF, RT_NULL);
|
||||
rt_device_close(lcd_device);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void adc_touch_entry(void *parameter)
|
||||
|
@ -184,13 +569,22 @@ static void adc_touch_entry(void *parameter)
|
|||
struct rt_touch_data touch_point;
|
||||
|
||||
rt_err_t result;
|
||||
rt_device_t pdev = &s_NuAdcTouch.dev.parent;
|
||||
rt_device_t pdev;
|
||||
|
||||
int max_range;
|
||||
|
||||
adc_touch_sem = rt_sem_create("adc_touch_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(adc_touch_sem != RT_NULL);
|
||||
|
||||
pdev = rt_device_find("adc_touch");
|
||||
if (!pdev)
|
||||
{
|
||||
rt_kprintf("Not found\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
nu_adc_touch_readfile();
|
||||
|
||||
result = rt_device_open(pdev, RT_DEVICE_FLAG_INT_RX);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
|
@ -205,45 +599,33 @@ static void adc_touch_entry(void *parameter)
|
|||
result = rt_device_control(pdev, RT_TOUCH_CTRL_SET_Y_RANGE, (void *)&max_range);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
// nu_adc_touch_reset_caldata(int *psi32NewValue);
|
||||
// nu_adc_touch_update_caldata(int *psi32NewValue);
|
||||
|
||||
result = rt_device_control(pdev, RT_TOUCH_CTRL_POWER_ON, RT_NULL);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
while (adc_touch_worker_run)
|
||||
{
|
||||
if ((-RT_ETIMEOUT == rt_sem_take(adc_touch_sem, rt_tick_from_millisecond(100))))
|
||||
if (!g_u32Calibrated)
|
||||
{
|
||||
rt_kprintf("Start ADC touching calibration.\n");
|
||||
nu_touch_do_calibration(pdev);
|
||||
rt_kprintf("Stop ADC touching calibration.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
rt_memset(&touch_point, 0, sizeof(struct rt_touch_data));
|
||||
|
||||
if (rt_device_read(pdev, 0, &touch_point, s_NuAdcTouch.dev.info.point_num) == s_NuAdcTouch.dev.info.point_num)
|
||||
if (adc_request_point(pdev, &touch_point) == RT_EOK)
|
||||
{
|
||||
if (touch_point.event == RT_TOUCH_EVENT_DOWN
|
||||
|| touch_point.event == RT_TOUCH_EVENT_UP
|
||||
|| touch_point.event == RT_TOUCH_EVENT_MOVE)
|
||||
{
|
||||
|
||||
#if defined(PKG_USING_LVGL)
|
||||
extern void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
|
||||
nu_touch_inputevent_cb(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
|
||||
#elif defined(PKG_USING_LITTLEVGL2RTT)
|
||||
extern void littlevgl2rtt_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
|
||||
littlevgl2rtt_send_input_event(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
|
||||
#endif
|
||||
|
||||
#if defined(PKG_USING_NUEMWIN)
|
||||
extern void nuemwin_send_input_event(rt_int16_t x, rt_int16_t y, rt_uint8_t state);
|
||||
nuemwin_send_input_event(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
|
||||
#endif
|
||||
rt_kprintf("[%d-%d] id=%d width=%d x=%d y=%d\n",
|
||||
touch_point.timestamp,
|
||||
touch_point.event,
|
||||
touch_point.track_id,
|
||||
touch_point.width,
|
||||
rt_kprintf("x=%d y=%d event=%s%s%s\n",
|
||||
touch_point.x_coordinate,
|
||||
touch_point.y_coordinate);
|
||||
touch_point.y_coordinate,
|
||||
(touch_point.event == RT_TOUCH_EVENT_DOWN) ? "DOWN" : "",
|
||||
(touch_point.event == RT_TOUCH_EVENT_UP) ? "UP" : "",
|
||||
(touch_point.event == RT_TOUCH_EVENT_MOVE) ? "MOVE" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +646,7 @@ static rt_err_t nu_touch_start(int argc, char **argv)
|
|||
adc_touch_thread = rt_thread_create("adc_touch_thread",
|
||||
adc_touch_entry,
|
||||
RT_NULL,
|
||||
2048,
|
||||
4096,
|
||||
25,
|
||||
5);
|
||||
adc_touch_worker_run = 1;
|
||||
|
@ -275,12 +657,6 @@ static rt_err_t nu_touch_start(int argc, char **argv)
|
|||
}
|
||||
MSH_CMD_EXPORT(nu_touch_start, e.g: start adc touch);
|
||||
|
||||
static int nu_touch_autostart(void)
|
||||
{
|
||||
return nu_touch_start(0, RT_NULL);
|
||||
}
|
||||
INIT_APP_EXPORT(nu_touch_autostart);
|
||||
|
||||
/* Support "nu_touch_stop" command line in msh mode */
|
||||
static rt_err_t nu_touch_stop(int argc, char **argv)
|
||||
{
|
||||
|
@ -290,4 +666,19 @@ static rt_err_t nu_touch_stop(int argc, char **argv)
|
|||
}
|
||||
MSH_CMD_EXPORT(nu_touch_stop, e.g: stop adc touch);
|
||||
|
||||
static int nu_touch_autostart(void)
|
||||
{
|
||||
return nu_touch_start(0, RT_NULL);
|
||||
}
|
||||
INIT_APP_EXPORT(nu_touch_autostart);
|
||||
|
||||
static rt_err_t nu_touch_calibration(int argc, char **argv)
|
||||
{
|
||||
/* Clean calibration matrix data for getting raw adc value. */
|
||||
nu_adc_touch_reset_calmat();
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(nu_touch_calibration, for adc touch);
|
||||
|
||||
#endif //#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
|
|
@ -27,6 +27,7 @@ static struct rt_device_graphic_info g_Ili9341Info =
|
|||
.pixel_format = RTGRAPHIC_PIXEL_FORMAT_RGB565,
|
||||
.framebuffer = RT_NULL,
|
||||
.width = XSIZE_PHYS,
|
||||
.pitch = XSIZE_PHYS * 2,
|
||||
.height = YSIZE_PHYS
|
||||
};
|
||||
|
||||
|
@ -324,7 +325,7 @@ int rt_hw_lcd_ili9341_init(void)
|
|||
lcd_device.user_data = &ili9341_ops;
|
||||
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
g_Ili9341Info.framebuffer = rt_malloc_align((DEF_VRAM_BUFFER_NUMBER * g_Ili9341Info.width * g_Ili9341Info.height * (g_Ili9341Info.bits_per_pixel / 8)) + 32, 32);
|
||||
g_Ili9341Info.framebuffer = rt_malloc_align((DEF_VRAM_BUFFER_NUMBER * g_Ili9341Info.pitch * g_Ili9341Info.height) + 32, 32);
|
||||
RT_ASSERT(g_Ili9341Info.framebuffer != RT_NULL);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ menu "Nuvoton Packages Config"
|
|||
bool "ILI9341 LCD Panel"
|
||||
select BSP_USING_GPIO
|
||||
default n
|
||||
|
||||
|
||||
if NU_PKG_USING_ILI9341
|
||||
|
||||
choice
|
||||
|
@ -62,8 +62,20 @@ menu "Nuvoton Packages Config"
|
|||
default n
|
||||
|
||||
config NU_PKG_ILI9341_HORIZONTAL
|
||||
bool "Set horizontal view. (320x240)"
|
||||
default n
|
||||
bool
|
||||
default y
|
||||
|
||||
config BSP_LCD_BPP
|
||||
int
|
||||
default 16 if NU_PKG_USING_ILI9341
|
||||
|
||||
config BSP_LCD_WIDTH
|
||||
int
|
||||
default 320 if NU_PKG_ILI9341_HORIZONTAL
|
||||
|
||||
config BSP_LCD_HEIGHT
|
||||
int
|
||||
default 240 if NU_PKG_ILI9341_HORIZONTAL
|
||||
|
||||
endif
|
||||
|
||||
|
|
|
@ -35,51 +35,142 @@ extern "C"
|
|||
#define ADC_ERR_CMD 2 /*!< The command is wrong */
|
||||
|
||||
/// @cond HIDDEN_SYMBOLS
|
||||
typedef INT32(*ADC_CALLBACK)(UINT32 status, UINT32 userData);
|
||||
typedef int32_t(*ADC_CALLBACK)(uint32_t status, uint32_t userData);
|
||||
/// @endcond HIDDEN_SYMBOLS
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
/* ADC_CTL constant definitions */
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
#define ADC_CTL_ADEN 0x00000001 /*!< ADC Power Control */
|
||||
#define ADC_CTL_VBGEN 0x00000002 /*!< ADC Internal Bandgap Power Control */
|
||||
#define ADC_CTL_VBGEN 0x00000002 /*!< ADC Internal Bandgap Power Control */
|
||||
#define ADC_CTL_PWKPEN 0x00000004 /*!< ADC Keypad Power Enable Control */
|
||||
#define ADC_CTL_MST 0x00000100 /*!< Menu Start Conversion */
|
||||
#define ADC_CTL_PEDEEN 0x00000200 /*!< Pen Down Event Enable */
|
||||
#define ADC_CTL_WKPEN 0x00000400 /*!< Keypad Press Wake Up Enable */
|
||||
#define ADC_CTL_WKTEN 0x00000800 /*!< Touch Wake Up Enable */
|
||||
#define ADC_CTL_WMSWCH 0x00010000 /*!< Wire Mode Switch For 5-Wire/4-Wire Configuration */
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
/* ADC_CONF constant definitions */
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
#define ADC_CONF_TEN 0x00000001 /*!< Touch Enable */
|
||||
#define ADC_CONF_ZEN 0x00000002 /*!< Press Enable */
|
||||
#define ADC_CONF_NACEN 0x00000004 /*!< Normal AD Conversion Enable */
|
||||
#define ADC_CONF_VBATEN 0x00000100 /*!< Voltage Battery Enable */
|
||||
#define ADC_CONF_KPCEN 0x00000200 /*!< Keypad Press Conversion Enable */
|
||||
#define ADC_CONF_SELFTEN 0x00000400 /*!< Selft Test Enable */
|
||||
#define ADC_CONF_DISTMAVEN (1<<20) /*!< Display T Mean Average Enable */
|
||||
#define ADC_CONF_DISZMAVEN (1<<21) /*!< Display Z Mean Average Enable */
|
||||
#define ADC_CONF_HSPEED (1<<22) /*!< High Speed Enable */
|
||||
|
||||
#define ADC_CONF_CHSEL_Pos 12 /*!< Channel Selection Position */
|
||||
#define ADC_CONF_CHSEL_Msk (0xF<<ADC_CONF_CHSEL_Pos) /*!< Channel Selection Mask */
|
||||
#define ADC_CONF_CHSEL_Pos 3 /*!< Channel Selection Position */
|
||||
#define ADC_CONF_CHSEL_Msk (7<<3) /*!< Channel Selection Mask */
|
||||
#define ADC_CONF_CHSEL_VBT (0<<3) /*!< ADC input channel select VBT */
|
||||
#define ADC_CONF_CHSEL_VHS (1<<3) /*!< ADC input channel select VHS */
|
||||
#define ADC_CONF_CHSEL_A2 (2<<3) /*!< ADC input channel select A2 */
|
||||
#define ADC_CONF_CHSEL_A3 (3<<3) /*!< ADC input channel select A3 */
|
||||
#define ADC_CONF_CHSEL_YM (4<<3) /*!< ADC input channel select YM */
|
||||
#define ADC_CONF_CHSEL_YP (5<<3) /*!< ADC input channel select YP */
|
||||
#define ADC_CONF_CHSEL_XM (6<<3) /*!< ADC input channel select XM */
|
||||
#define ADC_CONF_CHSEL_XP (7<<3) /*!< ADC input channel select XP */
|
||||
|
||||
#define ADC_CONF_REFSEL_Pos 6 /*!< Reference Selection Position */
|
||||
#define ADC_CONF_REFSEL_Msk (3<<6) /*!< Reference Selection Mask */
|
||||
#define ADC_CONF_REFSEL_VREF (0<<6) /*!< ADC reference select VREF input */
|
||||
#define ADC_CONF_REFSEL_AVDD33 (3<<6) /*!< ADC reference select AGND33 vs AVDD33 */
|
||||
#define ADC_CONF_REFSEL_Pos 6 /*!< Reference Selection Position */
|
||||
#define ADC_CONF_REFSEL_Msk (3<<6) /*!< Reference Selection Mask */
|
||||
#define ADC_CONF_REFSEL_VREF (0<<6) /*!< ADC reference select VREF input or 2.5v buffer output */
|
||||
#define ADC_CONF_REFSEL_YMYP (1<<6) /*!< ADC reference select YM vs YP */
|
||||
#define ADC_CONF_REFSEL_XMXP (2<<6) /*!< ADC reference select XM vs XP */
|
||||
#define ADC_CONF_REFSEL_AVDD33 (3<<6) /*!< ADC reference select AGND33 vs AVDD33 */
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
/* ADC_IER constant definitions */
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
#define ADC_IER_MIEN 0x00000001 /*!< Menu Interrupt Enable */
|
||||
#define ADC_IER_MIEN 0x00000001 /*!< Menu Interrupt Enable */
|
||||
#define ADC_IER_KPEIEN 0x00000002 /*!< Keypad Press Event Interrupt Enable */
|
||||
#define ADC_IER_PEDEIEN 0x00000004 /*!< Pen Down Even Interrupt Enable */
|
||||
#define ADC_IER_WKTIEN 0x00000008 /*!< Wake Up Touch Interrupt Enable */
|
||||
#define ADC_IER_WKPIEN 0x00000010 /*!< Wake Up Keypad Press Interrupt Enable */
|
||||
#define ADC_IER_KPUEIEN 0x00000020 /*!< Keypad Press Up Event Interrupt Enable */
|
||||
#define ADC_IER_PEUEIEN 0x00000040 /*!< Pen Up Event Interrupt Enable */
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
/* ADC_ISR constant definitions */
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
#define ADC_ISR_MF 0x00000001 /*!< Menu Complete Flag */
|
||||
#define ADC_ISR_KPEF 0x00000002 /*!< Keypad Press Event Flag */
|
||||
#define ADC_ISR_PEDEF 0x00000004 /*!< Pen Down Event Flag */
|
||||
#define ADC_ISR_KPUEF 0x00000008 /*!< Keypad Press Up Event Flag */
|
||||
#define ADC_ISR_PEUEF 0x00000010 /*!< Pen Up Event Flag */
|
||||
#define ADC_ISR_TF 0x00000100 /*!< Touch Conversion Finish */
|
||||
#define ADC_ISR_ZF 0x00000200 /*!< Press Conversion Finish */
|
||||
#define ADC_ISR_NACF 0x00000400 /*!< Normal AD Conversion Finish */
|
||||
#define ADC_ISR_VBF 0x00000800 /*!< Voltage Battery Conversion Finish */
|
||||
#define ADC_ISR_KPCF 0x00001000 /*!< Keypad Press Conversion Finish */
|
||||
#define ADC_ISR_SELFTF 0x00002000 /*!< Self-Test Conversion Finish */
|
||||
#define ADC_ISR_INTKP 0x00010000 /*!< Interrupt Signal For Keypad Detection */
|
||||
#define ADC_ISR_INTTC 0x00020000 /*!< Interrupt Signal For Touch Screen Touching Detection */
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
/* ADC_WKISR constant definitions */
|
||||
/*---------------------------------------------------------------------------------------------------------*/
|
||||
#define ADC_WKISR_WKPEF 0x00000001 /*!< Wake Up Pen Down Event Flag */
|
||||
#define ADC_WKISR_WPEDEF 0x00000002 /*!< Wake Up Keypad Press Event Flage */
|
||||
|
||||
/** \brief Structure type of ADC_CHAN
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
AIN0 = ADC_CONF_CHSEL_VBT, /*!< ADC input channel select \ref ADC_CONF_CHSEL_VBT */
|
||||
AIN1 = ADC_CONF_CHSEL_VHS, /*!< ADC input channel select \ref ADC_CONF_CHSEL_VHS */
|
||||
AIN2 = ADC_CONF_CHSEL_A2, /*!< ADC input channel select \ref ADC_CONF_CHSEL_A2 */
|
||||
AIN3 = ADC_CONF_CHSEL_A3, /*!< ADC input channel select \ref ADC_CONF_CHSEL_A3 */
|
||||
AIN4 = ADC_CONF_CHSEL_YM, /*!< ADC input channel select \ref ADC_CONF_CHSEL_YM */
|
||||
AIN5 = ADC_CONF_CHSEL_XP, /*!< ADC input channel select \ref ADC_CONF_CHSEL_XP */
|
||||
AIN6 = ADC_CONF_CHSEL_XM, /*!< ADC input channel select \ref ADC_CONF_CHSEL_XM */
|
||||
AIN7 = ADC_CONF_CHSEL_XP /*!< ADC input channel select \ref ADC_CONF_CHSEL_XP */
|
||||
} ADC_CHAN;
|
||||
|
||||
/** \brief Structure type of ADC_CMD
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
START_MST, /*!<Menu Start Conversion */
|
||||
VBPOWER_ON, /*!<Enable ADC Internal Bandgap Power */
|
||||
VBPOWER_OFF, /*!<Disable ADC Internal Bandgap Power */
|
||||
NAC_ON, /*!<Enable Normal AD Conversion */
|
||||
NAC_OFF, /*!<Disable Normal AD Conversion */
|
||||
START_MST, /*!<Menu Start Conversion with interrupt */
|
||||
START_MST_POLLING, /*!<Menu Start Conversion with polling */
|
||||
VBPOWER_ON, /*!<Enable ADC Internal Bandgap Power */
|
||||
VBPOWER_OFF, /*!<Disable ADC Internal Bandgap Power */
|
||||
VBAT_ON, /*!<Enable Voltage Battery conversion function */
|
||||
VBAT_OFF, /*!<Disable Voltage Battery conversion function */
|
||||
|
||||
KPPOWER_ON, /*!<Enable ADC Keypad power */
|
||||
KPPOWER_OFF, /*!<Disable ADC Keypad power */
|
||||
KPCONV_ON, /*!<Enable Keypad conversion function */
|
||||
KPCONV_OFF, /*!<Disable Keypad conversion function */
|
||||
KPPRESS_ON, /*!<Enable Keypad press event */
|
||||
KPPRESS_OFF, /*!<Disable Keypad press event */
|
||||
KPUP_ON, /*!<Enable Keypad up event */
|
||||
KPUP_OFF, /*!<Disable Keypad up event */
|
||||
|
||||
PEPOWER_ON, /*!<Enable Pen Down Power ,It can control pen down event */
|
||||
PEPOWER_OFF, /*!<Disable Pen Power */
|
||||
PEDEF_ON, /*!<Enable Pen Down Event Flag */
|
||||
PEDEF_OFF, /*!<Disable Pen Down Event Flag */
|
||||
|
||||
WKP_ON, /*!<Enable Keypad Press Wake Up */
|
||||
WKP_OFF, /*!<Disable Keypad Press Wake Up */
|
||||
WKT_ON, /*!<Enable Pen Down Wake Up */
|
||||
WKT_OFF, /*!<Disable Pen Down Wake Up */
|
||||
SWITCH_5WIRE_ON, /*!<Wire Mode Switch to 5-Wire Configuration */
|
||||
SWITCH_5WIRE_OFF, /*!<Wire Mode Switch to 4-Wire Configuration */
|
||||
|
||||
T_ON, /*!<Enable Touch detection function */
|
||||
T_OFF, /*!<Disable Touch detection function */
|
||||
TAVG_ON, /*!<Enable Touch Mean average for X and Y function */
|
||||
TAVG_OFF, /*!<Disable Touch Mean average for X and Y function */
|
||||
Z_ON, /*!<Enable Press measure function */
|
||||
Z_OFF, /*!<Disable Press measure function */
|
||||
TZAVG_ON, /*!<Enable Pressure Mean average for Z1 and Z2 function */
|
||||
TZAVG_OFF, /*!<Disable Pressure Mean average for Z1 and Z2 function */
|
||||
|
||||
NAC_ON, /*!<Enable Normal AD Conversion */
|
||||
NAC_OFF, /*!<Disable Normal AD Conversion */
|
||||
SWITCH_CH, /*!<Switch Channel */
|
||||
} ADC_CMD;
|
||||
|
||||
|
|
|
@ -1295,25 +1295,38 @@
|
|||
#define REG_PWM0_PIER (PWM0_BA+0x3C) /*!< PWM Timer Interrupt Enable Register */
|
||||
#define REG_PWM0_PIIR (PWM0_BA+0x40) /*!< PWM Timer Interrupt Identification Register */
|
||||
|
||||
#define REG_PWM1_PPR (PWM1_BA+0x00) /*!< PWM Pre-scale Register 0 */
|
||||
#define REG_PWM1_CSR (PWM1_BA+0x04) /*!< PWM Clock Select Register */
|
||||
#define REG_PWM1_PCR (PWM1_BA+0x08) /*!< PWM Control Register */
|
||||
#define REG_PWM1_CNR0 (PWM1_BA+0x0C) /*!< PWM Counter Register 0 */
|
||||
#define REG_PWM1_CMR0 (PWM1_BA+0x10) /*!< PWM Comparator Register 0 */
|
||||
#define REG_PWM1_PDR0 (PWM1_BA+0x14) /*!< PWM Data Register 0 */
|
||||
#define REG_PWM1_CNR1 (PWM1_BA+0x18) /*!< PWM Counter Register 1 */
|
||||
#define REG_PWM1_CMR1 (PWM1_BA+0x1C) /*!< PWM Comparator Register 1 */
|
||||
#define REG_PWM1_PDR1 (PWM1_BA+0x20) /*!< PWM Data Register 1 */
|
||||
#define REG_PWM1_CNR2 (PWM1_BA+0x24) /*!< PWM Counter Register 2 */
|
||||
#define REG_PWM1_CMR2 (PWM1_BA+0x28) /*!< PWM Comparator Register 2 */
|
||||
#define REG_PWM1_PDR2 (PWM1_BA+0x2C) /*!< PWM Data Register 2 */
|
||||
#define REG_PWM1_CNR3 (PWM1_BA+0x30) /*!< PWM Counter Register 3 */
|
||||
#define REG_PWM1_CMR3 (PWM1_BA+0x34) /*!< PWM Comparator Register 3 */
|
||||
#define REG_PWM1_PDR3 (PWM1_BA+0x38) /*!< PWM Data Register 3 */
|
||||
#define REG_PWM1_PIER (PWM1_BA+0x3C) /*!< PWM Timer Interrupt Enable Register */
|
||||
#define REG_PWM1_PIIR (PWM1_BA+0x40) /*!< PWM Timer Interrupt Identification Register */
|
||||
/*---------------------- Analog to Digital Converter -------------------------*/
|
||||
/**
|
||||
@addtogroup ADC Analog to Digital Converter(ADC)
|
||||
Memory Mapped Structure for ADC Controller
|
||||
@{ */
|
||||
|
||||
/**@}*/ /* end of PWM register group */
|
||||
#define REG_ADC_CTL (ADC_BA+0x000) /*!< ADC Contrl */
|
||||
#define REG_ADC_CONF (ADC_BA+0x004) /*!< ADC Configure */
|
||||
#define REG_ADC_IER (ADC_BA+0x008) /*!< ADC Interrupt Enable Register */
|
||||
#define REG_ADC_ISR (ADC_BA+0x00C) /*!< ADC Interrupt Status Register */
|
||||
#define REG_ADC_WKISR (ADC_BA+0x010) /*!< ADC Wake Up Interrupt Status Register */
|
||||
#define REG_ADC_XYDATA (ADC_BA+0x020) /*!< ADC Touch XY Pressure Data */
|
||||
#define REG_ADC_ZDATA (ADC_BA+0x024) /*!< ADC Touch Z Pressure Data */
|
||||
#define REG_ADC_DATA (ADC_BA+0x028) /*!< ADC Normal Conversion Data */
|
||||
#define REG_ADC_VBADATA (ADC_BA+0x02C) /*!< ADC Battery Detection Data */
|
||||
#define REG_ADC_KPDATA (ADC_BA+0x030) /*!< ADC Key Pad Data */
|
||||
#define REG_ADC_SELFDATA (ADC_BA+0x034) /*!< ADC Self-Test Data */
|
||||
#define REG_ADC_XYSORT0 (ADC_BA+0x1F4) /*!< ADC Touch XY Position Mean Value Sort 0 */
|
||||
#define REG_ADC_XYSORT1 (ADC_BA+0x1F8) /*!< ADC Touch XY Position Mean Value Sort 1 */
|
||||
#define REG_ADC_XYSORT2 (ADC_BA+0x1FC) /*!< ADC Touch XY Position Mean Value Sort 2 */
|
||||
#define REG_ADC_XYSORT3 (ADC_BA+0x200) /*!< ADC Touch XY Position Mean Value Sort 3 */
|
||||
#define REG_ADC_ZSORT0 (ADC_BA+0x204) /*!< ADC Touch Z Pressure Mean Value Sort 0 */
|
||||
#define REG_ADC_ZSORT1 (ADC_BA+0x208) /*!< ADC Touch Z Pressure Mean Value Sort 1 */
|
||||
#define REG_ADC_ZSORT2 (ADC_BA+0x20C) /*!< ADC Touch Z Pressure Mean Value Sort 2 */
|
||||
#define REG_ADC_ZSORT3 (ADC_BA+0x210) /*!< ADC Touch Z Pressure Mean Value Sort 3 */
|
||||
#define REG_ADC_MTMULCK (ADC_BA+0x220) /*!< ADC Manual Test Mode Unlock */
|
||||
#define REG_ADC_MTCONF (ADC_BA+0x224) /*!< ADC Manual Test Mode Configure */
|
||||
#define REG_ADC_MTCON (ADC_BA+0x228) /*!< ADC Manual Test Mode Control */
|
||||
#define REG_ADC_ADCAII (ADC_BA+0x22C) /*!< ADC Analog Interface Information */
|
||||
#define REG_ADC_ADCAIIRLT (ADC_BA+0x230) /*!< ADC Analog Interface Information Result */
|
||||
|
||||
/**@}*/ /* end of ADC register group */
|
||||
|
||||
|
||||
/*------------------ Capture Sensor Interface Controller ---------------------*/
|
||||
|
|
|
@ -70,6 +70,13 @@ config SOC_SERIES_NUC980
|
|||
bool "Enable Analog-to-Digital Converter(ADC)"
|
||||
select RT_USING_ADC
|
||||
|
||||
if BSP_USING_ADC
|
||||
config BSP_USING_ADC_TOUCH
|
||||
bool "Enable ADC Touching function"
|
||||
select RT_USING_TOUCH
|
||||
default n
|
||||
endif
|
||||
|
||||
menuconfig BSP_USING_TMR
|
||||
bool "Enable Timer Controller(TIMER)"
|
||||
|
||||
|
|
|
@ -15,9 +15,12 @@
|
|||
|
||||
#include <rtdevice.h>
|
||||
#include "NuMicro.h"
|
||||
#include <drv_sys.h>
|
||||
#include "drv_sys.h"
|
||||
#include "nu_bitutil.h"
|
||||
#include "drv_adc.h"
|
||||
|
||||
/* Private define ---------------------------------------------------------------*/
|
||||
#define DEF_ADC_TOUCH_SMPL_TICK 40
|
||||
|
||||
/* Private Typedef --------------------------------------------------------------*/
|
||||
struct nu_adc
|
||||
|
@ -31,12 +34,33 @@ struct nu_adc
|
|||
int chn_num;
|
||||
uint32_t chn_mask;
|
||||
rt_sem_t m_psSem;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
rt_touch_t psRtTouch;
|
||||
rt_timer_t psRtTouchMenuTimer;
|
||||
rt_mq_t m_pmqTouchXYZ;
|
||||
#endif
|
||||
|
||||
nu_adc_cb m_isr[eAdc_ISR_CNT];
|
||||
nu_adc_cb m_wkisr[eAdc_WKISR_CNT];
|
||||
};
|
||||
typedef struct nu_adc *nu_adc_t;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
struct nu_adc_touch_data
|
||||
{
|
||||
uint32_t u32X;
|
||||
uint32_t u32Y;
|
||||
uint32_t u32Z0;
|
||||
uint32_t u32Z1;
|
||||
};
|
||||
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_control(rt_device_t dev, int cmd, void *args);
|
||||
|
||||
/* Public functions ------------------------------------------------------------*/
|
||||
int rt_hw_adc_init(void);
|
||||
|
@ -56,24 +80,41 @@ static struct nu_adc g_sNuADC =
|
|||
|
||||
static void nu_adc_isr(int vector, void *param)
|
||||
{
|
||||
uint32_t isr, conf;
|
||||
rt_int32_t isr, wkisr;
|
||||
nu_adc_t psNuAdc = (nu_adc_t)param;
|
||||
rt_int32_t irqidx;
|
||||
|
||||
conf = inpw(REG_ADC_CONF);
|
||||
isr = inpw(REG_ADC_ISR);
|
||||
wkisr = inpw(REG_ADC_WKISR);
|
||||
|
||||
if ((isr & ADC_ISR_NACF) && (conf & ADC_CONF_NACEN))
|
||||
while ((irqidx = nu_ctz(isr)) < eAdc_ISR_CNT)
|
||||
{
|
||||
outpw(REG_ADC_ISR, ADC_ISR_NACF);
|
||||
}
|
||||
uint32_t u32IsrBitMask = 1 << irqidx ;
|
||||
|
||||
if (isr & ADC_ISR_MF)
|
||||
if (psNuAdc->m_isr[irqidx].cbfunc != RT_NULL)
|
||||
{
|
||||
//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 */
|
||||
outpw(REG_ADC_ISR, u32IsrBitMask);
|
||||
isr &= ~(u32IsrBitMask);
|
||||
} //while
|
||||
|
||||
while ((irqidx = nu_ctz(wkisr)) < eAdc_WKISR_CNT)
|
||||
{
|
||||
rt_err_t result;
|
||||
outpw(REG_ADC_ISR, ADC_ISR_MF);
|
||||
result = rt_sem_release(psNuAdc->m_psSem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
uint32_t u32IsrBitMask = 1 << irqidx ;
|
||||
|
||||
if (psNuAdc->m_wkisr[irqidx].cbfunc != RT_NULL)
|
||||
{
|
||||
psNuAdc->m_wkisr[irqidx].cbfunc(wkisr, psNuAdc->m_wkisr[irqidx].private_data);
|
||||
}
|
||||
|
||||
/* Clear sent bit */
|
||||
outpw(REG_ADC_WKISR, u32IsrBitMask);
|
||||
wkisr &= ~(u32IsrBitMask);
|
||||
} //while
|
||||
}
|
||||
|
||||
static rt_err_t _nu_adc_init(rt_device_t dev)
|
||||
|
@ -96,11 +137,171 @@ static rt_err_t _nu_adc_init(rt_device_t dev)
|
|||
return RT_EOK;
|
||||
}
|
||||
|
||||
static int32_t AdcMenuStartCallback(uint32_t status, uint32_t userData)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)userData;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
||||
static struct nu_adc_touch_data point;
|
||||
static rt_bool_t bDrop = RT_FALSE;
|
||||
static uint32_t u32LastZ0 = 0xffffu;
|
||||
|
||||
if (psNuAdc->psRtTouch != RT_NULL)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
value = inpw(REG_ADC_XYDATA);
|
||||
point.u32X = (value & 0x0ffful);
|
||||
point.u32Y = ((value >> 16) & 0x0ffful);
|
||||
|
||||
value = inpw(REG_ADC_ZDATA);
|
||||
point.u32Z0 = (value & 0x0ffful);
|
||||
point.u32Z1 = ((value >> 16) & 0x0ffful);
|
||||
|
||||
/* Trigger next or not. */
|
||||
if (point.u32Z0 == 0)
|
||||
{
|
||||
/* Stop sampling procedure. */
|
||||
rt_timer_stop(g_sNuADC.psRtTouchMenuTimer);
|
||||
|
||||
/* Re-start pendown detection */
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
bDrop = RT_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bDrop = RT_FALSE;
|
||||
}
|
||||
|
||||
/* Notify upper layer. */
|
||||
if ((!bDrop || (u32LastZ0 != 0)) && rt_mq_send(psNuAdc->m_pmqTouchXYZ, (const void *)&point, sizeof(struct nu_adc_touch_data)) == RT_EOK)
|
||||
{
|
||||
rt_hw_touch_isr(psNuAdc->psRtTouch);
|
||||
}
|
||||
|
||||
u32LastZ0 = point.u32Z0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
rt_err_t result = rt_sem_release(psNuAdc->m_psSem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
|
||||
if (bStartDetect)
|
||||
{
|
||||
/* Start detect PenDown */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, PEPOWER_ON, RT_NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Stop detect PenDown */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, PEPOWER_OFF, RT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t PenDownCallback(uint32_t status, uint32_t userData)
|
||||
{
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
|
||||
rt_timer_start(g_sNuADC.psRtTouchMenuTimer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t nu_adc_touch_read_xyz(uint32_t *bufX, uint32_t *bufY, uint32_t *bufZ0, uint32_t *bufZ1, int32_t dataCnt)
|
||||
{
|
||||
int i;
|
||||
struct nu_adc_touch_data value;
|
||||
|
||||
for (i = 0 ; i < dataCnt; i++)
|
||||
{
|
||||
if (rt_mq_recv(g_sNuADC.m_pmqTouchXYZ, (void *)&value, sizeof(struct nu_adc_touch_data), 0) == -RT_ETIMEOUT)
|
||||
break;
|
||||
|
||||
bufX[i] = value.u32X;
|
||||
bufY[i] = value.u32Y;
|
||||
bufZ0[i] = value.u32Z0;
|
||||
bufZ1[i] = value.u32Z1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void nu_adc_touch_start_conv(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, START_MST, RT_NULL);
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
nu_adc_cb sNuAdcCb;
|
||||
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 4);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_enable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
outpw(REG_ADC_CONF, (inpw(REG_ADC_CONF) & ~(0xfful << 24)) | 0xfful << 24);
|
||||
|
||||
/* Register touch device. */
|
||||
psNuAdc->psRtTouch = psRtTouch;
|
||||
|
||||
/* Enable TouchXY. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_ON, RT_NULL);
|
||||
|
||||
/* Enable TouchZZ. */
|
||||
_nu_adc_control((rt_device_t)psNuAdc, Z_ON, RT_NULL);
|
||||
|
||||
/* Register PenDown callback. */
|
||||
sNuAdcCb.cbfunc = PenDownCallback;
|
||||
sNuAdcCb.private_data = (rt_uint32_t)psRtTouch;
|
||||
_nu_adc_control((rt_device_t)psNuAdc, PEDEF_ON, (void *)&sNuAdcCb);
|
||||
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_disable(void)
|
||||
{
|
||||
nu_adc_t psNuAdc = (nu_adc_t)&g_sNuADC;
|
||||
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
|
||||
_nu_adc_control((rt_device_t)psNuAdc, T_OFF, RT_NULL);
|
||||
_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);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 5);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 6);
|
||||
rt_adc_disable((rt_adc_device_t)psNuAdc, 7);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
rt_err_t ret = RT_EINVAL ;
|
||||
nu_adc_t psNuAdc = (nu_adc_t)dev;
|
||||
|
||||
nu_adc_cb_t psAdcCb = (nu_adc_cb_t)args;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case START_MST: /* Menu Start Conversion */
|
||||
|
@ -116,29 +317,259 @@ static rt_err_t _nu_adc_control(rt_device_t dev, int cmd, void *args)
|
|||
RT_ASSERT(ret == RT_EOK);
|
||||
|
||||
/* Get data: valid data is 12-bit */
|
||||
*((uint32_t *)args) = inpw(REG_ADC_DATA) & 0x00000FFF;
|
||||
if (args != RT_NULL)
|
||||
*((uint32_t *)args) = inpw(REG_ADC_DATA) & 0x00000FFF;
|
||||
}
|
||||
break;
|
||||
|
||||
/* case START_MST_POLLING: Not supported. */
|
||||
|
||||
case VBPOWER_ON: /* Enable ADC Internal Bandgap Power */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_VBGEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case VBPOWER_OFF: /* Disable ADC Internal Bandgap Power */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_VBGEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPPOWER_ON: /* Enable ADC Keypad Power */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_PWKPEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPPOWER_OFF: /* Disable ADC Keypad Power */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_PWKPEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEPOWER_ON: /* Enable Pen Power */
|
||||
{
|
||||
int retry = 100;
|
||||
uint32_t treg = inpw(REG_ADC_IER);
|
||||
outpw(REG_ADC_IER, treg & ~(ADC_IER_PEDEIEN | ADC_IER_PEUEIEN));
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_PEDEEN);
|
||||
do
|
||||
{
|
||||
outpw(REG_ADC_ISR, ADC_ISR_PEDEF | ADC_ISR_PEUEF);
|
||||
rt_thread_mdelay(1);
|
||||
if (retry-- == 0)
|
||||
break;
|
||||
}
|
||||
while (inpw(REG_ADC_ISR) & (ADC_ISR_PEDEF | ADC_ISR_PEUEF));
|
||||
outpw(REG_ADC_IER, treg);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEPOWER_OFF: /* Disable Pen Power */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_PEDEEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPPRESS_ON: /* Enable Keypad press event */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_isr[eAdc_KPEF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_KPEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPPRESS_OFF: /* Disable Keypad press event */
|
||||
{
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER & ~ADC_IER_KPEIEN));
|
||||
}
|
||||
break;
|
||||
|
||||
case KPUP_ON: /* Enable Keypad up event */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_isr[eAdc_KPUEF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_KPUEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPUP_OFF: /* Disable Keypad up event */
|
||||
{
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) & ~ADC_IER_KPUEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEDEF_ON: /* Enable Pen Down Event */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_isr[eAdc_PEDEF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_PEDEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case PEDEF_OFF: /* Disable Pen Down Event */
|
||||
{
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) & ~ADC_IER_PEDEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case WKP_ON: /* Enable Keypad Press Wake Up */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_wkisr[eAdc_WKPEF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_WKPEN);
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_WKPIEN);
|
||||
//outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26));
|
||||
}
|
||||
break;
|
||||
|
||||
case WKP_OFF: /* Disable Keypad Press Wake Up */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_WKPEN);
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) & ~ADC_IER_WKPIEN);
|
||||
//outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26));
|
||||
}
|
||||
break;
|
||||
|
||||
case WKT_ON: /* Enable Touch Wake Up */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_wkisr[eAdc_WPEDEF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_WKTEN);
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_WKTIEN);
|
||||
//outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) | (1 << 26));
|
||||
}
|
||||
break;
|
||||
|
||||
case WKT_OFF: /* Disable Touch Wake Up */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_WKTEN);
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) & ~ADC_IER_WKTIEN);
|
||||
//outpw(REG_SYS_WKUPSER, inpw(REG_SYS_WKUPSER) & ~(1 << 26));
|
||||
}
|
||||
break;
|
||||
|
||||
case SWITCH_5WIRE_ON: /* Wire Mode Switch to 5-Wire */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_WMSWCH);
|
||||
}
|
||||
break;
|
||||
|
||||
case SWITCH_5WIRE_OFF: /* Wire Mode Switch to 4-Wire */
|
||||
{
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) & ~ADC_CTL_WMSWCH);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_ON: /* Enable Touch detection function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_TEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_OFF: /* Disable Touch detection function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_TEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case TAVG_ON: /* Enable Touch Mean average for X and Y function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_DISTMAVEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case TAVG_OFF: /* Disable Touch Mean average for X and Y function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_DISTMAVEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case Z_ON: /* Enable Press measure function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_ZEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case Z_OFF: /* Disable Press measure function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_ZEN);
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
rt_mq_control(psNuAdc->m_pmqTouchXYZ, RT_IPC_CMD_RESET, RT_NULL);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case TZAVG_ON: /* Enable Pressure Mean average for Z1 and Z2 function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_DISZMAVEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case TZAVG_OFF: /* Disable Pressure Mean average for Z1 and Z2 function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_DISZMAVEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case NAC_ON: /* Enable Normal AD Conversion */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_NACEN | ADC_CONF_REFSEL_AVDD33);
|
||||
}
|
||||
break;
|
||||
|
||||
case NAC_OFF: /* Disable Normal AD Conversion */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_NACEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case VBAT_ON: /* Enable Voltage Battery Conversion */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_isr[eAdc_VBF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_VBATEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case VBAT_OFF: /* Disable Voltage Battery */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_VBATEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPCONV_ON: /* Enable Keypad conversion function */
|
||||
{
|
||||
if (psAdcCb)
|
||||
{
|
||||
rt_memcpy(&psNuAdc->m_isr[eAdc_KPCF], psAdcCb, sizeof(nu_adc_cb));
|
||||
}
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) | ADC_CONF_KPCEN);
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_KPEIEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case KPCONV_OFF: /* Disable Keypad conversion function */
|
||||
{
|
||||
outpw(REG_ADC_CONF, inpw(REG_ADC_CONF) & ~ADC_CONF_KPCEN);
|
||||
}
|
||||
break;
|
||||
|
||||
case SWITCH_CH:
|
||||
{
|
||||
int chn = (int)args;
|
||||
|
@ -265,6 +696,16 @@ exit_nu_adc_convert:
|
|||
return (-ret) ;
|
||||
}
|
||||
|
||||
static void nu_adc_touch_smpl(void *p)
|
||||
{
|
||||
/* Enable interrupt */
|
||||
outpw(REG_ADC_IER, inpw(REG_ADC_IER) | ADC_IER_MIEN);
|
||||
|
||||
/* Start conversion */
|
||||
outpw(REG_ADC_CTL, inpw(REG_ADC_CTL) | ADC_CTL_MST);
|
||||
}
|
||||
|
||||
|
||||
int rt_hw_adc_init(void)
|
||||
{
|
||||
rt_err_t result = RT_ERROR;
|
||||
|
@ -279,8 +720,22 @@ int rt_hw_adc_init(void)
|
|||
g_sNuADC.m_psSem = rt_sem_create("adc_mst_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(g_sNuADC.m_psSem != RT_NULL);
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
g_sNuADC.m_pmqTouchXYZ = rt_mq_create("ADC_TOUCH_XYZ", sizeof(struct nu_adc_touch_data), TOUCH_MQ_LENGTH, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(g_sNuADC.m_pmqTouchXYZ != RT_NULL);
|
||||
|
||||
g_sNuADC.psRtTouchMenuTimer = rt_timer_create("TOUCH_SMPL_TIMER", nu_adc_touch_smpl, (void *)&g_sNuADC, DEF_ADC_TOUCH_SMPL_TICK, RT_TIMER_FLAG_PERIODIC);
|
||||
RT_ASSERT(g_sNuADC.psRtTouchMenuTimer != RT_NULL);
|
||||
#endif
|
||||
|
||||
rt_memset(&g_sNuADC.m_isr, 0, sizeof(g_sNuADC.m_isr));
|
||||
rt_memset(&g_sNuADC.m_wkisr, 0, sizeof(g_sNuADC.m_wkisr));
|
||||
|
||||
g_sNuADC.m_isr[eAdc_MF].cbfunc = AdcMenuStartCallback;
|
||||
g_sNuADC.m_isr[eAdc_MF].private_data = (UINT32)&g_sNuADC;
|
||||
|
||||
return (int)result;
|
||||
}
|
||||
INIT_BOARD_EXPORT(rt_hw_adc_init);
|
||||
|
||||
#endif //#if defined(BSP_USING_EADC)
|
||||
#endif //#if defined(BSP_USING_ADC)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/**************************************************************************//**
|
||||
*
|
||||
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-4-7 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __DRV_ADC_H__
|
||||
#define __DRV_ADC_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "nu_adc.h"
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
#include "touch.h"
|
||||
#endif
|
||||
|
||||
#define TOUCH_MQ_LENGTH 64
|
||||
|
||||
#define DEF_CAL_POINT_NUM 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eAdc_MF, //0
|
||||
eAdc_KPEF, //1
|
||||
eAdc_PEDEF, //2
|
||||
eAdc_KPUEF, //3
|
||||
eAdc_PEUEF, //4
|
||||
eAdc_TF = 8, //8
|
||||
eAdc_ZF, //9
|
||||
eAdc_NACF, //10
|
||||
eAdc_VBF, //11
|
||||
eAdc_KPCF, //12
|
||||
eAdc_SELFTF, //13
|
||||
eAdc_INTKP = 16, //16
|
||||
eAdc_INTTC, //17
|
||||
eAdc_ISR_CNT //18
|
||||
} E_ADC_ISR_EVENT;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eAdc_WKPEF,
|
||||
eAdc_WPEDEF,
|
||||
eAdc_WKISR_CNT
|
||||
} E_ADC_WKISR_EVENT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ADC_CALLBACK cbfunc;
|
||||
uint32_t private_data;
|
||||
} nu_adc_cb;
|
||||
|
||||
typedef nu_adc_cb *nu_adc_cb_t;
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
typedef struct
|
||||
{
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
} S_COORDINATE_POINT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t a;
|
||||
int32_t b;
|
||||
int32_t c;
|
||||
int32_t d;
|
||||
int32_t e;
|
||||
int32_t f;
|
||||
int32_t div;
|
||||
} S_CALIBRATION_MATRIX;
|
||||
|
||||
int32_t nu_adc_touch_read_xyz(uint32_t *bufX, uint32_t *bufY, uint32_t *bufZ0, uint32_t *bufZ1, int32_t dataCnt);
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch);
|
||||
rt_err_t nu_adc_touch_disable(void);
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect);
|
||||
void nu_adc_touch_start_conv(void);
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_ADC_H__ */
|
|
@ -0,0 +1,681 @@
|
|||
/**************************************************************************//**
|
||||
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-04-20 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH)
|
||||
|
||||
#include "NuMicro.h"
|
||||
#include <rtdevice.h>
|
||||
#include <dfs_posix.h>
|
||||
#include "drv_adc.h"
|
||||
#include "touch.h"
|
||||
|
||||
#if !defined(PATH_CALIBRATION_FILE)
|
||||
#define PATH_CALIBRATION_FILE "/mnt/filesystem/ts_calibration"
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct rt_touch_device dev;
|
||||
rt_uint32_t x_range;
|
||||
rt_uint32_t y_range;
|
||||
} nu_adc_touch;
|
||||
typedef nu_adc_touch *nu_adc_touch_t;
|
||||
|
||||
static nu_adc_touch s_NuAdcTouch = {0};
|
||||
|
||||
#if (BSP_LCD_WIDTH==320) && (BSP_LCD_HEIGHT==240)
|
||||
static S_CALIBRATION_MATRIX g_sCalMat = { 43, -5839, 21672848, 4193, -11, -747882, 65536 };
|
||||
static volatile uint32_t g_u32Calibrated = 1;
|
||||
#else
|
||||
static S_CALIBRATION_MATRIX g_sCalMat = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
static volatile uint32_t g_u32Calibrated = 0;
|
||||
#endif
|
||||
|
||||
static int nu_adc_touch_readfile(void);
|
||||
|
||||
static const S_CALIBRATION_MATRIX g_sCalZero = { 1, 0, 0, 0, 1, 0, 1 };
|
||||
|
||||
static int nu_adc_cal_mat_get(const S_COORDINATE_POINT *psDispCP, S_COORDINATE_POINT *psADCCP, S_CALIBRATION_MATRIX *psCM)
|
||||
{
|
||||
#if (DEF_CAL_POINT_NUM==3)
|
||||
|
||||
psCM->div = ((psADCCP[0].x - psADCCP[2].x) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psADCCP[1].x - psADCCP[2].x) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
if (psCM->div == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
psCM->a = ((psDispCP[0].x - psDispCP[2].x) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psDispCP[1].x - psDispCP[2].x) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
psCM->b = ((psADCCP[0].x - psADCCP[2].x) * (psDispCP[1].x - psDispCP[2].x)) -
|
||||
((psDispCP[0].x - psDispCP[2].x) * (psADCCP[1].x - psADCCP[2].x)) ;
|
||||
|
||||
psCM->c = (psADCCP[2].x * psDispCP[1].x - psADCCP[1].x * psDispCP[2].x) * psADCCP[0].y +
|
||||
(psADCCP[0].x * psDispCP[2].x - psADCCP[2].x * psDispCP[0].x) * psADCCP[1].y +
|
||||
(psADCCP[1].x * psDispCP[0].x - psADCCP[0].x * psDispCP[1].x) * psADCCP[2].y ;
|
||||
|
||||
psCM->d = ((psDispCP[0].y - psDispCP[2].y) * (psADCCP[1].y - psADCCP[2].y)) -
|
||||
((psDispCP[1].y - psDispCP[2].y) * (psADCCP[0].y - psADCCP[2].y)) ;
|
||||
|
||||
psCM->e = ((psADCCP[0].x - psADCCP[2].x) * (psDispCP[1].y - psDispCP[2].y)) -
|
||||
((psDispCP[0].y - psDispCP[2].y) * (psADCCP[1].x - psADCCP[2].x)) ;
|
||||
|
||||
psCM->f = (psADCCP[2].x * psDispCP[1].y - psADCCP[1].x * psDispCP[2].y) * psADCCP[0].y +
|
||||
(psADCCP[0].x * psDispCP[2].y - psADCCP[2].x * psDispCP[0].y) * psADCCP[1].y +
|
||||
(psADCCP[1].x * psDispCP[0].y - psADCCP[0].x * psDispCP[1].y) * psADCCP[2].y ;
|
||||
}
|
||||
|
||||
#elif (DEF_CAL_POINT_NUM==5)
|
||||
|
||||
int i;
|
||||
float n, x, y, xx, yy, xy, z, zx, zy;
|
||||
float a, b, c, d, e, f, g;
|
||||
float scaling = 65536.0f;
|
||||
|
||||
n = x = y = xx = yy = xy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
n += 1.0;
|
||||
x += (float)psADCCP[i].x;
|
||||
y += (float)psADCCP[i].y;
|
||||
xx += (float)psADCCP[i].x * psADCCP[i].x;
|
||||
yy += (float)psADCCP[i].y * psADCCP[i].y;
|
||||
xy += (float)psADCCP[i].x * psADCCP[i].y;
|
||||
}
|
||||
|
||||
d = n * (xx * yy - xy * xy) + x * (xy * y - x * yy) + y * (x * xy - y * xx);
|
||||
if (d < 0.1 && d > -0.1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
a = (xx * yy - xy * xy) / d;
|
||||
b = (xy * y - x * yy) / d;
|
||||
c = (x * xy - y * xx) / d;
|
||||
e = (n * yy - y * y) / d;
|
||||
f = (x * y - n * xy) / d;
|
||||
g = (n * xx - x * x) / d;
|
||||
|
||||
z = zx = zy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
z += (float)psDispCP[i].x;
|
||||
zx += (float)psDispCP[i].x * psADCCP[i].x;
|
||||
zy += (float)psDispCP[i].x * psADCCP[i].y;
|
||||
}
|
||||
|
||||
psCM->c = (int32_t)((a * z + b * zx + c * zy) * scaling);
|
||||
psCM->a = (int32_t)((b * z + e * zx + f * zy) * scaling);
|
||||
psCM->b = (int32_t)((c * z + f * zx + g * zy) * scaling);
|
||||
|
||||
z = zx = zy = 0;
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
z += (float)psDispCP[i].y;
|
||||
zx += (float)psDispCP[i].y * psADCCP[i].x;
|
||||
zy += (float)psDispCP[i].y * psADCCP[i].y;
|
||||
}
|
||||
|
||||
psCM->f = (int32_t)((a * z + b * zx + c * zy) * scaling);
|
||||
psCM->d = (int32_t)((b * z + e * zx + f * zy) * scaling);
|
||||
psCM->e = (int32_t)((c * z + f * zx + g * zy) * scaling);
|
||||
|
||||
psCM->div = (int32_t)scaling;
|
||||
|
||||
#else
|
||||
#error "Not supported calibration method"
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nu_adc_touch_cal(int32_t *sumx, int32_t *sumy)
|
||||
{
|
||||
int32_t xtemp, ytemp;
|
||||
|
||||
xtemp = *sumx;
|
||||
ytemp = *sumy;
|
||||
*sumx = (g_sCalMat.c +
|
||||
g_sCalMat.a * xtemp +
|
||||
g_sCalMat.b * ytemp) / g_sCalMat.div;
|
||||
*sumy = (g_sCalMat.f +
|
||||
g_sCalMat.d * xtemp +
|
||||
g_sCalMat.e * ytemp) / g_sCalMat.div;
|
||||
}
|
||||
|
||||
static rt_size_t nu_adc_touch_readpoint(struct rt_touch_device *device, void *buf, rt_size_t read_num)
|
||||
{
|
||||
static uint32_t last_report_x = 0, last_report_y = 0;
|
||||
struct rt_touch_data *pPoint = (struct rt_touch_data *)buf;
|
||||
nu_adc_touch_t psNuAdcTouch = (nu_adc_touch_t)device;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(buf != RT_NULL);
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < read_num; i++)
|
||||
{
|
||||
uint32_t bufZ0 = 0, bufZ1 = 0;
|
||||
int32_t sumx = 0, sumy = 0;
|
||||
pPoint[i].timestamp = rt_touch_get_ts();
|
||||
pPoint[i].track_id = 0;
|
||||
|
||||
if (nu_adc_touch_read_xyz((uint32_t *)&sumx, (uint32_t *)&sumy, &bufZ0, &bufZ1, 1) != 1)
|
||||
break;
|
||||
|
||||
if (bufZ0 == 0)
|
||||
{
|
||||
/* Workaround: In this case, x, y values are unstable. so, report last point's coordinate.*/
|
||||
pPoint[i].event = RT_TOUCH_EVENT_UP;
|
||||
pPoint[i].x_coordinate = (uint16_t)last_report_x;
|
||||
pPoint[i].y_coordinate = (uint16_t)last_report_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_u32Calibrated)
|
||||
{
|
||||
nu_adc_touch_cal(&sumx, &sumy);
|
||||
}
|
||||
last_report_x = sumx;
|
||||
last_report_y = sumy;
|
||||
|
||||
pPoint[i].event = RT_TOUCH_EVENT_DOWN;
|
||||
pPoint[i].x_coordinate = (uint16_t)sumx;
|
||||
pPoint[i].y_coordinate = (uint16_t)sumy;
|
||||
}
|
||||
|
||||
if (g_u32Calibrated)
|
||||
{
|
||||
bufZ0 = bufZ0 >> 3;
|
||||
pPoint[i].width = (bufZ0 > 255) ? 255 : bufZ0;
|
||||
|
||||
//Limit max x, y coordinate if value is over its range.
|
||||
pPoint[i].x_coordinate = (pPoint[i].x_coordinate > psNuAdcTouch->x_range) ? psNuAdcTouch->x_range : pPoint[i].x_coordinate;
|
||||
pPoint[i].y_coordinate = (pPoint[i].y_coordinate > psNuAdcTouch->y_range) ? psNuAdcTouch->y_range : pPoint[i].y_coordinate;
|
||||
}
|
||||
}
|
||||
return (rt_size_t)i;
|
||||
}
|
||||
|
||||
static rt_err_t nu_adc_touch_control(struct rt_touch_device *device, int cmd, void *data)
|
||||
{
|
||||
nu_adc_touch_t psNuAdcTouch = (nu_adc_touch_t)device;
|
||||
RT_ASSERT(psNuAdcTouch != RT_NULL);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case RT_TOUCH_CTRL_SET_X_RANGE: /* set x range */
|
||||
psNuAdcTouch->x_range = *((rt_int32_t *)data);
|
||||
break;
|
||||
|
||||
case RT_TOUCH_CTRL_SET_Y_RANGE: /* set y range */
|
||||
psNuAdcTouch->y_range = *((rt_int32_t *)data);
|
||||
break;
|
||||
|
||||
case RT_TOUCH_CTRL_ENABLE_INT: /* enable pen_down interrupt */
|
||||
nu_adc_touch_detect(RT_TRUE);
|
||||
break;
|
||||
|
||||
case RT_TOUCH_CTRL_DISABLE_INT: /* disable pen_down interrupt */
|
||||
nu_adc_touch_detect(RT_FALSE);
|
||||
break;
|
||||
|
||||
case RT_TOUCH_CTRL_POWER_ON: /* Touch Power On */
|
||||
return nu_adc_touch_enable(device);
|
||||
|
||||
case RT_TOUCH_CTRL_POWER_OFF: /* Touch Power Off */
|
||||
return nu_adc_touch_disable();
|
||||
|
||||
default:
|
||||
return -RT_ERROR;
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static struct rt_touch_ops touch_ops =
|
||||
{
|
||||
.touch_readpoint = nu_adc_touch_readpoint,
|
||||
.touch_control = nu_adc_touch_control,
|
||||
};
|
||||
|
||||
static void nu_adc_touch_update_calmat(S_CALIBRATION_MATRIX *psNewCalMat)
|
||||
{
|
||||
if (psNewCalMat &&
|
||||
psNewCalMat->div != 0)
|
||||
{
|
||||
rt_memcpy(&g_sCalMat, psNewCalMat, sizeof(S_CALIBRATION_MATRIX));
|
||||
g_u32Calibrated = 1;
|
||||
rt_kprintf("Applied calibration data: %d, %d, %d, %d, %d, %d, %d\n",
|
||||
g_sCalMat.a,
|
||||
g_sCalMat.b,
|
||||
g_sCalMat.c,
|
||||
g_sCalMat.d,
|
||||
g_sCalMat.e,
|
||||
g_sCalMat.f,
|
||||
g_sCalMat.div);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void nu_adc_touch_reset_calmat(void)
|
||||
{
|
||||
rt_memcpy(&g_sCalMat, &g_sCalZero, sizeof(S_CALIBRATION_MATRIX));
|
||||
g_u32Calibrated = 0;
|
||||
}
|
||||
|
||||
int rt_hw_adc_touch_init(void)
|
||||
{
|
||||
/* Register touch device */
|
||||
s_NuAdcTouch.dev.info.type = RT_TOUCH_TYPE_RESISTANCE;
|
||||
s_NuAdcTouch.dev.info.vendor = RT_TOUCH_VENDOR_UNKNOWN;
|
||||
s_NuAdcTouch.dev.info.point_num = 1;
|
||||
s_NuAdcTouch.dev.info.range_x = BSP_LCD_WIDTH;
|
||||
s_NuAdcTouch.dev.info.range_y = BSP_LCD_HEIGHT;
|
||||
|
||||
s_NuAdcTouch.dev.ops = &touch_ops;
|
||||
|
||||
return (int)rt_hw_touch_register(&s_NuAdcTouch.dev, "adc_touch", RT_DEVICE_FLAG_INT_RX, RT_NULL);
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_adc_touch_init);
|
||||
|
||||
|
||||
static rt_thread_t adc_touch_thread = RT_NULL;
|
||||
static rt_sem_t adc_touch_sem = RT_NULL;
|
||||
static int adc_touch_worker_run = 0;
|
||||
|
||||
static rt_err_t adc_touch_rx_callback(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
//rt_kprintf("[%s %d] %d\n", __func__, __LINE__, size);
|
||||
return rt_sem_release(adc_touch_sem);
|
||||
}
|
||||
|
||||
static rt_err_t adc_request_point(rt_device_t pdev, struct rt_touch_data *psTouchPoint)
|
||||
{
|
||||
rt_err_t ret = -RT_ERROR;
|
||||
|
||||
if ((ret = rt_sem_take(adc_touch_sem, rt_tick_from_millisecond(500))) == RT_EOK)
|
||||
{
|
||||
rt_memset(psTouchPoint, 0, sizeof(struct rt_touch_data));
|
||||
|
||||
if (rt_device_read(pdev, 0, psTouchPoint, s_NuAdcTouch.dev.info.point_num) == s_NuAdcTouch.dev.info.point_num)
|
||||
{
|
||||
ret = RT_EOK;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
RT_WEAK void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t event)
|
||||
{
|
||||
}
|
||||
|
||||
static rt_device_t lcd_device = 0;
|
||||
static struct rt_device_graphic_info info;
|
||||
|
||||
static void lcd_cleanscreen(void)
|
||||
{
|
||||
if (info.framebuffer != RT_NULL)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
|
||||
rt_memset(info.framebuffer, 0, (info.pitch * info.height));
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = info.width;
|
||||
rect.height = info.height;
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
#define DEF_DOT_NUMBER 9
|
||||
#define DOTS_NUMBER (DEF_DOT_NUMBER*DEF_DOT_NUMBER)
|
||||
static void nu_draw_bots(int x, int y)
|
||||
{
|
||||
if (info.framebuffer != RT_NULL)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
int i, j;
|
||||
int start_x = x - (DEF_DOT_NUMBER / 2);
|
||||
int start_y = y - (DEF_DOT_NUMBER / 2);
|
||||
|
||||
if (info.pixel_format == RTGRAPHIC_PIXEL_FORMAT_RGB565)
|
||||
{
|
||||
uint16_t *pu16Start = (uint16_t *)((uint32_t)info.framebuffer + (start_y) * info.pitch + (start_x * 2));
|
||||
for (j = 0; j < DEF_DOT_NUMBER; j++)
|
||||
{
|
||||
for (i = 0; i < DEF_DOT_NUMBER; i++)
|
||||
pu16Start[i] = 0x07E0; //Green, RGB
|
||||
pu16Start += info.width;
|
||||
}
|
||||
}
|
||||
else if (info.pixel_format == RTGRAPHIC_PIXEL_FORMAT_ARGB888)
|
||||
{
|
||||
uint32_t *pu32Start = (uint32_t *)((uint32_t)info.framebuffer + (start_y) * info.pitch + (start_x * 4));
|
||||
for (j = 0; j < DEF_DOT_NUMBER; j++)
|
||||
{
|
||||
for (i = 0; i < DEF_DOT_NUMBER; i++)
|
||||
pu32Start[i] = 0xff00ff00; //Green, ARGB
|
||||
pu32Start += info.width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Not supported
|
||||
}
|
||||
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.width = info.width;
|
||||
rect.height = info.height;
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
#if (DEF_CAL_POINT_NUM==3)
|
||||
const S_COORDINATE_POINT sDispPoints[DEF_CAL_POINT_NUM] =
|
||||
{
|
||||
{BSP_LCD_WIDTH / 4, BSP_LCD_HEIGHT / 2},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / 4, BSP_LCD_HEIGHT / 4},
|
||||
{BSP_LCD_WIDTH / 2, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / 4}
|
||||
};
|
||||
#elif (DEF_CAL_POINT_NUM==5)
|
||||
const static S_COORDINATE_POINT sDispPoints[DEF_CAL_POINT_NUM] =
|
||||
{
|
||||
#define DEF_CUT_PIECES 8
|
||||
{BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH - BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
{BSP_LCD_WIDTH / DEF_CUT_PIECES, BSP_LCD_HEIGHT - BSP_LCD_HEIGHT / DEF_CUT_PIECES},
|
||||
|
||||
{BSP_LCD_WIDTH / 2, BSP_LCD_HEIGHT / 2}
|
||||
};
|
||||
#endif
|
||||
|
||||
static int nu_adc_touch_readfile(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
S_CALIBRATION_MATRIX sCalMat;
|
||||
|
||||
if ((fd = open(PATH_CALIBRATION_FILE, O_RDONLY, 0)) < 0)
|
||||
{
|
||||
goto exit_nu_adc_touch_readfile;
|
||||
}
|
||||
else if (read(fd, &sCalMat, sizeof(S_CALIBRATION_MATRIX)) == sizeof(S_CALIBRATION_MATRIX))
|
||||
{
|
||||
rt_kprintf("[%s] %s\n", __func__, PATH_CALIBRATION_FILE);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
nu_adc_touch_update_calmat(&sCalMat);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_nu_adc_touch_readfile:
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int nu_adc_touch_writefile(void *buf, int buf_len)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if ((fd = open(PATH_CALIBRATION_FILE, O_WRONLY | O_CREAT, 0)) < 0)
|
||||
{
|
||||
goto exit_nu_adc_touch_writefile;
|
||||
}
|
||||
else if (write(fd, buf, buf_len) == buf_len)
|
||||
{
|
||||
rt_kprintf("[%s] %s\n", __func__, PATH_CALIBRATION_FILE);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_nu_adc_touch_writefile:
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void nu_touch_do_calibration(rt_device_t pdev)
|
||||
{
|
||||
int i;
|
||||
rt_err_t result;
|
||||
|
||||
S_CALIBRATION_MATRIX sCalMat;
|
||||
S_COORDINATE_POINT sADCPoints[DEF_CAL_POINT_NUM];
|
||||
|
||||
lcd_device = rt_device_find("lcd");
|
||||
if (!lcd_device)
|
||||
{
|
||||
rt_kprintf("Not supported graphics ops\n");
|
||||
return;
|
||||
}
|
||||
|
||||
result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
rt_kprintf("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
rt_kprintf("opened?");
|
||||
}
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_PAN_DISPLAY, info.framebuffer);
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_POWERON, RT_NULL);
|
||||
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
struct rt_touch_data sTouchPoint;
|
||||
int count = 0;
|
||||
|
||||
lcd_cleanscreen();
|
||||
|
||||
/* Drain RX queue before doing calibrate. */
|
||||
while (adc_request_point(pdev, &sTouchPoint) == RT_EOK);
|
||||
|
||||
rt_thread_mdelay(100);
|
||||
|
||||
/* Ready to calibrate */
|
||||
nu_draw_bots(sDispPoints[i].x, sDispPoints[i].y);
|
||||
|
||||
#define DEF_MAX_GET_POINT_NUM 5
|
||||
|
||||
sADCPoints[i].x = 0;
|
||||
sADCPoints[i].y = 0;
|
||||
|
||||
while (count < DEF_MAX_GET_POINT_NUM)
|
||||
{
|
||||
if (adc_request_point(pdev, &sTouchPoint) == RT_EOK)
|
||||
{
|
||||
sADCPoints[i].x += (int32_t)sTouchPoint.x_coordinate;
|
||||
sADCPoints[i].y += (int32_t)sTouchPoint.y_coordinate;
|
||||
rt_kprintf("[%d %d] - Disp:[%d, %d] -> ADC:[%d, %d]\n", i, count, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
sADCPoints[i].x = (int32_t)((float)sADCPoints[i].x / DEF_MAX_GET_POINT_NUM);
|
||||
sADCPoints[i].y = (int32_t)((float)sADCPoints[i].y / DEF_MAX_GET_POINT_NUM);
|
||||
rt_kprintf("[%d] - Disp:[%d, %d], ADC:[%d, %d]\n", i, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
|
||||
rt_thread_mdelay(300);
|
||||
}
|
||||
|
||||
lcd_cleanscreen();
|
||||
|
||||
/* Get calibration matrix. */
|
||||
if (nu_adc_cal_mat_get(&sDispPoints[0], &sADCPoints[0], &sCalMat) == 0)
|
||||
{
|
||||
/* Finally, update calibration matrix to drivers. */
|
||||
nu_adc_touch_update_calmat(&sCalMat);
|
||||
|
||||
nu_adc_touch_writefile(&sCalMat, sizeof(sCalMat));
|
||||
|
||||
for (i = 0; i < DEF_CAL_POINT_NUM; i++)
|
||||
{
|
||||
rt_kprintf("[%d] - Disp:[%d, %d], ADC:[%d, %d]\n", i, sDispPoints[i].x, sDispPoints[i].y, sADCPoints[i].x, sADCPoints[i].y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("Failed to calibrate.\n");
|
||||
}
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_POWEROFF, RT_NULL);
|
||||
rt_device_close(lcd_device);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void adc_touch_entry(void *parameter)
|
||||
{
|
||||
struct rt_touch_data touch_point;
|
||||
|
||||
rt_err_t result;
|
||||
rt_device_t pdev;
|
||||
|
||||
int max_range;
|
||||
|
||||
adc_touch_sem = rt_sem_create("adc_touch_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(adc_touch_sem != RT_NULL);
|
||||
|
||||
pdev = rt_device_find("adc_touch");
|
||||
if (!pdev)
|
||||
{
|
||||
rt_kprintf("Not found\n");
|
||||
return ;
|
||||
}
|
||||
|
||||
nu_adc_touch_readfile();
|
||||
|
||||
result = rt_device_open(pdev, RT_DEVICE_FLAG_INT_RX);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
result = rt_device_set_rx_indicate(pdev, adc_touch_rx_callback);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
max_range = BSP_LCD_WIDTH;
|
||||
result = rt_device_control(pdev, RT_TOUCH_CTRL_SET_X_RANGE, (void *)&max_range);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
max_range = BSP_LCD_HEIGHT;
|
||||
result = rt_device_control(pdev, RT_TOUCH_CTRL_SET_Y_RANGE, (void *)&max_range);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
result = rt_device_control(pdev, RT_TOUCH_CTRL_POWER_ON, RT_NULL);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
while (adc_touch_worker_run)
|
||||
{
|
||||
if (!g_u32Calibrated)
|
||||
{
|
||||
rt_kprintf("Start ADC touching calibration.\n");
|
||||
nu_touch_do_calibration(pdev);
|
||||
rt_kprintf("Stop ADC touching calibration.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (adc_request_point(pdev, &touch_point) == RT_EOK)
|
||||
{
|
||||
if (touch_point.event == RT_TOUCH_EVENT_DOWN
|
||||
|| touch_point.event == RT_TOUCH_EVENT_UP
|
||||
|| touch_point.event == RT_TOUCH_EVENT_MOVE)
|
||||
{
|
||||
nu_touch_inputevent_cb(touch_point.x_coordinate, touch_point.y_coordinate, touch_point.event);
|
||||
|
||||
rt_kprintf("x=%d y=%d event=%s%s%s\n",
|
||||
touch_point.x_coordinate,
|
||||
touch_point.y_coordinate,
|
||||
(touch_point.event == RT_TOUCH_EVENT_DOWN) ? "DOWN" : "",
|
||||
(touch_point.event == RT_TOUCH_EVENT_UP) ? "UP" : "",
|
||||
(touch_point.event == RT_TOUCH_EVENT_MOVE) ? "MOVE" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = rt_device_control(pdev, RT_TOUCH_CTRL_POWER_OFF, RT_NULL);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
result = rt_device_close(pdev);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
|
||||
/* Support "nu_touch_start" command line in msh mode */
|
||||
static rt_err_t nu_touch_start(int argc, char **argv)
|
||||
{
|
||||
if (adc_touch_thread == RT_NULL)
|
||||
{
|
||||
adc_touch_thread = rt_thread_create("adc_touch_thread",
|
||||
adc_touch_entry,
|
||||
RT_NULL,
|
||||
4096,
|
||||
25,
|
||||
5);
|
||||
adc_touch_worker_run = 1;
|
||||
if (adc_touch_thread != RT_NULL)
|
||||
rt_thread_startup(adc_touch_thread);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(nu_touch_start, e.g: start adc touch);
|
||||
|
||||
/* Support "nu_touch_stop" command line in msh mode */
|
||||
static rt_err_t nu_touch_stop(int argc, char **argv)
|
||||
{
|
||||
adc_touch_worker_run = 0;
|
||||
adc_touch_thread = RT_NULL;
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(nu_touch_stop, e.g: stop adc touch);
|
||||
|
||||
static int nu_touch_autostart(void)
|
||||
{
|
||||
return nu_touch_start(0, RT_NULL);
|
||||
}
|
||||
INIT_APP_EXPORT(nu_touch_autostart);
|
||||
|
||||
static rt_err_t nu_touch_calibration(int argc, char **argv)
|
||||
{
|
||||
/* Clean calibration matrix data for getting raw adc value. */
|
||||
nu_adc_touch_reset_calmat();
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(nu_touch_calibration, for adc touch);
|
||||
|
||||
#endif //#if defined(BSP_USING_ADC_TOUCH)
|
|
@ -682,7 +682,7 @@ lwiperf_report(void *arg, enum lwiperf_report_type report_type,
|
|||
(int)report_type, ipaddr_ntoa(remote_addr), (int)remote_port, bytes_transferred, ms_duration, bandwidth_kbitpsec);
|
||||
}
|
||||
|
||||
void lwiperf_example_init(void)
|
||||
void lwiperf_example_init(int argc, char **argv)
|
||||
{
|
||||
lwiperf_start_tcp_server_default(lwiperf_report, NULL);
|
||||
}
|
||||
|
|
|
@ -203,8 +203,7 @@ CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_SIZE=4096
|
|||
CONFIG_RT_AUDIO_REPLAY_MP_BLOCK_COUNT=2
|
||||
CONFIG_RT_AUDIO_RECORD_PIPE_SIZE=2048
|
||||
# CONFIG_RT_USING_SENSOR is not set
|
||||
CONFIG_RT_USING_TOUCH=y
|
||||
# CONFIG_RT_TOUCH_PIN_IRQ is not set
|
||||
# CONFIG_RT_USING_TOUCH is not set
|
||||
CONFIG_RT_USING_HWCRYPTO=y
|
||||
CONFIG_RT_HWCRYPTO_DEFAULT_NAME="hwcryto"
|
||||
CONFIG_RT_HWCRYPTO_IV_MAX_SIZE=16
|
||||
|
@ -550,17 +549,11 @@ CONFIG_PKG_NETUTILS_VER_NUM=0x10301
|
|||
#
|
||||
# LVGL: powerful and easy-to-use embedded GUI library
|
||||
#
|
||||
CONFIG_PKG_USING_LVGL=y
|
||||
CONFIG_PKG_LVGL_PATH="/packages/multimedia/LVGL/LVGL"
|
||||
# CONFIG_PKG_USING_LVGL_EXAMPLES is not set
|
||||
CONFIG_PKG_USING_LVGL_V810=y
|
||||
# CONFIG_PKG_USING_LVGL is not set
|
||||
# CONFIG_PKG_USING_LVGL_V810 is not set
|
||||
# CONFIG_PKG_USING_LVGL_LATEST_VERSION is not set
|
||||
CONFIG_PKG_LVGL_VER="v8.1.0"
|
||||
CONFIG_PKG_LVGL_VER_NUM=0x08010
|
||||
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
|
||||
CONFIG_PKG_USING_LV_MUSIC_DEMO=y
|
||||
CONFIG_PKG_LV_MUSIC_DEMO_PATH="/packages/multimedia/LVGL/lv_music_demo"
|
||||
CONFIG_PKG_LV_MUSIC_DEMO_VER="v0.1.1"
|
||||
# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set
|
||||
|
||||
#
|
||||
# u8g2: a monochrome graphic library
|
||||
|
@ -597,6 +590,7 @@ CONFIG_PKG_WAVPLAYER_VER="latest"
|
|||
# CONFIG_PKG_USING_MCURSES is not set
|
||||
# CONFIG_PKG_USING_TERMBOX is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
|
@ -607,7 +601,6 @@ CONFIG_PKG_WAVPLAYER_VER="latest"
|
|||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_SEGGER_RTT is not set
|
||||
# CONFIG_PKG_USING_RDB is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_ULOG_FILE is not set
|
||||
# CONFIG_PKG_USING_LOGMGR is not set
|
||||
|
@ -658,6 +651,7 @@ CONFIG_PKG_WAVPLAYER_VER="latest"
|
|||
# CONFIG_PKG_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_PKG_USING_POSIX_WCWIDTH is not set
|
||||
# CONFIG_PKG_USING_POSIX_ITOA is not set
|
||||
# CONFIG_PKG_USING_POSIX_STRINGS is not set
|
||||
|
||||
#
|
||||
# acceleration: Assembly language or algorithmic acceleration packages
|
||||
|
@ -783,6 +777,7 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
|||
# CONFIG_PKG_USING_SSD1306 is not set
|
||||
# CONFIG_PKG_USING_QKEY is not set
|
||||
# CONFIG_PKG_USING_RS485 is not set
|
||||
# CONFIG_PKG_USING_RS232 is not set
|
||||
# CONFIG_PKG_USING_NES is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
|
||||
# CONFIG_PKG_USING_VDEVICE is not set
|
||||
|
@ -874,23 +869,8 @@ CONFIG_PKG_OPTPARSE_VER="latest"
|
|||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
# CONFIG_PKG_USING_DESIGN_PATTERN is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
CONFIG_NU_PKG_USING_NAU8822=y
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
CONFIG_NU_PKG_USING_ILI9341=y
|
||||
CONFIG_NU_PKG_USING_ILI9341_SPI=y
|
||||
# CONFIG_NU_PKG_USING_ILI9341_EBI is not set
|
||||
CONFIG_NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER=y
|
||||
CONFIG_NU_PKG_ILI9341_HORIZONTAL=y
|
||||
CONFIG_NU_PKG_USING_SPINAND=y
|
||||
# CONFIG_PKG_USING_CONTROLLER is not set
|
||||
# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
|
@ -913,6 +893,7 @@ CONFIG_BSP_USING_RTC=y
|
|||
CONFIG_NU_RTC_SUPPORT_IO_RW=y
|
||||
CONFIG_NU_RTC_SUPPORT_MSH_CMD=y
|
||||
CONFIG_BSP_USING_ADC=y
|
||||
# CONFIG_BSP_USING_ADC_TOUCH is not set
|
||||
CONFIG_BSP_USING_TMR=y
|
||||
CONFIG_BSP_USING_TIMER=y
|
||||
CONFIG_BSP_USING_TMR0=y
|
||||
|
@ -998,10 +979,20 @@ CONFIG_BOARD_USING_USB1_HOST=y
|
|||
# Board extended module drivers
|
||||
#
|
||||
# CONFIG_BOARD_USING_MAX31875 is not set
|
||||
CONFIG_BOARD_USING_LCD_ILI9341=y
|
||||
CONFIG_BOARD_USING_ILI9341_PIN_BACKLIGHT=103
|
||||
CONFIG_BOARD_USING_ILI9341_PIN_RESET=90
|
||||
CONFIG_BOARD_USING_ILI9341_PIN_DC=89
|
||||
# CONFIG_BOARD_USING_LCD_ILI9341 is not set
|
||||
# CONFIG_BOARD_USING_ESP8266 is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
CONFIG_NU_PKG_USING_NAU8822=y
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
CONFIG_NU_PKG_USING_SPINAND=y
|
||||
CONFIG_BOARD_USE_UTEST=y
|
||||
CONFIG_UTEST_CMD_PREFIX="bsp.nuvoton.nk980-iot.test.utest."
|
||||
|
|
|
@ -72,6 +72,7 @@ menu "Hardware Drivers Config"
|
|||
config BOARD_USING_LCD_ILI9341
|
||||
bool "LCD ILI9341 (over spi0)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_SPI
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
|
|
|
@ -57,8 +57,10 @@ static void nu_pin_i2c_init(void)
|
|||
/* I2C0: PA[0, 1] */
|
||||
outpw(REG_SYS_GPA_MFPL, (inpw(REG_SYS_GPA_MFPL) & ~0x000000FF) | 0x00000033);
|
||||
|
||||
#if !defined(BSP_USING_ADC_TOUCH)
|
||||
/* I2C2: PB5, PB7 */
|
||||
outpw(REG_SYS_GPB_MFPL, (inpw(REG_SYS_GPB_MFPL) & ~0xF0F00000) | 0x20200000);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,4 +85,10 @@ elif PLATFORM == 'armcc':
|
|||
CFLAGS += ' -O2'
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output ' + TARGET_NAME + ' \n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
# RT-Thread Kernel
|
||||
#
|
||||
CONFIG_RT_NAME_MAX=16
|
||||
# CONFIG_RT_USING_BIG_ENDIAN is not set
|
||||
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
|
||||
# CONFIG_RT_USING_SMP is not set
|
||||
CONFIG_RT_ALIGN_SIZE=4
|
||||
|
@ -17,10 +18,19 @@ CONFIG_RT_THREAD_PRIORITY_MAX=32
|
|||
CONFIG_RT_TICK_PER_SECOND=1000
|
||||
CONFIG_RT_USING_OVERFLOW_CHECK=y
|
||||
CONFIG_RT_USING_HOOK=y
|
||||
CONFIG_RT_HOOK_USING_FUNC_PTR=y
|
||||
CONFIG_RT_USING_IDLE_HOOK=y
|
||||
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
|
||||
CONFIG_IDLE_THREAD_STACK_SIZE=2048
|
||||
# CONFIG_RT_USING_TIMER_SOFT is not set
|
||||
|
||||
#
|
||||
# kservice optimization
|
||||
#
|
||||
# CONFIG_RT_KSERVICE_USING_STDLIB is not set
|
||||
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
|
||||
# CONFIG_RT_USING_TINY_FFS is not set
|
||||
# CONFIG_RT_PRINTF_LONGLONG is not set
|
||||
CONFIG_RT_DEBUG=y
|
||||
CONFIG_RT_DEBUG_COLOR=y
|
||||
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
|
||||
|
@ -48,13 +58,18 @@ CONFIG_RT_USING_SIGNALS=y
|
|||
# Memory Management
|
||||
#
|
||||
CONFIG_RT_USING_MEMPOOL=y
|
||||
CONFIG_RT_USING_MEMHEAP=y
|
||||
# CONFIG_RT_USING_NOHEAP is not set
|
||||
CONFIG_RT_USING_SMALL_MEM=y
|
||||
# CONFIG_RT_USING_SLAB is not set
|
||||
CONFIG_RT_USING_MEMHEAP=y
|
||||
CONFIG_RT_MEMHEAP_FAST_MODE=y
|
||||
# CONFIG_RT_MEMHEAP_BSET_MODE is not set
|
||||
CONFIG_RT_USING_SMALL_MEM_AS_HEAP=y
|
||||
# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set
|
||||
# CONFIG_RT_USING_SLAB_AS_HEAP is not set
|
||||
# CONFIG_RT_USING_USERHEAP is not set
|
||||
# CONFIG_RT_USING_NOHEAP is not set
|
||||
CONFIG_RT_USING_MEMTRACE=y
|
||||
# CONFIG_RT_USING_HEAP_ISR is not set
|
||||
CONFIG_RT_USING_HEAP=y
|
||||
|
||||
#
|
||||
|
@ -66,7 +81,7 @@ CONFIG_RT_USING_DEVICE=y
|
|||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=256
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
|
||||
CONFIG_RT_VER_NUM=0x40003
|
||||
CONFIG_RT_VER_NUM=0x40100
|
||||
CONFIG_ARCH_ARM=y
|
||||
# CONFIG_RT_USING_CPU_FFS is not set
|
||||
CONFIG_ARCH_ARM_ARM9=y
|
||||
|
@ -79,6 +94,7 @@ CONFIG_RT_USING_COMPONENTS_INIT=y
|
|||
CONFIG_RT_USING_USER_MAIN=y
|
||||
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
||||
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||
# CONFIG_RT_USING_LEGACY is not set
|
||||
|
||||
#
|
||||
# C++ features
|
||||
|
@ -89,25 +105,26 @@ CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
|||
# Command shell
|
||||
#
|
||||
CONFIG_RT_USING_FINSH=y
|
||||
CONFIG_RT_USING_MSH=y
|
||||
CONFIG_FINSH_USING_MSH=y
|
||||
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_USING_HISTORY=y
|
||||
CONFIG_FINSH_HISTORY_LINES=5
|
||||
CONFIG_FINSH_USING_SYMTAB=y
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
|
||||
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
|
||||
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||
CONFIG_FINSH_CMD_SIZE=80
|
||||
# CONFIG_FINSH_USING_AUTH is not set
|
||||
CONFIG_FINSH_USING_MSH=y
|
||||
CONFIG_FINSH_USING_MSH_DEFAULT=y
|
||||
# CONFIG_FINSH_USING_MSH_ONLY is not set
|
||||
CONFIG_FINSH_ARG_MAX=10
|
||||
|
||||
#
|
||||
# Device virtual file system
|
||||
#
|
||||
CONFIG_RT_USING_DFS=y
|
||||
CONFIG_DFS_USING_POSIX=y
|
||||
CONFIG_DFS_USING_WORKDIR=y
|
||||
CONFIG_DFS_FILESYSTEMS_MAX=16
|
||||
CONFIG_DFS_FILESYSTEM_TYPES_MAX=16
|
||||
|
@ -125,27 +142,32 @@ CONFIG_RT_DFS_ELM_WORD_ACCESS=y
|
|||
# CONFIG_RT_DFS_ELM_USE_LFN_2 is not set
|
||||
CONFIG_RT_DFS_ELM_USE_LFN_3=y
|
||||
CONFIG_RT_DFS_ELM_USE_LFN=3
|
||||
CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_1 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_2 is not set
|
||||
# CONFIG_RT_DFS_ELM_LFN_UNICODE_3 is not set
|
||||
CONFIG_RT_DFS_ELM_LFN_UNICODE=0
|
||||
CONFIG_RT_DFS_ELM_MAX_LFN=255
|
||||
CONFIG_RT_DFS_ELM_DRIVES=8
|
||||
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
|
||||
# CONFIG_RT_DFS_ELM_USE_ERASE is not set
|
||||
CONFIG_RT_DFS_ELM_REENTRANT=y
|
||||
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
|
||||
CONFIG_RT_USING_DFS_DEVFS=y
|
||||
# CONFIG_RT_USING_DFS_ROMFS is not set
|
||||
# CONFIG_RT_USING_DFS_RAMFS is not set
|
||||
# CONFIG_RT_USING_DFS_UFFS is not set
|
||||
# CONFIG_RT_USING_DFS_JFFS2 is not set
|
||||
# CONFIG_RT_USING_DFS_NFS is not set
|
||||
|
||||
#
|
||||
# Device Drivers
|
||||
#
|
||||
CONFIG_RT_USING_DEVICE_IPC=y
|
||||
CONFIG_RT_PIPE_BUFSZ=512
|
||||
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
|
||||
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
|
||||
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
|
||||
CONFIG_RT_USING_SERIAL=y
|
||||
CONFIG_RT_USING_SERIAL_V1=y
|
||||
# CONFIG_RT_USING_SERIAL_V2 is not set
|
||||
CONFIG_RT_SERIAL_USING_DMA=y
|
||||
CONFIG_RT_SERIAL_RB_BUFSZ=2048
|
||||
CONFIG_RT_USING_CAN=y
|
||||
|
@ -167,9 +189,6 @@ CONFIG_RT_USING_PWM=y
|
|||
CONFIG_RT_USING_RTC=y
|
||||
CONFIG_RT_USING_ALARM=y
|
||||
# CONFIG_RT_USING_SOFT_RTC is not set
|
||||
CONFIG_RTC_SYNC_USING_NTP=y
|
||||
CONFIG_RTC_NTP_FIRST_SYNC_DELAY=30
|
||||
CONFIG_RTC_NTP_SYNC_PERIOD=3600
|
||||
# CONFIG_RT_USING_SDIO is not set
|
||||
CONFIG_RT_USING_SPI=y
|
||||
CONFIG_RT_USING_QSPI=y
|
||||
|
@ -220,9 +239,11 @@ CONFIG_RT_HWCRYPTO_USING_RNG=y
|
|||
#
|
||||
# Using USB
|
||||
#
|
||||
CONFIG_RT_USING_USB=y
|
||||
CONFIG_RT_USING_USB_HOST=y
|
||||
CONFIG_RT_USBH_MSTORAGE=y
|
||||
CONFIG_UDISK_MOUNTPOINT="/mnt/udisk"
|
||||
# CONFIG_RT_USBH_HID is not set
|
||||
CONFIG_RT_USING_USB_DEVICE=y
|
||||
CONFIG_RT_USBD_THREAD_STACK_SZ=4096
|
||||
CONFIG_USB_VENDOR_ID=0x0FFE
|
||||
|
@ -247,14 +268,34 @@ CONFIG_RT_USB_MSTORAGE_DISK_NAME="ramdisk1"
|
|||
#
|
||||
# POSIX layer and C standard library
|
||||
#
|
||||
CONFIG_RT_USING_LIBC=y
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
CONFIG_RT_USING_POSIX=y
|
||||
# CONFIG_RT_USING_POSIX_MMAP is not set
|
||||
# CONFIG_RT_USING_POSIX_TERMIOS is not set
|
||||
# CONFIG_RT_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_RT_USING_POSIX_AIO is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
|
||||
#
|
||||
# POSIX (Portable Operating System Interface) layer
|
||||
#
|
||||
CONFIG_RT_USING_POSIX_FS=y
|
||||
CONFIG_RT_USING_POSIX_DEVIO=y
|
||||
CONFIG_RT_USING_POSIX_STDIO=y
|
||||
CONFIG_RT_USING_POSIX_POLL=y
|
||||
CONFIG_RT_USING_POSIX_SELECT=y
|
||||
# CONFIG_RT_USING_POSIX_TERMIOS is not set
|
||||
# CONFIG_RT_USING_POSIX_AIO is not set
|
||||
# CONFIG_RT_USING_POSIX_MMAN is not set
|
||||
# CONFIG_RT_USING_POSIX_DELAY is not set
|
||||
# CONFIG_RT_USING_POSIX_CLOCK is not set
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
|
||||
#
|
||||
# Interprocess Communication (IPC)
|
||||
#
|
||||
# CONFIG_RT_USING_POSIX_PIPE is not set
|
||||
# CONFIG_RT_USING_POSIX_MESSAGE_QUEUE is not set
|
||||
# CONFIG_RT_USING_POSIX_MESSAGE_SEMAPHORE is not set
|
||||
|
||||
#
|
||||
# Socket is in the 'Network' category
|
||||
#
|
||||
|
||||
#
|
||||
# Network
|
||||
|
@ -264,7 +305,7 @@ CONFIG_RT_USING_POSIX=y
|
|||
# Socket abstraction layer
|
||||
#
|
||||
CONFIG_RT_USING_SAL=y
|
||||
CONFIG_SAL_INTERNET_CHECK=y
|
||||
# CONFIG_SAL_INTERNET_CHECK is not set
|
||||
|
||||
#
|
||||
# protocol stack implement
|
||||
|
@ -290,8 +331,9 @@ CONFIG_NETDEV_IPV6=0
|
|||
#
|
||||
CONFIG_RT_USING_LWIP=y
|
||||
# CONFIG_RT_USING_LWIP141 is not set
|
||||
CONFIG_RT_USING_LWIP202=y
|
||||
# CONFIG_RT_USING_LWIP212 is not set
|
||||
# CONFIG_RT_USING_LWIP202 is not set
|
||||
# CONFIG_RT_USING_LWIP203 is not set
|
||||
CONFIG_RT_USING_LWIP212=y
|
||||
# CONFIG_RT_USING_LWIP_IPV6 is not set
|
||||
CONFIG_RT_LWIP_MEM_ALIGNMENT=4
|
||||
CONFIG_RT_LWIP_IGMP=y
|
||||
|
@ -305,30 +347,30 @@ CONFIG_IP_SOF_BROADCAST_RECV=1
|
|||
#
|
||||
# Static IPv4 Address
|
||||
#
|
||||
CONFIG_RT_LWIP_IPADDR="192.168.1.30"
|
||||
CONFIG_RT_LWIP_GWADDR="192.168.1.1"
|
||||
CONFIG_RT_LWIP_IPADDR="192.168.31.55"
|
||||
CONFIG_RT_LWIP_GWADDR="192.168.31.1"
|
||||
CONFIG_RT_LWIP_MSKADDR="255.255.255.0"
|
||||
CONFIG_RT_LWIP_UDP=y
|
||||
CONFIG_RT_LWIP_TCP=y
|
||||
CONFIG_RT_LWIP_RAW=y
|
||||
# CONFIG_RT_LWIP_PPP is not set
|
||||
CONFIG_RT_MEMP_NUM_NETCONN=32
|
||||
CONFIG_RT_MEMP_NUM_NETCONN=16
|
||||
CONFIG_RT_LWIP_PBUF_NUM=256
|
||||
CONFIG_RT_LWIP_RAW_PCB_NUM=32
|
||||
CONFIG_RT_LWIP_UDP_PCB_NUM=32
|
||||
CONFIG_RT_LWIP_TCP_PCB_NUM=32
|
||||
CONFIG_RT_LWIP_TCP_SEG_NUM=256
|
||||
CONFIG_RT_LWIP_TCP_SND_BUF=32768
|
||||
CONFIG_RT_LWIP_TCP_WND=10240
|
||||
CONFIG_RT_LWIP_RAW_PCB_NUM=16
|
||||
CONFIG_RT_LWIP_UDP_PCB_NUM=16
|
||||
CONFIG_RT_LWIP_TCP_PCB_NUM=16
|
||||
CONFIG_RT_LWIP_TCP_SEG_NUM=64
|
||||
CONFIG_RT_LWIP_TCP_SND_BUF=16384
|
||||
CONFIG_RT_LWIP_TCP_WND=65535
|
||||
CONFIG_RT_LWIP_TCPTHREAD_PRIORITY=10
|
||||
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=32
|
||||
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=256
|
||||
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=4096
|
||||
# CONFIG_LWIP_NO_RX_THREAD is not set
|
||||
# CONFIG_LWIP_NO_TX_THREAD is not set
|
||||
CONFIG_RT_LWIP_ETHTHREAD_PRIORITY=12
|
||||
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=1024
|
||||
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=32
|
||||
# CONFIG_RT_LWIP_REASSEMBLY_FRAG is not set
|
||||
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=4096
|
||||
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=256
|
||||
CONFIG_RT_LWIP_REASSEMBLY_FRAG=y
|
||||
CONFIG_LWIP_NETIF_STATUS_CALLBACK=1
|
||||
CONFIG_LWIP_NETIF_LINK_CALLBACK=1
|
||||
CONFIG_SO_REUSE=1
|
||||
|
@ -362,8 +404,15 @@ CONFIG_RT_LWIP_USING_PING=y
|
|||
CONFIG_RT_USING_UTEST=y
|
||||
CONFIG_UTEST_THR_STACK_SIZE=4096
|
||||
CONFIG_UTEST_THR_PRIORITY=20
|
||||
# CONFIG_RT_USING_VAR_EXPORT is not set
|
||||
# CONFIG_RT_USING_RT_LINK is not set
|
||||
# CONFIG_RT_USING_LWP is not set
|
||||
|
||||
#
|
||||
# RT-Thread Utestcases
|
||||
#
|
||||
# CONFIG_RT_USING_UTESTCASES is not set
|
||||
|
||||
#
|
||||
# RT-Thread online packages
|
||||
#
|
||||
|
@ -411,22 +460,25 @@ CONFIG_PKG_NETUTILS_TFTP=y
|
|||
CONFIG_PKG_NETUTILS_IPERF=y
|
||||
# CONFIG_PKG_NETUTILS_NETIO is not set
|
||||
CONFIG_PKG_NETUTILS_NTP=y
|
||||
CONFIG_NETUTILS_NTP_TIMEZONE=8
|
||||
CONFIG_NTP_USING_AUTO_SYNC=y
|
||||
CONFIG_NTP_AUTO_SYNC_FIRST_DELAY=30
|
||||
CONFIG_NTP_AUTO_SYNC_PERIOD=3600
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME="0.tw.pool.ntp.org"
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME2="1.tw.pool.ntp.org"
|
||||
CONFIG_NETUTILS_NTP_HOSTNAME3="2.tw.pool.ntp.org"
|
||||
# CONFIG_PKG_NETUTILS_TELNET is not set
|
||||
# CONFIG_PKG_NETUTILS_TCPDUMP is not set
|
||||
CONFIG_PKG_USING_NETUTILS_V120=y
|
||||
# CONFIG_PKG_USING_NETUTILS_V110 is not set
|
||||
# CONFIG_PKG_USING_NETUTILS_V100 is not set
|
||||
# CONFIG_PKG_USING_NETUTILS_LATEST_VERSION is not set
|
||||
CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
||||
CONFIG_PKG_USING_NETUTILS_V131=y
|
||||
# CONFIG_PKG_USING_NETUTILS_V130 is not set
|
||||
CONFIG_PKG_NETUTILS_VER="v1.3.1"
|
||||
CONFIG_PKG_NETUTILS_VER_NUM=0x10301
|
||||
# CONFIG_PKG_USING_CMUX is not set
|
||||
# CONFIG_PKG_USING_PPP_DEVICE is not set
|
||||
# CONFIG_PKG_USING_AT_DEVICE is not set
|
||||
# CONFIG_PKG_USING_ATSRV_SOCKET is not set
|
||||
# CONFIG_PKG_USING_WIZNET is not set
|
||||
# CONFIG_PKG_USING_ZB_COORDINATOR is not set
|
||||
|
||||
#
|
||||
# IoT Cloud
|
||||
|
@ -439,6 +491,7 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
# CONFIG_PKG_USING_JIOT-C-SDK is not set
|
||||
# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set
|
||||
# CONFIG_PKG_USING_JOYLINK is not set
|
||||
# CONFIG_PKG_USING_EZ_IOT_OS is not set
|
||||
# CONFIG_PKG_USING_NIMBLE is not set
|
||||
# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
|
||||
# CONFIG_PKG_USING_IPMSG is not set
|
||||
|
@ -447,8 +500,6 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
# CONFIG_PKG_USING_LIBRWS is not set
|
||||
# CONFIG_PKG_USING_TCPSERVER is not set
|
||||
# CONFIG_PKG_USING_PROTOBUF_C is not set
|
||||
# CONFIG_PKG_USING_ONNX_PARSER is not set
|
||||
# CONFIG_PKG_USING_ONNX_BACKEND is not set
|
||||
# CONFIG_PKG_USING_DLT645 is not set
|
||||
# CONFIG_PKG_USING_QXWZ is not set
|
||||
# CONFIG_PKG_USING_SMTP_CLIENT is not set
|
||||
|
@ -462,12 +513,26 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
# CONFIG_PKG_USING_PDULIB is not set
|
||||
# CONFIG_PKG_USING_BTSTACK is not set
|
||||
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
|
||||
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
|
||||
# CONFIG_PKG_USING_MAVLINK is not set
|
||||
# CONFIG_PKG_USING_RAPIDJSON is not set
|
||||
# CONFIG_PKG_USING_BSAL is not set
|
||||
# CONFIG_PKG_USING_AGILE_MODBUS is not set
|
||||
# CONFIG_PKG_USING_AGILE_FTP is not set
|
||||
# CONFIG_PKG_USING_EMBEDDEDPROTO is not set
|
||||
# CONFIG_PKG_USING_RT_LINK_HW is not set
|
||||
# CONFIG_PKG_USING_LORA_PKT_FWD is not set
|
||||
# CONFIG_PKG_USING_LORA_GW_DRIVER_LIB is not set
|
||||
# CONFIG_PKG_USING_LORA_PKT_SNIFFER is not set
|
||||
# CONFIG_PKG_USING_HM is not set
|
||||
# CONFIG_PKG_USING_SMALL_MODBUS is not set
|
||||
# CONFIG_PKG_USING_NET_SERVER is not set
|
||||
|
||||
#
|
||||
# security packages
|
||||
#
|
||||
# CONFIG_PKG_USING_MBEDTLS is not set
|
||||
# CONFIG_PKG_USING_libsodium is not set
|
||||
# CONFIG_PKG_USING_LIBSODIUM is not set
|
||||
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||
# CONFIG_PKG_USING_TFM is not set
|
||||
# CONFIG_PKG_USING_YD_CRYPTO is not set
|
||||
|
@ -475,21 +540,51 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
#
|
||||
# language packages
|
||||
#
|
||||
# CONFIG_PKG_USING_LUATOS_SOC is not set
|
||||
# CONFIG_PKG_USING_LUA is not set
|
||||
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||
# CONFIG_PKG_USING_PIKASCRIPT is not set
|
||||
|
||||
#
|
||||
# multimedia packages
|
||||
#
|
||||
|
||||
#
|
||||
# LVGL: powerful and easy-to-use embedded GUI library
|
||||
#
|
||||
# CONFIG_PKG_USING_LVGL is not set
|
||||
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
|
||||
# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set
|
||||
|
||||
#
|
||||
# u8g2: a monochrome graphic library
|
||||
#
|
||||
# CONFIG_PKG_USING_U8G2_OFFICIAL is not set
|
||||
# CONFIG_PKG_USING_U8G2 is not set
|
||||
# CONFIG_PKG_USING_OPENMV is not set
|
||||
# CONFIG_PKG_USING_MUPDF is not set
|
||||
# CONFIG_PKG_USING_STEMWIN is not set
|
||||
# CONFIG_PKG_USING_WAVPLAYER is not set
|
||||
# CONFIG_PKG_USING_TJPGD is not set
|
||||
# CONFIG_PKG_USING_PDFGEN is not set
|
||||
# CONFIG_PKG_USING_HELIX is not set
|
||||
# CONFIG_PKG_USING_AZUREGUIX is not set
|
||||
# CONFIG_PKG_USING_TOUCHGFX2RTT is not set
|
||||
# CONFIG_PKG_USING_NUEMWIN is not set
|
||||
# CONFIG_PKG_USING_MP3PLAYER is not set
|
||||
# CONFIG_PKG_USING_TINYJPEG is not set
|
||||
# CONFIG_PKG_USING_UGUI is not set
|
||||
|
||||
#
|
||||
# PainterEngine: A cross-platform graphics application framework written in C language
|
||||
#
|
||||
# CONFIG_PKG_USING_PAINTERENGINE is not set
|
||||
# CONFIG_PKG_USING_PAINTERENGINE_AUX is not set
|
||||
# CONFIG_PKG_USING_MCURSES is not set
|
||||
# CONFIG_PKG_USING_TERMBOX is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
|
@ -498,9 +593,11 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_SEGGER_RTT is not set
|
||||
# CONFIG_PKG_USING_RDB is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_ULOG_FILE is not set
|
||||
# CONFIG_PKG_USING_LOGMGR is not set
|
||||
# CONFIG_PKG_USING_ADBD is not set
|
||||
# CONFIG_PKG_USING_COREMARK is not set
|
||||
# CONFIG_PKG_USING_DHRYSTONE is not set
|
||||
|
@ -514,15 +611,72 @@ CONFIG_PKG_NETUTILS_VER="v1.2.0"
|
|||
# CONFIG_PKG_USING_UMCN is not set
|
||||
# CONFIG_PKG_USING_LWRB2RTT is not set
|
||||
# CONFIG_PKG_USING_CPU_USAGE is not set
|
||||
# CONFIG_PKG_USING_GBK2UTF8 is not set
|
||||
# CONFIG_PKG_USING_VCONSOLE is not set
|
||||
# CONFIG_PKG_USING_KDB is not set
|
||||
# CONFIG_PKG_USING_WAMR is not set
|
||||
# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set
|
||||
# CONFIG_PKG_USING_LWLOG is not set
|
||||
# CONFIG_PKG_USING_ANV_TRACE is not set
|
||||
# CONFIG_PKG_USING_ANV_MEMLEAK is not set
|
||||
# CONFIG_PKG_USING_ANV_TESTSUIT is not set
|
||||
# CONFIG_PKG_USING_ANV_BENCH is not set
|
||||
# CONFIG_PKG_USING_DEVMEM is not set
|
||||
# CONFIG_PKG_USING_REGEX is not set
|
||||
CONFIG_PKG_USING_MEM_SANDBOX=y
|
||||
CONFIG_PKG_MEM_SANDBOX_PATH="/packages/tools/mem_sandbox"
|
||||
CONFIG_PKG_USING_MEM_SANDBOX_LATEST_VERSION=y
|
||||
CONFIG_PKG_MEM_SANDBOX_VER="latest"
|
||||
# CONFIG_PKG_USING_SOLAR_TERMS is not set
|
||||
# CONFIG_PKG_USING_GAN_ZHI is not set
|
||||
# CONFIG_PKG_USING_FDT is not set
|
||||
|
||||
#
|
||||
# system packages
|
||||
#
|
||||
|
||||
#
|
||||
# enhanced kernel services
|
||||
#
|
||||
# CONFIG_PKG_USING_RT_MEMCPY_CM is not set
|
||||
# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set
|
||||
# CONFIG_PKG_USING_RT_VSNPRINTF_FULL is not set
|
||||
|
||||
#
|
||||
# POSIX extension functions
|
||||
#
|
||||
# CONFIG_PKG_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_PKG_USING_POSIX_WCWIDTH is not set
|
||||
# CONFIG_PKG_USING_POSIX_ITOA is not set
|
||||
# CONFIG_PKG_USING_POSIX_STRINGS is not set
|
||||
|
||||
#
|
||||
# acceleration: Assembly language or algorithmic acceleration packages
|
||||
#
|
||||
# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set
|
||||
# CONFIG_PKG_USING_QFPLIB_M3 is not set
|
||||
|
||||
#
|
||||
# CMSIS: ARM Cortex-M Microcontroller Software Interface Standard
|
||||
#
|
||||
# CONFIG_PKG_USING_CMSIS_5 is not set
|
||||
# CONFIG_PKG_USING_CMSIS_RTOS2 is not set
|
||||
|
||||
#
|
||||
# Micrium: Micrium software products porting for RT-Thread
|
||||
#
|
||||
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
|
||||
# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
|
||||
# CONFIG_PKG_USING_UC_CRC is not set
|
||||
# CONFIG_PKG_USING_UC_CLK is not set
|
||||
# CONFIG_PKG_USING_UC_COMMON is not set
|
||||
# CONFIG_PKG_USING_UC_MODBUS is not set
|
||||
# CONFIG_RT_USING_ARDUINO is not set
|
||||
# CONFIG_PKG_USING_GUIENGINE is not set
|
||||
# CONFIG_PKG_USING_PERSIMMON is not set
|
||||
# CONFIG_PKG_USING_CAIRO is not set
|
||||
# CONFIG_PKG_USING_PIXMAN is not set
|
||||
# CONFIG_PKG_USING_LWEXT4 is not set
|
||||
# CONFIG_PKG_USING_PARTITION is not set
|
||||
CONFIG_PKG_USING_FAL=y
|
||||
CONFIG_PKG_FAL_PATH="/packages/system/fal"
|
||||
|
@ -542,10 +696,11 @@ CONFIG_PKG_FAL_VER_NUM=0x99999
|
|||
# CONFIG_PKG_USING_FLASHDB is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
|
||||
# CONFIG_PKG_USING_CMSIS is not set
|
||||
# CONFIG_PKG_USING_DFS_YAFFS is not set
|
||||
# CONFIG_PKG_USING_LITTLEFS is not set
|
||||
# CONFIG_PKG_USING_DFS_JFFS2 is not set
|
||||
# CONFIG_PKG_USING_DFS_UFFS is not set
|
||||
# CONFIG_PKG_USING_LWEXT4 is not set
|
||||
# CONFIG_PKG_USING_THREAD_POOL is not set
|
||||
# CONFIG_PKG_USING_ROBOTS is not set
|
||||
# CONFIG_PKG_USING_EV is not set
|
||||
|
@ -559,17 +714,15 @@ CONFIG_PKG_USING_RAMDISK_LATEST_VERSION=y
|
|||
CONFIG_PKG_RAMDISK_VER="latest"
|
||||
# CONFIG_PKG_USING_MININI is not set
|
||||
# CONFIG_PKG_USING_QBOOT is not set
|
||||
|
||||
#
|
||||
# Micrium: Micrium software products porting for RT-Thread
|
||||
#
|
||||
# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set
|
||||
# CONFIG_PKG_USING_UCOSII_WRAPPER is not set
|
||||
# CONFIG_PKG_USING_UC_CRC is not set
|
||||
# CONFIG_PKG_USING_UC_CLK is not set
|
||||
# CONFIG_PKG_USING_UC_COMMON is not set
|
||||
# CONFIG_PKG_USING_UC_MODBUS is not set
|
||||
# CONFIG_PKG_USING_PPOOL is not set
|
||||
# CONFIG_PKG_USING_OPENAMP is not set
|
||||
# CONFIG_PKG_USING_LPM is not set
|
||||
# CONFIG_PKG_USING_TLSF is not set
|
||||
# CONFIG_PKG_USING_EVENT_RECORDER is not set
|
||||
# CONFIG_PKG_USING_ARM_2D is not set
|
||||
# CONFIG_PKG_USING_MCUBOOT is not set
|
||||
# CONFIG_PKG_USING_TINYUSB is not set
|
||||
# CONFIG_PKG_USING_USB_STACK is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
|
@ -578,9 +731,9 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
|||
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
||||
# CONFIG_PKG_USING_SHT2X is not set
|
||||
# CONFIG_PKG_USING_SHT3X is not set
|
||||
# CONFIG_PKG_USING_AS7341 is not set
|
||||
# CONFIG_PKG_USING_STM32_SDIO is not set
|
||||
# CONFIG_PKG_USING_ICM20608 is not set
|
||||
# CONFIG_PKG_USING_U8G2 is not set
|
||||
# CONFIG_PKG_USING_BUTTON is not set
|
||||
# CONFIG_PKG_USING_PCF8574 is not set
|
||||
# CONFIG_PKG_USING_SX12XX is not set
|
||||
|
@ -593,7 +746,6 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
|||
# CONFIG_PKG_USING_WM_LIBRARIES is not set
|
||||
# CONFIG_PKG_USING_KENDRYTE_SDK is not set
|
||||
# CONFIG_PKG_USING_INFRARED is not set
|
||||
# CONFIG_PKG_USING_ROSSERIAL is not set
|
||||
# CONFIG_PKG_USING_AGILE_BUTTON is not set
|
||||
# CONFIG_PKG_USING_AGILE_LED is not set
|
||||
# CONFIG_PKG_USING_AT24CXX is not set
|
||||
|
@ -627,16 +779,73 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
|||
# CONFIG_PKG_USING_SSD1306 is not set
|
||||
# CONFIG_PKG_USING_QKEY is not set
|
||||
# CONFIG_PKG_USING_RS485 is not set
|
||||
# CONFIG_PKG_USING_RS232 is not set
|
||||
# CONFIG_PKG_USING_NES is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
|
||||
# CONFIG_PKG_USING_VDEVICE is not set
|
||||
# CONFIG_PKG_USING_SGM706 is not set
|
||||
# CONFIG_PKG_USING_STM32WB55_SDK is not set
|
||||
# CONFIG_PKG_USING_RDA58XX is not set
|
||||
# CONFIG_PKG_USING_LIBNFC is not set
|
||||
# CONFIG_PKG_USING_MFOC is not set
|
||||
# CONFIG_PKG_USING_TMC51XX is not set
|
||||
# CONFIG_PKG_USING_TCA9534 is not set
|
||||
# CONFIG_PKG_USING_KOBUKI is not set
|
||||
# CONFIG_PKG_USING_ROSSERIAL is not set
|
||||
# CONFIG_PKG_USING_MICRO_ROS is not set
|
||||
# CONFIG_PKG_USING_MCP23008 is not set
|
||||
# CONFIG_PKG_USING_BLUETRUM_SDK is not set
|
||||
# CONFIG_PKG_USING_MISAKA_AT24CXX is not set
|
||||
# CONFIG_PKG_USING_MISAKA_RGB_BLING is not set
|
||||
# CONFIG_PKG_USING_LORA_MODEM_DRIVER is not set
|
||||
# CONFIG_PKG_USING_BL_MCU_SDK is not set
|
||||
# CONFIG_PKG_USING_SOFT_SERIAL is not set
|
||||
# CONFIG_PKG_USING_MB85RS16 is not set
|
||||
# CONFIG_PKG_USING_CW2015 is not set
|
||||
|
||||
#
|
||||
# AI packages
|
||||
#
|
||||
# CONFIG_PKG_USING_LIBANN is not set
|
||||
# CONFIG_PKG_USING_NNOM is not set
|
||||
# CONFIG_PKG_USING_ONNX_BACKEND is not set
|
||||
# CONFIG_PKG_USING_ONNX_PARSER is not set
|
||||
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
|
||||
# CONFIG_PKG_USING_ELAPACK is not set
|
||||
# CONFIG_PKG_USING_ULAPACK is not set
|
||||
# CONFIG_PKG_USING_QUEST is not set
|
||||
# CONFIG_PKG_USING_NAXOS is not set
|
||||
|
||||
#
|
||||
# miscellaneous packages
|
||||
#
|
||||
|
||||
#
|
||||
# samples: kernel and components samples
|
||||
#
|
||||
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
|
||||
|
||||
#
|
||||
# entertainment: terminal games and other interesting software packages
|
||||
#
|
||||
# CONFIG_PKG_USING_CMATRIX is not set
|
||||
# CONFIG_PKG_USING_SL is not set
|
||||
# CONFIG_PKG_USING_CAL is not set
|
||||
# CONFIG_PKG_USING_ACLOCK is not set
|
||||
# CONFIG_PKG_USING_THREES is not set
|
||||
# CONFIG_PKG_USING_2048 is not set
|
||||
# CONFIG_PKG_USING_SNAKE is not set
|
||||
# CONFIG_PKG_USING_TETRIS is not set
|
||||
# CONFIG_PKG_USING_DONUT is not set
|
||||
# CONFIG_PKG_USING_COWSAY is not set
|
||||
# CONFIG_PKG_USING_LIBCSV is not set
|
||||
CONFIG_PKG_USING_OPTPARSE=y
|
||||
CONFIG_PKG_OPTPARSE_PATH="/packages/misc/optparse"
|
||||
CONFIG_PKG_USING_OPTPARSE_V100=y
|
||||
# CONFIG_PKG_USING_OPTPARSE_LATEST_VERSION is not set
|
||||
CONFIG_PKG_OPTPARSE_VER="v1.0.0"
|
||||
CONFIG_PKG_USING_OPTPARSE_LATEST_VERSION=y
|
||||
CONFIG_PKG_OPTPARSE_VER="latest"
|
||||
# CONFIG_OPTPARSE_USING_DEMO is not set
|
||||
# CONFIG_PKG_USING_FASTLZ is not set
|
||||
# CONFIG_PKG_USING_MINILZO is not set
|
||||
|
@ -646,69 +855,44 @@ CONFIG_PKG_OPTPARSE_VER="v1.0.0"
|
|||
# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set
|
||||
# CONFIG_PKG_USING_CANFESTIVAL is not set
|
||||
# CONFIG_PKG_USING_ZLIB is not set
|
||||
# CONFIG_PKG_USING_MINIZIP is not set
|
||||
# CONFIG_PKG_USING_DSTR is not set
|
||||
# CONFIG_PKG_USING_TINYFRAME is not set
|
||||
# CONFIG_PKG_USING_KENDRYTE_DEMO is not set
|
||||
# CONFIG_PKG_USING_DIGITALCTRL is not set
|
||||
# CONFIG_PKG_USING_UPACKER is not set
|
||||
# CONFIG_PKG_USING_UPARAM is not set
|
||||
|
||||
#
|
||||
# samples: kernel and components samples
|
||||
#
|
||||
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
|
||||
# CONFIG_PKG_USING_HELLO is not set
|
||||
CONFIG_PKG_USING_VI=y
|
||||
CONFIG_PKG_VI_PATH="/packages/misc/vi"
|
||||
CONFIG_VI_SANDBOX_SIZE_KB=20
|
||||
CONFIG_VI_MAX_LEN=4096
|
||||
# CONFIG_VI_ENABLE_8BIT is not set
|
||||
CONFIG_VI_ENABLE_COLON=y
|
||||
CONFIG_VI_ENABLE_COLON_EXPAND=y
|
||||
CONFIG_VI_ENABLE_YANKMARK=y
|
||||
CONFIG_VI_ENABLE_SEARCH=y
|
||||
CONFIG_VI_ENABLE_DOT_CMD=y
|
||||
CONFIG_VI_ENABLE_READONLY=y
|
||||
CONFIG_VI_ENABLE_SETOPTS=y
|
||||
CONFIG_VI_ENABLE_SET=y
|
||||
# CONFIG_VI_ENABLE_WIN_RESIZE is not set
|
||||
CONFIG_VI_ENABLE_VI_ASK_TERMINAL=y
|
||||
CONFIG_VI_ENABLE_UNDO=y
|
||||
CONFIG_VI_ENABLE_UNDO_QUEUE=y
|
||||
CONFIG_VI_UNDO_QUEUE_MAX=256
|
||||
CONFIG_VI_ENABLE_VERBOSE_STATUS=y
|
||||
CONFIG_PKG_USING_VI_LATEST_VERSION=y
|
||||
CONFIG_PKG_VI_VER="latest"
|
||||
# CONFIG_PKG_USING_KI is not set
|
||||
# CONFIG_PKG_USING_NNOM is not set
|
||||
# CONFIG_PKG_USING_LIBANN is not set
|
||||
# CONFIG_PKG_USING_ELAPACK is not set
|
||||
# CONFIG_PKG_USING_ARMv7M_DWT is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_ULAPACK is not set
|
||||
# CONFIG_PKG_USING_UKAL is not set
|
||||
# CONFIG_PKG_USING_CRCLIB is not set
|
||||
|
||||
#
|
||||
# games: games run on RT-Thread console
|
||||
#
|
||||
# CONFIG_PKG_USING_THREES is not set
|
||||
# CONFIG_PKG_USING_2048 is not set
|
||||
# CONFIG_PKG_USING_SNAKE is not set
|
||||
# CONFIG_PKG_USING_TETRIS is not set
|
||||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
CONFIG_NU_PKG_USING_NAU8822=y
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
# CONFIG_PKG_USING_DESIGN_PATTERN is not set
|
||||
# CONFIG_PKG_USING_CONTROLLER is not set
|
||||
# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
|
@ -718,12 +902,11 @@ CONFIG_NU_PKG_USING_NAU8822=y
|
|||
# On-chip Peripheral Drivers
|
||||
#
|
||||
CONFIG_SOC_SERIES_NUC980=y
|
||||
# CONFIG_BSP_USE_STDDRIVER_SOURCE is not set
|
||||
CONFIG_BSP_USE_STDDRIVER_SOURCE=y
|
||||
CONFIG_BSP_USING_MMU=y
|
||||
CONFIG_BSP_USING_PDMA=y
|
||||
CONFIG_NU_PDMA_MEMFUN_ACTOR_MAX=2
|
||||
CONFIG_BSP_USING_GPIO=y
|
||||
# CONFIG_BSP_USING_CLK is not set
|
||||
CONFIG_BSP_USING_EMAC=y
|
||||
CONFIG_BSP_USING_EMAC0=y
|
||||
# CONFIG_BSP_USING_EMAC1 is not set
|
||||
|
@ -732,27 +915,23 @@ CONFIG_BSP_USING_RTC=y
|
|||
CONFIG_NU_RTC_SUPPORT_IO_RW=y
|
||||
CONFIG_NU_RTC_SUPPORT_MSH_CMD=y
|
||||
CONFIG_BSP_USING_ADC=y
|
||||
# CONFIG_BSP_USING_ADC_TOUCH is not set
|
||||
CONFIG_BSP_USING_TMR=y
|
||||
CONFIG_BSP_USING_TIMER=y
|
||||
CONFIG_BSP_USING_TMR0=y
|
||||
CONFIG_BSP_USING_TIMER0=y
|
||||
# CONFIG_BSP_USING_TPWM0 is not set
|
||||
# CONFIG_BSP_USING_TIMER0_CAPTURE is not set
|
||||
CONFIG_BSP_USING_TMR1=y
|
||||
CONFIG_BSP_USING_TIMER1=y
|
||||
# CONFIG_BSP_USING_TPWM1 is not set
|
||||
# CONFIG_BSP_USING_TIMER1_CAPTURE is not set
|
||||
CONFIG_BSP_USING_TMR2=y
|
||||
CONFIG_BSP_USING_TIMER2=y
|
||||
# CONFIG_BSP_USING_TPWM2 is not set
|
||||
# CONFIG_BSP_USING_TIMER2_CAPTURE is not set
|
||||
CONFIG_BSP_USING_TMR3=y
|
||||
CONFIG_BSP_USING_TIMER3=y
|
||||
# CONFIG_BSP_USING_TPWM3 is not set
|
||||
# CONFIG_BSP_USING_TIMER3_CAPTURE is not set
|
||||
CONFIG_BSP_USING_TMR4=y
|
||||
CONFIG_BSP_USING_TIMER4=y
|
||||
# CONFIG_BSP_USING_TPWM4 is not set
|
||||
# CONFIG_BSP_USING_TIMER4_CAPTURE is not set
|
||||
CONFIG_BSP_USING_UART=y
|
||||
CONFIG_BSP_USING_UART0=y
|
||||
|
@ -794,8 +973,9 @@ CONFIG_BSP_USING_SPI1_NONE=y
|
|||
CONFIG_BSP_USING_I2S=y
|
||||
CONFIG_NU_I2S_DMA_FIFO_SIZE=4096
|
||||
CONFIG_BSP_USING_QSPI=y
|
||||
# CONFIG_BSP_USING_QSPI_PDMA is not set
|
||||
CONFIG_BSP_USING_QSPI0=y
|
||||
CONFIG_BSP_USING_QSPI0_PDMA=y
|
||||
# CONFIG_BSP_USING_QSPI0_PDMA is not set
|
||||
# CONFIG_BSP_USING_SCUART is not set
|
||||
CONFIG_BSP_USING_CRYPTO=y
|
||||
# CONFIG_NU_PRNG_USE_SEED is not set
|
||||
|
@ -823,5 +1003,18 @@ CONFIG_BOARD_USING_USB1_HOST=y
|
|||
# CONFIG_BOARD_USING_MAX31875 is not set
|
||||
# CONFIG_BOARD_USING_LCD_ILI9341 is not set
|
||||
# CONFIG_BOARD_USING_ESP8266 is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
CONFIG_NU_PKG_USING_NAU8822=y
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
CONFIG_BOARD_USE_UTEST=y
|
||||
CONFIG_UTEST_CMD_PREFIX="bsp.nuvoton.nk980-iot.test.utest."
|
||||
|
|
|
@ -85,4 +85,10 @@ elif PLATFORM == 'armcc':
|
|||
CFLAGS += ' -O2'
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output ' + TARGET_NAME + ' \n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
|
|
@ -85,4 +85,10 @@ elif PLATFORM == 'armcc':
|
|||
CFLAGS += ' -O2'
|
||||
|
||||
POST_ACTION = 'fromelf --bin $TARGET --output ' + TARGET_NAME + ' \n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
POST_ACTION += 'fromelf -z $TARGET\n'
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
|
|
@ -130,3 +130,11 @@ elif PLATFORM == 'iar':
|
|||
|
||||
EXEC_PATH = EXEC_PATH + '/arm/bin/'
|
||||
POST_ACTION = ''
|
||||
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
||||
|
|
|
@ -122,3 +122,11 @@ elif PLATFORM == 'iar':
|
|||
|
||||
EXEC_PATH += '/arm/bin/'
|
||||
POST_ACTION = ''
|
||||
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
||||
|
|
|
@ -557,6 +557,7 @@ CONFIG_PKG_AT_DEVICE_VER_NUM=0x99999
|
|||
# CONFIG_PKG_USING_MCURSES is not set
|
||||
# CONFIG_PKG_USING_TERMBOX is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
|
@ -567,7 +568,6 @@ CONFIG_PKG_AT_DEVICE_VER_NUM=0x99999
|
|||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_SEGGER_RTT is not set
|
||||
# CONFIG_PKG_USING_RDB is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_ULOG_FILE is not set
|
||||
# CONFIG_PKG_USING_LOGMGR is not set
|
||||
|
@ -618,6 +618,7 @@ CONFIG_PKG_AT_DEVICE_VER_NUM=0x99999
|
|||
# CONFIG_PKG_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_PKG_USING_POSIX_WCWIDTH is not set
|
||||
# CONFIG_PKG_USING_POSIX_ITOA is not set
|
||||
# CONFIG_PKG_USING_POSIX_STRINGS is not set
|
||||
|
||||
#
|
||||
# acceleration: Assembly language or algorithmic acceleration packages
|
||||
|
@ -652,14 +653,14 @@ CONFIG_FAL_DEBUG_CONFIG=y
|
|||
CONFIG_FAL_DEBUG=1
|
||||
CONFIG_FAL_PART_HAS_TABLE_CFG=y
|
||||
# CONFIG_FAL_USING_SFUD_PORT is not set
|
||||
CONFIG_PKG_USING_FAL_V00500=y
|
||||
# CONFIG_PKG_USING_FAL_V00500 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00400 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00300 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00200 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00100 is not set
|
||||
# CONFIG_PKG_USING_FAL_LATEST_VERSION is not set
|
||||
CONFIG_PKG_FAL_VER="v0.5.0"
|
||||
CONFIG_PKG_FAL_VER_NUM=0x00500
|
||||
CONFIG_PKG_USING_FAL_LATEST_VERSION=y
|
||||
CONFIG_PKG_FAL_VER="latest"
|
||||
CONFIG_PKG_FAL_VER_NUM=0x99999
|
||||
# CONFIG_PKG_USING_FLASHDB is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
|
@ -742,6 +743,7 @@ CONFIG_PKG_FAL_VER_NUM=0x00500
|
|||
# CONFIG_PKG_USING_SSD1306 is not set
|
||||
# CONFIG_PKG_USING_QKEY is not set
|
||||
# CONFIG_PKG_USING_RS485 is not set
|
||||
# CONFIG_PKG_USING_RS232 is not set
|
||||
# CONFIG_PKG_USING_NES is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
|
||||
# CONFIG_PKG_USING_VDEVICE is not set
|
||||
|
@ -829,19 +831,8 @@ CONFIG_PKG_FAL_VER_NUM=0x00500
|
|||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
# CONFIG_PKG_USING_DESIGN_PATTERN is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU8822 is not set
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
# CONFIG_PKG_USING_CONTROLLER is not set
|
||||
# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
|
@ -947,5 +938,18 @@ CONFIG_BOARD_USING_OTG=y
|
|||
# Board extended module drivers
|
||||
#
|
||||
CONFIG_BOARD_USING_SEGMENT_LCD=y
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU88L25 is not set
|
||||
# CONFIG_NU_PKG_USING_NAU8822 is not set
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
CONFIG_BOARD_USE_UTEST=y
|
||||
CONFIG_UTEST_CMD_PREFIX="bsp.nuvoton.numaker-m2354.test.utest."
|
||||
|
|
|
@ -122,3 +122,11 @@ elif PLATFORM == 'iar':
|
|||
|
||||
EXEC_PATH += '/arm/bin/'
|
||||
POST_ACTION = ''
|
||||
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
||||
|
|
|
@ -578,6 +578,7 @@ CONFIG_UTEST_THR_PRIORITY=20
|
|||
# CONFIG_PKG_USING_MCURSES is not set
|
||||
# CONFIG_PKG_USING_TERMBOX is not set
|
||||
# CONFIG_PKG_USING_VT100 is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
|
||||
#
|
||||
# tools packages
|
||||
|
@ -588,7 +589,6 @@ CONFIG_UTEST_THR_PRIORITY=20
|
|||
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||
# CONFIG_PKG_USING_SEGGER_RTT is not set
|
||||
# CONFIG_PKG_USING_RDB is not set
|
||||
# CONFIG_PKG_USING_QRCODE is not set
|
||||
# CONFIG_PKG_USING_ULOG_EASYFLASH is not set
|
||||
# CONFIG_PKG_USING_ULOG_FILE is not set
|
||||
# CONFIG_PKG_USING_LOGMGR is not set
|
||||
|
@ -639,6 +639,7 @@ CONFIG_UTEST_THR_PRIORITY=20
|
|||
# CONFIG_PKG_USING_POSIX_GETLINE is not set
|
||||
# CONFIG_PKG_USING_POSIX_WCWIDTH is not set
|
||||
# CONFIG_PKG_USING_POSIX_ITOA is not set
|
||||
# CONFIG_PKG_USING_POSIX_STRINGS is not set
|
||||
|
||||
#
|
||||
# acceleration: Assembly language or algorithmic acceleration packages
|
||||
|
@ -675,13 +676,13 @@ CONFIG_FAL_DEBUG=1
|
|||
CONFIG_FAL_PART_HAS_TABLE_CFG=y
|
||||
# CONFIG_FAL_USING_SFUD_PORT is not set
|
||||
# CONFIG_PKG_USING_FAL_V00500 is not set
|
||||
CONFIG_PKG_USING_FAL_V00400=y
|
||||
# CONFIG_PKG_USING_FAL_V00400 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00300 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00200 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00100 is not set
|
||||
# CONFIG_PKG_USING_FAL_LATEST_VERSION is not set
|
||||
CONFIG_PKG_FAL_VER="v0.4.0"
|
||||
CONFIG_PKG_FAL_VER_NUM=0x00400
|
||||
CONFIG_PKG_USING_FAL_LATEST_VERSION=y
|
||||
CONFIG_PKG_FAL_VER="latest"
|
||||
CONFIG_PKG_FAL_VER_NUM=0x99999
|
||||
# CONFIG_PKG_USING_FLASHDB is not set
|
||||
# CONFIG_PKG_USING_SQLITE is not set
|
||||
# CONFIG_PKG_USING_RTI is not set
|
||||
|
@ -764,6 +765,7 @@ CONFIG_PKG_FAL_VER_NUM=0x00400
|
|||
# CONFIG_PKG_USING_SSD1306 is not set
|
||||
# CONFIG_PKG_USING_QKEY is not set
|
||||
# CONFIG_PKG_USING_RS485 is not set
|
||||
# CONFIG_PKG_USING_RS232 is not set
|
||||
# CONFIG_PKG_USING_NES is not set
|
||||
# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set
|
||||
# CONFIG_PKG_USING_VDEVICE is not set
|
||||
|
@ -851,19 +853,8 @@ CONFIG_PKG_FAL_VER_NUM=0x00400
|
|||
# CONFIG_PKG_USING_LWGPS is not set
|
||||
# CONFIG_PKG_USING_STATE_MACHINE is not set
|
||||
# CONFIG_PKG_USING_DESIGN_PATTERN is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
CONFIG_NU_PKG_USING_NAU88L25=y
|
||||
# CONFIG_NU_PKG_USING_NAU8822 is not set
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
# CONFIG_PKG_USING_CONTROLLER is not set
|
||||
# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
|
@ -975,5 +966,18 @@ CONFIG_BOARD_USING_HSUSBH_USBD=y
|
|||
# Board extended module drivers
|
||||
#
|
||||
# CONFIG_BOARD_USING_ADVANCE_V4 is not set
|
||||
|
||||
#
|
||||
# Nuvoton Packages Config
|
||||
#
|
||||
CONFIG_NU_PKG_USING_UTILS=y
|
||||
CONFIG_NU_PKG_USING_DEMO=y
|
||||
# CONFIG_NU_PKG_USING_BMX055 is not set
|
||||
# CONFIG_NU_PKG_USING_MAX31875 is not set
|
||||
CONFIG_NU_PKG_USING_NAU88L25=y
|
||||
# CONFIG_NU_PKG_USING_NAU8822 is not set
|
||||
# CONFIG_NU_PKG_USING_DA9062 is not set
|
||||
# CONFIG_NU_PKG_USING_ILI9341 is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
CONFIG_BOARD_USE_UTEST=y
|
||||
CONFIG_UTEST_CMD_PREFIX="bsp.nuvoton.numaker-pfm-m487.test.utest."
|
||||
|
|
|
@ -130,3 +130,11 @@ elif PLATFORM == 'iar':
|
|||
|
||||
EXEC_PATH = EXEC_PATH + '/arm/bin/'
|
||||
POST_ACTION = ''
|
||||
|
||||
def dist_handle(BSP_ROOT, dist_dir):
|
||||
import sys
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(BSP_ROOT), 'tools'))
|
||||
from sdk_dist import dist_do_building
|
||||
dist_do_building(BSP_ROOT, dist_dir)
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import os
|
||||
import sys
|
||||
import shutil
|
||||
cwd_path = os.getcwd()
|
||||
sys.path.append(os.path.join(os.path.dirname(cwd_path), 'rt-thread', 'tools'))
|
||||
|
||||
def dist_modify_relative_path(board_kconfig_path):
|
||||
# Read in the file
|
||||
with open(board_kconfig_path, 'r') as file :
|
||||
filedata = file.read()
|
||||
|
||||
# Replace the target string
|
||||
filedata = filedata.replace('$BSP_DIR/../libraries', './libraries')
|
||||
|
||||
# Write the file out again
|
||||
with open(board_kconfig_path, 'w') as file:
|
||||
file.write(filedata)
|
||||
|
||||
# BSP dist function
|
||||
def dist_do_building(BSP_ROOT, dist_dir):
|
||||
from mkdist import bsp_copy_files
|
||||
import rtconfig
|
||||
|
||||
library_path = os.path.join(os.path.dirname(BSP_ROOT), 'libraries')
|
||||
library_dir = os.path.join(dist_dir, 'libraries')
|
||||
|
||||
print('=> copy nuvoton bsp drivers')
|
||||
bsp_copy_files(os.path.join(library_path, rtconfig.BSP_LIBRARY_TYPE),
|
||||
os.path.join(library_dir, rtconfig.BSP_LIBRARY_TYPE))
|
||||
|
||||
print('=> copy nu_packages')
|
||||
bsp_copy_files(os.path.join(library_path, 'nu_packages'),
|
||||
os.path.join(library_dir, 'nu_packages'))
|
||||
|
||||
print('=> copy Kconfig')
|
||||
shutil.copyfile(os.path.join(library_path, 'Kconfig'), os.path.join(library_dir, 'Kconfig'))
|
||||
|
||||
print('=> Modify libraries relative path in board/Kconfig ')
|
||||
dist_modify_relative_path(os.path.join(dist_dir, 'board', 'Kconfig'))
|
Loading…
Reference in New Issue