Commit graph

269 commits

Author SHA1 Message Date
omerk
57e630c155 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.
2023-04-22 23:15:33 +01:00
Drew Fustini
fe2e30a8a6
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
2021-01-24 22:09:43 -08:00
Javier Martinez Canillas
be710eaf9b
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.
2020-11-28 00:47:41 +01:00
Darren Schachter
af9ea512e8 Remove unnecessary conditional 2020-07-24 10:45:40 -04:00
Darren Schachter
db0adf258c Fix udev PWM path for DMTimer pins 2020-07-23 12:01:49 -04:00
Darren Schachter
928e8dc499 Add udev PWM path for DMTimer pins 2020-07-22 15:25:24 -04:00
Darren Schachter
1c012a42ed Add missing comma 2020-07-22 14:58:03 -04:00
Darren Schachter
1151dd9a8c Add dmtimer PWM entries in table for BBB 2020-07-22 14:05:10 -04:00
Darren Schachter
dcdb1adae9 Improve error logging 2020-07-22 13:50:37 -04:00
Darren Schachter
4149f2d4bc Change path for dmtimer PWM pins 2020-07-22 12:16:49 -04:00
Darren Schachter
0f9f472e36 Add is_dmtimer_pin function 2020-07-22 11:50:20 -04:00
Darren Schachter
c70c9bad97 Add dmtimer PWM entries in table for PocketBeagle 2020-07-22 10:36:03 -04:00
Sam Povilus
40f1160ac3 fixing document locaiton and version as current location dosn't load 2020-07-02 19:54:43 -06:00
Daniel Nguyen
61c29a1ecd
Update common.c 2020-03-07 14:19:39 -08:00
Daniel Nguyen
0be8cb5231
Update common.c
Added UART4 to Pocketbeagle
2020-03-07 14:15:49 -08:00
Drew Fustini
eca84d64d7 Fix warning about casting incompatible function types #308
Debian 10 (Buster) has gcc 8.2 which warns about:

cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’

The solution is to cast to '(PyCFunction)(void *)'
2019-12-11 09:06:12 +00:00
Drew Fustini
7fb13f9f3d Fix warnings on format truncation and sizeof in strncpy #308
Debian 10 (Buster) has gcc 8.2 which warns about:

source/c_pwm.c:459:65: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess]
source/c_pwm.c:396:43: error: ‘%s’ directive output may be truncated writing up to 199 bytes into a region of size 100 [-Werror=format-truncation=]
2019-12-11 09:03:44 +00:00
Drew Fustini
3a5d23d01b Fix warning about casting incompatible function types #308
Debian 10 (Buster) has gcc 8.2 which warns about:

cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’

The solution is to cast to '(PyCFunction)(void *)'
2019-12-06 10:26:49 +00:00
Drew Fustini
9298393cf5 Fix warning print format strings being truncated #308
Debian 10 (Buster) has gcc 8.2 which warns about:

error: ‘%s’ directive output may be truncated writing up to 19 bytes into a region of size between 10 and 59 [-Werror=format-truncation=]
  snprintf(path, sizeof(path), "%s/%s/state", ocp_dir, pinmux_dir);
2019-12-06 10:24:47 +00:00
Drew Fustini
7032af7e5f Fix warning about casting incompatible function types #308
Debian 10 (Buster) has gcc 8.2 which warns about:

cast between incompatible function types from ‘PyObject * (*)(PyObject *, PyObject *, PyObject *)’

The solution is to cast to '(PyCFunction)(void *)'
2019-12-06 10:20:18 +00:00
Drew Fustini
b867bbffe3
Change name of P1_3 to match bone.js 2019-04-03 00:21:27 +01:00
Drew Fustini
5df30a8b73
do not set pin mode for built-in USRn LEDs
This fix resolves Adafruit_BBIO issue #310 and https://github.com/adafruit/Adafruit_Blinka/issues/96 which was preventing the USR LEDs from being used by the CircuitPython Blinka library
2019-04-01 03:10:02 +01:00
Drew Fustini
2cfded3459
Fix dead link to bone.js #296 2018-12-10 07:32:21 -06:00
Drew Fustini
e96e1efb53 remove deug output 2018-11-23 05:35:27 +00:00
Drew Fustini
96aa8ed2aa do not set pinmux on the beaglebone blue
beaglebone blue has complete dtb file and does not need pinmux set for gpio ports
2018-11-23 04:54:32 +00:00
Drew Fustini
1f7c20e899 remove debug logging 2018-10-17 14:59:09 -05:00
Drew Fustini
c09ab8ee43 fix pwm on pocketbeagle and beaglebone blue #286
pocketbeagle and beaglebone blue have complete dtb file
and do not need overlays
2018-10-17 14:56:11 -05:00
Drew Fustini
b1ee5998f0
Merge pull request #285 from sam-bristow/bugfix/uart-error-reporting
Return error-code for problem UART interface
2018-10-11 11:26:28 -05:00
Sam Bristow
448854c209 Return error-code for failing interface
Rather than returning the error code for UART1 regardless of which
interface had problems, we should return the error code for the
interface that actually had an error.

Pretty sure this was a simple copy-paste mistake.
2018-10-09 23:57:20 +13:00
Sam Bristow
eff11b83fe Use print() function in all code and docs
Low-hanging fruit of Python3 compatibility work.

I've left fix_py_compile.py as it is only ever going to be run under
Python 2.
2018-10-09 23:34:26 +13:00
Drew Fustini
7affea78fd do not load overlays for the beaglebone blue #283
beaglebone blue has complete dtb file and does not need overlays

refer to issue 283:
https://github.com/adafruit/adafruit-beaglebone-io-python/issues/283
2018-10-07 22:10:02 +00:00
Erik Welsh
e626f07d8d Fixed GPIO export problem; Leaves GPIO in bad state on latest BeagleBone image on PocketBeagle 2018-09-30 16:24:33 +00:00
Drew Fustini
c749402003
Add UART entries for the PocketBeagle (issue #242)
PocketBeagle pins with UART pin mode:

  P1_30 uart0_txd
  P1_32 uart0_rxd
  P2_11 uart1_rxd
  P2_09 uart1_txd
  P1_08 uart2_rxd
  P1_10 uart2_txd
  P2_29 uart3_txd

Available UART names on PocketBeagle:

 PB-UART0: /dev/ttyO0, Rx: P1_30, Tx: P1_32
 PB-UART1: /dev/ttyO1, Rx: P2_11, Tx: P2_09
 PB-UART2: /dev/ttyO2, Rx: P1_08, Tx: P1_10
 PB-UART3: /dev/ttyO3, Rx: P2_29, Tx: none

Signed-off-by: Drew Fustini <drew@pdp7.com>
2018-08-31 04:10:47 -05:00
Drew Fustini
bbf0927781
Merge pull request #251 from amarburg/master
Added usleep after successfully enabling PWM via udev.
2018-06-26 11:16:03 -05:00
zserg
3265d156e4 * Minor style fixes
* Added comments
* Added debug logging
* Line 724 - now <initial> flag is properly reset upon removal of event detection from GPIO pin
2018-05-31 18:10:26 +01:00
zserg
b054cc083e * Fixed SEGFAULT in event_gpio,c run_callbacks()
* Added more elaborate epoll() error logging
2018-05-30 16:47:47 +01:00
Aaron Marburg
e061d1358e Added usleep after successfully enabling PWM via udev. 2018-04-12 22:46:49 +00:00
zserg
e9c70f7d23 * Fixed SEGFAULT when calling remove_event_detect() inside python callback function. 2018-02-18 00:06:57 +00:00
Drew Fustini
8dfbf64c36
Fix spidev path mismatch (#216)
Remove unnecessary call to get_spi_bus_path_number()
and use the bus and device passed to SPI_open().

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-12-01 06:36:50 -06:00
Drew Fustini
61af64e734
use set_pin_mode() to set uart pinmux (#158)
Use set_pin_mode() to set pinmux for UART
RX and TX pins. This is similar effect as
running the config-pin utility.

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-30 22:39:14 -06:00
Drew Fustini
a22cd5fd24
Fix seg fault of PWM in Python 3.6 (#189)
PWM.set_frequency() and PWM.set_duty_cycle()
were resulting in a seg fault inside the
call to PyArg_ParseTupleAndKeywords().

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-25 05:24:44 -06:00
Drew Fustini
503e8397e6
Fix leak of pwm enable file descriptor (#197)
Make sure that the file descriptor for pwm enable
is closed along with the other pwm file descriptors

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-24 00:29:04 -06:00
Drew Fustini
f82ba3a1ec
close enable_fd when stopping PWM output (#197)
Issue #197: JesseMcL raised the issue that running
PWM.start() and PWM.start() in a loop will eventually
exhaust the number of open file descriptors and
PWM.start() will raise the error:

  RuntimeError: problem with sysfs file.

The file descriptor for the enable file should
be closed in pwm_disable() to avoid the leak

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-22 04:38:14 -06:00
Drew Fustini
32814797ff
cache board type to avoid poor performance (#196)
cache board type to avoid poor performance
in functions that are called frequently like
gpio_set_value() in source/event_gpio.c

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-18 23:18:21 -06:00
Drew Fustini
b328cddd13
Fix PocketBeagle PWM pin typo (#192)
ehrpwm0 channel 1 is  P1_33 on a the PocketBeagle

Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-17 03:23:29 -06:00
Drew Fustini
335e105bc1
Comment out debug log in gpio hotpath #188
Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-08 17:43:19 -06:00
Drew Fustini
794d7136b4 Change log level from INFO to DEBUG #188
Signed-off-by: Drew Fustini <drew@pdp7.com>
2017-11-08 03:16:47 -06:00
Drew Fustini
ca0a4afcdb Filter DEBUG syslog to avoid poor performance #188 2017-11-08 03:03:52 -06:00
Drew Fustini
b65cbf8e41 sleep to avoid udev race condition #185
sleep 100 ms after export to avoid race condition as udev
needs the opportunity to set group ownership and permission

Test instructions:
==================
reboot, log back in, wait for udev to set group ownership and permission:

$ ls -la /sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip6/export
-rw-rw---- 1 root pwm 4096 Nov  2 04:02 /sys/devices/platform/ocp/48304000.epwmss/48304200.pwm/pwm/pwmchip6/export

run test program:

python ~/issue185.py

contents of test program:

import Adafruit_BBIO.PWM as PWM
PWM.start("P8_13", 50, 1000, 0)
PWM.stop("P8_13")
PWM.cleanup()
2017-11-02 04:08:48 +00:00
Robert Nelson
1ead3f90eb source/common.c: PocketBeagle Fix P2.24
I copied the initial schematic when i setup this pinmux table...

Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-11-01 21:24:30 -05:00