From 6c97d4f6fb4184c41f6283ce025a7030280a1802 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 31 Aug 2014 17:21:02 +0000 Subject: Enhanced ICU driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7211 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/STM32F0xx/PWM-ICU/main.c | 9 +++++---- testhal/STM32/STM32F1xx/PWM-ICU/main.c | 9 +++++---- testhal/STM32/STM32F30x/PWM-ICU/main.c | 1 + testhal/STM32/STM32F37x/PWM-ICU/.cproject | 1 + testhal/STM32/STM32F37x/PWM-ICU/main.c | 9 +++++---- testhal/STM32/STM32F4xx/PWM-ICU/main.c | 9 +++++---- testhal/STM32/STM32L1xx/PWM-ICU/main.c | 9 +++++---- 7 files changed, 27 insertions(+), 20 deletions(-) (limited to 'testhal') diff --git a/testhal/STM32/STM32F0xx/PWM-ICU/main.c b/testhal/STM32/STM32F0xx/PWM-ICU/main.c index 661635c95..c2f1a9e0b 100644 --- a/testhal/STM32/STM32F0xx/PWM-ICU/main.c +++ b/testhal/STM32/STM32F0xx/PWM-ICU/main.c @@ -48,13 +48,13 @@ icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { palSetPad(GPIOC, GPIOC_LED3); - last_width = icuGetWidth(icup); + last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { palClearPad(GPIOC, GPIOC_LED3); - last_period = icuGetPeriod(icup); + last_period = icuGetPeriodX(icup); } static void icuoverflowcb(ICUDriver *icup) { @@ -98,7 +98,8 @@ int main(void) { palSetPadMode(GPIOA, 8, PAL_MODE_ALTERNATE(2)); icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOA, 6, PAL_MODE_ALTERNATE(1)); - icuEnable(&ICUD3); + icuStartCapture(&ICUD3); + icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* @@ -132,7 +133,7 @@ int main(void) { */ pwmDisableChannel(&PWMD1, 0); pwmStop(&PWMD1); - icuDisable(&ICUD3); + icuStopCapture(&ICUD3); icuStop(&ICUD3); palClearPad(GPIOC, GPIOC_LED3); palClearPad(GPIOC, GPIOC_LED4); diff --git a/testhal/STM32/STM32F1xx/PWM-ICU/main.c b/testhal/STM32/STM32F1xx/PWM-ICU/main.c index 92805fec4..2700dea7f 100644 --- a/testhal/STM32/STM32F1xx/PWM-ICU/main.c +++ b/testhal/STM32/STM32F1xx/PWM-ICU/main.c @@ -50,12 +50,12 @@ icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { - last_width = icuGetWidth(icup); + last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { - last_period = icuGetPeriod(icup); + last_period = icuGetPeriodX(icup); } static ICUConfig icucfg = { @@ -95,7 +95,8 @@ int main(void) { pwmEnablePeriodicNotification(&PWMD1); palSetPadMode(IOPORT1, 8, PAL_MODE_STM32_ALTERNATE_PUSHPULL); icuStart(&ICUD4, &icucfg); - icuEnable(&ICUD4); + icuStartCapture(&ICUD4); + icuEnableNotifications(&ICUD4); chThdSleepMilliseconds(2000); /* @@ -129,7 +130,7 @@ int main(void) { */ pwmDisableChannel(&PWMD1, 0); pwmStop(&PWMD1); - icuDisable(&ICUD4); + icuStopCapture(&ICUD4); icuStop(&ICUD4); palSetPad(IOPORT3, GPIOC_LED); diff --git a/testhal/STM32/STM32F30x/PWM-ICU/main.c b/testhal/STM32/STM32F30x/PWM-ICU/main.c index df25de24d..ef67fdcf1 100644 --- a/testhal/STM32/STM32F30x/PWM-ICU/main.c +++ b/testhal/STM32/STM32F30x/PWM-ICU/main.c @@ -94,6 +94,7 @@ int main(void) { icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2)); icuStartCapture(&ICUD3); + icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* diff --git a/testhal/STM32/STM32F37x/PWM-ICU/.cproject b/testhal/STM32/STM32F37x/PWM-ICU/.cproject index 42e9f611b..fc26faa3d 100644 --- a/testhal/STM32/STM32F37x/PWM-ICU/.cproject +++ b/testhal/STM32/STM32F37x/PWM-ICU/.cproject @@ -48,4 +48,5 @@ + diff --git a/testhal/STM32/STM32F37x/PWM-ICU/main.c b/testhal/STM32/STM32F37x/PWM-ICU/main.c index 0178af14a..04b144dcd 100644 --- a/testhal/STM32/STM32F37x/PWM-ICU/main.c +++ b/testhal/STM32/STM32F37x/PWM-ICU/main.c @@ -48,13 +48,13 @@ icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { palSetPad(GPIOC, GPIOC_LED2); - last_width = icuGetWidth(icup); + last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { palClearPad(GPIOC, GPIOC_LED2); - last_period = icuGetPeriod(icup); + last_period = icuGetPeriodX(icup); } static ICUConfig icucfg = { @@ -93,7 +93,8 @@ int main(void) { palSetPadMode(GPIOC, 0, PAL_MODE_ALTERNATE(2)); icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2)); - icuEnable(&ICUD3); + icuStartCapture(&ICUD3); + icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* @@ -127,7 +128,7 @@ int main(void) { */ pwmDisableChannel(&PWMD5, 0); pwmStop(&PWMD5); - icuDisable(&ICUD3); + icuStopCapture(&ICUD3); icuStop(&ICUD3); /* diff --git a/testhal/STM32/STM32F4xx/PWM-ICU/main.c b/testhal/STM32/STM32F4xx/PWM-ICU/main.c index 64da60b1d..2b5a992b0 100644 --- a/testhal/STM32/STM32F4xx/PWM-ICU/main.c +++ b/testhal/STM32/STM32F4xx/PWM-ICU/main.c @@ -48,13 +48,13 @@ icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { palSetPad(GPIOD, GPIOD_LED4); - last_width = icuGetWidth(icup); + last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { palClearPad(GPIOD, GPIOD_LED4); - last_period = icuGetPeriod(icup); + last_period = icuGetPeriodX(icup); } static ICUConfig icucfg = { @@ -93,7 +93,8 @@ int main(void) { palSetPadMode(GPIOA, 8, PAL_MODE_ALTERNATE(1)); icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2)); - icuEnable(&ICUD3); + icuStartCapture(&ICUD3); + icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* @@ -127,7 +128,7 @@ int main(void) { */ pwmDisableChannel(&PWMD1, 0); pwmStop(&PWMD1); - icuDisable(&ICUD3); + icuStopCapture(&ICUD3); icuStop(&ICUD3); palClearPad(GPIOD, GPIOD_LED4); palClearPad(GPIOD, GPIOD_LED5); diff --git a/testhal/STM32/STM32L1xx/PWM-ICU/main.c b/testhal/STM32/STM32L1xx/PWM-ICU/main.c index 654f23379..450899049 100644 --- a/testhal/STM32/STM32L1xx/PWM-ICU/main.c +++ b/testhal/STM32/STM32L1xx/PWM-ICU/main.c @@ -48,13 +48,13 @@ icucnt_t last_width, last_period; static void icuwidthcb(ICUDriver *icup) { palSetPad(GPIOB, GPIOB_LED3); - last_width = icuGetWidth(icup); + last_width = icuGetWidthX(icup); } static void icuperiodcb(ICUDriver *icup) { palClearPad(GPIOB, GPIOB_LED3); - last_period = icuGetPeriod(icup); + last_period = icuGetPeriodX(icup); } static ICUConfig icucfg = { @@ -93,7 +93,8 @@ int main(void) { palSetPadMode(GPIOA, 15, PAL_MODE_ALTERNATE(1)); icuStart(&ICUD3, &icucfg); palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(2)); - icuEnable(&ICUD3); + icuStartCapture(&ICUD3); + icuEnableNotifications(&ICUD3); chThdSleepMilliseconds(2000); /* @@ -127,7 +128,7 @@ int main(void) { */ pwmDisableChannel(&PWMD2, 0); pwmStop(&PWMD2); - icuDisable(&ICUD3); + icuStopCapture(&ICUD3); icuStop(&ICUD3); palClearPad(GPIOB, GPIOB_LED3); palClearPad(GPIOB, GPIOB_LED4); -- cgit v1.2.3