Private
Public Access
2
0
Commit Graph

39 Commits

Author SHA1 Message Date
Brendan Le Foll
ffcf3d7d07 clang-format: run clang-format on C/C++ code
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2015-03-23 15:15:48 +00:00
Kurt Eckhardt
41956b07d6 pwm.c: cache period
There is an issue that  mraa_pwm_write would fail, because mraa_pwm_read
would fail and return 0.  When the read fails, journalctl shows an
error:
Dec 28 18:01:38 Edison libmraa[365]: pwm: Error in reading period

So now trying version, where the pwm object caches the period, that is
updated whenever you do a read or write of the period.  Side benefit is
that the write should be sped up.

Signed-off-by: Kurt Eckhardt <kurte@rockisland.com>
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2015-01-05 15:24:28 +00:00
Brendan Le Foll
acc3476326 pwm.c: Fix error in mraa_pwm_read_duty
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-12-02 10:50:17 +00:00
Brendan Le Foll
7ad78d01e5 pwm.c: Fix error in mraa_pwm_read_period
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-12-02 10:37:44 +00:00
Brendan Le Foll
0289c63c4c pwm.c: remove possibility of division by 0
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-11-26 14:00:17 +00:00
Brendan Le Foll
9f3cc6e890 pwm.c: check error condition when doing read operations
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-11-26 13:59:59 +00:00
Henry Bruce
7aea3459a9 pwm.c: Must write period before duty_cycle to avoid sysfs error
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
2014-11-20 15:08:31 +00:00
Thomas Ingleby
5d7c85c7a1 pwm: move pwm setup to module
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-11-17 17:41:47 +00:00
Matthias Hahn
cf6c3dd144 pwm: syslog message typo correction
Signed-off-by: Matthias Hahn <matthias.hahn@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-11-06 15:23:25 +00:00
Thomas Ingleby
3b01af1da1 pwm: add period limits, warn over syslog
Added minimum, maximum and default period settings to board definitions
PWM will now have a default period as defined in the board defintion.
When using pwm_write() writing 1.0f or above will default to 100%.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-10-30 12:22:40 +00:00
Maximilian von Tschirschnitz
a202b3fd17 pwm: fixed wrong line ending being checked by strtol
Move from fopen to POSIX open introduced this bug in strtol

Signed-off-by: Maximilian von Tschirschnitz <maximilian.tschirschnitz@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-10-29 13:01:53 +00:00
Brendan Le Foll
a6b3d384b2 syslog: unify error msg style
syslog messages should be written as <module>: Message in order to increase
readability and usefulness

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-10-22 21:09:11 +01:00
Thomas Ingleby
c5102dffba pwm: fix incorrect hook check
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-10-08 14:59:37 +01:00
Brendan Le Foll
2b5e38b40c coverity: Fix issues found by coverity scan
* Fix a few resource leaks in error conditions
* Makes strtol() calls safer in pwm module
* Make sure buffer is terminated after read() in aio

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-10-03 22:50:18 +01:00
Brendan Le Foll
32d8a6f0ca syslog: remove all fprintf calls and use syslog instead
Syslog is now used for all error messages, return values in the code should be
used by programmers to see the status of the library/board and syslog can be
used to see quickly from a debugging perspective what has gone wrong. A few
cosmetics where improved as well as a mraa_set_log_level() call where the
syslog log mask can be set directly from libmraa.

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-09-25 14:31:04 +01:00
Thomas Ingleby
dd9129d411 hook: add pwm hook around init
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-09-09 18:01:23 +01:00
Mark Ceisel
9cf6cad45a pwm: add config_ms and config_percent.
* Allows user to set both at the same time. Will reset to previous if
* period for duty cycle fails to write

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-09-01 12:18:01 +01:00
Thomas Ingleby
a8bbd55562 pwm: rename internal functions from get to read
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-09-01 11:30:58 +01:00
Thomas Ingleby
595eec2737 pwm: move internal context structure to internal header
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-07-24 14:21:06 +01:00
Thomas Ingleby
715863cd28 pwm: add period write replace hook
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-07-24 14:20:01 +01:00
Thomas Ingleby
6853997a92 mraa: rename from maa to mraa
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-24 17:24:54 +01:00
Thomas Ingleby
3e88578754 pwm: disable pwm before unexporting
Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-06-20 16:26:08 +01:00
Brendan Le Foll
0fe7bd335c src: add unistd.h to pwm and spi modules to remove compiler warnings
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-22 14:54:19 +01:00
Brendan Le Foll
55403793e3 pwm: equality comparison should be assignment
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-22 14:53:18 +01:00
Thomas Ingleby
a2c7eb5458 pwm: made export functions static
* removed functions from external api also.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-05-21 14:56:11 +01:00
Thomas Ingleby
7cc5d6b2b8 pwm: fix writing of period
Incorrect value attempted to be written

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-05-21 14:49:32 +01:00
Thomas Ingleby
2b8ab38418 maa: hide and rename internal maa functions
Based on feedback received. All check functions renamed to setup.
Update all modules to use new name and header.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-05-21 13:17:16 +01:00
Thomas Ingleby
5fa6f50edc pwm: added existing exposition logic
* Understands when pwm pin is already exported.
* Will not unexport if didnt export. Can be forced.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-20 14:07:19 +01:00
Thomas Ingleby
fa7180cb91 pwm: use posix open instead of fopen
* Add safety to output char arrays and filepaths.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-20 10:57:20 +01:00
Thomas Ingleby
0c82a47fe4 pwm: changed to use strtol for return values.
* Minor spelling corrections
* Small format change in function. Incorrect spacing.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-19 10:49:41 +01:00
Thomas Ingleby
6333a21c6f pwm: removed disabling pin on unexport.
Needed to be handled differently based on the running platform

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-19 10:49:36 +01:00
Brendan Le Foll
f0763844fa pwm.hpp: Add C++ wrapper around Pwm
* maa_pwm_context becomes an opaque pointer
* C++ wrapper class Pwm
* swig now uses C++ wrapper Pwm to generate API

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-16 14:31:36 +01:00
Brendan Le Foll
5141d24565 pwm: always return a value if stated in prototype
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-13 22:18:22 +00:00
Thomas Ingleby
171f66208e pwm: Use pinmap functions for setting up pwm.
* Intended function of check_pwm also checks for conflicting gpio, due
* to quirk on galileo rev d, functionality commented.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-05-06 15:33:54 +01:00
Brendan Le Foll
09cec0931b swig: add unexport() calls to be used by destructors in object api
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-05-02 16:33:36 +01:00
Thomas Ingleby
ccc4544455 pwm: Updated API
* Greater use of maa_result_t
* Added raw mode.
* Updated cycle-pwm3 to use new api.

Signed-off-by: Thomas Ingleby <thomas.c.ingleby@intel.com>
2014-04-30 10:30:56 +01:00
Brendan Le Foll
f280b3c0f6 maa: change struct names to be more unique and fix allocs
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-04-28 11:31:53 +01:00
Brendan Le Foll
ed0a1f6085 maa: change the linking of maa and make gpio functions match maa_ spec
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-04-27 23:11:31 +01:00
Brendan Le Foll
a5a407e4b5 MAA version 0.2.0 moves to a standard C API
* Removed all C++ code and renamed all .cxx extensions to .c
* All functions are renamed to maa_ and modules are for example called maa_pwm
* Cmake can now 'make doc' using a Doxyfile.in to create documentation
* examples/ have been updated but swig generated API is untested

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2014-04-27 21:17:54 +01:00