mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/sfr04: Fixed int overflow for AVR (arduino board)
This commit is contained in:
parent
979eeed81a
commit
caa1ad822d
@ -54,7 +54,7 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
srf04_params_t p; /**< GPIO Ports of device */
|
||||
int distance; /**< raw time of flight distance */
|
||||
int32_t distance; /**< raw time of flight distance */
|
||||
uint32_t time; /**< timestamp of trigger or echo */
|
||||
} srf04_t;
|
||||
|
||||
|
@ -83,11 +83,13 @@ int srf04_read(const srf04_t* dev)
|
||||
|
||||
int srf04_get_distance(const srf04_t* dev)
|
||||
{
|
||||
/* trigger new reading */
|
||||
/* Trigger new reading */
|
||||
srf04_trigger(dev);
|
||||
/* give the sensor the required time for sampling */
|
||||
|
||||
/* Give the sensor the required time for sampling */
|
||||
xtimer_usleep(SRF04_SAMPLE_PERIOD);
|
||||
/* get the result */
|
||||
|
||||
/* Get the result */
|
||||
if (dev->distance >= SRF04_OK) {
|
||||
return ((dev->distance * 100) / SRF04_DISTANCE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user