Fix flash_protect for GD32F103.

This commit is contained in:
NIIBE Yutaka
2018-05-08 17:35:13 +09:00
parent f500ac03da
commit 2764fc4ea2
3 changed files with 12 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
* doc/chopstx.texi (Compile-time macro): Add chapter. * doc/chopstx.texi (Compile-time macro): Add chapter.
* mcu/sys-stm32f103.c (usb_lld_sys_init): Use MHZ. * mcu/sys-stm32f103.c (usb_lld_sys_init): Use MHZ.
(flash_protect): Fix for GD32F103.
2018-04-26 NIIBE Yutaka <gniibe@fsij.org> 2018-04-26 NIIBE Yutaka <gniibe@fsij.org>

11
NEWS
View File

@@ -9,14 +9,17 @@ NEWS - Noteworthy changes
GD32F103 is an alternative implementation of STM32F103 by Giga Device, GD32F103 is an alternative implementation of STM32F103 by Giga Device,
which can run at 96MHz. which can run at 96MHz.
** Minor USB driver fix for STM32F103 ** Minor USB driver fix for STM32F103/GD32F103
BTABLE setting should be done for initialization, not for USB RESET. BTABLE setting should be done at initialization, not at USB RESET.
** Minor SYS driver fix for GD32F103
flash_protect should check FLASH_CR_OPTWRE.
** Minor ADC driver change for GD32F103 ** Minor ADC driver change for GD32F103
ADC on GD32F103 is another implementation and its behavior is somewhat ADC on GD32F103 is another implementation and its behavior is somewhat
different. It requires waits after enabling. So, we use continuous different. It requires waits after enabling. So, we use continuous
samping. Still, we observe enough noise (> 4.7 bit/byte) for each ADC sampling, instead of start and stop for each sample. Still, we
sampling. observe enough noise (> 4.7 bit/byte) for each ADC sampling.
* Major changes in Chopstx 1.8 * Major changes in Chopstx 1.8

View File

@@ -1,7 +1,7 @@
/* /*
* sys-stm32f103.c - system routines for the initial page for STM32F103. * sys-stm32f103.c - system routines for the initial page for STM32F103.
* *
* Copyright (C) 2013, 2014, 2015, 2016, 2017 * Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018
* Flying Stone Technology * Flying Stone Technology
* Author: NIIBE Yutaka <gniibe@fsij.org> * Author: NIIBE Yutaka <gniibe@fsij.org>
* *
@@ -256,6 +256,9 @@ flash_protect (void)
FLASH->OPTKEYR = FLASH_KEY1; FLASH->OPTKEYR = FLASH_KEY1;
FLASH->OPTKEYR = FLASH_KEY2; FLASH->OPTKEYR = FLASH_KEY2;
while (!(FLASH->CR & FLASH_CR_OPTWRE))
;
FLASH->CR |= FLASH_CR_OPTER; FLASH->CR |= FLASH_CR_OPTER;
FLASH->CR |= FLASH_CR_STRT; FLASH->CR |= FLASH_CR_STRT;