peltier  2.0.0.0
peltier.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 PELTIER_H
35 #define PELTIER_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 PELTIER_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.en2= MIKROBUS( mikrobus, MIKROBUS_RST ); \
62  cfg.en1= MIKROBUS( mikrobus, MIKROBUS_CS ); \
63  cfg.chg= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
64  cfg.con= MIKROBUS( mikrobus, MIKROBUS_INT )
65 
71 #define PELTIER_RETVAL uint8_t
72 
73 #define PELTIER_OK 0x00
74 #define PELTIER_INIT_ERROR 0xFF
75  // End group macro
78 // --------------------------------------------------------------- PUBLIC TYPES
87 typedef struct
88 {
89  // Output pins
90 
91  digital_out_t en2;
92  digital_out_t en1;
93 
94  // Input pins
95 
96  digital_in_t chg;
97  digital_in_t con;
98 
99 } peltier_t;
100 
104 typedef struct
105 {
106  // Additional gpio pins
107 
108  pin_name_t en2;
109  pin_name_t en1;
110  pin_name_t chg;
111  pin_name_t con;
112 
113 } peltier_cfg_t;
114  // End types group
116 
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
137 
146 
155 
164 
173 
182 
191 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // _PELTIER_H_
205  // End public_function group
208 
209 // ------------------------------------------------------------------------- END
peltier_cfg_t
Click configuration structure definition.
Definition: peltier.h:105
peltier_t::en1
digital_out_t en1
Definition: peltier.h:92
peltier_t
Click ctx object definition.
Definition: peltier.h:88
peltier_cfg_t::chg
pin_name_t chg
Definition: peltier.h:110
peltier_enable_ldo1
void peltier_enable_ldo1(peltier_t *ctx)
Enables LDO1 function.
peltier_cfg_setup
void peltier_cfg_setup(peltier_cfg_t *cfg)
Config Object Initialization function.
peltier_t::con
digital_in_t con
Definition: peltier.h:97
peltier_cfg_t::en2
pin_name_t en2
Definition: peltier.h:108
peltier_vin_good_flag
uint8_t peltier_vin_good_flag(peltier_t *ctx)
Check input voltage good flag pin function.
peltier_t::chg
digital_in_t chg
Definition: peltier.h:96
peltier_cfg_t::con
pin_name_t con
Definition: peltier.h:111
peltier_t::en2
digital_out_t en2
Definition: peltier.h:91
peltier_disable_ldo2
void peltier_disable_ldo2(peltier_t *ctx)
Disables LDO2 function.
peltier_init
PELTIER_RETVAL peltier_init(peltier_t *ctx, peltier_cfg_t *cfg)
Initialization function.
peltier_enable_ldo2
void peltier_enable_ldo2(peltier_t *ctx)
Enables LDO2 function.
peltier_battery_charge
uint8_t peltier_battery_charge(peltier_t *ctx)
Check ongoing battery charge flag pin function.
peltier_disable_ldo1
void peltier_disable_ldo1(peltier_t *ctx)
Disables LDO1 function.
peltier_cfg_t::en1
pin_name_t en1
Definition: peltier.h:109
PELTIER_RETVAL
#define PELTIER_RETVAL
Definition: peltier.h:71