Skip to content
Snippets Groups Projects
Commit 287aa4cd authored by Oleg Hahm's avatar Oleg Hahm
Browse files

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

periph_pwm: Return actual frequency (like the docs say)
parents c131911a 43b91504
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
*/
......
......@@ -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++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment