mbed-os5 only for TYBLE16
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
drivers/source/ResetReason.cpp@1:9db0e321a9f4, 2019-12-31 (annotated)
- Committer:
- kenjiArai
- Date:
- Tue Dec 31 06:02:27 2019 +0000
- Revision:
- 1:9db0e321a9f4
- Parent:
- drivers/ResetReason.cpp@0:5b88d5760320
updated based on mbed-os5.15.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 0:5b88d5760320 | 1 | /* |
kenjiArai | 0:5b88d5760320 | 2 | * Copyright (c) 2018-2019 Arm Limited and affiliates. |
kenjiArai | 0:5b88d5760320 | 3 | * SPDX-License-Identifier: Apache-2.0 |
kenjiArai | 0:5b88d5760320 | 4 | * |
kenjiArai | 0:5b88d5760320 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kenjiArai | 0:5b88d5760320 | 6 | * you may not use this file except in compliance with the License. |
kenjiArai | 0:5b88d5760320 | 7 | * You may obtain a copy of the License at |
kenjiArai | 0:5b88d5760320 | 8 | * |
kenjiArai | 0:5b88d5760320 | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
kenjiArai | 0:5b88d5760320 | 10 | * |
kenjiArai | 0:5b88d5760320 | 11 | * Unless required by applicable law or agreed to in writing, software |
kenjiArai | 0:5b88d5760320 | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
kenjiArai | 0:5b88d5760320 | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kenjiArai | 0:5b88d5760320 | 14 | * See the License for the specific language governing permissions and |
kenjiArai | 0:5b88d5760320 | 15 | * limitations under the License. |
kenjiArai | 0:5b88d5760320 | 16 | */ |
kenjiArai | 0:5b88d5760320 | 17 | |
kenjiArai | 0:5b88d5760320 | 18 | #include "ResetReason.h" |
kenjiArai | 0:5b88d5760320 | 19 | |
kenjiArai | 0:5b88d5760320 | 20 | #ifdef DEVICE_RESET_REASON |
kenjiArai | 0:5b88d5760320 | 21 | |
kenjiArai | 0:5b88d5760320 | 22 | namespace mbed { |
kenjiArai | 0:5b88d5760320 | 23 | |
kenjiArai | 0:5b88d5760320 | 24 | reset_reason_t ResetReason::get() |
kenjiArai | 0:5b88d5760320 | 25 | { |
kenjiArai | 0:5b88d5760320 | 26 | // Store the reason statically so it can be accessed after the first call to |
kenjiArai | 0:5b88d5760320 | 27 | // this function resets it. |
kenjiArai | 0:5b88d5760320 | 28 | const static reset_reason_t reason = hal_reset_reason_get(); |
kenjiArai | 0:5b88d5760320 | 29 | |
kenjiArai | 0:5b88d5760320 | 30 | // Call get raw to cache the reset reason before clearing the registers. |
kenjiArai | 0:5b88d5760320 | 31 | ResetReason::get_raw(); |
kenjiArai | 0:5b88d5760320 | 32 | |
kenjiArai | 0:5b88d5760320 | 33 | hal_reset_reason_clear(); |
kenjiArai | 0:5b88d5760320 | 34 | |
kenjiArai | 0:5b88d5760320 | 35 | return reason; |
kenjiArai | 0:5b88d5760320 | 36 | } |
kenjiArai | 0:5b88d5760320 | 37 | |
kenjiArai | 0:5b88d5760320 | 38 | uint32_t ResetReason::get_raw() |
kenjiArai | 0:5b88d5760320 | 39 | { |
kenjiArai | 0:5b88d5760320 | 40 | const static uint32_t reason = hal_reset_reason_get_raw(); |
kenjiArai | 0:5b88d5760320 | 41 | |
kenjiArai | 0:5b88d5760320 | 42 | return reason; |
kenjiArai | 0:5b88d5760320 | 43 | } |
kenjiArai | 0:5b88d5760320 | 44 | |
kenjiArai | 0:5b88d5760320 | 45 | } // namespace mbed |
kenjiArai | 0:5b88d5760320 | 46 | |
kenjiArai | 0:5b88d5760320 | 47 | #endif // DEVICE_RESET_REASON |