@@ -38,6 +38,7 @@ SOFTWARE.
3838#endif
3939
4040#define KEYLEN 7
41+ #define PIN_MODE_LEN 5
4142
4243int pwm_initialized = 0 ;
4344
@@ -286,6 +287,7 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
286287 char period_path [90 ];
287288 char polarity_path [90 ];
288289 char enable_path [90 ];
290+ char pin_mode [PIN_MODE_LEN ]; // "pwm" or "pwm2"
289291
290292 int e ;
291293 int period_fd , duty_fd , polarity_fd , enable_fd ;
@@ -316,7 +318,16 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
316318 return BBIO_CAPE ;
317319 }
318320 // Do pinmuxing
319- set_pin_mode (key , "pwm" );
321+ fprintf (stderr , "DEBUG: do pinmuxing: key=%s\n" , key );
322+ if (!strcmp (key , "P9_28" )) {
323+ fprintf (stderr , "DEBUG: P9_28: use pwm2\n" );
324+ strncpy (pin_mode , "pwm2" , PIN_MODE_LEN );
325+ } else {
326+ fprintf (stderr , "DEBUG: use pwm\n" );
327+ strncpy (pin_mode , "pwm" , PIN_MODE_LEN );
328+ }
329+ fprintf (stderr , "DEBUG: set_pin_mode(key=%s, pin_mode=%s)\n" , key , pin_mode );
330+ set_pin_mode (key , pin_mode );
320331
321332 // Get info for pwm
322333 err = get_pwm_by_key (key , & p );
0 commit comments