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;
120
136
140
147
154#define DRIVER_PCF8575_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
155
162#define DRIVER_PCF8575_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
163
170#define DRIVER_PCF8575_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
171
178#define DRIVER_PCF8575_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
179
186#define DRIVER_PCF8575_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
187
194#define DRIVER_PCF8575_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
195
202#define DRIVER_PCF8575_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
203
207
214
223uint8_t pcf8575_info(pcf8575_info_t *info);
224
235
246
258uint8_t pcf8575_init(pcf8575_handle_t *handle);
259
270uint8_t pcf8575_deinit(pcf8575_handle_t *handle);
271
285
299
303
310
323uint8_t pcf8575_set_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len);
324
337uint8_t pcf8575_get_reg(pcf8575_handle_t *handle, uint8_t *buf, uint16_t len);
338
342
346
347#ifdef __cplusplus
348}
349#endif
350
351#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]