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 
41 #ifdef PREINIT_SUPPORTED
42 #include "preinit.h"
43 #endif
44 
45 #ifdef MikroCCoreVersion
46  #if MikroCCoreVersion >= 1
47  #include "delays.h"
48  #endif
49 #endif
50 
51 #include "drv_digital_out.h"
52 #include "drv_digital_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
64 #define MCP73871_MAP_MIKROBUS( cfg, mikrobus ) \
65  cfg.pg2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
66  cfg.ce = MIKROBUS( mikrobus, MIKROBUS_CS ); \
67  cfg.te = MIKROBUS( mikrobus, MIKROBUS_PWM )
68 
74 #define MCP73871_RETVAL uint8_t
75 
76 #define MCP73871_OK 0x00
77 #define MCP73871_INIT_ERROR 0xFF
78  // End group macro
81 // --------------------------------------------------------------- PUBLIC TYPES
90 typedef struct
91 {
92  // Output pins
93 
94  digital_out_t pg2;
95  digital_out_t ce;
96  digital_out_t te;
97 
98 } mcp73871_t;
99 
103 typedef struct
104 {
105  // Additional gpio pins
106 
107  pin_name_t pg2;
108  pin_name_t ce;
109  pin_name_t te;
110 
112  // End types group
114 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
115 
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
134 
143 
152 void mcp73871_enable_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
153 
162 void mcp73871_prog_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
163 
172 void mcp73871_timer_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 #endif // _MCP73871_H_
178  // End public_function group
181 
182 // ------------------------------------------------------------------------- END
MCP73871_RETVAL
#define MCP73871_RETVAL
Definition: mcp73871.h:74
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:91
mcp73871_t::pg2
digital_out_t pg2
Definition: mcp73871.h:94
mcp73871_cfg_t::ce
pin_name_t ce
Definition: mcp73871.h:108
mcp73871_t::te
digital_out_t te
Definition: mcp73871.h:96
mcp73871_cfg_t::pg2
pin_name_t pg2
Definition: mcp73871.h:107
mcp73871_cfg_t
Click configuration structure definition.
Definition: mcp73871.h:104
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:109
mcp73871_t::ce
digital_out_t ce
Definition: mcp73871.h:95
mcp73871_enable_pin_control
void mcp73871_enable_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Enable pin control.