[bsp][stm32f746-Disco] Cleanup code
1. Using RT_USING_COMPONENTS_INIT and RT_USING_USER_MAIN 2. Cleanup code
This commit is contained in:
parent
b4e3fb2007
commit
090153f94f
|
@ -24,14 +24,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <components.h>
|
|
||||||
|
|
||||||
void rt_init_thread_entry(void *parameter)
|
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;
|
rt_thread_t tid;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@}*/
|
|
|
@ -22,13 +22,10 @@
|
||||||
* 2009-01-05 Bernard first implementation
|
* 2009-01-05 Bernard first implementation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rthw.h>
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include <components.h>
|
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "drv_usart.h"
|
#include "sram.h"
|
||||||
#include "drv_mpu.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @addtogroup STM32
|
* @addtogroup STM32
|
||||||
|
@ -74,7 +71,7 @@ static void SystemClock_Config(void)
|
||||||
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||||
if(ret != HAL_OK)
|
if(ret != HAL_OK)
|
||||||
{
|
{
|
||||||
while(1) { ; }
|
while (1) { ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = HAL_PWREx_EnableOverDrive();
|
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
|
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||||
clocks dividers */
|
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.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||||
|
@ -167,7 +165,7 @@ void HAL_ResumeTick(void)
|
||||||
void rt_hw_board_init()
|
void rt_hw_board_init()
|
||||||
{
|
{
|
||||||
/* Configure the MPU attributes as Write Through */
|
/* Configure the MPU attributes as Write Through */
|
||||||
mpu_init();
|
//mpu_init();
|
||||||
|
|
||||||
/* Enable the CPU Cache */
|
/* Enable the CPU Cache */
|
||||||
CPU_CACHE_Enable();
|
CPU_CACHE_Enable();
|
||||||
|
@ -186,7 +184,16 @@ void rt_hw_board_init()
|
||||||
/* set pend exception priority */
|
/* set pend exception priority */
|
||||||
NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
|
NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
|
||||||
|
|
||||||
|
#ifdef RT_USING_COMPONENTS_INIT
|
||||||
rt_components_board_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
|
#ifdef RT_USING_CONSOLE
|
||||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
// <e>Use external SDRAM memory on the board
|
// <e>Use external SDRAM memory on the board
|
||||||
// <o>Begin Address of External SDRAM
|
// <o>Begin Address of External SDRAM
|
||||||
#define EXT_SDRAM_BEGIN 0xC0000000
|
#define EXT_SDRAM_BEGIN 0xC0000000
|
||||||
|
// <o>Size of External SDRAM
|
||||||
#define EXT_SDRAM_SIZE (0x800000)
|
#define EXT_SDRAM_SIZE (0x800000)
|
||||||
// <o>End Address of External SDRAM
|
|
||||||
#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE)
|
#define EXT_SDRAM_END (EXT_SDRAM_BEGIN + EXT_SDRAM_SIZE)
|
||||||
// </e>
|
// </e>
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "drv_mpu.h"
|
#include "drv_mpu.h"
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include "stm32f7xx.h"
|
||||||
void mpu_init(void)
|
int mpu_init(void)
|
||||||
{
|
{
|
||||||
MPU_Region_InitTypeDef MPU_InitStruct;
|
MPU_Region_InitTypeDef MPU_InitStruct;
|
||||||
|
|
||||||
|
@ -79,5 +79,6 @@ void mpu_init(void)
|
||||||
|
|
||||||
/* Enable the MPU */
|
/* Enable the MPU */
|
||||||
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
|
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
INIT_BOARD_EXPORT(mpu_init);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#ifndef __DRV_MPU_H
|
#ifndef __DRV_MPU_H
|
||||||
#define __DRV_MPU_H
|
#define __DRV_MPU_H
|
||||||
#include "stm32f7xx.h"
|
|
||||||
|
|
||||||
/* Initialize Cortex M MPU */
|
/* Initialize Cortex M MPU */
|
||||||
void mpu_init(void);
|
int mpu_init(void);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -362,3 +362,9 @@ void SDRAM_DMA_IRQHandler(void)
|
||||||
{
|
{
|
||||||
HAL_DMA_IRQHandler(sdramHandle.hdma);
|
HAL_DMA_IRQHandler(sdramHandle.hdma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rt_sdram_hw_init(void)
|
||||||
|
{
|
||||||
|
return (int)sdram_hw_init();
|
||||||
|
}
|
||||||
|
INIT_BOARD_EXPORT(rt_sdram_hw_init);
|
||||||
|
|
|
@ -227,4 +227,7 @@
|
||||||
/* enable SDRAM */
|
/* enable SDRAM */
|
||||||
#define RT_USING_EXT_SDRAM
|
#define RT_USING_EXT_SDRAM
|
||||||
|
|
||||||
|
#define RT_USING_COMPONENTS_INIT
|
||||||
|
#define RT_USING_USER_MAIN
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,7 +45,7 @@ if PLATFORM == 'gcc':
|
||||||
STRIP = PREFIX + 'strip'
|
STRIP = PREFIX + 'strip'
|
||||||
|
|
||||||
DEVICE = ' -mcpu=cortex-m7 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -ffunction-sections -fdata-sections'
|
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 '
|
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'
|
LFLAGS = DEVICE + ' -lm -lgcc -lc' + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread_stm32f7xx.map,-cref,-u,Reset_Handler -T rtthread-stm32f7xx.ld'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue