mcp73871  2.0.0.0
mcp73871.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  */
32 // ----------------------------------------------------------------------------
33 
34 #ifndef MCP73871_H
35 #define MCP73871_H
36 
37 #include "mikrosdk_version.h"
38 
39 #ifdef __GNUC__
40 #if mikroSDK_GET_VERSION < 20800ul
41 #include "rcu_delays.h"
42 #else
43 #include "delays.h"
44 #endif
45 #endif
46 
47 #include "drv_digital_out.h"
48 #include "drv_digital_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define MCP73871_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.pg2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
62  cfg.ce = MIKROBUS( mikrobus, MIKROBUS_CS ); \
63  cfg.te = MIKROBUS( mikrobus, MIKROBUS_PWM )
64 
70 #define MCP73871_RETVAL uint8_t
71 
72 #define MCP73871_OK 0x00
73 #define MCP73871_INIT_ERROR 0xFF
74  // End group macro
77 // --------------------------------------------------------------- PUBLIC TYPES
86 typedef struct
87 {
88  // Output pins
89 
90  digital_out_t pg2;
91  digital_out_t ce;
92  digital_out_t te;
93 
94 } mcp73871_t;
95 
99 typedef struct
100 {
101  // Additional gpio pins
102 
103  pin_name_t pg2;
104  pin_name_t ce;
105  pin_name_t te;
106 
108  // End types group
110 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
111 
117 #ifdef __cplusplus
118 extern "C"{
119 #endif
120 
130 
139 
148 void mcp73871_enable_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
149 
158 void mcp73871_prog_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
159 
168 void mcp73871_timer_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 #endif // _MCP73871_H_
174  // End public_function group
177 
178 // ------------------------------------------------------------------------- END
MCP73871_RETVAL
#define MCP73871_RETVAL
Definition: mcp73871.h:70
mcp73871_timer_pin_control
void mcp73871_timer_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Timer pin control.
mcp73871_t
Click ctx object definition.
Definition: mcp73871.h:87
mcp73871_t::pg2
digital_out_t pg2
Definition: mcp73871.h:90
mcp73871_cfg_t::ce
pin_name_t ce
Definition: mcp73871.h:104
mcp73871_t::te
digital_out_t te
Definition: mcp73871.h:92
mcp73871_cfg_t::pg2
pin_name_t pg2
Definition: mcp73871.h:103
mcp73871_cfg_t
Click configuration structure definition.
Definition: mcp73871.h:100
mcp73871_prog_pin_control
void mcp73871_prog_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Prog pin control.
mcp73871_cfg_setup
void mcp73871_cfg_setup(mcp73871_cfg_t *cfg)
Config Object Initialization function.
mcp73871_init
MCP73871_RETVAL mcp73871_init(mcp73871_t *ctx, mcp73871_cfg_t *cfg)
Initialization function.
mcp73871_cfg_t::te
pin_name_t te
Definition: mcp73871.h:105
mcp73871_t::ce
digital_out_t ce
Definition: mcp73871.h:91
mcp73871_enable_pin_control
void mcp73871_enable_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Enable pin control.