MySensors Library & Examples  2.3.2
wdt.h
Go to the documentation of this file.
1 /* Copyright (c) 2002, 2004 Marek Michalkiewicz
2  Copyright (c) 2005, 2006, 2007 Eric B. Weddington
3  Copyright (c) 2016 Frank Holtz
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  * Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in
14  the documentation and/or other materials provided with the
15  distribution.
16 
17  * Neither the name of the copyright holders nor the names of
18  contributors may be used to endorse or promote products derived
19  from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  POSSIBILITY OF SUCH DAMAGE. */
32 
33 /* $Id$ */
34 
35 /*
36  avr/wdt.h - macros for AVR watchdog timer
37  */
38 
39 #ifndef _NRF5_WDT_H_
40 #define _NRF5_WDT_H_
41 
42 #include <nrf.h>
43 #include <stdint.h>
44 
67 #define wdt_reset() NRF_WDT->RR[0] = WDT_RR_RR_Reload
68 
78 #define wdt_enable(timeout) \
79  NRF_WDT->CONFIG = NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Run << WDT_CONFIG_SLEEP_Pos); \
80  NRF_WDT->CRV = (32768*timeout)/1000; \
81  NRF_WDT->RREN |= WDT_RREN_RR0_Msk; \
82  NRF_WDT->TASKS_START = 1
83 
89 #define wdt_disable() \
90  NRF_WDT->CONFIG = NRF_WDT->CONFIG = (WDT_CONFIG_HALT_Pause << WDT_CONFIG_HALT_Pos) | ( WDT_CONFIG_SLEEP_Pause << WDT_CONFIG_SLEEP_Pos); \
91  NRF_WDT->CRV = 4294967295
92 
108 #define WDTO_15MS 15
109 
112 #define WDTO_30MS 30
113 
116 #define WDTO_60MS 60
117 
120 #define WDTO_120MS 120
121 
124 #define WDTO_250MS 250
125 
128 #define WDTO_500MS 500
129 
132 #define WDTO_1S 1000
133 
136 #define WDTO_2S 2000
137 
158 #define WDTO_4S 4000
159 
184 #define WDTO_8S 8000
185 
186 #endif /* _NRF5_WDT_H_ */