LibDriver PCF8574
Loading...
Searching...
No Matches
driver_pcf8574.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_PCF8574_H
38#define DRIVER_PCF8574_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
73
88
97
101typedef struct pcf8574_handle_s
102{
103 uint8_t iic_addr;
104 uint8_t (*iic_init)(void);
105 uint8_t (*iic_deinit)(void);
106 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
107 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
108 void (*delay_ms)(uint32_t ms);
109 void (*debug_print)(const char *const fmt, ...);
110 uint8_t inited;
112
128
132
139
146#define DRIVER_PCF8574_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
147
154#define DRIVER_PCF8574_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
155
162#define DRIVER_PCF8574_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
163
170#define DRIVER_PCF8574_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
171
178#define DRIVER_PCF8574_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
179
186#define DRIVER_PCF8574_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
187
194#define DRIVER_PCF8574_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
195
199
206
215uint8_t pcf8574_info(pcf8574_info_t *info);
216
227
238
250uint8_t pcf8574_init(pcf8574_handle_t *handle);
251
262uint8_t pcf8574_deinit(pcf8574_handle_t *handle);
263
277
291
295
302
315uint8_t pcf8574_set_reg(pcf8574_handle_t *handle, uint8_t *buf, uint16_t len);
316
329uint8_t pcf8574_get_reg(pcf8574_handle_t *handle, uint8_t *buf, uint16_t len);
330
334
338
339#ifdef __cplusplus
340}
341#endif
342
343#endif
uint8_t pcf8574_info(pcf8574_info_t *info)
get chip's information
struct pcf8574_info_s pcf8574_info_t
pcf8574 information structure definition
uint8_t pcf8574_deinit(pcf8574_handle_t *handle)
close the chip
uint8_t pcf8574_get_addr_pin(pcf8574_handle_t *handle, pcf8574_address_t *addr_pin)
get the address pin
uint8_t pcf8574_write(pcf8574_handle_t *handle, pcf8574_pin_t pin, pcf8574_pin_level_t level)
write the pin
struct pcf8574_handle_s pcf8574_handle_t
pcf8574 handle structure definition
pcf8574_pin_level_t
pcf8574 pin enumeration definition
uint8_t pcf8574_read(pcf8574_handle_t *handle, pcf8574_pin_t pin, pcf8574_pin_level_t *level)
read the pin
uint8_t pcf8574_init(pcf8574_handle_t *handle)
initialize the chip
pcf8574_pin_t
pcf8574 pin enumeration definition
pcf8574_address_t
pcf8574 address enumeration definition
uint8_t pcf8574_set_addr_pin(pcf8574_handle_t *handle, pcf8574_address_t addr_pin)
set the address pin
@ PCF8574_PIN_LEVEL_HIGH
@ PCF8574_PIN_LEVEL_LOW
@ PCF8574_PIN_0
@ PCF8574_PIN_3
@ PCF8574_PIN_4
@ PCF8574_PIN_6
@ PCF8574_PIN_7
@ PCF8574_PIN_5
@ PCF8574_PIN_1
@ PCF8574_PIN_2
@ PCF8574_ADDRESS_A111
@ PCF8574_ADDRESS_A000
@ PCF8574_ADDRESS_A010
@ PCF8574_ADDRESS_A001
@ PCF8574_ADDRESS_A100
@ PCF8574_ADDRESS_A011
@ PCF8574_ADDRESS_A101
@ PCF8574_ADDRESS_A110
uint8_t pcf8574_get_reg(pcf8574_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
uint8_t pcf8574_set_reg(pcf8574_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
pcf8574 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
pcf8574 information structure definition
uint32_t driver_version
char manufacturer_name[32]