The unified diff between revisions [23a3e9a5..] and [81e4dce2..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'main.c'

#
# old_revision [23a3e9a50b4034343e3bd217d2c225dcaec064dd]
# new_revision [81e4dce274e79dd9187ed4bd182e1d6fc0fdfb37]
#
# patch "main.c"
#  from [e1a823b4962f3e8dc43b519a1f57745854ae6689]
#    to [b366dce1bedfd103e47161ada956b8569816f2f4]
#
============================================================
--- main.c	e1a823b4962f3e8dc43b519a1f57745854ae6689
+++ main.c	b366dce1bedfd103e47161ada956b8569816f2f4
@@ -1,3 +1,4 @@
+/* main.c */
 
 #include "wmp.h"
 #include "i2c.h"
@@ -5,8 +6,10 @@
 #include "uart.h"
 #include "interrupt.h"
 #include "event.h"
+#include "stick.h"
 
-#define PINSEL0 (*((volatile unsigned char *) 0xE002C000))
+#define PINSEL0 (*((volatile unsigned int *) 0xE002C000))
+#define PINSEL1 (*((volatile unsigned int *) 0xE002C004))
 #define FP0XDIR (*((volatile unsigned int *) 0x3FFFC000))
 #define FP0XVAL (*((volatile unsigned int *) 0x3FFFC014))
 
@@ -15,18 +18,26 @@ void init_pins(void)
 
 void init_pins(void)
 {
-	PINSEL0 = 0x00000055; /* P0.0 and P0.1 assigned to UART */
+	PINSEL0 = 0x00a88055; /* P0.0 and P0.1 assigned to UART */
 			      /* P0.2 and P0.3 assigned to I2C  */
+	                      /* P0.7 and P0.9 assigned to MAT2.[02] */
+	                      /* P0.10 and P0.11 assigned to CAP1.[01] */
+	PINSEL1 = 0x20000828; /* P0.21 and P0.30 assigned to MAT3.[03] */
+	                      /* P0.17 and P0.18 assigned to CAP1.[23] */
 	SCS = 1;
 	FP0XDIR = 0x04000000; /* P0.26 is an output */
 	FP0XVAL = 0x0;
 }
 
+#ifdef USE_UART
 void reply(char *str)
 {
 	putstr(str);
 	putstr("\r\n");
 }
+#else
+#define reply(x) ((void)0)
+#endif
 
 unsigned int count = 0;
 
@@ -167,6 +178,8 @@ int main(void) {
 void menu_handler(void);
 
 int main(void) {
+	armed = FALSE;
+
 	init_interrupt();
 	init_uart();
 	init_i2c();
@@ -183,6 +196,21 @@ int main(void) {
 
 	putstr("prompt> ");
 
+	FP0XVAL &= ~0x04000000;
+	timer_delay_ms(1000);
+	FP0XVAL |= 0x04000000;
+	timer_delay_ms(1000);
+	FP0XVAL &= ~0x04000000;
+	if (!wmp_init())
+		putstr("WMP initialisation failed\r\n");
+
+	/* Flight is potentially live after this. */
+	timer_set_period(5*TIMER_MS);
+	wmp_start_zero();
+
+	FP0XVAL |= 0x04000000;
+
+	/* Good luck! */
 	while (1) {
 		FP0XVAL ^= 0x04000000;
 		event_dispatch();
@@ -197,6 +225,9 @@ void menu_handler(void)
 	char c;
 
 	while (getch(&c)) {
+#if 1
+		continue; /* Yes, let's just ignore UART input now. */
+#endif
 		if (c == 0x0a)
 			continue;
 		putch(c);
@@ -283,6 +314,58 @@ void menu_handler(void)
 			reply("done");
 			wmp_start_zero();
 			break;
+		case 'W':
+			for (i = 0; i < 4; i++) {
+				putstr("Width ");
+				putint(i);
+				putstr(": ");
+				putint(timer_input(i));
+				if (!timer_valid(i))
+					putstr(" (invalid)");
+				putstr("\r\n");
+			}
+			if (!timer_allvalid()) {
+				putstr("ALL INVALID!\r\n");
+			}
+			break;
+		case '0' & 0xdf:
+			timer_set_pwm_value(0, 0);
+			timer_set_pwm_value(1, 0);
+			timer_set_pwm_value(2, 0);
+			timer_set_pwm_value(3, 0);
+			break;
+#if 0
+		case '1' & 0xdf:
+			timer_set_pwm_value(0, PWM_MAX/2);
+			break;
+		case '2' & 0xdf:
+			timer_set_pwm_value(1, PWM_MAX/2);
+			break;
+		case '3' & 0xdf:
+			timer_set_pwm_value(2, PWM_MAX/2);
+			break;
+		case '4' & 0xdf:
+			timer_set_pwm_value(3, PWM_MAX/2);
+			break;
+		case '5' & 0xdf:
+			timer_set_pwm_value(0, PWM_MAX);
+			break;
+		case '6' & 0xdf:
+			timer_set_pwm_value(1, PWM_MAX);
+			break;
+		case '7' & 0xdf:
+			timer_set_pwm_value(2, PWM_MAX);
+			break;
+		case '8' & 0xdf:
+			timer_set_pwm_value(3, PWM_MAX);
+			break;
+#endif
+		case '9' & 0xdf:
+			timer_set_pwm_invalid(0);
+			timer_set_pwm_invalid(1);
+			timer_set_pwm_invalid(2);
+			timer_set_pwm_invalid(3);
+			break;
 		default:
 			reply("Unrecognised command.");
 			break;