Merge pull request #553 from ArdaFu/master

[bsp][stm32f746-Disco] Cleanup code
This commit is contained in:
Bernard Xiong 2015-09-26 11:36:12 +08:00
commit 741346e31a
9 changed files with 37 additions and 145 deletions

View File

@ -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;

View File

@ -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;
}
/*@}*/

View File

@ -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);

View File

@ -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>

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -227,4 +227,7 @@
/* enable SDRAM */
#define RT_USING_EXT_SDRAM
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#endif

View File

@ -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'