srf02.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
3  * 2015 Freie Universit├Ąt Berlin
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
24 #ifndef SRF02_H
25 #define SRF02_H
26 
27 #include <stdint.h>
28 #include "periph/i2c.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #define SRF02_DEFAULT_ADDR (0xe0) /* 224 decimal */
38 
42 #define SRF02_RANGE_DELAY (70000U)
43 
47 typedef struct {
49  uint8_t addr;
50 } srf02_t;
51 
55 typedef enum {
62 } srf02_mode_t;
63 
74 int srf02_init(srf02_t *dev, i2c_t i2c, uint8_t addr);
75 
91 void srf02_trigger(srf02_t *dev, srf02_mode_t mode);
92 
101 uint16_t srf02_read(srf02_t *dev);
102 
118 uint16_t srf02_get_distance(srf02_t *dev, srf02_mode_t mode);
119 
126 void srf02_set_addr(srf02_t *dev, uint8_t new_addr);
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif /* SRF02_H */
133 
int srf02_init(srf02_t *dev, i2c_t i2c, uint8_t addr)
Initialize the SRF02 ultrasonic sensor.
srf02_mode_t
Possible measurement modes of the SRF02 sensor.
Definition: srf02.h:55
result in inches
Definition: srf02.h:56
void srf02_set_addr(srf02_t *dev, uint8_t new_addr)
Program the given device with a new bus address.
result in cm (no pulse send)
Definition: srf02.h:60
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
result in centimeters
Definition: srf02.h:57
i2c_t i2c
I2C device the sensor is connected to.
Definition: srf02.h:48
void srf02_trigger(srf02_t *dev, srf02_mode_t mode)
Trigger a new measurement.
result in ms (no pulse send)
Definition: srf02.h:61
result in inches (no pulse send)
Definition: srf02.h:59
uint8_t addr
I2C bus address of the sensor.
Definition: srf02.h:49
uint16_t srf02_read(srf02_t *dev)
Read the results of the last ranging operation.
result in microseconds
Definition: srf02.h:58
Device descriptor for SRF02 sensors.
Definition: srf02.h:47
uint16_t srf02_get_distance(srf02_t *dev, srf02_mode_t mode)
Get the distance measured from the SRF02 ultrasonic sensor.
Low-level I2C peripheral driver interface definition.