drivers: counter: nrfx_timer: Add barrier when reading CC
Add barrier between triggering Capture task and reading CC as otherwise it is possible that CC read will occur before task is triggered when bus is busy. Add barrier between reading previous CC value and writing the new one. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
dc711d721e
commit
d8c3ae0286
1 changed files with 2 additions and 0 deletions
|
|
@ -89,6 +89,7 @@ static uint32_t read(const struct device *dev)
|
||||||
|
|
||||||
nrf_timer_task_trigger(timer,
|
nrf_timer_task_trigger(timer,
|
||||||
nrf_timer_capture_task_get(COUNTER_READ_CC));
|
nrf_timer_capture_task_get(COUNTER_READ_CC));
|
||||||
|
nrf_barrier_w();
|
||||||
|
|
||||||
return nrf_timer_cc_get(timer, COUNTER_READ_CC);
|
return nrf_timer_cc_get(timer, COUNTER_READ_CC);
|
||||||
}
|
}
|
||||||
|
|
@ -160,6 +161,7 @@ static int set_cc(const struct device *dev, uint8_t id, uint32_t val,
|
||||||
*/
|
*/
|
||||||
now = read(dev);
|
now = read(dev);
|
||||||
prev_val = nrf_timer_cc_get(reg, chan);
|
prev_val = nrf_timer_cc_get(reg, chan);
|
||||||
|
nrf_barrier_r();
|
||||||
nrf_timer_cc_set(reg, chan, now);
|
nrf_timer_cc_set(reg, chan, now);
|
||||||
nrf_timer_event_clear(reg, evt);
|
nrf_timer_event_clear(reg, evt);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue