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> 2019-05-08 NIIBE Yutaka <gniibe@fsij.org>
* mcu/sys-stm32f103.c (usb_lld_sys_shutdown, usb_lld_sys_init): * mcu/sys-stm32f103.c (usb_lld_sys_shutdown, usb_lld_sys_init):

18
NEWS
View File

@@ -1,9 +1,23 @@
NEWS - Noteworthy changes 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
Cortex-M4 support has been added. Not supporting use of FPU or DSP, 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 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 was written when I was porting Chopstx to Kinetis L.
this document.
* Compatibility * Compatibility
@@ -10,7 +9,8 @@ this document.
SYS 2.0: Added clock_init, gpio_init SYS 2.0: Added clock_init, gpio_init
SYS 2.1: Added sys_board_id, sys_board_name SYS 2.1: Added sys_board_id, sys_board_name
SYS 3.0: Don't setup NVIC priority by usb_lld_sys_init 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 * Macro definition by DEFS in Makefile
@@ -131,23 +131,24 @@ and here is the list of all.
nvic_system_reset nvic_system_reset
The routines of clock_init and gpio_init are here because of some The routines of clock_init and gpio_init exist in SYS, because of some
historical reasons. (We could design a system with no such exported historical reasons; Without such exported routines, we could design a
routines: by defining: those things done internally after reset and system having an assumption: important clock and gpio initialization
before calling the application.) 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 Those are exported as entries of SYS, and it is the responsibility of
the application which do initialize clock and GPIO, calling those the application which do initialize clock and GPIO, calling those
routines. routines.
USB routines are needed because of hardware practice of STM32F103. USB routines are needed because of hardware practice of STM32F103. (It
With STM32F103, each board has different way for handling the pull up can support low speed device. It can support self powered USB
of USB D+ and how the device asks re-enumeration to host PC. In my system.) With STM32F103 (for allowing low speed device and self
opinion, if it's defined as full speed device and it's OK for us not powered system), each board has different way for handling the pull up
to use high impedance (but asserting to LOW, instead) of D+ to ask of USB D+ and how the device asks re-enumeration to host PC.
re-enumeration, we can just pull up D+ always. And we wouldn't need
such routines in SYS.
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 About SYS on Kinetis L

View File

@@ -16,8 +16,8 @@
const uint8_t sys_version[8] = { const uint8_t sys_version[8] = {
3*2+2, /* bLength */ 3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */ 0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */ /* sys version: "4.0" */
'3', 0, '.', 0, '0', 0, '4', 0, '.', 0, '0', 0,
}; };
#if defined(USE_SYS3) || defined(USE_SYS_BOARD_ID) #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"))) = { const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */ 3*2+2, /* bLength */
0x03, /* bDescriptorType = STRING_DESCRIPTOR */ 0x03, /* bDescriptorType = STRING_DESCRIPTOR */
/* sys version: "3.0" */ /* sys version: "4.0" */
'3', 0, '.', 0, '0', 0, '4', 0, '.', 0, '0', 0,
}; };
static const uint8_t board_name_string[] = BOARD_NAME; static const uint8_t board_name_string[] = BOARD_NAME;

View File

@@ -69,27 +69,13 @@ static void wait (int count)
static void static void
usb_lld_sys_shutdown (void) usb_lld_sys_shutdown (void)
{ {
RCC->APB1ENR &= ~RCC_APB1ENR_USBEN;
RCC->APB1RSTR = RCC_APB1RSTR_USBRST;
usb_cable_config (0); usb_cable_config (0);
} }
static void static void
usb_lld_sys_init (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); usb_cable_config (1);
RCC->APB1ENR |= RCC_APB1ENR_USBEN;
RCC->APB1RSTR = RCC_APB1RSTR_USBRST;
RCC->APB1RSTR = 0;
} }
#define FLASH_KEY1 0x45670123UL #define FLASH_KEY1 0x45670123UL
@@ -386,8 +372,8 @@ handler vector[] __attribute__ ((section(".vectors"))) = {
const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = { const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */ 3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */ 0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */ /* sys version: "4.0" */
'3', 0, '.', 0, '0', 0, '4', 0, '.', 0, '0', 0,
}; };
const uint32_t __attribute__((section(".sys.board_id"))) 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"))) = { const uint8_t sys_version[8] __attribute__((section(".sys.version"))) = {
3*2+2, /* bLength */ 3*2+2, /* bLength */
0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */ 0x03, /* bDescriptorType = USB_STRING_DESCRIPTOR_TYPE */
/* sys version: "3.0" */ /* sys version: "4.0" */
'3', 0, '.', 0, '0', 0, '4', 0, '.', 0, '0', 0,
}; };
const uint32_t __attribute__((section(".sys.board_id"))) const uint32_t __attribute__((section(".sys.board_id")))

View File

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