diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-04-01 08:45:34 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-04-01 08:45:34 +0000 |
commit | 0b0fb6f88f6851842e89f19129b0dc535f41dcbc (patch) | |
tree | 68f624b27371ca455ea1e43e16074963fd66d495 /testhal/STM32/PWM/main.c | |
parent | beab954a35b7c6be13b8c5af58c7cd52b5888abc (diff) | |
download | ChibiOS-0b0fb6f88f6851842e89f19129b0dc535f41dcbc.tar.gz ChibiOS-0b0fb6f88f6851842e89f19129b0dc535f41dcbc.tar.bz2 ChibiOS-0b0fb6f88f6851842e89f19129b0dc535f41dcbc.zip |
ICU driver functional.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2857 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/PWM/main.c')
-rw-r--r-- | testhal/STM32/PWM/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/testhal/STM32/PWM/main.c b/testhal/STM32/PWM/main.c index ef08b792c..c89b71988 100644 --- a/testhal/STM32/PWM/main.c +++ b/testhal/STM32/PWM/main.c @@ -46,6 +46,25 @@ static PWMConfig pwmcfg = { 0
};
+icucnt_t last_width, last_period;
+
+static void icuwidthcb(ICUDriver *icup) {
+
+ last_width = icuGetWidthI(icup);
+}
+
+static void icuperiodcb(ICUDriver *icup) {
+
+ last_period = icuGetPeriodI(icup);
+}
+
+static ICUConfig icucfg = {
+ ICU_INPUT_ACTIVE_HIGH,
+ 10000, /* 10KHz ICU clock frequency. */
+ icuwidthcb,
+ icuperiodcb
+};
+
/*
* Application entry point.
*/
@@ -71,6 +90,8 @@ int main(void) { */
pwmStart(&PWMD1, &pwmcfg);
palSetPadMode(IOPORT1, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
+ icuStart(&ICUD4, &icucfg);
+ icuEnable(&ICUD4);
chThdSleepMilliseconds(2000);
/*
@@ -97,6 +118,8 @@ int main(void) { */
pwmDisableChannel(&PWMD1, 0);
pwmStop(&PWMD1);
+ icuDisable(&ICUD4);
+ icuStop(&ICUD4);
palSetPad(IOPORT3, GPIOC_LED);
/*
|