mirror of https://github.com/ARMmbed/mbed-os.git
LPC1768 Reset Reason implementation
parent
2fcafb9c93
commit
7e2c2a98dd
|
@ -0,0 +1,62 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "reset_reason_api.h"
|
||||
|
||||
#ifdef DEVICE_RESET_REASON
|
||||
|
||||
#include "device.h"
|
||||
|
||||
reset_reason_t hal_reset_reason_get(void)
|
||||
{
|
||||
if (LPC_SC->RSID & (1<<0)) {
|
||||
return RESET_REASON_POWER_ON;
|
||||
}
|
||||
|
||||
if (LPC_SC->RSID & (1<<1)) {
|
||||
return RESET_REASON_PIN_RESET;
|
||||
}
|
||||
if (LPC_SC->RSID & (1<<2)) {
|
||||
return RESET_REASON_WATCHDOG;
|
||||
}
|
||||
|
||||
if (LPC_SC->RSID & (1<<3)) {
|
||||
return RESET_REASON_BROWN_OUT;
|
||||
}
|
||||
if (LPC_SC->RSID & (1<<4)) {
|
||||
return RESET_REASON_SOFTWARE;
|
||||
}
|
||||
|
||||
if (LPC_SC->RSID & (1<<5)) {
|
||||
return RESET_REASON_LOCKUP;
|
||||
}
|
||||
|
||||
return RESET_REASON_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
uint32_t hal_reset_reason_get_raw(void)
|
||||
{
|
||||
|
||||
return LPC_SC->RSID;
|
||||
}
|
||||
|
||||
|
||||
void hal_reset_reason_clear(void)
|
||||
{
|
||||
LPC_SC->RSID = 0xff; // Clear flags
|
||||
}
|
||||
|
||||
#endif // DEVICE_RESET_REASON
|
|
@ -625,7 +625,8 @@
|
|||
"FLASH",
|
||||
"MPU",
|
||||
"USBDEVICE",
|
||||
"WATCHDOG"
|
||||
"WATCHDOG",
|
||||
"RESET_REASON"
|
||||
],
|
||||
"release_versions": ["2", "5"],
|
||||
"device_name": "LPC1768",
|
||||
|
|
Loading…
Reference in New Issue