ups 2.0.0.0
ups.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef UPS_H
36#define UPS_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
51#define UPS_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.an= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53 cfg.rst= MIKROBUS( mikrobus, MIKROBUS_RST ); \
54 cfg.cs= MIKROBUS( mikrobus, MIKROBUS_CS ); \
55
61#define UPS_RETVAL uint8_t
62
63#define UPS_OK 0x00
64#define UPS_INIT_ERROR 0xFF
71#define UPS_MODE_ACTIVE 1
72#define UPS_MODE_SLEEP 0 // End group macro
76// --------------------------------------------------------------- PUBLIC TYPES
85typedef struct
86{
87 // Output pins
88
89 digital_out_t rst;
90
91 // Input pins
92
93 digital_in_t an;
94 digital_in_t cs;
95
96} ups_t;
97
101typedef struct
102{
103 // Additional gpio pins
104
105 pin_name_t an;
106 pin_name_t rst;
107 pin_name_t cs;
108
109} ups_cfg_t;
110 // End types group
112// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
113
119#ifdef __cplusplus
120extern "C"{
121#endif
122
132
142
156void usp_set_mode ( ups_t *ctx, uint8_t mode );
157
167uint8_t ups_get_power_good ( ups_t *ctx );
168
169#ifdef __cplusplus
170}
171#endif
172#endif // _UPS_H_
173 // End public_function group
176
177// ------------------------------------------------------------------------- END
#define UPS_RETVAL
Definition: ups.h:61
uint8_t ups_get_power_good(ups_t *ctx)
Functions for reading PGD state.
UPS_RETVAL ups_init(ups_t *ctx, ups_cfg_t *cfg)
Initialization function.
void ups_cfg_setup(ups_cfg_t *cfg)
Config Object Initialization function.
void usp_set_mode(ups_t *ctx, uint8_t mode)
Functions for settings chip mode.
Click configuration structure definition.
Definition: ups.h:102
pin_name_t rst
Definition: ups.h:106
pin_name_t an
Definition: ups.h:105
pin_name_t cs
Definition: ups.h:107
Click ctx object definition.
Definition: ups.h:86
digital_in_t cs
Definition: ups.h:94
digital_in_t an
Definition: ups.h:93
digital_out_t rst
Definition: ups.h:89