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 "drv_digital_out.h"
38 #include "drv_digital_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define MCP73871_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.pg2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
52  cfg.ce = MIKROBUS( mikrobus, MIKROBUS_CS ); \
53  cfg.te = MIKROBUS( mikrobus, MIKROBUS_PWM )
54 
60 #define MCP73871_RETVAL uint8_t
61 
62 #define MCP73871_OK 0x00
63 #define MCP73871_INIT_ERROR 0xFF
64  // End group macro
67 // --------------------------------------------------------------- PUBLIC TYPES
76 typedef struct
77 {
78  // Output pins
79 
80  digital_out_t pg2;
81  digital_out_t ce;
82  digital_out_t te;
83 
84 } mcp73871_t;
85 
89 typedef struct
90 {
91  // Additional gpio pins
92 
93  pin_name_t pg2;
94  pin_name_t ce;
95  pin_name_t te;
96 
98  // End types group
100 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
101 
107 #ifdef __cplusplus
108 extern "C"{
109 #endif
110 
119 void mcp73871_cfg_setup ( mcp73871_cfg_t *cfg );
120 
129 
138 void mcp73871_enable_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
139 
148 void mcp73871_prog_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
149 
158 void mcp73871_timer_pin_control ( mcp73871_t *ctx, uint8_t pin_state );
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 #endif // _MCP73871_H_
164  // End public_function group
167 
168 // ------------------------------------------------------------------------- END
pin_name_t pg2
Definition: mcp73871.h:93
void mcp73871_enable_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Enable pin control.
digital_out_t ce
Definition: mcp73871.h:81
pin_name_t ce
Definition: mcp73871.h:94
Click configuration structure definition.
Definition: mcp73871.h:89
MCP73871_RETVAL mcp73871_init(mcp73871_t *ctx, mcp73871_cfg_t *cfg)
Initialization function.
Click ctx object definition.
Definition: mcp73871.h:76
pin_name_t te
Definition: mcp73871.h:95
digital_out_t te
Definition: mcp73871.h:82
#define MCP73871_RETVAL
Definition: mcp73871.h:60
digital_out_t pg2
Definition: mcp73871.h:80
void mcp73871_timer_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Timer pin control.
void mcp73871_prog_pin_control(mcp73871_t *ctx, uint8_t pin_state)
Prog pin control.
void mcp73871_cfg_setup(mcp73871_cfg_t *cfg)
Config Object Initialization function.