summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorardafu <[email protected]>2015-09-25 15:35:37 +0800
committerardafu <[email protected]>2015-09-25 15:35:37 +0800
commit090153f94f52cc74906dd5f4cfc893493755c0a2 (patch)
tree9a1ccfe5a48234f3249d9bc361414cdfe4a5a95b
parentb4e3fb2007cc19abe5cd24103008396e791a4f4a (diff)
[bsp][stm32f746-Disco] Cleanup code
1. Using RT_USING_COMPONENTS_INIT and RT_USING_USER_MAIN 2. Cleanup code
-rw-r--r--bsp/stm32f7-disco/applications/application.c6
-rw-r--r--bsp/stm32f7-disco/applications/startup.c125
-rw-r--r--bsp/stm32f7-disco/drivers/board.c25
-rw-r--r--bsp/stm32f7-disco/drivers/board.h2
-rw-r--r--bsp/stm32f7-disco/drivers/drv_mpu.c9
-rw-r--r--bsp/stm32f7-disco/drivers/drv_mpu.h4
-rw-r--r--bsp/stm32f7-disco/drivers/drv_sdram.c6
-rw-r--r--bsp/stm32f7-disco/rtconfig.h3
-rw-r--r--bsp/stm32f7-disco/rtconfig.py2
9 files changed, 37 insertions, 145 deletions
diff --git a/bsp/stm32f7-disco/applications/application.c b/bsp/stm32f7-disco/applications/application.c
index e1dafdf5b2..2bf527c90b 100644
--- a/bsp/stm32f7-disco/applications/application.c
+++ b/bsp/stm32f7-disco/applications/application.c
@@ -24,14 +24,14 @@
*/
#include <rtthread.h>
-#include <components.h>
void rt_init_thread_entry(void *parameter)
{
- rt_components_init();
+ //rt_components_init();
}
-int rt_application_init()
+//int rt_application_init()
+int main(void)
{
rt_thread_t tid;
diff --git a/bsp/stm32f7-disco/applications/startup.c b/bsp/stm32f7-disco/applications/startup.c
deleted file mode 100644
index 628a805042..0000000000
--- a/bsp/stm32f7-disco/applications/startup.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * File : startup.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2015, RT-Thread Development Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Change Logs:
- * Date Author Notes
- * 2006-08-31 Bernard first implementation
- * 2015-08-01 xiaonong modify for STM32F7 version
- */
-
-#include <rthw.h>
-#include <rtthread.h>
-#include "board.h"
-
-#ifdef RT_USING_EXT_SDRAM
-#include "drv_sdram.h"
-#include "sram.h"
-#endif
-
-/**
- * @addtogroup STM32
- */
-
-/*@{*/
-
-extern int rt_application_init(void);
-
-#ifdef USE_FULL_ASSERT
-/**
-* @brief assert_failed
-* Reports the name of the source file and the source line number
-* where the assert_param error has occurred.
-* @param File: pointer to the source file name
-* @param Line: assert_param error line source number
-* @retval None
-*/
-void assert_failed(uint8_t* file, uint32_t line)
-{
- /* User can add his own implementation to report the file name and line
- number,ex: printf("Wrong parameters value: file %s on line %d\r\n",
- file, line) */
- rt_kprintf("\n\r Wrong parameter value detected on\r\n");
- rt_kprintf(" file %s\r\n", file);
- rt_kprintf(" line %d\r\n", line);
-
- /* Infinite loop */
- while (1)
- {}
-}
-#endif
-
-/**
- * This function will startup RT-Thread RTOS.
- */
-void rtthread_startup(void)
-{
- /* init board */
- rt_hw_board_init();
-
- /* show version */
- rt_show_version();
-
- /* init tick */
- rt_system_tick_init();
-
- /* init kernel object */
- rt_system_object_init();
-
- /* init timer system */
- rt_system_timer_init();
-
-#ifdef RT_USING_EXT_SDRAM
- sdram_hw_init();
- rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END);
- sram_init();
-#else
- rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
-#endif
-
- /* init scheduler system */
- rt_system_scheduler_init();
-
- /* init application */
- rt_application_init();
-
- /* init timer thread */
- rt_system_timer_thread_init();
-
- /* init idle thread */
- rt_thread_idle_init();
-
- /* start scheduler */
- rt_system_scheduler_start();
-
- /* never reach here */
- return ;
-}
-
-int main(void)
-{
- /* disable interrupt first */
- rt_hw_interrupt_disable();
-
- /* startup RT-Thread RTOS */
- rtthread_startup();
-
- return 0;
-}
-
-/*@}*/
diff --git a/bsp/stm32f7-disco/drivers/board.c b/bsp/stm32f7-disco/drivers/board.c
index 734ecf2094..0553920a47 100644
--- a/bsp/stm32f7-disco/drivers/board.c
+++ b/bsp/stm32f7-disco/drivers/board.c
@@ -22,13 +22,10 @@
* 2009-01-05 Bernard first implementation
*/
-#include <rthw.h>
#include <rtthread.h>
-#include <components.h>
-
#include "board.h"
-#include "drv_usart.h"
-#include "drv_mpu.h"
+#include "sram.h"
+
/**
* @addtogroup STM32
@@ -70,11 +67,11 @@ static void SystemClock_Config(void)
RCC_OscInitStruct.PLL.PLLN = 400;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 8;
-
+
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
- while(1) { ; }
+ while (1) { ; }
}
ret = HAL_PWREx_EnableOverDrive();
@@ -85,7 +82,8 @@ static void SystemClock_Config(void)
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
clocks dividers */
- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
+ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK |\
+ RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
@@ -167,7 +165,7 @@ void HAL_ResumeTick(void)
void rt_hw_board_init()
{
/* Configure the MPU attributes as Write Through */
- mpu_init();
+ //mpu_init();
/* Enable the CPU Cache */
CPU_CACHE_Enable();
@@ -186,7 +184,16 @@ void rt_hw_board_init()
/* set pend exception priority */
NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
+#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
+#endif
+
+#ifdef RT_USING_EXT_SDRAM
+ rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END);
+ sram_init();
+#else
+ rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
+#endif
#ifdef RT_USING_CONSOLE
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
diff --git a/bsp/stm32f7-disco/drivers/board.h b/bsp/stm32f7-disco/drivers/board.h
index d4aebe06d6..8d1e9f3739 100644
--- a/bsp/stm32f7-disco/drivers/board.h
+++ b/bsp/stm32f7-disco/drivers/board.h
@@ -31,8 +31,8 @@
// <e>Use external SDRAM memory on the board
// <o>Begin Address of External SDRAM
#define EXT_SDRAM_BEGIN 0xC0000000
+// <o>Size of External SDRAM
#define EXT_SDRAM_SIZE (0x800000)
-// <o>End Address of External SDRAM
#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE)
// </e>
diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.c b/bsp/stm32f7-disco/drivers/drv_mpu.c
index 4cab4d2281..630e48e2d2 100644
--- a/bsp/stm32f7-disco/drivers/drv_mpu.c
+++ b/bsp/stm32f7-disco/drivers/drv_mpu.c
@@ -23,9 +23,9 @@
*/
#include "drv_mpu.h"
-
-
-void mpu_init(void)
+#include <rtthread.h>
+#include "stm32f7xx.h"
+int mpu_init(void)
{
MPU_Region_InitTypeDef MPU_InitStruct;
@@ -79,5 +79,6 @@ void mpu_init(void)
/* Enable the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
+ return 0;
}
-
+INIT_BOARD_EXPORT(mpu_init);
diff --git a/bsp/stm32f7-disco/drivers/drv_mpu.h b/bsp/stm32f7-disco/drivers/drv_mpu.h
index 707adfc2ef..9baf74b0d7 100644
--- a/bsp/stm32f7-disco/drivers/drv_mpu.h
+++ b/bsp/stm32f7-disco/drivers/drv_mpu.h
@@ -1,9 +1,9 @@
#ifndef __DRV_MPU_H
#define __DRV_MPU_H
-#include "stm32f7xx.h"
+
/* Initialize Cortex M MPU */
-void mpu_init(void);
+int mpu_init(void);
#endif
diff --git a/bsp/stm32f7-disco/drivers/drv_sdram.c b/bsp/stm32f7-disco/drivers/drv_sdram.c
index 4b58e21d01..303bd3b928 100644
--- a/bsp/stm32f7-disco/drivers/drv_sdram.c
+++ b/bsp/stm32f7-disco/drivers/drv_sdram.c
@@ -362,3 +362,9 @@ void SDRAM_DMA_IRQHandler(void)
{
HAL_DMA_IRQHandler(sdramHandle.hdma);
}
+
+static int rt_sdram_hw_init(void)
+{
+ return (int)sdram_hw_init();
+}
+INIT_BOARD_EXPORT(rt_sdram_hw_init);
diff --git a/bsp/stm32f7-disco/rtconfig.h b/bsp/stm32f7-disco/rtconfig.h
index bd0aaed397..f599858171 100644
--- a/bsp/stm32f7-disco/rtconfig.h
+++ b/bsp/stm32f7-disco/rtconfig.h
@@ -227,4 +227,7 @@
/* enable SDRAM */
#define RT_USING_EXT_SDRAM
+#define RT_USING_COMPONENTS_INIT
+#define RT_USING_USER_MAIN
+
#endif
diff --git a/bsp/stm32f7-disco/rtconfig.py b/bsp/stm32f7-disco/rtconfig.py
index 91ef8db8b3..8fd7dd9094 100644
--- a/bsp/stm32f7-disco/rtconfig.py
+++ b/bsp/stm32f7-disco/rtconfig.py
@@ -45,7 +45,7 @@ if PLATFORM == 'gcc':
STRIP = PREFIX + 'strip'
DEVICE = ' -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections'
- CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED'
+ CFLAGS = DEVICE + ' -g -Wall -DSTM32F756xx -DUSE_HAL_DRIVER -D__ASSEMBLY__ -D__FPU_USED -eentry'
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb '
LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread_stm32f7xx.map,-cref,-u,Reset_Handler -T rtthread-stm32f7xx.ld'