Skip to content

Commit 9499ae3

Browse files
committed
Add watchdog timeout config.
Former-commit-id: 8de5117
1 parent 6a4f3b7 commit 9499ae3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ This Arduino Core does **not** contain any BLE functionality. It has been design
107107
2. Select nrfutil as the firmware uploader in the tools menu.
108108

109109
## Configuration (optional)
110-
You can change the configuration for many settings by creating a `build_opt.h` file in your sketch folder.
111-
In here you can set compile time definitions for settings that will be included directly on the command line.
110+
You can change the configuration for many settings by creating a `build_opt.h` file in your sketch folder.
111+
In here you can set compile time definitions for settings that will be included directly on the command line.
112112
For example: `'-DCONFIG_MAIN_TASK_STACK_SIZE=2048'` This will set the main task stack size to 2048 bytes.
113113

114114
### Configuration option list
@@ -118,6 +118,7 @@ For example: `'-DCONFIG_MAIN_TASK_STACK_SIZE=2048'` This will set the main task
118118
* `CONFIG_RTOS_MIN_TASK_STACK_SIZE` - set the minimum task stack size.
119119
* `CONFIG_RTOS_TIMER_QUEUE_LENGTH` - set the queue size for the FreeRTOS timers.
120120
* `CONFIG_RTOS_TIMER_STACK_DEPTH` - set the timer task stack size **in 32bit words**.
121+
* `CONFIG_WDT_TIMEOUT_SECONDS` - set the number of seconds before the watchdog times out (0 = disable watchdog, default = 5).
121122
* Nimble configuration options can also be included, the list of those can be found [here](https://h2zero.github.io/NimBLE-Arduino/md__command_line_config.html)
122123
* Other compiler options or definitions for other libraries can also be specified.
123124

@@ -138,7 +139,7 @@ There are a few useful functions available to help with your project.
138139
* `void systemRestart();` - Reboot.
139140

140141
## Bootloader
141-
Currently only some boards have Adafruit bootloaders available which are provided as options. You may choose to use the bootloader or none.
142+
Currently only some boards have Adafruit bootloaders available which are provided as options. You may choose to use the bootloader or none.
142143
The provided Adafruit bootloaders have no softdevice, if you currently are using the softdevice based Adafruit bootloader on your nRF52 board you will need to update it to the one provided by selecting it from the boards menu and clicking `Burn Bootloader`.
143144

144145
For boards without the Adafruit bootloader option clicking `Burn Bootloader` will simply erase the flash memory on the device. This is required if you have any bootloader flashed already.

cores/nRF5/wiring.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
extern "C" {
2727
#endif
2828

29+
#ifndef CONFIG_WDT_TIMEOUT_SECONDS
30+
#define CONFIG_WDT_TIMEOUT_SECONDS 5
31+
#endif
32+
2933
#define DFU_MAGIC_SERIAL_ONLY_RESET 0x4e
3034

3135
#ifdef NRF52_SERIES
@@ -116,11 +120,13 @@ void init( void )
116120
NVIC_SetPriority((IRQn_Type) i, DEFAULT_IRQ_PRIO);
117121
}
118122

119-
//Configure Watchdog. Pause watchdog while the CPU is halted by the debugger or sleeping.
123+
#if CONFIG_WDT_TIMEOUT_SECONDS
124+
//Configure Watchdog. Pause watchdog while the CPU is halted by the debugger or sleeping.
120125
NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos);
121-
NRF_WDT->CRV = 5*32768; //5 second timeout
126+
NRF_WDT->CRV = CONFIG_WDT_TIMEOUT_SECONDS*32768;
122127
NRF_WDT->RREN |= WDT_RREN_RR0_Msk;
123128
NRF_WDT->TASKS_START = 1; //Start the Watchdog timer
129+
#endif
124130
}
125131

126132
uint32_t getResetReason(void) {

0 commit comments

Comments
 (0)