Skip to content

Commit 603bea5

Browse files
rzryichoi
authored andcommitted
nuttx: Register PWM device only if device file is not present (#1886)
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: #1886 Change-Id: I6134f15ead43babe3e5de6a9f0d185f6629f62d2 IoT.js-DCO-1.0-Signed-off-by: Philippe Coval p.coval@samsung.com
1 parent d947c61 commit 603bea5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/modules/nuttx/iotjs_module_pwm-nuttx.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ bool iotjs_pwm_open(iotjs_pwm_t* pwm) {
8989
return false;
9090
}
9191

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

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

97-
if (pwm_register(path, pwm_lowerhalf) != 0) {
98-
return false;
98+
if (pwm_register(path, pwm_lowerhalf) != 0) {
99+
return false;
100+
}
99101
}
100102

101103
// File open

0 commit comments

Comments
 (0)