Commit graph

63 commits

Author SHA1 Message Date
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
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
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
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
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
Aaron Marburg
e061d1358e Added usleep after successfully enabling PWM via udev. 2018-04-12 22:46:49 +00: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
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
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
Drew Fustini
f267ec01b1 minor change to pwm debug logging 2017-11-01 09:11:44 +00:00
Drew Fustini
58eb54679c Attempt to use udev ecap path for pwm path
Example of pwm and ecap paths for pwm outputs in the 4.14 kernel:

/sys/devices/platform/ocp/48300000.epwmss/48300100.ecap/pwm/pwmchip0/pwm-0:0/duty_cycle
/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:0/duty_cycle
/sys/devices/platform/ocp/48300000.epwmss/48300200.pwm/pwm/pwmchip1/pwm-1:1/duty_cycle
/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm-3:0/duty_cycle
/sys/devices/platform/ocp/48302000.epwmss/48302200.pwm/pwm/pwmchip3/pwm-3:1/duty_cycle
/sys/devices/platform/ocp/48304000.epwmss/48304100.ecap/pwm/pwmchip5/pwm-5:0/duty_cycle

Note that the ecap path is longer than pwm path by 1 character
2017-11-01 09:05:12 +00:00
Drew Fustini
705368d91e only check kernel overlays if u-boot overlays are not being used 2017-11-01 04:15:08 +00:00
Drew Fustini
5af654ca14 change fprintf() to syslog() 2017-10-31 07:19:53 +00:00
Drew Fustini
8e08a40f14 move pwm_set_polarity() after period is set 2017-10-31 06:39:20 +00:00
Drew Fustini
73ea172d21 remove polarity "hack" for PWM #170 2017-10-31 05:37:14 +00:00
Drew Fustini
1b3dab6950 add "Adafruit_BBIO" to syslog() 2017-10-31 03:53:02 +00:00
Robert Nelson
c35e4cb98a source/c_pwm.c: disable pwm_set_polarity (broken in v4.9.x/v4.14.x)
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-10-12 16:33:43 -05:00
Robert Nelson
02c6ca5924 source/c_pwm.c: pwm: add support for pwmchipX/pwm-X:Y syntax
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-10-12 16:31:20 -05:00
Robert Nelson
2d5a88aee9 source/c_pwm.c: debug pwm_path/pwm_path_udev
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-10-12 16:05:23 -05:00
Robert Nelson
d201c910ec source/c_pwm.c: HACK: PocketBeagle: v4.14.x
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-10-12 16:00:43 -05:00
Robert Nelson
4e180c54cf source/c_pwm.c: HACK: U-Boot pre-setup everything, dont search for specific overlay
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
2017-10-12 15:04:17 -05:00
cocasema
6c489fce8e Add syslog and debugging messages 2017-03-31 02:16:21 -07:00
Drew Fustini
6d78f9db06 Fix gcc warnings about comparing signed and unsigned values
warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
2017-01-11 09:14:38 +00:00
Drew Fustini
b1ad088164 Fix unused parameter warning [-Werror=unused-parameter] 2017-01-10 10:52:01 +00:00
Drew Fustini
67e0f61f9c add PWM test for ecap0 (P9_42) and ecap2 (P9_28) 2016-12-20 10:26:19 +00:00
Drew Fustini
f58cabef1d Use pin mode "pwm2" for P9_28 2016-12-20 09:46:50 +00:00
cocasema
efc0a25f65 Treat warnings as errors 2016-10-18 21:59:24 -07:00
Jesse McLachlan
207526e91d Move BBBVERSION41 pwm disable logic into pwm list iterator.
Outside the list iteration loop it causes a seg fault from writing to a closed/invalid handle if PWM.stop is called when the PWM is not open
2016-10-10 14:58:52 +11:00
Matthew West
0620b43818 Bugfix: add missing read call 2016-08-30 09:46:56 -06:00
Matthew West
6759d58b91 Remove some trailing whitespace 2016-08-29 21:21:50 -07:00
Matthew West
f48e60d501 When setting up a PWM pin, read period_ns & duty_ns 2016-08-29 21:20:40 -07:00
Matthew West
ddbf6c354f Fix initialization weirdness with pwm_set_frequency 2016-08-10 15:29:51 -07:00
Matthew West
99e27ad39e Add a safeguard if we didn't start 2016-08-10 15:29:29 -07:00
Matthew West
f4fcd12c2f Move a common variable out of #ifdef and #else 2016-08-10 15:29:11 -07:00
Matthew West
149129c3f5 Initialize ocp_dir before use 2016-08-10 15:09:14 -07:00
Matthew West
0b8def4cb5 Bugfixes based on CircleCI (regressions introduced on 3.8) 2016-08-08 15:26:38 -07:00
Matthew West
b6cf76fa0b Small bugfix to setting frequency 2016-08-08 11:26:42 -07:00
Matthew West
ac1104c55b Fix bug with setting frequency, fix stopping 2016-08-08 11:18:27 -07:00
Matthew West
8fe1336b0a Bug fixes almost to stability 2016-08-08 10:51:15 -07:00
Matthew West
298334a814 Bug fixes to 4.1+ PWM code 2016-08-05 13:27:42 -07:00
Matthew West
6b2aa7aabc Change return value convention for errors
Replace 1 for success and 0/-1 for failure with an enum type.
2016-08-05 13:19:54 -07:00
Matthew West
599ec57f4c Fix PWM in Linux 4.1+ 2016-08-05 10:16:34 -07:00
Matthew West
a2a88fb21a Move PWM exporting to its own function 2016-08-05 09:58:04 -07:00
Tony DiCola
5c8db6b80d Fix #67 and fix compiler warnings. 2014-10-03 23:24:10 +00:00