aboutsummaryrefslogtreecommitdiff
path: root/src/platforms
diff options
context:
space:
mode:
authorGareth McMullin2012-10-22 18:45:42 +1300
committerGareth McMullin2012-10-22 18:45:42 +1300
commit09c0fb5773da62bb1c4f2fb338e8ca916fb88845 (patch)
treed8047109f71cde8ccb65be1f27f2a6187a15905f /src/platforms
parent206237e8ddc8d8fd94594b2d1fe4fb4c52fe12ca (diff)
Build with libopencm3 as a submodule.
Fix incompatibilities with latest libopencm3.
Diffstat (limited to 'src/platforms')
-rw-r--r--src/platforms/native/Makefile.inc6
-rw-r--r--src/platforms/native/platform.c27
-rw-r--r--src/platforms/stlink/Makefile.inc6
3 files changed, 21 insertions, 18 deletions
diff --git a/src/platforms/native/Makefile.inc b/src/platforms/native/Makefile.inc
index 41e1717..dc0e743 100644
--- a/src/platforms/native/Makefile.inc
+++ b/src/platforms/native/Makefile.inc
@@ -2,10 +2,12 @@ CROSS_COMPILE ?= arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
OBJCOPY = $(CROSS_COMPILE)objcopy
-CFLAGS += -Istm32/include -mcpu=cortex-m3 -mthumb -DSTM32F1
+CFLAGS += -Istm32/include -mcpu=cortex-m3 -mthumb \
+ -DSTM32F1 -I../libopencm3/include
LDFLAGS_BOOT = -lopencm3_stm32f1 -Wl,--defsym,_stack=0x20005000 \
-Wl,-T,platforms/stm32/blackmagic.ld -nostartfiles -lc -lnosys \
- -Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections
+ -Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections \
+ -L../libopencm3/lib
LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000
VPATH += platforms/stm32
diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c
index fe47ba0..4934f94 100644
--- a/src/platforms/native/platform.c
+++ b/src/platforms/native/platform.c
@@ -53,7 +53,7 @@ int platform_hwversion(void)
{
static int hwversion = -1;
if (hwversion == -1) {
- gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
+ gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_PULL_UPDOWN,
GPIO7 | GPIO6 | GPIO5);
gpio_clear(GPIOB, GPIO7 | GPIO6 | GPIO5);
@@ -74,10 +74,10 @@ int platform_init(void)
/* Setup GPIO ports */
gpio_clear(USB_PU_PORT, USB_PU_PIN);
- gpio_set_mode(USB_PU_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT,
+ gpio_set_mode(USB_PU_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT,
USB_PU_PIN);
- gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ,
+ gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL,
TMS_PIN | TCK_PIN | TDI_PIN);
@@ -88,18 +88,18 @@ int platform_init(void)
gpio_port_write(GPIOA, 0x8180);
gpio_port_write(GPIOB, 0x2002);
-
- gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL,
+
+ gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
+ GPIO_CNF_OUTPUT_PUSHPULL,
LED_UART | LED_IDLE_RUN | LED_ERROR);
/* FIXME: This pin in intended to be input, but the TXS0108 fails
* to release the device from reset if this floats. */
- gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
+ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
/* Setup heartbeat timer */
- systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
+ systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
systick_set_reload(900000); /* Interrupt us at 10 Hz */
SCB_SHPR(11) &= ~((15 << 4) & 0xff);
SCB_SHPR(11) |= ((14 << 4) & 0xff);
@@ -112,7 +112,7 @@ int platform_init(void)
adc_init();
} else {
gpio_clear(GPIOB, GPIO0);
- gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
+ gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
}
@@ -133,10 +133,10 @@ void platform_delay(uint32_t delay)
void sys_tick_handler(void)
{
- if(running_status)
+ if(running_status)
gpio_toggle(LED_PORT, LED_IDLE_RUN);
- if(timeout_counter)
+ if(timeout_counter)
timeout_counter--;
morse_update();
@@ -222,18 +222,17 @@ static void adc_init(void)
{
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_ADC1EN);
- gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
+ gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_ANALOG, GPIO0);
adc_off(ADC1);
adc_disable_scan_mode(ADC1);
adc_set_single_conversion_mode(ADC1);
- adc_enable_discontinous_mode_regular(ADC1);
adc_disable_external_trigger_regular(ADC1);
adc_set_right_aligned(ADC1);
adc_set_conversion_time_on_all_channels(ADC1, ADC_SMPR_SMP_28DOT5CYC);
- adc_on(ADC1);
+ adc_power_on(ADC1);
/* Wait for ADC starting up. */
for (int i = 0; i < 800000; i++) /* Wait a bit. */
diff --git a/src/platforms/stlink/Makefile.inc b/src/platforms/stlink/Makefile.inc
index 7124dfc..e12666b 100644
--- a/src/platforms/stlink/Makefile.inc
+++ b/src/platforms/stlink/Makefile.inc
@@ -2,10 +2,12 @@ CROSS_COMPILE ?= arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
OBJCOPY = $(CROSS_COMPILE)objcopy
-CFLAGS += -mcpu=cortex-m3 -mthumb -DSTM32F1
+CFLAGS += -mcpu=cortex-m3 -mthumb \
+ -DSTM32F1 -I../libopencm3/include
LDFLAGS = -lopencm3_stm32f1 -Wl,--defsym,_stack=0x20005000 \
-Wl,-T,platforms/stm32/blackmagic.ld -nostartfiles -lc -lnosys \
- -Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections
+ -Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections \
+ -L../libopencm3/lib
VPATH += platforms/stm32