diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c b/libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c index 21f9cc002f..72418cc51d 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c @@ -41,16 +41,12 @@ for micros64() */ -#if CH_CFG_ST_FREQUENCY != 1000000U && CH_CFG_ST_FREQUENCY != 1000U -#error "unsupported tick frequency" -#endif - #if CH_CFG_ST_RESOLUTION == 16 static uint32_t system_time_u32_us(void) { systime_t now = chVTGetSystemTimeX(); -#if CH_CFG_ST_FREQUENCY == 1000U - now *= 1000U; +#if CH_CFG_ST_FREQUENCY != 1000000U + now *= 1000000U/CH_CFG_ST_FREQUENCY; #endif static systime_t last_systime; static uint32_t timer_base_us32; @@ -63,8 +59,8 @@ static uint32_t system_time_u32_us(void) static uint32_t system_time_u32_us(void) { systime_t now = chVTGetSystemTimeX(); -#if CH_CFG_ST_FREQUENCY == 1000U - now *= 1000U; +#if CH_CFG_ST_FREQUENCY != 1000000U + now *= 1000000U/CH_CFG_ST_FREQUENCY; #endif return now; }