Skip to content

Commit

Permalink
FHSS: use divider function in ufsi calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed Oct 30, 2018
1 parent 74c7f37 commit 3deb08c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_
cur_slot = fhss_structure->number_of_channels;
}
cur_slot--;
uint32_t remaining_time_ms = get_remaining_slots_us(fhss_structure, fhss_unicast_handler, fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval*1000) / 1000;
uint32_t remaining_time_ms = divide_integer(get_remaining_slots_us(fhss_structure, fhss_unicast_handler, fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval*1000), 1000);
uint32_t time_to_tx = 0;
uint32_t cur_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
if (cur_time < tx_time) {
time_to_tx = (tx_time - cur_time) / 1000;
time_to_tx = divide_integer((tx_time - cur_time), 1000);
}
uint64_t ms_since_seq_start = (cur_slot * dwell_time) + (dwell_time-remaining_time_ms) + time_to_tx;
uint32_t seq_length = 0x10000;
Expand Down Expand Up @@ -316,7 +316,7 @@ static uint16_t fhss_ws_calculate_destination_slot(fhss_ws_neighbor_timing_info_
seq_length = neighbor_timing_info->uc_timing_info.unicast_number_of_channels;
}
uint32_t dest_ms_since_seq_start = own_ceil((float)((uint64_t)ufsi*seq_length*dwell_time) / DEF_2E24);
return (own_floor(((float)((tx_time - ufsi_timestamp)/1000 + dest_ms_since_seq_start) / dwell_time)) % seq_length);
return (own_floor(((float)(divide_integer((tx_time - ufsi_timestamp),1000) + dest_ms_since_seq_start) / dwell_time)) % seq_length);
}

static uint32_t fhss_ws_get_sf_timeout_callback(fhss_structure_t *fhss_structure)
Expand Down

0 comments on commit 3deb08c

Please sign in to comment.