cpu/samd21: allowed third PWM channel per device
This commit is contained in:
parent
a75847ca27
commit
bc1013b54e
@ -48,7 +48,7 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Tcc *dev; /**< TCC device to use */
|
Tcc *dev; /**< TCC device to use */
|
||||||
pwm_conf_chan_t chan[2]; /**< channel configuration */
|
pwm_conf_chan_t chan[3]; /**< channel configuration */
|
||||||
} pwm_conf_t;
|
} pwm_conf_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -106,8 +106,10 @@ uint32_t pwm_init(pwm_t dev, pwm_mode_t mode, uint32_t freq, uint16_t res)
|
|||||||
|
|
||||||
/* configure the used pins */
|
/* configure the used pins */
|
||||||
for (int i = 0; i < PWM_MAX_CHANNELS; i++) {
|
for (int i = 0; i < PWM_MAX_CHANNELS; i++) {
|
||||||
gpio_init(pwm_config[dev].chan[i].pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
if (pwm_config[dev].chan[i].pin != GPIO_UNDEF) {
|
||||||
gpio_init_mux(pwm_config[dev].chan[i].pin, pwm_config[dev].chan[i].mux);
|
gpio_init(pwm_config[dev].chan[i].pin, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||||
|
gpio_init_mux(pwm_config[dev].chan[i].pin, pwm_config[dev].chan[i].mux);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* power on the device */
|
/* power on the device */
|
||||||
@ -152,7 +154,8 @@ uint8_t pwm_channels(pwm_t dev)
|
|||||||
|
|
||||||
void pwm_set(pwm_t dev, uint8_t channel, uint16_t value)
|
void pwm_set(pwm_t dev, uint8_t channel, uint16_t value)
|
||||||
{
|
{
|
||||||
if (channel >= PWM_MAX_CHANNELS) {
|
if ((channel >= PWM_MAX_CHANNELS) ||
|
||||||
|
(pwm_config[dev].chan[channel].pin == GPIO_UNDEF)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_tcc(dev)->CC[_chan(dev, channel)].reg = value;
|
_tcc(dev)->CC[_chan(dev, channel)].reg = value;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user