aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/f4discovery
diff options
context:
space:
mode:
Diffstat (limited to 'src/platforms/f4discovery')
-rw-r--r--src/platforms/f4discovery/Makefile.inc22
-rw-r--r--src/platforms/f4discovery/Readme35
-rw-r--r--src/platforms/f4discovery/platform.c176
-rw-r--r--src/platforms/f4discovery/platform.h156
-rw-r--r--src/platforms/f4discovery/usbdfu.c14
5 files changed, 123 insertions, 280 deletions
diff --git a/src/platforms/f4discovery/Makefile.inc b/src/platforms/f4discovery/Makefile.inc
index 5470d65..e57bb0e 100644
--- a/src/platforms/f4discovery/Makefile.inc
+++ b/src/platforms/f4discovery/Makefile.inc
@@ -7,33 +7,21 @@ CFLAGS += -Istm32/include -mcpu=cortex-m4 -mthumb \
-DSTM32F4 -DF4DISCOVERY -I../libopencm3/include \
-Iplatforms/stm32
-LDFLAGS_BOOT = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20020000 \
+LDFLAGS = -lopencm3_stm32f4 -Wl,--defsym,_stack=0x20006000 \
-Wl,-T,platforms/stm32/f4discovery.ld -nostartfiles -lc -lnosys \
-Wl,-Map=mapfile -mthumb -mcpu=cortex-m4 -Wl,-gc-sections \
-mfloat-abi=hard -mfpu=fpv4-sp-d16 \
-L../libopencm3/lib
-LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8010000
VPATH += platforms/stm32
SRC += cdcacm.c \
- platform.c \
traceswo.c \
usbuart.c \
+ serialno.c \
+ timing.c \
-all: blackmagic.bin blackmagic_dfu.bin blackmagic_dfu.hex
-
-blackmagic.bin: blackmagic
- $(OBJCOPY) -O binary $^ $@
-
-blackmagic_dfu: usbdfu.o dfucore.o dfu_f4.o
- $(CC) $^ -o $@ $(LDFLAGS_BOOT)
-
-blackmagic_dfu.bin: blackmagic_dfu
- $(OBJCOPY) -O binary $^ $@
-
-blackmagic_dfu.hex: blackmagic_dfu
- $(OBJCOPY) -O ihex $^ $@
+all: blackmagic.bin
host_clean:
- -rm blackmagic.bin blackmagic_dfu blackmagic_dfu.bin blackmagic_dfu.hex
+ -$(Q)$(RM) blackmagic.bin
diff --git a/src/platforms/f4discovery/Readme b/src/platforms/f4discovery/Readme
index 6035917..9bc1557 100644
--- a/src/platforms/f4discovery/Readme
+++ b/src/platforms/f4discovery/Readme
@@ -1,17 +1,28 @@
-Application start address:
-=========================
+System vs BMP Bootloader
+========================
+For the BMP bootloader, flashing qas not reliable. So we use the system
+bootloder unconditional.
-Use 0x8010000
-- lower 3 16 k pages may be used for parameter storage
-- Erasing a single 64 k Page is faster then erasing 2 16 k Pages
- eventual the 64 k page
+Connections:
+====================
+PA0: User button to force system bootloader entry with reset
+PA2/PA3 eventual connected to the STLINK/ STM32F103C8
-Internal boot loader:
-====================
+PC2: TDI
+PC4: TMS/SWDIO
+PC5: TCK/SWCLK
+PC6: TDO/TRACESWO
+
+PC1: TRST
+PC8: SRST
-When we request invokation of a bootloader from inside the application,
-we boot the device internal bootloader with the blue botton pressed.
+Blue Led: Indicator that system bootloader is entered via BMP
-That way, we can easy exchange the custom bootloader via the device
-internale bootloader \ No newline at end of file
+Bootstrapping the F4Discovery on-board ST-Link
+==============================================
+http://embdev.net/articles/STM_Discovery_as_Black_Magic_Probe has some hints
+how to modify the F4Discovery on-board ST-Link. If you try to do so and hit
+a problem that stands some test like that you load the right firmware to the
+right device via the right BMP probe, explain, report and ask on the
+blackmagic mailing list http://sourceforge.net/mail/?group_id=407419.
diff --git a/src/platforms/f4discovery/platform.c b/src/platforms/f4discovery/platform.c
index 4aa14a6..e85ebd5 100644
--- a/src/platforms/f4discovery/platform.c
+++ b/src/platforms/f4discovery/platform.c
@@ -22,8 +22,12 @@
* implementation.
*/
+#include "general.h"
+#include "cdcacm.h"
+#include "usbuart.h"
+#include "morse.h"
+
#include <libopencm3/stm32/f4/rcc.h>
-#include <libopencm3/cm3/systick.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/exti.h>
@@ -31,37 +35,32 @@
#include <libopencm3/stm32/syscfg.h>
#include <libopencm3/usb/usbd.h>
-#include "platform.h"
-#include "jtag_scan.h"
-#include <usbuart.h>
-
-#include <ctype.h>
-
-uint8_t running_status;
-volatile uint32_t timeout_counter;
-
jmp_buf fatal_error_jmpbuf;
-static void morse_update(void);
-
-int platform_init(void)
+void platform_init(void)
{
- rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
+ /* Check the USER button*/
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
+ if(gpio_get(GPIOA, GPIO0)) {
+ platform_request_boot();
+ scb_reset_core();
+ }
+
+ rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_48MHZ]);
/* Enable peripherals */
rcc_peripheral_enable_clock(&RCC_AHB2ENR, RCC_AHB2ENR_OTGFSEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
- rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPBEN);
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPCEN);
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
-
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_CRCEN);
/* Set up USB Pins and alternate function*/
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE,
GPIO9 | GPIO11 | GPIO12);
gpio_set_af(GPIOA, GPIO_AF10, GPIO9 | GPIO11 | GPIO12);
- GPIOA_OSPEEDR &=~0xfc;
- GPIOA_OSPEEDR |= 0xa8;
+ GPIOC_OSPEEDR &=~0xF30;
+ GPIOC_OSPEEDR |= 0xA20;
gpio_mode_setup(JTAG_PORT, GPIO_MODE_OUTPUT,
GPIO_PUPD_NONE,
TMS_PIN | TCK_PIN | TDI_PIN);
@@ -72,118 +71,11 @@ int platform_init(void)
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
GPIO_PUPD_NONE,
- LED_UART | LED_IDLE_RUN | LED_ERROR | LED_SPARE1);
-
- /* Setup heartbeat timer */
- systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
- systick_set_reload(168000000/(10*8)); /* Interrupt us at 10 Hz */
- SCB_SHPR(11) &= ~((15 << 4) & 0xff);
- SCB_SHPR(11) |= ((14 << 4) & 0xff);
- systick_interrupt_enable();
- systick_counter_enable();
+ LED_UART | LED_IDLE_RUN | LED_ERROR | LED_BOOTLOADER);
+ platform_timing_init();
usbuart_init();
-
- SCB_VTOR = 0x10000; // Relocate interrupt vector table here
-
cdcacm_init();
-
- jtag_scan(NULL);
-
- return 0;
-}
-
-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--;
-
- morse_update();
-}
-
-
-/* Morse code patterns and lengths */
-static const struct {
- uint16_t code;
- uint8_t bits;
-} morse_letter[] = {
- { 0b00011101, 8}, // 'A' .-
- { 0b000101010111, 12}, // 'B' -...
- { 0b00010111010111, 14}, // 'C' -.-.
- { 0b0001010111, 10}, // 'D' -..
- { 0b0001, 4}, // 'E' .
- { 0b000101110101, 12}, // 'F' ..-.
- { 0b000101110111, 12}, // 'G' --.
- { 0b0001010101, 10}, // 'H' ....
- { 0b000101, 6}, // 'I' ..
- {0b0001110111011101, 16}, // 'J' .---
- { 0b000111010111, 12}, // 'K' -.-
- { 0b000101011101, 12}, // 'L' .-..
- { 0b0001110111, 10}, // 'M' --
- { 0b00010111, 8}, // 'N' -.
- { 0b00011101110111, 14}, // 'O' ---
- { 0b00010111011101, 14}, // 'P' .--.
- {0b0001110101110111, 16}, // 'Q' --.-
- { 0b0001011101, 10}, // 'R' .-.
- { 0b00010101, 8}, // 'S' ...
- { 0b000111, 6}, // 'T' -
- { 0b0001110101, 10}, // 'U' ..-
- { 0b000111010101, 12}, // 'V' ...-
- { 0b000111011101, 12}, // 'W' .--
- { 0b00011101010111, 14}, // 'X' -..-
- {0b0001110111010111, 16}, // 'Y' -.--
- { 0b00010101110111, 14}, // 'Z' --..
-};
-
-
-const char *morse_msg;
-static const char * volatile morse_ptr;
-static char morse_repeat;
-
-void morse(const char *msg, char repeat)
-{
- morse_msg = morse_ptr = msg;
- morse_repeat = repeat;
- SET_ERROR_STATE(0);
-}
-
-static void morse_update(void)
-{
- static uint16_t code;
- static uint8_t bits;
-
- if(!morse_ptr) return;
-
- if(!bits) {
- char c = *morse_ptr++;
- if(!c) {
- if(morse_repeat) {
- morse_ptr = morse_msg;
- c = *morse_ptr++;
- } else {
- morse_ptr = 0;
- return;
- }
- }
- if((c >= 'A') && (c <= 'Z')) {
- c -= 'A';
- code = morse_letter[c].code;
- bits = morse_letter[c].bits;
- } else {
- code = 0; bits = 4;
- }
- }
- SET_ERROR_STATE(code & 1);
- code >>= 1; bits--;
}
const char *platform_target_voltage(void)
@@ -191,18 +83,20 @@ const char *platform_target_voltage(void)
return "ABSENT!";
}
-void assert_boot_pin(void)
+void platform_request_boot(void)
{
- if (gpio_get(GPIOA, GPIO0)) {
- /* Jump to the built in bootloader by mapping System flash */
- rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
- SYSCFG_MEMRM &= ~3;
- SYSCFG_MEMRM |= 1;
- }
- else {
- /* Flag Bootloader Request by mimicing a pushed USER button*/
- gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT,
- GPIO_PUPD_NONE, GPIO0);
- gpio_set(GPIOA, GPIO0);
- }
+ /* Disconnect USB cable */
+ usbd_disconnect(usbdev, 1);
+ nvic_disable_irq(USB_IRQ);
+
+ /* Assert blue LED as indicator we are in the bootloader */
+ rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPDEN);
+ gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT,
+ GPIO_PUPD_NONE, LED_BOOTLOADER);
+ gpio_set(LED_PORT, LED_BOOTLOADER);
+
+ /* Jump to the built in bootloader by mapping System flash */
+ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_SYSCFGEN);
+ SYSCFG_MEMRM &= ~3;
+ SYSCFG_MEMRM |= 1;
}
diff --git a/src/platforms/f4discovery/platform.h b/src/platforms/f4discovery/platform.h
index a1deb48..16bd169 100644
--- a/src/platforms/f4discovery/platform.h
+++ b/src/platforms/f4discovery/platform.h
@@ -24,40 +24,33 @@
#ifndef __PLATFORM_H
#define __PLATFORM_H
-#include <libopencm3/stm32/f4/gpio.h>
-#include <libopencm3/usb/usbd.h>
+#include "gpio.h"
+#include "timing.h"
+#include "version.h"
#include <setjmp.h>
-#include <alloca.h>
-#include "gdb_packet.h"
-
-#define INLINE_GPIO
-#define CDCACM_PACKET_SIZE 64
#define PLATFORM_HAS_TRACESWO
-#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
-#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
-#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery"
-#define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg"
-
-extern usbd_device *usbdev;
-#define CDCACM_GDB_ENDPOINT 1
-#define CDCACM_UART_ENDPOINT 3
+#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware " FIRMWARE_VERSION ")"
+#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware " FIRMWARE_VERSION ")"
+#define DFU_IDENT "Black Magic Firmware Upgrade (F4Discovery"
+#define DFU_IFACE_STRING "@Internal Flash /0x08000000/1*016Ka,3*016Kg,1*064Kg,7*128Kg"
/* Important pin mappings for STM32 implementation:
*
* LED0 = PD12 (Green LED : Running)
* LED1 = PD13 (Orange LED : Idle)
* LED2 = PD12 (Red LED : Error)
+ * LED3 = PD15 (Blue LED : Bootloader active)
*
* TPWR = XXX (input) -- analogue on mini design ADC1, ch8
- * nTRST = PD0
- * SRST_OUT = PD1
- * TDI = PA1
- * TMS = PA3 (input for SWDP)
- * TCK = PA8
- * TDO = PB4 (input)
- * nSRST = PD2 (input)
+ * nTRST = PC1
+ * SRST_OUT = PC8
+ * TDI = PC2
+ * TMS = PC4 (input for SWDP)
+ * TCK = PC5/SWCLK
+ * TDO = PC6 (input for TRACESWO
+ * nSRST =
*
* USB cable pull-up: PA8
* USB VBUS detect: PB13 -- New on mini design.
@@ -66,40 +59,43 @@ extern usbd_device *usbdev;
*/
/* Hardware definitions... */
-#define JTAG_PORT GPIOA
+#define JTAG_PORT GPIOC
#define TDI_PORT JTAG_PORT
#define TMS_PORT JTAG_PORT
#define TCK_PORT JTAG_PORT
-#define TDO_PORT GPIOB
-#define TDI_PIN GPIO1
-#define TMS_PIN GPIO3
-#define TCK_PIN GPIO2
-#define TDO_PIN GPIO4
+#define TDO_PORT GPIOC
+#define TDI_PIN GPIO2
+#define TMS_PIN GPIO4
+#define TCK_PIN GPIO5
+#define TDO_PIN GPIO6
#define SWDIO_PORT JTAG_PORT
#define SWCLK_PORT JTAG_PORT
#define SWDIO_PIN TMS_PIN
#define SWCLK_PIN TCK_PIN
-#define TRST_PORT GPIOD
-#define TRST_PIN GPIO0
-#define SRST_PORT GPIOD
-#define SRST_PIN GPIO1
+#define TRST_PORT GPIOC
+#define TRST_PIN GPIO1
+#define SRST_PORT GPIOC
+#define SRST_PIN GPIO8
#define LED_PORT GPIOD
#define LED_PORT_UART GPIOD
#define LED_UART GPIO12
#define LED_IDLE_RUN GPIO13
#define LED_ERROR GPIO14
-#define LED_SPARE1 GPIO15
+#define LED_BOOTLOADER GPIO15
-#define TMS_SET_MODE() gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, \
- GPIO_PUPD_NONE, TMS_PIN);
-#define SWDIO_MODE_FLOAT() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_INPUT, \
- GPIO_PUPD_NONE, SWDIO_PIN);
+#define TMS_SET_MODE() \
+ gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, \
+ GPIO_PUPD_NONE, TMS_PIN);
+#define SWDIO_MODE_FLOAT() \
+ gpio_mode_setup(SWDIO_PORT, GPIO_MODE_INPUT, \
+ GPIO_PUPD_NONE, SWDIO_PIN);
-#define SWDIO_MODE_DRIVE() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_OUTPUT, \
- GPIO_PUPD_NONE, SWDIO_PIN);
+#define SWDIO_MODE_DRIVE() \
+ gpio_mode_setup(SWDIO_PORT, GPIO_MODE_OUTPUT, \
+ GPIO_PUPD_NONE, SWDIO_PIN);
#define USB_DRIVER stm32f107_usb_driver
@@ -111,42 +107,39 @@ extern usbd_device *usbdev;
*/
#define IRQ_PRI_USB (2 << 4)
#define IRQ_PRI_USBUSART (1 << 4)
+#define IRQ_PRI_USBUSART_TIM (3 << 4)
#define IRQ_PRI_TRACE (0 << 4)
#define USBUSART USART3
#define USBUSART_CR1 USART3_CR1
#define USBUSART_IRQ NVIC_USART3_IRQ
-#define USBUSART_APB_ENR RCC_APB1ENR
-#define USBUSART_CLK_ENABLE RCC_APB1ENR_USART3EN
+#define USBUSART_CLK RCC_USART3
#define USBUSART_TX_PORT GPIOD
#define USBUSART_TX_PIN GPIO8
#define USBUSART_RX_PORT GPIOD
#define USBUSART_RX_PIN GPIO9
#define USBUSART_ISR usart3_isr
-
-#define UART_PIN_SETUP() do { \
- gpio_mode_setup(USBUSART_TX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
- USBUSART_TX_PIN); \
- gpio_mode_setup(USBUSART_RX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
- USBUSART_RX_PIN); \
- gpio_set_af(USBUSART_TX_PORT, GPIO_AF7, USBUSART_TX_PIN); \
- gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
+#define USBUSART_TIM TIM4
+#define USBUSART_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM4)
+#define USBUSART_TIM_IRQ NVIC_TIM4_IRQ
+#define USBUSART_TIM_ISR tim4_isr
+
+#define UART_PIN_SETUP() do { \
+ gpio_mode_setup(USBUSART_TX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
+ USBUSART_TX_PIN); \
+ gpio_mode_setup(USBUSART_RX_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, \
+ USBUSART_RX_PIN); \
+ gpio_set_af(USBUSART_TX_PORT, GPIO_AF7, USBUSART_TX_PIN); \
+ gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
} while(0)
#define TRACE_TIM TIM3
-#define TRACE_TIM_CLK_EN() rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_TIM3EN)
+#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR tim3_isr
#define DEBUG(...)
-extern uint8_t running_status;
-extern volatile uint32_t timeout_counter;
-
-extern jmp_buf fatal_error_jmpbuf;
-
-extern const char *morse_msg;
-
#define gpio_set_val(port, pin, val) do { \
if(val) \
gpio_set((port), (pin)); \
@@ -158,58 +151,15 @@ extern const char *morse_msg;
#define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, LED_IDLE_RUN, state);}
#define SET_ERROR_STATE(state) {gpio_set_val(LED_PORT, LED_ERROR, state);}
-#define PLATFORM_SET_FATAL_ERROR_RECOVERY() {setjmp(fatal_error_jmpbuf);}
-#define PLATFORM_FATAL_ERROR(error) { \
- if(running_status) gdb_putpacketz("X1D"); \
- else gdb_putpacketz("EFF"); \
- running_status = 0; \
- target_list_free(); \
- morse("TARGET LOST.", 1); \
- longjmp(fatal_error_jmpbuf, (error)); \
+static inline int platform_hwversion(void)
+{
+ return 0;
}
-int platform_init(void);
-void morse(const char *msg, char repeat);
-const char *platform_target_voltage(void);
-int platform_hwversion(void);
-void platform_delay(uint32_t delay);
-
-/* <cdcacm.c> */
-void cdcacm_init(void);
-/* Returns current usb configuration, or 0 if not configured. */
-int cdcacm_get_config(void);
-int cdcacm_get_dtr(void);
-
-/* <platform.h> */
-void uart_usb_buf_drain(uint8_t ep);
-
/* Use newlib provided integer only stdio functions */
#define sscanf siscanf
#define sprintf siprintf
#define vasprintf vasiprintf
-#ifdef INLINE_GPIO
-static inline void _gpio_set(u32 gpioport, u16 gpios)
-{
- GPIO_BSRR(gpioport) = gpios;
-}
-#define gpio_set _gpio_set
-
-static inline void _gpio_clear(u32 gpioport, u16 gpios)
-{
- GPIO_BSRR(gpioport) = gpios<<16;
-}
-#define gpio_clear _gpio_clear
-
-static inline u16 _gpio_get(u32 gpioport, u16 gpios)
-{
- return (u16)GPIO_IDR(gpioport) & gpios;
-}
-#define gpio_get _gpio_get
-#endif
-
#endif
-#define disconnect_usb() do {usbd_disconnect(usbdev,1); nvic_disable_irq(USB_IRQ);} while(0)
-void assert_boot_pin(void);
-#define setup_vbus_irq()
diff --git a/src/platforms/f4discovery/usbdfu.c b/src/platforms/f4discovery/usbdfu.c
index 998628b..6a40295 100644
--- a/src/platforms/f4discovery/usbdfu.c
+++ b/src/platforms/f4discovery/usbdfu.c
@@ -17,17 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <string.h>
+#include "general.h"
+#include "usbdfu.h"
+
#include <libopencm3/cm3/systick.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/scb.h>
-#include "usbdfu.h"
-
void dfu_detach(void)
{
- /* USB device must detach, we just reset... */
+ /* USB device must detach, we just reset... */
scb_reset_system();
}
@@ -40,9 +40,9 @@ int main(void)
dfu_protect_enable();
- /* Set up clock*/
- rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
- systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
+ /* Set up clock*/
+ rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
+ systick_set_clocksource(STK_CSR_CLKSOURCE_AHB_DIV8);
systick_set_reload(2100000);
systick_interrupt_enable();