From 616c272801c7e6fcd227a1f3bedf9c3396ac262e Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 16 May 2015 09:57:04 +0200 Subject: [PATCH 1/5] tests/periph_pwm: Handle pwm_init return value as actual frequency --- tests/periph_pwm/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/periph_pwm/main.c b/tests/periph_pwm/main.c index 7e66c7692..7cbc228e2 100644 --- a/tests/periph_pwm/main.c +++ b/tests/periph_pwm/main.c @@ -48,16 +48,15 @@ int main(void) int step = STEP; puts("\nRIOT PWM test"); - puts("Connect an LED or scope to PWM pins to see something\n"); + puts("Connect an LED or scope to PWM pins to see something"); res = pwm_init(DEV, MODE, FREQU, STEPS); - if (res == 0) { - puts("PWM successfully initialized.\n"); - } - else { + if (res < 0) { puts("Errors while initializing PWM"); return -1; } + puts("PWM initialized."); + printf("requested: %d Hz, got %d Hz\n", FREQU, res); while (1) { for (int i = 0; i < CHANNELS; i++) { From 92a743560d8562147a34aa13cb16f15af9b0648d Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 16 May 2015 09:59:10 +0200 Subject: [PATCH 2/5] drivers/periph/pwm: Update return value doxygen to match long description --- drivers/include/periph/pwm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/include/periph/pwm.h b/drivers/include/periph/pwm.h index 15b7792b3..a64eebcfa 100644 --- a/drivers/include/periph/pwm.h +++ b/drivers/include/periph/pwm.h @@ -76,7 +76,7 @@ typedef enum { * @param[in] frequency the PWM frequency in Hz * @param[in] resolution the PWM resolution * - * @return 0 on success + * @return Actual PWM frequency on success * @return -1 on mode not applicable * @return -2 on frequency and resolution not applicable */ From 8619bdec63162b59a1adac90a3a1eb504593af9c Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 16 May 2015 10:06:30 +0200 Subject: [PATCH 3/5] lpc2387: pwm_init: return actual frequency --- cpu/lpc2387/periph/pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/lpc2387/periph/pwm.c b/cpu/lpc2387/periph/pwm.c index 7da96d59e..d8f5f3e63 100644 --- a/cpu/lpc2387/periph/pwm.c +++ b/cpu/lpc2387/periph/pwm.c @@ -82,7 +82,7 @@ int pwm_init(pwm_t dev, pwm_mode_t mode, unsigned int frequency, unsigned int re #endif } - return 0; + return frequency; } int pwm_set(pwm_t dev, int channel, unsigned int value) From 018b6a73d4e388884f0f75afe4125b97c68cd5ef Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 16 May 2015 10:06:44 +0200 Subject: [PATCH 4/5] stm32f3: pwm_init: return actual frequency --- cpu/stm32f3/periph/pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/stm32f3/periph/pwm.c b/cpu/stm32f3/periph/pwm.c index 091dd4d6e..f38c988a2 100644 --- a/cpu/stm32f3/periph/pwm.c +++ b/cpu/stm32f3/periph/pwm.c @@ -125,7 +125,7 @@ int pwm_init(pwm_t dev, pwm_mode_t mode, unsigned int frequency, unsigned int re /* enable PWM generation */ pwm_start(dev); - return 0; + return frequency; } int pwm_set(pwm_t dev, int channel, unsigned int value) From 43b9150460974f4c5d5eacd751a16d0593fd7dbd Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Sat, 16 May 2015 10:06:50 +0200 Subject: [PATCH 5/5] stm32f4: pwm_init: return actual frequency --- cpu/stm32f4/periph/pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/stm32f4/periph/pwm.c b/cpu/stm32f4/periph/pwm.c index 90999b3db..eaf5e76b3 100644 --- a/cpu/stm32f4/periph/pwm.c +++ b/cpu/stm32f4/periph/pwm.c @@ -157,7 +157,7 @@ int pwm_init(pwm_t dev, pwm_mode_t mode, unsigned int frequency, unsigned int re /* enable timer ergo the PWM generation */ pwm_start(dev); - return 0; + return frequency; } int pwm_set(pwm_t dev, int channel, unsigned int value)