Skip to content

Commit

Permalink
rp2040: pwm: Fix errors at CONFIG_PWM_NCHANNELS=1
Browse files Browse the repository at this point in the history
Perhaps it has never been tested with CONFIG_PWM_NCHANNELS=1.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
  • Loading branch information
takumiando committed Nov 13, 2023
1 parent 74d698f commit 900a827
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/arm/src/rp2040/Kconfig
Expand Up @@ -276,6 +276,7 @@ if PWM_MULTICHAN
config PWM_NCHANNELS
int "Number of channels"
default 2
range 1 2
---help---
If the number of channels is set to 1, the generated code will
only support the A channel of the PWM slices. This is functionally
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/rp2040/rp2040_pwm.c
Expand Up @@ -288,8 +288,8 @@ int pwm_shutdown (struct pwm_lowerhalf_s * dev)

if (priv->pin >= 0)
{
rp2040_gpio_setdir(priv->pin[0], true);
rp2040_gpio_put(priv->pin[0],
rp2040_gpio_setdir(priv->pin, true);
rp2040_gpio_put(priv->pin,
((priv->flags & RP2040_PWM_CSR_A_INV) != 0));
rp2040_gpio_set_function(priv->pin, RP2040_GPIO_FUNC_SIO);
}
Expand Down
7 changes: 7 additions & 0 deletions boards/arm/rp2040/common/src/rp2040_pwmdev.c
Expand Up @@ -58,11 +58,18 @@ int rp2040_pwmdev_initialize(int slice,
int ret;
struct rp2040_pwm_lowerhalf_s *pwm_lowerhalf;

#if defined(CONFIG_PWM_NCHANNELS) && CONFIG_PWM_NCHANNELS == 2
pwminfo("Initializing /dev/pwm%d a %d b %d f 0x%08lX..\n",
slice,
pin_a,
pin_b,
flags);
#else
pwminfo("Initializing /dev/pwm%d %d 0x%08lX..\n",
slice,
pin,
flags);
#endif

/* Initialize spi device */

Expand Down

0 comments on commit 900a827

Please sign in to comment.