LibDriver GP2Y1051AU0F  1.0.0
GP2Y1051AU0F full-featured driver
driver_gp2y1051au0f.h
Go to the documentation of this file.
1 
37 #ifndef DRIVER_GP2Y1051AU0F_H
38 #define DRIVER_GP2Y1051AU0F_H
39 
40 #include <stdio.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 #ifdef __cplusplus
45 extern "C"{
46 #endif
47 
62 typedef struct gp2y1051au0f_handle_s
63 {
64  uint8_t (*uart_init)(void);
65  uint8_t (*uart_deinit)(void);
66  uint16_t (*uart_read)(uint8_t *buf, uint16_t len);
67  uint8_t (*uart_flush)(void);
68  void (*delay_ms)(uint32_t ms);
69  void (*debug_print)(const char *const fmt, ...);
70  uint8_t inited;
72 
76 typedef struct gp2y1051au0f_info_s
77 {
78  char chip_name[32];
79  char manufacturer_name[32];
80  char interface[8];
86  uint32_t driver_version;
88 
106 #define DRIVER_GP2Y1051AU0F_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
107 
114 #define DRIVER_GP2Y1051AU0F_LINK_UART_INIT(HANDLE, FUC) (HANDLE)->uart_init = FUC
115 
122 #define DRIVER_GP2Y1051AU0F_LINK_UART_DEINIT(HANDLE, FUC) (HANDLE)->uart_deinit = FUC
123 
130 #define DRIVER_GP2Y1051AU0F_LINK_UART_READ(HANDLE, FUC) (HANDLE)->uart_read = FUC
131 
138 #define DRIVER_GP2Y1051AU0F_LINK_UART_FLUSH(HANDLE, FUC) (HANDLE)->uart_flush = FUC
139 
146 #define DRIVER_GP2Y1051AU0F_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
147 
154 #define DRIVER_GP2Y1051AU0F_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
155 
176 
188 
200 
216 uint8_t gp2y1051au0f_read(gp2y1051au0f_handle_t *handle, uint16_t *raw, float *mg_m3);
217 
242 uint8_t gp2y1051au0f_get_buf(gp2y1051au0f_handle_t *handle, char *buf, uint16_t len, uint32_t ms);
243 
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif
uint8_t gp2y1051au0f_read(gp2y1051au0f_handle_t *handle, uint16_t *raw, float *mg_m3)
read the data
uint8_t gp2y1051au0f_info(gp2y1051au0f_info_t *info)
get chip's information
struct gp2y1051au0f_handle_s gp2y1051au0f_handle_t
gp2y1051au0f handle structure definition
struct gp2y1051au0f_info_s gp2y1051au0f_info_t
gp2y1051au0f information structure definition
uint8_t gp2y1051au0f_init(gp2y1051au0f_handle_t *handle)
initialize the chip
uint8_t gp2y1051au0f_deinit(gp2y1051au0f_handle_t *handle)
close the chip
uint8_t gp2y1051au0f_get_buf(gp2y1051au0f_handle_t *handle, char *buf, uint16_t len, uint32_t ms)
get buffer
gp2y1051au0f handle structure definition
uint8_t(* uart_flush)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* uart_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint16_t(* uart_read)(uint8_t *buf, uint16_t len)
uint8_t(* uart_init)(void)
gp2y1051au0f information structure definition