Skip to content

Commit

Permalink
Optimise mbed_ticker_api.c
Browse files Browse the repository at this point in the history
The generic code in mbed_ticker_api.c uses run-time polymorphism to
handle different tickers, and has generic run-time calculations for
different ticker widths and frequencies, with a single special-case for
1MHz.

Extend the run-time special casing to handle any conversion cases where
either the multiply or divide can be done as a shift. This is a speed
optimisation for certain platforms.

Add a new option `target.custom-tickers`. If turned off, it promises
that only USTICKER and LPTICKER devices will be used. This then permits
elimination and/or simplification of runtime calculations, saving size
and speed. If either both USTICKER and LPTICKER have the same width, or
same period numerator or denominator, or only one of them exists, then
operations can be hard-coded. This is a significant ROM space saving,
and a minor speed and RAM saving.

We get to optimise all the calculations, but the run-time polymorphism
is retained even if there is only one ticker, as it doesn't
significantly affect code size versus direct calls, and the existence of
lp_ticker_wrapper and various us_ticker optimisations requires it, even
if only LPTICKER is available.
  • Loading branch information
kjbracey committed May 8, 2020
1 parent 56396d6 commit fcaabda
Show file tree
Hide file tree
Showing 3 changed files with 283 additions and 70 deletions.
Loading

0 comments on commit fcaabda

Please sign in to comment.