SYS 4.0.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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")))
|
||||
|
||||
@@ -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")))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user