Skip to content

TEST update : tests-mbed_hal-common_tickers_freq #6573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions TESTS/mbed_hal/common_tickers_freq/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const ticker_interface_t* intf;

static volatile unsigned int overflowCounter;

unsigned int ticks_to_us(unsigned int ticks, unsigned int freq)
uint32_t ticks_to_us(uint32_t ticks, uint32_t freq)
{
return (unsigned int)((unsigned long long)ticks * US_PER_S / freq);
return (uint32_t)((uint64_t)ticks * US_PER_S / freq);
}

void ticker_event_handler_stub(const ticker_data_t * const ticker)
Expand All @@ -65,11 +65,9 @@ void ticker_frequency_test()
char _key[11] = { };
char _value[128] = { };
int expected_key = 1;
const unsigned int ticker_freq = intf->get_info()->frequency;
const unsigned int ticker_bits = intf->get_info()->bits;
const unsigned int ticker_max = (1 << ticker_bits) - 1;

overflowCounter = 0;
const uint32_t ticker_freq = intf->get_info()->frequency;
const uint32_t ticker_bits = intf->get_info()->bits;
const uint32_t ticker_max = (1 << ticker_bits) - 1;

intf->init();

Expand All @@ -84,15 +82,17 @@ void ticker_frequency_test()
expected_key = strcmp(_key, "base_time");
} while (expected_key);

const unsigned int begin_ticks = intf->read();
overflowCounter = 0;

const uint32_t begin_ticks = intf->read();

/* Assume that there was no overflow at this point - we are just after init. */
greentea_send_kv(_key, ticks_to_us(begin_ticks, ticker_freq));

/* Wait for 2nd signal from host. */
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));

const unsigned int end_ticks = intf->read();
const uint32_t end_ticks = intf->read();

greentea_send_kv(_key, ticks_to_us(end_ticks + overflowCounter * ticker_max, ticker_freq));

Expand Down