Commit Graph

17 Commits (cd573a603fb35f974d5421cbf33cf90e8c0f5ed2)

Author SHA1 Message Date
Laurent MEUNIER f2eb77a81a STM32_us_ticker_16b: reset counter when fire interrupt
Fixing regression introduced in commit
"Ticker: add fire interrupt now function".

In above mentioned commit, the management of timestamp being in the past
has been moved to higher layer (hal/mbed_ticker_api.c), but the reset of
oc_int was missing when implementing the new us_ticker_fire_interrupt
function - which is fixed now.
2017-09-05 13:03:21 +02:00
Wolfgang Betz 4fe8e8ca44 Align HAL & US tickers 2017-07-25 13:25:09 +02:00
Martin Kojtal 10ea63b8e7 Ticker: add fire interrupt now function
fire_interrupt function should be used for events in the past. As we have now
64bit timestamp, we can figure out what is in the past, and ask a target to invoke
an interrupt immediately. The previous attemps in the target HAL tickers were not ideal, as it can wrap around easily (16 or 32 bit counters). This new
functionality should solve this problem.

set_interrupt for tickers in HAL code should not handle anything but the next match interrupt. If it was in the past is handled by the upper layer.

It is possible that we are setting next event to the close future, so once it is set it is already in the past. Therefore we add a check after set interrupt to verify it is in future.
If it is not, we fire interrupt immediately. This results in
two events - first one immediate, correct one. The second one might be scheduled in far future (almost entire ticker range),
that should be discarded.

The specification for the fire_interrupts are:
- should set pending bit for the ticker interrupt (as soon as possible),
the event we are scheduling is already in the past, and we do not want to skip
any events
- no arguments are provided, neither return value, not needed
- ticker should be initialized prior calling this function (no need to check if it is already initialized)

All our targets provide this new functionality, removing old misleading if (timestamp is in the past) checks.
2017-07-13 12:23:25 +01:00
Laurent MEUNIER ea2cc1d0e1 STM32 16bits tickers: consider all corner cases in us_ticker_set_interrupt
The present commit comes from monkiineko mbed contributor.
The comments in code explains in details all the possible case and
how they are handled.
2017-06-05 13:12:20 +02:00
Laurent MEUNIER fbfbb5e982 STM32 16 bits ticker: fix grammar issues in comments 2017-06-05 13:12:20 +02:00
Laurent MEUNIER 572a096c08 STM32 16 bits tickers: save useless instance init
TimMasterHandle.Instance initialization can be removed from here,
because it will either have been already done previously,
or it will be done in the us_ticker_init() call immediately below.
2017-06-05 13:12:20 +02:00
Laurent MEUNIER 27be2e1884 STM32 16 bits ticker: don't check FLAG just clear it
Not having the check will make the code more efficient.
2017-06-05 13:12:20 +02:00
Laurent MEUNIER 1b684ca4e9 STM32 16 bits tickers, no need to check TIM_FLAG_CC1OF FLAG
Following previous fixes on 16 tickers handling, the overflow flag
condition will not happen anymore, so the work-around in place is
not needed anymore
2017-06-05 13:12:20 +02:00
Laurent MEUNIER 35c68859c0 STM32: 16 bits ticker, fixes in set function and handler
This commit simplifies ticker interrupt set function and handler.

There were issues around the 16 bits timer wrap-around timing as we were
aligning interrupts with wrap-around limits (0xFFFF) and then reading
TIM_MST->CNT again in timer_update_irq_handler which could lead
to crossing case with the wrap-around (TIM_FLAG_UPDATE) case.

Now we're using the 16 lower bits of the timestamp as the reference from
using in set_compare and never changing it. There is also no need to set
comparator again in timer_update_irq_handler. This is more robust and
also more efficient.
2017-06-05 13:12:20 +02:00
Laurent MEUNIER b9b5f0b929 STM32 16bits ticker: rework us_ticker_read()
Move to a single more reliable implementation of us_ticker_read()
There were historically 2 versions of us_ticker_read() implementation.

The one removed here was not reliable because us_ticker_read() can be
called in interrupt context which means that TIM_MST->CNT would have
wrapped around while SlaveCounter is not yet updated. So there is a need
to check the TIM_FLAG_UPDATE inside this function, which was not done in
the implementation that is removed here.
2017-06-05 13:12:20 +02:00
Laurent MEUNIER 675d78d180 STM32 remove usage of deprecated MACROs 2017-05-09 16:48:34 +02:00
bcostm da23ef135e Update license + date (same license as in mbed.h file) 2016-11-14 10:01:07 +01:00
bcostm 2006e458fd Typo corrections (functions declaration) 2016-11-14 09:56:54 +01:00
bcostm 777692cc16 Timer 16bit: Remove volatile variables. This solved many fails with MBED_24 test. 2016-11-14 09:31:14 +01:00
bcostm f8e18cdde4 Change TimMasterHandle variable declaration + typo corrections 2016-11-14 09:31:14 +01:00
bcostm cc24e5b7f9 Add initialization of timer instance in all functions 2016-11-14 09:31:14 +01:00
bcostm 6baec10d29 Rename files (remove stm_ prefix) 2016-11-14 09:31:14 +01:00