Loading...
Searching...
No Matches
srf08.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2013 Zakaria Kasmi <zkasmi@inf.fu-berlin.de>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
26
27#include <stdint.h>
28#include "periph/i2c.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
35#define SRF08_COMMAND_REG 0x0
36
38#define SRF08_GAIN_REG 0x1
39
41#define SRF08_RANGE_REG 0x2
42
44#define SRF08_RANGE_HIGH_BYTE 0x2
45
47#define SRF08_RANGE_LOW_BYTE 0x3
48
50#define SRF08_MAX_REGISTER_NUMBER 35
51
53#define SRF08_MAX_ECHO_NUMBER 17
54
56#define SRF08_MAX_RANGE_6M 0x8C
57
59#define SRF08_MAX_GAIN 0x1F
60
64typedef struct {
66 uint8_t addr;
68
72typedef struct {
74} srf08_t;
75
87
99int srf08_init(srf08_t *dev, const srf08_params_t *params);
100
113int srf08_set_max_range(const srf08_t *dev, uint8_t max_range);
114
130int srf08_set_max_gain(const srf08_t *dev, uint8_t max_gain);
131
155 uint16_t *range_array,
156 int num_echos,
157 srf08_mode_t ranging_mode);
158
159#ifdef __cplusplus
160}
161#endif
162
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
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.
int srf08_set_max_range(const srf08_t *dev, uint8_t max_range)
Set the maximum range of the SRF08.
int srf08_init(srf08_t *dev, const srf08_params_t *params)
Initialize the SRF08 ultrasonic sensor.
int srf08_set_max_gain(const srf08_t *dev, uint8_t max_gain)
Set the maximum of the analog stages.
srf08_mode_t
Possible measurement modes for the SRF08 sensor.
Definition srf08.h:79
@ SRF08_ANN_MODE_INCH
synchronous measurement in inch
Definition srf08.h:83
@ SRF08_MODE_INCH
result in inches
Definition srf08.h:80
@ SRF08_MODE_MICRO_SEC
result in centimeters
Definition srf08.h:82
@ SRF08_ANN_MODE_MICRO_SEC
synchronous measurement in us
Definition srf08.h:85
@ SRF08_MODE_CM
result in centimeters
Definition srf08.h:81
@ SRF08_ANN_MODE_CM
synchronous measurement in cm
Definition srf08.h:84
Low-level I2C peripheral driver interface definition.
Device initialization parameters.
Definition srf08.h:64
i2c_t i2c
I2C device the sensor is connected to.
Definition srf08.h:65
uint8_t addr
I2C bus address of the sensor.
Definition srf08.h:66
Device descriptor for SRF08 sensors.
Definition srf08.h:72
srf08_params_t params
Initialization parameters.
Definition srf08.h:73