Skip to content

Commit

Permalink
[nuvoton] Update drivers and project setting. (#5726)
Browse files Browse the repository at this point in the history
  • Loading branch information
wosayttn authored Mar 28, 2022
1 parent 66d5101 commit 7fee653
Show file tree
Hide file tree
Showing 41 changed files with 2,160 additions and 2,065 deletions.
30 changes: 16 additions & 14 deletions bsp/nuvoton/libraries/m031/rtt_port/drv_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

/* rtc date upper bound reaches the year of 2099. */
#define RTC_TM_UPPER_BOUND \
{ .tm_year = CONV_TO_TM_YEAR(2099), \
.tm_mon = CONV_TO_TM_MON(12), \
.tm_mday = 31, \
.tm_hour = 23, \
.tm_min = 59, \
.tm_sec = 59, \
{ .tm_year = CONV_TO_TM_YEAR(2038), \
.tm_mon = CONV_TO_TM_MON(1), \
.tm_mday = 19, \
.tm_hour = 3, \
.tm_min = 14, \
.tm_sec = 07, \
}

/* rtc date lower bound reaches the year of 2000. */
Expand All @@ -57,8 +57,8 @@ static rt_size_t nu_rtc_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_siz
static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
#endif

static rt_err_t nu_rtc_is_date_valid(const time_t *const t);
static void nu_rtc_init(void);
static rt_err_t nu_rtc_is_date_valid(const time_t t);
static rt_err_t nu_rtc_init(void);

#if defined(RT_USING_ALARM)
static void nu_rtc_alarm_reset(void);
Expand All @@ -74,7 +74,7 @@ extern rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t secon
static struct rt_device device_rtc;


static void nu_rtc_init(void)
static rt_err_t nu_rtc_init(void)
{
/* hw rtc initialise */
RTC_Open(NULL);
Expand All @@ -86,6 +86,8 @@ static void nu_rtc_init(void)
RTC_EnableInt(RTC_INTEN_ALMIEN_Msk);
NVIC_EnableIRQ(RTC_IRQn);
#endif

return RT_EOK;
}


Expand Down Expand Up @@ -173,7 +175,7 @@ static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer,
#endif


static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
static rt_err_t nu_rtc_is_date_valid(const time_t t)
{
static struct tm tm_upper = RTC_TM_UPPER_BOUND;
static struct tm tm_lower = RTC_TM_LOWER_BOUND;
Expand All @@ -188,7 +190,7 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
}

/* check the date is supported by rtc. */
if ((*t > t_upper) || (*t < t_lower))
if ((t > t_upper) || (t < t_lower))
return -(RT_EINVAL);

return RT_EOK;
Expand Down Expand Up @@ -230,11 +232,11 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
case RT_DEVICE_CTRL_RTC_SET_TIME:

time = (time_t *) args;
tm_in = gmtime(time);

if (nu_rtc_is_date_valid(time) != RT_EOK)
return RT_ERROR;
if (nu_rtc_is_date_valid(*time) != RT_EOK)
return -(RT_ERROR);

tm_in = gmtime(time);
hw_time.u32Year = CONV_FROM_TM_YEAR(tm_in->tm_year);
hw_time.u32Month = CONV_FROM_TM_MON(tm_in->tm_mon);
hw_time.u32Day = tm_in->tm_mday;
Expand Down
30 changes: 16 additions & 14 deletions bsp/nuvoton/libraries/m2354/rtt_port/drv_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

/* rtc date upper bound reaches the year of 2099. */
#define RTC_TM_UPPER_BOUND \
{ .tm_year = CONV_TO_TM_YEAR(2099), \
.tm_mon = CONV_TO_TM_MON(12), \
.tm_mday = 31, \
.tm_hour = 23, \
.tm_min = 59, \
.tm_sec = 59, \
{ .tm_year = CONV_TO_TM_YEAR(2038), \
.tm_mon = CONV_TO_TM_MON(1), \
.tm_mday = 19, \
.tm_hour = 3, \
.tm_min = 14, \
.tm_sec = 07, \
}

/* rtc date lower bound reaches the year of 2000. */
Expand All @@ -57,8 +57,8 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args);
static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
#endif

static rt_err_t nu_rtc_is_date_valid(const time_t *const t);
static void nu_rtc_init(void);
static rt_err_t nu_rtc_is_date_valid(const time_t t);
static rt_err_t nu_rtc_init(void);

#if defined(RT_USING_ALARM)
static void nu_rtc_alarm_reset(void);
Expand All @@ -74,7 +74,7 @@ static void nu_rtc_init(void);
static struct rt_device device_rtc;


static void nu_rtc_init(void)
static rt_err_t nu_rtc_init(void)
{
/* hw rtc initialise */
RTC_Open(NULL);
Expand All @@ -89,6 +89,8 @@ static void nu_rtc_init(void)
RTC_EnableInt(RTC_INTEN_ALMIEN_Msk);
NVIC_EnableIRQ(RTC_IRQn);
#endif

return RT_EOK;
}


Expand Down Expand Up @@ -176,7 +178,7 @@ static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer,
#endif


static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
static rt_err_t nu_rtc_is_date_valid(const time_t t)
{
static struct tm tm_upper = RTC_TM_UPPER_BOUND;
static struct tm tm_lower = RTC_TM_LOWER_BOUND;
Expand All @@ -191,7 +193,7 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
}

/* check the date is supported by rtc. */
if ((*t > t_upper) || (*t < t_lower))
if ((t > t_upper) || (t < t_lower))
return -(RT_EINVAL);

return RT_EOK;
Expand Down Expand Up @@ -233,11 +235,11 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
case RT_DEVICE_CTRL_RTC_SET_TIME:

time = (time_t *) args;
tm_in = gmtime(time);

if (nu_rtc_is_date_valid(time) != RT_EOK)
return RT_ERROR;
if (nu_rtc_is_date_valid(*time) != RT_EOK)
return -(RT_ERROR);

tm_in = gmtime(time);
hw_time.u32Year = CONV_FROM_TM_YEAR(tm_in->tm_year);
hw_time.u32Month = CONV_FROM_TM_MON(tm_in->tm_mon);
hw_time.u32Day = tm_in->tm_mday;
Expand Down
30 changes: 16 additions & 14 deletions bsp/nuvoton/libraries/m480/rtt_port/drv_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@

/* rtc date upper bound reaches the year of 2099. */
#define RTC_TM_UPPER_BOUND \
{ .tm_year = CONV_TO_TM_YEAR(2099), \
.tm_mon = CONV_TO_TM_MON(12), \
.tm_mday = 31, \
.tm_hour = 23, \
.tm_min = 59, \
.tm_sec = 59, \
{ .tm_year = CONV_TO_TM_YEAR(2038), \
.tm_mon = CONV_TO_TM_MON(1), \
.tm_mday = 19, \
.tm_hour = 3, \
.tm_min = 14, \
.tm_sec = 07, \
}

/* rtc date lower bound reaches the year of 2000. */
Expand All @@ -57,8 +57,8 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args);
static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
#endif

static rt_err_t nu_rtc_is_date_valid(const time_t *const t);
static void nu_rtc_init(void);
static rt_err_t nu_rtc_is_date_valid(const time_t t);
static rt_err_t nu_rtc_init(void);

#if defined(RT_USING_ALARM)
static void nu_rtc_alarm_reset(void);
Expand All @@ -74,7 +74,7 @@ static void nu_rtc_init(void);
static struct rt_device device_rtc;


static void nu_rtc_init(void)
static rt_err_t nu_rtc_init(void)
{
/* hw rtc initialise */
RTC_Open(NULL);
Expand All @@ -88,6 +88,8 @@ static void nu_rtc_init(void)
RTC_EnableInt(RTC_INTEN_ALMIEN_Msk);
NVIC_EnableIRQ(RTC_IRQn);
#endif

return RT_EOK;
}


Expand Down Expand Up @@ -175,7 +177,7 @@ static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer,
#endif


static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
static rt_err_t nu_rtc_is_date_valid(const time_t t)
{
static struct tm tm_upper = RTC_TM_UPPER_BOUND;
static struct tm tm_lower = RTC_TM_LOWER_BOUND;
Expand All @@ -190,7 +192,7 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
}

/* check the date is supported by rtc. */
if ((*t > t_upper) || (*t < t_lower))
if ((t > t_upper) || (t < t_lower))
return -(RT_EINVAL);

return RT_EOK;
Expand Down Expand Up @@ -232,11 +234,11 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
case RT_DEVICE_CTRL_RTC_SET_TIME:

time = (time_t *) args;
tm_in = gmtime(time);

if (nu_rtc_is_date_valid(time) != RT_EOK)
return RT_ERROR;
if (nu_rtc_is_date_valid(*time) != RT_EOK)
return -(RT_ERROR);

tm_in = gmtime(time);
hw_time.u32Year = CONV_FROM_TM_YEAR(tm_in->tm_year);
hw_time.u32Month = CONV_FROM_TM_MON(tm_in->tm_mon);
hw_time.u32Day = tm_in->tm_mday;
Expand Down
2 changes: 2 additions & 0 deletions bsp/nuvoton/libraries/n9h30/Script/InitDDR2.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LOAD %L INCREMENTAL
$ = 0
12 changes: 12 additions & 0 deletions bsp/nuvoton/libraries/n9h30/Script/N9H30.sct
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


LR_IROM1 0x00000000 { ; load region size_region
ER_IROM1 0x00000000 { ; load address = execution address
*.o (NUC_INIT, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_RAM1 +0 { ; RW_RAM1 start address is after ER_ROM1
.ANY (+RW +ZI)
}
}
28 changes: 15 additions & 13 deletions bsp/nuvoton/libraries/n9h30/rtt_port/drv_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

/* rtc date upper bound reaches the year of 2099. */
#define RTC_TM_UPPER_BOUND \
{ .tm_year = CONV_TO_TM_YEAR(2099), \
.tm_mon = CONV_TO_TM_MON(12), \
.tm_mday = 31, \
.tm_hour = 23, \
.tm_min = 59, \
.tm_sec = 59, \
{ .tm_year = CONV_TO_TM_YEAR(2038), \
.tm_mon = CONV_TO_TM_MON(1), \
.tm_mday = 19, \
.tm_hour = 3, \
.tm_min = 14, \
.tm_sec = 07, \
}

/* rtc date lower bound reaches the year of 2000. */
Expand All @@ -58,8 +58,8 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args);
static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
#endif

static rt_err_t nu_rtc_is_date_valid(const time_t *const t);
static void nu_rtc_init(void);
static rt_err_t nu_rtc_is_date_valid(const time_t t);
static rt_err_t nu_rtc_init(void);

#if defined(RT_USING_ALARM)
static void nu_rtc_alarm_reset(void);
Expand All @@ -76,7 +76,7 @@ static void nu_rtc_init(void);
static struct rt_device device_rtc;


static void nu_rtc_init(void)
static rt_err_t nu_rtc_init(void)
{
S_RTC_TIME_DATA_T sInitTime = {0};

Expand Down Expand Up @@ -114,6 +114,8 @@ static void nu_rtc_init(void)
rt_hw_interrupt_umask(IRQ_RTC);

#endif

return RT_EOK;
}


Expand Down Expand Up @@ -194,7 +196,7 @@ static rt_size_t nu_rtc_write(rt_device_t dev, rt_off_t pos, const void *buffer,
#endif


static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
static rt_err_t nu_rtc_is_date_valid(const time_t t)
{
static struct tm tm_upper = RTC_TM_UPPER_BOUND;
static struct tm tm_lower = RTC_TM_LOWER_BOUND;
Expand All @@ -209,7 +211,7 @@ static rt_err_t nu_rtc_is_date_valid(const time_t *const t)
}

/* check the date is supported by rtc. */
if ((*t > t_upper) || (*t < t_lower))
if ((t > t_upper) || (t < t_lower))
return -(RT_EINVAL);

return RT_EOK;
Expand Down Expand Up @@ -255,11 +257,11 @@ static rt_err_t nu_rtc_control(rt_device_t dev, int cmd, void *args)
case RT_DEVICE_CTRL_RTC_SET_TIME:

time = (time_t *) args;
tm_in = gmtime(time);

if (nu_rtc_is_date_valid(time) != RT_EOK)
if (nu_rtc_is_date_valid(*time) != RT_EOK)
return -(RT_ERROR);

tm_in = gmtime(time);
hw_time.u32Year = CONV_FROM_TM_YEAR(tm_in->tm_year);
hw_time.u32cMonth = CONV_FROM_TM_MON(tm_in->tm_mon);
hw_time.u32cDay = tm_in->tm_mday;
Expand Down
21 changes: 17 additions & 4 deletions bsp/nuvoton/libraries/nu_packages/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,29 @@ menu "Nuvoton Packages Config"

endif

config NU_PKG_USING_ILI_TPC
bool "ILI Series TPC"
config NU_PKG_USING_TPC
bool "Support Touch Panel Controller over I2C"
select RT_USING_TOUCH
select RT_TOUCH_PIN_IRQ
select RT_USING_I2C
select BSP_USING_I2C
default n

if NU_PKG_USING_TPC
choice
prompt "Select TPC drivers"
config NU_PKG_USING_TPC_ILI
bool "ILI Series TPC"
default n

config NU_PKG_USING_TPC_GT911
bool "GT911 TPC"
default n
endchoice
endif

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
Expand Down
3 changes: 3 additions & 0 deletions bsp/nuvoton/libraries/nu_packages/SSD1963/lcd_ssd1963.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#endif

#define ssd1963_delay_ms(ms) rt_thread_mdelay(ms)
static void ssd1963_fillscreen(rt_uint16_t color);

static struct rt_device_graphic_info g_SSD1963Info =
{
Expand Down Expand Up @@ -125,6 +126,8 @@ static rt_err_t ssd1963_lcd_init(rt_device_t dev)
ssd1963_send_cmd(0x29); //SET display on
ssd1963_delay_ms(5);

ssd1963_fillscreen(0);

SET_DISP_ON;

SET_BACKLIGHT_ON;
Expand Down
Loading

0 comments on commit 7fee653

Please sign in to comment.