Improve handling of arming, providing LED blink codes if the arming fails.

Also, implement a software watchdog to make sure that the main real-time
modules are actually being run. Provide a panic facility, also giving blink
codes to indicate the panic reason.
This commit is contained in:
2012-09-22 12:08:07 +00:00
parent e36ec4d5b1
commit 999e129e2c
15 changed files with 336 additions and 22 deletions

18
stick.c
View File

@@ -13,6 +13,8 @@
#include "trig.h"
#include "motor.h"
#include "wmp.h"
#include "status.h"
#include "watchdog.h"
#define TWO_PI 6.28318531f
#define PI 3.14159265f
@@ -50,8 +52,6 @@ float stick_yaw = 0.0f;
unsigned int stick_counter;
bool armed = FALSE;
void stick_update(float x, float y, float z)
{
float tz = delta_t * z;
@@ -85,18 +85,17 @@ void stick_input(void) {
throttle = timer_input(2);
z = timer_input(3);
if (!armed) {
if (!status_armed()) {
if ((throttle < MIN_THR) &&
(x > (CENTRE_X - CENTRE_ZONE)) &&
(x < (CENTRE_X + CENTRE_ZONE)) &&
(y > (CENTRE_Y - CENTRE_ZONE)) &&
(y < (CENTRE_Y + CENTRE_ZONE)) &&
(z > (CENTRE_Z - CENTRE_ZONE)) &&
(z < (CENTRE_Z + CENTRE_ZONE)) &&
(wmp_zero == FALSE)) {
putstr("ARMED!!!\r\n");
armed = TRUE;
}
(z < (CENTRE_Z + CENTRE_ZONE)))
status_set_ready(STATUS_MODULE_STICK, TRUE);
else
status_set_ready(STATUS_MODULE_STICK,FALSE);
}
@@ -114,10 +113,13 @@ void stick_input(void) {
y = 0.0f;
z = 0.0f;
throttle = 0.0f;
status_set_ready(STATUS_MODULE_STICK,FALSE);
}
motor_set_throttle(throttle);
watchdog_kick(WATCHDOG_STICK);
/* So the controls are back to front. Let's fix that. */
x = -x;
y = -y;