Skip to content
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

Add STM32G0 support. #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CMSIS ?= CMSIS
CMSIS ?= $(HOME)/STM32Cube/Repository/STM32Cube_FW_G0_V1.6.1/Drivers/CMSIS
CMSISDEV ?= $(CMSIS)/Device
CMSISCORE ?= $(CMSIS)/CMSIS/Include $(CMSIS)/CMSIS/Core/Include
CMSISCORE ?= $(CMSIS)/Include $(CMSIS)/Core/Include
FLASH ?= st-flash
TOOLSET ?= arm-none-eabi-
CC = $(TOOLSET)gcc
Expand All @@ -9,7 +9,7 @@ AR = $(TOOLSET)gcc-ar
OBJCOPY = $(TOOLSET)objcopy
DFU_UTIL ?= dfu-util
STPROG_CLI ?= ~/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI
OPTFLAGS ?= -Os
OPTFLAGS ?= -Os -g

ifeq ($(OS),Windows_NT)
RM = del /Q
Expand Down Expand Up @@ -297,3 +297,9 @@ stm32f411xe stm32f411e-disco: clean
LDSCRIPT='demo/stm32f401xe.ld' \
DEFINES='STM32F4 STM32F411xE USBD_SOF_DISABLED' \
CFLAGS='-mcpu=cortex-m4'

stm32g0b1xe: clean
@$(MAKE) demo STARTUP='$(CMSISDEV)/ST/STM32G0xx/Source/Templates/gcc/startup_stm32g0b1xx.s' \
LDSCRIPT='demo/stm32g0b1xe.ld' \
DEFINES='STM32G0 STM32G0B1xx USBD_SOF_DISABLED' \
CFLAGS='-mcpu=cortex-m0plus'
11 changes: 11 additions & 0 deletions demo/cdc_startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,17 @@ static void cdc_init_rcc (void) {
/* using HSI16 as AHB/CPU clock, HSI48 as USB PHY clock */
_BST(RCC->CRRCR, RCC_CRRCR_HSI48ON);
_WBS(RCC->CRRCR, RCC_CRRCR_HSI48RDY);
#elif defined(STM32G0)
/* using HSI16 as AHB/CPU clock, HSI48 as USB PHY clock */
_BST(RCC->CR, RCC_CR_HSION);
_WBS(RCC->CR, RCC_CR_HSIRDY);
_BST(RCC->CR, RCC_CR_HSI48ON);
_WBS(RCC->CR, RCC_CR_HSI48RDY);
_BMD(RCC->CFGR, RCC_CFGR_HPRE, 0U /*LL_RCC_SYSCLK_DIV_1*/);
_BMD(RCC->CFGR, RCC_CFGR_SW, 0U /*LL_RCC_SYS_CLKSOURCE_HSI*/);
_WVL(RCC->CFGR, RCC_CFGR_SWS, 0U /*LL_RCC_SYS_CLKSOURCE_STATUS_HSI*/);
_BMD(RCC->CFGR, RCC_CFGR_PPRE, 0U /*LL_RCC_APB1_DIV_1*/);
_BST(FLASH->ACR, FLASH_ACR_PRFTEN);
#elif defined(STM32WB55xx)
/* using HSI16 as AHB/CPU clock, HSI48 as USB PHY clock */
_BST(RCC->CR, RCC_CR_HSION);
Expand Down
8 changes: 8 additions & 0 deletions demo/stm32g0b1xe.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ENTRY(Reset_Handler)
MEMORY
{
ROM (rx): ORIGIN = 0x08000000, LENGTH = 512K
RAM (rwx): ORIGIN = 0x20000000, LENGTH = 128K
}

INCLUDE sections.ld
13 changes: 13 additions & 0 deletions inc/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@
#define usbd_hw usbd_otgfs
#endif //__ASSEMBLER__

#elif defined(STM32G0)
#define USBD_STM32G0B1

#if !defined(__ASSEMBLER__)
extern const struct usbd_driver usbd_devfs;
extern const struct usbd_driver usbd_devfs_asm;
#if defined(USBD_ASM_DRIVER)
#define usbd_hw usbd_devfs_asm
#else
#define usbd_hw usbd_devfs
#endif
#endif

#else
#error Unsupported STM32 family
#endif
Expand Down
Loading