This commit is contained in:
NIIBE Yutaka
2019-05-10 09:59:57 +09:00
parent 3317fb39ab
commit fee2cae8c4
8 changed files with 49 additions and 48 deletions

View File

@@ -1,3 +1,11 @@
2019-05-10 NIIBE Yutaka <gniibe@fsij.org>
* mcu/sys-stm32f103.c: SYS version 4.0.
* mcu/sys-gnu-linux.c: Likewise.
* mcu/sys-mkl27z.c: Likewise.
* mcu/sys-stm32l4.c: Likewise.
* mcu/sys-stm32f0.c: Likewise.
2019-05-08 NIIBE Yutaka <gniibe@fsij.org>
* mcu/sys-stm32f103.c (usb_lld_sys_shutdown, usb_lld_sys_init):

18
NEWS
View File

@@ -1,9 +1,23 @@
NEWS - Noteworthy changes
* Major changes in Chopstx 2.0
* Major changes in Chopstx 1.15
Released 2019-0X-XX
Released 2019-05-10
** SYS version 4.0
USB initialization/finalization demarcation has been changed.
Enabling/disabling USB module is done by USB driver. SYS routines
only handles USB cable config. If a board has a fixed pull-up
resistor, USB driver can omit calling
usb_lld_sys_init/usb_lld_sys_shutdown.
** USB driver change
Enabling/disabling USB module is done by USB driver. Only with
-DUSE_SYS option, it calls usb_lld_sys_init/usb_lld_sys_shutdown.
Don't forget having -DUSE_SYS to support boards with non-fixed 1K5
resistor. Despite this change, it should work well with SYS 3.0
routines.
** Cortex-M4 support
Cortex-M4 support has been added. Not supporting use of FPU or DSP,

View File

@@ -1,8 +1,7 @@
Consideration about SYS and the first pages of flash ROM
========================================================
Now, I'm developing something like SYS for Kinetis L MCU, so, I write
this document.
This document was written when I was porting Chopstx to Kinetis L.
* Compatibility
@@ -10,7 +9,8 @@ this document.
SYS 2.0: Added clock_init, gpio_init
SYS 2.1: Added sys_board_id, sys_board_name
SYS 3.0: Don't setup NVIC priority by usb_lld_sys_init
SYS 4.0: For USB, only do usb_cable_config, enabling the USB module
is the role of USB driver.
* Macro definition by DEFS in Makefile
@@ -131,23 +131,24 @@ and here is the list of all.
nvic_system_reset
The routines of clock_init and gpio_init are here because of some
historical reasons. (We could design a system with no such exported
routines: by defining: those things done internally after reset and
before calling the application.)
The routines of clock_init and gpio_init exist in SYS, because of some
historical reasons; Without such exported routines, we could design a
system having an assumption: important clock and gpio initialization
is done internally after reset, so that an application can just work.
Those are exported as entries of SYS, and it is the responsibility of
the application which do initialize clock and GPIO, calling those
routines.
USB routines are needed because of hardware practice of STM32F103.
With STM32F103, each board has different way for handling the pull up
of USB D+ and how the device asks re-enumeration to host PC. In my
opinion, if it's defined as full speed device and it's OK for us not
to use high impedance (but asserting to LOW, instead) of D+ to ask
re-enumeration, we can just pull up D+ always. And we wouldn't need
such routines in SYS.
USB routines are needed because of hardware practice of STM32F103. (It
can support low speed device. It can support self powered USB
system.) With STM32F103 (for allowing low speed device and self
powered system), each board has different way for handling the pull up
of USB D+ and how the device asks re-enumeration to host PC.
For bus-powered system and full speed device, we can just pull up D+
always. Still, support of high impedance state of D+ line would be
ideal when asking re-enumeration, asserting to LOW works.
About SYS on Kinetis L

View File

@@ -16,8 +16,8 @@
const uint8_t sys_version[8] = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */
'3', 0, '.', 0, '0', 0,
/* sys version: "4.0" */
'4', 0, '.', 0, '0', 0,
};
#if defined(USE_SYS3) || defined(USE_SYS_BOARD_ID)

View File

@@ -69,8 +69,8 @@ set_led (int on)
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = STRING_DESCRIPTOR */
/* sys version: "3.0" */
'3', 0, '.', 0, '0', 0,
/* sys version: "4.0" */
'4', 0, '.', 0, '0', 0,
};
static const uint8_t board_name_string[] = BOARD_NAME;

View File

@@ -69,27 +69,13 @@ static void wait (int count)
static void
usb_lld_sys_shutdown (void)
{
RCC->APB1ENR &= ~RCC_APB1ENR_USBEN;
RCC->APB1RSTR = RCC_APB1RSTR_USBRST;
usb_cable_config (0);
}
static void
usb_lld_sys_init (void)
{
if ((RCC->APB1ENR & RCC_APB1ENR_USBEN)
&& (RCC->APB1RSTR & RCC_APB1RSTR_USBRST) == 0)
/* Make sure the device is disconnected, even after core reset. */
{
usb_lld_sys_shutdown ();
/* Disconnect requires SE0 (>= 2.5uS). */
wait (300);
}
usb_cable_config (1);
RCC->APB1ENR |= RCC_APB1ENR_USBEN;
RCC->APB1RSTR = RCC_APB1RSTR_USBRST;
RCC->APB1RSTR = 0;
}
#define FLASH_KEY1 0x45670123UL
@@ -386,8 +372,8 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */
'3', 0, '.', 0, '0', 0,
/* sys version: "4.0" */
'4', 0, '.', 0, '0', 0,
};
const uint32_t __attribute__((section(".sys.board_id")))

View File

@@ -353,8 +353,8 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */
'3', 0, '.', 0, '0', 0,
/* sys version: "4.0" */
'4', 0, '.', 0, '0', 0,
};
const uint32_t __attribute__((section(".sys.board_id")))

View File

@@ -35,14 +35,6 @@ set_led (int on)
#endif
}
static void wait (int count)
{
int i;
for (i = 0; i < count; i++)
asm volatile ("" : : "r" (i) : "memory");
}
void
usb_lld_sys_shutdown (void)
@@ -65,8 +57,8 @@ nvic_system_reset (void)
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */
'3', 0, '.', 0, '0', 0,
/* sys version: "4.0" */
'4', 0, '.', 0, '0', 0,
};
#if defined(USE_SYS3) || defined(USE_SYS_BOARD_ID)