Skip to content

Commit

Permalink
hal: nuvoton: add NuMaker RTC controller driver
Browse files Browse the repository at this point in the history
To add RTC controller into CMakeList for M46x and M2l31x.
To update M46x rtc.c to fix unused variable warning.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
  • Loading branch information
cyliangtw authored and fabiobaltieri committed Apr 30, 2024
1 parent 34efb92 commit ab342e6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion m2l31x/Devices/M2L31/Include/system_M2L31.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
/*----------------------------------------------------------------------------
Define clocks
*----------------------------------------------------------------------------*/
#define __HXT (32000000UL) //(12000000UL) /*!< External Crystal Clock Frequency */
#define __HXT (12000000UL) /*!< External Crystal Clock Frequency */
#define __LIRC ( 32000UL) /*!< Internal 32.0KHz RC Oscillator Frequency */
#define __HIRC (12000000UL) /*!< Internal 48M RC Oscillator Frequency */
#define __HIRC48 (48000000UL) /*!< Internal 48M RC Oscillator Frequency */
Expand Down
1 change: 1 addition & 0 deletions m2l31x/StdDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_PWM src/epwm.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_USBD src/usbd.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_CANFD src/canfd.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_ADC src/eadc.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_RTC src/rtc.c)
1 change: 1 addition & 0 deletions m46x/StdDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_ETH drv_emac/synopGMAC_Dev.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_ETH drv_emac/synopGMAC_network_interface.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_CANFD src/canfd.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_ADC src/eadc.c)
zephyr_library_sources_ifdef(CONFIG_HAS_NUMAKER_RTC src/rtc.c)
11 changes: 8 additions & 3 deletions m46x/StdDriver/src/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1067,10 +1067,15 @@ uint32_t RTC_SetClockSource(uint32_t u32ClkSrc)
}
else
{
/* Set the default RTC clock source is LIRC */
RTC->LXTCTL |= RTC_LXTCTL_RTCCKSEL_Msk;
/* Load LIRC32 trim setting */
RTC->LXTCTL = ((RTC->LXTCTL & ~(0x1FFul << 16)) | ((u32TrimDefault & 0x1FFul) << 16));

return RTC_CLOCK_SOURCE_LIRC;
/* RTC clock source is LIRC32K */
RTC->LXTCTL |= RTC_LXTCTL_LIRC32KEN_Msk;
RTC->LXTCTL &= ~RTC_LXTCTL_RTCCKSEL_Msk;
RTC->LXTCTL |= RTC_LXTCTL_C32KSEL_Msk;

return (RTC_CLOCK_SOURCE_LIRC + 1);
}
}

Expand Down

0 comments on commit ab342e6

Please sign in to comment.