dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_reset.c
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 
30 /* Project Includes */
31 #include "pios.h"
32 
33 #include "pios_reset.h"
34 
35 void PIOS_RESET_Clear()
36 {
37  RCC_ClearFlag();
38 }
39 
40 int16_t PIOS_RESET_GetResetReason (void)
41 {
42  uint8_t reboot_reason = PIOS_RESET_FLAG_UNDEFINED;
43 
44  // ****************************************************** //
45  // The order of these checks is important. DO NOT CHANGE. //
46  // ****************************************************** //
47  if(RCC_GetFlagStatus(RCC_FLAG_PORRST) == SET) { // Check #1
48  reboot_reason = PIOS_RESET_FLAG_POWERON;
49  } else if(RCC_GetFlagStatus(RCC_FLAG_SFTRST) == SET) { // Check #2
50  reboot_reason = PIOS_RESET_FLAG_SOFTWARE;
51  } else if(RCC_GetFlagStatus(RCC_FLAG_IWDGRST) == SET) { // Check #3
53  } else if(RCC_GetFlagStatus(RCC_FLAG_WWDGRST) == SET) { // Check #4
54  reboot_reason = PIOS_RESET_FLAG_WINDOW_WATCHDOG;
55  } else if(RCC_GetFlagStatus(RCC_FLAG_LPWRRST) == SET) { // Check #5
56  reboot_reason = PIOS_RESET_FLAG_LOW_POWER;
57  } else if(RCC_GetFlagStatus(RCC_FLAG_PINRST) == SET) { // Check #6. This MUST be last. This because the reset circuit works internally by triggering the NRST pin. See STM32 RCC docs.
58  reboot_reason = PIOS_RESET_FLAG_PIN;
59  }
60 
61  return reboot_reason;
62 }
Main PiOS header to include all the compiled in PiOS options.
int16_t PIOS_RESET_GetResetReason(void)
PIOS_RESET_GetResetReason Does nothing on POSIX systems.
Definition: pios_reset.c:47
Reset information.
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.
Definition: pios_reset.c:38