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 | |
parent | 944a03b280df083800c8aea9b206de0c6539e14a (diff) |
Test ppmsum decoding.
-rw-r--r-- | board.h | 2 | ||||
-rw-r--r-- | halconf.h | 2 | ||||
-rw-r--r-- | main.cpp | 32 | ||||
-rw-r--r-- | mcuconf.h | 14 |
4 files changed, 49 insertions, 1 deletions
@@ -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
@@ -69,6 +69,8 @@ #define HAL_USE_I2C TRUE
#endif
+#define HAL_USE_ICU TRUE
+
/**
* @brief Enables the MAC subsystem.
*/
@@ -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();
@@ -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
|