aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/swlink/platform.c
diff options
context:
space:
mode:
authorGareth McMullin2015-03-02 21:59:04 -0800
committerGareth McMullin2015-03-02 21:59:04 -0800
commit3e466f2d23401df610cb0f94a226317c2dc38751 (patch)
tree7225d3f7929044ced05872d0d11dfd3501605603 /src/platforms/swlink/platform.c
parentb07ffffcee53e18051b324eb59a2794044ce6f95 (diff)
Factor out timing routines common to all STM32 targets.
Diffstat (limited to 'src/platforms/swlink/platform.c')
-rw-r--r--src/platforms/swlink/platform.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/src/platforms/swlink/platform.c b/src/platforms/swlink/platform.c
index 1b9a76e..cbdae0c 100644
--- a/src/platforms/swlink/platform.c
+++ b/src/platforms/swlink/platform.c
@@ -27,16 +27,12 @@
#include "usbuart.h"
#include <libopencm3/stm32/f1/rcc.h>
-#include <libopencm3/cm3/systick.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/usart.h>
#include <libopencm3/usb/usbd.h>
#include <libopencm3/stm32/f1/adc.h>
-uint8_t running_status;
-volatile uint32_t timeout_counter;
-
jmp_buf fatal_error_jmpbuf;
void platform_init(void)
@@ -72,7 +68,7 @@ void platform_init(void)
GPIO_CNF_INPUT_PULL_UPDOWN, NRST_PIN);
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
+ GPIO_CNF_OUTPUT_PUSHPULL, LED_IDLE_RUN);
/* Remap TIM2 TIM2_REMAP[1]
* TIM2_CH1_ETR -> PA15 (TDI, set as output above)
@@ -83,34 +79,11 @@ void platform_init(void)
data |= AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1;
AFIO_MAPR = data;
- /* Setup heartbeat timer */
- systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
- systick_set_reload(900000); /* Interrupt us at 10 Hz */
- SCB_SHPR(11) &= ~((15 << 4) & 0xff);
- SCB_SHPR(11) |= ((14 << 4) & 0xff);
- systick_interrupt_enable();
- systick_counter_enable();
-
- usbuart_init();
-
SCB_VTOR = 0x2000; // Relocate interrupt vector table here
+ platform_timing_init();
cdcacm_init();
-}
-
-void platform_delay(uint32_t delay)
-{
- timeout_counter = delay;
- while(timeout_counter);
-}
-
-void sys_tick_handler(void)
-{
- if(running_status)
- gpio_toggle(LED_PORT, led_idle_run);
-
- if(timeout_counter)
- timeout_counter--;
+ usbuart_init();
}
const char *platform_target_voltage(void)