1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

LP-97 - Fixes for Osd and discoveryf4bare

This commit is contained in:
Alessio Morale 2015-08-19 14:56:59 +02:00 committed by a*morale
parent 06f59d2c40
commit 970ae3df00
4 changed files with 91 additions and 288 deletions

View File

@ -34,46 +34,12 @@
extern "C" {
#include "inc/openpilot.h"
#include <uavobjectsinit.h>
#include <systemmod.h>
/* Task Priorities */
#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3)
/* Global Variables */
/* Local Variables */
#define INCLUDE_TEST_TASKS 0
#if INCLUDE_TEST_TASKS
static uint8_t sdcard_available;
#endif
char Buffer[1024];
uint32_t Cache;
/* Function Prototypes */
#if INCLUDE_TEST_TASKS
static void TaskTick(void *pvParameters);
static void TaskTesting(void *pvParameters);
static void TaskHIDTest(void *pvParameters);
static void TaskServos(void *pvParameters);
static void TaskSDCard(void *pvParameters);
#endif
int32_t CONSOLE_Parse(uint8_t port, char c);
void OP_ADC_NotifyChange(uint32_t pin, uint32_t pin_value);
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void Stack_Change(void);
static void Stack_Change_Weak() __attribute__((weakref("Stack_Change")));
/* Local Variables */
#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority
#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive
static xTaskHandle initTaskHandle;
/* Function Prototypes */
static void initTask(void *parameters);
/* Prototype of generated InitModules() function */
extern void InitModules(void);
}
/**
@ -87,8 +53,6 @@ extern void InitModules(void);
*/
int main()
{
int result;
/* NOTE: Do NOT modify the following start-up sequence */
/* Any new initialization functions should be added in OpenPilotInit() */
vPortInitialiseBlocks();
@ -96,12 +60,7 @@ int main()
/* Brings up System using CMSIS functions, enables the LEDs. */
PIOS_SYS_Init();
/* For Revolution we use a FreeRTOS task to bring up the system so we can */
/* always rely on FreeRTOS primitive */
result = xTaskCreate(initTask, "init",
INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY,
&initTaskHandle);
PIOS_Assert(result == pdPASS);
SystemModStart();
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
@ -117,22 +76,7 @@ int main()
return 0;
}
/**
* Initialisation task.
*
* Runs board and module initialisation, then terminates.
*/
void initTask(__attribute__((unused)) void *parameters)
{
/* board driver init */
PIOS_Board_Init();
/* Initialize modules */
MODULE_INITIALISE_ALL;
/* terminate this task */
vTaskDelete(NULL);
}
/**
* @}

View File

@ -24,6 +24,9 @@ endif
include ../board-info.mk
include $(ROOT_DIR)/make/firmware-defs.mk
# REVO C++ support
USE_CXX = YES
# ARM DSP library
override USE_DSP_LIB := NO
@ -52,7 +55,7 @@ ifndef TESTAPP
## Application Core
SRC += ../pios_usb_board_data.c
SRC += $(OPMODULEDIR)/System/systemmod.c
SRC += $(OPSYSTEM)/osd.c
CPPSRC += $(OPSYSTEM)/osd.cpp
SRC += $(OPSYSTEM)/pios_board.c
SRC += $(FLIGHTLIB)/alarms.c
SRC += $(OPUAVTALK)/uavtalk.c

View File

@ -1,229 +0,0 @@
/**
******************************************************************************
*
* @file main.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Main modem functions
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// *****************************************************************************
// #define USE_WATCHDOG // comment this out if you don't want to use the watchdog
// *****************************************************************************
#include "inc/openpilot.h"
#include <string.h>
/* Task Priorities */
#define PRIORITY_TASK_HOOKS (tskIDLE_PRIORITY + 3)
/* Global Variables */
/* Prototype of PIOS_Board_Init() function */
extern void PIOS_Board_Init(void);
extern void Stack_Change(void);
static void Stack_Change_Weak() __attribute__((weakref("Stack_Change")));
/* Function Prototypes */
static void initTask(void *parameters);
/* Local Variables */
#define INIT_TASK_PRIORITY (tskIDLE_PRIORITY + configMAX_PRIORITIES - 1) // max priority
#define INIT_TASK_STACK (1024 / 4) // XXX this seems excessive
static xTaskHandle initTaskHandle;
// *****************************************************************************
// Global Variables
// *****************************************************************************
// Local Variables
#if defined(USE_WATCHDOG)
volatile uint16_t watchdog_timer;
uint16_t watchdog_delay;
#endif
// *****************************************************************************
#if defined(USE_WATCHDOG)
void processWatchdog(void)
{
// random32 = UpdateCRC32(random32, IWDG->SR);
if (watchdog_timer < watchdog_delay) {
return;
}
// the watchdog needs resetting
watchdog_timer = 0;
watchdog_Clear();
}
void enableWatchdog(void)
{ // enable a watchdog
watchdog_timer = 0;
watchdog_delay = watchdog_Init(1000); // 1 second watchdog timeout
}
#endif /* if defined(USE_WATCHDOG) */
// *****************************************************************************
void sequenceLEDs(void)
{
for (int i = 0; i < 2; i++) {
// USB_LED_ON;
PIOS_DELAY_WaitmS(100);
// USB_LED_OFF;
PIOS_DELAY_WaitmS(100);
#if defined(USE_WATCHDOG)
processWatchdog(); // process the watchdog
#endif
}
}
// *****************************************************************************
// find out what caused our reset and act on it
void processReset(void)
{
if (RCC_GetFlagStatus(RCC_FLAG_IWDGRST) != RESET) { // Independant Watchdog Reset
#if defined(PIOS_COM_DEBUG_CONSOLE)
DEBUG_PRINTF(0, "\r\nINDEPENDANT WATCHDOG CAUSED A RESET\r\n");
#endif
// all led's ON
// USB_LED_ON;
PIOS_DELAY_WaitmS(500); // delay a bit
// all led's OFF
// USB_LED_OFF;
}
/*
if (RCC_GetFlagStatus(RCC_FLAG_WWDGRST) != RESET)
{ // Window Watchdog Reset
DEBUG_PRINTF(0, "\r\nWINDOW WATCHDOG CAUSED A REBOOT\r\n");
// all led's ON
USB_LED_ON;
LINK_LED_ON;
RX_LED_ON;
TX_LED_ON;
PIOS_DELAY_WaitmS(500); // delay a bit
// all led's OFF
USB_LED_OFF;
LINK_LED_OFF;
RX_LED_OFF;
TX_LED_OFF;
}
*/
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { // Power-On Reset
#if defined(PIOS_COM_DEBUG)
DEBUG_PRINTF(0, "\r\nPOWER-ON-RESET\r\n");
#endif
}
if (RCC_GetFlagStatus(RCC_FLAG_SFTRST) != RESET) { // Software Reset
#if defined(PIOS_COM_DEBUG)
DEBUG_PRINTF(0, "\r\nSOFTWARE RESET\r\n");
#endif
}
if (RCC_GetFlagStatus(RCC_FLAG_LPWRRST) != RESET) { // Low-Power Reset
#if defined(PIOS_COM_DEBUG)
DEBUG_PRINTF(0, "\r\nLOW POWER RESET\r\n");
#endif
}
if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { // Pin Reset
#if defined(PIOS_COM_DEBUG)
DEBUG_PRINTF("0, \r\nPIN RESET\r\n");
#endif
}
// Clear reset flags
// RCC_ClearFlag();
}
int main()
{
int result;
// *************
// init various variables
// *************
/* NOTE: Do NOT modify the following start-up sequence */
/* Any new initialization functions should be added in OpenPilotInit() */
vPortInitialiseBlocks();
// Bring up System using CMSIS functions, enables the LEDs.
PIOS_SYS_Init();
/* For Revolution we use a FreeRTOS task to bring up the system so we can */
/* always rely on FreeRTOS primitive */
result = xTaskCreate(initTask, "init",
INIT_TASK_STACK, NULL, INIT_TASK_PRIORITY,
&initTaskHandle);
PIOS_Assert(result == pdPASS);
/* Start the FreeRTOS scheduler which should never returns.*/
vTaskStartScheduler();
/* If all is well we will never reach here as the scheduler will now be running. */
/* Do some indication to user that something bad just happened */
PIOS_LED_Off(PIOS_LED_HEARTBEAT); \
for (;;) { \
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \
PIOS_DELAY_WaitmS(100); \
}
;
return 0;
}
/**
* Initialisation task.
*
* Runs board and module initialisation, then terminates.
*/
void initTask(__attribute__((unused)) void *parameters)
{
/* board driver init */
PIOS_Board_Init();
/* Initialize modules */
MODULE_INITIALISE_ALL;
/* terminate this task */
vTaskDelete(NULL);
}
// *****************************************************************************

View File

@ -0,0 +1,85 @@
/**
******************************************************************************
* @addtogroup LibrePilotSystem LibrePilot System
* @brief These files are the core system files for Revolution.
* They are the ground layer just above PiOS. In practice, OSD actually starts
* in the main() function of osd.c
* @{
* @addtogroup LibrePilotCore LibrePilot Core
* @brief This is where the LP firmware starts. Those files also define the compile-time
* options of the firmware.
* @{
* @file osd.c
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2015
* @brief Sets up and runs main tasks.
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* 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, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
extern "C" {
#include "inc/openpilot.h"
#include <uavobjectsinit.h>
#include <systemmod.h>
/* Global Variables */
/* Local Variables */
}
/**
* OpenPilot Main function:
*
* Initialize PiOS<BR>
* Create the "System" task (SystemModInitializein Modules/System/systemmod.c) <BR>
* Start FreeRTOS Scheduler (vTaskStartScheduler)<BR>
* If something goes wrong, blink LED1 and LED2 every 100ms
*
*/
int main()
{
/* NOTE: Do NOT modify the following start-up sequence */
/* Any new initialization functions should be added in OpenPilotInit() */
vPortInitialiseBlocks();
/* Brings up System using CMSIS functions, enables the LEDs. */
PIOS_SYS_Init();
SystemModStart();
/* Start the FreeRTOS scheduler */
vTaskStartScheduler();
/* If all is well we will never reach here as the scheduler will now be running. */
/* Do some PIOS_LED_HEARTBEAT to user that something bad just happened */
PIOS_LED_Off(PIOS_LED_HEARTBEAT); \
for (;;) { \
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT); \
PIOS_DELAY_WaitmS(100); \
}
;
return 0;
}
/**
* @}
* @}
*/