Add timer_save and _restore functions. (#23887)
Co-authored-by: Sergey Vlasov <sigprof@gmail.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
@@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// counter resolution 1ms
|
||||
// NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }}
|
||||
volatile uint32_t timer_count;
|
||||
static uint32_t saved_ms;
|
||||
|
||||
/** \brief timer initialization
|
||||
*
|
||||
@@ -78,6 +79,24 @@ inline void timer_clear(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief timer save
|
||||
*
|
||||
* Set saved_ms to current time.
|
||||
*/
|
||||
void timer_save(void) {
|
||||
saved_ms = timer_read32();
|
||||
}
|
||||
|
||||
/** \brief timer restore
|
||||
*
|
||||
* Set timer_count to saved_ms
|
||||
*/
|
||||
void timer_restore(void) {
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
|
||||
timer_count = saved_ms;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief timer read
|
||||
*
|
||||
* FIXME: needs doc
|
||||
|
||||
Reference in New Issue
Block a user