watchdog  2.0.0.0
watchdog.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef WATCHDOG_H
29 #define WATCHDOG_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
72 #define WATCHDOG_SETUP_TIME_MODE_0 0x00
73 #define WATCHDOG_SETUP_TIME_MODE_1 0x01
74 #define WATCHDOG_SETUP_TIME_MODE_DISABLE 0x02
75 #define WATCHDOG_SETUP_TIME_MODE_2 0x03
76  // watchdog_set
78 
93 #define WATCHDOG_MAP_MIKROBUS( cfg, mikrobus ) \
94  cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
95  cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
96  cfg.wdi = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
97  cfg.wdo = MIKROBUS( mikrobus, MIKROBUS_INT )
98  // watchdog_map // watchdog
101 
106 typedef struct
107 {
108  digital_out_t s0;
109  digital_out_t s1;
110  digital_out_t wdi;
111  digital_in_t wdo;
113 } watchdog_t;
114 
119 typedef struct
120 {
121  pin_name_t s0;
122  pin_name_t s1;
123  pin_name_t wdi;
124  pin_name_t wdo;
127 
132 typedef enum
133 {
135  WATCHDOG_ERROR = -1
136 
138 
155 
170 
185 
186 
201 void watchdog_set_set0 ( watchdog_t *ctx, uint8_t set0_state );
202 
217 void watchdog_set_set1 ( watchdog_t *ctx, uint8_t set1_state );
218 
233 void watchdog_set_wdi ( watchdog_t *ctx, uint8_t wdi_state );
234 
246 uint8_t watchdog_get_wdo ( watchdog_t *ctx );
247 
260 void watchdog_send_pulse ( watchdog_t *ctx, uint16_t p_duration_ms );
261 
275 void watchdog_setup_time ( watchdog_t *ctx, uint8_t setup_time_mode );
276 
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 #endif // WATCHDOG_H
282  // watchdog
284 
285 // ------------------------------------------------------------------------ END
watchdog_t::s1
digital_out_t s1
Definition: watchdog.h:109
watchdog_t
Watchdog Click context object.
Definition: watchdog.h:107
watchdog_set_wdi
void watchdog_set_wdi(watchdog_t *ctx, uint8_t wdi_state)
Set WDI ( PWM ) pin state function.
watchdog_t::wdi
digital_out_t wdi
Definition: watchdog.h:110
WATCHDOG_OK
@ WATCHDOG_OK
Definition: watchdog.h:134
watchdog_cfg_t::wdi
pin_name_t wdi
Definition: watchdog.h:123
watchdog_setup_time
void watchdog_setup_time(watchdog_t *ctx, uint8_t setup_time_mode)
Set the watchdog time function.
watchdog_default_cfg
err_t watchdog_default_cfg(watchdog_t *ctx)
Watchdog default configuration function.
watchdog_get_wdo
uint8_t watchdog_get_wdo(watchdog_t *ctx)
Get WDO ( INT ) pin state function.
watchdog_send_pulse
void watchdog_send_pulse(watchdog_t *ctx, uint16_t p_duration_ms)
Send pulse function.
watchdog_set_set1
void watchdog_set_set1(watchdog_t *ctx, uint8_t set1_state)
Set S1 ( CS ) pin state function.
watchdog_cfg_t::s0
pin_name_t s0
Definition: watchdog.h:121
watchdog_init
err_t watchdog_init(watchdog_t *ctx, watchdog_cfg_t *cfg)
Watchdog initialization function.
watchdog_t::wdo
digital_in_t wdo
Definition: watchdog.h:111
watchdog_cfg_t::wdo
pin_name_t wdo
Definition: watchdog.h:124
watchdog_t::s0
digital_out_t s0
Definition: watchdog.h:108
watchdog_return_value_t
watchdog_return_value_t
Watchdog Click return value data.
Definition: watchdog.h:133
watchdog_cfg_t::s1
pin_name_t s1
Definition: watchdog.h:122
watchdog_cfg_t
Watchdog Click configuration object.
Definition: watchdog.h:120
watchdog_cfg_setup
void watchdog_cfg_setup(watchdog_cfg_t *cfg)
Watchdog configuration object setup function.
watchdog_set_set0
void watchdog_set_set0(watchdog_t *ctx, uint8_t set0_state)
Set S0 ( RST ) pin state function.
WATCHDOG_ERROR
@ WATCHDOG_ERROR
Definition: watchdog.h:135