drivers: counter: add counter_get_value(), deprecate counter_read()

Introduce a new counter API function for reading the current counter
value (counter_get_value()) and deprecate the former counter_read() in
favor of this.

Update all drivers and calling code to match the new counter API.

The previous counter driver API function for reading the current value
of the counter (counter_read()) did not support indicating whether the
read suceeded. This is fine for counters internal to the SoC where the
read always succeeds but insufficient for external counters (e.g. I2C
or SPI slaves).

Fixes #21846.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
This commit is contained in:
Henrik Brix Andersen 2020-01-18 15:24:32 +01:00 committed by Anas Nashif
commit c894a6db4d
19 changed files with 162 additions and 58 deletions

View file

@ -106,7 +106,16 @@ void BoardCriticalSectionEnd(uint32_t *mask)
uint32_t RtcGetTimerElapsedTime(void)
{
return counter_read(dev_data.counter);
u32_t ticks;
int err;
err = counter_get_value(dev_data.counter, &ticks);
if (err) {
LOG_ERR("Failed to read counter value (err %d)", err);
return 0;
}
return ticks;
}
u32_t RtcGetMinimumTimeout(void)