TimJTi commented on code in PR #16303: URL: https://github.com/apache/nuttx/pull/16303#discussion_r2072681120
########## 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 I have traced this through and it's consistent..NXboot calls a BOARDIOCTL to get the reset cause and by definition that is handled at board level. It is the board function that translates the arch-specific reset reason to the higher level generic functions that you identified. So, I think my original code/method *was* right (and is why I was able to test it using NXboot as the translation to the generalised names was being done by my board code). Are you Ok if I revert my too-hastily pushed code changes back to how I initially submitted this PR? -- 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