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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 
58 #define WATCHDOG_SETUP_TIME_MODE_0 0x00
59 #define WATCHDOG_SETUP_TIME_MODE_1 0x01
60 #define WATCHDOG_SETUP_TIME_MODE_DISABLE 0x02
61 #define WATCHDOG_SETUP_TIME_MODE_2 0x03
62  // watchdog_set
64 
79 #define WATCHDOG_MAP_MIKROBUS( cfg, mikrobus ) \
80  cfg.s0 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
81  cfg.s1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
82  cfg.wdi = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
83  cfg.wdo = MIKROBUS( mikrobus, MIKROBUS_INT )
84  // watchdog_map // watchdog
87 
92 typedef struct
93 {
94  digital_out_t s0;
95  digital_out_t s1;
96  digital_out_t wdi;
97  digital_in_t wdo;
99 } watchdog_t;
100 
105 typedef struct
106 {
107  pin_name_t s0;
108  pin_name_t s1;
109  pin_name_t wdi;
110  pin_name_t wdo;
113 
118 typedef enum
119 {
121  WATCHDOG_ERROR = -1
122 
124 
140 void watchdog_cfg_setup ( watchdog_cfg_t *cfg );
141 
155 err_t watchdog_init ( watchdog_t *ctx, watchdog_cfg_t *cfg );
156 
170 err_t watchdog_default_cfg ( watchdog_t *ctx );
171 
172 
187 void watchdog_set_set0 ( watchdog_t *ctx, uint8_t set0_state );
188 
203 void watchdog_set_set1 ( watchdog_t *ctx, uint8_t set1_state );
204 
219 void watchdog_set_wdi ( watchdog_t *ctx, uint8_t wdi_state );
220 
232 uint8_t watchdog_get_wdo ( watchdog_t *ctx );
233 
246 void watchdog_send_pulse ( watchdog_t *ctx, uint16_t p_duration_ms );
247 
261 void watchdog_setup_time ( watchdog_t *ctx, uint8_t setup_time_mode );
262 
263 
264 #ifdef __cplusplus
265 }
266 #endif
267 #endif // WATCHDOG_H
268  // watchdog
270 
271 // ------------------------------------------------------------------------ END
watchdog_t
Watchdog Click context object.
Definition: watchdog.h:91
watchdog_set_wdi
void watchdog_set_wdi(watchdog_t *ctx, uint8_t wdi_state)
Set WDI ( PWM ) pin state function.
WATCHDOG_OK
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_init
err_t watchdog_init(watchdog_t *ctx, watchdog_cfg_t *cfg)
Watchdog initialization function.
watchdog_return_value_t
watchdog_return_value_t
Watchdog Click return value data.
Definition: watchdog.h:117
watchdog_cfg_t
Watchdog Click configuration object.
Definition: watchdog.h:104
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
Definition: watchdog.h:120