solidswitch 2.0.0.0
solidswitch.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef SOLIDSWITCH_H
29#define SOLIDSWITCH_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define SOLIDSWITCH_ENABLE_OUT7 0x80
74#define SOLIDSWITCH_ENABLE_OUT6 0x40
75#define SOLIDSWITCH_ENABLE_OUT1 0x02
76#define SOLIDSWITCH_ENABLE_OUT0 0x01
77#define SOLIDSWITCH_ENABLE_ALL_OUTPUTS 0xC3
78#define SOLIDSWITCH_DISABLE_ALL_OUTPUTS 0x00
79
85#define SOLIDSWITCH_DEV_ADDR_A1_GND_A0_GND 0x68
86#define SOLIDSWITCH_DEV_ADDR_A1_GND_A0_VCC 0x69
87#define SOLIDSWITCH_DEV_ADDR_A1_VCC_A0_GND 0x6C
88#define SOLIDSWITCH_DEV_ADDR_A1_VCC_A0_VCC 0x6D
89
90 // solidswitch_set
91
106#define SOLIDSWITCH_MAP_MIKROBUS( cfg, mikrobus ) \
107 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
108 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
109 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
110 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
111
112 // solidswitch_map
113 // solidswitch
114
119typedef struct
120{
121 // Output pins
122
123 digital_out_t rst;
125 // Input pins
126
127 digital_in_t int_pin;
129 // Modules
130
131 i2c_master_t i2c;
133 // I2C slave address
134
138
143typedef struct
144{
145 pin_name_t scl;
146 pin_name_t sda;
148 pin_name_t rst;
149 pin_name_t int_pin;
151 uint32_t i2c_speed;
152 uint8_t i2c_address;
155
166
185
203
220
235err_t solidswitch_write_single ( solidswitch_t *ctx, uint8_t logic_state );
236
252err_t solidswitch_write_two_bytes ( solidswitch_t *ctx, uint8_t logic_state, uint8_t int_mask );
253
268err_t solidswitch_read_single ( solidswitch_t *ctx, uint8_t *logic_state );
269
285err_t solidswitch_read_two_bytes ( solidswitch_t *ctx, uint8_t *logic_state, uint8_t *transition_flags );
286
299
312
313#ifdef __cplusplus
314}
315#endif
316#endif // SOLIDSWITCH_H
317
318 // solidswitch
319
320// ------------------------------------------------------------------------ END
uint8_t solidswitch_get_int_state(solidswitch_t *ctx)
SolidSwitch get int pin state function.
err_t solidswitch_read_two_bytes(solidswitch_t *ctx, uint8_t *logic_state, uint8_t *transition_flags)
SolidSwitch I2C reading logic state and transition flags function.
void solidswitch_reset(solidswitch_t *ctx)
SolidSwitch reset function.
err_t solidswitch_write_single(solidswitch_t *ctx, uint8_t logic_state)
SolidSwitch I2C writing logic state function.
err_t solidswitch_init(solidswitch_t *ctx, solidswitch_cfg_t *cfg)
SolidSwitch initialization function.
err_t solidswitch_read_single(solidswitch_t *ctx, uint8_t *logic_state)
SolidSwitch I2C reading logic state function.
err_t solidswitch_default_cfg(solidswitch_t *ctx)
SolidSwitch default configuration function.
err_t solidswitch_write_two_bytes(solidswitch_t *ctx, uint8_t logic_state, uint8_t int_mask)
SolidSwitch I2C writing logic state and interrupt mask function.
void solidswitch_cfg_setup(solidswitch_cfg_t *cfg)
SolidSwitch configuration object setup function.
solidswitch_return_value_t
SolidSwitch Click return value data.
Definition solidswitch.h:161
@ SOLIDSWITCH_ERROR
Definition solidswitch.h:163
@ SOLIDSWITCH_OK
Definition solidswitch.h:162
SolidSwitch Click configuration object.
Definition solidswitch.h:144
uint32_t i2c_speed
Definition solidswitch.h:151
pin_name_t scl
Definition solidswitch.h:145
pin_name_t int_pin
Definition solidswitch.h:149
pin_name_t sda
Definition solidswitch.h:146
pin_name_t rst
Definition solidswitch.h:148
uint8_t i2c_address
Definition solidswitch.h:152
SolidSwitch Click context object.
Definition solidswitch.h:120
digital_in_t int_pin
Definition solidswitch.h:127
i2c_master_t i2c
Definition solidswitch.h:131
digital_out_t rst
Definition solidswitch.h:123
uint8_t slave_address
Definition solidswitch.h:135