From 5d02b7d0292b78c7c0409426f54c5701d31145df Mon Sep 17 00:00:00 2001 From: Steve Cartmell Date: Thu, 8 Feb 2018 13:40:21 +0000 Subject: [PATCH 1/3] Add ResetReason and Watchdog driver docs --- docs/reference/api/drivers/ResetReason.md | 41 +++++++++++++++++++++++ docs/reference/api/drivers/Watchdog.md | 37 ++++++++++++++++++-- 2 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 docs/reference/api/drivers/ResetReason.md diff --git a/docs/reference/api/drivers/ResetReason.md b/docs/reference/api/drivers/ResetReason.md new file mode 100644 index 0000000000..1b111e0489 --- /dev/null +++ b/docs/reference/api/drivers/ResetReason.md @@ -0,0 +1,41 @@ +## ResetReason + +Use the ResetReason interface to access hardware reset reason registers in a portable fashion. + + +### ResetReason class reference + +[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/v5.8/mbed-os-api-doxy/classmbed_1_1_resetreason.html) + + +### ResetReason example + +```c++ +#include "mbed.h" +#include "ResetReason.h" + +#include + +std::string reset_reason_to_string(const reset_reason_t reason) +{ + switch (reason) + { + case RESET_REASON_POWER_ON: + return "Power On"; + case RESET_REASON_PIN_RESET: + return "Hardware Pin"; + case RESET_REASON_SOFTWARE: + return "Software Reset"; + case RESET_REASON_WATCHDOG: + return "Watchdog"; + default: + return "Other Reason"; + } +} + +int main() { + const reset_reason_t reason = ResetReason::get(); + + printf("Last system reset reason: %s\n", reset_reason_to_string(reason).c_str()); +} +``` diff --git a/docs/reference/api/drivers/Watchdog.md b/docs/reference/api/drivers/Watchdog.md index 876e676de2..9c9a8ead5b 100644 --- a/docs/reference/api/drivers/Watchdog.md +++ b/docs/reference/api/drivers/Watchdog.md @@ -1,11 +1,42 @@ ## Watchdog -[Add description here.] +Use the Watchdog interface to set up a hardware watchdog which will reset the system after a set period of time if not periodically refreshed before it expires. + +### Warnings and notes + +* The maximum amount of time that can be set as the Watchdog timeout varies depending on the target hardware. The maximum value can be checked by calling `Watchdog::max_timeout()`. ### Watchdog class reference -[Add class reference here. Ask your editor for help if you've never done this before.] +[![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/v5.8/mbed-os-api-doxy/classmbed_1_1_watchdog.html) ### Watchdog example -[Add example here.] +Create a watchdog timer that expires after 5 seconds, the timer is refreshed by pushing BUTTON1 on the target board. + +```c++ +#include "mbed.h" + +#include "InterruptIn.h" +#include "mbed_sleep.h" +#include "Watchdog.h" + +mbed::InterruptIn button(BUTTON1); +mbed::Watchdog watchdog; + +void trigger() +{ + printf("Refreshing watchdog timer\r\n"); + watchdog.kick(); +} + +int main() +{ + printf("Board started, Watchdog timer initialized to 5 seconds.\r\n"); + watchdog.start(5000); + + button.rise(&trigger); + + sleep(); +} +``` From 1eeef0c9e70e2390c37b96e04a18cfdfeb8ab7d6 Mon Sep 17 00:00:00 2001 From: Amanda Butler Date: Thu, 15 Feb 2018 15:44:42 -0600 Subject: [PATCH 2/3] Copy edit ResetReason.md Fix formatting for consistency across documentation. --- docs/reference/api/drivers/ResetReason.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/reference/api/drivers/ResetReason.md b/docs/reference/api/drivers/ResetReason.md index 1b111e0489..6adc516d44 100644 --- a/docs/reference/api/drivers/ResetReason.md +++ b/docs/reference/api/drivers/ResetReason.md @@ -2,12 +2,10 @@ Use the ResetReason interface to access hardware reset reason registers in a portable fashion. - ### ResetReason class reference [![View code](https://www.mbed.com/embed/?type=library)](http://os-doc-builder.test.mbed.com/docs/v5.8/mbed-os-api-doxy/classmbed_1_1_resetreason.html) - ### ResetReason example ```c++ From de89c6ec7bc566884ddef0e9cda3163d9834bee3 Mon Sep 17 00:00:00 2001 From: Amanda Butler Date: Thu, 15 Feb 2018 15:47:52 -0600 Subject: [PATCH 3/3] Copy edit Watchdog.md Copy edit for active voice and formatting. --- docs/reference/api/drivers/Watchdog.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/reference/api/drivers/Watchdog.md b/docs/reference/api/drivers/Watchdog.md index 9c9a8ead5b..d8150a8daf 100644 --- a/docs/reference/api/drivers/Watchdog.md +++ b/docs/reference/api/drivers/Watchdog.md @@ -1,10 +1,8 @@ ## Watchdog -Use the Watchdog interface to set up a hardware watchdog which will reset the system after a set period of time if not periodically refreshed before it expires. +Use the Watchdog interface to set up a hardware watchdog that resets the system after a set period of time if you do not periodically refresh it before it expires. -### Warnings and notes - -* The maximum amount of time that can be set as the Watchdog timeout varies depending on the target hardware. The maximum value can be checked by calling `Watchdog::max_timeout()`. +**Note:** The maximum amount of time that you can set as the Watchdog timeout varies depending on the target hardware. You can check the maximum value by calling `Watchdog::max_timeout()`. ### Watchdog class reference @@ -12,7 +10,7 @@ Use the Watchdog interface to set up a hardware watchdog which will reset the sy ### Watchdog example -Create a watchdog timer that expires after 5 seconds, the timer is refreshed by pushing BUTTON1 on the target board. +Create a watchdog timer that expires after 5 seconds and that you refresh by pushing BUTTON1 on the target board. ```c++ #include "mbed.h"