diff --git a/src/platforms/posix/drivers/barosim/baro.cpp b/src/platforms/posix/drivers/barosim/baro.cpp index 90f0f71efc..91bd149135 100644 --- a/src/platforms/posix/drivers/barosim/baro.cpp +++ b/src/platforms/posix/drivers/barosim/baro.cpp @@ -439,10 +439,10 @@ BAROSIM::ioctl(device::file_t *filp, int cmd, unsigned long arg) bool want_start = (_measure_ticks == 0); /* convert hz to tick interval via microseconds */ - unsigned ticks = USEC2TICK(1000000 / arg); + unsigned long ticks = USEC2TICK(1000000 / arg); /* check against maximum rate */ - if ((long)ticks < USEC2TICK(BAROSIM_CONVERSION_INTERVAL)) + if (ticks < USEC2TICK(BAROSIM_CONVERSION_INTERVAL)) return -EINVAL; /* update interval for next measurement */ @@ -559,7 +559,7 @@ BAROSIM::cycle() * doing pressure measurements at something close to the desired rate. */ if ((_measure_phase != 0) && - ((long)_measure_ticks > USEC2TICK(BAROSIM_CONVERSION_INTERVAL))) { + (_measure_ticks > USEC2TICK(BAROSIM_CONVERSION_INTERVAL))) { /* schedule a fresh cycle call when we are ready to measure again */ work_queue(HPWORK, diff --git a/src/platforms/px4_defines.h b/src/platforms/px4_defines.h index 41499e69c7..e123a008c5 100644 --- a/src/platforms/px4_defines.h +++ b/src/platforms/px4_defines.h @@ -131,7 +131,7 @@ __BEGIN_DECLS extern long PX4_TICKS_PER_SEC; __END_DECLS -#define USEC_PER_TICK (1000000L/PX4_TICKS_PER_SEC) +#define USEC_PER_TICK (1000000UL/PX4_TICKS_PER_SEC) #define USEC2TICK(x) (((x)+(USEC_PER_TICK/2))/USEC_PER_TICK) #define px4_statfs_buf_f_bavail_t unsigned long