|
@@ -43,75 +43,79 @@ void NVIC_Configuration(void)
|
|
#endif
|
|
#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
|
|
#if STM32_EXT_SRAM
|
|
void EXT_SRAM_Configuration(void)
|
|
void EXT_SRAM_Configuration(void)
|
|
{
|
|
{
|
|
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
|
|
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
|
|
FSMC_NORSRAMTimingInitTypeDef p;
|
|
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 ------------------------------------------------------*/
|
|
/*-- FSMC Configuration ------------------------------------------------------*/
|
|
p.FSMC_AddressSetupTime = 0;
|
|
p.FSMC_AddressSetupTime = 0;
|
|
@@ -127,6 +131,7 @@ void EXT_SRAM_Configuration(void)
|
|
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
|
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
|
|
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
|
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
|
|
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
|
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
|
|
|
|
+ FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
|
|
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
|
|
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
|
|
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
|
|
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
|
|
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
|
|
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
|
|
@@ -167,8 +172,8 @@ void rt_hw_board_init()
|
|
/* NVIC Configuration */
|
|
/* NVIC Configuration */
|
|
NVIC_Configuration();
|
|
NVIC_Configuration();
|
|
|
|
|
|
- /* Configure the SysTick */
|
|
|
|
- SysTick_Configuration();
|
|
|
|
|
|
+ /* Configure the SysTick */
|
|
|
|
+ SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND );
|
|
|
|
|
|
#if STM32_EXT_SRAM
|
|
#if STM32_EXT_SRAM
|
|
EXT_SRAM_Configuration();
|
|
EXT_SRAM_Configuration();
|