summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-04-16 02:59:55 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-04-16 02:59:55 +0200
commit286cecb2bf08c5538cfe13053246b0d8b78b2df4 (patch)
tree7ab7a2c5316e5440385481cb46e0e446f5e5e0e0
parent944a03b280df083800c8aea9b206de0c6539e14a (diff)
Test ppmsum decoding.
-rw-r--r--board.h2
-rw-r--r--halconf.h2
-rw-r--r--main.cpp32
-rw-r--r--mcuconf.h14
4 files changed, 49 insertions, 1 deletions
diff --git a/board.h b/board.h
index c0b01d0..9034d20 100644
--- a/board.h
+++ b/board.h
@@ -47,7 +47,7 @@
* PB14 - Normal input (MMC SPI2 MISO).
* PB15 - Alternate output (MMC SPI2 MOSI).
*/
-#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */
+#define VAL_GPIOBCRL 0x84888888 /* PB7...PB0 */
#define VAL_GPIOBCRH 0xB4B84488 /* PB15...PB8 */
#define VAL_GPIOBODR 0xFFFFFFFF
diff --git a/halconf.h b/halconf.h
index d10e1fe..1b0e3dd 100644
--- a/halconf.h
+++ b/halconf.h
@@ -69,6 +69,8 @@
#define HAL_USE_I2C TRUE
#endif
+#define HAL_USE_ICU TRUE
+
/**
* @brief Enables the MAC subsystem.
*/
diff --git a/main.cpp b/main.cpp
index 27fab50..57d3d17 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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();
diff --git a/mcuconf.h b/mcuconf.h
index 74b6346..40be2cc 100644
--- a/mcuconf.h
+++ b/mcuconf.h
@@ -75,6 +75,20 @@
#define STM32_GPT_TIM5_IRQ_PRIORITY 7
/*
+ * ICU driver system settings.
+ */
+#define STM32_ICU_USE_TIM1 FALSE
+#define STM32_ICU_USE_TIM2 FALSE
+#define STM32_ICU_USE_TIM3 FALSE
+#define STM32_ICU_USE_TIM4 TRUE
+#define STM32_ICU_USE_TIM5 FALSE
+#define STM32_ICU_TIM1_IRQ_PRIORITY 7
+#define STM32_ICU_TIM2_IRQ_PRIORITY 7
+#define STM32_ICU_TIM3_IRQ_PRIORITY 7
+#define STM32_ICU_TIM4_IRQ_PRIORITY 7
+#define STM32_ICU_TIM5_IRQ_PRIORITY 7
+
+/*
* PWM driver system settings.
*/
#define STM32_PWM_USE_ADVANCED FALSE