Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ResetReason and Watchdog driver docs #404

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/reference/api/drivers/ResetReason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link doesn't work. Please fix it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intended pages don't currently exist. Could you generate the docs pages to link to under https://os.mbed.com/docs/v5.7/feature-hal-spec-watchdog-doxy/modules.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know. I'll talk with @iriark01 about having these rendered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, have what rendered? Is it just a feature branch to add?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't actually a feature branch. This is a driver page. Can you please help me find the correct link here: https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/annotated.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be exclusions from the mbed-os repo's branch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see it in the exclusion, but I'm never quite sure how that works

https://github.com/ARMmbed/mbed-os/blob/feature-watchdog/doxygen_options.json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh thanks, it looks like it might be the lack of DEVICE_RESET_REASON and DEVICE_WATCHDOG in the predefined section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scartmell-arm is that something you can fix?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


### ResetReason example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the examples from both files to the teams examples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the teams examples you're referring to?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These: https://os.mbed.com/teams/mbed_example/

We've now given you access (we think), so please create your examples here, and let me know if you still need permissions.


```c++
#include "mbed.h"
#include "ResetReason.h"

#include <string>

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());
}
```
35 changes: 32 additions & 3 deletions docs/reference/api/drivers/Watchdog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
## Watchdog

[Add description here.]
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.

<span class="notes">**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()`.</span>

### 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link doesn't work. Please fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not contributing (porting) pages, so they should not go to feature branches.


### Watchdog example

[Add example here.]
Create a watchdog timer that expires after 5 seconds and that you refresh 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();
}
```