Device driver for the srf04 ultra sonic range finder.
More...
Device driver for the srf04 ultra sonic range finder.
|
file | srf04.h |
| Device driver for the srf04 ultra sonic range finder.
|
|
file | srf04_params.h |
| Default configuration for srf04 devices.
|
|
◆ anonymous enum
Status and error return codes.
Enumerator |
---|
SRF04_OK | exit without error
|
SRF04_ERR_INVALID | error no valid measurement available
|
SRF04_ERR_MEASURING | error sensor is measuring
|
SRF04_ERR_GPIO | error initializing gpio
|
Definition at line 37 of file srf04.h.
◆ srf04_get_distance()
int srf04_get_distance |
( |
const srf04_t * |
dev | ) |
|
Convenience function triggers a measurement and returns distance.
- Note
- This function will return after 50 ms once new data is available
- Parameters
-
[in] | dev | device descriptor of sensor |
- Returns
- time of flight in mm
-
SRF04_MEASURING if measurement is in progress
-
SRF04_INVALID if no valid measurement is available
◆ srf04_init()
Initialize gpio and interrupt.
- Parameters
-
[out] | dev | device descriptor of sensor to initialize |
[in] | params | init param struct holding gpio trigger and echo pins |
- Returns
- SRF04_OK on success
-
SRF04_GPIO on gpio init failure
◆ srf04_read()
int srf04_read |
( |
const srf04_t * |
dev | ) |
|
Returns time of flight in ms.
- Note
- should not be invoked within 50 ms after triggering
- Parameters
-
[in] | dev | device descriptor of sensor |
- Returns
- time of flight in ms
-
SRF04_MEASURING if measurement is in progress
-
SRF04_INVALID if no valid measurement is available
◆ srf04_trigger()
void srf04_trigger |
( |
const srf04_t * |
dev | ) |
|
Triggers measurement.
- Parameters
-
[in] | dev | device descriptor of sensor |