Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_tca9534a.h
1 #ifndef _BC_TCA9534A_H
2 #define _BC_TCA9534A_H
3 
4 #include <bc_i2c.h>
5 #include <bc_tick.h>
6 
7 #define BC_TCA9534A_PIN_STATE_LOW 0
8 #define BC_TCA9534A_PIN_STATE_HIGH 1
9 
13 
15 
16 typedef enum
17 {
18  BC_TCA9534A_PIN_P0 = 0,
19  BC_TCA9534A_PIN_P1 = 1,
20  BC_TCA9534A_PIN_P2 = 2,
21  BC_TCA9534A_PIN_P3 = 3,
22  BC_TCA9534A_PIN_P4 = 4,
23  BC_TCA9534A_PIN_P5 = 5,
24  BC_TCA9534A_PIN_P6 = 6,
25  BC_TCA9534A_PIN_P7 = 7
26 
28 
30 
31 typedef enum
32 {
33  BC_TCA9534A_PIN_DIRECTION_OUTPUT = 0,
34  BC_TCA9534A_PIN_DIRECTION_INPUT = 1
35 
37 
39 
41 
42 typedef struct
43 {
44  bc_i2c_channel_t _i2c_channel;
45  uint8_t _i2c_address;
46  uint8_t _direction;
47  uint8_t _output_port;
48 
50 
55 
56 bool bc_tca9534a_init(bc_tca9534a_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
57 
63 
64 bool bc_tca9534a_read_port(bc_tca9534a_t *self, uint8_t *state);
65 
71 
72 bool bc_tca9534a_write_port(bc_tca9534a_t *self, uint8_t state);
73 
80 
81 bool bc_tca9534a_read_pin(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, int *state);
82 
89 
90 bool bc_tca9534a_write_pin(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, int state);
91 
97 
98 bool bc_tca9534a_get_port_direction(bc_tca9534a_t *self, uint8_t *direction);
99 
105 
106 bool bc_tca9534a_set_port_direction(bc_tca9534a_t *self, uint8_t direction);
107 
114 
116 
123 
125 
127 
128 #endif // _BC_TCA9534A_H
bool bc_tca9534a_set_port_direction(bc_tca9534a_t *self, uint8_t direction)
Set direction of all pins.
Definition: bc_tca9534a.c:87
bool bc_tca9534a_write_pin(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, int state)
Write pin state.
Definition: bc_tca9534a.c:61
Pin state.
Definition: bc_tca9534a.h:42
bool bc_tca9534a_write_port(bc_tca9534a_t *self, uint8_t state)
Write state to all pins.
Definition: bc_tca9534a.c:35
bool bc_tca9534a_read_port(bc_tca9534a_t *self, uint8_t *state)
Read state of all pins.
Definition: bc_tca9534a.c:30
bool bc_tca9534a_read_pin(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, int *state)
Read pin state.
Definition: bc_tca9534a.c:47
bool bc_tca9534a_get_port_direction(bc_tca9534a_t *self, uint8_t *direction)
Get direction of all pins.
Definition: bc_tca9534a.c:80
bool bc_tca9534a_init(bc_tca9534a_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize TCA9534A.
Definition: bc_tca9534a.c:8
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bc_tca9534a_pin_t
Individual pin names.
Definition: bc_tca9534a.h:16
bool bc_tca9534a_get_pin_direction(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, bc_tca9534a_pin_direction_t *direction)
Get pin direction.
Definition: bc_tca9534a.c:99
bool bc_tca9534a_set_pin_direction(bc_tca9534a_t *self, bc_tca9534a_pin_t pin, bc_tca9534a_pin_direction_t direction)
Set pin direction.
Definition: bc_tca9534a.c:113
bc_tca9534a_pin_direction_t
Pin direction.
Definition: bc_tca9534a.h:31