stm32/timing_stm32.c: Remove fixed constants and direct SCB access
This commit is contained in:
parent
c4d7232223
commit
9ca401497c
|
@ -20,7 +20,8 @@
|
||||||
#include "morse.h"
|
#include "morse.h"
|
||||||
|
|
||||||
#include <libopencm3/cm3/systick.h>
|
#include <libopencm3/cm3/systick.h>
|
||||||
#include <libopencm3/cm3/scb.h>
|
#include <libopencm3/cm3/nvic.h>
|
||||||
|
#include <libopencm3/stm32/rcc.h>
|
||||||
|
|
||||||
uint8_t running_status;
|
uint8_t running_status;
|
||||||
static volatile uint32_t time_ms;
|
static volatile uint32_t time_ms;
|
||||||
|
@ -29,9 +30,10 @@ void platform_timing_init(void)
|
||||||
{
|
{
|
||||||
/* Setup heartbeat timer */
|
/* Setup heartbeat timer */
|
||||||
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
|
||||||
systick_set_reload(900000); /* Interrupt us at 10 Hz */
|
/* Interrupt us at 10 Hz */
|
||||||
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
|
systick_set_reload(rcc_ahb_frequency / (8 * 10) );
|
||||||
SCB_SHPR(11) |= ((14 << 4) & 0xff);
|
/* SYSTICK_IRQ with low priority */
|
||||||
|
nvic_set_priority(NVIC_SYSTICK_IRQ, 14 << 4);
|
||||||
systick_interrupt_enable();
|
systick_interrupt_enable();
|
||||||
systick_counter_enable();
|
systick_counter_enable();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue