charger23  2.1.0.0
charger23.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 CHARGER23_H
29 #define CHARGER23_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
68 #define CHARGER23_STATE_UNKNOWN 0
69 #define CHARGER23_STATE_FAULT 1
70 #define CHARGER23_STATE_CHARGING 2
71 #define CHARGER23_STATE_IDLE 3
72 #define CHARGER23_STATE_MASK 0x03
73  // charger23_set
75 
90 #define CHARGER23_MAP_MIKROBUS( cfg, mikrobus ) \
91  cfg.status = MIKROBUS( mikrobus, MIKROBUS_AN ); \
92  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
93  cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
94  // charger23_map // charger23
97 
102 typedef struct
103 {
104  digital_out_t en;
106  digital_in_t status;
107  digital_in_t fault;
109 } charger23_t;
110 
115 typedef struct
116 {
117  pin_name_t status;
118  pin_name_t en;
119  pin_name_t fault;
122 
127 typedef enum
128 {
130  CHARGER23_ERROR = -1
131 
133 
150 
165 
175 
185 
197 
209 
222 
223 #ifdef __cplusplus
224 }
225 #endif
226 #endif // CHARGER23_H
227  // charger23
229 
230 // ------------------------------------------------------------------------ END
charger23_cfg_t
Charger 23 Click configuration object.
Definition: charger23.h:116
charger23_enable_device
void charger23_enable_device(charger23_t *ctx)
Charger 23 enable device function.
charger23_t::en
digital_out_t en
Definition: charger23.h:104
CHARGER23_OK
@ CHARGER23_OK
Definition: charger23.h:129
charger23_t::fault
digital_in_t fault
Definition: charger23.h:107
charger23_t::status
digital_in_t status
Definition: charger23.h:106
charger23_cfg_t::fault
pin_name_t fault
Definition: charger23.h:119
charger23_get_fault_pin
uint8_t charger23_get_fault_pin(charger23_t *ctx)
Charger 23 get fault pin function.
charger23_cfg_t::status
pin_name_t status
Definition: charger23.h:117
CHARGER23_ERROR
@ CHARGER23_ERROR
Definition: charger23.h:130
charger23_get_charger_state
uint8_t charger23_get_charger_state(charger23_t *ctx)
Charger 23 get charger state function.
charger23_get_status_pin
uint8_t charger23_get_status_pin(charger23_t *ctx)
Charger 23 get status pin function.
charger23_init
err_t charger23_init(charger23_t *ctx, charger23_cfg_t *cfg)
Charger 23 initialization function.
charger23_return_value_t
charger23_return_value_t
Charger 23 Click return value data.
Definition: charger23.h:128
charger23_disable_device
void charger23_disable_device(charger23_t *ctx)
Charger 23 disable device function.
charger23_cfg_setup
void charger23_cfg_setup(charger23_cfg_t *cfg)
Charger 23 configuration object setup function.
charger23_t
Charger 23 Click context object.
Definition: charger23.h:103
charger23_cfg_t::en
pin_name_t en
Definition: charger23.h:118