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 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define CHARGER9_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.flt= MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.shd= MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.chg= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
65  cfg.ful= MIKROBUS( mikrobus, MIKROBUS_INT );
66 
72 #define CHARGER9_RETVAL uint8_t
73 #define CHARGER9_STATE uint8_t
74 
75 #define CHARGER9_OK 0x00
76 #define CHARGER9_INIT_ERROR 0xFF
77 
83 #define CHARGER9_ENABLE 0x01
84 #define CHARGER9_DISABLE 0x00
85 
91 #define CHARGER9_INVALID_STATE 0xFF
92 #define CHARGER9_OK 0x00
93 #define CHARGER9_IND_ACTIVE 0x00
94 #define CHARGER9_IND_INACTIVE 0x01
95  // End group macro
98 // --------------------------------------------------------------- PUBLIC TYPES
107 typedef struct
108 {
109  // Output pins
110 
111  digital_out_t shd;
112 
113  // Input pins
114 
115  digital_in_t flt;
116  digital_in_t chg;
117  digital_in_t ful;
118 
119 } charger9_t;
120 
124 typedef struct
125 {
126  // Additional gpio pins
127 
128  pin_name_t flt;
129  pin_name_t shd;
130  pin_name_t chg;
131  pin_name_t ful;
132 
134  // End types group
136 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137 
143 #ifdef __cplusplus
144 extern "C"{
145 #endif
146 
156 
165 
177 
188 
199 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _CHARGER9_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------- END
charger9_fast_charge_ind
CHARGER9_RETVAL charger9_fast_charge_ind(charger9_t *ctx)
Fast-Charge Indicate function.
charger9_cfg_t
Click configuration structure definition.
Definition: charger9.h:125
charger9_t::ful
digital_in_t ful
Definition: charger9.h:117
charger9_cfg_t::shd
pin_name_t shd
Definition: charger9.h:129
charger9_t::flt
digital_in_t flt
Definition: charger9.h:115
charger9_cfg_t::chg
pin_name_t chg
Definition: charger9.h:130
CHARGER9_RETVAL
#define CHARGER9_RETVAL
Definition: charger9.h:72
charger9_enable
CHARGER9_RETVAL charger9_enable(charger9_t *ctx, CHARGER9_STATE pwr_state)
Enable function.
charger9_fault_ind
CHARGER9_RETVAL charger9_fault_ind(charger9_t *ctx)
Fault Indicate function.
charger9_init
CHARGER9_RETVAL charger9_init(charger9_t *ctx, charger9_cfg_t *cfg)
Initialization function.
charger9_t::chg
digital_in_t chg
Definition: charger9.h:116
charger9_t
Click ctx object definition.
Definition: charger9.h:108
charger9_cfg_t::flt
pin_name_t flt
Definition: charger9.h:128
charger9_cfg_t::ful
pin_name_t ful
Definition: charger9.h:131
charger9_full_charge_ind
CHARGER9_RETVAL charger9_full_charge_ind(charger9_t *ctx)
Full-Charge Indicate function.
charger9_cfg_setup
void charger9_cfg_setup(charger9_cfg_t *cfg)
Config Object Initialization function.
charger9_t::shd
digital_out_t shd
Definition: charger9.h:111
CHARGER9_STATE
#define CHARGER9_STATE
Definition: charger9.h:73