예제 #1
0
void windturbine_periodic( void ) {
  if (trigger_ext_valid == TRUE) {
    uint8_t ac_id = 0;
    uint8_t turb_id = TURBINE_ID;
    uint32_t sync_itow, cycle_time;

    sync_itow = gps_tow_from_sys_ticks(trigger_t0);
    cycle_time = msec_of_sys_time_ticks(trigger_delta_t0);

    DOWNLINK_SEND_WINDTURBINE_STATUS_(DefaultChannel, DefaultDevice,
                &ac_id,
                &turb_id,
                &sync_itow,
                &cycle_time );
    trigger_ext_valid = FALSE;
  }
}
예제 #2
0
파일: gps.c 프로젝트: 2seasuav/paparuzzi
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
{
  uint32_t clock_delta;
  uint32_t time_delta;
  uint32_t itow_now;

  if (sys_ticks < gps_time_sync.t0_ticks) {
    clock_delta = (0xFFFFFFFF - sys_ticks) + gps_time_sync.t0_ticks + 1;
  } else {
    clock_delta = sys_ticks - gps_time_sync.t0_ticks;
  }

  time_delta = msec_of_sys_time_ticks(clock_delta);

  itow_now = gps_time_sync.t0_tow + time_delta;
  if (itow_now > MSEC_PER_WEEK) {
    itow_now %= MSEC_PER_WEEK;
  }

  return itow_now;
}