From c70c9bad971bd4194aa29f51b73675deabb8220c Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 10:36:03 -0400 Subject: [PATCH 01/14] Add dmtimer PWM entries in table for PocketBeagle --- source/common.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/common.c b/source/common.c index 1027bed..f66968c 100644 --- a/source/common.c +++ b/source/common.c @@ -311,6 +311,11 @@ pwm_t pwm_table[] = { { "ehrpwm0", 1, 1, 1, "ehrpwm.0:1", "EHRPWM0B", "48300000", "48300200", "P1_33"}, { "ehrpwm1", 3, 0, 6, "ehrpwm.1:0", "EHRPWM1A", "48302000", "48302200", "P2_1"}, { "ehrpwm2", 6, 1, 3, "ehrpwm.2:1", "EHRPWM2B", "48304000", "48304200", "P2_3"}, + { "timer7", 0, 0, 4, "", "", "", "", "P1_20" }, + { "timer6", 0, 0, 1, "", "", "", "", "P1_26" }, + { "timer5", 0, 0, 1, "", "", "", "", "P1_28" }, + { "timer7", 0, 0, 5, "", "", "", "", "P2_27" }, + { "timer4", 0, 0, 2, "", "", "", "", "P2_31" }, { NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } }; From 0f9f472e36cb20b19bc3c3e238768bf5c4f76b63 Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 11:50:20 -0400 Subject: [PATCH 02/14] Add is_dmtimer_pin function --- source/c_pwm.c | 11 +++++++++++ source/common.c | 10 +++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index f03e1bd..1e00eae 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -94,6 +94,17 @@ void export_pwm(struct pwm_exp *new_pwm) } } +int is_dmtimer_pin(pwm_t *p) { + if(strlen(p->module) < 5) + return 0; + + char temp[6]; + strncpy(temp, p->module, 5); + temp[5] = '\0'; + + return (strcmp(temp, "timer") == 0); +} + BBIO_err initialize_pwm(void) { #ifdef BBBVERSION41 // don't load overlay in 4.1+ diff --git a/source/common.c b/source/common.c index f66968c..a5964cf 100644 --- a/source/common.c +++ b/source/common.c @@ -206,15 +206,15 @@ pins_t table[] = { { "VREFN", "P1_17", 0, -1, -1}, { "VREFP", "P1_18", 0, -1, -1}, { "AIN0", "P1_19", 0, -1, 0}, - { "GPIO0_20", "P1_20", 20, -1, -1}, + { "GPIO0_20", "P1_20", 20, 4, -1}, { "AIN1", "P1_21", 0, -1, 1}, { "GND", "P1_22", 0, -1, -1}, { "AIN2", "P1_23", 0, -1, 2}, { "VOUT-5V", "P1_24", 0, -1, -1}, { "AIN3", "P1_25", 0, -1, 3}, - { "I2C2_SDA", "P1_26", 12, -1, -1}, + { "I2C2_SDA", "P1_26", 12, 1, -1}, { "AIN4", "P1_27", 0, -1, 4}, - { "I2C2_SCL", "P1_28", 13, -1, -1}, + { "I2C2_SCL", "P1_28", 13, 1, -1}, { "GPIO3_21", "P1_29", 117, -1, -1}, { "UART0_TXD", "P1_30", 43, -1, -1}, { "GPIO3_18", "P1_31", 114, -1, -1}, @@ -249,11 +249,11 @@ pins_t table[] = { { "GPIO1_12", "P2_24", 44, -1, -1}, { "SPI1_CS0", "P2_25", 41, -1, -1}, { "RESET#", "P2_26", 0, -1, -1}, - { "SPI1_D0", "P2_27", 40, -1, -1}, + { "SPI1_D0", "P2_27", 40, 5, -1}, { "GPIO3_20", "P2_28", 116, -1, -1}, { "SPI1_SCLK", "P2_29", 7, -1, -1}, { "GPIO3_17", "P2_30", 113, -1, -1}, - { "SPI1_CS1", "P2_31", 19, -1, -1}, + { "SPI1_CS1", "P2_31", 19, 2, -1}, { "GPIO3_16", "P2_32", 112, -1, -1}, { "GPIO1_13", "P2_33", 45, -1, -1}, { "GPIO3_19", "P2_34", 115, -1, -1}, From 4149f2d4bc5f2254e10e898e59f9df17848526bc Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 12:16:49 -0400 Subject: [PATCH 03/14] Change path for dmtimer PWM pins --- source/c_pwm.c | 27 ++++++++++++++++++--------- source/common.c | 10 +++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index 1e00eae..fd09490 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -386,16 +386,25 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri return err; } - err = build_path(ocp_dir, p->chip, pwm_dev_path, sizeof(pwm_dev_path)); - if (err != BBIO_OK) { - syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_dev_path: %i", key, err); - return err; - } + if(!is_dmtimer_pin(p)) { + err = build_path(ocp_dir, p->chip, pwm_dev_path, sizeof(pwm_dev_path)); + if (err != BBIO_OK) { + syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_dev_path: %i", key, err); + return err; + } - err = build_path(pwm_dev_path, p->addr, pwm_addr_path, sizeof(pwm_addr_path)); - if (err != BBIO_OK) { - syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_addr_path: %i", key, err); - return err; + err = build_path(pwm_dev_path, p->addr, pwm_addr_path, sizeof(pwm_addr_path)); + if (err != BBIO_OK) { + syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_addr_path: %i", key, err); + return err; + } + } + else { + err = build_path("/sys/devices/platform", p->addr, pwm_addr_path, sizeof(pwm_addr_path)); + if (err != BBIO_OK) { + syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_addr_path: %i", key, err); + return err; + } } err = build_path(pwm_addr_path, "pwm/pwmchip", pwm_chip_path, sizeof(pwm_chip_path)); diff --git a/source/common.c b/source/common.c index a5964cf..7c3c3c3 100644 --- a/source/common.c +++ b/source/common.c @@ -311,11 +311,11 @@ pwm_t pwm_table[] = { { "ehrpwm0", 1, 1, 1, "ehrpwm.0:1", "EHRPWM0B", "48300000", "48300200", "P1_33"}, { "ehrpwm1", 3, 0, 6, "ehrpwm.1:0", "EHRPWM1A", "48302000", "48302200", "P2_1"}, { "ehrpwm2", 6, 1, 3, "ehrpwm.2:1", "EHRPWM2B", "48304000", "48304200", "P2_3"}, - { "timer7", 0, 0, 4, "", "", "", "", "P1_20" }, - { "timer6", 0, 0, 1, "", "", "", "", "P1_26" }, - { "timer5", 0, 0, 1, "", "", "", "", "P1_28" }, - { "timer7", 0, 0, 5, "", "", "", "", "P2_27" }, - { "timer4", 0, 0, 2, "", "", "", "", "P2_31" }, + { "timer7", 0, 0, 4, "", "", "", "dmtimer-pwm-7", "P1_20" }, + { "timer6", 0, 0, 1, "", "", "", "dmtimer-pwm-6", "P1_26" }, + { "timer5", 0, 0, 1, "", "", "", "dmtimer-pwm-5", "P1_28" }, + { "timer7", 0, 0, 5, "", "", "", "dmtimer-pwm-7", "P2_27" }, + { "timer4", 0, 0, 2, "", "", "", "dmtimer-pwm-4", "P2_31" }, { NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } }; From dcdb1adae9470b022d8af3ba56dd0e1b9969826d Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 13:50:37 -0400 Subject: [PATCH 04/14] Improve error logging --- source/c_pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index fd09490..22ed809 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -402,7 +402,7 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri else { err = build_path("/sys/devices/platform", p->addr, pwm_addr_path, sizeof(pwm_addr_path)); if (err != BBIO_OK) { - syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_addr_path: %i", key, err); + syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_addr_path, are you sure you've loaded the correct dmtimer device tree overlay?: %i", key, err); return err; } } From 1151dd9a8c0b3bda56b6f5a7f86dbcae924a5f9e Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 14:05:10 -0400 Subject: [PATCH 05/14] Add dmtimer PWM entries in table for BBB --- source/common.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/common.c b/source/common.c index 7c3c3c3..44c8aa1 100644 --- a/source/common.c +++ b/source/common.c @@ -81,10 +81,10 @@ pins_t table[] = { { "GPIO1_7", "P8_4", 39, -1, -1}, { "GPIO1_2", "P8_5", 34, -1, -1}, { "GPIO1_3", "P8_6", 35, -1, -1}, - { "TIMER4", "P8_7", 66, -1, -1}, - { "TIMER7", "P8_8", 67, -1, -1}, - { "TIMER5", "P8_9", 69, -1, -1}, - { "TIMER6", "P8_10", 68, -1, -1}, + { "TIMER4", "P8_7", 66, 2, -1}, + { "TIMER7", "P8_8", 67, 2, -1}, + { "TIMER5", "P8_9", 69, 2, -1}, + { "TIMER6", "P8_10", 68, 2, -1}, { "GPIO1_13", "P8_11", 45, -1, -1}, { "GPIO1_12", "P8_12", 44, -1, -1}, { "EHRPWM2B", "P8_13", 23, 4, -1}, @@ -305,6 +305,10 @@ pwm_t pwm_table[] = { { "ehrpwm0", 1, 1, 1, "ehrpwm.0:1", "EHRPWM0B", "48300000", "48300200", "P9_29"}, { "ehrpwm0", 0, 0, 1, "ehrpwm.0:0", "EHRPWM0A", "48300000", "48300200", "P9_31"}, { "ecap0", 2, 0, 0, "ecap.0", "ECAPPWM0", "48300000", "48300100", "P9_42"}, + { "timer4", 0, 0, 2, "", "", "", "dmtimer-pwm-4", "P8_7" }, + { "timer7", 0, 0, 2, "", "", "", "dmtimer-pwm-7", "P8_8" }, + { "timer5", 0, 0, 2, "", "", "", "dmtimer-pwm-5", "P8_9" }, + { "timer6", 0, 0, 2, "", "", "", "dmtimer-pwm-6", "P8_10" } { "ehrpwm0", 0, 0, 1, "ehrpwm.0:0", "EHRPWM0A", "48300000", "48300200", "P1_8"}, { "ehrpwm0", 0, 0, 1, "ehrpwm.0:0", "EHRPWM0A", "48300000", "48300200", "P1_36"}, { "ehrpwm0", 1, 1, 1, "ehrpwm.0:1", "EHRPWM0B", "48300000", "48300200", "P1_10"}, From 1c012a42eda220108aab3515fb6f30449db592c2 Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 14:58:03 -0400 Subject: [PATCH 06/14] Add missing comma --- source/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common.c b/source/common.c index 44c8aa1..f911d49 100644 --- a/source/common.c +++ b/source/common.c @@ -308,7 +308,7 @@ pwm_t pwm_table[] = { { "timer4", 0, 0, 2, "", "", "", "dmtimer-pwm-4", "P8_7" }, { "timer7", 0, 0, 2, "", "", "", "dmtimer-pwm-7", "P8_8" }, { "timer5", 0, 0, 2, "", "", "", "dmtimer-pwm-5", "P8_9" }, - { "timer6", 0, 0, 2, "", "", "", "dmtimer-pwm-6", "P8_10" } + { "timer6", 0, 0, 2, "", "", "", "dmtimer-pwm-6", "P8_10" }, { "ehrpwm0", 0, 0, 1, "ehrpwm.0:0", "EHRPWM0A", "48300000", "48300200", "P1_8"}, { "ehrpwm0", 0, 0, 1, "ehrpwm.0:0", "EHRPWM0A", "48300000", "48300200", "P1_36"}, { "ehrpwm0", 1, 1, 1, "ehrpwm.0:1", "EHRPWM0B", "48300000", "48300200", "P1_10"}, From 928e8dc499c61f26f5428d2e1ab0dcae4d2967be Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Wed, 22 Jul 2020 15:25:24 -0400 Subject: [PATCH 07/14] Add udev PWM path for DMTimer pins --- source/c_pwm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index 22ed809..4b40a72 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -386,7 +386,9 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri return err; } - if(!is_dmtimer_pin(p)) { + int dmtimer_pin = is_dmtimer_pin(p); + + if(!dmtimer_pin) { err = build_path(ocp_dir, p->chip, pwm_dev_path, sizeof(pwm_dev_path)); if (err != BBIO_OK) { syslog(LOG_ERR, "Adafruit_BBIO: pwm_setup: %s couldn't build pwm_dev_path: %i", key, err); @@ -417,10 +419,10 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path: %s", key, pwm_path); //pwm with udev patch - snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, pwm_path[66], p->index); + snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? p->module[5] : pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path_udev: %s", key, pwm_path_udev); //ecap output with udev patch - snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, pwm_path[66], p->index); + snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? p->module[5] : pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, ecap_path_udev: %s", key, ecap_path_udev); // Export PWM if hasn't already been From db0adf258cb3d73c51a1cbb6ae76cbc43ac3c522 Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Thu, 23 Jul 2020 12:01:49 -0400 Subject: [PATCH 08/14] Fix udev PWM path for DMTimer pins --- source/c_pwm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index 4b40a72..117a607 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -419,10 +419,10 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path: %s", key, pwm_path); //pwm with udev patch - snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? p->module[5] : pwm_path[66], p->index); + snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? pwm_path[47] : pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path_udev: %s", key, pwm_path_udev); //ecap output with udev patch - snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? p->module[5] : pwm_path[66], p->index); + snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? pwm_path[47] : pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, ecap_path_udev: %s", key, ecap_path_udev); // Export PWM if hasn't already been From af9ea512e8aa7508d03109de6c7e5b8bfe739e2b Mon Sep 17 00:00:00 2001 From: Darren Schachter Date: Fri, 24 Jul 2020 10:45:40 -0400 Subject: [PATCH 09/14] Remove unnecessary conditional --- source/c_pwm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index 117a607..1756e5f 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -94,10 +94,7 @@ void export_pwm(struct pwm_exp *new_pwm) } } -int is_dmtimer_pin(pwm_t *p) { - if(strlen(p->module) < 5) - return 0; - +int is_dmtimer_pin(pwm_t *p) { char temp[6]; strncpy(temp, p->module, 5); temp[5] = '\0'; From d3bae3c1ab3cde1b489de7fe2e7448a3a177e53c Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Wed, 29 Jul 2020 21:37:42 -0500 Subject: [PATCH 10/14] update CHANGELOG --- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3895c2..4f9325e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,42 @@ +1.1.2 +--- +Daniel Nguyen (2): + Update common.c + Update common.c + +Drew Fustini (28): + upload to PyPI againt to resolve #293 + do not set pinmux on the beaglebone blue + remove deug output + Fix dead link to bone.js #296 + force Encoder period to be an integer #299 + Ignore new compiler warnings in gcc 8.2.0 + Update setup.py + do not set pin mode for built-in USRn LEDs + Change name of P1_3 to match bone.js + Fix warning about casting incompatible function types #308 + Fix warning print format strings being truncated #308 + Fix warning about casting incompatible function types #308 + Fix warnings on format truncation and sizeof in strncpy #308 + Fix warning about casting incompatible function types #308 + Update travis config to specify Python 3.6 + Update tox.ini to Python 3.6 + Merge pull request #321 from adafruit/issue308 + Update ISSUE_TEMPLATE.md + Update README.md + Update README.md + Merge pull request #327 from zer0cod3r/master + Merge pull request #337 from SamPovilus/docfix + Update README.md + Update README.md + Update README.md + remove -Werror from CFLAGS + Remove suppression of gcc warnings in CFLAGS #336 + Update version in setup.py to v1.2 + +Sam Povilus (1): + fixing document locaiton and version as current location dosn't load + 1.1.1 --- Attempt upload to PyPI again to avoid From dbecfcddad4399b8f0f51ad105a4572fa76e4261 Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Thu, 30 Jul 2020 21:26:13 -0500 Subject: [PATCH 11/14] add long_description_content_type to satisfy pypi Refer to https://packaging.python.org/guides/making-a-pypi-friendly-readme/ --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 184d71e..a6f5891 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ author_email = 'justin@adafruit.com', description = 'A module to control BeagleBone IO channels', long_description = open_as_utf8('README.md').read() + open_as_utf8('CHANGELOG.md').read(), + long_description_content_type = 'text/markdown', license = 'MIT', keywords = 'Adafruit BeagleBone IO GPIO PWM ADC', url = 'https://github.com/adafruit/adafruit-beaglebone-io-python/', From be710eaf9bbcd232cc627e7a3e7073fdc47fb9ac Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 28 Nov 2020 00:03:09 +0100 Subject: [PATCH 12/14] fix link error due multiple variables definitions Building with GCC 10.2.1 fails due linking errors caused by having multiple definitions of the variables defined in the source/constants.h header file. Fix this by moving the variables definition to the source/constants.c file, to avoid the variables to be defined each time that the header is included. While being there, use a single variable instead of having one for each object that is added to the module. --- source/constants.c | 50 ++++++++++++++++++++++++---------------------- source/constants.h | 13 ------------ 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/source/constants.c b/source/constants.c index 5e284c8..23753c6 100644 --- a/source/constants.c +++ b/source/constants.c @@ -35,39 +35,41 @@ SOFTWARE. void define_constants(PyObject *module) { - high = Py_BuildValue("i", HIGH); - PyModule_AddObject(module, "HIGH", high); + PyObject *object; - low = Py_BuildValue("i", LOW); - PyModule_AddObject(module, "LOW", low); + object = Py_BuildValue("i", HIGH); + PyModule_AddObject(module, "HIGH", object); - output = Py_BuildValue("i", OUTPUT); - PyModule_AddObject(module, "OUT", output); + object = Py_BuildValue("i", LOW); + PyModule_AddObject(module, "LOW", object); - input = Py_BuildValue("i", INPUT); - PyModule_AddObject(module, "IN", input); + object = Py_BuildValue("i", OUTPUT); + PyModule_AddObject(module, "OUT", object); - alt0 = Py_BuildValue("i", ALT0); - PyModule_AddObject(module, "ALT0", alt0); + object = Py_BuildValue("i", INPUT); + PyModule_AddObject(module, "IN", object); - pud_off = Py_BuildValue("i", PUD_OFF); - PyModule_AddObject(module, "PUD_OFF", pud_off); + object = Py_BuildValue("i", ALT0); + PyModule_AddObject(module, "ALT0", object); - pud_up = Py_BuildValue("i", PUD_UP); - PyModule_AddObject(module, "PUD_UP", pud_up); + object = Py_BuildValue("i", PUD_OFF); + PyModule_AddObject(module, "PUD_OFF", object); - pud_down = Py_BuildValue("i", PUD_DOWN); - PyModule_AddObject(module, "PUD_DOWN", pud_down); + object = Py_BuildValue("i", PUD_UP); + PyModule_AddObject(module, "PUD_UP", object); + + object = Py_BuildValue("i", PUD_DOWN); + PyModule_AddObject(module, "PUD_DOWN", object); - rising_edge = Py_BuildValue("i", RISING_EDGE); - PyModule_AddObject(module, "RISING", rising_edge); + object = Py_BuildValue("i", RISING_EDGE); + PyModule_AddObject(module, "RISING", object); - falling_edge = Py_BuildValue("i", FALLING_EDGE); - PyModule_AddObject(module, "FALLING", falling_edge); + object = Py_BuildValue("i", FALLING_EDGE); + PyModule_AddObject(module, "FALLING", object); - both_edge = Py_BuildValue("i", BOTH_EDGE); - PyModule_AddObject(module, "BOTH", both_edge); + object = Py_BuildValue("i", BOTH_EDGE); + PyModule_AddObject(module, "BOTH", object); - version = Py_BuildValue("s", "0.0.20"); - PyModule_AddObject(module, "VERSION", version); + object = Py_BuildValue("s", "0.0.20"); + PyModule_AddObject(module, "VERSION", object); } diff --git a/source/constants.h b/source/constants.h index 0f6fdf5..82ebe5e 100644 --- a/source/constants.h +++ b/source/constants.h @@ -1,19 +1,6 @@ #ifndef CONSTANTS_H #define CONSTANTS_H -PyObject *high; -PyObject *low; -PyObject *input; -PyObject *output; -PyObject *alt0; -PyObject *pud_off; -PyObject *pud_up; -PyObject *pud_down; -PyObject *rising_edge; -PyObject *falling_edge; -PyObject *both_edge; -PyObject *version; - void define_constants(PyObject *module); #endif From fe2e30a8a622de66a98b88ee307d6ed459fc4f85 Mon Sep 17 00:00:00 2001 From: Drew Fustini Date: Sun, 24 Jan 2021 22:09:43 -0800 Subject: [PATCH 13/14] Fix pwm output for ecap pins P9_28 and P9_42 #342 PWM outputs on P9_28 and P9_42 are part of the ECAP hardware block. This causes 'ecap' to be in the path instead of 'pwm'. For example: `/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0/pwm0` is one character longer than: `/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip4/pwm0` Thus the index in pwm_path must be adjusted for the ecap_path_udev path. This fixes issue #342 --- source/c_pwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/c_pwm.c b/source/c_pwm.c index 1756e5f..a5ef5ec 100644 --- a/source/c_pwm.c +++ b/source/c_pwm.c @@ -419,7 +419,7 @@ BBIO_err pwm_setup(const char *key, __attribute__ ((unused)) float duty, __attri snprintf(pwm_path_udev, sizeof(pwm_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? pwm_path[47] : pwm_path[66], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, pwm_path_udev: %s", key, pwm_path_udev); //ecap output with udev patch - snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? pwm_path[47] : pwm_path[66], p->index); + snprintf(ecap_path_udev, sizeof(ecap_path_udev), "%s/pwm-%c:%d", pwm_chip_path, dmtimer_pin ? pwm_path[47] : pwm_path[67], p->index); syslog(LOG_DEBUG, "Adafruit_BBIO: pwm_start: key: %s, ecap_path_udev: %s", key, ecap_path_udev); // Export PWM if hasn't already been From 57e630c1552ba12688995d4e201df6073002bea8 Mon Sep 17 00:00:00 2001 From: omerk Date: Sat, 22 Apr 2023 23:15:33 +0100 Subject: [PATCH 14/14] fix compilation for newer versions of Python PyEval_ThreadsInitialized() and PyEval_InitThreads() are deprecated and break the build, adding a version check to ignore if we are compiling with a newer Python version. --- source/py_gpio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/py_gpio.c b/source/py_gpio.c index 2721cca..99cb0e7 100644 --- a/source/py_gpio.c +++ b/source/py_gpio.c @@ -599,8 +599,10 @@ PyMODINIT_FUNC initGPIO(void) initlog(LOG_INFO, NULL, BBIO_LOG_OPTION); +#if PY_VERSION_HEX < 0x03090000 if (!PyEval_ThreadsInitialized()) PyEval_InitThreads(); +#endif if (Py_AtExit(event_cleanup) != 0) {