expand13 2.0.0.0
expand13.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 EXPAND13_H
29#define EXPAND13_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define EXPAND13_NO_PIN_MASK 0x00
60#define EXPAND13_PIN_0_MASK 0x01
61#define EXPAND13_PIN_1_MASK 0x02
62#define EXPAND13_PIN_2_MASK 0x04
63#define EXPAND13_PIN_3_MASK 0x08
64#define EXPAND13_PIN_4_MASK 0x10
65#define EXPAND13_PIN_5_MASK 0x20
66#define EXPAND13_PIN_6_MASK 0x40
67#define EXPAND13_PIN_7_MASK 0x80
68#define EXPAND13_ALL_PINS_MASK 0xFF
69
74#define EXPAND13_PORT_0 0x00
75#define EXPAND13_PORT_1 0x01
76#define EXPAND13_PORT_2 0x02
77#define EXPAND13_PORT_3 0x03
78#define EXPAND13_PORT_4 0x04
79#define EXPAND13_PORT_5 0x05
80
86#define EXPAND13_SET_DEV_ADDR_A2A1A0_000 0x20
87#define EXPAND13_SET_DEV_ADDR_A2A1A0_001 0x21
88#define EXPAND13_SET_DEV_ADDR_A2A1A0_010 0x22
89#define EXPAND13_SET_DEV_ADDR_A2A1A0_011 0x23
90#define EXPAND13_SET_DEV_ADDR_A2A1A0_100 0x24
91#define EXPAND13_SET_DEV_ADDR_A2A1A0_101 0x25
92#define EXPAND13_SET_DEV_ADDR_A2A1A0_110 0x26
93#define EXPAND13_SET_DEV_ADDR_A2A1A0_111 0x27
94 // expand13_set
96
111#define EXPAND13_MAP_MIKROBUS( cfg, mikrobus ) \
112 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
113 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
114 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
115 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
116 // expand13_map // expand13
119
124typedef struct
125{
126 // Output pins
127 digital_out_t rst;
129 // Input pins
130 digital_in_t int_pin;
132 // Modules
133 i2c_master_t i2c;
135 // I2C slave address
138} expand13_t;
139
144typedef struct
145{
146 pin_name_t scl;
147 pin_name_t sda;
149 pin_name_t rst;
150 pin_name_t int_pin;
152 uint32_t i2c_speed;
153 uint8_t i2c_address;
156
161typedef enum
162{
164 EXPAND13_ERROR = -1
165
167
184
200
210
220
230
243err_t expand13_write_all_ports ( expand13_t *ctx, uint8_t *ports );
244
257err_t expand13_read_all_ports ( expand13_t *ctx, uint8_t *ports );
258
278err_t expand13_set_port_value ( expand13_t *ctx, uint8_t port, uint8_t clr_mask, uint8_t set_mask );
279
298err_t expand13_read_port_value ( expand13_t *ctx, uint8_t port, uint8_t *data_out );
299
300#ifdef __cplusplus
301}
302#endif
303#endif // EXPAND13_H
304 // expand13
306
307// ------------------------------------------------------------------------ END
expand13_return_value_t
Expand 13 Click return value data.
Definition: expand13.h:162
@ EXPAND13_ERROR
Definition: expand13.h:164
@ EXPAND13_OK
Definition: expand13.h:163
uint8_t expand13_get_int_pin(expand13_t *ctx)
Expand 13 get int pin function.
err_t expand13_write_all_ports(expand13_t *ctx, uint8_t *ports)
Expand 13 write all ports function.
err_t expand13_read_all_ports(expand13_t *ctx, uint8_t *ports)
Expand 13 read all ports function.
void expand13_enable_device(expand13_t *ctx)
Expand 13 enable device function.
void expand13_cfg_setup(expand13_cfg_t *cfg)
Expand 13 configuration object setup function.
err_t expand13_set_port_value(expand13_t *ctx, uint8_t port, uint8_t clr_mask, uint8_t set_mask)
Expand 13 set port value function.
err_t expand13_read_port_value(expand13_t *ctx, uint8_t port, uint8_t *data_out)
Expand 13 read port value function.
err_t expand13_init(expand13_t *ctx, expand13_cfg_t *cfg)
Expand 13 initialization function.
void expand13_disable_device(expand13_t *ctx)
Expand 13 disable device function.
Expand 13 Click configuration object.
Definition: expand13.h:145
uint32_t i2c_speed
Definition: expand13.h:152
pin_name_t scl
Definition: expand13.h:146
pin_name_t int_pin
Definition: expand13.h:150
pin_name_t sda
Definition: expand13.h:147
pin_name_t rst
Definition: expand13.h:149
uint8_t i2c_address
Definition: expand13.h:153
Expand 13 Click context object.
Definition: expand13.h:125
digital_in_t int_pin
Definition: expand13.h:130
i2c_master_t i2c
Definition: expand13.h:133
digital_out_t rst
Definition: expand13.h:127
uint8_t slave_address
Definition: expand13.h:136