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
32extern "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
77 // 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
99 // watchdog_map
100 // watchdog
101
106typedef 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
119typedef struct
120{
121 pin_name_t s0;
122 pin_name_t s1;
123 pin_name_t wdi;
124 pin_name_t wdo;
127
132typedef enum
133{
135 WATCHDOG_ERROR = -1
136
138
155
170
185
186
201void watchdog_set_set0 ( watchdog_t *ctx, uint8_t set0_state );
202
217void watchdog_set_set1 ( watchdog_t *ctx, uint8_t set1_state );
218
233void watchdog_set_wdi ( watchdog_t *ctx, uint8_t wdi_state );
234
247
260void watchdog_send_pulse ( watchdog_t *ctx, uint16_t p_duration_ms );
261
275void watchdog_setup_time ( watchdog_t *ctx, uint8_t setup_time_mode );
276
277
278#ifdef __cplusplus
279}
280#endif
281#endif // WATCHDOG_H
282
283 // watchdog
284
285// ------------------------------------------------------------------------ END
void watchdog_send_pulse(watchdog_t *ctx, uint16_t p_duration_ms)
Send pulse function.
void watchdog_set_wdi(watchdog_t *ctx, uint8_t wdi_state)
Set WDI ( PWM ) pin state function.
void watchdog_set_set0(watchdog_t *ctx, uint8_t set0_state)
Set S0 ( RST ) pin state function.
void watchdog_cfg_setup(watchdog_cfg_t *cfg)
Watchdog configuration object setup function.
err_t watchdog_init(watchdog_t *ctx, watchdog_cfg_t *cfg)
Watchdog initialization function.
void watchdog_setup_time(watchdog_t *ctx, uint8_t setup_time_mode)
Set the watchdog time function.
err_t watchdog_default_cfg(watchdog_t *ctx)
Watchdog default configuration function.
uint8_t watchdog_get_wdo(watchdog_t *ctx)
Get WDO ( INT ) pin state function.
void watchdog_set_set1(watchdog_t *ctx, uint8_t set1_state)
Set S1 ( CS ) pin state function.
Watchdog Click configuration object.
Definition watchdog.h:120
pin_name_t s0
Definition watchdog.h:121
pin_name_t wdi
Definition watchdog.h:123
pin_name_t wdo
Definition watchdog.h:124
pin_name_t s1
Definition watchdog.h:122
Watchdog Click context object.
Definition watchdog.h:107
digital_in_t wdo
Definition watchdog.h:111
digital_out_t s1
Definition watchdog.h:109
digital_out_t s0
Definition watchdog.h:108
digital_out_t wdi
Definition watchdog.h:110
watchdog_return_value_t
Watchdog Click return value data.
Definition watchdog.h:133
@ WATCHDOG_ERROR
Definition watchdog.h:135
@ WATCHDOG_OK
Definition watchdog.h:134