mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
Merge branch 'RT-Thread:master' into master
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
# Bring up LVGL demo on Nuvoton platforms
|
||||
|
||||
Current supported LVGL running environment on Nuvoton's boards shown in below table:
|
||||
|
||||
| **Board Name** | **Default demo** | **Need Expansion** | **Used Configuration filename** |
|
||||
| -------------- | ------------------------------- | ---------------- | ----------- |
|
||||
| numaker-iot-m487 | Widgets | Nu-TFT v1.3 | config_lvgl |
|
||||
| numaker-pfm-m487 | Widgets | Advance v4 | config_lvgl |
|
||||
| nk-980iot | Music | Nu-TFT v1.3 | config_lvgl |
|
||||
| numaker-m2354 | Music | Nu-TFT v1.3 | config_lvgl |
|
||||
| nk-n9h30 | Music | No | .config |
|
||||
| numaker-m032ki | Widgets | Nu-TFT v1.3 | config_lvgl |
|
||||
|
||||
## Download related packages
|
||||
|
||||
To execute below commands in env command-line window to download related packages for building.
|
||||
|
||||
```bash
|
||||
# cd <path-to-rt-thread>bsp/nuvoton/<board-name>
|
||||
# menuconfig --config config_lvgl
|
||||
# pkgs --update
|
||||
# scons
|
||||
```
|
||||
|
||||
## Firmware programming
|
||||
|
||||
To program built rt-thread.bin into flash. You can refer steps in README.md in corresponding supported board folder or CN quick-start guide in rt-thread documents site.
|
||||
|
||||
```
|
||||
<path-to-rt-thread>/bsp/nuvoton/<board-name>/README.md
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/tutorial/quick-start/more
|
||||
```
|
||||
@@ -8,9 +8,6 @@
|
||||
*****************************************************************************/
|
||||
#include "M031Series.h"
|
||||
|
||||
|
||||
static uint8_t u8ChSelect[PDMA_CH_MAX];
|
||||
|
||||
/** @addtogroup Standard_Driver Standard Driver
|
||||
@{
|
||||
*/
|
||||
@@ -28,6 +25,7 @@ static uint8_t u8ChSelect[PDMA_CH_MAX];
|
||||
* @brief PDMA Open
|
||||
*
|
||||
* @param[in] pdma The pointer of the specified PDMA module
|
||||
*
|
||||
* @param[in] u32Mask Channel enable bits.
|
||||
*
|
||||
* @return None
|
||||
@@ -40,10 +38,9 @@ void PDMA_Open(PDMA_T *pdma, uint32_t u32Mask)
|
||||
|
||||
for (i = 0UL; i < PDMA_CH_MAX; i++)
|
||||
{
|
||||
if((1 << i) & u32Mask)
|
||||
if ((1 << i) & u32Mask)
|
||||
{
|
||||
pdma->DSCT[i].CTL = 0UL;
|
||||
u8ChSelect[i] = PDMA_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,59 +163,26 @@ void PDMA_SetTransferAddr(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32SrcAddr, uin
|
||||
*/
|
||||
void PDMA_SetTransferMode(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr)
|
||||
{
|
||||
u8ChSelect[u32Ch] = u32Peripheral;
|
||||
|
||||
switch (u32Ch)
|
||||
if (u32Ch < PDMA_CH_MAX)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC0_Msk) | u32Peripheral;
|
||||
break;
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk;
|
||||
|
||||
case 1ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC1_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC1_Pos);
|
||||
break;
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
pau32REQSEL[u32Ch / 4] = (pau32REQSEL[u32Ch / 4] & ~u32REQSEL_Msk) | (u32Peripheral << u32REQSEL_Pos);
|
||||
|
||||
case 2ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC2_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC2_Pos);
|
||||
break;
|
||||
|
||||
case 3ul:
|
||||
pdma->REQSEL0_3 = (pdma->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC3_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC3_Pos);
|
||||
break;
|
||||
|
||||
case 4ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC4_Msk) | u32Peripheral;
|
||||
break;
|
||||
|
||||
case 5ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC5_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC5_Pos);
|
||||
break;
|
||||
|
||||
case 6ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC6_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC6_Pos);
|
||||
break;
|
||||
|
||||
case 7ul:
|
||||
pdma->REQSEL4_7 = (pdma->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC7_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC7_Pos);
|
||||
break;
|
||||
|
||||
case 8ul:
|
||||
pdma->REQSEL8 = (pdma->REQSEL8 & ~PDMA_REQSEL8_REQSRC8_Msk) | u32Peripheral;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
if (u32ScatterEn)
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER;
|
||||
pdma->DSCT[u32Ch].NEXT = u32DescAddr - (pdma->SCATBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
pdma->DSCT[u32Ch].CTL = (pdma->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC;
|
||||
}
|
||||
}
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,6 +217,7 @@ void PDMA_SetBurstType(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32BurstType, uint
|
||||
* @brief Enable timeout function
|
||||
*
|
||||
* @param[in] pdma The pointer of the specified PDMA module
|
||||
*
|
||||
* @param[in] u32Mask Channel enable bits.
|
||||
*
|
||||
* @return None
|
||||
@@ -268,6 +233,7 @@ void PDMA_EnableTimeout(PDMA_T *pdma, uint32_t u32Mask)
|
||||
* @brief Disable timeout function
|
||||
*
|
||||
* @param[in] pdma The pointer of the specified PDMA module
|
||||
*
|
||||
* @param[in] u32Mask Channel enable bits.
|
||||
*
|
||||
* @return None
|
||||
@@ -294,24 +260,21 @@ void PDMA_DisableTimeout(PDMA_T *pdma, uint32_t u32Mask)
|
||||
*/
|
||||
void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u32TimeOutCnt)
|
||||
{
|
||||
switch (u32Ch)
|
||||
if (u32Ch < 2)
|
||||
{
|
||||
case 0ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC0_Msk) | u32TimeOutCnt;
|
||||
break;
|
||||
__IO uint32_t *pau32TOC = (__IO uint32_t *)&pdma->TOC0_1;
|
||||
uint32_t u32TOC_Pos, u32TOC_Msk;
|
||||
|
||||
case 1ul:
|
||||
pdma->TOC0_1 = (pdma->TOC0_1 & ~PDMA_TOC0_1_TOC1_Msk) | (u32TimeOutCnt << PDMA_TOC0_1_TOC1_Pos);
|
||||
break;
|
||||
u32TOC_Pos = (u32Ch % 2) * 16 ;
|
||||
u32TOC_Msk = PDMA_TOC0_1_TOC0_Msk << u32TOC_Pos;
|
||||
pau32TOC[u32Ch / 2] = (pau32TOC[u32Ch / 2] & ~u32TOC_Msk) | (u32TimeOutCnt << u32TOC_Pos);
|
||||
|
||||
default:
|
||||
break;
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1 << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1 << u32Ch);
|
||||
}
|
||||
|
||||
if (u32OnOff)
|
||||
pdma->TOUTEN |= (1ul << u32Ch);
|
||||
else
|
||||
pdma->TOUTEN &= ~(1ul << u32Ch);
|
||||
else {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,7 +289,15 @@ void PDMA_SetTimeOut(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32OnOff, uint32_t u
|
||||
*/
|
||||
void PDMA_Trigger(PDMA_T *pdma, uint32_t u32Ch)
|
||||
{
|
||||
if (u8ChSelect[u32Ch] == PDMA_MEM)
|
||||
__IO uint32_t *pau32REQSEL = (__IO uint32_t *)&pdma->REQSEL0_3;
|
||||
uint32_t u32REQSEL_Pos, u32REQSEL_Msk, u32ChReq;
|
||||
|
||||
u32REQSEL_Pos = (u32Ch % 4) * 8 ;
|
||||
u32REQSEL_Msk = PDMA_REQSEL0_3_REQSRC0_Msk << u32REQSEL_Pos;
|
||||
|
||||
u32ChReq = (pau32REQSEL[u32Ch / 4] & u32REQSEL_Msk) >> u32REQSEL_Pos;
|
||||
|
||||
if (u32ChReq == PDMA_MEM)
|
||||
{
|
||||
pdma->SWREQ = (1ul << u32Ch);
|
||||
}
|
||||
@@ -354,11 +325,9 @@ void PDMA_EnableInt(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Mask)
|
||||
case PDMA_INT_TRANS_DONE:
|
||||
pdma->INTEN |= (1ul << u32Ch);
|
||||
break;
|
||||
|
||||
case PDMA_INT_TEMPTY:
|
||||
pdma->DSCT[u32Ch].CTL &= ~PDMA_DSCT_CTL_TBINTDIS_Msk;
|
||||
break;
|
||||
|
||||
case PDMA_INT_TIMEOUT:
|
||||
pdma->TOUTIEN |= (1ul << u32Ch);
|
||||
break;
|
||||
@@ -389,11 +358,9 @@ void PDMA_DisableInt(PDMA_T *pdma, uint32_t u32Ch, uint32_t u32Mask)
|
||||
case PDMA_INT_TRANS_DONE:
|
||||
pdma->INTEN &= ~(1ul << u32Ch);
|
||||
break;
|
||||
|
||||
case PDMA_INT_TEMPTY:
|
||||
pdma->DSCT[u32Ch].CTL |= PDMA_DSCT_CTL_TBINTDIS_Msk;
|
||||
break;
|
||||
|
||||
case PDMA_INT_TIMEOUT:
|
||||
pdma->TOUTIEN &= ~(1ul << u32Ch);
|
||||
break;
|
||||
|
||||
@@ -188,7 +188,7 @@ static void nu_pdma_init(void)
|
||||
RT_ASSERT(g_mutex_sg != RT_NULL);
|
||||
|
||||
nu_pdma_chn_mask = ~NU_PDMA_CH_Msk;
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX*sizeof(nu_pdma_chn_t));
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX * sizeof(nu_pdma_chn_t));
|
||||
|
||||
NVIC_EnableIRQ(PDMA_IRQn);
|
||||
|
||||
@@ -598,11 +598,13 @@ static void nu_pdma_sgtbls_token_free(nu_pdma_desc_t psSgtbls)
|
||||
rt_err_t nu_pdma_sgtbls_allocate(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
{
|
||||
int i, j, idx;
|
||||
rt_err_t result;
|
||||
|
||||
RT_ASSERT(ppsSgtbls != NULL);
|
||||
RT_ASSERT(num <= NU_PDMA_SG_TBL_MAXSIZE);
|
||||
|
||||
rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -617,7 +619,8 @@ rt_err_t nu_pdma_sgtbls_allocate(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
ppsSgtbls[i] = (nu_pdma_desc_t)&nu_pdma_sgtbl_arr[idx];
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
return RT_EOK;
|
||||
|
||||
@@ -633,18 +636,22 @@ fail_nu_pdma_sgtbls_allocate:
|
||||
ppsSgtbls[j] = NULL;
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
void nu_pdma_sgtbls_free(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
{
|
||||
int i;
|
||||
rt_err_t result;
|
||||
|
||||
RT_ASSERT(ppsSgtbls != NULL);
|
||||
RT_ASSERT(num <= NU_PDMA_SG_TBL_MAXSIZE);
|
||||
|
||||
rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -655,7 +662,8 @@ void nu_pdma_sgtbls_free(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
ppsSgtbls[i] = NULL;
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
static rt_err_t nu_pdma_sgtbls_valid(nu_pdma_desc_t head)
|
||||
@@ -843,6 +851,7 @@ static void nu_pdma_memfun_actor_init(void)
|
||||
if (-(RT_ERROR) != (nu_pdma_memfun_actor_arr[i].m_i32ChannID = nu_pdma_channel_allocate(PDMA_MEM)))
|
||||
{
|
||||
nu_pdma_memfun_actor_arr[i].m_psSemMemFun = rt_sem_create("memactor_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_arr[i].m_psSemMemFun != RT_NULL);
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -851,16 +860,23 @@ static void nu_pdma_memfun_actor_init(void)
|
||||
{
|
||||
nu_pdma_memfun_actor_maxnum = i;
|
||||
nu_pdma_memfun_actor_mask = ~(((1 << i) - 1));
|
||||
|
||||
nu_pdma_memfun_actor_pool_sem = rt_sem_create("mempool_sem", nu_pdma_memfun_actor_maxnum, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_pool_sem != RT_NULL);
|
||||
|
||||
nu_pdma_memfun_actor_pool_lock = rt_mutex_create("mempool_lock", RT_IPC_FLAG_PRIO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_pool_lock != RT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void nu_pdma_memfun_cb(void *pvUserData, uint32_t u32Events)
|
||||
{
|
||||
rt_err_t result;
|
||||
nu_pdma_memfun_actor_t psMemFunActor = (nu_pdma_memfun_actor_t)pvUserData;
|
||||
|
||||
psMemFunActor->m_u32Result = u32Events;
|
||||
rt_sem_release(psMemFunActor->m_psSemMemFun);
|
||||
result = rt_sem_release(psMemFunActor->m_psSemMemFun);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
static int nu_pdma_memfun_employ(void)
|
||||
@@ -870,7 +886,10 @@ static int nu_pdma_memfun_employ(void)
|
||||
/* Headhunter */
|
||||
if (nu_pdma_memfun_actor_pool_sem && (rt_sem_take(nu_pdma_memfun_actor_pool_sem, RT_WAITING_FOREVER) == RT_EOK))
|
||||
{
|
||||
rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
rt_err_t result;
|
||||
result = rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Find the position of first '0' in nu_pdma_memfun_actor_mask. */
|
||||
idx = nu_cto(nu_pdma_memfun_actor_mask);
|
||||
if (idx != 32)
|
||||
@@ -881,7 +900,8 @@ static int nu_pdma_memfun_employ(void)
|
||||
{
|
||||
idx = -1;
|
||||
}
|
||||
rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
result = rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
return idx;
|
||||
@@ -897,6 +917,8 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
|
||||
while (1)
|
||||
{
|
||||
rt_err_t result;
|
||||
|
||||
/* Employ actor */
|
||||
if ((idx = nu_pdma_memfun_employ()) < 0)
|
||||
continue;
|
||||
@@ -925,7 +947,8 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
0);
|
||||
|
||||
/* Wait it done. */
|
||||
rt_sem_take(psMemFunActor->m_psSemMemFun, RT_WAITING_FOREVER);
|
||||
result = rt_sem_take(psMemFunActor->m_psSemMemFun, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Give result if get NU_PDMA_EVENT_TRANSFER_DONE.*/
|
||||
if (psMemFunActor->m_u32Result & NU_PDMA_EVENT_TRANSFER_DONE)
|
||||
@@ -945,16 +968,20 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
}
|
||||
|
||||
u32TransferCnt -= u32TxCnt;
|
||||
u32Offset += u32TxCnt;
|
||||
u32Offset += u32TxCnt * (u32DataWidth / 8);
|
||||
}
|
||||
while (u32TransferCnt > 0);
|
||||
|
||||
rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
nu_pdma_memfun_actor_mask &= ~(1 << idx);
|
||||
rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
result = rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Fire actor */
|
||||
rt_sem_release(nu_pdma_memfun_actor_pool_sem);
|
||||
result = rt_sem_release(nu_pdma_memfun_actor_pool_sem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -96,11 +96,13 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
uint32_t u32SPIMode;
|
||||
uint32_t u32BusClock;
|
||||
rt_err_t ret = RT_EOK;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(configuration != RT_NULL);
|
||||
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
/* Check mode */
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
@@ -150,12 +152,29 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
/* Set CS pin to LOW */
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration->mode & RT_SPI_MSB)
|
||||
@@ -514,6 +533,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
struct nu_spi *spi_bus;
|
||||
struct rt_spi_configuration *configuration;
|
||||
uint8_t bytes_per_word;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
@@ -522,6 +542,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
configuration = (struct rt_spi_configuration *)&spi_bus->configuration;
|
||||
bytes_per_word = configuration->data_width / 8;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
if ((message->length % bytes_per_word) != 0)
|
||||
{
|
||||
@@ -534,13 +555,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
{
|
||||
if (message->cs_take && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,13 +585,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
|
||||
if (message->cs_release && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -214,7 +214,7 @@ static void nu_pdma_init(void)
|
||||
RT_ASSERT(g_mutex_sg != RT_NULL);
|
||||
|
||||
nu_pdma_chn_mask = ~(NU_PDMA_CH_Msk);
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX*sizeof(nu_pdma_chn_t));
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX * sizeof(nu_pdma_chn_t));
|
||||
|
||||
/* Initialize PDMA0 setting */
|
||||
PDMA_Open(PDMA0, NU_PDMA_CH_HALF_Msk);
|
||||
@@ -609,11 +609,13 @@ static void nu_pdma_sgtbls_token_free(nu_pdma_desc_t psSgtbls)
|
||||
rt_err_t nu_pdma_sgtbls_allocate(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
{
|
||||
int i, j, idx;
|
||||
rt_err_t result;
|
||||
|
||||
RT_ASSERT(ppsSgtbls != NULL);
|
||||
RT_ASSERT(num <= NU_PDMA_SG_TBL_MAXSIZE);
|
||||
|
||||
rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -628,7 +630,8 @@ rt_err_t nu_pdma_sgtbls_allocate(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
ppsSgtbls[i] = (nu_pdma_desc_t)&nu_pdma_sgtbl_arr[idx];
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
return RT_EOK;
|
||||
|
||||
@@ -644,18 +647,22 @@ fail_nu_pdma_sgtbls_allocate:
|
||||
ppsSgtbls[j] = NULL;
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
void nu_pdma_sgtbls_free(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
{
|
||||
int i;
|
||||
rt_err_t result;
|
||||
|
||||
RT_ASSERT(ppsSgtbls != NULL);
|
||||
RT_ASSERT(num <= NU_PDMA_SG_TBL_MAXSIZE);
|
||||
|
||||
rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(g_mutex_sg, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
@@ -666,7 +673,8 @@ void nu_pdma_sgtbls_free(nu_pdma_desc_t *ppsSgtbls, int num)
|
||||
ppsSgtbls[i] = NULL;
|
||||
}
|
||||
|
||||
rt_mutex_release(g_mutex_sg);
|
||||
result = rt_mutex_release(g_mutex_sg);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
static rt_err_t nu_pdma_sgtbls_valid(nu_pdma_desc_t head)
|
||||
@@ -881,6 +889,7 @@ static void nu_pdma_memfun_actor_init(void)
|
||||
if (-(RT_ERROR) != (nu_pdma_memfun_actor_arr[i].m_i32ChannID = nu_pdma_channel_allocate(PDMA_MEM)))
|
||||
{
|
||||
nu_pdma_memfun_actor_arr[i].m_psSemMemFun = rt_sem_create("memactor_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_arr[i].m_psSemMemFun != RT_NULL);
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -889,16 +898,23 @@ static void nu_pdma_memfun_actor_init(void)
|
||||
{
|
||||
nu_pdma_memfun_actor_maxnum = i;
|
||||
nu_pdma_memfun_actor_mask = ~(((1 << i) - 1));
|
||||
|
||||
nu_pdma_memfun_actor_pool_sem = rt_sem_create("mempool_sem", nu_pdma_memfun_actor_maxnum, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_pool_sem != RT_NULL);
|
||||
|
||||
nu_pdma_memfun_actor_pool_lock = rt_mutex_create("mempool_lock", RT_IPC_FLAG_PRIO);
|
||||
RT_ASSERT(nu_pdma_memfun_actor_pool_lock != RT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void nu_pdma_memfun_cb(void *pvUserData, uint32_t u32Events)
|
||||
{
|
||||
rt_err_t result;
|
||||
nu_pdma_memfun_actor_t psMemFunActor = (nu_pdma_memfun_actor_t)pvUserData;
|
||||
|
||||
psMemFunActor->m_u32Result = u32Events;
|
||||
rt_sem_release(psMemFunActor->m_psSemMemFun);
|
||||
result = rt_sem_release(psMemFunActor->m_psSemMemFun);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
static int nu_pdma_memfun_employ(void)
|
||||
@@ -908,7 +924,10 @@ static int nu_pdma_memfun_employ(void)
|
||||
/* Headhunter */
|
||||
if (nu_pdma_memfun_actor_pool_sem && (rt_sem_take(nu_pdma_memfun_actor_pool_sem, RT_WAITING_FOREVER) == RT_EOK))
|
||||
{
|
||||
rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
rt_err_t result;
|
||||
result = rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Find the position of first '0' in nu_pdma_memfun_actor_mask. */
|
||||
idx = nu_cto(nu_pdma_memfun_actor_mask);
|
||||
if (idx != 32)
|
||||
@@ -919,7 +938,8 @@ static int nu_pdma_memfun_employ(void)
|
||||
{
|
||||
idx = -1;
|
||||
}
|
||||
rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
result = rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
}
|
||||
|
||||
return idx;
|
||||
@@ -935,6 +955,8 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
|
||||
while (1)
|
||||
{
|
||||
rt_err_t result;
|
||||
|
||||
/* Employ actor */
|
||||
if ((idx = nu_pdma_memfun_employ()) < 0)
|
||||
continue;
|
||||
@@ -963,7 +985,8 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
0);
|
||||
|
||||
/* Wait it done. */
|
||||
rt_sem_take(psMemFunActor->m_psSemMemFun, RT_WAITING_FOREVER);
|
||||
result = rt_sem_take(psMemFunActor->m_psSemMemFun, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Give result if get NU_PDMA_EVENT_TRANSFER_DONE.*/
|
||||
if (psMemFunActor->m_u32Result & NU_PDMA_EVENT_TRANSFER_DONE)
|
||||
@@ -983,16 +1006,20 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
}
|
||||
|
||||
u32TransferCnt -= u32TxCnt;
|
||||
u32Offset += u32TxCnt;
|
||||
u32Offset += u32TxCnt * (u32DataWidth / 8);
|
||||
}
|
||||
while (u32TransferCnt > 0);
|
||||
|
||||
rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
result = rt_mutex_take(nu_pdma_memfun_actor_pool_lock, RT_WAITING_FOREVER);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
nu_pdma_memfun_actor_mask &= ~(1 << idx);
|
||||
rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
result = rt_mutex_release(nu_pdma_memfun_actor_pool_lock);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
/* Fire actor */
|
||||
rt_sem_release(nu_pdma_memfun_actor_pool_sem);
|
||||
result = rt_sem_release(nu_pdma_memfun_actor_pool_sem);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -156,11 +156,13 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
uint32_t u32SPIMode;
|
||||
uint32_t u32BusClock;
|
||||
rt_err_t ret = RT_EOK;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(configuration != RT_NULL);
|
||||
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
/* Check mode */
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
@@ -210,12 +212,29 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
/* Set CS pin to LOW */
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration->mode & RT_SPI_MSB)
|
||||
@@ -574,6 +593,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
struct nu_spi *spi_bus;
|
||||
struct rt_spi_configuration *configuration;
|
||||
uint8_t bytes_per_word;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
@@ -582,6 +602,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
configuration = (struct rt_spi_configuration *)&spi_bus->configuration;
|
||||
bytes_per_word = configuration->data_width / 8;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
if ((message->length % bytes_per_word) != 0)
|
||||
{
|
||||
@@ -594,13 +615,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
{
|
||||
if (message->cs_take && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,13 +645,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
|
||||
if (message->cs_release && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -124,7 +124,7 @@ static void *nu_emac_memcpy(void *dest, void *src, unsigned int count)
|
||||
if (count >= NU_EMAC_PDMA_MEMCOPY_THRESHOLD)
|
||||
return nu_pdma_memcpy(dest, src, count);
|
||||
#endif
|
||||
return memcpy(dest, src, count);
|
||||
return rt_memcpy(dest, src, count);
|
||||
}
|
||||
|
||||
static void nu_emac_reinit(void)
|
||||
|
||||
@@ -215,7 +215,7 @@ static void nu_pdma_init(void)
|
||||
RT_ASSERT(g_mutex_sg != RT_NULL);
|
||||
|
||||
nu_pdma_chn_mask = ~NU_PDMA_CH_Msk;
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX*sizeof(nu_pdma_chn_t));
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX * sizeof(nu_pdma_chn_t));
|
||||
|
||||
NVIC_EnableIRQ(PDMA_IRQn);
|
||||
|
||||
@@ -998,7 +998,7 @@ static rt_size_t nu_pdma_memfun(void *dest, void *src, uint32_t u32DataWidth, un
|
||||
}
|
||||
|
||||
u32TransferCnt -= u32TxCnt;
|
||||
u32Offset += u32TxCnt;
|
||||
u32Offset += u32TxCnt * (u32DataWidth / 8);
|
||||
}
|
||||
while (u32TransferCnt > 0);
|
||||
|
||||
|
||||
@@ -156,11 +156,13 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
uint32_t u32SPIMode;
|
||||
uint32_t u32BusClock;
|
||||
rt_err_t ret = RT_EOK;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(configuration != RT_NULL);
|
||||
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
/* Check mode */
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
@@ -210,12 +212,29 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
/* Set CS pin to LOW */
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration->mode & RT_SPI_MSB)
|
||||
@@ -574,6 +593,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
struct nu_spi *spi_bus;
|
||||
struct rt_spi_configuration *configuration;
|
||||
uint8_t bytes_per_word;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
@@ -582,6 +602,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
configuration = (struct rt_spi_configuration *)&spi_bus->configuration;
|
||||
bytes_per_word = configuration->data_width / 8;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
if ((message->length % bytes_per_word) != 0)
|
||||
{
|
||||
@@ -594,13 +615,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
{
|
||||
if (message->cs_take && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,13 +645,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
|
||||
if (message->cs_release && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,6 +21,7 @@
|
||||
|
||||
/* Private define ---------------------------------------------------------------*/
|
||||
#define DEF_ADC_TOUCH_SMPL_TICK 40
|
||||
#define TOUCH_MQ_LENGTH 64
|
||||
|
||||
/* Private Typedef --------------------------------------------------------------*/
|
||||
struct nu_adc
|
||||
|
||||
@@ -15,14 +15,11 @@
|
||||
|
||||
#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
|
||||
@@ -57,28 +54,10 @@ typedef struct
|
||||
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);
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect);
|
||||
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);
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_ADC_H__ */
|
||||
|
||||
@@ -153,7 +153,7 @@ static void nu_emac_halt(nu_emac_t psNuEmac)
|
||||
|
||||
static void *nu_emac_memcpy(void *dest, void *src, unsigned int count)
|
||||
{
|
||||
return memcpy(dest, src, count);
|
||||
return rt_memcpy(dest, src, count);
|
||||
}
|
||||
|
||||
static void nu_emac_reinit(nu_emac_t psNuEmac)
|
||||
|
||||
@@ -342,6 +342,7 @@ int rt_hw_vpost_init(void)
|
||||
else
|
||||
{
|
||||
uint32_t u32FBSize = psVpost->info.pitch * psVpostLcmInst->u32DevHeight;
|
||||
psVpost->info.smem_len = u32FBSize * DEF_VPOST_BUFFER_NUMBER;
|
||||
rt_memset(psVpost->info.framebuffer, 0, u32FBSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# RT-Thread building script for component
|
||||
Import('RTT_ROOT')
|
||||
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
group = []
|
||||
if GetDepend('NU_PKG_USING_ADC_TOUCH'):
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
group = DefineGroup('nu_pkgs_adc_touch', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
+95
-40
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-21 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __ADC_TOUCH_CALIBRATE_H__
|
||||
#define __ADC_TOUCH_CALIBRATE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEF_CAL_POINT_NUM 5
|
||||
|
||||
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;
|
||||
|
||||
#endif /* __ADC_TOUCH_CALIBRATE_H__ */
|
||||
@@ -0,0 +1,195 @@
|
||||
/**************************************************************************//**
|
||||
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-02-22 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
|
||||
#include "rtdevice.h"
|
||||
#include "touch.h"
|
||||
#include "touch_sw.h"
|
||||
|
||||
/* Private define ---------------------------------------------------------------*/
|
||||
#define DEF_ADC_TOUCH_SMPL_TICK 40
|
||||
#define TOUCH_MQ_LENGTH 32
|
||||
|
||||
/* Private Typedef --------------------------------------------------------------*/
|
||||
static rt_timer_t g_psRtTouchMenuTimer;
|
||||
static rt_mq_t g_pmqTouchXYZ;
|
||||
|
||||
static S_TOUCH_SW *g_psTouchSW = RT_NULL;
|
||||
static rt_bool_t bDoSmpling = RT_FALSE;
|
||||
|
||||
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;
|
||||
|
||||
static rt_uint32_t Get_X(S_TOUCH_SW *psTouchSW)
|
||||
{
|
||||
/*=== Get X from ADC input ===*/
|
||||
rt_pin_mode(psTouchSW->pin[evXR], PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(psTouchSW->pin[evYD], PIN_MODE_INPUT);
|
||||
rt_pin_mode(psTouchSW->pin[evXL], PIN_MODE_OUTPUT);
|
||||
|
||||
rt_pin_write(psTouchSW->pin[evXR], PIN_HIGH);
|
||||
rt_pin_write(psTouchSW->pin[evXL], PIN_LOW);
|
||||
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evXR]);
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evYD]);
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evXL]);
|
||||
|
||||
/* Disable the digital input path to avoid the leakage current. */
|
||||
/* Configure the ADC analog input pins. */
|
||||
psTouchSW->switch_to_analog(psTouchSW->pin[evYU]);
|
||||
|
||||
return rt_adc_read((rt_adc_device_t)psTouchSW->adc, psTouchSW->i32ADCChnYU) & 0x0FFF;
|
||||
}
|
||||
|
||||
static rt_uint32_t Get_Y(S_TOUCH_SW *psTouchSW)
|
||||
{
|
||||
/*=== Get Y from ADC input ===*/
|
||||
rt_pin_mode(psTouchSW->pin[evYU], PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(psTouchSW->pin[evYD], PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(psTouchSW->pin[evXL], PIN_MODE_INPUT);
|
||||
|
||||
rt_pin_write(psTouchSW->pin[evYU], PIN_HIGH);
|
||||
rt_pin_write(psTouchSW->pin[evYD], PIN_LOW);
|
||||
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evYU]);
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evYD]);
|
||||
psTouchSW->switch_to_digital(psTouchSW->pin[evXL]);
|
||||
|
||||
/* Disable the digital input path to avoid the leakage current. */
|
||||
/* Configure the ADC analog input pins. */
|
||||
psTouchSW->switch_to_analog(psTouchSW->pin[evXR]);
|
||||
|
||||
return rt_adc_read((rt_adc_device_t)psTouchSW->adc, psTouchSW->i32ADCChnXR) & 0x0FFF;
|
||||
}
|
||||
|
||||
static void nu_adc_touch_smpl(void *p)
|
||||
{
|
||||
static rt_bool_t bDrop = RT_FALSE;
|
||||
static uint32_t u32LastZ0 = 0xffffu;
|
||||
|
||||
struct nu_adc_touch_data point;
|
||||
S_TOUCH_SW *psTouchSW;
|
||||
|
||||
if (!bDoSmpling)
|
||||
return ;
|
||||
|
||||
psTouchSW = (S_TOUCH_SW *)p;
|
||||
|
||||
rt_memset(&point, 0, sizeof(struct nu_adc_touch_data));
|
||||
|
||||
/* Get X, Y ADC converting data */
|
||||
point.u32X = Get_X(psTouchSW);
|
||||
point.u32Y = Get_Y(psTouchSW);
|
||||
if ((point.u32X < 4000) && (point.u32Y < 4000))
|
||||
{
|
||||
point.u32Z0 = point.u32Z1 = 1;
|
||||
bDrop = RT_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bDrop = RT_TRUE;
|
||||
}
|
||||
|
||||
// rt_kprintf("%04x %04x %d %d\n", point.u32X, point.u32Y, point.u32Z0, bDrop);
|
||||
if ((!bDrop || (u32LastZ0 != 0)) && (rt_mq_send(g_pmqTouchXYZ, (const void *)&point, sizeof(struct nu_adc_touch_data)) == RT_EOK))
|
||||
{
|
||||
if (psTouchSW->psRtTouch != RT_NULL)
|
||||
rt_hw_touch_isr(psTouchSW->psRtTouch);
|
||||
}
|
||||
u32LastZ0 = point.u32Z0;
|
||||
}
|
||||
|
||||
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_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_detect(rt_bool_t bStartDetect)
|
||||
{
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_enable(rt_touch_t psRtTouch)
|
||||
{
|
||||
if (g_psTouchSW->adc)
|
||||
{
|
||||
g_psTouchSW->psRtTouch = psRtTouch;
|
||||
|
||||
rt_adc_enable((rt_adc_device_t)g_psTouchSW->adc, g_psTouchSW->i32ADCChnXR);
|
||||
rt_adc_enable((rt_adc_device_t)g_psTouchSW->adc, g_psTouchSW->i32ADCChnYU);
|
||||
bDoSmpling = RT_TRUE;
|
||||
|
||||
/* Start sampling procedure. */
|
||||
rt_timer_start(g_psRtTouchMenuTimer);
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_disable(void)
|
||||
{
|
||||
if (g_psTouchSW->adc)
|
||||
{
|
||||
/* Stop sampling procedure. */
|
||||
rt_timer_stop(g_psRtTouchMenuTimer);
|
||||
|
||||
bDoSmpling = RT_FALSE;
|
||||
rt_adc_disable((rt_adc_device_t)g_psTouchSW->adc, g_psTouchSW->i32ADCChnXR);
|
||||
rt_adc_disable((rt_adc_device_t)g_psTouchSW->adc, g_psTouchSW->i32ADCChnYU);
|
||||
g_psTouchSW->psRtTouch = RT_NULL;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
rt_err_t nu_adc_touch_sw_register(S_TOUCH_SW *psTouchSW)
|
||||
{
|
||||
RT_ASSERT(psTouchSW);
|
||||
|
||||
psTouchSW->adc = rt_device_find(psTouchSW->adc_name);
|
||||
RT_ASSERT(psTouchSW->adc);
|
||||
|
||||
g_pmqTouchXYZ = rt_mq_create("ADC_TOUCH_SW", sizeof(struct nu_adc_touch_data), TOUCH_MQ_LENGTH, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(g_pmqTouchXYZ);
|
||||
|
||||
g_psRtTouchMenuTimer = rt_timer_create("TOUCH_SMPL_TIMER", nu_adc_touch_smpl, (void *)psTouchSW, DEF_ADC_TOUCH_SMPL_TICK, RT_TIMER_FLAG_PERIODIC);
|
||||
RT_ASSERT(g_psRtTouchMenuTimer);
|
||||
|
||||
g_psTouchSW = psTouchSW;
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif //#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
@@ -0,0 +1,43 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-21 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __TOUCH_SW_H__
|
||||
#define __TOUCH_SW_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "touch.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
evXL, //X-
|
||||
evYU, //Y-
|
||||
evXR, //X+
|
||||
evYD, //Y+
|
||||
evTOUCH_PIN_CNT
|
||||
} E_TOUCH_PIN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *adc_name;
|
||||
rt_device_t adc;
|
||||
int i32ADCChnYU;
|
||||
int i32ADCChnXR;
|
||||
rt_touch_t psRtTouch;
|
||||
|
||||
rt_base_t pin[evTOUCH_PIN_CNT];
|
||||
void (*switch_to_analog)(rt_base_t pin);
|
||||
void (*switch_to_digital)(rt_base_t pin);
|
||||
} S_TOUCH_SW;
|
||||
|
||||
rt_err_t nu_adc_touch_sw_register(S_TOUCH_SW *psTouchSW);
|
||||
|
||||
#endif /* __TOUCH_SW_H__ */
|
||||
@@ -15,6 +15,7 @@
|
||||
#if defined(NU_PKG_USING_ILI9341_EBI)
|
||||
|
||||
#include <lcd_ili9341.h>
|
||||
#include "drv_pdma.h"
|
||||
|
||||
#define ILI9341_ADDR_CMD 0x0
|
||||
#define ILI9341_ADDR_DATA 0x0030000
|
||||
@@ -44,11 +45,22 @@ void ili9341_send_pixel_data(rt_uint16_t color)
|
||||
|
||||
void ili9341_send_pixels(rt_uint16_t *pixels, int len)
|
||||
{
|
||||
int i = 0;
|
||||
int size = len / sizeof(rt_uint16_t);
|
||||
|
||||
while (i < size)
|
||||
ili9341_write_data(pixels[i]);
|
||||
int count = len / sizeof(rt_uint16_t);
|
||||
if (count < 1024)
|
||||
{
|
||||
// CPU feed
|
||||
int i = 0;
|
||||
while (i < count)
|
||||
{
|
||||
ili9341_write_data(pixels[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// PDMA-M2M feed
|
||||
nu_pdma_mempush((void *)(g_uint32_ili9341_base + (ILI9341_ADDR_DATA)), (void *)pixels, 16, count);
|
||||
}
|
||||
}
|
||||
|
||||
void ili9341_set_column(uint16_t StartCol, uint16_t EndCol)
|
||||
|
||||
@@ -17,12 +17,16 @@
|
||||
#include <rtdevice.h>
|
||||
#include <lcd_ili9341.h>
|
||||
|
||||
#if !defined(NU_PKG_USING_ILI9341_SPI_CLK_FREQ)
|
||||
#define NU_PKG_USING_ILI9341_SPI_CLK_FREQ 48000000
|
||||
#endif
|
||||
|
||||
static struct rt_spi_device ili9341_spi_device;
|
||||
static struct rt_spi_configuration ili9341_cfg =
|
||||
{
|
||||
.mode = RT_SPI_MODE_0 | RT_SPI_MSB,
|
||||
.data_width = 8,
|
||||
.max_hz = 48000000,
|
||||
.max_hz = NU_PKG_USING_ILI9341_SPI_CLK_FREQ,
|
||||
};
|
||||
|
||||
static void ili9341_change_datawidth(int data_width)
|
||||
@@ -190,11 +194,19 @@ void ili9341_lcd_get_pixel(char *color, int x, int y)
|
||||
*(rt_uint16_t *)color = ((bgrx.S.r >> 3) << 11) | ((bgrx.S.g >> 2) << 5) | (bgrx.S.b >> 3);
|
||||
}
|
||||
|
||||
rt_err_t rt_hw_lcd_ili9341_spi_init(const char *spibusname)
|
||||
rt_err_t rt_hw_lcd_ili9341_spi_init(const char *spibusname, void *pvUserData)
|
||||
{
|
||||
if (rt_spi_bus_attach_device(&ili9341_spi_device, "lcd_ili9341", spibusname, RT_NULL) != RT_EOK)
|
||||
if (rt_spi_bus_attach_device(&ili9341_spi_device, "lcd_ili9341", spibusname, pvUserData) != RT_EOK)
|
||||
return -RT_ERROR;
|
||||
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// GPIO CS pin mode to output */
|
||||
rt_pin_mode(*((rt_base_t *)pvUserData), PIN_MODE_OUTPUT);
|
||||
}
|
||||
|
||||
rt_kprintf("Preferred ili9341 spi clock frequency is %d Hz.\n", NU_PKG_USING_ILI9341_SPI_CLK_FREQ);
|
||||
|
||||
return rt_spi_configure(&ili9341_spi_device, &ili9341_cfg);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,14 @@
|
||||
#include <rtdevice.h>
|
||||
#include <lcd_ili9341.h>
|
||||
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
#if !defined(NU_PKG_ILI9341_LINE_BUFFER_NUMBER)
|
||||
#define NU_PKG_ILI9341_LINE_BUFFER_NUMBER YSIZE_PHYS
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ili9341_delay_ms(ms) rt_thread_mdelay(ms)
|
||||
|
||||
static struct rt_device_graphic_info g_Ili9341Info =
|
||||
{
|
||||
.bits_per_pixel = 16,
|
||||
@@ -27,11 +35,6 @@ static struct rt_device_graphic_info g_Ili9341Info =
|
||||
.height = YSIZE_PHYS
|
||||
};
|
||||
|
||||
static void ili9341_delay_ms(rt_uint32_t nms)
|
||||
{
|
||||
rt_thread_mdelay(nms);
|
||||
}
|
||||
|
||||
static rt_err_t ili9341_pin_init(void)
|
||||
{
|
||||
rt_pin_mode(BOARD_USING_ILI9341_PIN_DC, PIN_MODE_OUTPUT);
|
||||
@@ -185,15 +188,28 @@ static void ili9341_fillrect(uint16_t *pixels, struct rt_device_rect_info *pRect
|
||||
static void ili9341_fillscreen(rt_uint16_t color)
|
||||
{
|
||||
#if defined(NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER)
|
||||
struct rt_device_rect_info rectinfo = { 0, 0, XSIZE_PHYS, YSIZE_PHYS };
|
||||
int pixel_count = XSIZE_PHYS * YSIZE_PHYS;
|
||||
rt_uint16_t *pu16ShadowBuf = (rt_uint16_t *)g_Ili9341Info.framebuffer;
|
||||
struct rt_device_rect_info rectinfo;
|
||||
int filled_line_num = 0;
|
||||
|
||||
while (pixel_count--)
|
||||
while (filled_line_num < YSIZE_PHYS)
|
||||
{
|
||||
*pu16ShadowBuf++ = color;
|
||||
int pixel_count;
|
||||
rectinfo.x = 0;
|
||||
rectinfo.y = filled_line_num;
|
||||
rectinfo.width = XSIZE_PHYS;
|
||||
rectinfo.height = (NU_PKG_ILI9341_LINE_BUFFER_NUMBER < YSIZE_PHYS) ? NU_PKG_ILI9341_LINE_BUFFER_NUMBER : YSIZE_PHYS;
|
||||
|
||||
pixel_count = XSIZE_PHYS * NU_PKG_ILI9341_LINE_BUFFER_NUMBER;
|
||||
rt_uint16_t *pu16ShadowBuf = (rt_uint16_t *)g_Ili9341Info.framebuffer;
|
||||
|
||||
while (pixel_count > 0)
|
||||
{
|
||||
*pu16ShadowBuf++ = color;
|
||||
pixel_count--;
|
||||
}
|
||||
ili9341_fillrect((uint16_t *)g_Ili9341Info.framebuffer, &rectinfo);
|
||||
filled_line_num += NU_PKG_ILI9341_LINE_BUFFER_NUMBER;
|
||||
}
|
||||
ili9341_fillrect((uint16_t *)g_Ili9341Info.framebuffer, &rectinfo);
|
||||
#else
|
||||
ili9341_set_column(0, (XSIZE_PHYS - 1));
|
||||
ili9341_set_page(0, (YSIZE_PHYS - 1));
|
||||
@@ -282,7 +298,7 @@ static rt_err_t ili9341_lcd_control(rt_device_t dev, int cmd, void *args)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
@@ -314,8 +330,9 @@ 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((g_Ili9341Info.pitch * g_Ili9341Info.height) + 32, 32);
|
||||
g_Ili9341Info.framebuffer = rt_malloc_align((g_Ili9341Info.pitch * NU_PKG_ILI9341_LINE_BUFFER_NUMBER) + 32, 32);
|
||||
RT_ASSERT(g_Ili9341Info.framebuffer != RT_NULL);
|
||||
g_Ili9341Info.smem_len = g_Ili9341Info.pitch * NU_PKG_ILI9341_LINE_BUFFER_NUMBER;
|
||||
#endif
|
||||
|
||||
/* register graphic device driver */
|
||||
|
||||
@@ -46,7 +46,7 @@ void ili9341_lcd_get_pixel(char *color, int x, int y);
|
||||
void ili9341_send_pixels(rt_uint16_t *pixels, int len);
|
||||
|
||||
#if defined(NU_PKG_USING_ILI9341_SPI)
|
||||
rt_err_t rt_hw_lcd_ili9341_spi_init(const char *spibusname);
|
||||
rt_err_t rt_hw_lcd_ili9341_spi_init(const char *spibusname, void *pvUserData);
|
||||
#elif defined(NU_PKG_USING_ILI9341_EBI)
|
||||
rt_err_t rt_hw_lcd_ili9341_ebi_init(rt_uint32_t ebi_base);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
from building import *
|
||||
Import('rtconfig')
|
||||
|
||||
src = []
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
src += Glob('*.c')
|
||||
path = [cwd]
|
||||
|
||||
# add src and include to group.
|
||||
group = DefineGroup('nu_pkgs_ili_tpc', src, depend = ['NU_PKG_USING_ILI_TPC'], CPPPATH = path)
|
||||
|
||||
Return('group')
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-02-25 Wayne the first version
|
||||
*/
|
||||
|
||||
#ifndef __ILI_H__
|
||||
#define __ILI_H__
|
||||
|
||||
#include "touch.h"
|
||||
|
||||
int rt_hw_ili_tpc_init(const char *name, struct rt_touch_config *cfg);
|
||||
|
||||
#endif /* ili2130.h */
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2018, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-02-25 Wayne the first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "ili.h"
|
||||
|
||||
#define THREAD_PRIORITY 5
|
||||
#define THREAD_STACK_SIZE 2048
|
||||
#define THREAD_TIMESLICE 5
|
||||
|
||||
static rt_sem_t tpc_sem = RT_NULL;
|
||||
|
||||
RT_WEAK void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
|
||||
{
|
||||
rt_kprintf("[%d] %d %d\n", state, x, y);
|
||||
}
|
||||
|
||||
static rt_err_t rx_callback(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
return rt_sem_release(tpc_sem);
|
||||
}
|
||||
|
||||
static void tpc_entry(void *parameter)
|
||||
{
|
||||
struct rt_touch_data *read_data;
|
||||
struct rt_touch_info info;
|
||||
rt_device_t dev = RT_NULL;
|
||||
|
||||
const char *name = "ili_tpc";
|
||||
rt_uint32_t x_range = BSP_LCD_WIDTH;
|
||||
rt_uint32_t y_range = BSP_LCD_HEIGHT;
|
||||
|
||||
dev = rt_device_find(name);
|
||||
if (dev == RT_NULL)
|
||||
{
|
||||
rt_kprintf("can't find device:%s\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rt_device_open(dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK)
|
||||
{
|
||||
rt_kprintf("open device failed!");
|
||||
return;
|
||||
}
|
||||
rt_kprintf("[%s] x: %d, y: %d\n", __func__, x_range, y_range);
|
||||
|
||||
rt_device_control(dev, RT_TOUCH_CTRL_SET_X_RANGE, &x_range); /* if possible you can set your x y coordinate*/
|
||||
rt_device_control(dev, RT_TOUCH_CTRL_SET_Y_RANGE, &y_range);
|
||||
|
||||
tpc_sem = rt_sem_create("dsem", 0, RT_IPC_FLAG_FIFO);
|
||||
if (tpc_sem == RT_NULL)
|
||||
{
|
||||
rt_kprintf("create dynamic semaphore failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
rt_device_set_rx_indicate(dev, rx_callback);
|
||||
|
||||
rt_device_control(dev, RT_TOUCH_CTRL_GET_INFO, &info);
|
||||
rt_kprintf("range_x = %d \n", info.range_x);
|
||||
rt_kprintf("range_y = %d \n", info.range_y);
|
||||
rt_kprintf("point_num = %d \n", info.point_num);
|
||||
|
||||
read_data = (struct rt_touch_data *)rt_malloc(sizeof(struct rt_touch_data) * info.point_num);
|
||||
RT_ASSERT(read_data);
|
||||
|
||||
rt_memset(read_data, 0, sizeof(struct rt_touch_data) * info.point_num);
|
||||
|
||||
while (1)
|
||||
{
|
||||
rt_sem_take(tpc_sem, RT_WAITING_FOREVER);
|
||||
rt_device_control(dev, RT_TOUCH_CTRL_DISABLE_INT, RT_NULL);
|
||||
|
||||
if (rt_device_read(dev, 0, read_data, info.point_num) == info.point_num)
|
||||
{
|
||||
for (rt_uint8_t i = 0; i < 1; i++) // Only report one point.
|
||||
{
|
||||
if (read_data[i].event == RT_TOUCH_EVENT_DOWN
|
||||
|| read_data[i].event == RT_TOUCH_EVENT_UP
|
||||
|| read_data[i].event == RT_TOUCH_EVENT_MOVE)
|
||||
{
|
||||
//rt_kprintf("[%d] %d %d\n", read_data[i].event, read_data[i].x_coordinate, read_data[i].y_coordinate);
|
||||
|
||||
nu_touch_inputevent_cb(read_data[i].x_coordinate, read_data[i].y_coordinate, read_data[i].event);
|
||||
}
|
||||
}
|
||||
}
|
||||
rt_device_control(dev, RT_TOUCH_CTRL_ENABLE_INT, RT_NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Test function */
|
||||
int tpc_sample(void)
|
||||
{
|
||||
rt_thread_t tpc_thread;
|
||||
tpc_thread = rt_thread_create("tpc",
|
||||
tpc_entry,
|
||||
RT_NULL,
|
||||
THREAD_STACK_SIZE,
|
||||
THREAD_PRIORITY,
|
||||
THREAD_TIMESLICE);
|
||||
|
||||
if (tpc_thread != RT_NULL)
|
||||
rt_thread_startup(tpc_thread);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(tpc_sample);
|
||||
@@ -57,14 +57,28 @@ menu "Nuvoton Packages Config"
|
||||
Choose this option if you the ili9341 device is with EBI interface.
|
||||
endchoice
|
||||
|
||||
if NU_PKG_USING_ILI9341_SPI
|
||||
config NU_PKG_USING_ILI9341_SPI_CLK_FREQ
|
||||
int "Set SPI Clock frequency"
|
||||
default 48000000
|
||||
endif
|
||||
|
||||
config NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
bool "Create an offscreen framebuffer."
|
||||
default n
|
||||
|
||||
if NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
config NU_PKG_ILI9341_LINE_BUFFER_NUMBER
|
||||
int "Allocate Line buffer number."
|
||||
range 1 240
|
||||
default 240
|
||||
endif
|
||||
|
||||
config NU_PKG_ILI9341_HORIZONTAL
|
||||
bool
|
||||
default y
|
||||
|
||||
|
||||
config BSP_LCD_BPP
|
||||
int
|
||||
default 16 if NU_PKG_USING_ILI9341
|
||||
@@ -79,6 +93,67 @@ menu "Nuvoton Packages Config"
|
||||
|
||||
endif
|
||||
|
||||
|
||||
config NU_PKG_USING_SSD1963
|
||||
bool "SSD1963 LCD Panel"
|
||||
select BSP_USING_GPIO
|
||||
default n
|
||||
|
||||
if NU_PKG_USING_SSD1963
|
||||
|
||||
choice
|
||||
prompt "Select SSD1963 interface"
|
||||
|
||||
config NU_PKG_USING_SSD1963_EBI
|
||||
select BSP_USING_EBI
|
||||
bool "SSD1963_EBI"
|
||||
help
|
||||
Choose this option if you the SSD1963 device is with EBI interface.
|
||||
endchoice
|
||||
|
||||
config NU_PKG_SSD1963_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
bool "Create an offscreen framebuffer."
|
||||
default n
|
||||
|
||||
if NU_PKG_SSD1963_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
config NU_PKG_SSD1963_LINE_BUFFER_NUMBER
|
||||
int "Allocate Line buffer number."
|
||||
range 16 272
|
||||
default 272
|
||||
endif
|
||||
|
||||
config BSP_LCD_BPP
|
||||
int
|
||||
default 16 if NU_PKG_USING_SSD1963
|
||||
|
||||
config BSP_LCD_WIDTH
|
||||
int
|
||||
default 480 if NU_PKG_USING_SSD1963
|
||||
|
||||
config BSP_LCD_HEIGHT
|
||||
int
|
||||
default 272 if NU_PKG_USING_SSD1963
|
||||
|
||||
endif
|
||||
|
||||
config NU_PKG_USING_ILI_TPC
|
||||
bool "ILI Series TPC"
|
||||
select RT_USING_TOUCH
|
||||
select RT_USING_I2C
|
||||
select BSP_USING_I2C
|
||||
default n
|
||||
|
||||
config NU_PKG_USING_ADC_TOUCH
|
||||
bool "ADC touch function"
|
||||
default n
|
||||
|
||||
if NU_PKG_USING_ADC_TOUCH
|
||||
config NU_PKG_USING_ADC_TOUCH_SW
|
||||
bool "Using SW ADC touch"
|
||||
select RT_USING_ADC
|
||||
default n
|
||||
endif
|
||||
|
||||
config NU_PKG_USING_SPINAND
|
||||
bool "SPI NAND flash."
|
||||
select BSP_USING_QSPI
|
||||
|
||||
@@ -14,6 +14,24 @@
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#include <arm_math.h>
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /* ARM Compiler 6 */
|
||||
#ifdef __has_include
|
||||
#if __has_include("cmsis_armclang.h")
|
||||
#include "cmsis_armclang.h"
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
#ifdef __has_include
|
||||
#if __has_include("cmsis_armcc.h")
|
||||
#include "cmsis_armcc.h"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(__STATIC_INLINE)
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -41,9 +59,10 @@ extern "C" {
|
||||
Find Highest Set
|
||||
nu_clz will start zero-counting from MSB and return the number.
|
||||
*/
|
||||
|
||||
__STATIC_INLINE int nu_clz(uint32_t x)
|
||||
{
|
||||
return x ? __CLZ(x):32;
|
||||
return x ? __CLZ(x) : 32;
|
||||
}
|
||||
|
||||
/* Count Leading Ones in word - Find Highest Zero
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
group = []
|
||||
|
||||
src = Split("""
|
||||
lcd_ssd1963.c
|
||||
""")
|
||||
CPPPATH = [cwd]
|
||||
|
||||
if GetDepend('NU_PKG_USING_SSD1963_EBI'):
|
||||
src += Glob('ssd1963_ebi.c')
|
||||
|
||||
if GetDepend('NU_PKG_USING_SSD1963'):
|
||||
group = DefineGroup('nu_pkgs_ssd1963', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-23 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __LCD_SSD1963_H__
|
||||
#define __LCD_SSD1963_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#define SET_RS rt_pin_write(BOARD_USING_SSD1963_PIN_DC, 1)
|
||||
#define CLR_RS rt_pin_write(BOARD_USING_SSD1963_PIN_DC, 0)
|
||||
|
||||
#define SET_RST rt_pin_write(BOARD_USING_SSD1963_PIN_RESET, 1)
|
||||
#define CLR_RST rt_pin_write(BOARD_USING_SSD1963_PIN_RESET, 0)
|
||||
|
||||
#define SET_BACKLIGHT_ON rt_pin_write(BOARD_USING_SSD1963_PIN_BACKLIGHT, 1)
|
||||
#define SET_BACKLIGHT_OFF rt_pin_write(BOARD_USING_SSD1963_PIN_BACKLIGHT, 0)
|
||||
|
||||
#define SET_DISP_ON rt_pin_write(BOARD_USING_SSD1963_PIN_DISPLAY, 1)
|
||||
#define SET_DISP_OFF rt_pin_write(BOARD_USING_SSD1963_PIN_DISPLAY, 0)
|
||||
|
||||
//
|
||||
// Physical display size
|
||||
//
|
||||
//#if defined(NU_PKG_SSD1963_HORIZONTAL)
|
||||
#define XSIZE_PHYS 480
|
||||
#define YSIZE_PHYS 272
|
||||
//#else
|
||||
// #define XSIZE_PHYS 272
|
||||
// #define YSIZE_PHYS 480
|
||||
//#endif
|
||||
|
||||
int rt_hw_lcd_ssd1963_init(void);
|
||||
void ssd1963_send_cmd(rt_uint8_t cmd);
|
||||
void ssd1963_send_cmd_parameter(rt_uint8_t data);
|
||||
void ssd1963_set_column(rt_uint16_t StartCol, rt_uint16_t EndCol);
|
||||
void ssd1963_set_page(rt_uint16_t StartPage, rt_uint16_t EndPage);
|
||||
void ssd1963_send_pixel_data(rt_uint16_t color);
|
||||
void ssd1963_lcd_get_pixel(char *color, int x, int y);
|
||||
void ssd1963_send_pixels(rt_uint16_t *pixels, int len);
|
||||
|
||||
#if defined(NU_PKG_USING_SSD1963_EBI)
|
||||
rt_err_t rt_hw_lcd_ssd1963_ebi_init(rt_uint32_t ebi_base);
|
||||
#endif
|
||||
|
||||
#endif /* __LCD_SSD1963_H__ */
|
||||
@@ -0,0 +1,118 @@
|
||||
/**************************************************************************//**
|
||||
*
|
||||
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-23 Wayne First version
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#if defined(NU_PKG_USING_SSD1963_EBI)
|
||||
|
||||
#include <lcd_ssd1963.h>
|
||||
#include "drv_pdma.h"
|
||||
|
||||
#define SSD1963_ADDR_CMD 0x0
|
||||
#define SSD1963_ADDR_DATA 0x0
|
||||
|
||||
#define ssd1963_reg_write(u32RegAddr) (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_CMD))) = (u32RegAddr))
|
||||
#define ssd1963_read_data() (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_DATA))))
|
||||
#define ssd1963_write_data(u32Data) (*((volatile unsigned short *)(g_uint32_ssd1963_base+(SSD1963_ADDR_DATA))) = (u32Data))
|
||||
|
||||
static rt_uint32_t g_uint32_ssd1963_base = 0;
|
||||
|
||||
void ssd1963_send_cmd(rt_uint8_t cmd)
|
||||
{
|
||||
CLR_RS;
|
||||
ssd1963_reg_write(cmd);
|
||||
SET_RS;
|
||||
}
|
||||
|
||||
void ssd1963_send_cmd_parameter(rt_uint8_t data)
|
||||
{
|
||||
ssd1963_write_data(data);
|
||||
}
|
||||
|
||||
void ssd1963_send_pixel_data(rt_uint16_t color)
|
||||
{
|
||||
ssd1963_write_data(color);
|
||||
}
|
||||
|
||||
void ssd1963_send_pixels(rt_uint16_t *pixels, int len)
|
||||
{
|
||||
int count = len / sizeof(rt_uint16_t);
|
||||
if (count < 1024)
|
||||
{
|
||||
// CPU feed
|
||||
int i = 0;
|
||||
while (i < count)
|
||||
{
|
||||
ssd1963_write_data(pixels[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// PDMA-M2M feed
|
||||
nu_pdma_mempush((void *)(g_uint32_ssd1963_base + (SSD1963_ADDR_DATA)), (void *)pixels, 16, count);
|
||||
}
|
||||
}
|
||||
|
||||
void ssd1963_set_column(uint16_t StartCol, uint16_t EndCol)
|
||||
{
|
||||
ssd1963_send_cmd(0x2A);
|
||||
ssd1963_write_data((StartCol >> 8) & 0xFF);
|
||||
ssd1963_write_data(StartCol & 0xFF);
|
||||
ssd1963_write_data((EndCol >> 8) & 0xFF);
|
||||
ssd1963_write_data(EndCol & 0xFF);
|
||||
}
|
||||
|
||||
void ssd1963_set_page(uint16_t StartPage, uint16_t EndPage)
|
||||
{
|
||||
ssd1963_send_cmd(0x2B);
|
||||
ssd1963_write_data((StartPage >> 8) & 0xFF);
|
||||
ssd1963_write_data(StartPage & 0xFF);
|
||||
ssd1963_write_data((EndPage >> 8) & 0xFF);
|
||||
ssd1963_write_data(EndPage & 0xFF);
|
||||
}
|
||||
|
||||
void ssd1963_lcd_get_pixel(char *color, int x, int y)
|
||||
{
|
||||
rt_uint16_t red = 0;
|
||||
rt_uint16_t green = 0;
|
||||
rt_uint16_t blue = 0;
|
||||
|
||||
if (x >= XSIZE_PHYS || y >= YSIZE_PHYS)
|
||||
{
|
||||
*(rt_uint16_t *)color = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
ssd1963_set_column(x, x);
|
||||
ssd1963_set_page(y, y);
|
||||
ssd1963_send_cmd(0x2E);
|
||||
|
||||
ssd1963_read_data(); // Dummy
|
||||
red = ssd1963_read_data(); // Red[4:0]@D15~D11
|
||||
blue = ssd1963_read_data(); // Blue[4:0]@D15~D11
|
||||
green = ssd1963_read_data(); // Green[5:0]@D15~D10
|
||||
|
||||
//BGR565: B in High byte, R in low byte
|
||||
//*(rt_uint16_t *)color = (((blue >> 11) << 11) | ((green >> 10) << 5) | (red >> 11));
|
||||
|
||||
//RGB565: R in High byte, B in low byte
|
||||
*(rt_uint16_t *)color = (((red >> 11) << 11) | ((green >> 10) << 5) | (blue >> 11));
|
||||
}
|
||||
|
||||
rt_err_t rt_hw_lcd_ssd1963_ebi_init(rt_uint32_t ssd1963_base)
|
||||
{
|
||||
g_uint32_ssd1963_base = ssd1963_base;
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#endif /* if defined(NU_PKG_USING_SSD1963_EBI) */
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
/* Private define ---------------------------------------------------------------*/
|
||||
#define DEF_ADC_TOUCH_SMPL_TICK 40
|
||||
#define TOUCH_MQ_LENGTH 64
|
||||
|
||||
/* Private Typedef --------------------------------------------------------------*/
|
||||
struct nu_adc
|
||||
|
||||
@@ -15,14 +15,11 @@
|
||||
|
||||
#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
|
||||
@@ -57,28 +54,10 @@ typedef struct
|
||||
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);
|
||||
void nu_adc_touch_detect(rt_bool_t bStartDetect);
|
||||
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);
|
||||
#endif
|
||||
|
||||
#endif /* __DRV_ADC_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@
|
||||
#include <netif/etharp.h>
|
||||
#include <lwip/icmp.h>
|
||||
#include <lwip/pbuf.h>
|
||||
#include <lwip/sys.h>
|
||||
#include "lwipopts.h"
|
||||
|
||||
#include "drv_sys.h"
|
||||
|
||||
@@ -177,7 +177,7 @@ static void nu_pdma_init(void)
|
||||
return;
|
||||
|
||||
nu_pdma_chn_mask = ~(NU_PDMA_CH_Msk);
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX*sizeof(nu_pdma_chn_t));
|
||||
rt_memset(nu_pdma_chn_arr, 0x00, NU_PDMA_CH_MAX * sizeof(nu_pdma_chn_t));
|
||||
|
||||
nu_sys_ipclk_enable(PDMA0CKEN);
|
||||
nu_sys_ipclk_enable(PDMA1CKEN);
|
||||
@@ -1106,7 +1106,8 @@ void *nu_pdma_memcpy(void *dest, void *src, unsigned int count)
|
||||
uint32_t u32dest = (uint32_t)dest + u32Offset;
|
||||
|
||||
if (((u32src % i) == (u32dest % i)) &&
|
||||
((u32src % i) == 0) && (RT_ALIGN_DOWN(u32Remaining, i) >= i))
|
||||
((u32src % i) == 0) &&
|
||||
(RT_ALIGN_DOWN(u32Remaining, i) >= i))
|
||||
{
|
||||
uint32_t u32TXCnt = u32Remaining / i;
|
||||
if (u32TXCnt != nu_pdma_memfun((void *)u32dest, (void *)u32src, i * 8, u32TXCnt, eMemCtl_SrcInc_DstInc))
|
||||
|
||||
@@ -116,11 +116,13 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
struct nu_spi *spi_bus;
|
||||
uint32_t u32SPIMode;
|
||||
rt_err_t ret = RT_EOK;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(configuration != RT_NULL);
|
||||
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
/* Check mode */
|
||||
switch (configuration->mode & RT_SPI_MODE_3)
|
||||
@@ -162,12 +164,29 @@ static rt_err_t nu_spi_bus_configure(struct rt_spi_device *device,
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
/* Set CS pin to LOW */
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set CS pin to HIGH */
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration->mode & RT_SPI_MSB)
|
||||
@@ -371,6 +390,7 @@ rt_err_t nu_hw_spi_pdma_allocate(struct nu_spi *spi_bus)
|
||||
}
|
||||
|
||||
spi_bus->m_psSemBus = rt_sem_create("spibus_sem", 0, RT_IPC_FLAG_FIFO);
|
||||
RT_ASSERT(spi_bus->m_psSemBus != RT_NULL);
|
||||
|
||||
return RT_EOK;
|
||||
|
||||
@@ -550,6 +570,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
struct nu_spi *spi_bus;
|
||||
struct rt_spi_configuration *configuration;
|
||||
uint8_t bytes_per_word;
|
||||
void *pvUserData;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
RT_ASSERT(device->bus != RT_NULL);
|
||||
@@ -558,6 +579,7 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
spi_bus = (struct nu_spi *) device->bus;
|
||||
configuration = (struct rt_spi_configuration *)&spi_bus->configuration;
|
||||
bytes_per_word = configuration->data_width / 8;
|
||||
pvUserData = device->parent.user_data;
|
||||
|
||||
if ((message->length % bytes_per_word) != 0)
|
||||
{
|
||||
@@ -570,13 +592,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
{
|
||||
if (message->cs_take && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,13 +622,29 @@ static rt_uint32_t nu_spi_bus_xfer(struct rt_spi_device *device, struct rt_spi_m
|
||||
|
||||
if (message->cs_release && !(configuration->mode & RT_SPI_NO_CS))
|
||||
{
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
if (pvUserData != RT_NULL)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
// set to LOW */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set to HIGH */
|
||||
rt_pin_write(*((rt_base_t *)pvUserData), PIN_HIGH);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
if (configuration->mode & RT_SPI_CS_HIGH)
|
||||
{
|
||||
SPI_SET_SS_LOW(spi_bus->spi_base);
|
||||
}
|
||||
else
|
||||
{
|
||||
SPI_SET_SS_HIGH(spi_bus->spi_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ menu "Hardware Drivers Config"
|
||||
bool "LCD ILI9341 (over spi0)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_SPI
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
|
||||
@@ -189,6 +189,12 @@ static int rt_hw_spinand_init(void)
|
||||
INIT_COMPONENT_EXPORT(rt_hw_spinand_init);
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_ADC_TOUCH) && defined(NU_PKG_USING_ADC_TOUCH)
|
||||
#include "adc_touch.h"
|
||||
#if (BSP_LCD_WIDTH==320) && (BSP_LCD_HEIGHT==240)
|
||||
S_CALIBRATION_MATRIX g_sCalMat = { 43, -5839, 21672848, 4193, -11, -747882, 65536 };
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_SPI)
|
||||
#include <lcd_ili9341.h>
|
||||
@@ -197,7 +203,7 @@ INIT_COMPONENT_EXPORT(rt_hw_spinand_init);
|
||||
#endif
|
||||
int rt_hw_ili9341_port(void)
|
||||
{
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi0") != RT_EOK)
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi0", RT_NULL) != RT_EOK)
|
||||
return -1;
|
||||
|
||||
rt_hw_lcd_ili9341_init();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,9 +5,13 @@ CPU = 'arm926'
|
||||
# toolchains options
|
||||
CROSS_TOOL = 'gcc'
|
||||
|
||||
#------- toolchains path -------------------------------------------------------
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
@@ -20,7 +24,7 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = 'debug'
|
||||
#BUILD = 'release'
|
||||
#BUILD = ''
|
||||
|
||||
CORE = 'arm926ej-s'
|
||||
MAP_FILE = 'rtthread_nuc980.map'
|
||||
@@ -32,9 +36,9 @@ if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
CXX = PREFIX + 'g++'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
@@ -53,11 +57,13 @@ if PLATFORM == 'gcc':
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O2 -gdwarf-2'
|
||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
||||
POST_ACTION += SIZE + ' $TARGET\n'
|
||||
#------- Keil settings ---------------------------------------------------------
|
||||
@@ -79,7 +85,7 @@ elif PLATFORM == 'armcc':
|
||||
LFLAGS += ' --scatter ' + LINK_FILE + '.sct'
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -g -O2'
|
||||
CFLAGS += ' -g -O0'
|
||||
AFLAGS += ' -g'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
baudrate=115200
|
||||
bootdelay=1
|
||||
stderr=serial
|
||||
stdin=serial
|
||||
stdout=serial
|
||||
loadrtt=nand read 0x80000000 0x200000 0x100000
|
||||
bootcmd=run loadrtt;go 0x0
|
||||
baudrate=115200
|
||||
bootdelay=1
|
||||
stderr=serial
|
||||
stdin=serial
|
||||
stdout=serial
|
||||
loadrtt=nand read 0x80000000 0x200000 0x100000
|
||||
bootcmd=run loadrtt;go 0x0
|
||||
@@ -7,7 +7,6 @@
|
||||
# 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
|
||||
@@ -247,7 +246,6 @@ CONFIG_RT_USB_MSTORAGE_DISK_NAME="ramdisk1"
|
||||
#
|
||||
# POSIX layer and C standard library
|
||||
#
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8
|
||||
|
||||
#
|
||||
@@ -263,7 +261,9 @@ CONFIG_RT_USING_POSIX_SELECT=y
|
||||
# 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_POSIX_TIMER is not set
|
||||
# CONFIG_RT_USING_PTHREADS is not set
|
||||
# CONFIG_RT_USING_MODULE is not set
|
||||
|
||||
#
|
||||
# Interprocess Communication (IPC)
|
||||
@@ -310,7 +310,6 @@ CONFIG_NETDEV_IPV6=0
|
||||
#
|
||||
CONFIG_RT_USING_LWIP=y
|
||||
# CONFIG_RT_USING_LWIP141 is not set
|
||||
# CONFIG_RT_USING_LWIP202 is not set
|
||||
CONFIG_RT_USING_LWIP203=y
|
||||
# CONFIG_RT_USING_LWIP212 is not set
|
||||
# CONFIG_RT_USING_LWIP_IPV6 is not set
|
||||
@@ -454,6 +453,7 @@ CONFIG_UTEST_THR_PRIORITY=20
|
||||
# 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_LLSYNC_SDK_ADAPTER is not set
|
||||
# CONFIG_PKG_USING_OTA_DOWNLOADER is not set
|
||||
# CONFIG_PKG_USING_IPMSG is not set
|
||||
# CONFIG_PKG_USING_LSSDP is not set
|
||||
@@ -517,6 +517,8 @@ CONFIG_UTEST_THR_PRIORITY=20
|
||||
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_DEMOS is not set
|
||||
# CONFIG_PKG_USING_LVGL_V820 is not set
|
||||
CONFIG_PKG_USING_LVGL_V810=y
|
||||
# CONFIG_PKG_USING_LVGL_LATEST_VERSION is not set
|
||||
CONFIG_PKG_LVGL_VER="v8.1.0"
|
||||
@@ -553,6 +555,7 @@ CONFIG_PKG_LV_MUSIC_DEMO_VER="v0.1.1"
|
||||
# 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
|
||||
@@ -563,7 +566,6 @@ CONFIG_PKG_LV_MUSIC_DEMO_VER="v0.1.1"
|
||||
# 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
|
||||
@@ -614,6 +616,7 @@ CONFIG_PKG_LV_MUSIC_DEMO_VER="v0.1.1"
|
||||
# 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
|
||||
@@ -650,6 +653,7 @@ CONFIG_FAL_DEBUG=1
|
||||
CONFIG_FAL_PART_HAS_TABLE_CFG=y
|
||||
CONFIG_FAL_USING_SFUD_PORT=y
|
||||
CONFIG_FAL_USING_NOR_FLASH_DEV_NAME="norflash0"
|
||||
# CONFIG_PKG_USING_FAL_V10000 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00500 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00400 is not set
|
||||
# CONFIG_PKG_USING_FAL_V00300 is not set
|
||||
@@ -687,7 +691,7 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
||||
# 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
|
||||
# CONFIG_PKG_USING_CHERRYUSB is not set
|
||||
|
||||
#
|
||||
# peripheral libraries and drivers
|
||||
@@ -817,6 +821,7 @@ CONFIG_PKG_RAMDISK_VER="latest"
|
||||
# CONFIG_PKG_USING_CANFESTIVAL is not set
|
||||
# CONFIG_PKG_USING_ZLIB is not set
|
||||
# CONFIG_PKG_USING_MINIZIP is not set
|
||||
# CONFIG_PKG_USING_HEATSHRINK 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
|
||||
@@ -832,6 +837,8 @@ CONFIG_PKG_RAMDISK_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
|
||||
# CONFIG_PKG_USING_CONTROLLER is not set
|
||||
# CONFIG_PKG_USING_PHASE_LOCKED_LOOP is not set
|
||||
|
||||
#
|
||||
# Hardware Drivers Config
|
||||
@@ -959,6 +966,8 @@ CONFIG_NU_PKG_USING_UTILS=y
|
||||
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_ADC_TOUCH=y
|
||||
# CONFIG_NU_PKG_USING_ADC_TOUCH_SW is not set
|
||||
# CONFIG_NU_PKG_USING_SPINAND is not set
|
||||
CONFIG_BOARD_USE_UTEST=y
|
||||
CONFIG_UTEST_CMD_PREFIX="bsp.nuvoton.nk-n9h30.test.utest."
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# NK-N9H30
|
||||
## 1. Introduction
|
||||
Nuvoton offers the emWin platform which is embedded with Nuvoton N9H MPU, it provides complete HMI solutions which are further enhanced by the emWin software. The N9H series with ARM926EJ-S core can operate at up to 300 MHz and can drive up to 1024x768 pixels in parallel port. It integrated TFT LCD controller and 2D graphics accelerator, up to 16 million colors (24-bit) LCD screen output, and provides high resolution and high chroma to deliver gorgeous display effects. To play compressed video in HMI screens smoothly, the N9H series is equipped with H.264 video decompression engine. It also offers built-in voice decoder, which can streamline the peripheral circuits of HMI applications with sound playback. It embedded up to 64 MB DDR memory, along with ample hardware storage and computing space for excellent design flexibility.
|
||||
Nuvoton offers HMI platforms which are embedded with Nuvoton N9H MPU. The N9H series with ARM926EJ-S core can operate at up to 300 MHz and can drive up to 1024x768 pixels in parallel port. It integrated TFT LCD controller and 2D graphics accelerator, up to 16 million colors (24-bit) LCD screen output, and provides high resolution and high chroma to deliver gorgeous display effects. It embedded up to 64 MB DDR memory, along with ample hardware storage and computing space for excellent design flexibility.
|
||||
|
||||
[](https://i.imgur.com/B04MCCf.png "NK-N9H30")
|
||||
|
||||
@@ -47,7 +47,7 @@ Support GCC, MDK4 and MDK5 IDE/compilers. More information of these compiler ver
|
||||
| IDE/Compiler | Tested version |
|
||||
| ---------- | ---------------------------- |
|
||||
| MDK5 | 5.26.2 |
|
||||
| GCC | GCC 5.4.1 20160919 (release) |
|
||||
| GCC | 6-2017-q1-update |
|
||||
|
||||
Notice: Please install ICE driver for development.
|
||||
|
||||
@@ -87,9 +87,10 @@ You can use Tera Term terminate emulator (or other software) to type commands of
|
||||
[](https://i.imgur.com/5NYuSNM.png "Serial settings")
|
||||
|
||||
## 5. Purchase
|
||||
* [Nuvoton Direct](https://direct.nuvoton.com/en/numaker-emwin-n9h30)
|
||||
* [Nuvoton Direct](https://direct.nuvoton.com/en/numaker-hmi-n9h30)
|
||||
|
||||
## 6. Resources
|
||||
* [Board Schematic](https://www.nuvoton.com/resource-download.jsp?tp_GUID=HL1020201117191514)
|
||||
* [Download NK-N9H30 Quick Start Guide](https://www.nuvoton.com/resource-download.jsp?tp_GUID=UG1320210329155300)
|
||||
* [Download NuWriter](https://github.com/OpenNuvoton/NUC970_NuWriter)
|
||||
* [Download Windows 32-bit 6-2017-q1-update ARM GCC](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads/6-2017-q1-update)
|
||||
|
||||
@@ -102,6 +102,7 @@ menu "Hardware Drivers Config"
|
||||
config BOARD_USING_ADCTOUCH
|
||||
bool "ADC touching"
|
||||
select BSP_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
help
|
||||
Choose this option if you use internal ADC touching function.
|
||||
|
||||
|
||||
@@ -5,9 +5,13 @@ CPU = 'arm926'
|
||||
# toolchains options
|
||||
CROSS_TOOL = 'gcc'
|
||||
|
||||
#------- toolchains path -------------------------------------------------------
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
@@ -20,7 +24,7 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = 'debug'
|
||||
#BUILD = 'release'
|
||||
#BUILD = ''
|
||||
|
||||
CORE = 'arm926ej-s'
|
||||
MAP_FILE = 'rtthread_n9h30.map'
|
||||
@@ -32,9 +36,9 @@ if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
CXX = PREFIX + 'g++'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
@@ -53,11 +57,13 @@ if PLATFORM == 'gcc':
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O2 -gdwarf-2'
|
||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
||||
POST_ACTION += SIZE + ' $TARGET\n'
|
||||
#------- Keil settings ---------------------------------------------------------
|
||||
|
||||
@@ -5,9 +5,13 @@ CPU = 'arm926'
|
||||
# toolchains options
|
||||
CROSS_TOOL = 'gcc'
|
||||
|
||||
#------- toolchains path -------------------------------------------------------
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
|
||||
if CROSS_TOOL == 'gcc':
|
||||
PLATFORM = 'gcc'
|
||||
@@ -20,7 +24,7 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = 'debug'
|
||||
#BUILD = 'release'
|
||||
#BUILD = ''
|
||||
|
||||
CORE = 'arm926ej-s'
|
||||
MAP_FILE = 'rtthread_nuc980.map'
|
||||
@@ -32,9 +36,9 @@ if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
CXX = PREFIX + 'g++'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
@@ -53,11 +57,13 @@ if PLATFORM == 'gcc':
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O2 -gdwarf-2'
|
||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET ' + TARGET_NAME + '\n'
|
||||
POST_ACTION += SIZE + ' $TARGET\n'
|
||||
#------- Keil settings ---------------------------------------------------------
|
||||
|
||||
@@ -3,9 +3,19 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
objs = objs + group
|
||||
|
||||
Return('objs')
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('LVGL-port', src, depend = ['PKG_USING_LVGL'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-17 Wayne First version
|
||||
*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
#define LV_HOR_RES_MAX (320)
|
||||
#define LV_VER_RES_MAX (240)
|
||||
|
||||
#define LV_FONT_MONTSERRAT_12 1
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
//#define LV_USE_DEMO_BENCHMARK 1
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 1
|
||||
#define LV_DISP_DEF_REFR_PERIOD 16
|
||||
|
||||
//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-17 Meco Man First version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef LV_THREAD_STACK_SIZE
|
||||
#define LV_THREAD_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
#ifndef LV_THREAD_PRIO
|
||||
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif
|
||||
|
||||
static void lvgl_thread(void *parameter)
|
||||
{
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
extern void lv_demo_benchmark(void);
|
||||
lv_demo_benchmark();
|
||||
#endif
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
extern void lv_demo_widgets(void);
|
||||
lv_demo_widgets();
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
lv_task_handler();
|
||||
rt_thread_mdelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_demo_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10);
|
||||
if (tid == RT_NULL)
|
||||
{
|
||||
LOG_E("Fail to create 'LVGL' thread");
|
||||
}
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(lvgl_demo_init);
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-17 Wayne The first version
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
|
||||
#define LOG_TAG "lvgl.disp"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL DBG_ERROR
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*A static or global variable to store the buffers*/
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
|
||||
static rt_device_t lcd_device = 0;
|
||||
static struct rt_device_graphic_info info;
|
||||
|
||||
static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
|
||||
rect.x = area->x1;
|
||||
rect.y = area->y1;
|
||||
rect.width = area->x2 - area->x1 + 1;
|
||||
rect.height = area->y2 - area->y1 + 1;
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px)
|
||||
{
|
||||
rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t));
|
||||
}
|
||||
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
rt_err_t result;
|
||||
void *buf1 = RT_NULL;
|
||||
|
||||
lcd_device = rt_device_find("lcd");
|
||||
if (lcd_device == 0)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* get framebuffer address */
|
||||
result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info);
|
||||
if (result != RT_EOK && info.framebuffer == RT_NULL)
|
||||
{
|
||||
LOG_E("error!");
|
||||
/* get device information failed */
|
||||
return;
|
||||
}
|
||||
|
||||
RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 ||
|
||||
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
|
||||
|
||||
buf1 = (void *)info.framebuffer;
|
||||
rt_kprintf("LVGL: Use one buffers - buf1@%08x, size: %d bytes\n", buf1, info.smem_len);
|
||||
|
||||
/*Initialize `disp_buf` with the buffer(s).*/
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, RT_NULL, info.smem_len/(info.bits_per_pixel/8));
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = info.width;
|
||||
disp_drv.ver_res = info.height;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
|
||||
/*Write the internal buffer (draw_buf) to the display*/
|
||||
disp_drv.flush_cb = lcd_fb_flush;
|
||||
|
||||
/* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
|
||||
//disp_drv.monitor_cb = lcd_perf_monitor;
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_DISP_H
|
||||
#define LV_PORT_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_port_disp_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
* 2021-12-17 Wayne Add input event
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <rtdevice.h>
|
||||
#include "touch.h"
|
||||
|
||||
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
||||
static rt_int16_t last_x = 0;
|
||||
static rt_int16_t last_y = 0;
|
||||
|
||||
static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
|
||||
{
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = last_state;
|
||||
}
|
||||
|
||||
void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case RT_TOUCH_EVENT_UP:
|
||||
last_state = LV_INDEV_STATE_RELEASED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_DOWN:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_state = LV_INDEV_STATE_PRESSED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_MOVE:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
/* Basic initialization */
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = input_read;
|
||||
|
||||
/* Register the driver in LVGL and save the created input device object */
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_INDEV_H
|
||||
#define LV_PORT_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <lv_hal_indev.h>
|
||||
|
||||
extern lv_indev_t *button_indev;
|
||||
|
||||
void lv_port_indev_init(void);
|
||||
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -109,9 +109,18 @@ menu "Hardware Drivers Config"
|
||||
|
||||
config BOARD_USING_LCD_ILI9341
|
||||
bool "LCD ILI9341 (over spi2)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_SPI2
|
||||
select BSP_USING_EADC
|
||||
select BSP_USING_EADC0
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH_SW
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_SPI
|
||||
select BSP_USING_SPI2
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
select NU_PKG_ILI9341_HORIZONTAL
|
||||
select PKG_USING_LVGL
|
||||
select PKG_USING_LVGL_DEMOS
|
||||
default n
|
||||
|
||||
if BOARD_USING_LCD_ILI9341
|
||||
|
||||
@@ -245,13 +245,75 @@ static void at_wifi_set(int argc, char **argv)
|
||||
#endif /* BOARD_USING_ESP8266 */
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_SPI)
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
|
||||
#include "adc_touch.h"
|
||||
#include "touch_sw.h"
|
||||
#include "NuMicro.h"
|
||||
|
||||
#define NU_MFP_POS(PIN) ((PIN % 8) * 4)
|
||||
#define NU_MFP_MSK(PIN) (0xful << NU_MFP_POS(PIN))
|
||||
|
||||
S_CALIBRATION_MATRIX g_sCalMat = { 97, 6214, -3216652, 4844, -30, -2333200, 65536 };
|
||||
|
||||
static void nu_pin_func(rt_base_t pin, int data)
|
||||
{
|
||||
uint32_t pin_index = NU_GET_PINS(pin);
|
||||
uint32_t port_index = NU_GET_PORT(pin);
|
||||
__IO uint32_t *GPx_MFPx = ((__IO uint32_t *) &SYS->GPA_MFPL) + port_index * 2 + (pin_index / 8);
|
||||
uint32_t MFP_Msk = NU_MFP_MSK(pin_index);
|
||||
|
||||
*GPx_MFPx = (*GPx_MFPx & (~MFP_Msk)) | data;
|
||||
}
|
||||
|
||||
static void tp_switch_to_analog(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
if (pin == NU_GET_PININDEX(NU_PB, 6))
|
||||
nu_pin_func(pin, SYS_GPB_MFPL_PB6MFP_EADC0_CH6);
|
||||
else if (pin == NU_GET_PININDEX(NU_PB, 9))
|
||||
nu_pin_func(pin, SYS_GPB_MFPH_PB9MFP_EADC0_CH9);
|
||||
|
||||
GPIO_DISABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static void tp_switch_to_digital(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
nu_pin_func(pin, 0);
|
||||
|
||||
/* Enable digital path on these EADC pins */
|
||||
GPIO_ENABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static S_TOUCH_SW sADCTP =
|
||||
{
|
||||
.adc_name = "eadc0",
|
||||
.i32ADCChnYU = 6,
|
||||
.i32ADCChnXR = 9,
|
||||
.pin =
|
||||
{
|
||||
NU_GET_PININDEX(NU_PB, 7), // XL
|
||||
NU_GET_PININDEX(NU_PB, 6), // YU
|
||||
NU_GET_PININDEX(NU_PB, 9), // XR
|
||||
NU_GET_PININDEX(NU_PB, 8), // YD
|
||||
},
|
||||
.switch_to_analog = tp_switch_to_analog,
|
||||
.switch_to_digital = tp_switch_to_digital,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include <lcd_ili9341.h>
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
#include <rtgui/driver.h>
|
||||
#endif
|
||||
int rt_hw_ili9341_port(void)
|
||||
{
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi2") != RT_EOK)
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi2", RT_NULL) != RT_EOK)
|
||||
return -1;
|
||||
|
||||
rt_hw_lcd_ili9341_init();
|
||||
@@ -264,6 +326,11 @@ int rt_hw_ili9341_port(void)
|
||||
rtgui_graphic_set_device(lcd_ili9341);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
nu_adc_touch_sw_register(&sADCTP);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ili9341_port);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,12 @@ import os
|
||||
# toolchains options
|
||||
ARCH='arm'
|
||||
CPU='cortex-m4'
|
||||
CROSS_TOOL='keil'
|
||||
CROSS_TOOL='gcc'
|
||||
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
@@ -25,39 +27,37 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = ''
|
||||
# BUILD = 'debug'
|
||||
|
||||
#BUILD = 'debug'
|
||||
|
||||
if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
LINK = PREFIX + 'g++'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -Wuninitialized'
|
||||
|
||||
if BUILD == 'debug':
|
||||
DEVICE = DEVICE + ' -DDEBUG'
|
||||
|
||||
CFLAGS = DEVICE
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map -T ./linking_scripts/m480_link.ld '
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
|
||||
CFLAGS = DEVICE + ' -Dgcc'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
|
||||
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T ./linking_scripts/m480_link.ld '
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O0 -gdwarf-2'
|
||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2 -gdwarf-2'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
|
||||
@@ -3,9 +3,19 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
objs = []
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd, str(Dir('#'))]
|
||||
|
||||
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
objs = objs + group
|
||||
|
||||
Return('objs')
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('LVGL-port', src, depend = ['PKG_USING_LVGL'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-17 Wayne First version
|
||||
*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
#define LV_HOR_RES_MAX (320)
|
||||
#define LV_VER_RES_MAX (240)
|
||||
|
||||
#define LV_FONT_MONTSERRAT_12 1
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
//#define LV_USE_DEMO_BENCHMARK 1
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 1
|
||||
//#define LV_DISP_DEF_REFR_PERIOD 16
|
||||
|
||||
//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-17 Meco Man First version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef LV_THREAD_STACK_SIZE
|
||||
#define LV_THREAD_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
#ifndef LV_THREAD_PRIO
|
||||
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif
|
||||
|
||||
static void lvgl_thread(void *parameter)
|
||||
{
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
extern void lv_demo_benchmark(void);
|
||||
lv_demo_benchmark();
|
||||
#endif
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
extern void lv_demo_widgets(void);
|
||||
lv_demo_widgets();
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
lv_task_handler();
|
||||
rt_thread_mdelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_demo_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10);
|
||||
if (tid == RT_NULL)
|
||||
{
|
||||
LOG_E("Fail to create 'LVGL' thread");
|
||||
}
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(lvgl_demo_init);
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-17 Wayne The first version
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
|
||||
#define LOG_TAG "lvgl.disp"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL DBG_ERROR
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*A static or global variable to store the buffers*/
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
|
||||
static rt_device_t lcd_device = 0;
|
||||
static struct rt_device_graphic_info info;
|
||||
|
||||
static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
|
||||
rect.x = area->x1;
|
||||
rect.y = area->y1;
|
||||
rect.width = area->x2 - area->x1 + 1;
|
||||
rect.height = area->y2 - area->y1 + 1;
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px)
|
||||
{
|
||||
rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t));
|
||||
}
|
||||
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
rt_err_t result;
|
||||
void *buf1 = RT_NULL;
|
||||
|
||||
lcd_device = rt_device_find("lcd");
|
||||
if (lcd_device == 0)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* get framebuffer address */
|
||||
result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info);
|
||||
if (result != RT_EOK && info.framebuffer == RT_NULL)
|
||||
{
|
||||
LOG_E("error!");
|
||||
/* get device information failed */
|
||||
return;
|
||||
}
|
||||
|
||||
RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 ||
|
||||
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
|
||||
|
||||
buf1 = (void *)info.framebuffer;
|
||||
rt_kprintf("LVGL: Use one buffers - buf1@%08x, size: %d bytes\n", buf1, info.smem_len);
|
||||
|
||||
/*Initialize `disp_buf` with the buffer(s).*/
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, RT_NULL, info.smem_len / (info.bits_per_pixel / 8));
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = info.width;
|
||||
disp_drv.ver_res = info.height;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
|
||||
/*Write the internal buffer (draw_buf) to the display*/
|
||||
disp_drv.flush_cb = lcd_fb_flush;
|
||||
|
||||
/* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
|
||||
//disp_drv.monitor_cb = lcd_perf_monitor;
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_DISP_H
|
||||
#define LV_PORT_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_port_disp_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
* 2021-12-17 Wayne Add input event
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <rtdevice.h>
|
||||
#include "touch.h"
|
||||
|
||||
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
||||
static rt_int16_t last_x = 0;
|
||||
static rt_int16_t last_y = 0;
|
||||
|
||||
static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
|
||||
{
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = last_state;
|
||||
}
|
||||
|
||||
void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case RT_TOUCH_EVENT_UP:
|
||||
last_state = LV_INDEV_STATE_RELEASED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_DOWN:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_state = LV_INDEV_STATE_PRESSED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_MOVE:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
/* Basic initialization */
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = input_read;
|
||||
|
||||
/* Register the driver in LVGL and save the created input device object */
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_INDEV_H
|
||||
#define LV_PORT_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <lv_hal_indev.h>
|
||||
|
||||
extern lv_indev_t *button_indev;
|
||||
|
||||
void lv_port_indev_init(void);
|
||||
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -22,6 +22,42 @@ menu "Hardware Drivers Config"
|
||||
select BSP_USING_QSPI0
|
||||
default n
|
||||
|
||||
config BOARD_USING_LCD_ILI9341
|
||||
bool "LCD ILI9341 (over uspi0)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_USCI0
|
||||
select BSP_USING_USPI0
|
||||
select BSP_USING_EADC
|
||||
select BSP_USING_EADC0
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH_SW
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_SPI
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
select NU_PKG_ILI9341_HORIZONTAL
|
||||
select PKG_USING_LVGL
|
||||
select PKG_USING_LVGL_DEMOS
|
||||
default n
|
||||
|
||||
if BOARD_USING_LCD_ILI9341
|
||||
|
||||
config BOARD_USING_ILI9341_PIN_BACKLIGHT
|
||||
int "Specify the pin index of backlight pin index"
|
||||
range 0 127
|
||||
default 6
|
||||
|
||||
config BOARD_USING_ILI9341_PIN_RESET
|
||||
int "Specify the pin index of reset pin index"
|
||||
range 0 127
|
||||
default 19
|
||||
|
||||
config BOARD_USING_ILI9341_PIN_DC
|
||||
int "Specify the pin index of data&command switching"
|
||||
range 0 127
|
||||
default 18
|
||||
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
||||
source "$BSP_DIR/../libraries/nu_packages/Kconfig"
|
||||
|
||||
@@ -45,6 +45,7 @@ Pin128:ADC0_CH6
|
||||
********************/
|
||||
|
||||
#include "M031Series.h"
|
||||
#include "rtconfig.h"
|
||||
|
||||
void nutool_pincfg_init_ice(void)
|
||||
{
|
||||
@@ -120,6 +121,13 @@ void nutool_pincfg_init_qspi0(void)
|
||||
|
||||
}
|
||||
|
||||
void nutool_pincfg_init_usci0(void)
|
||||
{
|
||||
SYS->GPA_MFPH &= ~(SYS_GPA_MFPH_PA8MFP_Msk | SYS_GPA_MFPH_PA9MFP_Msk | SYS_GPA_MFPH_PA10MFP_Msk | SYS_GPA_MFPH_PA11MFP_Msk);
|
||||
|
||||
SYS->GPA_MFPH |= (/*SYS_GPA_MFPH_PA8MFP_USCI0_CTL1 |*/ SYS_GPA_MFPH_PA9MFP_USCI0_DAT1 | SYS_GPA_MFPH_PA10MFP_USCI0_DAT0 | SYS_GPA_MFPH_PA11MFP_USCI0_CLK);
|
||||
}
|
||||
|
||||
void nutool_pincfg_deinit_qspi0(void)
|
||||
{
|
||||
SYS->GPA_MFPL &= ~(SYS_GPA_MFPL_PA0MFP_Msk | SYS_GPA_MFPL_PA1MFP_Msk | SYS_GPA_MFPL_PA2MFP_Msk | SYS_GPA_MFPL_PA3MFP_Msk |
|
||||
@@ -208,10 +216,15 @@ void nutool_pincfg_init(void)
|
||||
nutool_pincfg_init_x32();
|
||||
nutool_pincfg_init_xt1();
|
||||
nutool_pincfg_init_qspi0();
|
||||
#if defined(BOARD_USING_LCD_ILI9341)
|
||||
nutool_pincfg_init_usci0();
|
||||
#endif
|
||||
nutool_pincfg_init_i2c0();
|
||||
nutool_pincfg_init_adc0();
|
||||
nutool_pincfg_init_pwm0();
|
||||
nutool_pincfg_init_uart1();
|
||||
#if !defined(BOARD_USING_LCD_ILI9341)
|
||||
nutool_pincfg_deinit_pwm0();
|
||||
nutool_pincfg_deinit_uart1();
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -223,6 +236,7 @@ void nutool_pincfg_deinit(void)
|
||||
nutool_pincfg_deinit_x32();
|
||||
nutool_pincfg_deinit_xt1();
|
||||
nutool_pincfg_deinit_qspi0();
|
||||
nutool_pincfg_init_usci0();
|
||||
nutool_pincfg_deinit_i2c0();
|
||||
nutool_pincfg_deinit_adc0();
|
||||
nutool_pincfg_deinit_pwm0();
|
||||
|
||||
@@ -150,3 +150,96 @@ static int rt_hw_spiflash_init(void)
|
||||
INIT_COMPONENT_EXPORT(rt_hw_spiflash_init);
|
||||
#endif /* BOARD_USING_STORAGE_SPIFLASH */
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_SPI)
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
|
||||
#include "adc_touch.h"
|
||||
#include "touch_sw.h"
|
||||
#include "NuMicro.h"
|
||||
|
||||
#define NU_MFP_POS(PIN) ((PIN % 8) * 4)
|
||||
#define NU_MFP_MSK(PIN) (0xful << NU_MFP_POS(PIN))
|
||||
|
||||
S_CALIBRATION_MATRIX g_sCalMat = { 25, 6607, -3535848, 5185, 33, -2924330, 65536 };
|
||||
|
||||
static void nu_pin_func(rt_base_t pin, int data)
|
||||
{
|
||||
uint32_t pin_index = NU_GET_PINS(pin);
|
||||
uint32_t port_index = NU_GET_PORT(pin);
|
||||
__IO uint32_t *GPx_MFPx = ((__IO uint32_t *) &SYS->GPA_MFPL) + port_index * 2 + (pin_index / 8);
|
||||
uint32_t MFP_Msk = NU_MFP_MSK(pin_index);
|
||||
|
||||
*GPx_MFPx = (*GPx_MFPx & (~MFP_Msk)) | data;
|
||||
}
|
||||
|
||||
static void tp_switch_to_analog(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(PA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
if (pin == NU_GET_PININDEX(NU_PB, 7))
|
||||
nu_pin_func(pin, SYS_GPB_MFPL_PB7MFP_ADC0_CH7);
|
||||
else if (pin == NU_GET_PININDEX(NU_PB, 4))
|
||||
nu_pin_func(pin, SYS_GPB_MFPL_PB4MFP_ADC0_CH4);
|
||||
|
||||
GPIO_DISABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static void tp_switch_to_digital(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(PA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
nu_pin_func(pin, 0);
|
||||
|
||||
/* Enable digital path on these EADC pins */
|
||||
GPIO_ENABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static S_TOUCH_SW sADCTP =
|
||||
{
|
||||
.adc_name = "adc0",
|
||||
.i32ADCChnYU = 7,
|
||||
.i32ADCChnXR = 4,
|
||||
.pin =
|
||||
{
|
||||
NU_GET_PININDEX(NU_PB, 6), // XL
|
||||
NU_GET_PININDEX(NU_PB, 7), // YU
|
||||
NU_GET_PININDEX(NU_PB, 4), // XR
|
||||
NU_GET_PININDEX(NU_PB, 5), // YD
|
||||
},
|
||||
.switch_to_analog = tp_switch_to_analog,
|
||||
.switch_to_digital = tp_switch_to_digital,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include <lcd_ili9341.h>
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
#include <rtgui/driver.h>
|
||||
#endif
|
||||
|
||||
static rt_base_t g_ILI9341_SPI_CS_PIN = NU_GET_PININDEX(NU_PA, 8);
|
||||
int rt_hw_ili9341_port(void)
|
||||
{
|
||||
if (rt_hw_lcd_ili9341_spi_init("uspi0", (void *)&g_ILI9341_SPI_CS_PIN) != RT_EOK)
|
||||
return -1;
|
||||
|
||||
rt_hw_lcd_ili9341_init();
|
||||
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
rt_device_t lcd_ili9341;
|
||||
lcd_ili9341 = rt_device_find("lcd");
|
||||
if (lcd_ili9341)
|
||||
{
|
||||
rtgui_graphic_set_device(lcd_ili9341);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
nu_adc_touch_sw_register(&sADCTP);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ili9341_port);
|
||||
#endif /* BOARD_USING_LCD_ILI9341 */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,6 +7,8 @@ CROSS_TOOL='keil'
|
||||
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
@@ -34,6 +36,7 @@ if PLATFORM == 'gcc':
|
||||
CC = PREFIX + 'gcc'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
@@ -54,6 +57,8 @@ if PLATFORM == 'gcc':
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
elif PLATFORM == 'armcc':
|
||||
|
||||
@@ -67,10 +67,10 @@ void lv_port_disp_init(void)
|
||||
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
|
||||
|
||||
buf1 = (void *)info.framebuffer;
|
||||
rt_kprintf("LVGL: Use one buffers - buf1@%08x\n", buf1);
|
||||
rt_kprintf("LVGL: Use one buffers - buf1@%08x, size: %d bytes\n", buf1, info.smem_len);
|
||||
|
||||
/*Initialize `disp_buf` with the buffer(s).*/
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, RT_NULL, info.width * info.height);
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, RT_NULL, info.smem_len/(info.bits_per_pixel/8));
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
|
||||
@@ -64,11 +64,15 @@ menu "Hardware Drivers Config"
|
||||
config BOARD_USING_LCD_ILI9341
|
||||
bool "LCD ILI9341 (over spi1)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_SPI1
|
||||
select BSP_USING_EADC
|
||||
select BSP_USING_EADC0
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH_SW
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_SPI
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
select NU_PKG_ILI9341_HORIZONTAL
|
||||
select BSP_USING_SPI1
|
||||
select PKG_USING_LVGL
|
||||
select PKG_USING_LV_MUSIC_DEMO
|
||||
default n
|
||||
|
||||
@@ -15,30 +15,6 @@
|
||||
|
||||
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_SPI)
|
||||
#include <lcd_ili9341.h>
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
#include <rtgui/driver.h>
|
||||
#endif
|
||||
int rt_hw_ili9341_port(void)
|
||||
{
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi1") != RT_EOK)
|
||||
return -1;
|
||||
|
||||
rt_hw_lcd_ili9341_init();
|
||||
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
rt_device_t lcd_ili9341;
|
||||
lcd_ili9341 = rt_device_find("lcd");
|
||||
if (lcd_ili9341)
|
||||
{
|
||||
rtgui_graphic_set_device(lcd_ili9341);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ili9341_port);
|
||||
#endif /* BOARD_USING_LCD_ILI9341 */
|
||||
#if defined(BOARD_USING_ESP8266)
|
||||
#include <at_device_esp8266.h>
|
||||
|
||||
@@ -106,3 +82,94 @@ static void at_wifi_set(int argc, char **argv)
|
||||
#endif
|
||||
#endif /* BOARD_USING_ESP8266 */
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_SPI)
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
|
||||
#include "adc_touch.h"
|
||||
#include "touch_sw.h"
|
||||
#include "NuMicro.h"
|
||||
|
||||
#define NU_MFP_POS(PIN) ((PIN % 8) * 4)
|
||||
#define NU_MFP_MSK(PIN) (0xful << NU_MFP_POS(PIN))
|
||||
|
||||
S_CALIBRATION_MATRIX g_sCalMat = { 52, 6247, -2804852, 4917, 47, -2309716, 65536 };
|
||||
|
||||
static void nu_pin_func(rt_base_t pin, int data)
|
||||
{
|
||||
uint32_t pin_index = NU_GET_PINS(pin);
|
||||
uint32_t port_index = NU_GET_PORT(pin);
|
||||
__IO uint32_t *GPx_MFPx = ((__IO uint32_t *) &SYS->GPA_MFPL) + port_index * 2 + (pin_index / 8);
|
||||
uint32_t MFP_Msk = NU_MFP_MSK(pin_index);
|
||||
|
||||
*GPx_MFPx = (*GPx_MFPx & (~MFP_Msk)) | data;
|
||||
}
|
||||
|
||||
static void tp_switch_to_analog(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
if (pin == NU_GET_PININDEX(NU_PB, 11))
|
||||
nu_pin_func(pin, SYS_GPB_MFPH_PB11MFP_EADC0_CH11);
|
||||
else if (pin == NU_GET_PININDEX(NU_PB, 8))
|
||||
nu_pin_func(pin, SYS_GPB_MFPH_PB8MFP_EADC0_CH8);
|
||||
|
||||
GPIO_DISABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static void tp_switch_to_digital(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
nu_pin_func(pin, 0);
|
||||
|
||||
/* Enable digital path on these EADC pins */
|
||||
GPIO_ENABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static S_TOUCH_SW sADCTP =
|
||||
{
|
||||
.adc_name = "eadc0",
|
||||
.i32ADCChnYU = 11,
|
||||
.i32ADCChnXR = 8,
|
||||
.pin =
|
||||
{
|
||||
NU_GET_PININDEX(NU_PB, 10), // XL
|
||||
NU_GET_PININDEX(NU_PB, 11), // YU
|
||||
NU_GET_PININDEX(NU_PB, 8), // XR
|
||||
NU_GET_PININDEX(NU_PB, 9), // YD
|
||||
},
|
||||
.switch_to_analog = tp_switch_to_analog,
|
||||
.switch_to_digital = tp_switch_to_digital,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include <lcd_ili9341.h>
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
#include <rtgui/driver.h>
|
||||
#endif
|
||||
int rt_hw_ili9341_port(void)
|
||||
{
|
||||
if (rt_hw_lcd_ili9341_spi_init("spi1", RT_NULL) != RT_EOK)
|
||||
return -1;
|
||||
|
||||
rt_hw_lcd_ili9341_init();
|
||||
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
rt_device_t lcd_ili9341;
|
||||
lcd_ili9341 = rt_device_find("lcd");
|
||||
if (lcd_ili9341)
|
||||
{
|
||||
rtgui_graphic_set_device(lcd_ili9341);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
nu_adc_touch_sw_register(&sADCTP);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ili9341_port);
|
||||
#endif /* BOARD_USING_LCD_ILI9341 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,12 @@ import os
|
||||
# toolchains options
|
||||
ARCH='arm'
|
||||
CPU='cortex-m23'
|
||||
CROSS_TOOL='keil'
|
||||
CROSS_TOOL='gcc'
|
||||
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
@@ -25,15 +27,16 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = ''
|
||||
# BUILD = 'debug'
|
||||
|
||||
#BUILD = 'debug'
|
||||
|
||||
if PLATFORM == 'gcc':
|
||||
# tool-chains
|
||||
# toolchains
|
||||
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
@@ -54,6 +57,8 @@ if PLATFORM == 'gcc':
|
||||
else:
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
elif PLATFORM == 'armclang':
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('LVGL-port', src, depend = ['PKG_USING_LVGL'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-2-17 Wayne First version
|
||||
*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
|
||||
#define LV_USE_PERF_MONITOR 1
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
#define LV_HOR_RES_MAX (320)
|
||||
#define LV_VER_RES_MAX (240)
|
||||
|
||||
#define LV_FONT_MONTSERRAT_12 1
|
||||
#define LV_FONT_MONTSERRAT_16 1
|
||||
//#define LV_USE_DEMO_BENCHMARK 1
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 1
|
||||
#define LV_DISP_DEF_REFR_PERIOD 16
|
||||
|
||||
//#define CONFIG_LV_LOG_LEVEL LV_LOG_LEVEL_TRACE
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-17 Meco Man First version
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#define DBG_TAG "LVGL"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
#ifndef LV_THREAD_STACK_SIZE
|
||||
#define LV_THREAD_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
#ifndef LV_THREAD_PRIO
|
||||
#define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
|
||||
#endif
|
||||
|
||||
static void lvgl_thread(void *parameter)
|
||||
{
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
extern void lv_demo_benchmark(void);
|
||||
lv_demo_benchmark();
|
||||
#endif
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
extern void lv_demo_widgets(void);
|
||||
lv_demo_widgets();
|
||||
#endif
|
||||
while (1)
|
||||
{
|
||||
lv_task_handler();
|
||||
rt_thread_mdelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
static int lvgl_demo_init(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 10);
|
||||
if (tid == RT_NULL)
|
||||
{
|
||||
LOG_E("Fail to create 'LVGL' thread");
|
||||
}
|
||||
rt_thread_startup(tid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_APP_EXPORT(lvgl_demo_init);
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-12-17 Wayne The first version
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
|
||||
#define LOG_TAG "lvgl.disp"
|
||||
#define DBG_ENABLE
|
||||
#define DBG_SECTION_NAME LOG_TAG
|
||||
#define DBG_LEVEL DBG_ERROR
|
||||
#define DBG_COLOR
|
||||
#include <rtdbg.h>
|
||||
|
||||
/*A static or global variable to store the buffers*/
|
||||
static lv_disp_draw_buf_t disp_buf;
|
||||
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
|
||||
|
||||
static rt_device_t lcd_device = 0;
|
||||
static struct rt_device_graphic_info info;
|
||||
|
||||
static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
/* Rendering */
|
||||
struct rt_device_rect_info rect;
|
||||
|
||||
rect.x = area->x1;
|
||||
rect.y = area->y1;
|
||||
rect.width = area->x2 - area->x1 + 1;
|
||||
rect.height = area->y2 - area->y1 + 1;
|
||||
|
||||
rt_device_control(lcd_device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect);
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
void lcd_perf_monitor(struct _lv_disp_drv_t *disp_drv, uint32_t time, uint32_t px)
|
||||
{
|
||||
rt_kprintf("Elapsed: %dms, Pixel: %d, Bytes:%d\n", time, px, px * sizeof(lv_color_t));
|
||||
}
|
||||
|
||||
void lv_port_disp_init(void)
|
||||
{
|
||||
rt_err_t result;
|
||||
void *buf1 = RT_NULL;
|
||||
|
||||
lcd_device = rt_device_find("lcd");
|
||||
if (lcd_device == 0)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
/* get framebuffer address */
|
||||
result = rt_device_control(lcd_device, RTGRAPHIC_CTRL_GET_INFO, &info);
|
||||
if (result != RT_EOK && info.framebuffer == RT_NULL)
|
||||
{
|
||||
LOG_E("error!");
|
||||
/* get device information failed */
|
||||
return;
|
||||
}
|
||||
|
||||
RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 ||
|
||||
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
|
||||
|
||||
buf1 = (void *)info.framebuffer;
|
||||
rt_kprintf("LVGL: Use one buffers - buf1@%08x, size: %d bytes\n", buf1, info.smem_len);
|
||||
|
||||
/*Initialize `disp_buf` with the buffer(s).*/
|
||||
lv_disp_draw_buf_init(&disp_buf, buf1, RT_NULL, info.smem_len/(info.bits_per_pixel/8));
|
||||
|
||||
result = rt_device_open(lcd_device, 0);
|
||||
if (result != RT_EOK)
|
||||
{
|
||||
LOG_E("error!");
|
||||
return;
|
||||
}
|
||||
|
||||
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
|
||||
|
||||
/*Set the resolution of the display*/
|
||||
disp_drv.hor_res = info.width;
|
||||
disp_drv.ver_res = info.height;
|
||||
|
||||
/*Set a display buffer*/
|
||||
disp_drv.draw_buf = &disp_buf;
|
||||
|
||||
/*Write the internal buffer (draw_buf) to the display*/
|
||||
disp_drv.flush_cb = lcd_fb_flush;
|
||||
|
||||
/* Called after every refresh cycle to tell the rendering and flushing time + the number of flushed pixels */
|
||||
//disp_drv.monitor_cb = lcd_perf_monitor;
|
||||
|
||||
/*Finally register the driver*/
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_DISP_H
|
||||
#define LV_PORT_DISP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lv_port_disp_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
* 2021-12-17 Wayne Add input event
|
||||
*/
|
||||
#include <lvgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <rtdevice.h>
|
||||
#include "touch.h"
|
||||
|
||||
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
|
||||
static rt_int16_t last_x = 0;
|
||||
static rt_int16_t last_y = 0;
|
||||
|
||||
static void input_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data)
|
||||
{
|
||||
data->point.x = last_x;
|
||||
data->point.y = last_y;
|
||||
data->state = last_state;
|
||||
}
|
||||
|
||||
void nu_touch_inputevent_cb(rt_int16_t x, rt_int16_t y, rt_uint8_t state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case RT_TOUCH_EVENT_UP:
|
||||
last_state = LV_INDEV_STATE_RELEASED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_DOWN:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
last_state = LV_INDEV_STATE_PRESSED;
|
||||
break;
|
||||
case RT_TOUCH_EVENT_MOVE:
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_port_indev_init(void)
|
||||
{
|
||||
static lv_indev_drv_t indev_drv;
|
||||
|
||||
/* Basic initialization */
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
indev_drv.read_cb = input_read;
|
||||
|
||||
/* Register the driver in LVGL and save the created input device object */
|
||||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-18 Meco Man The first version
|
||||
*/
|
||||
#ifndef LV_PORT_INDEV_H
|
||||
#define LV_PORT_INDEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <lv_hal_indev.h>
|
||||
|
||||
extern lv_indev_t *button_indev;
|
||||
|
||||
void lv_port_indev_init(void);
|
||||
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -108,8 +108,17 @@ menu "Hardware Drivers Config"
|
||||
|
||||
config BOARD_USING_LCD_ILI9341
|
||||
bool "LCD ILI9341(over ebi0)"
|
||||
select RT_USING_TOUCH
|
||||
select BSP_USING_EADC
|
||||
select BSP_USING_EADC0
|
||||
select NU_PKG_USING_ADC_TOUCH
|
||||
select NU_PKG_USING_ADC_TOUCH_SW
|
||||
select NU_PKG_USING_ILI9341
|
||||
select NU_PKG_USING_ILI9341_EBI
|
||||
select NU_PKG_ILI9341_WITH_OFFSCREEN_FRAMEBUFFER
|
||||
select NU_PKG_ILI9341_HORIZONTAL
|
||||
select PKG_USING_LVGL
|
||||
select PKG_USING_LVGL_DEMOS
|
||||
default n
|
||||
|
||||
if BOARD_USING_LCD_ILI9341
|
||||
|
||||
@@ -208,6 +208,67 @@ INIT_APP_EXPORT(rt_hw_mpu6500_port);
|
||||
#endif /* BOARD_USING_MPU6500 */
|
||||
|
||||
#if defined(BOARD_USING_LCD_ILI9341) && defined(NU_PKG_USING_ILI9341_EBI)
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
|
||||
#include "adc_touch.h"
|
||||
#include "touch_sw.h"
|
||||
|
||||
#define NU_MFP_POS(PIN) ((PIN % 8) * 4)
|
||||
#define NU_MFP_MSK(PIN) (0xful << NU_MFP_POS(PIN))
|
||||
|
||||
S_CALIBRATION_MATRIX g_sCalMat = { -7, 6358, -3727548, 4990, 30, -2368560, 65536 };
|
||||
|
||||
static void nu_pin_func(rt_base_t pin, int data)
|
||||
{
|
||||
uint32_t pin_index = NU_GET_PINS(pin);
|
||||
uint32_t port_index = NU_GET_PORT(pin);
|
||||
__IO uint32_t *GPx_MFPx = ((__IO uint32_t *) &SYS->GPA_MFPL) + port_index * 2 + (pin_index / 8);
|
||||
uint32_t MFP_Msk = NU_MFP_MSK(pin_index);
|
||||
|
||||
*GPx_MFPx = (*GPx_MFPx & (~MFP_Msk)) | data;
|
||||
}
|
||||
|
||||
static void tp_switch_to_analog(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
if (pin == NU_GET_PININDEX(NU_PB, 8))
|
||||
nu_pin_func(pin, SYS_GPB_MFPH_PB8MFP_EADC0_CH8);
|
||||
else if (pin == NU_GET_PININDEX(NU_PB, 9))
|
||||
nu_pin_func(pin, SYS_GPB_MFPH_PB9MFP_EADC0_CH9);
|
||||
|
||||
GPIO_DISABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static void tp_switch_to_digital(rt_base_t pin)
|
||||
{
|
||||
GPIO_T *port = (GPIO_T *)(GPIOA_BASE + (0x40) * NU_GET_PORT(pin));
|
||||
|
||||
nu_pin_func(pin, 0);
|
||||
|
||||
/* Enable digital path on these EADC pins */
|
||||
GPIO_ENABLE_DIGITAL_PATH(port, NU_GET_PIN_MASK(NU_GET_PINS(pin)));
|
||||
}
|
||||
|
||||
static S_TOUCH_SW sADCTP =
|
||||
{
|
||||
.adc_name = "eadc0",
|
||||
.i32ADCChnYU = 8,
|
||||
.i32ADCChnXR = 9,
|
||||
.pin =
|
||||
{
|
||||
NU_GET_PININDEX(NU_PH, 4), // XL
|
||||
NU_GET_PININDEX(NU_PB, 8), // YU
|
||||
NU_GET_PININDEX(NU_PB, 9), // XR
|
||||
NU_GET_PININDEX(NU_PH, 5), // YD
|
||||
},
|
||||
.switch_to_analog = tp_switch_to_analog,
|
||||
.switch_to_digital = tp_switch_to_digital,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#include <lcd_ili9341.h>
|
||||
#if defined(PKG_USING_GUIENGINE)
|
||||
#include <rtgui/driver.h>
|
||||
@@ -253,6 +314,10 @@ int rt_hw_ili9341_port(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NU_PKG_USING_ADC_TOUCH_SW)
|
||||
nu_adc_touch_sw_register(&sADCTP);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_ili9341_port);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,12 @@ import os
|
||||
# toolchains options
|
||||
ARCH='arm'
|
||||
CPU='cortex-m4'
|
||||
CROSS_TOOL='keil'
|
||||
CROSS_TOOL='gcc'
|
||||
|
||||
if os.getenv('RTT_CC'):
|
||||
CROSS_TOOL = os.getenv('RTT_CC')
|
||||
if os.getenv('RTT_ROOT'):
|
||||
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||
|
||||
# cross_tool provides the cross compiler
|
||||
# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR
|
||||
@@ -25,39 +27,37 @@ if os.getenv('RTT_EXEC_PATH'):
|
||||
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||
|
||||
BUILD = ''
|
||||
# BUILD = 'debug'
|
||||
|
||||
#BUILD = 'debug'
|
||||
|
||||
if PLATFORM == 'gcc':
|
||||
# toolchains
|
||||
|
||||
PREFIX = 'arm-none-eabi-'
|
||||
CC = PREFIX + 'gcc'
|
||||
AS = PREFIX + 'gcc'
|
||||
AR = PREFIX + 'ar'
|
||||
LINK = PREFIX + 'g++'
|
||||
CXX = PREFIX + 'g++'
|
||||
LINK = PREFIX + 'gcc'
|
||||
TARGET_EXT = 'elf'
|
||||
SIZE = PREFIX + 'size'
|
||||
OBJDUMP = PREFIX + 'objdump'
|
||||
OBJCPY = PREFIX + 'objcopy'
|
||||
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -Wuninitialized'
|
||||
|
||||
if BUILD == 'debug':
|
||||
DEVICE = DEVICE + ' -DDEBUG'
|
||||
|
||||
CFLAGS = DEVICE
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
|
||||
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map -T ./linking_scripts/m480_link.ld '
|
||||
DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections'
|
||||
CFLAGS = DEVICE + ' -Dgcc'
|
||||
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
|
||||
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T ./linking_scripts/m480_link.ld '
|
||||
|
||||
CPATH = ''
|
||||
LPATH = ''
|
||||
|
||||
if BUILD == 'debug':
|
||||
CFLAGS += ' -O0 -gdwarf-2'
|
||||
CFLAGS += ' -O0 -gdwarf-2 -g'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
else:
|
||||
CFLAGS += ' -O2 -gdwarf-2'
|
||||
AFLAGS += ' -gdwarf-2'
|
||||
CFLAGS += ' -O2'
|
||||
|
||||
CXXFLAGS = CFLAGS
|
||||
|
||||
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
|
||||
|
||||
|
||||
@@ -40,14 +40,6 @@
|
||||
|
||||
#define LIST_FIND_OBJ_NR 8
|
||||
|
||||
long hello(void)
|
||||
{
|
||||
rt_kprintf("Hello RT-Thread!\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(hello, say hello world);
|
||||
|
||||
static long clear(void)
|
||||
{
|
||||
rt_kprintf("\x1b[2J\x1b[H");
|
||||
@@ -886,28 +878,4 @@ long list_device(void)
|
||||
MSH_CMD_EXPORT(list_device, list device in system);
|
||||
#endif
|
||||
|
||||
long list(void)
|
||||
{
|
||||
rt_kprintf("--Commands List:\n");
|
||||
{
|
||||
struct finsh_syscall *index;
|
||||
for (index = _syscall_table_begin;
|
||||
index < _syscall_table_end;
|
||||
FINSH_NEXT_SYSCALL(index))
|
||||
{
|
||||
/* skip the internal command */
|
||||
if (strncmp((char *)index->name, "__", 2) == 0) continue;
|
||||
|
||||
#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
|
||||
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
||||
#else
|
||||
rt_kprintf("%s\n", index->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(list, list all commands in system)
|
||||
|
||||
#endif /* RT_USING_FINSH */
|
||||
|
||||
@@ -5,6 +5,13 @@ menuconfig RT_USING_LWIP
|
||||
default n
|
||||
|
||||
if RT_USING_LWIP
|
||||
config RT_USING_LWIP_LOCAL_VERSION
|
||||
bool "Use LwIP local version only"
|
||||
default n
|
||||
help
|
||||
If don't select this option, both local version and upstream
|
||||
version can be selected. If select this option, only local version
|
||||
can be selected.
|
||||
choice
|
||||
prompt "lwIP version"
|
||||
default RT_USING_LWIP203
|
||||
@@ -20,10 +27,17 @@ if RT_USING_LWIP
|
||||
config RT_USING_LWIP212
|
||||
bool "lwIP v2.1.2"
|
||||
|
||||
# online version
|
||||
if !RT_USING_LWIP_LOCAL_VERSION
|
||||
config RT_USING_LWIP_LATEST
|
||||
bool "lwIP latest"
|
||||
select PKG_USING_LWIP
|
||||
endif
|
||||
endchoice
|
||||
|
||||
config RT_USING_LWIP_VER_NUM
|
||||
hex
|
||||
default 0x99999 if RT_USING_LWIP_LATEST
|
||||
default 0x20102 if RT_USING_LWIP212
|
||||
default 0x20003 if RT_USING_LWIP203
|
||||
default 0x10401 if RT_USING_LWIP141
|
||||
|
||||
@@ -1151,6 +1151,7 @@ struct rt_device_graphic_info
|
||||
rt_uint16_t height; /**< height of graphic device */
|
||||
|
||||
rt_uint8_t *framebuffer; /**< frame buffer */
|
||||
rt_uint32_t smem_len; /**< allocated frame buffer size */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
|
||||
/* Watch Dog registers */
|
||||
#define WDT_EN HWREG32(WDT_BASE + 0x00)
|
||||
#define WDT_SET HWREG32(WDT_BASE + 0x04)
|
||||
#define WDT_TIMER HWREG32(WDT_BASE + 0x08)
|
||||
#define WDT_SET HWREG32(WDT_BASE + 0x08)
|
||||
#define WDT_TIMER HWREG32(WDT_BASE + 0x04)
|
||||
|
||||
#define PLL_FREQ HWREG32(0xbfe78030)
|
||||
#define PLL_DIV_PARAM HWREG32(0xbfe78034)
|
||||
|
||||
Reference in New Issue
Block a user