Skip to content

Commit 298334a

Browse files
author
Matthew West
committed
Bug fixes to 4.1+ PWM code
1 parent 6b2aa7a commit 298334a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

source/c_pwm.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,18 @@ void export_pwm(struct pwm_exp *new_pwm)
8787

8888
BBIO_err initialize_pwm(void)
8989
{
90+
BBIO_err err;
9091
#ifdef BBBVERSION41 // don't load overlay in 4.1+
9192
if (!pwm_initialized) {
93+
strncpy(ocp_dir, "/sys/devices/platform/ocp", sizeof(ocp_dir));
9294
#else
9395
if (!pwm_initialized && load_device_tree("am33xx_pwm")) {
94-
#endif
95-
if (!build_path("/sys/devices", "ocp", ocp_dir, sizeof(ocp_dir)))
96+
err = build_path("/sys/devices", "ocp", ocp_dir, sizeof(ocp_dir));
97+
if (err != BBIO_OK)
9698
{
9799
return BBIO_SYSFS;
98100
}
101+
#endif
99102
pwm_initialized = 1;
100103
return BBIO_OK;
101104
}
@@ -398,7 +401,7 @@ BBIO_err pwm_disable(const char *key)
398401
pwm = pwm->next;
399402
}
400403
}
401-
return BBIO_OK;
404+
return BBIO_OK;
402405
}
403406

404407
void pwm_cleanup(void)

source/c_pwm.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ SOFTWARE.
2323
#ifndef C_PWM_H
2424
#define C_PWM_H
2525

26-
int pwm_start(const char *key, float duty, float freq, int polarity);
27-
int pwm_disable(const char *key);
28-
int pwm_set_frequency(const char *key, float freq);
29-
int pwm_set_duty_cycle(const char *key, float duty);
26+
BBIO_err pwm_start(const char *key, float duty, float freq, int polarity);
27+
BBIO_err pwm_disable(const char *key);
28+
BBIO_err pwm_set_frequency(const char *key, float freq);
29+
BBIO_err pwm_set_duty_cycle(const char *key, float duty);
30+
BBIO_err pwm_set_polarity(const char *key, int polarity);
3031
void pwm_cleanup(void);
3132
#endif

0 commit comments

Comments
 (0)