Browse Source

Merge pull request #2992 from gebart/pr/pwm-return-value

periph_pwm: Return actual frequency (like the docs say)
dev/timer
Oleg Hahm 8 years ago
parent
commit
287aa4cdbf
  1. 2
      cpu/lpc2387/periph/pwm.c
  2. 2
      cpu/stm32f3/periph/pwm.c
  3. 2
      cpu/stm32f4/periph/pwm.c
  4. 2
      drivers/include/periph/pwm.h
  5. 9
      tests/periph_pwm/main.c

2
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)

2
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)

2
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)

2
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
*/

9
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++) {

Loading…
Cancel
Save