Skip to content

Commit f01c5f2

Browse files
author
Jarkko Paso
committed
fhss_ws: conversion macros/functions to support int64
1 parent ab23116 commit f01c5f2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ void (*fhss_uc_switch)(void) = NULL;
4444
void (*fhss_bc_switch)(void) = NULL;
4545
#endif /*FHSS_CHANNEL_DEBUG_CBS*/
4646
// Seconds to milliseconds
47-
#define S_TO_MS(x) (((int32_t)x)*1000)
47+
#define S_TO_MS(x) (((int64_t)x)*1000)
4848
// Milliseconds to seconds
4949
#define MS_TO_S(x) divide_integer(x, 1000)
5050
// Seconds to microseconds
51-
#define S_TO_US(x) (((int32_t)x)*1000000)
51+
#define S_TO_US(x) (((int64_t)x)*1000000)
5252
// Microseconds to seconds
5353
#define US_TO_S(x) divide_integer(x, 1000000)
5454
// Milliseconds to microseconds
55-
#define MS_TO_US(x) (((int32_t)x)*1000)
55+
#define MS_TO_US(x) (((int64_t)x)*1000)
5656
// Microseconds to milliseconds
5757
#define US_TO_MS(x) divide_integer(x, 1000)
5858
// Milliseconds to nanoseconds
59-
#define MS_TO_NS(x) (((int32_t)x)*1000000)
59+
#define MS_TO_NS(x) (((int64_t)x)*1000000)
6060
// Nanoseconds to milliseconds
6161
#define NS_TO_MS(x) divide_integer(x, 1000000)
6262
// Microseconds to nanoseconds
63-
#define US_TO_NS(x) (((int32_t)x)*1000)
63+
#define US_TO_NS(x) (((int64_t)x)*1000)
6464
// Nanoseconds to microseconds
6565
#define NS_TO_US(x) divide_integer(x, 1000)
6666
#define DEF_2E24 0x1000000
@@ -86,7 +86,7 @@ static bool fhss_ws_check_tx_allowed(fhss_structure_t *fhss_structure);
8686
static uint32_t fhss_set_txrx_slot_length(fhss_structure_t *fhss_structure);
8787

8888
// This function supports rounding up
89-
static int32_t divide_integer(int32_t dividend, int32_t divisor)
89+
static int32_t divide_integer(int64_t dividend, int32_t divisor)
9090
{
9191
if (dividend < 0) {
9292
return (dividend - divisor / 2) / divisor;
@@ -821,8 +821,6 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
821821
uint32_t prev_synchronization_time = fhss_structure->ws->synchronization_time;
822822
fhss_structure->ws->synchronization_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
823823
uint32_t time_since_last_synch_us = fhss_structure->ws->synchronization_time - prev_synchronization_time;
824-
// IOTTHD-3571, temporary debug traces
825-
tr_debug("time_since_last_synch_us: %"PRIu32", synchronization_time: %"PRIu32", prev_synchronization_time: %"PRIu32"", time_since_last_synch_us, fhss_structure->ws->synchronization_time, prev_synchronization_time);
826824
uint32_t own_bc_interval_offset = fhss_ws_calculate_broadcast_interval_offset(fhss_structure, fhss_structure->ws->synchronization_time);
827825
fhss_stop_timer(fhss_structure, fhss_broadcast_handler);
828826
uint32_t time_from_reception_ms = US_TO_MS(fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp);

0 commit comments

Comments
 (0)