mirror of https://github.com/ARMmbed/mbed-os.git
Update ARDUINO test to allow period change
parent
7c657ad5c9
commit
c9350f8e5a
|
|
@ -19,15 +19,15 @@ float value = 0.75;
|
||||||
int main() {
|
int main() {
|
||||||
#if defined(TARGET_FF_ARDUINO)
|
#if defined(TARGET_FF_ARDUINO)
|
||||||
PwmOut pwm(D9);
|
PwmOut pwm(D9);
|
||||||
|
int period_us = 40000; // allows to test various periods
|
||||||
|
|
||||||
pwm.period_ms(10);
|
pwm.period_us(period_us);
|
||||||
pwm.write(value);
|
pwm.write(value);
|
||||||
|
|
||||||
float result = floor(pwm.read() * 100 + 0.5) / 100; // round it to 0.xx
|
float result = floor(pwm.read() * 100 + 0.5) / 100; // round it to 0.xx
|
||||||
printf("Initialize PWM on pin D9 with duty cycle: %.2f\n", result);
|
printf("PWM period = %dus with duty cycle: %d%%\n", period_us, (int) (result * 100));
|
||||||
|
|
||||||
notify_completion(result == value ? true : false);
|
notify_completion(result == value ? true : false);
|
||||||
|
|
||||||
#elif defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC11U24) || defined(TARGET_LPC4088) || defined(TARGET_LPC2460)
|
#elif defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC11U24) || defined(TARGET_LPC4088) || defined(TARGET_LPC2460)
|
||||||
PwmOut pwm_p25(p25);
|
PwmOut pwm_p25(p25);
|
||||||
PwmOut pwm_p26(p26);
|
PwmOut pwm_p26(p26);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue