@@ -126,12 +126,29 @@ static int cmd_nsec(const struct shell *sh, size_t argc, char **argv)
126126 return 0 ;
127127}
128128
129+ static bool device_is_pwm_and_ready (const struct device * dev )
130+ {
131+ return device_is_ready (dev ) && DEVICE_API_IS (pwm , dev );
132+ }
133+
134+ static void device_name_get (size_t idx , struct shell_static_entry * entry )
135+ {
136+ const struct device * dev = shell_device_filter (idx , device_is_pwm_and_ready );
137+
138+ entry -> syntax = (dev != NULL ) ? dev -> name : NULL ;
139+ entry -> handler = NULL ;
140+ entry -> help = NULL ;
141+ entry -> subcmd = NULL ;
142+ }
143+
144+ SHELL_DYNAMIC_CMD_CREATE (dsub_device_name , device_name_get );
145+
129146SHELL_STATIC_SUBCMD_SET_CREATE (pwm_cmds ,
130- SHELL_CMD_ARG (cycles , NULL , "<device> <channel> <period in cycles> "
147+ SHELL_CMD_ARG (cycles , & dsub_device_name , "<device> <channel> <period in cycles> "
131148 "<pulse width in cycles> [flags]" , cmd_cycles , 5 , 1 ),
132- SHELL_CMD_ARG (usec , NULL , "<device> <channel> <period in usec> "
149+ SHELL_CMD_ARG (usec , & dsub_device_name , "<device> <channel> <period in usec> "
133150 "<pulse width in usec> [flags]" , cmd_usec , 5 , 1 ),
134- SHELL_CMD_ARG (nsec , NULL , "<device> <channel> <period in nsec> "
151+ SHELL_CMD_ARG (nsec , & dsub_device_name , "<device> <channel> <period in nsec> "
135152 "<pulse width in nsec> [flags]" , cmd_nsec , 5 , 1 ),
136153 SHELL_SUBCMD_SET_END
137154);
0 commit comments