kopia lustrzana https://github.com/OpenRTX/OpenRTX
Moved bootstrap code into a dedicated file to improve readability
rodzic
7ff11ff5a3
commit
00d726ddbc
|
@ -79,6 +79,7 @@ endif
|
|||
|
||||
## TYT MD380
|
||||
md380_src = src + ['openrtx/src/main.c',
|
||||
'openrtx/src/bootstrap.c',
|
||||
'platform/mcu/STM32F4xx/boot/startup.c',
|
||||
'platform/mcu/STM32F4xx/boot/libc_integration.c',
|
||||
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2020 by Federico Izzo IU2NUO, Niccolò Izzo IU2KIN and *
|
||||
* Silvano Seva IU2KWO *
|
||||
* *
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/> *
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <app_cfg.h>
|
||||
#include <os.h>
|
||||
#include <lib_mem.h>
|
||||
#include "stm32f4xx.h"
|
||||
#include "platform.h"
|
||||
#include "gpio.h"
|
||||
|
||||
/*
|
||||
* Entry point for application code, not in this translation unit.
|
||||
*/
|
||||
int main(int argc, char *argv[]);
|
||||
|
||||
/*
|
||||
* OS startup task, will call main() when all initialisations are done.
|
||||
*/
|
||||
static OS_TCB startTCB;
|
||||
static CPU_STK_SIZE startStk[APP_CFG_TASK_START_STK_SIZE];
|
||||
static void startTask(void *arg);
|
||||
|
||||
void systemBootstrap()
|
||||
{
|
||||
OS_ERR err;
|
||||
|
||||
OSInit(&err);
|
||||
|
||||
OSTaskCreate((OS_TCB *)&startTCB,
|
||||
(CPU_CHAR *)" ",
|
||||
(OS_TASK_PTR ) startTask,
|
||||
(void *) 0,
|
||||
(OS_PRIO ) APP_CFG_TASK_START_PRIO,
|
||||
(CPU_STK *)&startStk[0],
|
||||
(CPU_STK )startStk[APP_CFG_TASK_START_STK_SIZE / 10u],
|
||||
(CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE,
|
||||
(OS_MSG_QTY ) 0,
|
||||
(OS_TICK ) 0,
|
||||
(void *) 0,
|
||||
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
|
||||
(OS_ERR *)&err);
|
||||
|
||||
OSStart(&err);
|
||||
|
||||
for(;;) ;
|
||||
}
|
||||
|
||||
static void startTask(void* arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
CPU_Init();
|
||||
|
||||
/* SysTick is available only for ARM-based targets */
|
||||
#ifdef __arm__
|
||||
OS_CPU_SysTickInitFreq(SystemCoreClock);
|
||||
#endif
|
||||
|
||||
/* Initialise platform drivers */
|
||||
platform_init();
|
||||
|
||||
/* Jump to application code */
|
||||
main(0, NULL);
|
||||
|
||||
/* If main returns loop indefinitely */
|
||||
for(;;) ;
|
||||
}
|
|
@ -19,93 +19,29 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <app_cfg.h>
|
||||
#include <os.h>
|
||||
#include <lib_mem.h>
|
||||
#include <stdio.h>
|
||||
#include "gpio.h"
|
||||
#include "delays.h"
|
||||
#include "display.h"
|
||||
#include "graphics.h"
|
||||
|
||||
static OS_TCB startTCB;
|
||||
static CPU_STK_SIZE startStk[APP_CFG_TASK_START_STK_SIZE];
|
||||
static void startTask(void *arg);
|
||||
|
||||
static OS_TCB uiTaskTCB;
|
||||
static CPU_STK_SIZE uiTaskStk[128];
|
||||
static void uiTask(void *arg);
|
||||
#include "hwconfig.h"
|
||||
#include "platform.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
OS_ERR err;
|
||||
|
||||
OSInit(&err);
|
||||
|
||||
OSTaskCreate((OS_TCB *)&startTCB,
|
||||
(CPU_CHAR *)" ",
|
||||
(OS_TASK_PTR ) startTask,
|
||||
(void *) 0,
|
||||
(OS_PRIO ) APP_CFG_TASK_START_PRIO,
|
||||
(CPU_STK *)&startStk[0],
|
||||
(CPU_STK )startStk[APP_CFG_TASK_START_STK_SIZE / 10u],
|
||||
(CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE,
|
||||
(OS_MSG_QTY ) 0,
|
||||
(OS_TICK ) 0,
|
||||
(void *) 0,
|
||||
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
|
||||
(OS_ERR *)&err);
|
||||
|
||||
OSStart(&err);
|
||||
|
||||
for(;;) ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void startTask(void* arg)
|
||||
{
|
||||
|
||||
(void) arg;
|
||||
OS_ERR err;
|
||||
|
||||
gpio_setMode(GPIOE, 0, OUTPUT);
|
||||
gpio_setMode(GPIOE, 1, OUTPUT);
|
||||
|
||||
CPU_Init();
|
||||
OS_CPU_SysTickInitFreq(SystemCoreClock);
|
||||
|
||||
OSTaskCreate((OS_TCB *)&uiTaskTCB,
|
||||
(CPU_CHAR *)" ",
|
||||
(OS_TASK_PTR ) uiTask,
|
||||
(void *) 0,
|
||||
(OS_PRIO ) 5,
|
||||
(CPU_STK *)&uiTaskStk[0],
|
||||
(CPU_STK ) 0,
|
||||
(CPU_STK_SIZE) 128,
|
||||
(OS_MSG_QTY ) 0,
|
||||
(OS_TICK ) 0,
|
||||
(void *) 0,
|
||||
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
|
||||
(OS_ERR *)&err);
|
||||
|
||||
while(1) ;
|
||||
}
|
||||
|
||||
static void uiTask(void *arg)
|
||||
{
|
||||
(void) arg;
|
||||
OS_ERR os_err;
|
||||
|
||||
// Init the graphic stack
|
||||
gfx_init();
|
||||
gfx_setBacklightLevel(255);
|
||||
platform_setBacklightLevel(255);
|
||||
|
||||
point_t origin = {0, SCREEN_HEIGHT / 2};
|
||||
color_t color_yellow = {250, 180, 19};
|
||||
char *buffer = "OpenRTX";
|
||||
|
||||
OS_ERR os_err;
|
||||
|
||||
// Task infinite loop
|
||||
while(DEF_ON)
|
||||
while(1)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
gfx_print(origin, buffer, FONT_SIZE_4, TEXT_ALIGN_CENTER, color_yellow);
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#include "stm32f4xx.h"
|
||||
#include "../drivers/usb_vcom.h"
|
||||
|
||||
///< Entry point for application code
|
||||
int main(int argc, char *argv[]);
|
||||
///< Entry point for system bootstrap after initial configurations.
|
||||
void systemBootstrap();
|
||||
|
||||
void Reset_Handler() __attribute__((__interrupt__, noreturn));
|
||||
void Reset_Handler()
|
||||
|
@ -84,11 +84,11 @@ void Reset_Handler()
|
|||
// correctly
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
|
||||
|
||||
// Jump to application code
|
||||
main(0, NULL);
|
||||
systemBootstrap();
|
||||
|
||||
// If main returns loop indefinitely
|
||||
// Execution flow should never reach this point but, in any case, loop
|
||||
// indefinitely it this happens
|
||||
for(;;) ;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue