charger9 2.0.0.0
charger9.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 CHARGER9_H
36#define CHARGER9_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define CHARGER9_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.flt= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.shd= MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.chg= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69 cfg.ful= MIKROBUS( mikrobus, MIKROBUS_INT );
76#define CHARGER9_RETVAL uint8_t
77#define CHARGER9_STATE uint8_t
78
79#define CHARGER9_OK 0x00
80#define CHARGER9_INIT_ERROR 0xFF
87#define CHARGER9_ENABLE 0x01
88#define CHARGER9_DISABLE 0x00
95#define CHARGER9_INVALID_STATE 0xFF
96#define CHARGER9_OK 0x00
97#define CHARGER9_IND_ACTIVE 0x00
98#define CHARGER9_IND_INACTIVE 0x01
101 // End group macro
102// --------------------------------------------------------------- PUBLIC TYPES
111typedef struct
112{
113 // Output pins
114
115 digital_out_t shd;
116
117 // Input pins
118
119 digital_in_t flt;
120 digital_in_t chg;
121 digital_in_t ful;
122
123} charger9_t;
124
128typedef struct
129{
130 // Additional gpio pins
131
132 pin_name_t flt;
133 pin_name_t shd;
134 pin_name_t chg;
135 pin_name_t ful;
136
138
139 // End types group
140// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141
147#ifdef __cplusplus
148extern "C"{
149#endif
150
160
169
181
192
203
214
215#ifdef __cplusplus
216}
217#endif
218#endif // _CHARGER9_H_
219
220 // End public_function group
222
223// ------------------------------------------------------------------------- END
#define CHARGER9_RETVAL
Definition charger9.h:76
#define CHARGER9_STATE
Definition charger9.h:77
void charger9_cfg_setup(charger9_cfg_t *cfg)
Config Object Initialization function.
CHARGER9_RETVAL charger9_full_charge_ind(charger9_t *ctx)
Full-Charge Indicate function.
CHARGER9_RETVAL charger9_enable(charger9_t *ctx, CHARGER9_STATE pwr_state)
Enable function.
CHARGER9_RETVAL charger9_fault_ind(charger9_t *ctx)
Fault Indicate function.
CHARGER9_RETVAL charger9_fast_charge_ind(charger9_t *ctx)
Fast-Charge Indicate function.
CHARGER9_RETVAL charger9_init(charger9_t *ctx, charger9_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition charger9.h:129
pin_name_t shd
Definition charger9.h:133
pin_name_t flt
Definition charger9.h:132
pin_name_t ful
Definition charger9.h:135
pin_name_t chg
Definition charger9.h:134
Click ctx object definition.
Definition charger9.h:112
digital_in_t flt
Definition charger9.h:119
digital_in_t chg
Definition charger9.h:120
digital_in_t ful
Definition charger9.h:121
digital_out_t shd
Definition charger9.h:115