linum-stm32h753bi: Add support to RTC and alarm

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2023-11-18 09:09:01 -03:00 committed by Alan Carvalho de Assis
parent 2cf56e0fb3
commit 46b8b057da
3 changed files with 49 additions and 0 deletions

View File

@ -25,9 +25,11 @@ CONFIG_BOARD_LOOPSPERMSEC=43103
CONFIG_BUILTIN=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_EXAMPLES_ALARM=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INTELHEX_BINARY=y
CONFIG_MM_REGIONS=4
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
@ -37,10 +39,15 @@ CONFIG_RAM_SIZE=245760
CONFIG_RAM_START=0x20010000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_RTC_ALARM=y
CONFIG_RTC_DATETIME=y
CONFIG_RTC_DRIVER=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=6
CONFIG_START_MONTH=12
CONFIG_START_YEAR=2011
CONFIG_STM32H7_PWR=y
CONFIG_STM32H7_RTC=y
CONFIG_STM32H7_USART1=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0

View File

@ -49,6 +49,13 @@
#define GPIO_LED_GREEN GPIO_LD2
#define GPIO_LED_BLUE GPIO_LD3
/* Check if we can support the RTC driver */
#define HAVE_RTC_DRIVER 1
#if !defined(CONFIG_RTC) || !defined(CONFIG_RTC_DRIVER)
# undef HAVE_RTC_DRIVER
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View File

@ -39,6 +39,11 @@
#include <nuttx/leds/userled.h>
#endif
#ifdef HAVE_RTC_DRIVER
# include <nuttx/timers/rtc.h>
# include "stm32_rtc.h"
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@ -68,6 +73,10 @@ int stm32_bringup(void)
UNUSED(ret);
#ifdef HAVE_RTC_DRIVER
struct rtc_lowerhalf_s *lower;
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
@ -89,5 +98,31 @@ int stm32_bringup(void)
}
#endif
#ifdef HAVE_RTC_DRIVER
/* Instantiate the STM32 lower-half RTC driver */
lower = stm32_rtc_lowerhalf();
if (!lower)
{
syslog(LOG_ERR,
"ERROR: Failed to instantiate the RTC lower-half driver\n");
return -ENOMEM;
}
else
{
/* Bind the lower half driver and register the combined RTC driver
* as /dev/rtc0
*/
ret = rtc_initialize(0, lower);
if (ret < 0)
{
syslog(LOG_ERR,
"ERROR: Failed to bind/register the RTC driver: %d\n", ret);
return ret;
}
}
#endif
return OK;
}