TimJTi commented on code in PR #16303:
URL: https://github.com/apache/nuttx/pull/16303#discussion_r2072365026


##########
arch/arm/src/sama5/sam_systemreset.c:
##########
@@ -35,13 +35,63 @@
 
 #include "arm_internal.h"
 #include "hardware/sam_rstc.h"
+#include "sam_systemreset.h"
 
 #ifdef CONFIG_SAMA5_SYSTEMRESET
 
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: sam_get_reset_cause
+ *
+ * Description:
+ *   Get cause of the last CPU reset. This is done by reading reset status
+ *   registger.
+ *
+ * Returned Value:
+ *   CPU reset cause in form of macros defined in sam_systemreset.h. This is
+ *   to avoid passing boardctl dependent structure to architecture layer.
+ *   Board level specific code should include sam_systemreset.h and set
+ *   boardctl result according to that. -1 is returned in case of invalid
+ *   value in status register.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARDCTL_RESET_CAUSE
+int sam_get_reset_cause(void)
+{
+  int ret;
+  uint32_t rstsr;
+
+  rstsr = getreg32(SAM_RSTC_SR);
+  switch (rstsr & RSTC_SR_RSTTYP_MASK)
+    {
+      case RSTC_SR_RSTTYP_PWRUP:
+        ret = SAMA5_RESET_PWRUP;

Review Comment:
   @xiaoxiang781216 Yes,  I think you're correct. I had searched for instance 
of `board_reset_cause` and only found 1 anywhere, for samv7 so took a copy and 
modified for SAMA5. Since it was to use with NXboot I *really* should have 
spotted that the enum names were different!
   
   I will change it, retest, and push again. I'll mark it back as draft for now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to