diff --git a/bsp/lpc2148/lpc2148_rom.ld b/bsp/lpc2148/lpc2148_rom.ld index 42af52415a7536b87a09e3276e5476d11763bc34..2dbe82514f7a7847a63a61a54016dc65dd2f9ab6 100644 --- a/bsp/lpc2148/lpc2148_rom.ld +++ b/bsp/lpc2148/lpc2148_rom.ld @@ -132,7 +132,6 @@ SECTIONS . = ALIGN(4); /* This is used by the startup in order to initialize the .bss secion */ _ebss = . ; - _estack = .; } > DATA __bss_end = .; diff --git a/bsp/stm32f10x/application.c b/bsp/stm32f10x/application.c index 975fba1f9a79def737b8e31233815cf7c6ae7f2f..56df272b4bf44de460843062d0786fe656431c33 100644 --- a/bsp/stm32f10x/application.c +++ b/bsp/stm32f10x/application.c @@ -38,8 +38,8 @@ #include "led.h" ALIGN(RT_ALIGN_SIZE) +static rt_uint8_t led_stack[ 512 ]; static struct rt_thread led_thread; -static rt_uint32_t led_stack[512/4]; static void led_thread_entry(void* parameter) { unsigned int count=0; @@ -58,7 +58,7 @@ static void led_thread_entry(void* parameter) /* led1 off */ #ifndef RT_USING_FINSH - rt_kprintf("led2 off\r\n"); + rt_kprintf("led off\r\n"); #endif rt_hw_led_off(0); rt_thread_delay( RT_TICK_PER_SECOND/2 ); diff --git a/bsp/stm32f10x/board.c b/bsp/stm32f10x/board.c index 27da518e4b00e291a579d2e64146696bf5a46c27..17de67a3146d0b0caee6d8075f6a71d543c7d603 100644 --- a/bsp/stm32f10x/board.c +++ b/bsp/stm32f10x/board.c @@ -43,75 +43,79 @@ void NVIC_Configuration(void) #endif } -/******************************************************************************* - * Function Name : SysTick_Configuration - * Description : Configures the SysTick for OS tick. - * Input : None - * Output : None - * Return : None - *******************************************************************************/ -void SysTick_Configuration(void) -{ - RCC_ClocksTypeDef rcc_clocks; - rt_uint32_t cnts; - - RCC_GetClocksFreq(&rcc_clocks); - - cnts = (rt_uint32_t)rcc_clocks.HCLK_Frequency / RT_TICK_PER_SECOND; - - SysTick_Config(cnts); - SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK); -} - #if STM32_EXT_SRAM void EXT_SRAM_Configuration(void) { FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p; - GPIO_InitTypeDef GPIO_InitStructure; - - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); - - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOE | - RCC_APB2Periph_GPIOF, ENABLE); - - /*-- GPIO Configuration ------------------------------------------------------*/ - /* SRAM Data lines configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | - GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | - GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | - GPIO_Pin_15; - GPIO_Init(GPIOE, &GPIO_InitStructure); - - /* SRAM Address lines configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | - GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | - GPIO_Pin_14 | GPIO_Pin_15; - GPIO_Init(GPIOF, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | - GPIO_Pin_4 | GPIO_Pin_5; - GPIO_Init(GPIOG, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* NOE and NWE configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* NE3 NE4 configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_12; - GPIO_Init(GPIOG, &GPIO_InitStructure); - /* NBL0, NBL1 configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; - GPIO_Init(GPIOE, &GPIO_InitStructure); + /* FSMC GPIO configure */ + { + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF + | RCC_APB2Periph_GPIOG, ENABLE); + RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); + + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + + /* + FSMC_D0 ~ FSMC_D3 + PD14 FSMC_D0 PD15 FSMC_D1 PD0 FSMC_D2 PD1 FSMC_D3 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* + FSMC_D4 ~ FSMC_D12 + PE7 ~ PE15 FSMC_D4 ~ FSMC_D12 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 + | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOE,&GPIO_InitStructure); + + /* FSMC_D13 ~ FSMC_D15 PD8 ~ PD10 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* + FSMC_A0 ~ FSMC_A5 FSMC_A6 ~ FSMC_A9 + PF0 ~ PF5 PF12 ~ PF15 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 + | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOF,&GPIO_InitStructure); + + /* FSMC_A10 ~ FSMC_A15 PG0 ~ PG5 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; + GPIO_Init(GPIOG,&GPIO_InitStructure); + + /* FSMC_A16 ~ FSMC_A18 PD11 ~ PD13 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* RD-PD4 WR-PD5 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* NBL0-PE0 NBL1-PE1 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; + GPIO_Init(GPIOE,&GPIO_InitStructure); + + /* NE1/NCE2 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; + GPIO_Init(GPIOD,&GPIO_InitStructure); + /* NE2 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; + GPIO_Init(GPIOG,&GPIO_InitStructure); + /* NE3 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_Init(GPIOG,&GPIO_InitStructure); + /* NE4 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; + GPIO_Init(GPIOG,&GPIO_InitStructure); + } + /* FSMC GPIO configure */ /*-- FSMC Configuration ------------------------------------------------------*/ p.FSMC_AddressSetupTime = 0; @@ -127,6 +131,7 @@ void EXT_SRAM_Configuration(void) FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; @@ -167,8 +172,8 @@ void rt_hw_board_init() /* NVIC Configuration */ NVIC_Configuration(); - /* Configure the SysTick */ - SysTick_Configuration(); + /* Configure the SysTick */ + SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND ); #if STM32_EXT_SRAM EXT_SRAM_Configuration(); diff --git a/bsp/stm32f10x/dm9000a.c b/bsp/stm32f10x/dm9000a.c index 92cc7f84bad41b4f92b7742dacd0912420e1234b..9a8c613c00d694cffd0872895544c44597853ae8 100644 --- a/bsp/stm32f10x/dm9000a.c +++ b/bsp/stm32f10x/dm9000a.c @@ -631,48 +631,74 @@ static void FSMC_Configuration() { FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p; - GPIO_InitTypeDef GPIO_InitStructure; - RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOE | - RCC_APB2Periph_GPIOF, ENABLE); - - /*-- GPIO Configuration ------------------------------------------------------*/ - /* SRAM Data lines configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | - GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | - GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | - GPIO_Pin_15; - GPIO_Init(GPIOE, &GPIO_InitStructure); - - /* SRAM Address lines configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | - GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | - GPIO_Pin_14 | GPIO_Pin_15; - GPIO_Init(GPIOF, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | - GPIO_Pin_4 | GPIO_Pin_5; - GPIO_Init(GPIOG, &GPIO_InitStructure); - - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* NOE and NWE configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5; - GPIO_Init(GPIOD, &GPIO_InitStructure); - - /* NE3 NE4 configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_12; - GPIO_Init(GPIOG, &GPIO_InitStructure); - - /* NBL0, NBL1 configuration */ - GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; - GPIO_Init(GPIOE, &GPIO_InitStructure); + /* FSMC GPIO configure */ + { + GPIO_InitTypeDef GPIO_InitStructure; + RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_GPIOF + | RCC_APB2Periph_GPIOG, ENABLE); + RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE); + + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; + + /* + FSMC_D0 ~ FSMC_D3 + PD14 FSMC_D0 PD15 FSMC_D1 PD0 FSMC_D2 PD1 FSMC_D3 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* + FSMC_D4 ~ FSMC_D12 + PE7 ~ PE15 FSMC_D4 ~ FSMC_D12 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 + | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOE,&GPIO_InitStructure); + + /* FSMC_D13 ~ FSMC_D15 PD8 ~ PD10 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* + FSMC_A0 ~ FSMC_A5 FSMC_A6 ~ FSMC_A9 + PF0 ~ PF5 PF12 ~ PF15 + */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 + | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; + GPIO_Init(GPIOF,&GPIO_InitStructure); + + /* FSMC_A10 ~ FSMC_A15 PG0 ~ PG5 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5; + GPIO_Init(GPIOG,&GPIO_InitStructure); + + /* FSMC_A16 ~ FSMC_A18 PD11 ~ PD13 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* RD-PD4 WR-PD5 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; + GPIO_Init(GPIOD,&GPIO_InitStructure); + + /* NBL0-PE0 NBL1-PE1 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; + GPIO_Init(GPIOE,&GPIO_InitStructure); + + /* NE1/NCE2 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; + GPIO_Init(GPIOD,&GPIO_InitStructure); + /* NE2 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; + GPIO_Init(GPIOG,&GPIO_InitStructure); + /* NE3 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; + GPIO_Init(GPIOG,&GPIO_InitStructure); + /* NE4 */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; + GPIO_Init(GPIOG,&GPIO_InitStructure); + } + /* FSMC GPIO configure */ /*-- FSMC Configuration ------------------------------------------------------*/ p.FSMC_AddressSetupTime = 0; @@ -688,6 +714,7 @@ static void FSMC_Configuration() FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b; FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; + FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; diff --git a/bsp/stm32f10x/stm32_rom.ld b/bsp/stm32f10x/stm32_rom.ld index a0e9747af20e87971929e07e1a6366341c8c0324..b6854c9df063d7c8cbff0042e8b441ea2b11d05e 100644 --- a/bsp/stm32f10x/stm32_rom.ld +++ b/bsp/stm32f10x/stm32_rom.ld @@ -6,10 +6,11 @@ /* Program Entry, set to mark it as "used" and avoid gc */ MEMORY { - CODE (rx) : ORIGIN = 0x08000000, LENGTH = 0x00080000 - DATA (rw) : ORIGIN = 0x20000000, LENGTH = 0x00010000 + CODE (rx) : ORIGIN = 0x08000000, LENGTH = 512k /* 512KB flash */ + DATA (rw) : ORIGIN = 0x20000000, LENGTH = 64k /* 64K sram */ } ENTRY(Reset_Handler) +_system_tack_size = 0x100; SECTIONS { @@ -69,6 +70,13 @@ SECTIONS _edata = . ; } >DATA + .stack : + { + . = . + _system_tack_size; + . = ALIGN(4); + _estack = .; + } >DATA + __bss_start = .; .bss : { @@ -83,7 +91,6 @@ SECTIONS . = ALIGN(4); /* This is used by the startup in order to initialize the .bss secion */ _ebss = . ; - _estack = .; *(.bss.init) } > DATA