This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 46b8b057da linum-stm32h753bi: Add support to RTC and alarm
46b8b057da is described below

commit 46b8b057da0bbed95b5f38d49a389982295b9ed8
Author: Jorge Guzman <[email protected]>
AuthorDate: Sat Nov 18 09:09:01 2023 -0300

    linum-stm32h753bi: Add support to RTC and alarm
    
    Signed-off-by: Jorge Guzman <[email protected]>
---
 .../linum-stm32h753bi/configs/nsh/defconfig        |  7 +++++
 .../linum-stm32h753bi/src/linum-stm32h753bi.h      |  7 +++++
 .../stm32h7/linum-stm32h753bi/src/stm32_bringup.c  | 35 ++++++++++++++++++++++
 3 files changed, 49 insertions(+)

diff --git a/boards/arm/stm32h7/linum-stm32h753bi/configs/nsh/defconfig 
b/boards/arm/stm32h7/linum-stm32h753bi/configs/nsh/defconfig
index a3b5302571..4f218ce3f4 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/configs/nsh/defconfig
+++ b/boards/arm/stm32h7/linum-stm32h753bi/configs/nsh/defconfig
@@ -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
diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h 
b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
index 7e117cbab5..d0330cc10f 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
+++ b/boards/arm/stm32h7/linum-stm32h753bi/src/linum-stm32h753bi.h
@@ -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
  ****************************************************************************/
diff --git a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c 
b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c
index 1e388ff51d..5987ccdab7 100644
--- a/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c
+++ b/boards/arm/stm32h7/linum-stm32h753bi/src/stm32_bringup.c
@@ -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;
 }

Reply via email to