diff options
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);
/*
|