buck3  2.0.0.0
buck3.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  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef BUCK3_H
36 #define BUCK3_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define BUCK3_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.en= MIKROBUS( mikrobus, MIKROBUS_RST ); \
63  cfg.pgd= MIKROBUS( mikrobus, MIKROBUS_CS );
64 
70 #define BUCK3_RETVAL uint8_t
71 
72 #define BUCK3_OK 0x00
73 #define BUCK3_INIT_ERROR 0xFF
74 
80 #define BUCK3_MODE_ACTIVE 0x01
81 #define BUCK3_MODE_SLEEP 0x00
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96  // Output pins
97 
98  digital_out_t en;
99 
100  // Input pins
101 
102  digital_in_t pgd;
103 
104 } buck3_t;
105 
109 typedef struct
110 {
111  // Additional gpio pins
112 
113  pin_name_t en;
114  pin_name_t pgd;
115 
116 } buck3_cfg_t;
117  // End types group
119 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120 
126 #ifdef __cplusplus
127 extern "C"{
128 #endif
129 
139 
148 
161 
172 uint8_t buck3_get_power_good ( buck3_t *ctx );
173 
187 void buck3_set_device_state ( buck3_t *ctx, uint8_t state );
188 
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 #endif // _BUCK3_H_
194  // End public_function group
197 
198 // ------------------------------------------------------------------------- END
buck3_set_device_state
void buck3_set_device_state(buck3_t *ctx, uint8_t state)
Function for setting chip mode.
buck3_cfg_setup
void buck3_cfg_setup(buck3_cfg_t *cfg)
Config Object Initialization function.
buck3_t::en
digital_out_t en
Definition: buck3.h:98
buck3_cfg_t::pgd
pin_name_t pgd
Definition: buck3.h:114
BUCK3_RETVAL
#define BUCK3_RETVAL
Definition: buck3.h:70
buck3_get_power_good
uint8_t buck3_get_power_good(buck3_t *ctx)
Function reads state of PGD pin.
buck3_default_cfg
void buck3_default_cfg(buck3_t *ctx)
Click Default Configuration function.
buck3_cfg_t::en
pin_name_t en
Definition: buck3.h:113
buck3_t::pgd
digital_in_t pgd
Definition: buck3.h:102
buck3_init
BUCK3_RETVAL buck3_init(buck3_t *ctx, buck3_cfg_t *cfg)
Initialization function.
buck3_t
Click ctx object definition.
Definition: buck3.h:95
buck3_cfg_t
Click configuration structure definition.
Definition: buck3.h:110