1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-30 08:51:19 +01:00

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

periph_pwm: Return actual frequency (like the docs say)
This commit is contained in:
Oleg Hahm 2015-05-17 13:06:08 +02:00
commit 287aa4cdbf
5 changed files with 8 additions and 9 deletions

View File

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

View File

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

View File

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

View File

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

View File

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