LibDriver GP2Y1051AU0F  1.0.0
GP2Y1051AU0F full-featured driver
driver_gp2y1051au0f_basic.c
Go to the documentation of this file.
1 
38 
39 static gp2y1051au0f_handle_t gs_handle;
49 {
50  uint8_t res;
51 
52  /* link interface function */
60 
61  /* gp2y1051au0f init */
62  res = gp2y1051au0f_init(&gs_handle);
63  if (res != 0)
64  {
65  gp2y1051au0f_interface_debug_print("gp2y1051au0f: init failed.\n");
66 
67  return 1;
68  }
69 
70  return 0;
71 }
72 
81 uint8_t gp2y1051au0f_basic_read(float *mg_m3)
82 {
83  uint8_t res;
84  uint16_t raw;
85 
86  /* read */
87  res = gp2y1051au0f_read(&gs_handle, &raw, mg_m3);
88  if (res != 0)
89  {
90  return 1;
91  }
92 
93  return 0;
94 }
95 
104 {
105  /* deinit gp2y1051au0f */
106  if (gp2y1051au0f_deinit(&gs_handle) != 0)
107  {
108  return 1;
109  }
110 
111  return 0;
112 }
driver gp2y1051au0f basic header file
uint8_t gp2y1051au0f_read(gp2y1051au0f_handle_t *handle, uint16_t *raw, float *mg_m3)
read the data
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_basic_deinit(void)
basic example deinit
uint8_t gp2y1051au0f_basic_init(void)
basic example init
uint8_t gp2y1051au0f_basic_read(float *mg_m3)
basic example read
uint8_t gp2y1051au0f_interface_uart_deinit(void)
interface uart deinit
uint8_t gp2y1051au0f_interface_uart_flush(void)
interface uart flush
void gp2y1051au0f_interface_delay_ms(uint32_t ms)
interface delay ms
uint16_t gp2y1051au0f_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
uint8_t gp2y1051au0f_interface_uart_init(void)
interface uart init
void gp2y1051au0f_interface_debug_print(const char *const fmt,...)
interface print format data
gp2y1051au0f handle structure definition