Skip to content

Commit

Permalink
stm32: Rename stm32f4/ directory to stm32/
Browse files Browse the repository at this point in the history
Now that the code in stm32f4/ can handle both stm32f1 and stm32f4
chips, rename the directory to just "stm32".

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Aug 5, 2019
1 parent ec3d865 commit 8b9cc62
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 94 deletions.
9 changes: 3 additions & 6 deletions src/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ choice
bool "SAMD21/SAMD51"
config MACH_LPC176X
bool "LPC176x (Smoothieboard)"
config MACH_STM32
bool "STMicroelectronics STM32F1/F4"
config MACH_STM32F0
bool "STMicroelectronics STM32F042"
config MACH_STM32F1
bool "STMicroelectronics STM32F103"
config MACH_STM32F4
bool "STMicroelectronics STM32F4"
config MACH_PRU
bool "Beaglebone PRU"
config MACH_LINUX
Expand All @@ -37,9 +35,8 @@ source "src/avr/Kconfig"
source "src/atsam/Kconfig"
source "src/atsamd/Kconfig"
source "src/lpc176x/Kconfig"
source "src/stm32/Kconfig"
source "src/stm32f0/Kconfig"
source "src/stm32f1/Kconfig"
source "src/stm32f4/Kconfig"
source "src/pru/Kconfig"
source "src/linux/Kconfig"
source "src/simulator/Kconfig"
Expand Down
20 changes: 10 additions & 10 deletions src/stm32f4/Kconfig → src/stm32/Kconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Kconfig settings for STM32F4 processors
# Kconfig settings for STM32 processors

if MACH_STM32F4
if MACH_STM32

config STM32F4_SELECT
config STM32_SELECT
bool
default y
select HAVE_GPIO
Expand All @@ -12,28 +12,28 @@ config STM32F4_SELECT

config BOARD_DIRECTORY
string
default "stm32f4"
default "stm32"

choice
prompt "Processor model"
config MACH_STM32F103
bool "STM32F103"
select MACH_STM32F1xx
select MACH_STM32F1
select HAVE_STM32_USBFS
config MACH_STM32F405
bool "STM32F405"
select MACH_STM32F4xx
select MACH_STM32F4
config MACH_STM32F407
bool "STM32F407"
select MACH_STM32F4xx
select MACH_STM32F4
config MACH_STM32F446
bool "STM32F446"
select MACH_STM32F4xx
select MACH_STM32F4
endchoice

config MACH_STM32F1xx
config MACH_STM32F1
bool
config MACH_STM32F4xx
config MACH_STM32F4
bool
config HAVE_STM32_USBFS
bool
Expand Down
63 changes: 63 additions & 0 deletions src/stm32/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Additional STM32 build rules

# Setup the toolchain
CROSS_PREFIX=arm-none-eabi-

dirs-y += src/stm32 src/generic
dirs-$(CONFIG_MACH_STM32F1) += lib/stm32f1 lib/stm32f1/gcc
dirs-$(CONFIG_MACH_STM32F4) += lib/stm32f4 lib/stm32f4/gcc

MCU := $(shell echo $(CONFIG_MCU))
MCU_UPPER := $(shell echo $(CONFIG_MCU) | tr a-z A-Z | tr X x)

CFLAGS-$(CONFIG_MACH_STM32F1) += -mcpu=cortex-m3 -Ilib/stm32f1/include
CFLAGS-$(CONFIG_MACH_STM32F4) += -mcpu=cortex-m4 -Ilib/stm32f4/include
CFLAGS-$(CONFIG_MACH_STM32F4) += -mfpu=fpv4-sp-d16 -mfloat-abi=hard

CFLAGS += $(CFLAGS-y) -D$(MCU_UPPER) -mthumb -Ilib/cmsis-core
CFLAGS_klipper.elf += -T $(OUT)stm32.ld --specs=nano.specs --specs=nosys.specs

# Add source files
src-y += stm32/main.c stm32/watchdog.c stm32/gpio.c
src-y += generic/crc16_ccitt.c generic/armcm_irq.c generic/armcm_timer.c
src-$(CONFIG_MACH_STM32F1) += ../lib/stm32f1/system_stm32f1xx.c
src-$(CONFIG_MACH_STM32F1) += stm32/stm32f1.c
src-$(CONFIG_MACH_STM32F4) += ../lib/stm32f4/system_stm32f4xx.c
src-$(CONFIG_MACH_STM32F4) += stm32/clock.c
src-$(CONFIG_HAVE_GPIO_ADC) += stm32/adc.c
src-$(CONFIG_HAVE_GPIO_SPI) += stm32/spi.c
src-$(CONFIG_USBSERIAL) += stm32/usbfs.c generic/usb_cdc.c
src-$(CONFIG_SERIAL) += stm32/serial.c generic/serial_irq.c

# Add assembler build rules
$(OUT)%.o: %.s $(OUT)autoconf.h $(OUT)board-link
@echo " Assembling $@"
$(Q)$(AS) $< -o $@

asmsrc-$(CONFIG_MACH_STM32F1) := ../lib/stm32f1/gcc/startup_$(MCU).s
asmsrc-$(CONFIG_MACH_STM32F4) := ../lib/stm32f4/gcc/startup_$(MCU).s
OBJS_klipper.elf += $(patsubst %.s, $(OUT)src/%.o,$(asmsrc-y))

# Build the linker script
$(OUT)stm32.ld: src/stm32/stm32.lds.S $(OUT)board-link
@echo " Preprocessing $@"
$(Q)$(CPP) -I$(OUT) -P -MD -MT $@ $< -o $@
$(OUT)klipper.elf: $(OUT)stm32.ld

# Binary output file rules
target-y += $(OUT)klipper.bin

$(OUT)klipper.bin: $(OUT)klipper.elf
@echo " Creating hex file $@"
$(Q)$(OBJCOPY) -O binary $< $@

FLASH_TYPE-$(CONFIG_MACH_STM32F1) := stm32f1
FLASH_TYPE-$(CONFIG_MACH_STM32F4) := stm32f4

flash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(FLASH_TYPE-y) -d "$(FLASH_DEVICE)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin

serialflash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE) via stm32flash"
$(Q)stm32flash -w $< -v -g 0 $(FLASH_DEVICE)
6 changes: 3 additions & 3 deletions src/stm32f4/adc.c → src/stm32/adc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ADC functions on STM32F4
// ADC functions on STM32
//
// Copyright (C) 2019 Kevin O'Connor <[email protected]>
//
Expand All @@ -22,7 +22,7 @@ static const uint8_t adc_pins[] = {
GPIO('C', 2), GPIO('C', 3), GPIO('C', 4), GPIO('C', 5)
};

#if CONFIG_MACH_STM32F1xx
#if CONFIG_MACH_STM32F1
#define CR2_FLAGS (ADC_CR2_ADON | (7 << ADC_CR2_EXTSEL_Pos) | ADC_CR2_EXTTRIG)
#else
#define CR2_FLAGS ADC_CR2_ADON
Expand Down Expand Up @@ -52,7 +52,7 @@ gpio_adc_setup(uint32_t pin)
| (aticks << 21) | (aticks << 24) | (aticks << 27));
ADC1->CR2 = CR2_FLAGS;

#if CONFIG_MACH_STM32F1xx
#if CONFIG_MACH_STM32F1
// Perform calibration
udelay(timer_from_us(1));
ADC1->CR2 = ADC_CR2_CAL | CR2_FLAGS;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/stm32f4/gpio.h → src/stm32/gpio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __STM32F4_GPIO_H
#define __STM32F4_GPIO_H
#ifndef __STM32_GPIO_H
#define __STM32_GPIO_H

#include <stdint.h> // uint32_t

Expand Down
10 changes: 5 additions & 5 deletions src/stm32f4/internal.h → src/stm32/internal.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef __STM32F4_INTERNAL_H
#define __STM32F4_INTERNAL_H
// Local definitions for STM32F4 code
#ifndef __STM32_INTERNAL_H
#define __STM32_INTERNAL_H
// Local definitions for STM32 code

#include "autoconf.h" // CONFIG_MACH_STM32F1xx
#include "autoconf.h" // CONFIG_MACH_STM32F1

#if CONFIG_MACH_STM32F1xx
#if CONFIG_MACH_STM32F1
#include "stm32f1xx.h"
#else
#include "stm32f4xx.h"
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f4/main.c → src/stm32/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Main starting point for STM32F4 boards.
// Main starting point for STM32 boards.
//
// Copyright (C) 2019 Kevin O'Connor <[email protected]>
//
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f4/serial.c → src/stm32/serial.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// STM32F4 serial
// STM32 serial
//
// Copyright (C) 2019 Kevin O'Connor <[email protected]>
//
Expand Down
2 changes: 1 addition & 1 deletion src/stm32f4/spi.c → src/stm32/spi.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPI functions on STM32F4
// SPI functions on STM32
//
// Copyright (C) 2019 Kevin O'Connor <[email protected]>
//
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/stm32f4/watchdog.c → src/stm32/watchdog.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Watchdog handler on STM32F4
// Watchdog handler on STM32
//
// Copyright (C) 2019 Kevin O'Connor <[email protected]>
//
Expand Down
63 changes: 0 additions & 63 deletions src/stm32f4/Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion test/configs/stm32f1.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Base config file for STM32F1 ARM processor
CONFIG_MACH_STM32F1=y
CONFIG_MACH_STM32=y
CONFIG_MACH_STM32F103=y

0 comments on commit 8b9cc62

Please sign in to comment.