You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/11/05 01:44:02 UTC
incubator-mynewt-core git commit: MYNEWT-403;
fill in hal_reset_cause() for STM32F4.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop f55051b2c -> 383dee40c
MYNEWT-403; fill in hal_reset_cause() for STM32F4.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/383dee40
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/383dee40
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/383dee40
Branch: refs/heads/develop
Commit: 383dee40cbc16f0deedd2a14a3ddefb15f5235bc
Parents: f55051b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Nov 4 18:34:07 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Nov 4 18:38:39 2016 -0700
----------------------------------------------------------------------
hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c | 27 +++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/383dee40/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c b/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c
index 66722c3..3bf3521 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_reset_cause.c
@@ -16,10 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-#include "hal/hal_system.h"
+#include <hal/hal_system.h>
+
+#include "stm32f4xx_hal_def.h"
enum hal_reset_reason
hal_reset_cause(void)
{
- return HAL_RESET_POR;
+ static enum hal_reset_reason reason;
+ uint32_t reg;
+
+ if (reason) {
+ return reason;
+ }
+
+ reg = RCC->CSR;
+
+ if (reg & (RCC_CSR_WDGRSTF | RCC_CSR_WWDGRSTF)) {
+ reason = HAL_RESET_WATCHDOG;
+ } else if (reg & RCC_CSR_SFTRSTF) {
+ reason = HAL_RESET_SOFT;
+ } else if (reg & RCC_CSR_PADRSTF) {
+ reason = HAL_RESET_PIN;
+ } else if (reg & RCC_CSR_BORRSTF) {
+ reason = HAL_RESET_BROWNOUT;
+ } else {
+ reason = HAL_RESET_POR;
+ }
+ RCC->CSR |= RCC_CSR_RMVF;
+ return reason;
}