Browse Source

HAL_ChibiOS: fixed system time for clocks other than 1MHz

needed for IOMCU
master
Andrew Tridgell 6 years ago
parent
commit
4674a1c68d
  1. 6
      libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c

6
libraries/AP_HAL_ChibiOS/hwdef/common/hrt.c

@ -31,6 +31,9 @@ static volatile systime_t last_systime; @@ -31,6 +31,9 @@ static volatile systime_t last_systime;
static uint32_t get_systime_us32(void)
{
systime_t now = chVTGetSystemTimeX();
#if CH_CFG_ST_FREQUENCY != 1000000
now *= (1000000UL / CH_CFG_ST_FREQUENCY);
#endif
if (now < last_systime) {
uint32_t last_u32 = timer_base_us32;
timer_base_us32 += (uint32_t)TIME_MAX_SYSTIME;
@ -47,6 +50,9 @@ static uint32_t get_systime_us32(void) @@ -47,6 +50,9 @@ static uint32_t get_systime_us32(void)
static uint32_t get_systime_us32(void)
{
systime_t now = chVTGetSystemTimeX();
#if CH_CFG_ST_FREQUENCY != 1000000
now *= (1000000UL / CH_CFG_ST_FREQUENCY);
#endif
if (now < last_systime) {
timer_base_us64 += TIME_MAX_SYSTIME;
timer_base_ms += TIME_MAX_SYSTIME/1000;

Loading…
Cancel
Save