Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/efm32: pwm_init errors are zeros #19405

Merged
merged 2 commits into from Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpu/efm32/periph/pwm.c
Expand Up @@ -33,7 +33,7 @@ uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res)
{
/* check if device is valid */
if (dev >= PWM_NUMOF) {
return -1;
return 0;
}

/* enable clocks */
Expand All @@ -46,7 +46,7 @@ uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res)
freq_timer);

if (prescaler > timerPrescale1024) {
return -2;
return 0;
}

/* reset and initialize peripheral */
Expand Down
12 changes: 6 additions & 6 deletions tests/periph_pwm/main.c
Expand Up @@ -42,7 +42,7 @@
#define OSC_STEPS (256U)
#define PWR_SLEEP (1U)

static uint32_t initiated;
static uint32_t initialized;

static unsigned _get_dev(const char *dev_str)
{
Expand Down Expand Up @@ -94,11 +94,11 @@ static int _init(int argc, char** argv)
(uint16_t)atoi(argv[4]));
if (pwm_freq != 0) {
printf("The pwm frequency is set to %" PRIu32 "\n", pwm_freq);
initiated |= (1 << dev);
initialized |= (1 << dev);
return 0;
}

puts("Error: device is not initiated");
puts("Error: device is not initialized");
return 1;
}

Expand All @@ -117,8 +117,8 @@ static int _set(int argc, char**argv)
return 1;
}

if ((initiated & (1 << dev)) == 0) {
puts("Error: pwm is not initiated.\n");
if ((initialized & (1 << dev)) == 0) {
puts("Error: pwm is not initialized.\n");
puts("Execute init function first.\n");
return 1;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ static const shell_command_t shell_commands[] = {
int main(void)
{
puts("PWM peripheral driver test\n");
initiated = 0;
initialized = 0;

char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
Expand Down