Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/flipperdevices/libusb_stm32.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFragonite <48802408+Fragonite@users.noreply.github.com>2021-05-02 23:10:41 +0300
committerGitHub <noreply@github.com>2021-05-02 23:10:41 +0300
commitbacc89658b0a101d6b525444e42abd9a9e08e710 (patch)
tree997c8da98246228ddf07934719072e6935188e8c
parentd6924e0ef7ea12f781fc28689cb868db939fc606 (diff)
STM32F303xC Demo (#88)
* STM32F303CC Demo (Device Descriptor Request Failed) * STM32F303xC demo is now working (updated startup code). Co-authored-by: BuildTools <unconfigured@null.spigotmc.org>
-rw-r--r--Makefile5
-rw-r--r--demo/cdc_startup.c17
-rw-r--r--demo/stm32f303xc.ld9
3 files changed, 31 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index d9b696b..ebf62c9 100644
--- a/Makefile
+++ b/Makefile
@@ -147,6 +147,11 @@ stm32f303xe 32f303re-nucleo: clean
DEFINES='STM32F3 STM32F303xE USBD_SOF_DISABLED' \
CFLAGS='-mcpu=cortex-m4'
+stm32f303xc: clean
+ @$(MAKE) demo STARTUP='$(CMSISDEV)/ST/STM32F3xx/Source/Templates/gcc/startup_stm32f303xc.s' \
+ LDSCRIPT='demo/stm32f303xc.ld' \
+ DEFINES='STM32F3 STM32F303xC USBD_SOF_DISABLED' \
+ CFLAGS='-mcpu=cortex-m4'
stm32f105xb: clean
@$(MAKE) demo STARTUP='$(CMSISDEV)/ST/STM32F1xx/Source/Templates/gcc/startup_stm32f105xc.s' \
diff --git a/demo/cdc_startup.c b/demo/cdc_startup.c
index f5e7126..202b70b 100644
--- a/demo/cdc_startup.c
+++ b/demo/cdc_startup.c
@@ -92,6 +92,23 @@ static void cdc_init_rcc (void) {
_BMD(RCC->CFGR, RCC_CFGR_SW, RCC_CFGR_SW_PLL);
_WVL(RCC->CFGR, RCC_CFGR_SWS, RCC_CFGR_SWS_PLL);
+#elif defined(STM32F303xC)
+ /* set flash latency 1WS */
+ _BMD(FLASH->ACR, FLASH_ACR_LATENCY, FLASH_ACR_LATENCY_1);
+ /* use PLL 48MHz clock from 8Mhz HSI */
+ _BMD(RCC->CFGR,
+ RCC_CFGR_PLLMUL | RCC_CFGR_PLLSRC | RCC_CFGR_USBPRE,
+ RCC_CFGR_PLLMUL12 | RCC_CFGR_USBPRE);
+ _BST(RCC->CR, RCC_CR_PLLON);
+ _WBS(RCC->CR, RCC_CR_PLLRDY);
+ /* switch to PLL */
+ _BMD(RCC->CFGR, RCC_CFGR_SW, RCC_CFGR_SW_PLL);
+ _WVL(RCC->CFGR, RCC_CFGR_SWS, RCC_CFGR_SWS_PLL);
+
+ _BST(RCC->AHBENR, RCC_AHBENR_GPIOAEN);
+ _BST(GPIOA->AFR[1], (0x0E << 12) | (0x0E << 16));
+ _BMD(GPIOA->MODER, (0x03 << 22) | (0x03 << 24), (0x02 << 22) | (0x02 << 24));
+
#elif defined(STM32F373xC)
/* set flash latency 1WS */
_BMD(FLASH->ACR, FLASH_ACR_LATENCY, FLASH_ACR_LATENCY_1);
diff --git a/demo/stm32f303xc.ld b/demo/stm32f303xc.ld
new file mode 100644
index 0000000..2eee88a
--- /dev/null
+++ b/demo/stm32f303xc.ld
@@ -0,0 +1,9 @@
+ENTRY(Reset_Handler)
+MEMORY
+{
+ ROM (rx): ORIGIN = 0x08000000, LENGTH = 256K
+ RAM (rwx): ORIGIN = 0x20000000, LENGTH = 40K
+ CCMRAM (rwx): ORIGIN = 0x10000000, LENGTH = 8K
+}
+
+INCLUDE sections.ld