LibDriver PCF8575
Loading...
Searching...
No Matches
driver_pcf8575.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_PCF8575_H
38#define DRIVER_PCF8575_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
96
105
109typedef struct pcf8575_handle_s
110{
111 uint8_t iic_addr;
112 uint8_t (*iic_init)(void);
113 uint8_t (*iic_deinit)(void);
114 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
115 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
116 void (*delay_ms)(uint32_t ms);
117 void (*debug_print)(const char *const fmt, ...);
118 uint8_t inited;
119 uint16_t output_shadow;
121
137
141
148
155#define DRIVER_PCF8575_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
156
163#define DRIVER_PCF8575_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
164
171#define DRIVER_PCF8575_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
172
179#define DRIVER_PCF8575_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
180
187#define DRIVER_PCF8575_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
188
195#define DRIVER_PCF8575_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
196
203#define DRIVER_PCF8575_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
204
208
215
224uint8_t pcf8575_info(pcf8575_info_t *info);
225
236
247
259uint8_t pcf8575_init(pcf8575_handle_t *handle);
260
271uint8_t pcf8575_deinit(pcf8575_handle_t *handle);
272
286
300
304
311
324uint8_t pcf8575_set_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len);
325
338uint8_t pcf8575_get_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len);
339
343
347
348#ifdef __cplusplus
349}
350#endif
351
352#endif
uint8_t pcf8575_deinit(pcf8575_handle_t *handle)
close the chip
struct pcf8575_handle_s pcf8575_handle_t
pcf8575 handle structure definition
uint8_t pcf8575_set_addr_pin(pcf8575_handle_t *handle, pcf8575_address_t addr_pin)
set the address pin
uint8_t pcf8575_write(pcf8575_handle_t *handle, pcf8575_pin_t pin, pcf8575_pin_level_t level)
write the pin
uint8_t pcf8575_read(pcf8575_handle_t *handle, pcf8575_pin_t pin, pcf8575_pin_level_t *level)
read the pin
uint8_t pcf8575_init(pcf8575_handle_t *handle)
initialize the chip
pcf8575_address_t
pcf8575 address enumeration definition
pcf8575_pin_t
pcf8575 pin enumeration definition
pcf8575_pin_level_t
pcf8575 pin enumeration definition
struct pcf8575_info_s pcf8575_info_t
pcf8575 information structure definition
uint8_t pcf8575_info(pcf8575_info_t *info)
get chip's information
uint8_t pcf8575_get_addr_pin(pcf8575_handle_t *handle, pcf8575_address_t *addr_pin)
get the address pin
@ PCF8575_ADDRESS_A111
@ PCF8575_ADDRESS_A100
@ PCF8575_ADDRESS_A010
@ PCF8575_ADDRESS_A011
@ PCF8575_ADDRESS_A110
@ PCF8575_ADDRESS_A101
@ PCF8575_ADDRESS_A000
@ PCF8575_ADDRESS_A001
@ PCF8575_PIN_06
@ PCF8575_PIN_17
@ PCF8575_PIN_04
@ PCF8575_PIN_16
@ PCF8575_PIN_02
@ PCF8575_PIN_03
@ PCF8575_PIN_07
@ PCF8575_PIN_01
@ PCF8575_PIN_10
@ PCF8575_PIN_05
@ PCF8575_PIN_00
@ PCF8575_PIN_14
@ PCF8575_PIN_12
@ PCF8575_PIN_13
@ PCF8575_PIN_15
@ PCF8575_PIN_11
@ PCF8575_PIN_LEVEL_LOW
@ PCF8575_PIN_LEVEL_HIGH
uint8_t pcf8575_set_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
uint8_t pcf8575_get_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
pcf8575 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)
pcf8575 information structure definition
uint32_t driver_version
char manufacturer_name[32]