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 
28 #ifndef SRF08_H
29 #define SRF08_H
30 
31 #include <stdint.h>
32 #include "periph/i2c.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
39 #define SRF08_COMMAND_REG 0x0
40 
42 #define SRF08_GAIN_REG 0x1
43 
45 #define SRF08_RANGE_REG 0x2
46 
48 #define SRF08_RANGE_HIGH_BYTE 0x2
49 
51 #define SRF08_RANGE_LOW_BYTE 0x3
52 
54 #define SRF08_MAX_REGISTER_NUMBER 35
55 
57 #define SRF08_MAX_ECHO_NUMBER 17
58 
60 #define SRF08_MAX_RANGE_6M 0x8C
61 
63 #define SRF08_MAX_GAIN 0x1F
64 
68 typedef struct {
70  uint8_t addr;
72 
76 typedef struct {
78 } srf08_t;
79 
83 typedef enum {
84  SRF08_MODE_INCH = 0x50,
85  SRF08_MODE_CM = 0x51,
91 
103 int srf08_init(srf08_t *dev, const srf08_params_t *params);
104 
117 int srf08_set_max_range(const srf08_t *dev, uint8_t max_range);
118 
134 int srf08_set_max_gain(const srf08_t *dev, uint8_t max_gain);
135 
158 int srf08_get_distances(const srf08_t *dev,
159  uint16_t *range_array,
160  int num_echos,
161  srf08_mode_t ranging_mode);
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
168 #endif /* SRF08_H */
srf08_t::params
srf08_params_t params
Initialization parameters.
Definition: srf08.h:77
SRF08_MODE_INCH
@ SRF08_MODE_INCH
result in inches
Definition: srf08.h:84
srf08_init
int srf08_init(srf08_t *dev, const srf08_params_t *params)
Initialize the SRF08 ultrasonic sensor.
SRF08_ANN_MODE_INCH
@ SRF08_ANN_MODE_INCH
synchronous measurement in inch
Definition: srf08.h:87
srf08_params_t::i2c
i2c_t i2c
I2C device the sensor is connected to.
Definition: srf08.h:69
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
SRF08_MODE_CM
@ SRF08_MODE_CM
result in centimeters
Definition: srf08.h:85
SRF08_ANN_MODE_MICRO_SEC
@ SRF08_ANN_MODE_MICRO_SEC
synchronous measurement in us
Definition: srf08.h:89
SRF08_ANN_MODE_CM
@ SRF08_ANN_MODE_CM
synchronous measurement in cm
Definition: srf08.h:88
srf08_set_max_range
int srf08_set_max_range(const srf08_t *dev, uint8_t max_range)
Set the maximum range of the SRF08.
srf08_params_t
Device initialization parameters.
Definition: srf08.h:68
srf08_mode_t
srf08_mode_t
Possible measurement modes for the SRF08 sensor.
Definition: srf08.h:83
srf08_set_max_gain
int srf08_set_max_gain(const srf08_t *dev, uint8_t max_gain)
Set the maximum of the analog stages.
srf08_params_t::addr
uint8_t addr
I2C bus address of the sensor.
Definition: srf08.h:70
srf08_t
Device descriptor for SRF08 sensors.
Definition: srf08.h:76
SRF08_MODE_MICRO_SEC
@ SRF08_MODE_MICRO_SEC
result in centimeters
Definition: srf08.h:86
srf08_get_distances
int srf08_get_distances(const srf08_t *dev, uint16_t *range_array, int num_echos, srf08_mode_t ranging_mode)
Get all distances measured from the SRF08 ultrasonic sensor.
i2c.h
Low-level I2C peripheral driver interface definition.