Browse Source

Add method to clear the systick value, that is undefined at startup.

pull/238/head
Frantisek Burian 11 years ago
parent
commit
5ba8b10428
  1. 1
      include/libopencm3/cm3/systick.h
  2. 15
      lib/cm3/systick.c

1
include/libopencm3/cm3/systick.h

@ -123,6 +123,7 @@ void systick_interrupt_disable(void);
void systick_counter_enable(void);
void systick_counter_disable(void);
uint8_t systick_get_countflag(void);
void systick_clear(void);
uint32_t systick_get_calib(void);

15
lib/cm3/systick.c

@ -46,6 +46,10 @@
* The counter is set to the reload value when the counter starts and after it
* reaches zero.
*
* @note The systick counter value might be undefined upon startup. To get
* predictable behavior, it is a good idea to set or clear the counter after
* set reload. @seealso systick_clear
*
* @param[in] value uint32_t. 24 bit reload value.
*/
@ -175,6 +179,17 @@ uint8_t systick_get_countflag(void)
return (STK_CSR & STK_CSR_COUNTFLAG) ? 1 : 0;
}
/*---------------------------------------------------------------------------*/
/** @brief SysTick Clear counter Value.
*
* The counter value is cleared. Useful for well defined startup.
*/
void systick_clear(void)
{
STK_CVR = 0;
}
/*---------------------------------------------------------------------------*/
/** @brief SysTick Get Calibration Value
*

Loading…
Cancel
Save