1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

OP-200 Flight/Watchdog: Have flag that is set from actuator, ahrs_comms, manual

and stabilization that is monitored by watchdog.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2078 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-11-05 14:28:21 +00:00 committed by peabody124
parent c5ff7ca5a8
commit 834eecfc1f
7 changed files with 65 additions and 11 deletions

View File

@ -51,7 +51,6 @@
*/
#include "ahrs_comms.h"
#include "ahrs_spi_comm.h"
// Private constants
@ -66,6 +65,9 @@ static xTaskHandle taskHandle;
// Private functions
static void ahrscommsTask(void *parameters);
// Global update flag
volatile uint8_t ahrs_updated;
/**
* Initialise the module, called on startup
* \returns 0 on success or -1 if initialisation failed
@ -91,6 +93,8 @@ static void ahrscommsTask(void *parameters)
// Main task loop
while (1) {
ahrs_updated = 1;
AHRSSettingsData settings;
AHRSSettingsGet(&settings);

View File

@ -70,6 +70,8 @@ float ProcessMixer(const int index, const float curve1, const float curve2,
MixerSettingsData* mixerSettings, ActuatorDesiredData* desired,
const float period);
// External watchdog update flag
volatile uint8_t actuator_updated;
//this structure is equivalent to the UAVObjects for one mixer.
typedef struct {
@ -125,7 +127,7 @@ static void actuatorTask(void* parameters)
ActuatorDesiredData desired;
MixerStatusData mixerStatus;
ManualControlCommandData manualControl;
ActuatorSettingsGet(&settings);
// Set servo update frequency (done only on start-up)
PIOS_Servo_SetHz(settings.ChannelUpdateFreq[0], settings.ChannelUpdateFreq[1]);
@ -145,6 +147,8 @@ static void actuatorTask(void* parameters)
setFailsafe();
continue;
}
actuator_updated = 1;
// Check how long since last update
thisSysTime = xTaskGetTickCount();

View File

@ -64,6 +64,9 @@ static void manualControlTask(void *parameters);
static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutral);
static uint32_t timeDifferenceMs(portTickType start_time, portTickType end_time);
// Global updated variable
volatile uint8_t manual_updated;
/**
* Module initialization
*/
@ -107,6 +110,8 @@ static void manualControlTask(void *parameters)
// Wait until next update
vTaskDelayUntil(&lastSysTime, UPDATE_PERIOD_MS / portTICK_RATE_MS);
manual_updated = 1;
// Read settings
ManualControlSettingsGet(&settings);
StabilizationSettingsGet(&stabSettings);

View File

@ -43,7 +43,6 @@
#include "systemsettings.h"
#include "ahrssettings.h"
// Private constants
#define MAX_QUEUE_SIZE 2
#define STACK_SIZE configMINIMAL_STACK_SIZE
@ -72,8 +71,6 @@ static xQueueHandle queue;
float dT = 1;
pid_type pids[PID_MAX];
// Private functions
static void stabilizationTask(void* parameters);
static float ApplyPid(pid_type * pid, const float desired, const float actual, const uint8_t angular);
@ -81,6 +78,9 @@ static float bound(float val);
static void ZeroPids(void);
static void SettingsUpdatedCb(UAVObjEvent * ev);
// Global updated variable
volatile uint8_t stabilization_updated;
/**
* Module initialization
*/
@ -132,6 +132,8 @@ static void stabilizationTask(void* parameters)
{
AlarmsSet(SYSTEMALARMS_ALARM_STABILIZATION,SYSTEMALARMS_ALARM_WARNING);
}
stabilization_updated = 1;
// Check how long since last update
thisSysTime = xTaskGetTickCount();

View File

@ -44,6 +44,7 @@
#include "manualcontrolcommand.h"
#include "systemstats.h"
// Private constants
#define SYSTEM_UPDATE_PERIOD_MS 1000
#define IDLE_COUNTS_PER_SEC_AT_NO_LOAD 995998 // calibrated by running tests/test_cpuload.c

View File

@ -1,8 +1,33 @@
/**
******************************************************************************
*
* @file watchdog.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Watchdog module which must run every 250 ms
*
* @see The GNU Public License (GPL) Version 3
*
*****************************************************************************/
/*
* watchdog.h
* OpenPilotOSX
* 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.
*
* Created by James Cotton on 8/10/10.
* Copyright 2010 OpenPilot. All rights reserved.
* 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
*/
#ifndef WATCHDOG_H
#define WATCHDOG_H
extern volatile uint8_t actuator_updated;
extern volatile uint8_t stabilization_updated;
extern volatile uint8_t ahrs_updated;
extern volatile uint8_t manual_updated;
#endif /* WATCHDOG_H */

View File

@ -34,8 +34,8 @@
*/
#include "openpilot.h"
#include "watchdog.h"
#include "pios_wdg.h"
#include "watchdog.h"
// Private constants
// TODO: Look up maximum task priority and set this to it. Not trying to replicate CPU load.
@ -51,12 +51,18 @@ static xTaskHandle taskHandle;
// Private functions
static void watchdogTask(void *parameters);
/**
* Initialise the module, called on startup
* \returns 0 on success or -1 if initialisation failed
*/
int32_t WatchdogInitialize()
{
actuator_updated = 0;
stabilization_updated = 0;
ahrs_updated = 0;
manual_updated = 0;
// Start main task
xTaskCreate(watchdogTask, (signed char *)"Watchdog", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
@ -78,7 +84,14 @@ static void watchdogTask(void *parameters)
// Main task loop
lastSysTime = xTaskGetTickCount();
while (1) {
PIOS_WDG_Clear();
if(actuator_updated && stabilization_updated &&
ahrs_updated && manual_updated) {
PIOS_WDG_Clear();
actuator_updated = 0;
stabilization_updated = 0;
ahrs_updated = 0;
manual_updated = 0;
}
vTaskDelayUntil(&lastSysTime, delay);
}