Skip to content

Commit

Permalink
nuttx: Register PWM device only if device file is not present
Browse files Browse the repository at this point in the history
If configured from menuconfig, device inode is already there
there is no need to register it again.

It was observed on STM32F7 using a config with those options:

```
CONFIG_STM32F7_TIM1=y
CONFIG_STM32F7_TIM1_PWM=y
```

Relate-to: rzr/webthing-iotjs#3
Forwarded: https://github.com/pando-project/iotjs/pull/
Change-Id: I6134f15ead43babe3e5de6a9f0d185f6629f62d2
IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com
  • Loading branch information
rzr committed May 28, 2019
1 parent d947c61 commit 535c678
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/modules/nuttx/iotjs_module_pwm-nuttx.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ bool iotjs_pwm_open(iotjs_pwm_t* pwm) {
return false;
}

struct pwm_lowerhalf_s* pwm_lowerhalf =
iotjs_pwm_config_nuttx(timer, pwm->pin);
if (access(path, F_OK) != 0) {
struct pwm_lowerhalf_s* pwm_lowerhalf =
iotjs_pwm_config_nuttx(timer, pwm->pin);

DDDLOG("%s - path: %s, timer: %d\n", __func__, path, timer);
DDDLOG("%s - path: %s, timer: %d\n", __func__, path, timer);

if (pwm_register(path, pwm_lowerhalf) != 0) {
return false;
if (pwm_register(path, pwm_lowerhalf) != 0) {
return false;
}
}

// File open
Expand Down

0 comments on commit 535c678

Please sign in to comment.