Skip to content

arch/arm/stm32: Basic STM32F7 family support #7220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b1522e
arch/arm/stm32: Basic STM32F7 support
Apr 26, 2018
1432a83
Revert "arch/arm/stm32: Basic STM32F7 support"
Apr 27, 2018
a80dd6a
arch: arm: stm32: Basic STM32F7 family support
Apr 27, 2018
b249ec0
boards: arm: stm32: Support for STM32F746G Discovery board
Apr 27, 2018
09cda99
drivers: clock_control: STM32F7 family clock control support
Apr 27, 2018
895922c
drivers: gpio: GPIO support for STM32F7 family
Apr 27, 2018
3864153
drivers: interrupt_controller: STM32F7 interrupt controller support
Apr 27, 2018
0e035d3
drivers: pinmux: STM32F7 pinmux support
Apr 27, 2018
ab4a6ee
drivers: serial: STM32F7 UART support
Apr 27, 2018
b54dbbf
dts: arm: st: STM32F7 family device tree
Apr 27, 2018
13b36fb
Revert "boards: arm: stm32: Support for STM32F746G Discovery board"
Apr 28, 2018
20869af
boards: arm: stm32: Basic support for STM32F746G Discovery board
May 1, 2018
6208332
arch: arm: stm32: Basic STM32F7 family support
Apr 27, 2018
4a01023
drivers: clock_control: STM32F7 family clock control support
Apr 27, 2018
4339e06
drivers: gpio: GPIO support for STM32F7 family
Apr 27, 2018
f6cecca
drivers: interrupt_controller: STM32F7 interrupt controller support
Apr 27, 2018
3ae7f49
drivers: pinmux: STM32F7 pinmux support
Apr 27, 2018
d7360fd
drivers: serial: STM32F7 UART support
Apr 27, 2018
70a5895
dts: arm: st: STM32F7 family device tree
Apr 27, 2018
f1fde9e
boards: arm: stm32: Basic support for STM32F746G Discovery board
May 1, 2018
aa52335
Merge branch 'master' of github.com:pic16f887/zephyr
May 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
zephyr_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_sources(
soc.c
)
zephyr_sources_ifdef(CONFIG_GPIO soc_gpio.c)
15 changes: 15 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/Kconfig.defconfig.series
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Kconfig.defconfig.series - ST Microelectronics STM32F7 MCU line
#
# Copyright (c) 2018 Yurii Hamann
#
# SPDX-License-Identifier: Apache-2.0
#

if SOC_SERIES_STM32F7X

source "arch/arm/soc/st_stm32/stm32f7/Kconfig.defconfig.stm32f7*"

config SOC_SERIES
default stm32f7

endif # SOC_SERIES_STM32F7X
18 changes: 18 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/Kconfig.defconfig.stm32f746xg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Kconfig - ST STM32F746XG MCU configuration options
#
# Copyright (c) 2018 Yurii Hamann
#
# SPDX-License-Identifier: Apache-2.0
#

if SOC_STM32F746XG

config SOC
string
default stm32f746xx

config NUM_IRQS
int
default 97

endif # SOC_STM32F746XG
19 changes: 19 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/Kconfig.series
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Kconfig - ST Microelectronics STM32F7 MCU series
#
# Copyright (c) 2018 Yurii Hamann
#
# SPDX-License-Identifier: Apache-2.0
#

config SOC_SERIES_STM32F7X
bool "STM32F7x Series MCU"
select CPU_CORTEX_M7
select CPU_HAS_FPU
select SOC_FAMILY_STM32
select SYS_POWER_LOW_POWER_STATE_SUPPORTED
select HAS_STM32CUBE
select CPU_HAS_MPU
select CPU_HAS_SYSTICK
select CLOCK_CONTROL_STM32_CUBE if CLOCK_CONTROL
help
Enable support for STM32F7 MCU series
28 changes: 28 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Kconfig.soc - ST Microelectronics STM32F7 MCU line
#
# Copyright (c) 2018 Yurii Hamann
#
# SPDX-License-Identifier: Apache-2.0
#

choice
prompt "STM32F7x MCU Selection"
depends on SOC_SERIES_STM32F7X

config SOC_STM32F746XG
bool "STM32F746XG"

endchoice


choice
prompt "Configure Bootloader Options"
depends on MPU_ENABLE

config BL_BOOTLOADER
bool "Build the Bootloader"

config BL_APPLICATION
bool "Build an Application"

endchoice
29 changes: 29 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/dts.fixup
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* SoC level DTS fixup file */

#define CONFIG_NUM_IRQ_PRIO_BITS ARM_V7M_NVIC_E000E100_ARM_NUM_IRQ_PRIORITY_BITS

#define CONFIG_UART_STM32_PORT_1_BASE_ADDRESS ST_STM32_USART_40011000_BASE_ADDRESS
#define CONFIG_UART_STM32_PORT_1_BAUD_RATE ST_STM32_USART_40011000_CURRENT_SPEED
#define CONFIG_UART_STM32_PORT_1_IRQ_PRI ST_STM32_USART_40011000_IRQ_0_PRIORITY
#define CONFIG_UART_STM32_PORT_1_NAME ST_STM32_USART_40011000_LABEL
#define PORT_1_IRQ ST_STM32_USART_40011000_IRQ_0

#define CONFIG_UART_STM32_PORT_2_BASE_ADDRESS ST_STM32_USART_40004400_BASE_ADDRESS
#define CONFIG_UART_STM32_PORT_2_BAUD_RATE ST_STM32_USART_40004400_CURRENT_SPEED
#define CONFIG_UART_STM32_PORT_2_IRQ_PRI ST_STM32_USART_40004400_IRQ_0_PRIORITY
#define CONFIG_UART_STM32_PORT_2_NAME ST_STM32_USART_40004400_LABEL
#define PORT_2_IRQ ST_STM32_USART_40004400_IRQ_0

#define CONFIG_UART_STM32_PORT_3_BASE_ADDRESS ST_STM32_USART_40004800_BASE_ADDRESS
#define CONFIG_UART_STM32_PORT_3_BAUD_RATE ST_STM32_USART_40004800_CURRENT_SPEED
#define CONFIG_UART_STM32_PORT_3_IRQ_PRI ST_STM32_USART_40004800_IRQ_0_PRIORITY
#define CONFIG_UART_STM32_PORT_3_NAME ST_STM32_USART_40004800_LABEL
#define PORT_3_IRQ ST_STM32_USART_40004800_IRQ_0

#define CONFIG_UART_STM32_PORT_6_NAME ST_STM32_USART_40011400_LABEL
#define CONFIG_UART_STM32_PORT_6_BASE_ADDRESS ST_STM32_USART_40011400_BASE_ADDRESS
#define CONFIG_UART_STM32_PORT_6_BAUD_RATE ST_STM32_USART_40011400_CURRENT_SPEED
#define CONFIG_UART_STM32_PORT_6_IRQ_PRI ST_STM32_USART_40011400_IRQ_0_PRIORITY
#define PORT_6_IRQ ST_STM32_USART_40011400_IRQ_0

/* End of SoC Level DTS fixup file */
42 changes: 42 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/flash_registers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2018 Yurii Hamann
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _STM32F7X_FLASH_REGISTERS_H_
#define _STM32F7X_FLASH_REGISTERS_H_

/**
* @brief
*
* Based on reference manual:
*
* Chapter 3.4: Embedded Flash Memory
*/

union __flash_acr {
u32_t val;
struct {
u32_t latency :4 __packed;
u32_t rsvd__4_7 :4 __packed;
u32_t prften :1 __packed;
u32_t icen :1 __packed;
u32_t dcen :1 __packed;
u32_t icrst :1 __packed;
u32_t dcrst :1 __packed;
u32_t rsvd__13_31 :19 __packed;
} bit;
};

/* 3.8.7 Embedded flash registers */
struct stm32f7x_flash {
volatile union __flash_acr acr;
volatile u32_t keyr;
volatile u32_t optkeyr;
volatile u32_t sr;
volatile u32_t cr;
volatile u32_t optcr;
};

#endif /* _STM32F7X_FLASHREGISTERS_H_ */
52 changes: 52 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/gpio_registers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2018 Yurii Hamann
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _STM32F7X_GPIO_REGISTERS_H_
#define _STM32F7X_GPIO_REGISTERS_H_

/**
* @brief Driver for GPIO of STM32F7X family processor.
*
* Based on reference manual:
* RM0385 Reference manual STM32F75xxx and STM32F74xxx
* advanced ARM(r)-based 32-bit MCUs
*
* Chapter 6: General-purpose I/Os (GPIOs)
*/

/* 6.4 GPIO registers - each GPIO port controls 16 pins */
struct stm32f7x_gpio {
u32_t mode;
u32_t otype;
u32_t ospeed;
u32_t pupdr;
u32_t idr;
u32_t odr;
u32_t bsr;
u32_t lck;
u32_t afr[2];
};

union syscfg_exticr {
u32_t val;
struct {
u16_t rsvd__16_31;
u16_t exti;
} bit;
};

/* 7.2 SYSCFG registers */
struct stm32f7x_syscfg {
u32_t memrmp;
u32_t pmc;
union syscfg_exticr exticr1;
union syscfg_exticr exticr2;
union syscfg_exticr exticr3;
union syscfg_exticr exticr4;
u32_t cmpcr;
};

#endif /* _STM32F7X_GPIO_REGISTERS_H_ */
9 changes: 9 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* linker.ld - Linker command/script file */

/*
* Copyright (c) 2018 Yurii Hamann
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <arch/arm/cortex_m/scripts/linker.ld>
62 changes: 62 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/soc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2018 Yurii Hamann
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief System/hardware module for STM32F7 processor
*/

#include <kernel.h>
#include <device.h>
#include <init.h>
#include <soc.h>
#include <arch/cpu.h>
#include <cortex_m/exc.h>

/**
* @brief This function configures the source of stm32cube time base.
* Cube HAL expects a 1ms tick which matches with k_uptime_get_32.
* Tick interrupt priority is not used
* @return HAL status
*/
uint32_t HAL_GetTick(void)
{
return k_uptime_get_32();
}

/**
* @brief Perform basic hardware initialization at boot.
*
* This needs to be run from the very beginning.
* So the init priority has to be 0 (zero).
*
* @return 0
*/
static int st_stm32f7_init(struct device *arg)
{
u32_t key;

ARG_UNUSED(arg);

key = irq_lock();

_ClearFaults();

/* Install default handler that simply resets the CPU
* if configured in the kernel, NOP otherwise
*/
NMI_INIT();

irq_unlock(key);

/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, system core clock is set to 25 MHz from HSI */
SystemCoreClock = 25000000;

return 0;
}

SYS_INIT(st_stm32f7_init, PRE_KERNEL_1, 0);
50 changes: 50 additions & 0 deletions arch/arm/soc/st_stm32/stm32f7/soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2018 Yurii Hamann
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file SoC configuration macros for the ST STM32F7 family processors.
*
* Based on reference manual:
* RM0368 Reference manual STM32F401xB/C and STM32F401xD/E
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add STM32F7 reference manuals.

* advanced ARM(r)-based 32-bit MCUs
*
* Chapter 2.3: Memory Map
*/

#ifndef _STM32F7_SOC_H_
#define _STM32F7_SOC_H_

#define GPIO_REG_SIZE 0x400
/* base address for where GPIO registers start */
#define GPIO_PORTS_BASE (GPIOA_BASE)

#ifndef _ASMLANGUAGE

#include <device.h>
#include <misc/util.h>
#include <stm32f7xx.h>

#include "soc_irq.h"

#ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
#include <stm32f7xx_ll_utils.h>
#include <stm32f7xx_ll_bus.h>
#include <stm32f7xx_ll_rcc.h>
#include <stm32f7xx_ll_system.h>
#include <stm32f7xx_ll_spi.h>
#endif /* CONFIG_CLOCK_CONTROL_STM32_CUBE */

#ifdef CONFIG_SERIAL_HAS_DRIVER
#include <stm32f7xx_ll_usart.h>
#endif

#ifdef CONFIG_IWDG_STM32
#include <stm32f7xx_ll_iwdg.h>
#endif

#endif /* !_ASMLANGUAGE */

#endif /* _STM3274_SOC_H_ */
Loading