gp2y10xx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Locha Inc
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
37 #ifndef GP2Y10XX_H
38 #define GP2Y10XX_H
39 
40 #include <stdint.h>
41 #include <stdbool.h>
42 
43 #include "periph/adc.h"
44 #include "periph/gpio.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
56 #ifndef CONFIG_GP2Y10XX_MAX_READINGS
57 #define CONFIG_GP2Y10XX_MAX_READINGS (10)
58 #endif
59 
63 enum {
67 };
68 
76 typedef enum {
80 
84 typedef struct {
87  uint16_t vref;
89  gpio_t iled_pin;
92 
96 typedef struct {
98 } gp2y10xx_t;
99 
110 int gp2y10xx_init(gp2y10xx_t *dev, const gp2y10xx_params_t *params);
111 
121 int gp2y10xx_read_density(const gp2y10xx_t *dev, uint16_t *density);
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
127 #endif /* GP2Y10XX_H */
128 
GP2Y10XX_ERR_ADC
@ GP2Y10XX_ERR_ADC
ADC error.
Definition: gp2y10xx.h:65
gp2y10xx_t
GP2Y10xx device descriptor.
Definition: gp2y10xx.h:96
adc_t
unsigned int adc_t
Define default ADC type identifier.
Definition: adc.h:72
GP2Y10XX_ILED_LEVEL_LOW
@ GP2Y10XX_ILED_LEVEL_LOW
Active low.
Definition: gp2y10xx.h:78
adc_res_t
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:93
adc.h
Low-level ADC peripheral driver interface definitions.
gp2y10xx_params_t
GP2Y10xx device parameters.
Definition: gp2y10xx.h:84
gp2y10xx_level_t
gp2y10xx_level_t
ILED pin level.
Definition: gp2y10xx.h:76
gp2y10xx_init
int gp2y10xx_init(gp2y10xx_t *dev, const gp2y10xx_params_t *params)
Initialize an GP2Y10xx device.
gp2y10xx_params_t::iled_level
gp2y10xx_level_t iled_level
ILED pin level.
Definition: gp2y10xx.h:90
gp2y10xx_read_density
int gp2y10xx_read_density(const gp2y10xx_t *dev, uint16_t *density)
Read a raw ADC value.
gp2y10xx_params_t::vref
uint16_t vref
Reference voltage used for the VCC supply of the sensor, in mV.
Definition: gp2y10xx.h:87
gp2y10xx_params_t::aout
adc_t aout
ADC line connected to device AOUT pin.
Definition: gp2y10xx.h:85
gp2y10xx_t::params
gp2y10xx_params_t params
device driver configuration
Definition: gp2y10xx.h:97
GP2Y10XX_ILED_LEVEL_HIGH
@ GP2Y10XX_ILED_LEVEL_HIGH
Active high.
Definition: gp2y10xx.h:77
gp2y10xx_params_t::iled_pin
gpio_t iled_pin
ILED pin.
Definition: gp2y10xx.h:89
gpio.h
Low-level GPIO peripheral driver interface definitions.
GP2Y10XX_ERR_ILED
@ GP2Y10XX_ERR_ILED
ILED pin error.
Definition: gp2y10xx.h:66
gp2y10xx_params_t::adc_res
adc_res_t adc_res
ADC line resolution.
Definition: gp2y10xx.h:86
GP2Y10XX_OK
@ GP2Y10XX_OK
Everything is ok.
Definition: gp2y10xx.h:64