diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-04-16 02:59:55 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2011-04-16 02:59:55 +0200 |
commit | 286cecb2bf08c5538cfe13053246b0d8b78b2df4 (patch) | |
tree | 7ab7a2c5316e5440385481cb46e0e446f5e5e0e0 /main.cpp | |
parent | 944a03b280df083800c8aea9b206de0c6539e14a (diff) |
Test ppmsum decoding.
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -170,12 +170,44 @@ static PWMConfig pwmcfg = { 0
};
+icucnt_t last_width, last_period;
+
+int16_t ppm_input[4];
+
+int ppm_n = 0;
+
+static void icuwidthcb(ICUDriver *icup) {
+
+ last_width = icuGetWidthI(icup);
+ ppm_input[ppm_n] = last_width;
+}
+
+static void icuperiodcb(ICUDriver *icup) {
+
+ last_period = icuGetPeriodI(icup);
+ if(last_period > 5000) {
+ ppm_n = 0;
+ } else {
+ ppm_n = (ppm_n + 1) % 4;
+ }
+}
+
+static ICUConfig icucfg = {
+ ICU_INPUT_ACTIVE_HIGH,
+ 1000000,
+ icuwidthcb,
+ icuperiodcb
+};
+
int main(void) {
halInit();
chSysInit();
led_thread.start();
+ icuStart(&ICUD4, &icucfg);
+ icuEnable(&ICUD4);
+
usbs.init();
i2c_thread.start();
|