|
|
|
@ -26,6 +26,8 @@ |
|
|
|
|
#include <libopencm3/cm3/scb.h> |
|
|
|
|
#include <libopencm3/cm3/systick.h> |
|
|
|
|
|
|
|
|
|
#include <librfn/time.h> |
|
|
|
|
|
|
|
|
|
#include <libcommon/iob.h> |
|
|
|
|
#include <libcommon/microvty.h> |
|
|
|
|
|
|
|
|
@ -40,19 +42,12 @@ static uint32_t last_reset_cause; |
|
|
|
|
extern const struct attenuator_cfg board_att_cfg; |
|
|
|
|
extern struct attenuator_state *board_att_st[]; |
|
|
|
|
|
|
|
|
|
volatile uint32_t jiffies; |
|
|
|
|
|
|
|
|
|
void sys_tick_handler(void) |
|
|
|
|
{ |
|
|
|
|
jiffies++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* busy wait specified number of ms */ |
|
|
|
|
void msleep(uint32_t delay) |
|
|
|
|
{ |
|
|
|
|
uint32_t wake = jiffies + delay; |
|
|
|
|
uint32_t wake = time_now() + delay; |
|
|
|
|
do { |
|
|
|
|
} while (wake > jiffies); |
|
|
|
|
} while (wake > time_now()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
@ -65,10 +60,6 @@ static void clock_setup(void) |
|
|
|
|
/* HCLK=48MHz; ADC=6MHz; APB1=24MHz; APB2=48MHz; USB=48MHz */ |
|
|
|
|
|
|
|
|
|
/* tick rate of 1ms */ |
|
|
|
|
systick_set_reload(48000); |
|
|
|
|
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB); |
|
|
|
|
systick_counter_enable(); |
|
|
|
|
systick_interrupt_enable(); |
|
|
|
|
|
|
|
|
|
/* Enable GPIOC clock. */ |
|
|
|
|
rcc_periph_clock_enable(RCC_GPIOA); |
|
|
|
|