ledflash  2.0.0.0
ledflash.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 LEDFLASH_H
36 #define LEDFLASH_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 LEDFLASH_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.ch_ena = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.fls = MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.tor = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
65  cfg.flg = MIKROBUS( mikrobus, MIKROBUS_INT );
66 
72 #define LEDFLASH_RETVAL uint8_t
73 
74 #define LEDFLASH_OK 0x00
75 #define LEDFLASH_INIT_ERROR 0xFF
76  // End group macro
79 // --------------------------------------------------------------- PUBLIC TYPES
88 typedef struct
89 {
90  // Output pins
91 
92  digital_out_t ch_ena;
93  digital_out_t fls;
94  digital_out_t tor;
95 
96  // Input pins
97 
98  digital_in_t flg;
99 
100 } ledflash_t;
101 
105 typedef struct
106 {
107  // Additional gpio pins
108 
109  pin_name_t ch_ena;
110  pin_name_t fls;
111  pin_name_t tor;
112  pin_name_t flg;
113 
115  // End types group
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
137 
146 
155 
164 
173 
182 
191 
200 
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 #endif // _LEDFLASH_H_
217  // End public_function group
220 
221 // ------------------------------------------------------------------------- END
ledflash_torch_enable
void ledflash_torch_enable(ledflash_t *ctx)
Torch Enable function.
ledflash_t::fls
digital_out_t fls
Definition: ledflash.h:93
ledflash_flash_disable
void ledflash_flash_disable(ledflash_t *ctx)
Flash Disable function.
ledflash_cfg_t
Click configuration structure definition.
Definition: ledflash.h:106
ledflash_cfg_setup
void ledflash_cfg_setup(ledflash_cfg_t *cfg)
Config Object Initialization function.
ledflash_char_supcap_disable
void ledflash_char_supcap_disable(ledflash_t *ctx)
Charge Supercapacitor Disable function.
ledflash_cfg_t::ch_ena
pin_name_t ch_ena
Definition: ledflash.h:109
ledflash_cfg_t::tor
pin_name_t tor
Definition: ledflash.h:111
ledflash_t::flg
digital_in_t flg
Definition: ledflash.h:98
ledflash_t::tor
digital_out_t tor
Definition: ledflash.h:94
ledflash_torch_disable
void ledflash_torch_disable(ledflash_t *ctx)
Torch Disable function.
ledflash_t::ch_ena
digital_out_t ch_ena
Definition: ledflash.h:92
ledflash_t
Click ctx object definition.
Definition: ledflash.h:89
ledflash_flash_rdy_flag
uint8_t ledflash_flash_rdy_flag(ledflash_t *ctx)
Check Flash Ready Flag function.
LEDFLASH_RETVAL
#define LEDFLASH_RETVAL
Definition: ledflash.h:72
ledflash_flash_enable
void ledflash_flash_enable(ledflash_t *ctx)
Flash Enable function.
ledflash_cfg_t::flg
pin_name_t flg
Definition: ledflash.h:112
ledflash_char_supcap_enable
void ledflash_char_supcap_enable(ledflash_t *ctx)
Charge Supercapacitor Enable function.
ledflash_cfg_t::fls
pin_name_t fls
Definition: ledflash.h:110
ledflash_init
LEDFLASH_RETVAL ledflash_init(ledflash_t *ctx, ledflash_cfg_t *cfg)
Initialization function.