The friendly Operating System for the Internet of Things
srf08.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
27 #ifndef SRF08_H
28 #define SRF08_H
29 
30 #include <stdint.h>
31 #include "periph/i2c.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 #define SRF08_DEFAULT_ADDR 112
39 
41 #define SRF08_COMMAND_REG 0x0
42 
44 #define SRF08_GAIN_REG 0x1
45 
47 #define SRF08_RANGE_REG 0x2
48 
50 #define SRF08_RANGE_HIGH_BYTE 0x2
51 
53 #define SRF08_RANGE_LOW_BYTE 0x3
54 
56 #define SRF08_MAX_REGISTER_NUMBER 35
57 
59 #define SRF08_MAX_ECHO_NUMBER 17
60 
62 #define SRF08_MAX_RANGE_6M 0x8C
63 
65 #define SRF08_MAX_GAIN 0x25
66 
70 typedef struct {
72  uint8_t addr;
73 } srf08_t;
74 
78 typedef enum {
79  SRF08_MODE_INCH = 0x50,
80  SRF08_MODE_CM = 0x51,
86 
102 int srf08_init(srf08_t *dev, i2c_t i2c, uint8_t addr, i2c_speed_t speed);
103 
116 int srf08_set_max_range(srf08_t *dev, uint8_t max_range);
117 
133 int srf08_set_max_gain(srf08_t *dev, uint8_t max_gain);
134 
157 int srf08_get_distances(srf08_t *dev, uint16_t *range_array, int num_echos, srf08_mode_t ranging_mode);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
164 #endif /* SRF08_H */
srf08_mode_t
Possible measurement modes for the SRF08 sensor.
Definition: srf08.h:78
int srf08_set_max_gain(srf08_t *dev, uint8_t max_gain)
Set the maximum of the analog stages.
int srf08_init(srf08_t *dev, i2c_t i2c, uint8_t addr, i2c_speed_t speed)
Initialize the SRF08 ultrasonic sensor.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:104
result in centimeters
Definition: srf08.h:80
result in inches
Definition: srf08.h:79
synchronous measurement in inches
Definition: srf08.h:82
synchronous measurement in centimeters
Definition: srf08.h:83
result in centimeters
Definition: srf08.h:81
Device descriptor for SRF08 sensors.
Definition: srf08.h:70
int srf08_get_distances(srf08_t *dev, uint16_t *range_array, int num_echos, srf08_mode_t ranging_mode)
Get all distances measured from the SRF08 ultrasonic sensor.
int srf08_set_max_range(srf08_t *dev, uint8_t max_range)
Set the maximum range of the SRF08.
i2c_t i2c
I2C device the sensor is connected to.
Definition: srf08.h:71
uint8_t addr
I2C bus address of the sensor.
Definition: srf08.h:72
synchronous measurement in microseconds
Definition: srf08.h:84
Low-level I2C peripheral driver interface definition.