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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
68 #define WATCHDOG_SETUP_TIME_MODE_0 0x00
69 #define WATCHDOG_SETUP_TIME_MODE_1 0x01
70 #define WATCHDOG_SETUP_TIME_MODE_DISABLE 0x02
71 #define WATCHDOG_SETUP_TIME_MODE_2 0x03
72  // watchdog_set
74 
89 #define WATCHDOG_MAP_MIKROBUS( cfg, mikrobus ) \
90  cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
91  cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
92  cfg.wdi = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
93  cfg.wdo = MIKROBUS( mikrobus, MIKROBUS_INT )
94  // watchdog_map // watchdog
97 
102 typedef struct
103 {
104  digital_out_t s0;
105  digital_out_t s1;
106  digital_out_t wdi;
107  digital_in_t wdo;
109 } watchdog_t;
110 
115 typedef struct
116 {
117  pin_name_t s0;
118  pin_name_t s1;
119  pin_name_t wdi;
120  pin_name_t wdo;
123 
128 typedef enum
129 {
131  WATCHDOG_ERROR = -1
132 
134 
151 
166 
181 
182 
197 void watchdog_set_set0 ( watchdog_t *ctx, uint8_t set0_state );
198 
213 void watchdog_set_set1 ( watchdog_t *ctx, uint8_t set1_state );
214 
229 void watchdog_set_wdi ( watchdog_t *ctx, uint8_t wdi_state );
230 
242 uint8_t watchdog_get_wdo ( watchdog_t *ctx );
243 
256 void watchdog_send_pulse ( watchdog_t *ctx, uint16_t p_duration_ms );
257 
271 void watchdog_setup_time ( watchdog_t *ctx, uint8_t setup_time_mode );
272 
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 #endif // WATCHDOG_H
278  // watchdog
280 
281 // ------------------------------------------------------------------------ END
watchdog_t::s1
digital_out_t s1
Definition: watchdog.h:105
watchdog_t
Watchdog Click context object.
Definition: watchdog.h:103
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:106
WATCHDOG_OK
@ WATCHDOG_OK
Definition: watchdog.h:130
watchdog_cfg_t::wdi
pin_name_t wdi
Definition: watchdog.h:119
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:117
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:107
watchdog_cfg_t::wdo
pin_name_t wdo
Definition: watchdog.h:120
watchdog_t::s0
digital_out_t s0
Definition: watchdog.h:104
watchdog_return_value_t
watchdog_return_value_t
Watchdog Click return value data.
Definition: watchdog.h:129
watchdog_cfg_t::s1
pin_name_t s1
Definition: watchdog.h:118
watchdog_cfg_t
Watchdog Click configuration object.
Definition: watchdog.h:116
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:131