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
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
92typedef struct
93{
94 digital_out_t s0;
95 digital_out_t s1;
96 digital_out_t wdi;
97 digital_in_t wdo;
100
105typedef struct
106{
107 pin_name_t s0;
108 pin_name_t s1;
109 pin_name_t wdi;
110 pin_name_t wdo;
113
118typedef enum
119{
121 WATCHDOG_ERROR = -1
122
124
141
156
171
172
187void watchdog_set_set0 ( watchdog_t *ctx, uint8_t set0_state );
188
203void watchdog_set_set1 ( watchdog_t *ctx, uint8_t set1_state );
204
219void watchdog_set_wdi ( watchdog_t *ctx, uint8_t wdi_state );
220
233
246void watchdog_send_pulse ( watchdog_t *ctx, uint16_t p_duration_ms );
247
261void 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
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:106
pin_name_t s0
Definition: watchdog.h:107
pin_name_t wdi
Definition: watchdog.h:109
pin_name_t wdo
Definition: watchdog.h:110
pin_name_t s1
Definition: watchdog.h:108
Watchdog Click context object.
Definition: watchdog.h:93
digital_in_t wdo
Definition: watchdog.h:97
digital_out_t s1
Definition: watchdog.h:95
digital_out_t s0
Definition: watchdog.h:94
digital_out_t wdi
Definition: watchdog.h:96
watchdog_return_value_t
Watchdog Click return value data.
Definition: watchdog.h:119
@ WATCHDOG_ERROR
Definition: watchdog.h:121
@ WATCHDOG_OK
Definition: watchdog.h:120