@@ -48,7 +48,9 @@ struct pwm_exp
4848 int period_fd ;
4949 int duty_fd ;
5050 int polarity_fd ;
51+ #ifdef BBBVERSION41
5152 int enable_fd ;
53+ #endif
5254 float duty ;
5355 unsigned long duty_ns ;
5456 unsigned long period_ns ;
@@ -179,7 +181,9 @@ BBIO_err pwm_set_polarity(const char *key, int polarity) {
179181 int len ;
180182 char buffer [9 ]; /* allow room for trailing NUL byte */
181183 struct pwm_exp * pwm ;
184+ #ifdef BBBVERSION41
182185 int enabled ; /* Maintain original state */
186+ #endif
183187
184188 pwm = lookup_exported_pwm (key );
185189
@@ -270,7 +274,6 @@ BBIO_err pwm_set_duty_cycle(const char *key, float duty) {
270274
271275BBIO_err pwm_setup (const char * key , float duty , float freq , int polarity )
272276{
273- int e ;
274277 BBIO_err err ;
275278
276279#ifdef BBBVERSION41
@@ -284,6 +287,7 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
284287 char polarity_path [90 ];
285288 char enable_path [90 ];
286289
290+ int e ;
287291 int period_fd , duty_fd , polarity_fd , enable_fd ;
288292 struct pwm_exp * new_pwm ;
289293 struct stat s ;
@@ -382,8 +386,8 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
382386 int period_fd , duty_fd , polarity_fd ;
383387 struct pwm_exp * new_pwm ;
384388
385- if (!pwm_initialized ) {
386- err = initialize_pwm ()
389+ if (!pwm_initialized ) {
390+ err = initialize_pwm ();
387391 if (err != BBIO_OK ) {
388392 return err ;
389393 }
@@ -456,7 +460,11 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
456460 new_pwm -> period_fd = period_fd ;
457461 new_pwm -> duty_fd = duty_fd ;
458462 new_pwm -> polarity_fd = polarity_fd ;
463+
464+ #ifdef BBBVERSION41
459465 new_pwm -> enable_fd = enable_fd ;
466+ #endif
467+
460468 new_pwm -> next = NULL ;
461469
462470 export_pwm (new_pwm );
@@ -467,8 +475,10 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
467475BBIO_err pwm_start (const char * key , float duty , float freq , int polarity )
468476{
469477 BBIO_err err ;
478+ #ifdef BBBVERSION41
470479 char buffer [20 ];
471480 size_t len ;
481+ #endif
472482
473483 struct pwm_exp * pwm = lookup_exported_pwm (key );
474484 if (pwm == NULL ) {
@@ -513,10 +523,11 @@ BBIO_err pwm_start(const char *key, float duty, float freq, int polarity)
513523BBIO_err pwm_disable (const char * key )
514524{
515525 struct pwm_exp * pwm , * temp , * prev_pwm = NULL ;
516- char buffer [2 ];
517- size_t len ;
526+ BBIO_err err ;
518527
519528#ifdef BBBVERSION41
529+ char buffer [2 ];
530+ size_t len ;
520531 pwm = lookup_exported_pwm (key );
521532
522533 // Disable the PWM
0 commit comments