Compare commits
814 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
52f9c48bbc | ||
|
0fabc9b46a | ||
|
21bea74b74 | ||
|
8b02c419f8 | ||
|
296ed38227 | ||
|
14de175425 | ||
|
63a29e92ea | ||
|
49ab97f81c | ||
|
319c932036 | ||
|
35b2426170 | ||
|
8c0aa5af2c | ||
|
a7c688b867 | ||
|
6fc2bef13f | ||
|
747429ca7e | ||
|
c302269750 | ||
|
de0b9e72c6 | ||
|
2fb577d348 | ||
|
30322f8ac5 | ||
|
5cfddd6bcc | ||
|
a17079c460 | ||
|
fac9d99f01 | ||
|
ec267c3482 | ||
|
df2e131d26 | ||
|
317c85ecb6 | ||
|
f1f578363a | ||
|
0fb2aed7af | ||
|
405e601387 | ||
|
0e5dadeb8c | ||
|
9a5abb7d56 | ||
|
334a57be11 | ||
|
1d4f721d4f | ||
|
67eaf78fbf | ||
|
451dcbad6c | ||
|
a52ce5d5bb | ||
|
de42b9558f | ||
|
9b157e6f19 | ||
|
915be98d03 | ||
|
420486519b | ||
|
91452e5c83 | ||
|
5789f5001d | ||
|
7088527339 | ||
|
f07a442860 | ||
|
2919b38b15 | ||
|
603834461f | ||
|
537a69923b | ||
|
59107f0a29 | ||
|
612f566c99 | ||
|
cae63bbd52 | ||
|
04f7cbff5d | ||
|
4b76fbd14c | ||
|
78caa990f1 | ||
|
f2cbe1c68d | ||
|
10e1301bef | ||
|
edd554b606 | ||
|
168764481a | ||
|
3397c95c0a | ||
|
95c259f6b2 | ||
|
6c83886a51 | ||
|
143bc38e47 | ||
|
a51f3a939f | ||
|
65dc2e7ea3 | ||
|
14617d0f36 | ||
|
076a648ef9 | ||
|
51c60a0ac4 | ||
|
85a848960a | ||
|
a797003ec6 | ||
|
53058d500b | ||
|
029e08669c | ||
|
12b5130c1a | ||
|
237308898c | ||
|
b1fd66c561 | ||
|
bc1c3469f5 | ||
|
44b2367fdc | ||
|
d313ac0579 | ||
|
9d497e08cd | ||
|
0633cd4145 | ||
|
8230d7cb45 | ||
|
d8024bb516 | ||
|
29ddf56b67 | ||
|
3b9c4f2bad | ||
|
7f78b6760f | ||
|
441a24aaea | ||
|
9c2f3c83c9 | ||
|
65514bb432 | ||
|
c770c4c669 | ||
|
511332cda5 | ||
|
82cfa32f70 | ||
|
a387d5e4d4 | ||
|
df8d471cfb | ||
|
350a6489ee | ||
|
389d0ceafd | ||
|
8e8ed7d52d | ||
|
2b73083955 | ||
|
f9501c5c78 | ||
|
3b2a5b8429 | ||
|
00e8f72ef4 | ||
|
e354c59b6c | ||
|
ca11078fd0 | ||
|
6b3794003f | ||
|
699d476de1 | ||
|
0899f1e995 | ||
|
baa1fcf7be | ||
|
32d36dfbd0 | ||
|
2a6bf2b16d | ||
|
b33bd5ccd2 | ||
|
1865dd0ba1 | ||
|
944670f66a | ||
|
839bdb9011 | ||
|
a73882240b | ||
|
43ae362be8 | ||
|
6bf706befb | ||
|
1fd4ed5736 | ||
|
d2fcb88c4b | ||
|
cb4c9152d6 | ||
|
61011df748 | ||
|
d04911d569 | ||
|
1f57c6c082 | ||
|
51340c6289 | ||
|
14960c4190 | ||
|
c101117ece | ||
|
9202eb172d | ||
|
3e1c528571 | ||
|
1ce28ee082 | ||
|
8710280142 | ||
|
cc4fe26c09 | ||
|
084883c210 | ||
|
04f3b93f85 | ||
|
5c10ad05ee | ||
|
1015beec47 | ||
|
67f5ab7346 | ||
|
1f41b2f97e | ||
|
7fce2e2a3a | ||
|
44e705a518 | ||
|
8ff42482ec | ||
|
3924070171 | ||
|
ff31d6763c | ||
|
ba5318fee9 | ||
|
2e5e3eaea2 | ||
|
078218f680 | ||
|
c86fe2a12b | ||
|
8b68f3040e | ||
|
c564dad68f | ||
|
ecc04d7511 | ||
|
c63e38a57e | ||
|
78a4d12a37 | ||
|
0aed0003ff | ||
|
bdb5ef66e9 | ||
|
caebb8b1fb | ||
|
ab14b9de43 | ||
|
7e302242db | ||
|
3483db363f | ||
|
c2681dc78c | ||
|
6c0881848b | ||
|
03d741ff3e | ||
|
0ebab9603e | ||
|
a87a104efe | ||
|
6d391ce605 | ||
|
63604ef5cc | ||
|
a708e08101 | ||
|
8c40842e4b | ||
|
ed0124cc70 | ||
|
86a0e10c03 | ||
|
7f85f2bbdb | ||
|
92cc9ea176 | ||
|
ff6b304fd2 | ||
|
2bb00b494f | ||
|
d430b5c2b5 | ||
|
ea183b3738 | ||
|
d4b32ec1c5 | ||
|
e98bd8653a | ||
|
ff34651325 | ||
|
58cf292dfc | ||
|
15e400eaf2 | ||
|
8862ebd9f2 | ||
|
79609ba359 | ||
|
27c097e82e | ||
|
725ce5e946 | ||
|
fd531abd3d | ||
|
f4385a8b82 | ||
|
ee69045ea8 | ||
|
fcfdeb1304 | ||
|
d5233adbf9 | ||
|
4ffb094063 | ||
|
8e4a809f12 | ||
|
5f01de1bf1 | ||
|
7703634bc5 | ||
|
6a85c57c06 | ||
|
924f4b4799 | ||
|
3429b5383d | ||
|
bd4f6998a7 | ||
|
11211936b6 | ||
|
7ea11f0dd3 | ||
|
c1d081c783 | ||
|
ae80d4afc8 | ||
|
131021a629 | ||
|
0049ba1378 | ||
|
448f14f41c | ||
|
fbfe3e315f | ||
|
b77bf40c34 | ||
|
cb09ff2327 | ||
|
e975a690ab | ||
|
3750e2cfa2 | ||
|
e7e58509f0 | ||
|
8d7c0722ab | ||
|
0bd1ab2c53 | ||
|
edb7f8a215 | ||
|
219632a1b8 | ||
|
8a548de8ae | ||
|
13086cb2db | ||
|
069985641e | ||
|
657f28a67d | ||
|
2df28fa883 | ||
|
078b6371d7 | ||
|
7a55a1384a | ||
|
dc240913c7 | ||
|
4c41d2c2df | ||
|
e5f28ab04c | ||
|
325ac461d6 | ||
|
7fa4990d81 | ||
|
3b55cc70bf | ||
|
65614f5f58 | ||
|
529cf8a26e | ||
|
acfb74f04e | ||
|
2c97fd5953 | ||
|
b192e7a223 | ||
|
2b9e832ff9 | ||
|
d8c2c7c483 | ||
|
8c19105309 | ||
|
ba9ab4b384 | ||
|
d920d136ea | ||
|
0f312545e0 | ||
|
1947426baf | ||
|
f9a31956ab | ||
|
d80e4295aa | ||
|
36fabe3245 | ||
|
c0dfb71237 | ||
|
47ec54c333 | ||
|
38aa9e8fe6 | ||
|
5e0c6d3807 | ||
|
b2e8af641b | ||
|
e14534b071 | ||
|
5cf54fdbc2 | ||
|
759d387c5a | ||
|
ccafc77641 | ||
|
2dd94cda3b | ||
|
b1016635c3 | ||
|
c7a405a531 | ||
|
063a3154aa | ||
|
5f4f0a2aef | ||
|
1c7bd53bf3 | ||
|
efc79d13c0 | ||
|
e8cb060f4e | ||
|
93839d4865 | ||
|
caaf36dfb6 | ||
|
8d252c62cd | ||
|
57b3775ae9 | ||
|
2dd46494ff | ||
|
5b1068fc62 | ||
|
bde9715c94 | ||
|
90accf7b04 | ||
|
fa772a0a9d | ||
|
80024ff184 | ||
|
049ba5fa9f | ||
|
937a38c4ac | ||
|
cd4626852d | ||
|
8e63c718e4 | ||
|
51436f6a0a | ||
|
0836067900 | ||
|
c89b04eb19 | ||
|
6aaf48940e | ||
|
bf803209aa | ||
|
799f1409b9 | ||
|
df8492a8f7 | ||
|
63ff901674 | ||
|
f9af006c97 | ||
|
621bf5266e | ||
|
338feb2c3e | ||
|
dbd1a31536 | ||
|
3c3136d43a | ||
|
b8e1f79b4d | ||
|
e6c3dd24a6 | ||
|
3059c06fa0 | ||
|
24d4446193 | ||
|
18249d5ecc | ||
|
31750be753 | ||
|
a7414edca3 | ||
|
06e5e7dc11 | ||
|
42d169e003 | ||
|
bda9f4d211 | ||
|
0e44dfac44 | ||
|
013c04c7b9 | ||
|
b7a0968489 | ||
|
2db72217d5 | ||
|
08fe460772 | ||
|
70600dece4 | ||
|
eae2b58cbe | ||
|
7d11bd4cdc | ||
|
effc813e42 | ||
|
32aa4310c8 | ||
|
434f454139 | ||
|
1a29dc9910 | ||
|
0aac9df414 | ||
|
e2aaa349ff | ||
|
0071039fa0 | ||
|
35760929db | ||
|
c9c6ac785a | ||
|
5c7bab1c79 | ||
|
b650a9fdc9 | ||
|
f245cacd6f | ||
|
99b7f131d9 | ||
|
54bf18b246 | ||
|
17eb7a791a | ||
|
1937473c01 | ||
|
a0791f8277 | ||
|
3934897864 | ||
|
679d1a55b6 | ||
|
b2a0bbfcbc | ||
|
07343e2ee7 | ||
|
fc55088c03 | ||
|
a49d8d6d12 | ||
|
2101e491ce | ||
|
6284806b96 | ||
|
3e76bee085 | ||
|
ba85c9ebc2 | ||
|
b841d6c75c | ||
|
c03d746544 | ||
|
c84cd4328a | ||
|
570fba9463 | ||
|
4757d039ab | ||
|
eb5a3ac5d2 | ||
|
5bd5f2d546 | ||
|
4031124081 | ||
|
b109a12dd1 | ||
|
308289497e | ||
|
4acb0e5562 | ||
|
b20a685b0c | ||
|
79e33890b6 | ||
|
7c5972ad15 | ||
|
c9cfb42326 | ||
|
93d326bff4 | ||
|
89d25cffeb | ||
|
99901d05f7 | ||
|
33645791af | ||
|
453eefc56a | ||
|
001e291d63 | ||
|
802c5af986 | ||
|
11bf69e29a | ||
|
7058fea8bd | ||
|
99593ec640 | ||
|
13118e949b | ||
|
30cf8ec560 | ||
|
5740e46ae0 | ||
|
d5e5539be3 | ||
|
7ada55982d | ||
|
6302b635aa | ||
|
4a6bf832bc | ||
|
1c9b87bfd3 | ||
|
e353508e30 | ||
|
e170e21031 | ||
|
6dfe6ff6bc | ||
|
8f48df0533 | ||
|
22a930e39e | ||
|
dc6a585991 | ||
|
f95f2d8b35 | ||
|
ba348a2da4 | ||
|
cfff6c3c98 | ||
|
59ab125f7e | ||
|
c80883621e | ||
|
e9a7415ee7 | ||
|
0256b680f1 | ||
|
86d974417c | ||
|
37262fce93 | ||
|
2504e36e5f | ||
|
02399b61f9 | ||
|
af533deffe | ||
|
79f1571c32 | ||
|
bfac49e653 | ||
|
d547cda05b | ||
|
cb97f24edd | ||
|
9b9a5ab168 | ||
|
5d24868582 | ||
|
0ad753689e | ||
|
8390c5cfb7 | ||
|
3f51ebaaf1 | ||
|
8269340c25 | ||
|
b3768ddb7c | ||
|
832d7901d5 | ||
|
45133922aa | ||
|
ef28607cea | ||
|
2c4389c2a1 | ||
|
80485c942d | ||
|
fe2512c500 | ||
|
ba2a7cb776 | ||
|
49d70cd2a9 | ||
|
f8752b7a09 | ||
|
9e67788eb0 | ||
|
a1c9db505e | ||
|
9c0753cb18 | ||
|
5717bba0d4 | ||
|
6d39902a8a | ||
|
e481026227 | ||
|
73e9c2859d | ||
|
296172d385 | ||
|
8609dada2c | ||
|
a5d13670f4 | ||
|
9c93eeb323 | ||
|
df0dbb0c73 | ||
|
f5d6a6dc18 | ||
|
7a2408766c | ||
|
184a71aaa1 | ||
|
7f34a5c9cf | ||
|
8734a42377 | ||
|
f9dd4c06de | ||
|
5131349c4d | ||
|
3ceed624da | ||
|
12620cee0e | ||
|
af41d56597 | ||
|
c5b0d7a1d1 | ||
|
4698d18fa1 | ||
|
76a34afe84 | ||
|
8a95972774 | ||
|
f080a74497 | ||
|
5ccd7a675f | ||
|
b8b5c935a2 | ||
|
1ef71bb370 | ||
|
fd50ea087b | ||
|
79d1acd17f | ||
|
22ace9c642 | ||
|
ea31104db0 | ||
|
41d71e6ce2 | ||
|
a06757b62b | ||
|
a44c5851cc | ||
|
c9cfcb2cae | ||
|
5adc951f57 | ||
|
44047e746f | ||
|
33e4f3eeec | ||
|
1c4be07aac | ||
|
ae9130ee8f | ||
|
299bf5ab27 | ||
|
2cb32f791c | ||
|
06085589d8 | ||
|
91c56917c7 | ||
|
5004381669 | ||
|
359cad0336 | ||
|
b4655b250b | ||
|
21355d4bb5 | ||
|
4c50ff4b5b | ||
|
b006ba2896 | ||
|
d4968b6b81 | ||
|
45b01b29de | ||
|
bca2bce323 | ||
|
d6b33a9cbf | ||
|
cd2e78c37a | ||
|
b142f3fdda | ||
|
e0ce5454bd | ||
|
40c52784ad | ||
|
236a8e9586 | ||
|
347fd449f9 | ||
|
4628f3f2a0 | ||
|
ea71308702 | ||
|
8493ed4239 | ||
|
fa57cee2e7 | ||
|
b982160ec5 | ||
|
19cad5cf24 | ||
|
b02f8b4d50 | ||
|
522a4feea1 | ||
|
4d86860e0c | ||
|
7e47b05c8f | ||
|
0a516ef3bf | ||
|
88f3052d99 | ||
|
c30457e434 | ||
|
cf14939cca | ||
|
6d269eeabd | ||
|
bdadbb8b01 | ||
|
38acfe6d30 | ||
|
55533ed8c1 | ||
|
f4d67b5f53 | ||
|
8e2ec01b61 | ||
|
f86703d7bb | ||
|
609e9fb102 | ||
|
ddff33280e | ||
|
472b1c1370 | ||
|
f6e87f63e0 | ||
|
2679a916be | ||
|
0b382100d2 | ||
|
4302f0d0c3 | ||
|
c5780dceaa | ||
|
ff2ce93fc9 | ||
|
8ffdf2ff94 | ||
|
a17e8dbd21 | ||
|
0093dc3f0d | ||
|
c69a022d13 | ||
|
b2af0b0751 | ||
|
0d15d3a38c | ||
|
095ff894a7 | ||
|
56ba08a98f | ||
|
bff7b558eb | ||
|
68e216ec3f | ||
|
d2fcadc8d5 | ||
|
4d36d24a70 | ||
|
4599f3c12a | ||
|
8cc957ac64 | ||
|
784ee58b26 | ||
|
5dfd8e43df | ||
|
d9d55e42bc | ||
|
d0c466e81c | ||
|
5fa47dd4ab | ||
|
2138802b59 | ||
|
6aa601cd1d | ||
|
c397fef4a1 | ||
|
eb894033c5 | ||
|
8ad5064ce2 | ||
|
874d69e9e5 | ||
|
a1c5bd8742 | ||
|
2b8b28171b | ||
|
1b6af99c5a | ||
|
8f239579a4 | ||
|
be4312e506 | ||
|
64f962d15c | ||
|
52c53760b2 | ||
|
2388fb9a2a | ||
|
ffcf3d7d07 | ||
|
2174ee1673 | ||
|
c1ac6f1928 | ||
|
35d1dc10c7 | ||
|
54a4a0bb1f | ||
|
f0b3035337 | ||
|
406acb61b3 | ||
|
812fc5e9c8 | ||
|
128f0a22da | ||
|
824618ccf1 | ||
|
e03eec3ce1 | ||
|
8b0b9f1a79 | ||
|
0eda8cd397 | ||
|
827e1974bf | ||
|
62213fad77 | ||
|
805d22f0b1 | ||
|
c621fad5f3 | ||
|
228b7b672d | ||
|
0dd03950e4 | ||
|
caf1383325 | ||
|
f854a2b410 | ||
|
7375146295 | ||
|
f33880c235 | ||
|
677af126aa | ||
|
2c74ba72a7 | ||
|
76ffa35cec | ||
|
10f450b3f6 | ||
|
3b3b940000 | ||
|
415c369e15 | ||
|
2755c571ff | ||
|
a747c80f63 | ||
|
bd9eeb11ab | ||
|
64f377cdfc | ||
|
a2220e3636 | ||
|
797b137826 | ||
|
efdbf4b0a8 | ||
|
163a40e6e7 | ||
|
9d80b12521 | ||
|
ee05b49ea2 | ||
|
dd807308ac | ||
|
d6891e8bd7 | ||
|
008184c305 | ||
|
ffe40033d4 | ||
|
921e27ac22 | ||
|
55ac2e8996 | ||
|
3a5b992524 | ||
|
78fe6f4270 | ||
|
cd36880f34 | ||
|
989566bc04 | ||
|
3597d8a805 | ||
|
581184d8fd | ||
|
f9ae045697 | ||
|
8e305a1032 | ||
|
2965665fee | ||
|
244879697f | ||
|
a4431e7a3e | ||
|
818e1a86de | ||
|
b32507064d | ||
|
c1b96680c9 | ||
|
403424e4c0 | ||
|
7b213b6393 | ||
|
75138c90ce | ||
|
2dc79dde6f | ||
|
fca0efa254 | ||
|
459ecc0c1c | ||
|
8ccefe95e5 | ||
|
e7c3c17eb3 | ||
|
cd6701d604 | ||
|
dbc64fbe86 | ||
|
baa1a0ae03 | ||
|
019b0a5e7e | ||
|
4d81fec6c9 | ||
|
e68546ad85 | ||
|
82bb1c573d | ||
|
6c73a8adce | ||
|
e76d85eade | ||
|
d88da134af | ||
|
212be299fd | ||
|
94dd44a2d3 | ||
|
fb54307939 | ||
|
e8bc227a92 | ||
|
53a9a7dce4 | ||
|
067487f9ec | ||
|
456646ca53 | ||
|
e23325d9dd | ||
|
c3980c217c | ||
|
4e5991779a | ||
|
e3dba949b6 | ||
|
25bd897ec5 | ||
|
9cfbc87924 | ||
|
ed4c68eba1 | ||
|
20d229168b | ||
|
66eb476620 | ||
|
5daad72fe0 | ||
|
50ca84b600 | ||
|
c3e43e5984 | ||
|
21962f4d87 | ||
|
26106a2fb4 | ||
|
5af11978ca | ||
|
16fc50bc31 | ||
|
c28eea88f7 | ||
|
f51afc1fbc | ||
|
b7a0856f51 | ||
|
17ee0c9669 | ||
|
219eeed5f8 | ||
|
c45e3c8c58 | ||
|
5dc28d9800 | ||
|
d8bef92bbe | ||
|
62c3264b2c | ||
|
a76061a981 | ||
|
3efb7a03e1 | ||
|
ec5c09fe37 | ||
|
461015a22f | ||
|
f14654a120 | ||
|
23fca714e1 | ||
|
31b16735e9 | ||
|
9bcd652c21 | ||
|
c45388b602 | ||
|
d6bbd0bf38 | ||
|
41956b07d6 | ||
|
3eb0a8dbf7 | ||
|
a65a906e9e | ||
|
cc9a4f59b5 | ||
|
ab3af9cc2d | ||
|
836d953cb7 | ||
|
fc5d37d391 | ||
|
87e242a07b | ||
|
6651d49b6a | ||
|
74d172cb6c | ||
|
bc05ce7078 | ||
|
455ab6f063 | ||
|
21d88d15eb | ||
|
e7649db96d | ||
|
2574efdb1d | ||
|
1ee5e25f85 | ||
|
a769f78e83 | ||
|
d58adefa3c | ||
|
3c4742c6e4 | ||
|
e5835fa0da | ||
|
083db5bd27 | ||
|
4d8b82eedb | ||
|
875c48cd04 | ||
|
71118af233 | ||
|
f7256f1d5b | ||
|
f6a05b128d | ||
|
f277e7d35a | ||
|
4944f42d9a | ||
|
643bb99892 | ||
|
da15fdb6da | ||
|
0c086d8540 | ||
|
2c5e749c2c | ||
|
e9297d8283 | ||
|
bd16eccad1 | ||
|
71913b96f4 | ||
|
86a71d834e | ||
|
953d7af7e0 | ||
|
ea38d8c397 | ||
|
f9d466bb84 | ||
|
79afd9173a | ||
|
b0a21e2c30 | ||
|
aff88114e5 | ||
|
46acb93370 | ||
|
2059787bbc | ||
|
c270d31a0e | ||
|
7be054f9c0 | ||
|
0523ed20f1 | ||
|
0fc59b61c2 | ||
|
2378bf1d6a | ||
|
cf1a8645f7 | ||
|
1ee0548587 | ||
|
8f1c542d5d | ||
|
261f04f94d | ||
|
ffdd828ba8 | ||
|
ed1fc6cdd2 | ||
|
eb3f2b5bed | ||
|
acc3476326 | ||
|
7ad78d01e5 | ||
|
1b059c1351 | ||
|
14f4567d86 | ||
|
36e24bade8 | ||
|
96849157c8 | ||
|
ade49a82b3 | ||
|
46bb0f38c5 | ||
|
d1185efc0a | ||
|
0289c63c4c | ||
|
9f3cc6e890 | ||
|
be1a725db8 | ||
|
24e52bdbbd | ||
|
51cfc7981d | ||
|
fefe0a24cd | ||
|
a7b8d4a0ca | ||
|
bb5314efc1 | ||
|
1a1c9c2db2 | ||
|
74bcaf3984 | ||
|
d42f8f40f5 | ||
|
276b0a8920 | ||
|
8be861aa1f | ||
|
abd538dc4b | ||
|
0ca4b10687 | ||
|
a38c07f7b1 | ||
|
d4552fdc5e | ||
|
c01451989e | ||
|
7b93207fd9 | ||
|
d99bfa45a3 | ||
|
27f22d077b | ||
|
152a7b04df | ||
|
d7c92bf19e | ||
|
97e00d9298 | ||
|
8f9059767f | ||
|
148c22fb27 | ||
|
6805aebc47 | ||
|
7aea3459a9 | ||
|
41bbc0b86b | ||
|
4e0165c45a | ||
|
57540cd86c | ||
|
6bc2b0fb53 | ||
|
c123ff75f0 | ||
|
d95df3ec22 | ||
|
75be9992fd | ||
|
19d7dad364 | ||
|
e9de25d797 | ||
|
7dc29aa3b7 | ||
|
ac1c60d4fe | ||
|
1133b32b5a | ||
|
72ff035301 | ||
|
745054e7d0 | ||
|
d2ced53344 | ||
|
e84baf6636 | ||
|
9014fc61a0 | ||
|
cf43031994 | ||
|
d2457c29d3 | ||
|
3865bebe8d | ||
|
d1f9e98060 | ||
|
5d7c85c7a1 | ||
|
e39268899c | ||
|
ffd38bb68c | ||
|
66c5011cfb | ||
|
401f0cfe65 | ||
|
1cbdef1ab3 | ||
|
2be24d8887 | ||
|
a3d5af9ea1 | ||
|
ee1f7281dc | ||
|
fd920d6fd1 | ||
|
b5a273965d | ||
|
93107a388c | ||
|
fdb11d98ea | ||
|
bb3228ad58 | ||
|
cf6c3dd144 | ||
|
ac02940174 | ||
|
2896b05dcd | ||
|
d0d0d3ced7 | ||
|
274d5b2d50 | ||
|
428c99f940 | ||
|
2a851d7cc7 | ||
|
9235ed178a | ||
|
cbf4c7447f | ||
|
c852685975 | ||
|
3b01af1da1 | ||
|
29b0425c9b | ||
|
a202b3fd17 | ||
|
e5c3e491a8 | ||
|
af3aa9d8b9 | ||
|
b59aecb70d | ||
|
7c807b3acc | ||
|
418c198999 | ||
|
535d92ab79 | ||
|
a6b3d384b2 | ||
|
a67d71ed90 | ||
|
8b7c1d80cb | ||
|
232fb2cf5e | ||
|
77be6da29c | ||
|
d49f20b7ba | ||
|
c8a99ee8e4 | ||
|
071951e926 | ||
|
0f2329bd95 | ||
|
d734a661fd | ||
|
2a11e31052 | ||
|
54deb01796 | ||
|
88341c7e56 | ||
|
0a43974175 | ||
|
5e20a1cc02 | ||
|
23feec94d0 | ||
|
0cba580ca6 | ||
|
1dd5f89b37 | ||
|
03114cbadb | ||
|
c5102dffba | ||
|
d1037eda59 | ||
|
d1717fa2bb | ||
|
2b5e38b40c | ||
|
4e5ec299ed | ||
|
60f2e639b2 | ||
|
6d5a3d796c | ||
|
c5c5c9b700 |
50
.clang-format
Normal file
50
.clang-format
Normal file
@@ -0,0 +1,50 @@
|
||||
AccessModifierOffset: -2
|
||||
AlignEscapedNewlinesLeft: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
AlwaysBreakAfterDefinitionReturnType: true
|
||||
BinPackParameters: false
|
||||
BreakBeforeBinaryOperators: false
|
||||
BreakBeforeBraces: Linux
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ContinuationIndentWidth: 0
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerBinding: false
|
||||
IndentCaseLabels: true
|
||||
IndentFunctionDeclarationAfterType: false
|
||||
IndentWidth: 4
|
||||
Language: Cpp
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakBeforeFirstCallParameter: 100
|
||||
PenaltyBreakComment: 100
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 100
|
||||
PenaltyExcessCharacter: 1
|
||||
PenaltyReturnTypeOnItsOwnLine: 20
|
||||
PointerBindsToType: true
|
||||
PointerAlignment: Left
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
9
.gitignore
vendored
9
.gitignore
vendored
@@ -10,4 +10,13 @@ build/
|
||||
|
||||
# Temp files
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# npmpub files
|
||||
src/mraajsJAVASCRIPT_wrap.cxx
|
||||
src/version.c
|
||||
package.json
|
||||
binding.gyp
|
||||
READMEFIRST
|
||||
npm-debug.log
|
||||
|
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
[submodule "doxygen2jsdoc"]
|
||||
path = doxygen2jsdoc
|
||||
url = https://github.com/arfoll/doxygen2jsdoc.git
|
||||
branch = master
|
32
.travis.yml
Normal file
32
.travis.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
language: cpp
|
||||
env:
|
||||
- CC=gcc CXX=gcc
|
||||
- CC=clang CXX=clang++
|
||||
- NODE4=true
|
||||
- NODE5=true
|
||||
- NODE012=true
|
||||
install:
|
||||
- if [ "${NODE4}" ]; then export CC=gcc-4.8 CXX=g++-4.8; fi
|
||||
- sudo add-apt-repository --yes ppa:kalakris/cmake
|
||||
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y -qq swig3.0 python git cmake
|
||||
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
|
||||
- sudo update-java-alternatives -s java-8-oracle
|
||||
before_script:
|
||||
- export NODE_ROOT_DIR="/home/travis/.nvm/v0.10.36"
|
||||
- if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
|
||||
- export JAVA_HOME=/usr/lib/jvm/java-8-oracle
|
||||
- if [ "${NODE4}" ]; then nvm install 4.1; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
- if [ "${NODE5}" ]; then nvm install 5; export CC=gcc-4.8; export CXX=g++-4.8; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
- if [ "${NODE012}" ]; then nvm install 0.12; export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; fi
|
||||
script:
|
||||
- mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" .. && make && make test
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.6
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- clang-3.6
|
||||
- g++-4.8
|
61
Android.mk
Normal file
61
Android.mk
Normal file
@@ -0,0 +1,61 @@
|
||||
# Copyright (C) 2015 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libmraa
|
||||
LOCAL_CFLAGS += -Wno-unused-parameter -DX86PLAT=1
|
||||
LOCAL_SHARED_LIBRARIES := libcutils libutils libdl libc
|
||||
LOCAL_SRC_FILES := \
|
||||
src/mraa.c \
|
||||
src/gpio/gpio.c \
|
||||
src/i2c/i2c.c \
|
||||
src/pwm/pwm.c \
|
||||
src/spi/spi.c \
|
||||
src/aio/aio.c \
|
||||
src/uart/uart.c \
|
||||
src/x86/x86.c \
|
||||
src/iio/iio.c \
|
||||
src/x86/intel_galileo_rev_d.c \
|
||||
src/x86/intel_galileo_rev_g.c \
|
||||
src/x86/intel_edison_fab_c.c \
|
||||
src/x86/intel_de3815.c \
|
||||
src/x86/intel_nuc5.c \
|
||||
src/x86/intel_sofia_3gr.c \
|
||||
src/x86/intel_minnow_byt_compatible.c \
|
||||
src/x86/intel_cherryhills.c \
|
||||
src/x86/up.c
|
||||
|
||||
# glob.c pulled in from NetBSD project (BSD 3-clause License)
|
||||
LOCAL_SRC_FILES += \
|
||||
src/glob/glob.c
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/include \
|
||||
$(LOCAL_PATH)/include/linux \
|
||||
$(LOCAL_PATH)/include/x86 \
|
||||
$(LOCAL_PATH)/api \
|
||||
$(LOCAL_PATH)/api/mraa \
|
||||
$(LOCAL_PATH)/src/glob
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDE_DIRS := \
|
||||
$(LOCAL_PATH)/api \
|
||||
$(LOCAL_PATH)/api/mraa
|
||||
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
150
CMakeLists.txt
150
CMakeLists.txt
@@ -1,11 +1,21 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
project (mraa)
|
||||
project (mraa C)
|
||||
|
||||
FIND_PACKAGE (Threads)
|
||||
FIND_PACKAGE (Threads REQUIRED)
|
||||
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer -DDEBUG")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
|
||||
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -DDEBUG")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -fno-omit-frame-pointer ")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall ")
|
||||
set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
|
||||
|
||||
# Set CMAKE_LIB_INSTALL_DIR if not defined
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# By default, build shared object libraries on linux
|
||||
if (UNIX AND NOT APPLE)
|
||||
if (NOT DEFINED BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||
@@ -13,12 +23,13 @@ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_
|
||||
# Make a version file containing the current version from git.
|
||||
include (GetGitRevisionDescription)
|
||||
git_describe (VERSION "--tags")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND")
|
||||
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_HEAD-HASH-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
|
||||
message (WARNING " - Install git to compile a production libmraa!")
|
||||
set (VERSION "v0.5.0-dirty")
|
||||
set (VERSION "v0.10.0-dirty")
|
||||
endif ()
|
||||
|
||||
message (INFO " - MRAA Version ${VERSION}")
|
||||
message (STATUS "INFO - libmraa Version ${VERSION}")
|
||||
message (STATUS "INFO - cmake Version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
|
||||
|
||||
#parse the version information into pieces.
|
||||
string (REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
|
||||
@@ -46,16 +57,57 @@ set (CMAKE_SWIG_FLAGS "")
|
||||
find_path (SYSTEM_USR_DIR "stdlib.h")
|
||||
include_directories (${SYSTEM_USR_DIR})
|
||||
|
||||
option (GTEST "Build all gtests." OFF)
|
||||
option (BUILDDOC "Build all doc." OFF)
|
||||
option (BUILDSWIG "Build swig modules." ON)
|
||||
option (BUILDSWIGPYTHON "Build swig python modules." ON)
|
||||
option (BUILDSWIGNODE "Build swig node modules." ON)
|
||||
option (BUILDSWIGJAVA "Build Java API." OFF)
|
||||
option (USBPLAT "Detection USB platform." OFF)
|
||||
option (FIRMATA "Add Firmata support to mraa." OFF)
|
||||
option (IMRAA "Add Imraa support to mraa." OFF)
|
||||
option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF)
|
||||
option (IPK "Generate IPK using CPack" OFF)
|
||||
option (RPM "Generate RPM using CPack" OFF)
|
||||
option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF)
|
||||
option (ENABLEEXAMPLES "Disable building of examples" ON)
|
||||
option (INSTALLGPIOTOOL "Install gpio tool" OFF)
|
||||
option (INSTALLTOOLS "Install all tools" OFF)
|
||||
option (BUILDARCH "Override architecture to build for - override" OFF)
|
||||
option (BUILDTESTS "Override the addition of tests" ON)
|
||||
|
||||
if (GTEST)
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
set (MRAAPLATFORMFORCE "" CACHE STRING "ALL")
|
||||
|
||||
if (NOT BUILDSWIG)
|
||||
set (BUILDSWIGPYTHON OFF)
|
||||
set (BUILDSWIGNODE OFF)
|
||||
set (BUILDSWIGJAVA OFF)
|
||||
endif()
|
||||
|
||||
if (NOT BUILDARCH)
|
||||
include (TargetArch)
|
||||
target_architecture (DETECTED_ARCH)
|
||||
message (STATUS "INFO - Target arch is ${DETECTED_ARCH}")
|
||||
else ()
|
||||
set (DETECTED_ARCH ${BUILDARCH})
|
||||
message (STATUS "INFO - Override arch is ${DETECTED_ARCH}")
|
||||
endif()
|
||||
|
||||
if (DETECTED_ARCH STREQUAL "i586" OR DETECTED_ARCH STREQUAL "x86_64"
|
||||
OR DETECTED_ARCH STREQUAL "i386")
|
||||
set (X86PLAT ON)
|
||||
elseif (DETECTED_ARCH MATCHES "arm.*")
|
||||
set (ARMPLAT ON)
|
||||
else ()
|
||||
message (FATAL_ERROR "Only x86 and arm platforms currently supported")
|
||||
endif()
|
||||
|
||||
if (BUILDSWIGPYTHON OR BUILDTESTS)
|
||||
if (BUILDPYTHON3)
|
||||
set (PYTHONBUILD_VERSION 3)
|
||||
else ()
|
||||
set (PYTHONBUILD_VERSION 2.7)
|
||||
endif ()
|
||||
find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (BUILDDOC)
|
||||
@@ -63,6 +115,9 @@ if (BUILDDOC)
|
||||
find_package (Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
if (BUILDSWIGJAVA)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.java.in ${CMAKE_CURRENT_BINARY_DIR}/src/java/Doxyfile @ONLY)
|
||||
endif ()
|
||||
add_custom_target (doc
|
||||
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
@@ -72,30 +127,77 @@ if (BUILDDOC)
|
||||
endif ()
|
||||
|
||||
if (IPK)
|
||||
include (TargetArch)
|
||||
target_architecture (DETECTED_ARCH)
|
||||
message( INFO " - Target arch is ${DETECTED_ARCH}")
|
||||
# Get target package arch from Yocto ADT sysroot if set or host OS, mapping to Ubuntu name if necessary
|
||||
if (DEFINED ENV{OECORE_TARGET_SYSROOT})
|
||||
GET_FILENAME_COMPONENT (DETECTED_SYSROOT $ENV{OECORE_TARGET_SYSROOT} NAME)
|
||||
string (REGEX REPLACE "-poky-linux" "" TARGET_ARCH "${DETECTED_SYSROOT}")
|
||||
else ()
|
||||
# debian uses amd64 to denote x86_64
|
||||
if (DETECTED_ARCH STREQUAL "x86_64")
|
||||
set (TARGET_ARCH "amd64")
|
||||
else ()
|
||||
set (TARGET_ARCH ${DETECTED_ARCH})
|
||||
endif ()
|
||||
endif ()
|
||||
message (STATUS "INFO - Package arch is ${TARGET_ARCH}")
|
||||
|
||||
set(CPACK_GENERATOR "DEB" "TGZ")
|
||||
set(OPKG_ARCH ${DETECTED_ARCH})
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(OPKG_ARCH ${TARGET_ARCH})
|
||||
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
|
||||
set(mraa_PACKAGE_ON_TAG ".")
|
||||
if ("${VERSION_COMMIT}" STREQUAL "")
|
||||
set(mraa_PACKAGE_ON_TAG "")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||
set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_NAME "mraa")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${DETECTED_ARCH})
|
||||
set(CPACK_SYSTEM_NAME ${DETECTED_ARCH})
|
||||
set(CPACK_DEBIAN_PACKAGE_PROVIDES "libmraa-dev, libmraa-dbg, libmraa-doc, libmaa-dev, libmaa-dbg, libmaa-doc, libmaa0")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${TARGET_ARCH})
|
||||
set(CPACK_SYSTEM_NAME ${TARGET_ARCH})
|
||||
set(CPACK_DEBIAN_PACKAGE_PROVIDES "mraa-dev, mraa-dbg, mraa-doc")
|
||||
set(CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_PROVIDES}, libmraa, libmraa-dev, libmraa-doc")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONFLICTS ${CPACK_DEBIAN_PACKAGE_PROVIDES})
|
||||
set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}")
|
||||
include (CPack)
|
||||
endif()
|
||||
|
||||
if (RPM)
|
||||
message (STATUS "INFO - Enabled RPM packaging for ${DETECTED_ARCH}")
|
||||
set(CMAKE_INSTALL_PREFIX "/usr")
|
||||
set(CPACK_PACKAGE_VERSION ${VERSION})
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
set(CPACK_PACKAGE_NAME "libmraa${mraa_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_RELEASE 1)
|
||||
set(CPACK_PACKAGE_VERSION
|
||||
"${mraa_VERSION_MAJOR}.${mraa_VERSION_MINOR}.${mraa_VERSION_PATCH}${mraa_PACKAGE_ON_TAG}${VERSION_COMMIT}")
|
||||
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
|
||||
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
|
||||
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
|
||||
# Get distro tag (e.g. 'fc20') by parsing output of rpm --showrc
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND rpm --showrc
|
||||
COMMAND grep -w dist
|
||||
COMMAND sed -e "s/\\t./ /"
|
||||
COMMAND awk "{printf \"%s\", \$NF}"
|
||||
OUTPUT_VARIABLE DIST_TAG
|
||||
)
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${DIST_TAG}.${DETECTED_ARCH}")
|
||||
include(CPack)
|
||||
endif()
|
||||
|
||||
add_subdirectory (src)
|
||||
add_subdirectory (examples)
|
||||
if (ENABLEEXAMPLES)
|
||||
add_subdirectory (examples)
|
||||
endif ()
|
||||
|
||||
if (IMRAA)
|
||||
add_subdirectory (imraa)
|
||||
endif ()
|
||||
|
||||
if (BUILDTESTS)
|
||||
if (${PYTHONINTERP_FOUND})
|
||||
enable_testing ()
|
||||
add_subdirectory (tests)
|
||||
endif ()
|
||||
endif ()
|
||||
|
90
CONTRIBUTING.md
Normal file
90
CONTRIBUTING.md
Normal file
@@ -0,0 +1,90 @@
|
||||
Contributing to libmraa {#contributing}
|
||||
======================
|
||||
|
||||
libmraa is an opensource project and we are actively looking for people to help
|
||||
with:
|
||||
|
||||
- Writing platform supports for all types of boards running linux
|
||||
- People to extend the functionality, API with useful functions
|
||||
- Anything we haven't thought about :) Ideas always welcome!
|
||||
|
||||
The recommended method to contribute is to fork on github, and then send pull
|
||||
requests to the main project. You can open issues if you find any bugs/have
|
||||
questions.
|
||||
|
||||
If you'd rather not use github you are more than welcome to send git formatted
|
||||
patches to our mailing list mraa@lists.01.org which you can register for access
|
||||
on: https://lists.01.org/mailman/listinfo/mraa
|
||||
|
||||
Basic rules
|
||||
-----------
|
||||
- Your code must build
|
||||
- Commits must have a sign-off line by at least yourself
|
||||
- Commits must be named <file/module>: Some decent description
|
||||
- Try not to break master. In any commit.
|
||||
- Try to split commits up logically, you will be asked to rebase them if they
|
||||
are not.
|
||||
- Try to stick to the established coding style regardless of your personal
|
||||
feeling for it! Use clang-format (3.6+ required)
|
||||
|
||||
Coding Style
|
||||
------------
|
||||
|
||||
Coding style for all code is defined by clang-format, have a look at it. Avoid
|
||||
styling fixes as they make history difficult to read. Javascript & Java can
|
||||
also be parsed through the clang-format, it complains but seems to do an ok
|
||||
job. Few exceptions to coding styles:
|
||||
- All python code is indented by 2 spaces
|
||||
- CmakeLists files are 2 space indented and a space is required before all
|
||||
brackets so endif () and if () and command (). Also use lowercase for
|
||||
everything but variables. Cmake is case insensitive but this isn't the wild
|
||||
wild west ;-)
|
||||
|
||||
Use common sense and don't be afraid to challenge something if it doesn't make sense!
|
||||
|
||||
Code signing
|
||||
------------
|
||||
|
||||
The sign-off is a simple line at the end of the explanation for the
|
||||
patch, which certifies that you wrote it or otherwise have the right to pass it
|
||||
on as an open-source patch. The rules are pretty simple: if you can certify
|
||||
the below:
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
then you just add a line saying
|
||||
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
|
||||
Using your real name (sorry, no pseudonyms or anonymous contributions.)
|
||||
|
||||
Where to find us
|
||||
----------------
|
||||
|
||||
Hop onto the freenode network on IRC and join #mraa. Please be patient as we're
|
||||
not always online.
|
||||
|
3
COPYING
3
COPYING
@@ -1,4 +1,5 @@
|
||||
Copyright © 2014 Intel Corporation
|
||||
The MIT License (MIT)
|
||||
Copyright © 2014-2016 Intel Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
@@ -755,7 +755,8 @@ WARN_LOGFILE =
|
||||
|
||||
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/api/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/api/mraa/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/docs/ \
|
||||
@CMAKE_CURRENT_SOURCE_DIR@/CONTRIBUTING.md
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
2324
Doxyfile.java.in
Normal file
2324
Doxyfile.java.in
Normal file
File diff suppressed because it is too large
Load Diff
93
README.md
93
README.md
@@ -1,9 +1,15 @@
|
||||
MRAA - Low Level Skeleton Library for Communication on GNU/Linux platforms
|
||||
<p align="center">
|
||||
<img src="http://iotdk.intel.com/misc/logos/mraa.png" height="150px" width="auto" algt="Mraa Logo"/>
|
||||
</p>
|
||||
libmraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
|
||||
==============
|
||||
|
||||
Library in C/C++ to interface with Galileo & other Intel platforms, in a
|
||||
structured and sane API with port names/numbering that match boards & with
|
||||
bindings to javascript & python.
|
||||
Libmraa is a C/C++ library with bindings to javascript & python to interface
|
||||
with the IO on Galileo, Edison & other platforms, with a structured and sane
|
||||
API where port names/numbering matches the board that you are on. Use of
|
||||
libmraa does not tie you to specific hardware with board detection done at
|
||||
runtime you can create portable code that will work across the supported
|
||||
platforms.
|
||||
|
||||
The intent is to make it easier for developers and sensor manufacturers to map
|
||||
their sensors & actuators on top of supported hardware and to allow control of
|
||||
@@ -12,21 +18,54 @@ low level communication protocol by high level languages & constructs.
|
||||
Supported Boards
|
||||
================
|
||||
|
||||
X86
|
||||
---
|
||||
* [Galileo Gen 1 - Rev D](../master/docs/galileorevd.md)
|
||||
* [Galileo Gen 2 - Rev H](../master/docs/galileorevh.md)
|
||||
* [Edison](../master/docs/edison.md)
|
||||
* [Intel DE3815](../master/docs/intel_de3815.md)
|
||||
* [Minnowboard Max](../master/docs/minnow_max.md)
|
||||
* [NUC 5th generation](../master/docs/intel_nuc5.md)
|
||||
* [UP](../master/docs/up.md)
|
||||
|
||||
ARM
|
||||
---
|
||||
* [Raspberry Pi](../master/docs/raspberry_pi.md)
|
||||
* [Bannana Pi](../master/docs/banana_pi.md)
|
||||
* [Beaglebone Black](../master/docs/beaglebone.md)
|
||||
|
||||
USB
|
||||
---
|
||||
* [FT4222](../master/docs/ftdi_ft4222.md)
|
||||
|
||||
Installing on your board
|
||||
========
|
||||
|
||||
See the section below on compiling or use our repository to install on an
|
||||
eglibc based yocto poky image that supports opkg. Adding this repository is as
|
||||
simple as:
|
||||
See the section below on compiling or use our repository to install on a glibc
|
||||
based yocto poky image that supports opkg. Adding this repository is as simple
|
||||
as and you'll have the latest stable tagged build of mraa installed!
|
||||
|
||||
``` bash
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/mraa-upm.conf
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
opkg update
|
||||
opkg install libmraa0
|
||||
opkg install mraa
|
||||
```
|
||||
|
||||
If you would like to get the latest & greatest builds from master HEAD you can
|
||||
use our -dev repository
|
||||
|
||||
```bash
|
||||
echo "src mraa-upm http://iotdk.intel.com/repos/3.0/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf
|
||||
opkg update
|
||||
opkg install mraa
|
||||
```
|
||||
|
||||
You can also install just the node.js mraa module by using npm. You will need a
|
||||
C++ compiler and the node development headers, however it's not required to
|
||||
have SWIG installed.
|
||||
|
||||
```bash
|
||||
npm install mraa
|
||||
```
|
||||
|
||||
Compiling
|
||||
@@ -39,20 +78,32 @@ Examples
|
||||
|
||||
See the [examples](../../tree/master/examples) available for various languages
|
||||
|
||||
C/C++ API Documentation
|
||||
===========
|
||||
Debugging
|
||||
=========
|
||||
|
||||
The C/C++ documentation is available [here](http://iotdk.intel.com/docs/master/mraa/)
|
||||
Sometimes it just doesn't want to work, let us try and help you, you can file
|
||||
issues in github or join us in #mraa on freenode IRC, hang around for a little
|
||||
while because we're not necessarily on 24/7, but we'll get back to you! Have a
|
||||
glance at our [debugging](../master/docs/debugging.md) page too.
|
||||
|
||||
Python API Documentation
|
||||
===========
|
||||
API Documentation
|
||||
=================
|
||||
|
||||
The Python documentation is available [here](http://iotdk.intel.com/docs/master/mraa/python)
|
||||
<a href="http://c.mraa.io"><img src="http://iotdk.intel.com/misc/logos/c++.png"/></a>
|
||||
<a href="http://java.mraa.io"><img src="http://iotdk.intel.com/misc/logos/java.png"/></a>
|
||||
<a href="http://py.mraa.io"><img src="http://iotdk.intel.com/misc/logos/python.png"/></a>
|
||||
<a href="http://js.mraa.io"><img src="http://iotdk.intel.com/misc/logos/node.png"/></a>
|
||||
|
||||
NodeJS API documentation
|
||||
===========
|
||||
Contact Us
|
||||
==========
|
||||
|
||||
There is no explicit nodejs API documentation, see the examples. The API itself
|
||||
is very similar to the python one but with a js syntax. If you know of an
|
||||
autodoc tool for generating nodejs APIs from a native C++ nodejs extension
|
||||
please get in touch!
|
||||
To ask questions either file issues in github or send emails on our [mailing
|
||||
list](https://lists.01.org/mailman/listinfo/mraa). You might also catch us on
|
||||
the mraa channel on freenode IRC.
|
||||
|
||||
See the [Contribution](CONTRIBUTING.md) documentation for more details.
|
||||
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Version changelog [here](docs/changelog.md).
|
||||
|
@@ -67,6 +67,14 @@ mraa_aio_context mraa_aio_init(unsigned int pin);
|
||||
*/
|
||||
unsigned int mraa_aio_read(mraa_aio_context dev);
|
||||
|
||||
/**
|
||||
* Read the input voltage and return it as a normalized float (0.0f-1.0f).
|
||||
*
|
||||
* @param dev The AIO context
|
||||
* @returns The current input voltage as a normalized float (0.0f-1.0f)
|
||||
*/
|
||||
float mraa_aio_read_float(mraa_aio_context dev);
|
||||
|
||||
/**
|
||||
* Close the analog input context, this will free the memory for the context
|
||||
*
|
||||
|
118
api/mraa/aio.hpp
118
api/mraa/aio.hpp
@@ -24,63 +24,87 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include "aio.h"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to Analog IO
|
||||
*
|
||||
* This file defines the aio interface for libmraa
|
||||
*
|
||||
* @snippet examples/c++/AioA0.cpp Interesting
|
||||
* @snippet AioA0.cpp Interesting
|
||||
*/
|
||||
class Aio {
|
||||
public:
|
||||
/**
|
||||
* Aio Constructor, takes a pin number which will map directly to the
|
||||
* board number
|
||||
*
|
||||
* @param pin channel number to read ADC inputs
|
||||
*/
|
||||
Aio(unsigned int pin) {
|
||||
m_aio = mraa_aio_init(pin);
|
||||
}
|
||||
/**
|
||||
* Aio destructor
|
||||
*/
|
||||
~Aio() {
|
||||
mraa_aio_close(m_aio);
|
||||
}
|
||||
/**
|
||||
* Read a value from the AIO pin. By default mraa will shift
|
||||
* the raw value up or down to a 10 bit value.
|
||||
*
|
||||
* @returns The current input voltage. By default, a 10bit value
|
||||
*/
|
||||
int read() {
|
||||
return mraa_aio_read(m_aio);
|
||||
}
|
||||
/**
|
||||
* Set the bit value which mraa will shift the raw reading
|
||||
* from the ADC to. I.e. 10bits
|
||||
* @param bits the bits the return from read should be i.e 10
|
||||
* @return mraa result type
|
||||
*/
|
||||
mraa_result_t setBit(int bits) {
|
||||
return mraa_aio_set_bit(m_aio, bits);
|
||||
}
|
||||
/**
|
||||
* Gets the bit value mraa is shifting the analog read to.
|
||||
*
|
||||
* @return bit value mraa is set return from the read function
|
||||
*/
|
||||
int getBit() {
|
||||
return mraa_aio_get_bit(m_aio);
|
||||
class Aio
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Aio Constructor, takes a pin number which will map directly to the
|
||||
* board number
|
||||
*
|
||||
* @param pin channel number to read ADC inputs
|
||||
*/
|
||||
Aio(unsigned int pin)
|
||||
{
|
||||
m_aio = mraa_aio_init(pin);
|
||||
if (m_aio == NULL) {
|
||||
throw std::invalid_argument("Invalid AIO pin specified - do you have an ADC?");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Aio destructor
|
||||
*/
|
||||
~Aio()
|
||||
{
|
||||
mraa_aio_close(m_aio);
|
||||
}
|
||||
/**
|
||||
* Read a value from the AIO pin. By default mraa will shift
|
||||
* the raw value up or down to a 10 bit value.
|
||||
*
|
||||
* @returns The current input voltage. By default, a 10bit value
|
||||
*/
|
||||
int
|
||||
read()
|
||||
{
|
||||
return mraa_aio_read(m_aio);
|
||||
}
|
||||
/**
|
||||
* Read a value from the AIO pin and return it as a normalized float.
|
||||
*
|
||||
* @returns The current input voltage as a normalized float (0.0f-1.0f)
|
||||
*/
|
||||
float
|
||||
readFloat()
|
||||
{
|
||||
return mraa_aio_read_float(m_aio);
|
||||
}
|
||||
/**
|
||||
* Set the bit value which mraa will shift the raw reading
|
||||
* from the ADC to. I.e. 10bits
|
||||
* @param bits the bits the return from read should be i.e 10
|
||||
* @return mraa::Result type
|
||||
*/
|
||||
Result
|
||||
setBit(int bits)
|
||||
{
|
||||
return (Result) mraa_aio_set_bit(m_aio, bits);
|
||||
}
|
||||
/**
|
||||
* Gets the bit value mraa is shifting the analog read to.
|
||||
*
|
||||
* @return bit value mraa is set return from the read function
|
||||
*/
|
||||
int
|
||||
getBit()
|
||||
{
|
||||
return mraa_aio_get_bit(m_aio);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
private:
|
||||
mraa_aio_context m_aio;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -24,8 +24,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "types.h"
|
||||
|
||||
#define MRAA_PLATFORM_NAME_MAX_SIZE 64
|
||||
#define MRAA_PIN_NAME_SIZE 12
|
||||
|
||||
#define MRAA_SUB_PLATFORM_BIT_SHIFT 9
|
||||
#define MRAA_SUB_PLATFORM_MASK (1<<MRAA_SUB_PLATFORM_BIT_SHIFT)
|
||||
|
||||
#define MRAA_MAIN_PLATFORM_OFFSET 0
|
||||
#define MRAA_SUB_PLATFORM_OFFSET 1
|
||||
|
||||
/** Executes function func and returns its result in case of error
|
||||
*/
|
||||
#define MRAA_RETURN_FOR_ERROR(func) do { \
|
||||
mraa_result_t res; \
|
||||
res = func; \
|
||||
if (res != MRAA_SUCCESS) \
|
||||
return res;} while(0)
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared values for libmraa
|
||||
@@ -41,156 +59,12 @@ extern "C" {
|
||||
*/
|
||||
typedef unsigned int mraa_boolean_t;
|
||||
|
||||
/**
|
||||
* Enum representing different possible modes for a pin.
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_PIN_VALID = 0, /**< Pin Valid */
|
||||
MRAA_PIN_GPIO = 1, /**< General Purpose IO */
|
||||
MRAA_PIN_PWM = 2, /**< Pulse Width Modulation */
|
||||
MRAA_PIN_FAST_GPIO = 3, /**< Faster GPIO */
|
||||
MRAA_PIN_SPI = 4, /**< SPI */
|
||||
MRAA_PIN_I2C = 5, /**< I2C */
|
||||
MRAA_PIN_AIO = 6, /**< Analog in */
|
||||
MRAA_PIN_UART = 7 /**< UART */
|
||||
} mraa_pinmodes_t;
|
||||
|
||||
/**
|
||||
* A bitfield representing the capabilities of a pin.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
mraa_boolean_t valid:1; /**< Is the pin valid at all */
|
||||
mraa_boolean_t gpio:1; /**< Is the pin gpio capable */
|
||||
mraa_boolean_t pwm:1; /**< Is the pin pwm capable */
|
||||
mraa_boolean_t fast_gpio:1; /**< Is the pin fast gpio capable */
|
||||
mraa_boolean_t spi:1; /**< Is the pin spi capable */
|
||||
mraa_boolean_t i2c:1; /**< Is the pin i2c capable */
|
||||
mraa_boolean_t aio:1; /**< Is the pin analog input capable */
|
||||
mraa_boolean_t uart:1; /**< Is the pin uart capable */
|
||||
/*@}*/
|
||||
} mraa_pincapabilities_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a multiplexer and the required value
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int pin; /**< Raw GPIO pin id */
|
||||
unsigned int value; /**< Raw GPIO value */
|
||||
/*@}*/
|
||||
} mraa_mux_t;
|
||||
|
||||
typedef struct {
|
||||
mraa_boolean_t complex_pin:1;
|
||||
mraa_boolean_t output_en:1;
|
||||
mraa_boolean_t output_en_high:1;
|
||||
mraa_boolean_t pullup_en:1;
|
||||
mraa_boolean_t pullup_en_hiz:1;
|
||||
} mraa_pin_cap_complex_t;
|
||||
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int pinmap; /**< sysfs pin */
|
||||
unsigned int parent_id; /** parent chip id */
|
||||
unsigned int mux_total; /** Numfer of muxes needed for operation of pin */
|
||||
mraa_mux_t mux[6]; /** Array holding information about mux */
|
||||
unsigned int output_enable; /** Output Enable GPIO, for level shifting */
|
||||
unsigned int pullup_enable; /** Pull-Up enable GPIO, inputs */
|
||||
mraa_pin_cap_complex_t complex_cap;
|
||||
/*@}*/
|
||||
} mraa_pin_t;
|
||||
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char mem_dev[32]; /**< Memory device to use /dev/uio0 etc */
|
||||
unsigned int mem_sz; /** Size of memory to map */
|
||||
unsigned int bit_pos; /** Position of value bit */
|
||||
mraa_pin_t gpio; /** GPio context containing none mmap info */
|
||||
/*@}*/
|
||||
} mraa_mmap_pin_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a physical Pin.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
char name[8]; /**< Pin's real world name */
|
||||
mraa_pincapabilities_t capabilites; /**< Pin Capabiliites */
|
||||
mraa_pin_t gpio; /**< GPIO structure */
|
||||
mraa_pin_t pwm; /**< PWM structure */
|
||||
mraa_pin_t aio; /**< Anaglog Pin */
|
||||
mraa_mmap_pin_t mmap; /**< GPIO through memory */
|
||||
mraa_pin_t i2c; /**< i2c bus/pin */
|
||||
mraa_pin_t spi; /**< spi bus/pin */
|
||||
mraa_pin_t uart; /**< uart module/pin */
|
||||
/*@}*/
|
||||
} mraa_pininfo_t;
|
||||
|
||||
/**
|
||||
* A Structure representing the physical properties of a i2c bus.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int bus_id; /**< ID as exposed in the system */
|
||||
unsigned int scl; /**< i2c SCL */
|
||||
unsigned int sda; /**< i2c SDA */
|
||||
/*@}*/
|
||||
} mraa_i2c_bus_t;
|
||||
|
||||
/**
|
||||
* A Structure representing the physical properties of a spi bus.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int bus_id; /**< The Bus ID as exposed to the system. */
|
||||
unsigned int slave_s; /**< Slave select */
|
||||
mraa_boolean_t three_wire; /**< Is the bus only a three wire system */
|
||||
unsigned int sclk; /**< Serial Clock */
|
||||
unsigned int mosi; /**< Master Out, Slave In. */
|
||||
unsigned int miso; /**< Master In, Slave Out. */
|
||||
unsigned int cs; /**< Chip Select, used when the board is a spi slave */
|
||||
/*@}*/
|
||||
} mraa_spi_bus_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a uart device.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int index; /**< ID as exposed in the system */
|
||||
int rx; /**< uart rx */
|
||||
int tx; /**< uart tx */
|
||||
/*@}*/
|
||||
} mraa_uart_dev_t;
|
||||
|
||||
/**
|
||||
* A Structure representing a platform/board.
|
||||
*/
|
||||
typedef struct {
|
||||
/*@{*/
|
||||
unsigned int phy_pin_count; /**< The Total IO pins on board */
|
||||
unsigned int gpio_count; /**< GPIO Count */
|
||||
unsigned int aio_count; /**< Analog side Count */
|
||||
unsigned int i2c_bus_count; /**< Usable i2c Count */
|
||||
mraa_i2c_bus_t i2c_bus[12]; /**< Array of i2c */
|
||||
unsigned int def_i2c_bus; /**< Position in array of default i2c bus */
|
||||
unsigned int spi_bus_count; /**< Usable spi Count */
|
||||
mraa_spi_bus_t spi_bus[12]; /**< Array of spi */
|
||||
unsigned int def_spi_bus; /**< Position in array of defult spi bus */
|
||||
unsigned int adc_raw; /**< ADC raw bit value */
|
||||
unsigned int adc_supported; /**< ADC supported bit value */
|
||||
unsigned int def_uart_dev; /**< Position in array of defult uart */
|
||||
unsigned int uart_dev_count; /**< Usable spi Count */
|
||||
mraa_uart_dev_t uart_dev[6]; /**< Array of UARTs */
|
||||
mraa_pininfo_t* pins; /**< Pointer to pin array */
|
||||
/*@}*/
|
||||
} mraa_board_t;
|
||||
|
||||
/**
|
||||
* Initialise MRAA
|
||||
*
|
||||
* Detects running platform and attempts to use included pinmap
|
||||
* Detects running platform and attempts to use included pinmap, this is run on
|
||||
* module/library init/load but is handy to rerun to check board initialised
|
||||
* correctly. MRAA_SUCCESS inidicates correct initialisation.
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
@@ -228,6 +102,14 @@ mraa_boolean_t mraa_pin_mode_test(int pin, mraa_pinmodes_t mode);
|
||||
*/
|
||||
unsigned int mraa_adc_raw_bits();
|
||||
|
||||
/**
|
||||
* Check the specified board's bit size when reading the value
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @return raw bits being read from kernel module. zero if no ADC
|
||||
*/
|
||||
unsigned int mraa_get_platform_adc_raw_bits(uint8_t platform_offset);
|
||||
|
||||
/**
|
||||
* Return value that the raw value should be shifted to. Zero if no ADC
|
||||
*
|
||||
@@ -235,6 +117,13 @@ unsigned int mraa_adc_raw_bits();
|
||||
*/
|
||||
unsigned int mraa_adc_supported_bits();
|
||||
|
||||
/**
|
||||
* Return value that the raw value should be shifted to. Zero if no ADC
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @return return actual bit size the adc value should be understood as.
|
||||
*/
|
||||
unsigned int mraa_get_platform_adc_supported_bits(int platform_offset);
|
||||
|
||||
/**
|
||||
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
||||
@@ -244,6 +133,157 @@ unsigned int mraa_adc_supported_bits();
|
||||
*/
|
||||
mraa_result_t mraa_set_log_level(int level);
|
||||
|
||||
/**
|
||||
* Return the Platform's Name, If no platform detected return NULL
|
||||
*
|
||||
* @return platform name
|
||||
*/
|
||||
const char* mraa_get_platform_name();
|
||||
|
||||
/**
|
||||
* Return the platform's versioning info, the information given depends per
|
||||
* platform and can be NULL. platform_offset has to be given. Do not modify
|
||||
* this pointer
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 for sub platform
|
||||
* @return platform's versioning string
|
||||
*/
|
||||
const char* mraa_get_platform_version(int platform_offset);
|
||||
|
||||
/**
|
||||
* This function attempts to set the mraa process to a given priority and the
|
||||
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
||||
* This function * will set to MAX if * priority is > MAX. Function will return
|
||||
* -1 on failure.
|
||||
*
|
||||
* @param priority Value from typically 0 to 99
|
||||
* @return The priority value set
|
||||
*/
|
||||
int mraa_set_priority(const unsigned int priority);
|
||||
|
||||
/** Get the version string of mraa autogenerated from git tag
|
||||
*
|
||||
* The version returned may not be what is expected however it is a reliable
|
||||
* number associated with the git tag closest to that version at build time
|
||||
*
|
||||
* @return version string from version.h
|
||||
*/
|
||||
const char* mraa_get_version();
|
||||
|
||||
/**
|
||||
* Print a textual representation of the mraa_result_t
|
||||
*
|
||||
* @param result the result to print
|
||||
*/
|
||||
void mraa_result_print(mraa_result_t result);
|
||||
|
||||
/**
|
||||
* Get platform type, board must be initialised.
|
||||
*
|
||||
* @return mraa_platform_t Platform type enum
|
||||
*/
|
||||
mraa_platform_t mraa_get_platform_type();
|
||||
|
||||
/**
|
||||
* Get combined platform type, board must be initialised.
|
||||
* The combined type is represented as
|
||||
* (sub_platform_type << 8) | main_platform_type
|
||||
*
|
||||
* @return int combined platform type
|
||||
*/
|
||||
int mraa_get_platform_combined_type();
|
||||
|
||||
/**
|
||||
* Get platform pincount, board must be initialised.
|
||||
*
|
||||
* @return uint of physical pin count on the in-use platform
|
||||
*/
|
||||
unsigned int mraa_get_pin_count();
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
* @return number f usable I2C bus count on the current platform. Function will
|
||||
* return -1 on failure
|
||||
*/
|
||||
int mraa_get_i2c_bus_count();
|
||||
|
||||
/**
|
||||
* Get I2C adapter number in sysfs.
|
||||
*
|
||||
* @param i2c_bus the logical I2C bus number
|
||||
* @return I2C adapter number in sysfs. Function will return -1 on failure
|
||||
*/
|
||||
int mraa_get_i2c_bus_id(unsigned int i2c_bus);
|
||||
|
||||
/**
|
||||
* Get specified platform pincount, board must be initialised.
|
||||
*
|
||||
* @param specified platform offset; 0 for main platform, 1 foor sub platform
|
||||
* @return uint of physical pin count on the in-use platform
|
||||
*/
|
||||
unsigned int mraa_get_platform_pin_count(uint8_t platform_offset);
|
||||
|
||||
/**
|
||||
* Get name of pin, board must be initialised.
|
||||
*
|
||||
* @param pin number
|
||||
* @return char* of pin name
|
||||
*/
|
||||
char* mraa_get_pin_name(int pin);
|
||||
|
||||
/**
|
||||
* Get default i2c bus, board must be initialised.
|
||||
*
|
||||
* @return int default i2c bus index
|
||||
*/
|
||||
int mraa_get_default_i2c_bus(uint8_t platform_offset);
|
||||
|
||||
/**
|
||||
* Detect presence of sub platform.
|
||||
*
|
||||
* @return mraa_boolean_t 1 if sub platform is present and initialized, 0 otherwise
|
||||
*/
|
||||
mraa_boolean_t mraa_has_sub_platform();
|
||||
|
||||
|
||||
/**
|
||||
* Check if pin or bus id includes sub platform mask.
|
||||
*
|
||||
* @param int pin or bus number
|
||||
*
|
||||
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
|
||||
*/
|
||||
mraa_boolean_t mraa_is_sub_platform_id(int pin_or_bus_id);
|
||||
|
||||
/**
|
||||
* Convert pin or bus index to corresponding sub platform id.
|
||||
*
|
||||
* @param int pin or bus index
|
||||
*
|
||||
* @return int sub platform pin or bus number
|
||||
*/
|
||||
int mraa_get_sub_platform_id(int pin_or_bus_index);
|
||||
|
||||
/**
|
||||
* Convert pin or bus sub platform id to index.
|
||||
*
|
||||
* @param int sub platform pin or bus id
|
||||
*
|
||||
* @return int pin or bus index
|
||||
*/
|
||||
int mraa_get_sub_platform_index(int pin_or_bus_id);
|
||||
|
||||
/**
|
||||
* Add mraa subplatform
|
||||
*
|
||||
* @param subplatform type
|
||||
* @param uart device subplatform is on
|
||||
*
|
||||
* @return mraa_result_t indicating success
|
||||
*/
|
||||
mraa_result_t mraa_add_subplatform(mraa_platform_t subplatformtype, const char* uart_dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -25,12 +25,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "types.hpp"
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @namespace mraa namespace
|
||||
*/
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @file
|
||||
@@ -39,12 +41,28 @@ namespace mraa {
|
||||
* This file defines the interface for libmraa common functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialise MRAA
|
||||
*
|
||||
* Detects running platform and attempts to use included pinmap, this is run on
|
||||
* module/library init/load but is handy to rerun to check board initialised
|
||||
* correctly. mraa::SUCCESS inidicates correct initialisation.
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline Result
|
||||
init()
|
||||
{
|
||||
return (Result) mraa_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get libmraa version.
|
||||
*
|
||||
* @return libmraa version (e.g. v0.4.0-20-gb408207)
|
||||
*/
|
||||
std::string getVersion()
|
||||
inline std::string
|
||||
getVersion()
|
||||
{
|
||||
std::string ret = mraa_get_version();
|
||||
return ret;
|
||||
@@ -59,7 +77,8 @@ std::string getVersion()
|
||||
* @param priority Value from typically 0 to 99
|
||||
* @return The priority value set
|
||||
*/
|
||||
int setPriority(const unsigned int priority)
|
||||
inline int
|
||||
setPriority(const unsigned int priority)
|
||||
{
|
||||
return mraa_set_priority(priority);
|
||||
}
|
||||
@@ -67,21 +86,23 @@ int setPriority(const unsigned int priority)
|
||||
/**
|
||||
* Get platform type, board must be initialised.
|
||||
*
|
||||
* @return mraa_platform_t Platform type enum
|
||||
* @return mraa::platform Platform type enum
|
||||
*/
|
||||
mraa_platform_t getPlatformType()
|
||||
inline Platform
|
||||
getPlatformType()
|
||||
{
|
||||
return mraa_get_platform_type();
|
||||
return (Platform) mraa_get_platform_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a textual representation of the mraa_result_t
|
||||
* Print a textual representation of the mraa::Result
|
||||
*
|
||||
* @param result the result to print
|
||||
* @param Result the Result to print
|
||||
*/
|
||||
void printError(mraa_result_t result)
|
||||
inline void
|
||||
printError(Result result)
|
||||
{
|
||||
mraa_result_print(result);
|
||||
mraa_result_print((mraa_result_t) result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,9 +112,10 @@ void printError(mraa_result_t result)
|
||||
* @param mode the mode to be tested.
|
||||
* @return boolean if the mode is supported, 0=false.
|
||||
*/
|
||||
bool pinModeTest(int pin, mraa_pinmodes_t mode)
|
||||
inline bool
|
||||
pinModeTest(int pin, Pinmodes mode)
|
||||
{
|
||||
return (bool) mraa_pin_mode_test(pin,mode);
|
||||
return (bool) mraa_pin_mode_test(pin, (mraa_pinmodes_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,7 +123,8 @@ bool pinModeTest(int pin, mraa_pinmodes_t mode)
|
||||
*
|
||||
* @return raw bits being read from kernel module. Zero if no ADC
|
||||
*/
|
||||
unsigned int adcRawBits()
|
||||
inline unsigned int
|
||||
adcRawBits()
|
||||
{
|
||||
return mraa_adc_raw_bits();
|
||||
}
|
||||
@@ -111,20 +134,173 @@ unsigned int adcRawBits()
|
||||
*
|
||||
* @return return actual bit size the adc value should be understood as.
|
||||
*/
|
||||
unsigned int adcSupportedBits()
|
||||
inline unsigned int
|
||||
adcSupportedBits()
|
||||
{
|
||||
return mraa_adc_supported_bits();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Platform Name. Returns NULL if no platform inited.
|
||||
*
|
||||
* @return platform name
|
||||
*/
|
||||
inline std::string
|
||||
getPlatformName()
|
||||
{
|
||||
std::string ret_val(mraa_get_platform_name());
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return platform versioning info. Returns NULL if no info present.
|
||||
*
|
||||
* @param optional subplatform identifier
|
||||
* @return platform versioning info
|
||||
*/
|
||||
inline std::string
|
||||
getPlatformVersion(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
|
||||
{
|
||||
std::string ret_val(mraa_get_platform_version(platform_offset));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return count of physical pins on the running platform
|
||||
*
|
||||
* @return uint of physical pins.
|
||||
*/
|
||||
inline unsigned int
|
||||
getPinCount()
|
||||
{
|
||||
return mraa_get_pin_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform usable I2C bus count, board must be initialised.
|
||||
*
|
||||
* @return number f usable I2C bus count on the current platform. Function will
|
||||
* return -1 on failure
|
||||
*/
|
||||
inline int
|
||||
getI2cBusCount()
|
||||
{
|
||||
return mraa_get_i2c_bus_count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get I2C adapter number in sysfs.
|
||||
*
|
||||
* @param i2c_bus the logical I2C bus number
|
||||
* @return I2C adapter number in sysfs. Function will return -1 on failure
|
||||
*/
|
||||
inline int
|
||||
getI2cBusId(unsigned int i2c_bus)
|
||||
{
|
||||
return mraa_get_i2c_bus_id(i2c_bus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of pin, board must be initialised.
|
||||
*
|
||||
* @param pin number
|
||||
*
|
||||
* @return char* of pin name
|
||||
*/
|
||||
inline std::string
|
||||
getPinName(int pin)
|
||||
{
|
||||
std::string ret_val(mraa_get_pin_name(pin));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the log level to use from 0-7 where 7 is very verbose. These are the
|
||||
* syslog log levels, see syslog(3) for more information on the levels.
|
||||
*
|
||||
* @param level
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t setLogLevel(int level)
|
||||
inline Result
|
||||
setLogLevel(int level)
|
||||
{
|
||||
return mraa_set_log_level(level);
|
||||
return (Result) mraa_set_log_level(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect presence of sub platform.
|
||||
*
|
||||
* @return bool true if sub platform is present and initialized, false otherwise
|
||||
*/
|
||||
inline bool
|
||||
hasSubPlatform()
|
||||
{
|
||||
return static_cast<bool>(mraa_has_sub_platform());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if pin or bus id includes sub platform mask.
|
||||
*
|
||||
* @param int pin or bus number
|
||||
*
|
||||
* @return mraa_boolean_t 1 if pin or bus is for sub platform, 0 otherwise
|
||||
*/
|
||||
inline bool
|
||||
isSubPlatformId(int pin_or_bus_id)
|
||||
{
|
||||
return static_cast<bool>(mraa_is_sub_platform_id(pin_or_bus_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pin or bus index to corresponding sub platform id.
|
||||
*
|
||||
* @param int pin or bus index
|
||||
*
|
||||
* @return int sub platform pin or bus number
|
||||
*/
|
||||
inline int
|
||||
getSubPlatformId(int pin_or_bus_index)
|
||||
{
|
||||
return mraa_get_sub_platform_id(pin_or_bus_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert pin or bus sub platform id to index.
|
||||
*
|
||||
* @param int sub platform pin or bus id
|
||||
*
|
||||
* @return int pin or bus index
|
||||
*/
|
||||
inline int
|
||||
getSubPlatformIndex(int pin_or_bus_id)
|
||||
{
|
||||
return mraa_get_sub_platform_index(pin_or_bus_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default i2c bus, board must be initialised.
|
||||
*
|
||||
* @param optional subplatform identifier
|
||||
* @return default i2c bus for paltform
|
||||
*/
|
||||
inline int
|
||||
getDefaultI2cBus(int platform_offset=MRAA_MAIN_PLATFORM_OFFSET)
|
||||
{
|
||||
return mraa_get_default_i2c_bus(platform_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add mraa subplatform
|
||||
*
|
||||
* @param subplatformtype the type of subplatform to add
|
||||
* (e.g. MRAA_GENERIC_FIRMATA)
|
||||
* @param uart_dev subplatform device string (e.g. "/dev/ttyACM0")
|
||||
* @return Result of operation
|
||||
*/
|
||||
inline Result
|
||||
addSubplatform(Platform subplatformtype, std::string uart_dev)
|
||||
{
|
||||
return (Result) mraa_add_subplatform((mraa_platform_t) subplatformtype, uart_dev.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
101
api/mraa/firmata.h
Normal file
101
api/mraa/firmata.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Firmata IO
|
||||
*
|
||||
* Firmata IO lets you SYSEX messages construct and ask for a callback on a
|
||||
* SYSEX messages. This is meant to provide a way to call custom firmata APIs
|
||||
* especially using the Custom firmata API
|
||||
*
|
||||
* @snippet firmata_curie_imu.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _firmata. This context
|
||||
* refers to one firmata 'extension' letting you write/return SYSEX messages
|
||||
* directly
|
||||
*/
|
||||
typedef struct _firmata* mraa_firmata_context;
|
||||
|
||||
/**
|
||||
* Initialise firmata context on a feature. This feature is what will be
|
||||
* listened on if you request a response callback
|
||||
*
|
||||
* @param firmata feature
|
||||
* @return firmata context or NULL
|
||||
*/
|
||||
mraa_firmata_context mraa_firmata_init(int feature);
|
||||
|
||||
/**
|
||||
* Sends a custom SYSEX message to the firmata board.
|
||||
*
|
||||
* @param dev The Firmata context
|
||||
* @param msg The SYSEX message
|
||||
* @param length The length of the sysex message
|
||||
*/
|
||||
mraa_result_t mraa_firmata_write_sysex(mraa_firmata_context dev, char* msg, int length);
|
||||
|
||||
/**
|
||||
* Set a callback on 'feature'. This function is not thread safe and threads
|
||||
* calling it need to make sure they are the only thread calling this.
|
||||
*
|
||||
* @param dev The Firmata context
|
||||
* @param fptr Function pointer to function to be called when interupt is
|
||||
* triggered, the returned buffer and length are the arguments.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_firmata_response(mraa_firmata_context dev, void (*fptr)(uint8_t*, int));
|
||||
|
||||
/**
|
||||
* Stop getting events on feature. This is more efficient than mraa_firmata_close
|
||||
* as it can be re-enabled without adding a feature
|
||||
*
|
||||
* @param dev The Firmata context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_firmata_response_stop(mraa_firmata_context dev);
|
||||
|
||||
/**
|
||||
* Free all firmata handle resources, this will leave an element in an array
|
||||
* internally that will be skipped, avoid closing many firmata contexts often
|
||||
* as there is a cost to doing this
|
||||
*
|
||||
* @param dev The Firmata context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_firmata_close(mraa_firmata_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@@ -28,11 +28,10 @@
|
||||
* @file
|
||||
* @brief General Purpose IO
|
||||
*
|
||||
* Gpio is the General Purpose IO interface to libmraa. It's features depends on
|
||||
* Gpio is the General Purpose IO interface to libmraa. Its features depend on
|
||||
* the board type used, it can use gpiolibs (exported via a kernel module
|
||||
* through sysfs), or memory mapped IO via a /dev/uio device or /dev/mem
|
||||
* depending again on the board configuratio, or memory mapped IO via a
|
||||
* /dev/uio device or /dev/mem depending again on the board configuration
|
||||
* depending again on the board configuration.
|
||||
*
|
||||
* @snippet gpio_read6.c Interesting
|
||||
*/
|
||||
@@ -41,15 +40,17 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
|
||||
#include <jni.h>
|
||||
extern "C" {
|
||||
void mraa_java_isr_callback(void *args);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _gpio
|
||||
*/
|
||||
@@ -59,29 +60,31 @@ typedef struct _gpio* mraa_gpio_context;
|
||||
* Gpio Output modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
|
||||
MRAA_GPIO_PULLUP = 1, /**< Resistive High */
|
||||
MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
|
||||
MRAA_GPIO_HIZ = 3 /**< High Z State */
|
||||
} gpio_mode_t;
|
||||
MRAA_GPIO_STRONG = 0, /**< Default. Strong high and low */
|
||||
MRAA_GPIO_PULLUP = 1, /**< Resistive High */
|
||||
MRAA_GPIO_PULLDOWN = 2, /**< Resistive Low */
|
||||
MRAA_GPIO_HIZ = 3 /**< High Z State */
|
||||
} mraa_gpio_mode_t;
|
||||
|
||||
/**
|
||||
* Gpio Direction options
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
|
||||
MRAA_GPIO_IN = 1 /**< Input */
|
||||
} gpio_dir_t;
|
||||
MRAA_GPIO_OUT = 0, /**< Output. A Mode can also be set */
|
||||
MRAA_GPIO_IN = 1, /**< Input */
|
||||
MRAA_GPIO_OUT_HIGH = 2, /**< Output. Init High */
|
||||
MRAA_GPIO_OUT_LOW = 3 /**< Output. Init Low */
|
||||
} mraa_gpio_dir_t;
|
||||
|
||||
/**
|
||||
* Gpio Edge types for interupts
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
MRAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
MRAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
MRAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
} gpio_edge_t;
|
||||
MRAA_GPIO_EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
MRAA_GPIO_EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
MRAA_GPIO_EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
MRAA_GPIO_EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
} mraa_gpio_edge_t;
|
||||
|
||||
/**
|
||||
* Initialise gpio_context, based on board number
|
||||
@@ -106,7 +109,7 @@ mraa_gpio_context mraa_gpio_init_raw(int gpiopin);
|
||||
* @param mode The edge mode to set the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
|
||||
mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, mraa_gpio_edge_t mode);
|
||||
|
||||
/**
|
||||
* Set an interupt on pin
|
||||
@@ -118,7 +121,7 @@ mraa_result_t mraa_gpio_edge_mode(mraa_gpio_context dev, gpio_edge_t mode);
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, gpio_edge_t edge, void (*fptr)(void *), void * args);
|
||||
mraa_result_t mraa_gpio_isr(mraa_gpio_context dev, mraa_gpio_edge_t edge, void (*fptr)(void*), void* args);
|
||||
|
||||
/**
|
||||
* Stop the current interupt watcher on this Gpio, and set the Gpio edge mode
|
||||
@@ -136,7 +139,7 @@ mraa_result_t mraa_gpio_isr_exit(mraa_gpio_context dev);
|
||||
* @param mode The Gpio Output Mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode);
|
||||
mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, mraa_gpio_mode_t mode);
|
||||
|
||||
/**
|
||||
* Set Gpio direction
|
||||
@@ -145,7 +148,16 @@ mraa_result_t mraa_gpio_mode(mraa_gpio_context dev, gpio_mode_t mode);
|
||||
* @param dir The direction of the Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir);
|
||||
mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, mraa_gpio_dir_t dir);
|
||||
|
||||
/**
|
||||
* Read Gpio direction
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @param dir The address where to store the Gpio direction
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_gpio_read_dir(mraa_gpio_context dev, mraa_gpio_dir_t *dir);
|
||||
|
||||
/**
|
||||
* Close the Gpio context
|
||||
@@ -157,7 +169,8 @@ mraa_result_t mraa_gpio_dir(mraa_gpio_context dev, gpio_dir_t dir);
|
||||
mraa_result_t mraa_gpio_close(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Read the Gpio value.
|
||||
* Read the Gpio value. This can be 0 or 1. A resonse of -1 means that there
|
||||
* was a fatal error.
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return Result of operation
|
||||
@@ -191,6 +204,22 @@ mraa_result_t mraa_gpio_owner(mraa_gpio_context dev, mraa_boolean_t owner);
|
||||
*/
|
||||
mraa_result_t mraa_gpio_use_mmaped(mraa_gpio_context dev, mraa_boolean_t mmap);
|
||||
|
||||
/**
|
||||
* Get a pin number of the gpio, invalid will return -1
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return Pin number
|
||||
*/
|
||||
int mraa_gpio_get_pin(mraa_gpio_context dev);
|
||||
|
||||
/**
|
||||
* Get a gpio number as used within sysfs, invalid will return -1
|
||||
*
|
||||
* @param dev The Gpio context
|
||||
* @return gpio number
|
||||
*/
|
||||
int mraa_gpio_get_pin_raw(mraa_gpio_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -25,8 +25,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "gpio.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa {
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
#include <uv.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
// These enums must match the enums in gpio.h
|
||||
|
||||
@@ -34,28 +43,30 @@ namespace mraa {
|
||||
* Gpio Output modes
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_STRONG = 0, /**< No interrupt on Gpio */
|
||||
MODE_PULLUP = 1, /**< Interupt on rising & falling */
|
||||
MODE_PULLDOWN = 2, /**< Interupt on rising only */
|
||||
MODE_HIZ = 3 /**< Interupt on falling only */
|
||||
MODE_STRONG = 0, /**< Default. Strong High and Low */
|
||||
MODE_PULLUP = 1, /**< Resistive High */
|
||||
MODE_PULLDOWN = 2, /**< Resistive Low */
|
||||
MODE_HIZ = 3 /**< High Z State */
|
||||
} Mode;
|
||||
|
||||
/**
|
||||
* Gpio Direction options
|
||||
*/
|
||||
typedef enum {
|
||||
DIR_OUT = 0, /**< Output. A Mode can also be set */
|
||||
DIR_IN = 1 /**< Input */
|
||||
DIR_OUT = 0, /**< Output. A Mode can also be set */
|
||||
DIR_IN = 1, /**< Input */
|
||||
DIR_OUT_HIGH = 2, /**< Output. Init High */
|
||||
DIR_OUT_LOW = 3 /**< Output. Init Low */
|
||||
} Dir;
|
||||
|
||||
/**
|
||||
* Gpio Edge types for interupts
|
||||
*/
|
||||
typedef enum {
|
||||
EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
EDGE_NONE = 0, /**< No interrupt on Gpio */
|
||||
EDGE_BOTH = 1, /**< Interupt on rising & falling */
|
||||
EDGE_RISING = 2, /**< Interupt on rising only */
|
||||
EDGE_FALLING = 3 /**< Interupt on falling only */
|
||||
} Edge;
|
||||
|
||||
/**
|
||||
@@ -65,117 +76,237 @@ typedef enum {
|
||||
*
|
||||
* @snippet Blink-IO.cpp Interesting
|
||||
*/
|
||||
class Gpio {
|
||||
public:
|
||||
/**
|
||||
* Instanciates a Gpio object
|
||||
*
|
||||
* @param pin pin number to use
|
||||
* @param owner (optional) Set pin owner, default behaviour is to 'own'
|
||||
* the pin if we exported it. This means we will close it on destruct.
|
||||
* Otherwise it will get left open. This is only valid in sysfs use
|
||||
* cases
|
||||
* @param raw (optional) Raw pins will use gpiolibs pin numbering from
|
||||
* the kernel module. Note that you will not get any muxers set up for
|
||||
* you so this may not always work as expected.
|
||||
*/
|
||||
Gpio(int pin, bool owner=true, bool raw=false) {
|
||||
if (raw)
|
||||
m_gpio = mraa_gpio_init_raw(pin);
|
||||
else
|
||||
m_gpio = mraa_gpio_init(pin);
|
||||
if (!owner)
|
||||
mraa_gpio_owner(m_gpio, 0);
|
||||
class Gpio
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Instanciates a Gpio object
|
||||
*
|
||||
* @param pin pin number to use
|
||||
* @param owner (optional) Set pin owner, default behaviour is to 'own'
|
||||
* the pin if we exported it. This means we will close it on destruct.
|
||||
* Otherwise it will get left open. This is only valid in sysfs use
|
||||
* cases
|
||||
* @param raw (optional) Raw pins will use gpiolibs pin numbering from
|
||||
* the kernel module. Note that you will not get any muxers set up for
|
||||
* you so this may not always work as expected.
|
||||
*/
|
||||
Gpio(int pin, bool owner = true, bool raw = false)
|
||||
{
|
||||
if (raw) {
|
||||
m_gpio = mraa_gpio_init_raw(pin);
|
||||
} else {
|
||||
m_gpio = mraa_gpio_init(pin);
|
||||
}
|
||||
/**
|
||||
* Gpio object destructor, this will only unexport the gpio if we where
|
||||
* the owner
|
||||
*/
|
||||
~Gpio() {
|
||||
mraa_gpio_close(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Set the edge mode for ISR
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t edge(Edge mode) {
|
||||
return mraa_gpio_edge_mode(m_gpio, (gpio_edge_t) mode);
|
||||
}
|
||||
#if defined(SWIGPYTHON)
|
||||
mraa_result_t isr(Edge mode, PyObject *pyfunc, PyObject* args) {
|
||||
return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, (void (*) (void *)) pyfunc, (void *) args);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Sets a callback to be called when pin value changes
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @param fptr Function pointer to function to be called when interupt is
|
||||
* triggered
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t isr(Edge mode, void (*fptr)(void *), void * args) {
|
||||
return mraa_gpio_isr(m_gpio, (gpio_edge_t) mode, fptr, args);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Exits callback - this call will not kill the isr thread imediatlu
|
||||
* but only when it is out of it's critical section
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t isrExit() {
|
||||
return mraa_gpio_isr_exit(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Change Gpio mode
|
||||
*
|
||||
* @param mode The mode to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mode(Mode mode) {
|
||||
return mraa_gpio_mode(m_gpio, (gpio_mode_t) mode);
|
||||
}
|
||||
/**
|
||||
* Change Gpio direction
|
||||
*
|
||||
* @param dir The direction to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t dir(Dir dir) {
|
||||
return mraa_gpio_dir(m_gpio, (gpio_dir_t) dir);
|
||||
}
|
||||
/**
|
||||
* Read value from Gpio
|
||||
*
|
||||
* @return Gpio value
|
||||
*/
|
||||
int read() {
|
||||
return mraa_gpio_read(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Write value to Gpio
|
||||
*
|
||||
* @param value Value to write to Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(int value) {
|
||||
return mraa_gpio_write(m_gpio, value);
|
||||
}
|
||||
/**
|
||||
* Enable use of mmap i/o if available.
|
||||
*
|
||||
* @param enable true to use mmap
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t useMmap(bool enable) {
|
||||
return mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
|
||||
}
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
};
|
||||
|
||||
if (m_gpio == NULL) {
|
||||
throw std::invalid_argument("Invalid GPIO pin specified");
|
||||
}
|
||||
|
||||
if (!owner) {
|
||||
mraa_gpio_owner(m_gpio, 0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gpio object destructor, this will only unexport the gpio if we where
|
||||
* the owner
|
||||
*/
|
||||
~Gpio()
|
||||
{
|
||||
mraa_gpio_close(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Set the edge mode for ISR
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
edge(Edge mode)
|
||||
{
|
||||
return (Result) mraa_gpio_edge_mode(m_gpio, (mraa_gpio_edge_t) mode);
|
||||
}
|
||||
#if defined(SWIGPYTHON)
|
||||
Result
|
||||
isr(Edge mode, PyObject* pyfunc, PyObject* args)
|
||||
{
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, (void (*) (void*)) pyfunc, (void*) args);
|
||||
}
|
||||
#elif defined(SWIGJAVASCRIPT)
|
||||
static void
|
||||
v8isr(uv_work_t* req, int status)
|
||||
{
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||
#endif
|
||||
mraa::Gpio* This = (mraa::Gpio*) req->data;
|
||||
int argc = 1;
|
||||
v8::Local<v8::Value> argv[] = { SWIGV8_INTEGER_NEW(-1) };
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
v8::Local<v8::Function> f = v8::Local<v8::Function>::New(v8::Isolate::GetCurrent(), This->m_v8isr);
|
||||
f->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
|
||||
#else
|
||||
This->m_v8isr->Call(SWIGV8_CURRENT_CONTEXT()->Global(), argc, argv);
|
||||
#endif
|
||||
delete req;
|
||||
}
|
||||
|
||||
static void
|
||||
nop(uv_work_t* req)
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
static void
|
||||
uvwork(void* ctx)
|
||||
{
|
||||
uv_work_t* req = new uv_work_t;
|
||||
req->data = ctx;
|
||||
uv_queue_work(uv_default_loop(), req, nop, v8isr);
|
||||
}
|
||||
|
||||
Result
|
||||
isr(Edge mode, v8::Handle<v8::Function> func)
|
||||
{
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
m_v8isr.Reset(v8::Isolate::GetCurrent(), func);
|
||||
#else
|
||||
m_v8isr = v8::Persistent<v8::Function>::New(func);
|
||||
#endif
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, &uvwork, this);
|
||||
}
|
||||
#elif defined(SWIGJAVA) || defined(JAVACALLBACK)
|
||||
Result
|
||||
isr(Edge mode, jobject runnable)
|
||||
{
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, mraa_java_isr_callback, runnable);
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* Sets a callback to be called when pin value changes
|
||||
*
|
||||
* @param mode The edge mode to set
|
||||
* @param fptr Function pointer to function to be called when interupt is
|
||||
* triggered
|
||||
* @param args Arguments passed to the interrupt handler (fptr)
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
isr(Edge mode, void (*fptr)(void*), void* args)
|
||||
{
|
||||
return (Result) mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) mode, fptr, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exits callback - this call will not kill the isr thread immediatly
|
||||
* but only when it is out of it's critical section
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
isrExit()
|
||||
{
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
#if NODE_MODULE_VERSION >= 0x000D
|
||||
m_v8isr.Reset();
|
||||
#else
|
||||
m_v8isr.Dispose();
|
||||
m_v8isr.Clear();
|
||||
#endif
|
||||
#endif
|
||||
return (Result) mraa_gpio_isr_exit(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Change Gpio mode
|
||||
*
|
||||
* @param mode The mode to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
mode(Mode mode)
|
||||
{
|
||||
return (Result )mraa_gpio_mode(m_gpio, (mraa_gpio_mode_t) mode);
|
||||
}
|
||||
/**
|
||||
* Change Gpio direction
|
||||
*
|
||||
* @param dir The direction to change the gpio into
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
dir(Dir dir)
|
||||
{
|
||||
return (Result )mraa_gpio_dir(m_gpio, (mraa_gpio_dir_t) dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read Gpio direction
|
||||
*
|
||||
* @throw std::runtime_error in case of failure
|
||||
* @return Result of operation
|
||||
*/
|
||||
Dir
|
||||
readDir()
|
||||
{
|
||||
mraa_gpio_dir_t dir;
|
||||
if (mraa_gpio_read_dir(m_gpio, &dir) != MRAA_SUCCESS) {
|
||||
throw std::runtime_error("Failed to read direction");
|
||||
}
|
||||
return (Dir) dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read value from Gpio
|
||||
*
|
||||
* @return Gpio value
|
||||
*/
|
||||
int
|
||||
read()
|
||||
{
|
||||
return mraa_gpio_read(m_gpio);
|
||||
}
|
||||
/**
|
||||
* Write value to Gpio
|
||||
*
|
||||
* @param value Value to write to Gpio
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
write(int value)
|
||||
{
|
||||
return (Result) mraa_gpio_write(m_gpio, value);
|
||||
}
|
||||
/**
|
||||
* Enable use of mmap i/o if available.
|
||||
*
|
||||
* @param enable true to use mmap
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
useMmap(bool enable)
|
||||
{
|
||||
return (Result) mraa_gpio_use_mmaped(m_gpio, (mraa_boolean_t) enable);
|
||||
}
|
||||
/**
|
||||
* Get pin number of Gpio. If raw param is True will return the
|
||||
* number as used within sysfs. Invalid will return -1.
|
||||
*
|
||||
* @param raw (optional) get the raw gpio number.
|
||||
* @return Pin number
|
||||
*/
|
||||
int
|
||||
getPin(bool raw = false)
|
||||
{
|
||||
if (raw) {
|
||||
return mraa_gpio_get_pin_raw(m_gpio);
|
||||
}
|
||||
return mraa_gpio_get_pin(m_gpio);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_gpio_context m_gpio;
|
||||
#if defined(SWIGJAVASCRIPT)
|
||||
v8::Persistent<v8::Function> m_v8isr;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ typedef struct _i2c* mraa_i2c_context;
|
||||
mraa_i2c_context mraa_i2c_init(int bus);
|
||||
|
||||
/**
|
||||
* Initialise i2c context, passing in spi bus to use.
|
||||
* Initialise i2c context, passing in the i2c bus to use.
|
||||
*
|
||||
* @param bus The i2c bus to use i.e. /dev/i2c-2 would be "2"
|
||||
* @return i2c context or NULL
|
||||
@@ -69,44 +69,76 @@ mraa_i2c_context mraa_i2c_init(int bus);
|
||||
mraa_i2c_context mraa_i2c_init_raw(unsigned int bus);
|
||||
|
||||
/**
|
||||
* Sets the frequency of the i2c context
|
||||
* Sets the frequency of the i2c context. Most platforms do not support this.
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param hz The bus frequency in hertz
|
||||
* @param mode The bus mode
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, int hz);
|
||||
mraa_result_t mraa_i2c_frequency(mraa_i2c_context dev, mraa_i2c_mode_t mode);
|
||||
|
||||
/**
|
||||
* Read from an i2c context
|
||||
* Simple bulk read from an i2c context, this will always begin with the i2c
|
||||
* offset 0x0
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data pointer to the byte array to read data in to
|
||||
* @param length max number of bytes to read
|
||||
* @return length of the read in bytes or 0
|
||||
*/
|
||||
int mraa_i2c_read(mraa_i2c_context dev, uint8_t *data, int length);
|
||||
int mraa_i2c_read(mraa_i2c_context dev, uint8_t* data, int length);
|
||||
|
||||
/**
|
||||
* Read a single byte from the i2c context
|
||||
* Simple read for a single byte from the i2c context, this will always begin
|
||||
* with the i2c offset 0x0
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @return The result of the read or -1 if failed
|
||||
* @return The result of the read and 0 if failed
|
||||
*/
|
||||
uint8_t mraa_i2c_read_byte(mraa_i2c_context dev);
|
||||
|
||||
/**
|
||||
* Write to an i2c context
|
||||
* Read a single byte from i2c context, from designated register
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param command The register
|
||||
* @return The result of the read and 0 if failed
|
||||
*/
|
||||
uint8_t mraa_i2c_read_byte_data(mraa_i2c_context dev, const uint8_t command);
|
||||
|
||||
/**
|
||||
* Read a single word from i2c context, from designated register
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param command The register
|
||||
* @return The result of the read and 0 if failed
|
||||
*/
|
||||
uint16_t mraa_i2c_read_word_data(mraa_i2c_context dev, const uint8_t command);
|
||||
|
||||
/**
|
||||
* Bulk read from i2c context, starting from designated register
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param command The register
|
||||
* @param data pointer to the byte array to read data in to
|
||||
* @param length max number of bytes to read
|
||||
* @return The length in bytes passed to the function or -1
|
||||
*/
|
||||
int mraa_i2c_read_bytes_data(mraa_i2c_context dev, uint8_t command, uint8_t* data, int length);
|
||||
|
||||
/**
|
||||
* Write length bytes to the bus, the first byte in the array is the
|
||||
* command/register to write
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data pointer to the byte array to be written
|
||||
* @param length the number of bytes to transmit
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int length);
|
||||
mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t* data, int length);
|
||||
|
||||
/**
|
||||
* Write a single byte to an i2c context
|
||||
* Write a single byte to an i2c context, always at offset 0x0
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data The byte to write
|
||||
@@ -114,6 +146,26 @@ mraa_result_t mraa_i2c_write(mraa_i2c_context dev, const uint8_t *data, int leng
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
|
||||
|
||||
/**
|
||||
* Write a single byte to an i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data The byte to write
|
||||
* @param command The register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write_byte_data(mraa_i2c_context dev, const uint8_t data, const uint8_t command);
|
||||
|
||||
/**
|
||||
* Write a single word to an i2c context
|
||||
*
|
||||
* @param dev The i2c context
|
||||
* @param data The word to write
|
||||
* @param command The register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_write_word_data(mraa_i2c_context dev, const uint16_t data, const uint8_t command);
|
||||
|
||||
/**
|
||||
* Sets the i2c context address.
|
||||
*
|
||||
@@ -123,7 +175,7 @@ mraa_result_t mraa_i2c_write_byte(mraa_i2c_context dev, const uint8_t data);
|
||||
* general call address.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, int address);
|
||||
mraa_result_t mraa_i2c_address(mraa_i2c_context dev, uint8_t address);
|
||||
|
||||
/**
|
||||
* De-inits an mraa_i2c_context device
|
||||
|
286
api/mraa/i2c.hpp
286
api/mraa/i2c.hpp
@@ -25,8 +25,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "i2c.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to Inter-Integrated Circuit
|
||||
@@ -37,117 +40,182 @@ namespace mraa {
|
||||
*
|
||||
* @snippet I2c-compass.cpp Interesting
|
||||
*/
|
||||
class I2c {
|
||||
public:
|
||||
/**
|
||||
* Instantiates an i2c bus. Multiple instances of the same bus can
|
||||
* exist and the bus is not guarranteed to be on the correct address
|
||||
* before read/write.
|
||||
*
|
||||
* @param bus The i2c bus to use
|
||||
* @param raw Whether to disable pinmapper for your board
|
||||
*/
|
||||
I2c(int bus, bool raw=false) {
|
||||
if (raw)
|
||||
m_i2c = mraa_i2c_init_raw(bus);
|
||||
else
|
||||
m_i2c = mraa_i2c_init(bus);
|
||||
class I2c
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Instantiates an i2c bus. Multiple instances of the same bus can
|
||||
* exist and the bus is not guarranteed to be on the correct address
|
||||
* before read/write.
|
||||
*
|
||||
* @param bus The i2c bus to use
|
||||
* @param raw Whether to disable pinmapper for your board
|
||||
*/
|
||||
I2c(int bus, bool raw = false)
|
||||
{
|
||||
if (raw) {
|
||||
m_i2c = mraa_i2c_init_raw(bus);
|
||||
} else {
|
||||
m_i2c = mraa_i2c_init(bus);
|
||||
}
|
||||
/**
|
||||
* Closes the I2c Bus used. This does not guarrantee the bus will not
|
||||
* be usable by anyone else or communicates this disconnect to any
|
||||
* slaves.
|
||||
*/
|
||||
~I2c() {
|
||||
mraa_i2c_stop(m_i2c);
|
||||
}
|
||||
/**
|
||||
* Sets the i2c Frequency for communication. Your board may not support
|
||||
* the set frequency. Anyone can change this at any time and this will
|
||||
* affect every slave on the bus
|
||||
*
|
||||
* @param hz Frequency to set the bus to in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t frequency(int hz) {
|
||||
return mraa_i2c_frequency(m_i2c, hz);
|
||||
}
|
||||
/**
|
||||
* Set the slave to talk to, typically called before every read/write
|
||||
* operation
|
||||
*
|
||||
* @param address Communicate to the i2c slave on this address
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t address(int address) {
|
||||
return mraa_i2c_address(m_i2c, address);
|
||||
}
|
||||
/**
|
||||
* Read exactly one byte from the bus
|
||||
*
|
||||
* @return char read from the bus
|
||||
*/
|
||||
unsigned char read() {
|
||||
return (unsigned char) mraa_i2c_read_byte(m_i2c);
|
||||
}
|
||||
/**
|
||||
* Read mutliple bytes from the bus
|
||||
*
|
||||
* @param data Buffer to write into
|
||||
* @param length Size of read
|
||||
* @return length of the read or 0 if failed
|
||||
*/
|
||||
int read(char *data, size_t length) {
|
||||
return mraa_i2c_read(m_i2c, (uint8_t*) data, (int) length);
|
||||
}
|
||||
/**
|
||||
* Read length bytes from the bus, and return as a std::string note
|
||||
* that this is not a null terminated string
|
||||
*
|
||||
* @param length Size of read to make
|
||||
* @return pointer to std::string
|
||||
*/
|
||||
std::string read(size_t length) {
|
||||
char* data = (char*) malloc(sizeof(char) * length);
|
||||
mraa_i2c_read(m_i2c, (uint8_t*) data, (int) length);
|
||||
std::string str(data, (int) length);
|
||||
free(data);
|
||||
return str;
|
||||
}
|
||||
/**
|
||||
* Write one byte to the bus
|
||||
*
|
||||
* @param data Buffer to send on the bus
|
||||
* @param length Size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(char* data, size_t length) {
|
||||
return mraa_i2c_write(m_i2c, (const unsigned char *)data, (int) length);
|
||||
if (m_i2c == NULL) {
|
||||
throw std::invalid_argument("Invalid i2c bus");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to an i2c register
|
||||
*
|
||||
* @param reg Register to write to
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t writeReg(char reg, char data) {
|
||||
const unsigned char buf[2] = {(unsigned char) reg, (unsigned char) data};
|
||||
return mraa_i2c_write(m_i2c, buf, 2);
|
||||
}
|
||||
/**
|
||||
* Closes the I2c Bus used. This does not guarrantee the bus will not
|
||||
* be usable by anyone else or communicates this disconnect to any
|
||||
* slaves.
|
||||
*/
|
||||
~I2c()
|
||||
{
|
||||
mraa_i2c_stop(m_i2c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write multiple bytes to the bus
|
||||
*
|
||||
* @param data The byte to send on the bus
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(char data) {
|
||||
return mraa_i2c_write_byte(m_i2c, data);
|
||||
}
|
||||
private:
|
||||
mraa_i2c_context m_i2c;
|
||||
/**
|
||||
* Sets the i2c Frequency for communication. Your board may not support
|
||||
* the set frequency. Anyone can change this at any time and this will
|
||||
* affect every slave on the bus
|
||||
*
|
||||
* @param mode Frequency to set the bus to
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
frequency(I2cMode mode)
|
||||
{
|
||||
return (Result) mraa_i2c_frequency(m_i2c, (mraa_i2c_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the slave to talk to, typically called before every read/write
|
||||
* operation
|
||||
*
|
||||
* @param address Communicate to the i2c slave on this address
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
address(uint8_t address)
|
||||
{
|
||||
return (Result) mraa_i2c_address(m_i2c, address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read exactly one byte from the bus
|
||||
*
|
||||
* @return char read from the bus
|
||||
*/
|
||||
uint8_t
|
||||
readByte()
|
||||
{
|
||||
return (uint8_t) mraa_i2c_read_byte(m_i2c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read length bytes from the bus into *data pointer
|
||||
*
|
||||
* @param data Data to read into
|
||||
* @param length Size of read in bytes to make
|
||||
* @return length of read, should match length
|
||||
*/
|
||||
int
|
||||
read(uint8_t* data, int length)
|
||||
{
|
||||
return mraa_i2c_read(m_i2c, data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read byte from an i2c register
|
||||
*
|
||||
* @param reg Register to read from
|
||||
* @return char read from register
|
||||
*/
|
||||
uint8_t
|
||||
readReg(uint8_t reg)
|
||||
{
|
||||
return mraa_i2c_read_byte_data(m_i2c, reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read word from an i2c register
|
||||
*
|
||||
* @param reg Register to read from
|
||||
* @return char read from register
|
||||
*/
|
||||
uint16_t
|
||||
readWordReg(uint8_t reg)
|
||||
{
|
||||
return mraa_i2c_read_word_data(m_i2c, reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read length bytes from the bus into *data pointer starting from
|
||||
* an i2c register
|
||||
*
|
||||
* @param reg Register to read from
|
||||
* @param data pointer to the byte array to read data in to
|
||||
* @param length max number of bytes to read
|
||||
* @return length passed to the function or -1
|
||||
*/
|
||||
int
|
||||
readBytesReg(uint8_t reg, uint8_t* data, int length)
|
||||
{
|
||||
return mraa_i2c_read_bytes_data(m_i2c, reg, data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a byte on the bus
|
||||
*
|
||||
* @param data The byte to send on the bus
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
writeByte(uint8_t data)
|
||||
{
|
||||
return (Result) mraa_i2c_write_byte(m_i2c, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write length bytes to the bus, the first byte in the array is the
|
||||
* command/register to write
|
||||
*
|
||||
* @param data Buffer to send on the bus, first byte is i2c command
|
||||
* @param length Size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
write(const uint8_t* data, int length)
|
||||
{
|
||||
return (Result) mraa_i2c_write(m_i2c, data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a byte to an i2c register
|
||||
*
|
||||
* @param reg Register to write to
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
writeReg(uint8_t reg, uint8_t data)
|
||||
{
|
||||
return (Result) mraa_i2c_write_byte_data(m_i2c, data, reg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a word to an i2c register
|
||||
*
|
||||
* @param reg Register to write to
|
||||
* @param data Value to write to register
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
writeWordReg(uint8_t reg, uint16_t data)
|
||||
{
|
||||
return (Result) mraa_i2c_write_word_data(m_i2c, data, reg);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_i2c_context m_i2c;
|
||||
};
|
||||
|
||||
}
|
||||
|
139
api/mraa/iio.h
Normal file
139
api/mraa/iio.h
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "iio_kernel_headers.h"
|
||||
|
||||
typedef struct {
|
||||
int index;
|
||||
int enabled;
|
||||
char* type;
|
||||
mraa_boolean_t lendian;
|
||||
int signedd;
|
||||
unsigned int offset;
|
||||
uint64_t mask;
|
||||
unsigned int bits_used;
|
||||
unsigned int bytes;
|
||||
unsigned int shift;
|
||||
unsigned int location;
|
||||
} mraa_iio_channel;
|
||||
|
||||
typedef struct {
|
||||
char* name;
|
||||
int enabled;
|
||||
} mraa_iio_event;
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief iio
|
||||
*
|
||||
* An iio context represents an IIO device
|
||||
*
|
||||
* @snippet iio_driver.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Opaque pointer definition to the internal struct _iio
|
||||
*/
|
||||
typedef struct _iio* mraa_iio_context;
|
||||
|
||||
/**
|
||||
* Initialise iio context
|
||||
*
|
||||
* @param bus iio device to use
|
||||
* @return i2c context or NULL
|
||||
*/
|
||||
mraa_iio_context mraa_iio_init(int device);
|
||||
|
||||
mraa_result_t mraa_iio_trigger_buffer(mraa_iio_context dev, void (*fptr)(char* data), void* args);
|
||||
|
||||
const char* mraa_iio_get_device_name(mraa_iio_context dev);
|
||||
|
||||
int mraa_iio_get_device_num_by_name(const char* name);
|
||||
|
||||
int mraa_iio_read_size(mraa_iio_context dev);
|
||||
|
||||
mraa_iio_channel* mraa_iio_get_channels(mraa_iio_context dev);
|
||||
|
||||
int mraa_iio_get_channel_count(mraa_iio_context dev);
|
||||
|
||||
mraa_result_t mraa_iio_read_float(mraa_iio_context dev, const char* filename, float* data);
|
||||
|
||||
mraa_result_t mraa_iio_read_int(mraa_iio_context dev, const char* filename, int* data);
|
||||
|
||||
mraa_result_t mraa_iio_read_string(mraa_iio_context dev, const char* filename, char* data, int max_len);
|
||||
|
||||
mraa_result_t mraa_iio_write_float(mraa_iio_context dev, const char* attr_chan, const float data);
|
||||
|
||||
mraa_result_t mraa_iio_write_int(mraa_iio_context dev, const char* attr_chan, const int data);
|
||||
|
||||
mraa_result_t mraa_iio_write_string(mraa_iio_context dev, const char* attr_chan, const char* data);
|
||||
|
||||
mraa_result_t mraa_iio_get_channel_data(mraa_iio_context dev);
|
||||
|
||||
mraa_result_t mraa_iio_get_event_data(mraa_iio_context dev);
|
||||
|
||||
mraa_result_t mraa_iio_event_poll(mraa_iio_context dev, struct iio_event_data* data);
|
||||
|
||||
mraa_result_t
|
||||
mraa_iio_event_setup_callback(mraa_iio_context dev, void (*fptr)(struct iio_event_data* data, void* args), void* args);
|
||||
|
||||
mraa_result_t mraa_iio_event_extract_event(struct iio_event_data* event,
|
||||
int* chan_type,
|
||||
int* modifier,
|
||||
int* type,
|
||||
int* direction,
|
||||
int* channel,
|
||||
int* channel2,
|
||||
int* different);
|
||||
|
||||
mraa_result_t mraa_iio_get_mounting_matrix(mraa_iio_context dev, float mm[9]);
|
||||
|
||||
mraa_result_t mraa_iio_create_trigger(mraa_iio_context dev, const char* trigger);
|
||||
|
||||
mraa_result_t mraa_iio_update_channels(mraa_iio_context dev);
|
||||
/**
|
||||
* De-inits an mraa_iio_context device
|
||||
*
|
||||
* @param dev The iio context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_iio_close(mraa_iio_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
245
api/mraa/iio.hpp
Normal file
245
api/mraa/iio.hpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* Author: Henry Bruce <henry.bruce@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include "iio.h"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
struct IioEventData
|
||||
{
|
||||
int channelType;
|
||||
int modifier;
|
||||
int type;
|
||||
int direction;
|
||||
int channel;
|
||||
int channel2;
|
||||
int diff;
|
||||
};
|
||||
|
||||
class IioHandler
|
||||
{
|
||||
public:
|
||||
virtual void onIioEvent(const IioEventData& eventData) = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief API to Industrial IO
|
||||
*
|
||||
* This file defines the C++ iio interface for libmraa
|
||||
*
|
||||
* @snippet iio_dummy_test.cpp Interesting
|
||||
*/
|
||||
class Iio
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Iio Constructor, takes a device number which will map directly to sysfs
|
||||
* e.g. device 0 maps to /sys/bus/iio/devices/iio:device0
|
||||
*
|
||||
* @param device IIO device number
|
||||
*
|
||||
* @throws std::invalid_argument if initialization fails
|
||||
*/
|
||||
Iio(int device)
|
||||
{
|
||||
m_iio = mraa_iio_init(device);
|
||||
if (m_iio == NULL) {
|
||||
std::ostringstream oss;
|
||||
oss << "IIO device " << device << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iio Constructor
|
||||
*
|
||||
* @param deviceName IIO device name
|
||||
*
|
||||
* @throws std::invalid_argument if initialization fails
|
||||
*/
|
||||
Iio(const std::string& deviceName)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
int id = mraa_iio_get_device_num_by_name(deviceName.c_str());
|
||||
if (id == -1) {
|
||||
oss << "IIO device name " << deviceName << " not found";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
m_iio = mraa_iio_init(id);
|
||||
if (m_iio == NULL) {
|
||||
oss << "IIO device " << deviceName << " is not valid";
|
||||
throw std::invalid_argument(oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iio destructor
|
||||
*/
|
||||
~Iio()
|
||||
{
|
||||
mraa_iio_close(m_iio);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get device name
|
||||
*
|
||||
* @returns The device name
|
||||
*/
|
||||
std::string
|
||||
getDeviceName() const
|
||||
{
|
||||
return mraa_iio_get_device_name(m_iio);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read an int value from specified attribute.
|
||||
*
|
||||
* @param attributeName attribute mame
|
||||
*
|
||||
* @returns The int value
|
||||
*
|
||||
* @throws std::invalid_argument if read fails
|
||||
*/
|
||||
int
|
||||
readInt(const std::string& attributeName) const
|
||||
{
|
||||
int value;
|
||||
mraa_result_t res = mraa_iio_read_int(m_iio, attributeName.c_str(), &value);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
std::ostringstream oss;
|
||||
oss << "IIO readInt for attibute " << attributeName << " failed";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a float value from specified attribute.
|
||||
*
|
||||
* @param attributeName attribute mame
|
||||
*
|
||||
* @returns The float value
|
||||
*
|
||||
* @throws std::invalid_argument if read fails
|
||||
*/
|
||||
float
|
||||
readFloat(const std::string& attributeName) const
|
||||
{
|
||||
float value;
|
||||
mraa_result_t res = mraa_iio_read_float(m_iio, attributeName.c_str(), &value);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
std::ostringstream oss;
|
||||
oss << "IIO readFloat for attibute " << attributeName << " failed";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an int value to specified attribute.
|
||||
*
|
||||
* @param attributeName attribute mame
|
||||
* @param value int value
|
||||
*
|
||||
* @throws std::invalid_argument if write fails
|
||||
*/
|
||||
void
|
||||
writeInt(const std::string& attributeName, int value) const
|
||||
{
|
||||
mraa_result_t res = mraa_iio_write_int(m_iio, attributeName.c_str(), value);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
std::ostringstream oss;
|
||||
oss << "IIO writeInt for attibute " << attributeName << " failed";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a float value to specified attribute.
|
||||
*
|
||||
* @param attributeName attribute mame
|
||||
* @param value float value
|
||||
*
|
||||
* @throws std::invalid_argument if write fails
|
||||
*/
|
||||
void
|
||||
writeFloat(const std::string& attributeName, float value) const
|
||||
{
|
||||
mraa_result_t res = mraa_iio_write_float(m_iio, attributeName.c_str(), value);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
std::ostringstream oss;
|
||||
oss << "IIO writeFloat for attibute " << attributeName << " failed";
|
||||
throw std::runtime_error(oss.str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register event handler.
|
||||
*
|
||||
* @param handler handler class that implements IioHandler
|
||||
*
|
||||
* @throws std::invalid_argument on failure
|
||||
*/
|
||||
void
|
||||
registerEventHandler(IioHandler* handler) const
|
||||
{
|
||||
mraa_result_t res = mraa_iio_event_setup_callback(m_iio, private_event_handler, handler);
|
||||
if (res != MRAA_SUCCESS) {
|
||||
throw std::runtime_error("registerEventHandler failed");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void private_event_handler(iio_event_data* data, void *args)
|
||||
{
|
||||
if (args != NULL) {
|
||||
IioHandler* handler = (IioHandler*)args;
|
||||
IioEventData eventData;
|
||||
int chan_type, modifier, type, direction, channel, channel2, different;
|
||||
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel, &channel2, &different);
|
||||
eventData.channelType = chan_type;
|
||||
eventData.modifier = modifier;
|
||||
eventData.type = type;
|
||||
eventData.direction = direction;
|
||||
eventData.channel = channel;
|
||||
eventData.channel2 = channel2;
|
||||
eventData.diff = different;
|
||||
handler->onIioEvent(eventData);
|
||||
}
|
||||
}
|
||||
|
||||
mraa_iio_context m_iio;
|
||||
};
|
||||
|
||||
}
|
136
api/mraa/iio_kernel_headers.h
Normal file
136
api/mraa/iio_kernel_headers.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//For kernel 4.1+,
|
||||
//#include <linux/iio/types.h>
|
||||
//#include <linux/iio/events.h>
|
||||
|
||||
//linux/iio/types.h
|
||||
enum iio_chan_type {
|
||||
IIO_VOLTAGE,
|
||||
IIO_CURRENT,
|
||||
IIO_POWER,
|
||||
IIO_ACCEL,
|
||||
IIO_ANGL_VEL,
|
||||
IIO_MAGN,
|
||||
IIO_LIGHT,
|
||||
IIO_INTENSITY,
|
||||
IIO_PROXIMITY,
|
||||
IIO_TEMP,
|
||||
IIO_INCLI,
|
||||
IIO_ROT,
|
||||
IIO_ANGL,
|
||||
IIO_TIMESTAMP,
|
||||
IIO_CAPACITANCE,
|
||||
IIO_ALTVOLTAGE,
|
||||
IIO_CCT,
|
||||
IIO_PRESSURE,
|
||||
IIO_HUMIDITYRELATIVE,
|
||||
IIO_ACTIVITY,
|
||||
IIO_STEPS,
|
||||
IIO_ENERGY,
|
||||
IIO_DISTANCE,
|
||||
IIO_VELOCITY,
|
||||
};
|
||||
|
||||
enum iio_modifier {
|
||||
IIO_NO_MOD,
|
||||
IIO_MOD_X,
|
||||
IIO_MOD_Y,
|
||||
IIO_MOD_Z,
|
||||
IIO_MOD_X_AND_Y,
|
||||
IIO_MOD_X_AND_Z,
|
||||
IIO_MOD_Y_AND_Z,
|
||||
IIO_MOD_X_AND_Y_AND_Z,
|
||||
IIO_MOD_X_OR_Y,
|
||||
IIO_MOD_X_OR_Z,
|
||||
IIO_MOD_Y_OR_Z,
|
||||
IIO_MOD_X_OR_Y_OR_Z,
|
||||
IIO_MOD_LIGHT_BOTH,
|
||||
IIO_MOD_LIGHT_IR,
|
||||
IIO_MOD_ROOT_SUM_SQUARED_X_Y,
|
||||
IIO_MOD_SUM_SQUARED_X_Y_Z,
|
||||
IIO_MOD_LIGHT_CLEAR,
|
||||
IIO_MOD_LIGHT_RED,
|
||||
IIO_MOD_LIGHT_GREEN,
|
||||
IIO_MOD_LIGHT_BLUE,
|
||||
IIO_MOD_QUATERNION,
|
||||
IIO_MOD_TEMP_AMBIENT,
|
||||
IIO_MOD_TEMP_OBJECT,
|
||||
IIO_MOD_NORTH_MAGN,
|
||||
IIO_MOD_NORTH_TRUE,
|
||||
IIO_MOD_NORTH_MAGN_TILT_COMP,
|
||||
IIO_MOD_NORTH_TRUE_TILT_COMP,
|
||||
IIO_MOD_RUNNING,
|
||||
IIO_MOD_JOGGING,
|
||||
IIO_MOD_WALKING,
|
||||
IIO_MOD_STILL,
|
||||
IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
|
||||
};
|
||||
|
||||
enum iio_event_type {
|
||||
IIO_EV_TYPE_THRESH,
|
||||
IIO_EV_TYPE_MAG,
|
||||
IIO_EV_TYPE_ROC,
|
||||
IIO_EV_TYPE_THRESH_ADAPTIVE,
|
||||
IIO_EV_TYPE_MAG_ADAPTIVE,
|
||||
IIO_EV_TYPE_CHANGE,
|
||||
};
|
||||
|
||||
enum iio_event_direction {
|
||||
IIO_EV_DIR_EITHER,
|
||||
IIO_EV_DIR_RISING,
|
||||
IIO_EV_DIR_FALLING,
|
||||
IIO_EV_DIR_NONE,
|
||||
};
|
||||
|
||||
//linux/iio/events.h
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
/**
|
||||
* struct iio_event_data - The actual event being pushed to userspace
|
||||
* @id: event identifier
|
||||
* @timestamp: best estimate of time of event occurrence (often from
|
||||
* the interrupt handler)
|
||||
*/
|
||||
struct iio_event_data {
|
||||
unsigned long long int id;
|
||||
long long int timestamp;
|
||||
};
|
||||
|
||||
#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
|
||||
|
||||
#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
|
||||
|
||||
#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F)
|
||||
|
||||
#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
|
||||
|
||||
/* Event code number extraction depends on which type of event we have.
|
||||
* Perhaps review this function in the future*/
|
||||
#define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((short int)(mask & 0xFFFF))
|
||||
#define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((short int)(((mask) >> 16) & 0xFFFF))
|
||||
|
||||
#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
|
||||
#define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1)
|
@@ -186,6 +186,22 @@ mraa_result_t mraa_pwm_config_ms(mraa_pwm_context dev, int period, float duty);
|
||||
*/
|
||||
mraa_result_t mraa_pwm_config_percent(mraa_pwm_context dev, int period, float duty);
|
||||
|
||||
/**
|
||||
* Get the maximum pwm period in us
|
||||
*
|
||||
* @param dev The pwm context to use
|
||||
* @return max pwm in us
|
||||
*/
|
||||
int mraa_pwm_get_max_period(mraa_pwm_context dev);
|
||||
|
||||
/**
|
||||
* Get the minimum pwm period in us
|
||||
*
|
||||
* @param dev The pwm context to use
|
||||
* @return min pwm in us
|
||||
*/
|
||||
int mraa_pwm_get_min_period(mraa_pwm_context dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
327
api/mraa/pwm.hpp
327
api/mraa/pwm.hpp
@@ -25,8 +25,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "pwm.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to Pulse Width Modulation
|
||||
@@ -35,144 +38,192 @@ namespace mraa {
|
||||
*
|
||||
* @snippet Pwm3-cycle.cpp Interesting
|
||||
*/
|
||||
class Pwm {
|
||||
public:
|
||||
/**
|
||||
* instanciates a PWM object on a pin
|
||||
*
|
||||
* @param pin the pin number used on your board
|
||||
* @param chipid the pwmchip to use, use only in raw mode
|
||||
* @param owner if you are the owner of the pin the destructor will
|
||||
* unexport the pin from sysfs, default behaviour is you are the owner
|
||||
* if the pinmapper exported it
|
||||
*/
|
||||
Pwm(int pin, int chipid=-1, bool owner = true) {
|
||||
if (chipid == -1)
|
||||
m_pwm = mraa_pwm_init(pin);
|
||||
else
|
||||
m_pwm = mraa_pwm_init_raw(pin, chipid);
|
||||
if (!owner)
|
||||
mraa_pwm_owner(m_pwm, 0);
|
||||
}
|
||||
/**
|
||||
* Pwm destructor
|
||||
*/
|
||||
~Pwm() {
|
||||
mraa_pwm_close(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the output duty-cycle percentage, as a float
|
||||
*
|
||||
* @param percentage A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t write(float percentage) {
|
||||
return mraa_pwm_write(m_pwm, percentage);
|
||||
}
|
||||
/**
|
||||
* Read the ouput duty-cycle percentage, as a float
|
||||
*
|
||||
* @return A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
*/
|
||||
float read() {
|
||||
return mraa_pwm_read(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the PWM period as seconds represented in a float
|
||||
*
|
||||
* @param period Period represented as a float in seconds
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period(float period) {
|
||||
return mraa_pwm_period(m_pwm, period);
|
||||
}
|
||||
/**
|
||||
* Set period, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period_ms(int ms) {
|
||||
return mraa_pwm_period_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* Set period, microseconds
|
||||
*
|
||||
* @param us microseconds as period
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t period_us(int us) {
|
||||
return mraa_pwm_period_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, As represnted by seconds in a (float)
|
||||
*
|
||||
* @param seconds The duration of a pulse
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth(float seconds) {
|
||||
return mraa_pwm_pulsewidth(m_pwm, seconds);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth_ms(int ms) {
|
||||
return mraa_pwm_pulsewidth_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* The pulsewidth, microseconds
|
||||
*
|
||||
* @param us microseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t pulsewidth_us(int us) {
|
||||
return mraa_pwm_pulsewidth_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set the enable status of the PWM pin. None zero will assume on with
|
||||
* output being driven and 0 will disable the output
|
||||
*
|
||||
* @param enable enable status of pin
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t enable(bool enable) {
|
||||
if (enable)
|
||||
return mraa_pwm_enable(m_pwm, 1);
|
||||
else
|
||||
return mraa_pwm_enable(m_pwm, 0);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty of a PWM object.
|
||||
*
|
||||
* @param period represented in ms.
|
||||
* @param duty represnted in ms as float.
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t config_ms(int period, float duty) {
|
||||
return mraa_pwm_config_ms(m_pwm, period, duty);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty (percent) of a PWM object.
|
||||
*
|
||||
* @param period as represented in ms.
|
||||
* @param duty percentage i.e. 50% = 0.5f
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t config_percent(int period, float duty) {
|
||||
return mraa_pwm_config_percent(m_pwm, period, duty);
|
||||
class Pwm
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* instanciates a PWM object on a pin
|
||||
*
|
||||
* @param pin the pin number used on your board
|
||||
* @param owner if you are the owner of the pin the destructor will
|
||||
* @param chipid the pwmchip to use, use only in raw mode
|
||||
* unexport the pin from sysfs, default behaviour is you are the owner
|
||||
* if the pinmapper exported it
|
||||
*/
|
||||
Pwm(int pin, bool owner = true, int chipid = -1)
|
||||
{
|
||||
if (chipid == -1) {
|
||||
m_pwm = mraa_pwm_init(pin);
|
||||
} else {
|
||||
m_pwm = mraa_pwm_init_raw(chipid, pin);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_pwm_context m_pwm;
|
||||
if (m_pwm == NULL) {
|
||||
throw std::invalid_argument("Error initialising PWM on pin");
|
||||
}
|
||||
|
||||
if (!owner) {
|
||||
mraa_pwm_owner(m_pwm, 0);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Pwm destructor
|
||||
*/
|
||||
~Pwm()
|
||||
{
|
||||
mraa_pwm_close(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the output duty-cycle percentage, as a float
|
||||
*
|
||||
* @param percentage A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
write(float percentage)
|
||||
{
|
||||
return (Result) mraa_pwm_write(m_pwm, percentage);
|
||||
}
|
||||
/**
|
||||
* Read the ouput duty-cycle percentage, as a float
|
||||
*
|
||||
* @return A floating-point value representing percentage of
|
||||
* output. The value should lie between 0.0f (representing on 0%) and
|
||||
* 1.0f Values above or below this range will be set at either 0.0f or
|
||||
* 1.0f
|
||||
*/
|
||||
float
|
||||
read()
|
||||
{
|
||||
return mraa_pwm_read(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Set the PWM period as seconds represented in a float
|
||||
*
|
||||
* @param period Period represented as a float in seconds
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
period(float period)
|
||||
{
|
||||
return (Result) mraa_pwm_period(m_pwm, period);
|
||||
}
|
||||
/**
|
||||
* Set period, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for period
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
period_ms(int ms)
|
||||
{
|
||||
return (Result) mraa_pwm_period_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* Set period, microseconds
|
||||
*
|
||||
* @param us microseconds as period
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
period_us(int us)
|
||||
{
|
||||
return (Result) mraa_pwm_period_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, As represnted by seconds in a (float)
|
||||
*
|
||||
* @param seconds The duration of a pulse
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
pulsewidth(float seconds)
|
||||
{
|
||||
return (Result) mraa_pwm_pulsewidth(m_pwm, seconds);
|
||||
}
|
||||
/**
|
||||
* Set pulsewidth, milliseconds
|
||||
*
|
||||
* @param ms milliseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
pulsewidth_ms(int ms)
|
||||
{
|
||||
return (Result) mraa_pwm_pulsewidth_ms(m_pwm, ms);
|
||||
}
|
||||
/**
|
||||
* The pulsewidth, microseconds
|
||||
*
|
||||
* @param us microseconds for pulsewidth
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
pulsewidth_us(int us)
|
||||
{
|
||||
return (Result) mraa_pwm_pulsewidth_us(m_pwm, us);
|
||||
}
|
||||
/**
|
||||
* Set the enable status of the PWM pin. None zero will assume on with
|
||||
* output being driven and 0 will disable the output
|
||||
*
|
||||
* @param enable enable status of pin
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
enable(bool enable)
|
||||
{
|
||||
return (Result) mraa_pwm_enable(m_pwm, enable);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty of a PWM object.
|
||||
*
|
||||
* @param period represented in ms.
|
||||
* @param duty represnted in ms as float.
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
config_ms(int period, float duty)
|
||||
{
|
||||
return (Result) mraa_pwm_config_ms(m_pwm, period, duty);
|
||||
}
|
||||
/**
|
||||
* Set the period and duty (percent) of a PWM object.
|
||||
*
|
||||
* @param period as represented in ms.
|
||||
* @param duty percentage i.e. 50% = 0.5f
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
config_percent(int period, float duty)
|
||||
{
|
||||
return (Result) mraa_pwm_config_percent(m_pwm, period, duty);
|
||||
}
|
||||
/**
|
||||
* Get the maximum pwm period in us
|
||||
*
|
||||
* @return max pwm in us
|
||||
*/
|
||||
int
|
||||
max_period()
|
||||
{
|
||||
return mraa_pwm_get_max_period(m_pwm);
|
||||
}
|
||||
/**
|
||||
* Get the minimum pwm period in us
|
||||
*
|
||||
* @return min pwm in us
|
||||
*/
|
||||
int
|
||||
min_period()
|
||||
{
|
||||
return mraa_pwm_get_min_period(m_pwm);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_pwm_context m_pwm;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief System Packet Interface
|
||||
* @brief Serial Peripheral Interface
|
||||
*
|
||||
* This file defines the spi interface for libmraa. A Spi object in libmraa
|
||||
* represents a spidev device. Linux spidev devices are created per spi bus and
|
||||
@@ -48,13 +48,17 @@ extern "C" {
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* MRAA supported platform types
|
||||
* MRAA SPI Modes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge, output data (change) on falling edge */
|
||||
MRAA_SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
|
||||
MRAA_SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge, output data (change) on rising edge */
|
||||
MRAA_SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge output data (change) on falling edge */
|
||||
MRAA_SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge,
|
||||
output data (change) on falling edge */
|
||||
MRAA_SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge,
|
||||
output data (change) on rising edge */
|
||||
MRAA_SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge,
|
||||
output data (change) on rising edge */
|
||||
MRAA_SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge
|
||||
output data (change) on falling edge */
|
||||
} mraa_spi_mode_t;
|
||||
|
||||
/**
|
||||
@@ -70,33 +74,54 @@ typedef struct _spi* mraa_spi_context;
|
||||
*/
|
||||
mraa_spi_context mraa_spi_init(int bus);
|
||||
|
||||
/**
|
||||
* Initialise SPI_context without any board configuration, selects a bus and a mux.
|
||||
*
|
||||
* @param bus Bus to use as listed by spidev
|
||||
* @param cs Chip select to use as listed in spidev
|
||||
* @return Spi context or NULL
|
||||
*/
|
||||
mraa_spi_context mraa_spi_init_raw(unsigned int bus, unsigned int cs);
|
||||
|
||||
/**
|
||||
* Set the SPI device mode. see spidev 0-3.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param mode The SPI mode, See Linux spidev
|
||||
* @return Spi context or NULL
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_mode(mraa_spi_context dev, mraa_spi_mode_t mode);
|
||||
|
||||
/** Set the SPI device operating clock frequency.
|
||||
/**
|
||||
* Set the SPI device operating clock frequency.
|
||||
*
|
||||
* @param dev the Spi context
|
||||
* @param hz the frequency in hz
|
||||
* @return mraa_spi_context The returned initialised SPI context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz);
|
||||
|
||||
/** Write Single Byte to the SPI device.
|
||||
/**
|
||||
* Write Single Byte to the SPI device.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data Data to send
|
||||
* @return Data received on the miso line or -1 in case of error
|
||||
*/
|
||||
int mraa_spi_write(mraa_spi_context dev, uint8_t data);
|
||||
|
||||
/**
|
||||
*Write Two Bytes to the SPI device.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data Data to send
|
||||
* @return Data received on the miso line
|
||||
*/
|
||||
uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data);
|
||||
uint16_t mraa_spi_write_word(mraa_spi_context dev, uint16_t data);
|
||||
|
||||
/** Write Buffer of bytes to the SPI device. The pointer return has to be
|
||||
* free'd by the caller.
|
||||
/**
|
||||
* Write Buffer of bytes to the SPI device. The pointer return has to be
|
||||
* free'd by the caller. It will return a NULL pointer in cases of error.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data to send
|
||||
@@ -105,6 +130,41 @@ uint8_t mraa_spi_write(mraa_spi_context dev, uint8_t data);
|
||||
*/
|
||||
uint8_t* mraa_spi_write_buf(mraa_spi_context dev, uint8_t* data, int length);
|
||||
|
||||
/**
|
||||
* Write Buffer of uint16 to the SPI device. The pointer return has to be
|
||||
* free'd by the caller. It will return a NULL pointer in cases of error.
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data to send
|
||||
* @param length elements (in bytes) within buffer, Max 4096
|
||||
* @return Data received on the miso line, same length as passed in
|
||||
*/
|
||||
uint16_t* mraa_spi_write_buf_word(mraa_spi_context dev, uint16_t* data, int length);
|
||||
|
||||
/**
|
||||
* Transfer Buffer of bytes to the SPI device. Both send and recv buffers
|
||||
* are passed in
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data to send
|
||||
* @param rxbuf buffer to recv data back, may be NULL
|
||||
* @param length elements within buffer, Max 4096
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_transfer_buf(mraa_spi_context dev, uint8_t* data, uint8_t* rxbuf, int length);
|
||||
|
||||
/**
|
||||
* Transfer Buffer of uint16 to the SPI device. Both send and recv buffers
|
||||
* are passed in
|
||||
*
|
||||
* @param dev The Spi context
|
||||
* @param data to send
|
||||
* @param rxbuf buffer to recv data back, may be NULL
|
||||
* @param length elements (in bytes) within buffer, Max 4096
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_spi_transfer_buf_word(mraa_spi_context dev, uint16_t* data, uint16_t* rxbuf, int length);
|
||||
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
*
|
||||
|
273
api/mraa/spi.hpp
273
api/mraa/spi.hpp
@@ -25,88 +25,205 @@
|
||||
#pragma once
|
||||
|
||||
#include "spi.h"
|
||||
#include "types.hpp"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to System Packet Interface
|
||||
*
|
||||
* This file defines the SPI interface for libmraa
|
||||
*
|
||||
* @snippet Spi-pot.cpp Interesting
|
||||
* MRAA SPI Modes
|
||||
*/
|
||||
class Spi {
|
||||
public:
|
||||
/**
|
||||
* Initialise SPI object using the board mapping to set muxes
|
||||
*
|
||||
* @param bus to use, as listed in the platform definition, normally 0
|
||||
*/
|
||||
Spi(int bus) {
|
||||
m_spi = mraa_spi_init(bus);
|
||||
typedef enum {
|
||||
SPI_MODE0 = 0, /**< CPOL = 0, CPHA = 0, Clock idle low, data is clocked in on rising edge,
|
||||
output data (change) on falling edge */
|
||||
SPI_MODE1 = 1, /**< CPOL = 0, CPHA = 1, Clock idle low, data is clocked in on falling edge,
|
||||
output data (change) on rising edge */
|
||||
SPI_MODE2 = 2, /**< CPOL = 1, CPHA = 0, Clock idle low, data is clocked in on falling edge,
|
||||
output data (change) on rising edge */
|
||||
SPI_MODE3 = 3, /**< CPOL = 1, CPHA = 1, Clock idle low, data is clocked in on rising, edge
|
||||
output data (change) on falling edge */
|
||||
} Spi_Mode;
|
||||
|
||||
|
||||
/**
|
||||
* @brief API to Serial Peripheral Interface
|
||||
*
|
||||
* This file defines the SPI interface for libmraa
|
||||
*
|
||||
* @snippet Spi-pot.cpp Interesting
|
||||
*/
|
||||
class Spi
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initialise SPI object using the board mapping to set muxes
|
||||
*
|
||||
* @param bus to use, as listed in the platform definition, normally 0
|
||||
*/
|
||||
Spi(int bus)
|
||||
{
|
||||
m_spi = mraa_spi_init(bus);
|
||||
|
||||
if (m_spi == NULL) {
|
||||
throw std::invalid_argument("Error initialising SPI bus");
|
||||
}
|
||||
/**
|
||||
* Closes spi bus
|
||||
*/
|
||||
~Spi() {
|
||||
mraa_spi_stop(m_spi);
|
||||
}
|
||||
|
||||
Spi(int bus, int cs)
|
||||
{
|
||||
m_spi = mraa_spi_init_raw(bus, cs);
|
||||
|
||||
if (m_spi == NULL) {
|
||||
throw std::invalid_argument("Error initialising SPI bus");
|
||||
}
|
||||
/**
|
||||
* Set the SPI device mode. see spidev0-3
|
||||
*
|
||||
* @param mode the mode. See Linux spidev doc
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mode(mraa_spi_mode_t mode) {
|
||||
return mraa_spi_mode(m_spi, mode);
|
||||
}
|
||||
/**
|
||||
* Set the SPI device operating clock frequency
|
||||
*
|
||||
* @param hz the frequency to set in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t frequency(int hz) {
|
||||
return mraa_spi_frequency(m_spi, hz);
|
||||
}
|
||||
/**
|
||||
* Write single byte to the SPI device
|
||||
*
|
||||
* @param data the byte to send
|
||||
* @return data received on the miso line
|
||||
*/
|
||||
char write(char data) {
|
||||
return (char) mraa_spi_write(m_spi, (uint8_t) data);
|
||||
}
|
||||
/**
|
||||
* Write buffer of bytes to SPI device
|
||||
*
|
||||
* @param data buffer to send
|
||||
* @param length size of buffer to send
|
||||
* @return char* data received on the miso line. Same length as passed in
|
||||
*/
|
||||
char* write(char* data, size_t length) {
|
||||
return (char*) mraa_spi_write_buf(m_spi, (uint8_t *) data, (int) length);
|
||||
}
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
*
|
||||
* @param lsb Use least significant bit transmission - 0 for msbi
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t lsbmode(bool lsb) {
|
||||
return mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
|
||||
}
|
||||
/**
|
||||
* Set bits per mode on transaction, default is 8
|
||||
*
|
||||
* @param bits bits per word
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t bitPerWord(unsigned int bits) {
|
||||
return mraa_spi_bit_per_word(m_spi, bits);
|
||||
}
|
||||
private:
|
||||
mraa_spi_context m_spi;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes spi bus
|
||||
*/
|
||||
~Spi()
|
||||
{
|
||||
mraa_spi_stop(m_spi);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SPI device mode. see spidev0-3
|
||||
*
|
||||
* @param mode the mode. See Linux spidev doc
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
mode(Spi_Mode mode)
|
||||
{
|
||||
return (Result) mraa_spi_mode(m_spi, (mraa_spi_mode_t) mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SPI device operating clock frequency
|
||||
*
|
||||
* @param hz the frequency to set in hz
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
frequency(int hz)
|
||||
{
|
||||
return (Result) mraa_spi_frequency(m_spi, hz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write single byte to the SPI device
|
||||
*
|
||||
* @param data the byte to send
|
||||
* @return data received on the miso line or -1 in case of error
|
||||
*/
|
||||
int
|
||||
writeByte(uint8_t data)
|
||||
{
|
||||
return mraa_spi_write(m_spi, (uint8_t) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write single byte to the SPI device
|
||||
*
|
||||
* @param data the byte to send
|
||||
* @return data received on the miso line
|
||||
*/
|
||||
uint16_t
|
||||
write_word(uint16_t data)
|
||||
{
|
||||
return mraa_spi_write_word(m_spi, (uint16_t) data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write buffer of bytes to SPI device The pointer return has to be
|
||||
* free'd by the caller. It will return a NULL pointer in cases of
|
||||
* error
|
||||
*
|
||||
* @param txBuf buffer to send
|
||||
* @param length size of buffer to send
|
||||
* @return uint8_t* data received on the miso line. Same length as passed in
|
||||
*/
|
||||
uint8_t*
|
||||
write(uint8_t* txBuf, int length)
|
||||
{
|
||||
return mraa_spi_write_buf(m_spi, txBuf, length);
|
||||
}
|
||||
|
||||
#ifndef SWIG
|
||||
/**
|
||||
* Write buffer of bytes to SPI device The pointer return has to be
|
||||
* free'd by the caller. It will return a NULL pointer in cases of
|
||||
* error
|
||||
*
|
||||
* @param txBuf buffer to send
|
||||
* @param length size of buffer (in bytes) to send
|
||||
* @return uint8_t* data received on the miso line. Same length as passed in
|
||||
*/
|
||||
uint16_t*
|
||||
write_word(uint16_t* txBuf, int length)
|
||||
{
|
||||
return mraa_spi_write_buf_word(m_spi, txBuf, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SWIG
|
||||
/**
|
||||
* Transfer data to and from SPI device Receive pointer may be null if
|
||||
* return data is not needed.
|
||||
*
|
||||
* @param txBuf buffer to send
|
||||
* @param rxBuf buffer to optionally receive data from spi device
|
||||
* @param length size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
transfer(uint8_t* txBuf, uint8_t* rxBuf, int length)
|
||||
{
|
||||
return (Result) mraa_spi_transfer_buf(m_spi, txBuf, rxBuf, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer data to and from SPI device Receive pointer may be null if
|
||||
* return data is not needed.
|
||||
*
|
||||
* @param txBuf buffer to send
|
||||
* @param rxBuf buffer to optionally receive data from spi device
|
||||
* @param length size of buffer to send
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
transfer_word(uint16_t* txBuf, uint16_t* rxBuf, int length)
|
||||
{
|
||||
return (Result) mraa_spi_transfer_buf_word(m_spi, txBuf, rxBuf, length);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Change the SPI lsb mode
|
||||
*
|
||||
* @param lsb Use least significant bit transmission - 0 for msbi
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
lsbmode(bool lsb)
|
||||
{
|
||||
return (Result) mraa_spi_lsbmode(m_spi, (mraa_boolean_t) lsb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bits per mode on transaction, default is 8
|
||||
*
|
||||
* @param bits bits per word
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
bitPerWord(unsigned int bits)
|
||||
{
|
||||
return (Result) mraa_spi_bit_per_word(m_spi, bits);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_spi_context m_spi;
|
||||
};
|
||||
}
|
||||
|
233
api/mraa/types.h
233
api/mraa/types.h
@@ -37,67 +37,210 @@ extern "C" {
|
||||
* MRAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
MRAA_INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
|
||||
MRAA_INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
MRAA_INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
MRAA_INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
|
||||
MRAA_INTEL_DE3815 = 3, /**< The Intel DE3815 Baytrail NUC */
|
||||
MRAA_INTEL_MINNOWBOARD_MAX = 4, /**< The Intel Minnow Board Max */
|
||||
MRAA_RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
|
||||
MRAA_BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
|
||||
MRAA_BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
|
||||
MRAA_INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
|
||||
MRAA_96BOARDS = 9, /**< Linaro 96boards */
|
||||
MRAA_INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
|
||||
MRAA_INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
|
||||
MRAA_UP = 12, /**< The UP Board */
|
||||
|
||||
MRAA_UNKNOWN_PLATFORM = 99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
// USB platform extenders start at 256
|
||||
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
|
||||
// contains bit 9 so is subplatform
|
||||
MRAA_GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
|
||||
|
||||
MRAA_NULL_PLATFORM = 98, /**< Platform with no capabilities that hosts a sub platform */
|
||||
MRAA_UNKNOWN_PLATFORM =
|
||||
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} mraa_platform_t;
|
||||
|
||||
/**
|
||||
* Intel edison miniboard numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_1 = 0,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_5 = 4,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_7 = 6,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_8 = 7,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_9 = 8,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_10 = 9,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_11 = 10,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_12 = 11,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J17_14 = 13,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_1 = 14,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_2 = 15,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_6 = 19,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_7 = 20,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_8 = 21,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_10 = 23,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_11 = 24,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_12 = 25,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J18_13 = 26,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_4 = 31,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_5 = 32,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_6 = 33,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_8 = 35,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_9 = 36,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_10 = 37,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_11 = 38,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_12 = 39,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_13 = 40,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J19_14 = 41,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_3 = 44,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_4 = 45,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_5 = 46,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_6 = 47,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_7 = 48,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_8 = 49,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_9 = 50,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_10 = 51,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_11 = 52,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_12 = 53,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_13 = 54,
|
||||
MRAA_INTEL_EDISON_MINIBOARD_J20_14 = 55
|
||||
} mraa_intel_edison_miniboard_t;
|
||||
|
||||
/**
|
||||
* Intel Edison raw GPIO numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_INTEL_EDISON_GP182 = 0,
|
||||
MRAA_INTEL_EDISON_GP135 = 4,
|
||||
MRAA_INTEL_EDISON_GP27 = 6,
|
||||
MRAA_INTEL_EDISON_GP20 = 7,
|
||||
MRAA_INTEL_EDISON_GP28 = 8,
|
||||
MRAA_INTEL_EDISON_GP111 = 0,
|
||||
MRAA_INTEL_EDISON_GP109 = 10,
|
||||
MRAA_INTEL_EDISON_GP115 = 11,
|
||||
MRAA_INTEL_EDISON_GP128 = 13,
|
||||
MRAA_INTEL_EDISON_GP13 = 14,
|
||||
MRAA_INTEL_EDISON_GP165 = 15,
|
||||
MRAA_INTEL_EDISON_GP19 = 19,
|
||||
MRAA_INTEL_EDISON_GP12 = 20,
|
||||
MRAA_INTEL_EDISON_GP183 = 21,
|
||||
MRAA_INTEL_EDISON_GP110 = 23,
|
||||
MRAA_INTEL_EDISON_GP114 = 24,
|
||||
MRAA_INTEL_EDISON_GP129 = 25,
|
||||
MRAA_INTEL_EDISON_GP130 = 26,
|
||||
MRAA_INTEL_EDISON_GP44 = 31,
|
||||
MRAA_INTEL_EDISON_GP46 = 32,
|
||||
MRAA_INTEL_EDISON_GP48 = 33,
|
||||
MRAA_INTEL_EDISON_GP131 = 35,
|
||||
MRAA_INTEL_EDISON_GP14 = 36,
|
||||
MRAA_INTEL_EDISON_GP40 = 37,
|
||||
MRAA_INTEL_EDISON_GP43 = 38,
|
||||
MRAA_INTEL_EDISON_GP77 = 39,
|
||||
MRAA_INTEL_EDISON_GP82 = 40,
|
||||
MRAA_INTEL_EDISON_GP83 = 41,
|
||||
MRAA_INTEL_EDISON_GP134 = 44,
|
||||
MRAA_INTEL_EDISON_GP45 = 45,
|
||||
MRAA_INTEL_EDISON_GP47 = 46,
|
||||
MRAA_INTEL_EDISON_GP49 = 47,
|
||||
MRAA_INTEL_EDISON_GP15 = 48,
|
||||
MRAA_INTEL_EDISON_GP84 = 49,
|
||||
MRAA_INTEL_EDISON_GP42 = 50,
|
||||
MRAA_INTEL_EDISON_GP41 = 51,
|
||||
MRAA_INTEL_EDISON_GP78 = 52,
|
||||
MRAA_INTEL_EDISON_GP79 = 53,
|
||||
MRAA_INTEL_EDISON_GP80 = 54,
|
||||
MRAA_INTEL_EDISON_GP81 = 55
|
||||
} mraa_intel_edison_t;
|
||||
|
||||
/**
|
||||
* Raspberry PI Wiring compatible numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_RASPBERRY_WIRING_PIN8 = 3,
|
||||
MRAA_RASPBERRY_WIRING_PIN9 = 5,
|
||||
MRAA_RASPBERRY_WIRING_PIN7 = 7,
|
||||
MRAA_RASPBERRY_WIRING_PIN15 = 8,
|
||||
MRAA_RASPBERRY_WIRING_PIN16 = 10,
|
||||
MRAA_RASPBERRY_WIRING_PIN0 = 11,
|
||||
MRAA_RASPBERRY_WIRING_PIN1 = 12,
|
||||
MRAA_RASPBERRY_WIRING_PIN2 = 13,
|
||||
MRAA_RASPBERRY_WIRING_PIN3 = 15,
|
||||
MRAA_RASPBERRY_WIRING_PIN4 = 16,
|
||||
MRAA_RASPBERRY_WIRING_PIN5 = 18,
|
||||
MRAA_RASPBERRY_WIRING_PIN12 = 19,
|
||||
MRAA_RASPBERRY_WIRING_PIN13 = 21,
|
||||
MRAA_RASPBERRY_WIRING_PIN6 = 22,
|
||||
MRAA_RASPBERRY_WIRING_PIN14 = 23,
|
||||
MRAA_RASPBERRY_WIRING_PIN10 = 24,
|
||||
MRAA_RASPBERRY_WIRING_PIN11 = 26,
|
||||
MRAA_RASPBERRY_WIRING_PIN17 = 29, // RPi B V2
|
||||
MRAA_RASPBERRY_WIRING_PIN21 = 29,
|
||||
MRAA_RASPBERRY_WIRING_PIN18 = 30, // RPi B V2
|
||||
MRAA_RASPBERRY_WIRING_PIN19 = 31, // RPI B V2
|
||||
MRAA_RASPBERRY_WIRING_PIN22 = 31,
|
||||
MRAA_RASPBERRY_WIRING_PIN20 = 32, // RPi B V2
|
||||
MRAA_RASPBERRY_WIRING_PIN26 = 32,
|
||||
MRAA_RASPBERRY_WIRING_PIN23 = 33,
|
||||
MRAA_RASPBERRY_WIRING_PIN24 = 35,
|
||||
MRAA_RASPBERRY_WIRING_PIN27 = 36,
|
||||
MRAA_RASPBERRY_WIRING_PIN25 = 37,
|
||||
MRAA_RASPBERRY_WIRING_PIN28 = 38,
|
||||
MRAA_RASPBERRY_WIRING_PIN29 = 40
|
||||
} mraa_raspberry_wiring_t;
|
||||
|
||||
/**
|
||||
* MRAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
MRAA_SUCCESS = 0, /**< Expected response */
|
||||
MRAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MRAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MRAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MRAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MRAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MRAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MRAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MRAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 12, /**< Board is already initialised */
|
||||
MRAA_SUCCESS = 0, /**< Expected response */
|
||||
MRAA_ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
MRAA_ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
MRAA_ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
MRAA_ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
MRAA_ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
MRAA_ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
MRAA_ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
MRAA_ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
MRAA_ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
MRAA_ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
MRAA_ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
MRAA_ERROR_PLATFORM_ALREADY_INITIALISED = 0, /**< Board is already initialised, same as MRAA_SUCESS */
|
||||
|
||||
MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
MRAA_ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} mraa_result_t;
|
||||
|
||||
/**
|
||||
* This function attempts to set the mraa process to a given priority and the
|
||||
* scheduler to SCHED_RR. Highest * priority is typically 99 and minimum is 0.
|
||||
* This function * will set to MAX if * priority is > MAX. Function will return
|
||||
* -1 on failure.
|
||||
*
|
||||
* @param priority Value from typically 0 to 99
|
||||
* @return The priority value set
|
||||
* Enum representing different possible modes for a pin.
|
||||
*/
|
||||
int mraa_set_priority(const unsigned int priority);
|
||||
|
||||
/** Get the version string of mraa autogenerated from git tag
|
||||
*
|
||||
* The version returned may not be what is expected however it is a reliable
|
||||
* number associated with the git tag closest to that version at build time
|
||||
*
|
||||
* @return version string from version.h
|
||||
*/
|
||||
const char* mraa_get_version();
|
||||
typedef enum {
|
||||
MRAA_PIN_VALID = 0, /**< Pin Valid */
|
||||
MRAA_PIN_GPIO = 1, /**< General Purpose IO */
|
||||
MRAA_PIN_PWM = 2, /**< Pulse Width Modulation */
|
||||
MRAA_PIN_FAST_GPIO = 3, /**< Faster GPIO */
|
||||
MRAA_PIN_SPI = 4, /**< SPI */
|
||||
MRAA_PIN_I2C = 5, /**< I2C */
|
||||
MRAA_PIN_AIO = 6, /**< Analog in */
|
||||
MRAA_PIN_UART = 7 /**< UART */
|
||||
} mraa_pinmodes_t;
|
||||
|
||||
/**
|
||||
* Print a textual representation of the mraa_result_t
|
||||
*
|
||||
* @param result the result to print
|
||||
* Enum reprensenting different i2c speeds/modes
|
||||
*/
|
||||
void mraa_result_print(mraa_result_t result);
|
||||
typedef enum {
|
||||
MRAA_I2C_STD = 0, /**< up to 100Khz */
|
||||
MRAA_I2C_FAST = 1, /**< up to 400Khz */
|
||||
MRAA_I2C_HIGH = 2 /**< up to 3.4Mhz */
|
||||
} mraa_i2c_mode_t;
|
||||
|
||||
/**
|
||||
* Get platform type, board must be initialised.
|
||||
*
|
||||
* @return mraa_platform_t Platform type enum
|
||||
*/
|
||||
mraa_platform_t mraa_get_platform_type();
|
||||
typedef enum {
|
||||
MRAA_UART_PARITY_NONE = 0,
|
||||
MRAA_UART_PARITY_EVEN = 1,
|
||||
MRAA_UART_PARITY_ODD = 2,
|
||||
MRAA_UART_PARITY_MARK = 3,
|
||||
MRAA_UART_PARITY_SPACE = 4
|
||||
} mraa_uart_parity_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
243
api/mraa/types.hpp
Normal file
243
api/mraa/types.hpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright © 2014 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
*
|
||||
* This file defines the basic shared types for libmraa
|
||||
* this file is different to common.h in that swig takes this as an input
|
||||
*/
|
||||
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
//These enums must match the enums in types.h
|
||||
|
||||
/**
|
||||
* MRAA supported platform types
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_GALILEO_GEN1 = 0, /**< The Generation 1 Galileo platform (RevD) */
|
||||
INTEL_GALILEO_GEN2 = 1, /**< The Generation 2 Galileo platform (RevG/H) */
|
||||
INTEL_EDISON_FAB_C = 2, /**< The Intel Edison (FAB C) */
|
||||
INTEL_DE3815 = 3, /**< The Intel DE3815 Baytrail NUC */
|
||||
INTEL_MINNOWBOARD_MAX = 4, /**< The Intel Minnow Board Max */
|
||||
RASPBERRY_PI = 5, /**< The different Raspberry PI Models -like A,B,A+,B+ */
|
||||
BEAGLEBONE = 6, /**< The different BeagleBone Black Modes B/C */
|
||||
BANANA = 7, /**< Allwinner A20 based Banana Pi and Banana Pro */
|
||||
INTEL_NUC5 = 8, /**< The Intel 5th generations Broadwell NUCs */
|
||||
A96BOARDS = 9, /**< Linaro 96boards, A prefix for 'ARM' since not allowed numerical */
|
||||
INTEL_SOFIA_3GR = 10, /**< The Intel SoFIA 3GR */
|
||||
INTEL_CHERRYHILLS = 11, /**< The Intel Braswell Cherryhills */
|
||||
|
||||
FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */
|
||||
|
||||
GENERIC_FIRMATA = 1280, /**< Firmata uart platform/bridge */
|
||||
|
||||
NULL_PLATFORM = 98,
|
||||
UNKNOWN_PLATFORM =
|
||||
99 /**< An unknown platform type, typically will load INTEL_GALILEO_GEN1 */
|
||||
} Platform;
|
||||
|
||||
/**
|
||||
* Intel edison miniboard numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_EDISON_MINIBOARD_J17_1 = 0,
|
||||
INTEL_EDISON_MINIBOARD_J17_5 = 4,
|
||||
INTEL_EDISON_MINIBOARD_J17_7 = 6,
|
||||
INTEL_EDISON_MINIBOARD_J17_8 = 7,
|
||||
INTEL_EDISON_MINIBOARD_J17_9 = 8,
|
||||
INTEL_EDISON_MINIBOARD_J17_10 = 9,
|
||||
INTEL_EDISON_MINIBOARD_J17_11 = 10,
|
||||
INTEL_EDISON_MINIBOARD_J17_12 = 11,
|
||||
INTEL_EDISON_MINIBOARD_J17_14 = 13,
|
||||
INTEL_EDISON_MINIBOARD_J18_1 = 14,
|
||||
INTEL_EDISON_MINIBOARD_J18_2 = 15,
|
||||
INTEL_EDISON_MINIBOARD_J18_6 = 19,
|
||||
INTEL_EDISON_MINIBOARD_J18_7 = 20,
|
||||
INTEL_EDISON_MINIBOARD_J18_8 = 21,
|
||||
INTEL_EDISON_MINIBOARD_J18_10 = 23,
|
||||
INTEL_EDISON_MINIBOARD_J18_11 = 24,
|
||||
INTEL_EDISON_MINIBOARD_J18_12 = 25,
|
||||
INTEL_EDISON_MINIBOARD_J18_13 = 26,
|
||||
INTEL_EDISON_MINIBOARD_J19_4 = 31,
|
||||
INTEL_EDISON_MINIBOARD_J19_5 = 32,
|
||||
INTEL_EDISON_MINIBOARD_J19_6 = 33,
|
||||
INTEL_EDISON_MINIBOARD_J19_8 = 35,
|
||||
INTEL_EDISON_MINIBOARD_J19_9 = 36,
|
||||
INTEL_EDISON_MINIBOARD_J19_10 = 37,
|
||||
INTEL_EDISON_MINIBOARD_J19_11 = 38,
|
||||
INTEL_EDISON_MINIBOARD_J19_12 = 39,
|
||||
INTEL_EDISON_MINIBOARD_J19_13 = 40,
|
||||
INTEL_EDISON_MINIBOARD_J19_14 = 41,
|
||||
INTEL_EDISON_MINIBOARD_J20_3 = 44,
|
||||
INTEL_EDISON_MINIBOARD_J20_4 = 45,
|
||||
INTEL_EDISON_MINIBOARD_J20_5 = 46,
|
||||
INTEL_EDISON_MINIBOARD_J20_6 = 47,
|
||||
INTEL_EDISON_MINIBOARD_J20_7 = 48,
|
||||
INTEL_EDISON_MINIBOARD_J20_8 = 49,
|
||||
INTEL_EDISON_MINIBOARD_J20_9 = 50,
|
||||
INTEL_EDISON_MINIBOARD_J20_10 = 51,
|
||||
INTEL_EDISON_MINIBOARD_J20_11 = 52,
|
||||
INTEL_EDISON_MINIBOARD_J20_12 = 53,
|
||||
INTEL_EDISON_MINIBOARD_J20_13 = 54,
|
||||
INTEL_EDISON_MINIBOARD_J20_14 = 55
|
||||
} IntelEdisonMiniboard;
|
||||
|
||||
/**
|
||||
* Intel Edison raw GPIO numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
INTEL_EDISON_GP182 = 0,
|
||||
INTEL_EDISON_GP135 = 4,
|
||||
INTEL_EDISON_GP27 = 6,
|
||||
INTEL_EDISON_GP20 = 7,
|
||||
INTEL_EDISON_GP28 = 8,
|
||||
INTEL_EDISON_GP111 = 0,
|
||||
INTEL_EDISON_GP109 = 10,
|
||||
INTEL_EDISON_GP115 = 11,
|
||||
INTEL_EDISON_GP128 = 13,
|
||||
INTEL_EDISON_GP13 = 14,
|
||||
INTEL_EDISON_GP165 = 15,
|
||||
INTEL_EDISON_GP19 = 19,
|
||||
INTEL_EDISON_GP12 = 20,
|
||||
INTEL_EDISON_GP183 = 21,
|
||||
INTEL_EDISON_GP110 = 23,
|
||||
INTEL_EDISON_GP114 = 24,
|
||||
INTEL_EDISON_GP129 = 25,
|
||||
INTEL_EDISON_GP130 = 26,
|
||||
INTEL_EDISON_GP44 = 31,
|
||||
INTEL_EDISON_GP46 = 32,
|
||||
INTEL_EDISON_GP48 = 33,
|
||||
INTEL_EDISON_GP131 = 35,
|
||||
INTEL_EDISON_GP14 = 36,
|
||||
INTEL_EDISON_GP40 = 37,
|
||||
INTEL_EDISON_GP43 = 38,
|
||||
INTEL_EDISON_GP77 = 39,
|
||||
INTEL_EDISON_GP82 = 40,
|
||||
INTEL_EDISON_GP83 = 41,
|
||||
INTEL_EDISON_GP134 = 44,
|
||||
INTEL_EDISON_GP45 = 45,
|
||||
INTEL_EDISON_GP47 = 46,
|
||||
INTEL_EDISON_GP49 = 47,
|
||||
INTEL_EDISON_GP15 = 48,
|
||||
INTEL_EDISON_GP84 = 49,
|
||||
INTEL_EDISON_GP42 = 50,
|
||||
INTEL_EDISON_GP41 = 51,
|
||||
INTEL_EDISON_GP78 = 52,
|
||||
INTEL_EDISON_GP79 = 53,
|
||||
INTEL_EDISON_GP80 = 54,
|
||||
INTEL_EDISON_GP81 = 55
|
||||
} IntelEdison;
|
||||
|
||||
/**
|
||||
* Raspberry PI Wiring compatible numbering enum
|
||||
*/
|
||||
typedef enum {
|
||||
RASPBERRY_WIRING_PIN8 = 3,
|
||||
RASPBERRY_WIRING_PIN9 = 5,
|
||||
RASPBERRY_WIRING_PIN7 = 7,
|
||||
RASPBERRY_WIRING_PIN15 = 8,
|
||||
RASPBERRY_WIRING_PIN16 = 10,
|
||||
RASPBERRY_WIRING_PIN0 = 11,
|
||||
RASPBERRY_WIRING_PIN1 = 12,
|
||||
RASPBERRY_WIRING_PIN2 = 13,
|
||||
RASPBERRY_WIRING_PIN3 = 15,
|
||||
RASPBERRY_WIRING_PIN4 = 16,
|
||||
RASPBERRY_WIRING_PIN5 = 18,
|
||||
RASPBERRY_WIRING_PIN12 = 19,
|
||||
RASPBERRY_WIRING_PIN13 = 21,
|
||||
RASPBERRY_WIRING_PIN6 = 22,
|
||||
RASPBERRY_WIRING_PIN14 = 23,
|
||||
RASPBERRY_WIRING_PIN10 = 24,
|
||||
RASPBERRY_WIRING_PIN11 = 26,
|
||||
RASPBERRY_WIRING_PIN17 = 29, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN21 = 29,
|
||||
RASPBERRY_WIRING_PIN18 = 30, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN19 = 31, // RPI B V2
|
||||
RASPBERRY_WIRING_PIN22 = 31,
|
||||
RASPBERRY_WIRING_PIN20 = 32, // RPi B V2
|
||||
RASPBERRY_WIRING_PIN26 = 32,
|
||||
RASPBERRY_WIRING_PIN23 = 33,
|
||||
RASPBERRY_WIRING_PIN24 = 35,
|
||||
RASPBERRY_WIRING_PIN27 = 36,
|
||||
RASPBERRY_WIRING_PIN25 = 37,
|
||||
RASPBERRY_WIRING_PIN28 = 38,
|
||||
RASPBERRY_WIRING_PIN29 = 40
|
||||
} RaspberryWiring;
|
||||
|
||||
/**
|
||||
* MRAA return codes
|
||||
*/
|
||||
typedef enum {
|
||||
SUCCESS = 0, /**< Expected response */
|
||||
ERROR_FEATURE_NOT_IMPLEMENTED = 1, /**< Feature TODO */
|
||||
ERROR_FEATURE_NOT_SUPPORTED = 2, /**< Feature not supported by HW */
|
||||
ERROR_INVALID_VERBOSITY_LEVEL = 3, /**< Verbosity level wrong */
|
||||
ERROR_INVALID_PARAMETER = 4, /**< Parameter invalid */
|
||||
ERROR_INVALID_HANDLE = 5, /**< Handle invalid */
|
||||
ERROR_NO_RESOURCES = 6, /**< No resource of that type avail */
|
||||
ERROR_INVALID_RESOURCE = 7, /**< Resource invalid */
|
||||
ERROR_INVALID_QUEUE_TYPE = 8, /**< Queue type incorrect */
|
||||
ERROR_NO_DATA_AVAILABLE = 9, /**< No data available */
|
||||
ERROR_INVALID_PLATFORM = 10, /**< Platform not recognised */
|
||||
ERROR_PLATFORM_NOT_INITIALISED = 11, /**< Board information not initialised */
|
||||
ERROR_PLATFORM_ALREADY_INITIALISED = 0, /**< Board is already initialised, same as SUCCESS */
|
||||
|
||||
ERROR_UNSPECIFIED = 99 /**< Unknown Error */
|
||||
} Result;
|
||||
|
||||
/**
|
||||
* Enum representing different possible modes for a pin.
|
||||
*/
|
||||
typedef enum {
|
||||
PIN_VALID = 0, /**< Pin Valid */
|
||||
PIN_GPIO = 1, /**< General Purpose IO */
|
||||
PIN_PWM = 2, /**< Pulse Width Modulation */
|
||||
PIN_FAST_GPIO = 3, /**< Faster GPIO */
|
||||
PIN_SPI = 4, /**< SPI */
|
||||
PIN_I2C = 5, /**< I2C */
|
||||
PIN_AIO = 6, /**< Analog in */
|
||||
PIN_UART = 7 /**< UART */
|
||||
} Pinmodes;
|
||||
|
||||
/**
|
||||
* Enum reprensenting different i2c speeds/modes
|
||||
*/
|
||||
typedef enum {
|
||||
I2C_STD = 0, /**< up to 100Khz */
|
||||
I2C_FAST = 1, /**< up to 400Khz */
|
||||
I2C_HIGH = 2 /**< up to 3.4Mhz */
|
||||
} I2cMode;
|
||||
|
||||
typedef enum {
|
||||
UART_PARITY_NONE = 0,
|
||||
UART_PARITY_EVEN = 1,
|
||||
UART_PARITY_ODD = 2,
|
||||
UART_PARITY_MARK = 3,
|
||||
UART_PARITY_SPACE = 4
|
||||
} UartParity;
|
||||
|
||||
}
|
125
api/mraa/uart.h
125
api/mraa/uart.h
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Contributions: Jon Trulson <jtrulson@ics.com>
|
||||
* Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 - 2015 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -32,7 +34,7 @@
|
||||
* libmraa. It allows the exposure of UART pins on supported boards.
|
||||
* With functionality to expand at a later date.
|
||||
*
|
||||
* @snippet uart_setup.c Interesting
|
||||
* @snippet uart.c Interesting
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -40,7 +42,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -54,6 +55,124 @@ typedef struct _uart* mraa_uart_context;
|
||||
*/
|
||||
mraa_uart_context mraa_uart_init(int uart);
|
||||
|
||||
/**
|
||||
* Initialise a raw uart_context. No board setup.
|
||||
*
|
||||
* @param path for example "/dev/ttyS0"
|
||||
* @return uart context or NULL
|
||||
*/
|
||||
mraa_uart_context mraa_uart_init_raw(const char* path);
|
||||
|
||||
/**
|
||||
* Flush the outbound data.
|
||||
* Blocks until complete.
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_flush(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Set the baudrate.
|
||||
* Takes an int and will attempt to decide what baudrate is
|
||||
* to be used on the UART hardware.
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param baud unsigned int of baudrate i.e. 9600
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_set_baudrate(mraa_uart_context dev, unsigned int baud);
|
||||
|
||||
/**
|
||||
* Set the transfer mode
|
||||
* For example setting the mode to 8N1 would be
|
||||
* "mraa_uart_set_mode(dev, 8,MRAA_UART_PARITY_NONE , 1)"
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param bytesize data bits
|
||||
* @param parity Parity bit setting
|
||||
* @param stopbits stop bits
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_set_mode(mraa_uart_context dev, int bytesize, mraa_uart_parity_t parity, int stopbits);
|
||||
|
||||
/**
|
||||
* Set the flowcontrol
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param xonxoff XON/XOFF Software flow control.
|
||||
* @param rtscts RTS/CTS out of band hardware flow control
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_set_flowcontrol(mraa_uart_context dev, mraa_boolean_t xonxoff, mraa_boolean_t rtscts);
|
||||
|
||||
/**
|
||||
* Set the timeout for read and write operations
|
||||
* <= 0 will disable that timeout
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param read read timeout
|
||||
* @param write write timeout
|
||||
* @param interchar inbetween char timeout
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar);
|
||||
|
||||
/**
|
||||
* Set the blocking state for write operations
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param nonblock new nonblocking state
|
||||
* @return Result of operation
|
||||
*/
|
||||
mraa_result_t mraa_uart_set_non_blocking(mraa_uart_context dev, mraa_boolean_t nonblock);
|
||||
|
||||
/**
|
||||
* Get Char pointer with tty device path within Linux
|
||||
* For example. Could point to "/dev/ttyS0"
|
||||
*
|
||||
* @param dev uart context
|
||||
* @return char pointer of device path
|
||||
*/
|
||||
const char* mraa_uart_get_dev_path(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Destroy a mraa_uart_context
|
||||
*
|
||||
* @param dev uart context
|
||||
* @return mraa_result_t
|
||||
*/
|
||||
mraa_result_t mraa_uart_stop(mraa_uart_context dev);
|
||||
|
||||
/**
|
||||
* Read bytes from the device into a buffer
|
||||
*
|
||||
* @param dev uart context
|
||||
* @param buf buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
* @return the number of bytes read, or -1 if an error occurred
|
||||
*/
|
||||
int mraa_uart_read(mraa_uart_context dev, char* buf, size_t length);
|
||||
|
||||
/**
|
||||
* Write bytes in buffer to a device
|
||||
*
|
||||
* @param dev uart context
|
||||
* @param buf buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
* @return the number of bytes written, or -1 if an error occurred
|
||||
*/
|
||||
int mraa_uart_write(mraa_uart_context dev, const char* buf, size_t length);
|
||||
|
||||
/**
|
||||
* Check to see if data is available on the device for reading
|
||||
*
|
||||
* @param dev uart context
|
||||
* @param millis number of milliseconds to wait, or 0 to return immediately
|
||||
* @return 1 if there is data available to read, 0 otherwise
|
||||
*/
|
||||
mraa_boolean_t mraa_uart_data_available(mraa_uart_context dev, unsigned int millis);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Contributions: Jon Trulson <jtrulson@ics.com>
|
||||
* Contributions: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 - 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -25,33 +27,234 @@
|
||||
#pragma once
|
||||
|
||||
#include "uart.h"
|
||||
#include "types.hpp"
|
||||
#include <stdlib.h>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
|
||||
namespace mraa {
|
||||
namespace mraa
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief API to UART (enabling only)
|
||||
*
|
||||
* This file defines the UART interface for libmraa
|
||||
*
|
||||
* @snippet Uart-example.cpp Interesting
|
||||
*/
|
||||
class Uart {
|
||||
public:
|
||||
/**
|
||||
* Uart Constructor, takes a pin number which will map directly to the
|
||||
* linux uart number, this 'enables' the uart, nothing more
|
||||
*
|
||||
* @param uart the index of the uart set to use
|
||||
*/
|
||||
Uart(int uart) {
|
||||
m_uart = mraa_uart_init(uart);
|
||||
}
|
||||
/**
|
||||
* Uart destructor
|
||||
*/
|
||||
~Uart() {
|
||||
return;
|
||||
}
|
||||
private:
|
||||
mraa_uart_context m_uart;
|
||||
};
|
||||
class Uart
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Uart Constructor, takes a pin number which will map directly to the
|
||||
* linux uart number, this 'enables' the uart, nothing more
|
||||
*
|
||||
* @param uart the index of the uart set to use
|
||||
*/
|
||||
Uart(int uart)
|
||||
{
|
||||
m_uart = mraa_uart_init(uart);
|
||||
|
||||
if (m_uart == NULL) {
|
||||
throw std::invalid_argument("Error initialising UART");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uart Constructor, takes a string to the path of the serial
|
||||
* interface that is needed.
|
||||
*
|
||||
* @param uart the index of the uart set to use
|
||||
*/
|
||||
Uart(std::string path)
|
||||
{
|
||||
m_uart = mraa_uart_init_raw(path.c_str());
|
||||
|
||||
if (m_uart == NULL) {
|
||||
throw std::invalid_argument("Error initialising UART");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uart destructor
|
||||
*/
|
||||
~Uart()
|
||||
{
|
||||
mraa_uart_stop(m_uart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get string with tty device path within Linux
|
||||
* For example. Could point to "/dev/ttyS0"
|
||||
*
|
||||
* @return char pointer of device path
|
||||
*/
|
||||
std::string
|
||||
getDevicePath()
|
||||
{
|
||||
std::string ret_val(mraa_uart_get_dev_path(m_uart));
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read bytes from the device into char* buffer
|
||||
*
|
||||
* @param data buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
* @return numbers of bytes read
|
||||
*/
|
||||
int
|
||||
read(char* data, int length)
|
||||
{
|
||||
return mraa_uart_read(m_uart, data, (size_t) length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bytes in String object to a device
|
||||
*
|
||||
* @param data buffer pointer
|
||||
* @param length maximum size of buffer
|
||||
* @return the number of bytes written, or -1 if an error occurred
|
||||
*/
|
||||
int
|
||||
write(const char* data, int length)
|
||||
{
|
||||
return mraa_uart_write(m_uart, data, (size_t) length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read bytes from the device into a String object
|
||||
*
|
||||
* @param length to read
|
||||
* @throws std::bad_alloc If there is no space left for read.
|
||||
* @return string of data
|
||||
*/
|
||||
std::string
|
||||
readStr(int length)
|
||||
{
|
||||
char* data = (char*) malloc(sizeof(char) * length);
|
||||
if (data == NULL) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
int v = mraa_uart_read(m_uart, data, (size_t) length);
|
||||
std::string ret(data, v);
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write bytes in String object to a device
|
||||
*
|
||||
* @param string to write
|
||||
* @return the number of bytes written, or -1 if an error occurred
|
||||
*/
|
||||
int
|
||||
writeStr(std::string data)
|
||||
{
|
||||
// this is data.length() not +1 because we want to avoid the '\0' char
|
||||
return mraa_uart_write(m_uart, data.c_str(), (data.length()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if data is available on the device for reading
|
||||
*
|
||||
* @param millis number of milliseconds to wait, or 0 to return immediately
|
||||
* @return true if there is data available to read, false otherwise
|
||||
*/
|
||||
bool
|
||||
dataAvailable(unsigned int millis = 0)
|
||||
{
|
||||
if (mraa_uart_data_available(m_uart, millis))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the outbound data.
|
||||
* Blocks until complete.
|
||||
*
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
flush()
|
||||
{
|
||||
return (Result) mraa_uart_flush(m_uart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the baudrate.
|
||||
* Takes an int and will attempt to decide what baudrate is
|
||||
* to be used on the UART hardware.
|
||||
*
|
||||
* @param baud unsigned int of baudrate i.e. 9600
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
setBaudRate(unsigned int baud)
|
||||
{
|
||||
return (Result) mraa_uart_set_baudrate(m_uart, baud);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transfer mode
|
||||
* For example setting the mode to 8N1 would be
|
||||
* "dev.setMode(8,UART_PARITY_NONE , 1)"
|
||||
*
|
||||
* @param bytesize data bits
|
||||
* @param parity Parity bit setting
|
||||
* @param stopbits stop bits
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
setMode(int bytesize, UartParity parity, int stopbits)
|
||||
{
|
||||
return (Result) mraa_uart_set_mode(m_uart, bytesize, (mraa_uart_parity_t) parity, stopbits);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the flowcontrol
|
||||
*
|
||||
* @param xonxoff XON/XOFF Software flow control.
|
||||
* @param rtscts RTS/CTS out of band hardware flow control
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
setFlowcontrol(bool xonxoff, bool rtscts)
|
||||
{
|
||||
return (Result) mraa_uart_set_flowcontrol(m_uart, xonxoff, rtscts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the timeout for read and write operations
|
||||
* <= 0 will disable that timeout
|
||||
*
|
||||
* @param read read timeout
|
||||
* @param write write timeout
|
||||
* @param interchar inbetween char timeout
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
setTimeout(int read, int write, int interchar)
|
||||
{
|
||||
return (Result) mraa_uart_set_timeout(m_uart, read, write, interchar);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the blocking state for write operations
|
||||
*
|
||||
* @param dev The UART context
|
||||
* @param nonblock new nonblocking state
|
||||
* @return Result of operation
|
||||
*/
|
||||
Result
|
||||
SetNonBlocking(bool nonblock)
|
||||
{
|
||||
return (Result) mraa_uart_set_non_blocking(m_uart, nonblock);
|
||||
}
|
||||
|
||||
private:
|
||||
mraa_uart_context m_uart;
|
||||
};
|
||||
}
|
||||
|
25
cmake/Toolchains/oe-sdk_cross.cmake
Normal file
25
cmake/Toolchains/oe-sdk_cross.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
# this toolchain file comes from gnuradio project
|
||||
|
||||
set( CMAKE_SYSTEM_NAME Linux )
|
||||
#set( CMAKE_C_COMPILER $ENV{CC} )
|
||||
#set( CMAKE_CXX_COMPILER $ENV{CXX} )
|
||||
string(REGEX MATCH "sysroots/([a-zA-Z0-9]+)" CMAKE_SYSTEM_PROCESSOR $ENV{SDKTARGETSYSROOT})
|
||||
string(REGEX REPLACE "sysroots/" "" CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set( CMAKE_CXX_FLAGS $ENV{CXXFLAGS} CACHE STRING "" FORCE )
|
||||
set( CMAKE_C_FLAGS $ENV{CFLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||
set( CMAKE_LDFLAGS_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE ) #same flags for C sources
|
||||
set( CMAKE_LIBRARY_PATH ${OECORE_TARGET_SYSROOT}/usr/lib )
|
||||
set( CMAKE_FIND_ROOT_PATH $ENV{OECORE_TARGET_SYSROOT} $ENV{OECORE_NATIVE_SYSROOT} )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
|
||||
set( CMAKE_INSTALL_PREFIX $ENV{OECORE_TARGET_SYSROOT}/usr CACHE STRING "" FORCE)
|
||||
set( ORC_INCLUDE_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/include/orc-0.4 )
|
||||
set( ORC_LIBRARY_DIRS $ENV{OECORE_TARGET_SYSROOT}/usr/lib )
|
||||
|
||||
# for java
|
||||
set( JAVA_AWT_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||
set( JAVA_AWT_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjawt.so CACHE FILEPATH "" FORCE)
|
||||
set( JAVA_INCLUDE_PATH $ENV{JAVA_HOME}/include CACHE PATH "" FORCE)
|
||||
set( JAVA_INCLUDE_PATH2 $ENV{JAVA_HOME}/include/linux CACHE PATH "" FORCE)
|
||||
set( JAVA_JVM_LIBRARY $ENV{JAVA_HOME}/jre/lib/amd64/libjvm.so CACHE FILEPATH "" FORCE)
|
22
cmake/modules/COPYING-CMAKE-SCRIPTS
Normal file
22
cmake/modules/COPYING-CMAKE-SCRIPTS
Normal file
@@ -0,0 +1,22 @@
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
57
cmake/modules/Copyright.txt
Normal file
57
cmake/modules/Copyright.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
CMake - Cross Platform Makefile Generator
|
||||
Copyright 2000-2015 Kitware, Inc.
|
||||
Copyright 2000-2011 Insight Software Consortium
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||
nor the names of their contributors may be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
The above copyright and license notice applies to distributions of
|
||||
CMake in source and binary form. Some source files contain additional
|
||||
notices of original copyright by their contributors; see each source
|
||||
for details. Third-party software packages supplied with CMake under
|
||||
compatible licenses provide their own copyright notices documented in
|
||||
corresponding subdirectories.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
CMake was initially developed by Kitware with the following sponsorship:
|
||||
|
||||
* National Library of Medicine at the National Institutes of Health
|
||||
as part of the Insight Segmentation and Registration Toolkit (ITK).
|
||||
|
||||
* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
|
||||
Visualization Initiative.
|
||||
|
||||
* National Alliance for Medical Image Computing (NAMIC) is funded by the
|
||||
National Institutes of Health through the NIH Roadmap for Medical Research,
|
||||
Grant U54 EB005149.
|
||||
|
||||
* Kitware, Inc.
|
73
cmake/modules/FindFtd2xx.cmake
Normal file
73
cmake/modules/FindFtd2xx.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
# - Try to find libftd2xx
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBFTD2XX_FOUND - system has libftd2xx
|
||||
# LIBFTD2XX_INCLUDE_DIRS - the libftd2xx include directory
|
||||
# LIBFTD2XX_LIBRARIES - Link these to use libftd2xx
|
||||
# LIBFTD2XX_DEFINITIONS - Compiler switches required for using libftd2xx
|
||||
#
|
||||
# Adapted from cmake-modules Google Code project
|
||||
#
|
||||
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
|
||||
#
|
||||
# (Changes for libftd2xx) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBFTD2XX_FOUND TRUE)
|
||||
else (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
||||
find_path(LIBFTD2XX_INCLUDE_DIR
|
||||
NAMES
|
||||
ftd2xx.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
)
|
||||
|
||||
SET(FTD2XX_LIBNAME ftd2xx)
|
||||
IF(WIN32)
|
||||
SET(FTD2XX_LIBNAME ftd2xx.lib)
|
||||
ENDIF(WIN32)
|
||||
|
||||
find_library(LIBFTD2XX_LIBRARY
|
||||
NAMES
|
||||
${FTD2XX_LIBNAME}
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
if(LIBFTD2XX_INCLUDE_DIR)
|
||||
set(LIBFTD2XX_INCLUDE_DIRS
|
||||
${LIBFTD2XX_INCLUDE_DIR}
|
||||
)
|
||||
endif(LIBFTD2XX_INCLUDE_DIR)
|
||||
set(LIBFTD2XX_LIBRARIES
|
||||
${LIBFTD2XX_LIBRARY}
|
||||
)
|
||||
|
||||
if (LIBFTD2XX_INCLUDE_DIRS AND LIBFTD2XX_LIBRARIES)
|
||||
set(LIBFTD2XX_FOUND TRUE)
|
||||
endif (LIBFTD2XX_INCLUDE_DIRS AND LIBFTD2XX_LIBRARIES)
|
||||
|
||||
if (LIBFTD2XX_FOUND)
|
||||
if (NOT libftd2xx_FIND_QUIETLY)
|
||||
message(STATUS "Found libftd2xx: ${LIBFTD2XX_LIBRARIES}")
|
||||
endif (NOT libftd2xx_FIND_QUIETLY)
|
||||
else (LIBFTD2XX_FOUND)
|
||||
if (libftd2xx_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find libftd2xx")
|
||||
endif (libftd2xx_FIND_REQUIRED)
|
||||
endif (LIBFTD2XX_FOUND)
|
||||
|
||||
# show the LIBFTD2XX_INCLUDE_DIRS and LIBFTD2XX_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(LIBFTD2XX_INCLUDE_DIRS LIBFTD2XX_LIBRARIES)
|
||||
|
||||
endif (LIBFTD2XX_LIBRARIES AND LIBFTD2XX_INCLUDE_DIRS)
|
75
cmake/modules/FindFtd4222.cmake
Normal file
75
cmake/modules/FindFtd4222.cmake
Normal file
@@ -0,0 +1,75 @@
|
||||
# - Try to find LIBFT4222
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBFT4222_FOUND - system has LIBFT4222
|
||||
# LIBFT4222_INCLUDE_DIRS - the LIBFT4222 include directory
|
||||
# LIBFT4222_LIBRARIES - Link these to use LIBFT4222
|
||||
# LIBFT4222_DEFINITIONS - Compiler switches required for using LIBFT4222
|
||||
#
|
||||
# Adapted from cmake-modules Google Code project
|
||||
#
|
||||
# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
|
||||
#
|
||||
# (Changes for LIBFTD2XX) Copyright (c) 2008 Kyle Machulis <kyle@nonpolynomial.com>
|
||||
# (Changes for LIBFT4222) Henry Bruce <henry.bruce@intel.com> Copyright (c) 2015 Intel Corporation.
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the New BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBFT4222_FOUND TRUE)
|
||||
else (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
|
||||
find_path(LIBFT4222_INCLUDE_DIR
|
||||
NAMES
|
||||
libft4222.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
)
|
||||
|
||||
SET(FTD4222_LIBNAME ft4222)
|
||||
IF(WIN32)
|
||||
SET(FTD4222_LIBNAME LibFT4222.lib)
|
||||
ENDIF(WIN32)
|
||||
|
||||
find_library(LIBFT4222_LIBRARY
|
||||
NAMES
|
||||
${FTD4222_LIBNAME}
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
if(LIBFT4222_INCLUDE_DIR)
|
||||
set(LIBFT4222_INCLUDE_DIRS
|
||||
${LIBFT4222_INCLUDE_DIR}
|
||||
)
|
||||
endif(LIBFT4222_INCLUDE_DIR)
|
||||
set(LIBFT4222_LIBRARIES
|
||||
${LIBFT4222_LIBRARY}
|
||||
)
|
||||
|
||||
if (LIBFT4222_INCLUDE_DIRS AND LIBFT4222_LIBRARIES)
|
||||
set(LIBFT4222_FOUND TRUE)
|
||||
endif (LIBFT4222_INCLUDE_DIRS AND LIBFT4222_LIBRARIES)
|
||||
|
||||
if (LIBFT4222_FOUND)
|
||||
if (NOT LIBFT4222_FIND_QUIETLY)
|
||||
message(STATUS "Found LIBFT4222: ${LIBFT4222_LIBRARIES}")
|
||||
endif (NOT LIBFT4222_FIND_QUIETLY)
|
||||
else (LIBFT4222_FOUND)
|
||||
if (LIBFT4222_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find LIBFT4222")
|
||||
endif (LIBFT4222_FIND_REQUIRED)
|
||||
endif (LIBFT4222_FOUND)
|
||||
|
||||
# show the LIBFT4222_INCLUDE_DIRS and LIBFT4222_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(LIBFT4222_INCLUDE_DIRS LIBFT4222_LIBRARIES)
|
||||
|
||||
endif (LIBFT4222_LIBRARIES AND LIBFT4222_INCLUDE_DIRS)
|
||||
|
21
cmake/modules/FindJSON-C.cmake
Normal file
21
cmake/modules/FindJSON-C.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
# JSON-C_FOUND - true if library and headers were found
|
||||
# JSON-C_INCLUDE_DIRS - include directories
|
||||
# JSON-C_LIBRARIES - library directories
|
||||
|
||||
find_package (PkgConfig)
|
||||
pkg_check_modules (PC_JSON-C QUIET json-c)
|
||||
|
||||
find_path (JSON-C_INCLUDE_DIR json.h HINTS ${PC_JSON-C_INCLUDEDIR}
|
||||
${PC_JSON-C_INCLUDE_DIRS} PATH_SUFFIXES json-c json)
|
||||
|
||||
find_library (JSON-C_LIBRARY NAMES json-c libjson-c HINTS ${PC_JSON-C_LIBDIR}
|
||||
${PC_JSON-C_LIBRARY_DIRS})
|
||||
|
||||
set (JSON-C_LIBRARIES ${JSON-C_LIBRARY})
|
||||
set (JSON-C_INCLUDE_DIRS ${JSON-C_INCLUDE_DIR})
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (JSON-C DEFAULT_MSG JSON-C_LIBRARY JSON-C_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced (JSON-C_INCLUDE_DIR JSON-C_LIBRARY)
|
94
cmake/modules/FindNodejs.cmake
Normal file
94
cmake/modules/FindNodejs.cmake
Normal file
@@ -0,0 +1,94 @@
|
||||
# Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
|
||||
macro(add_include_dir dir)
|
||||
if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
|
||||
set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
find_program (NODEJS_EXECUTABLE NAMES node nodejs
|
||||
HINTS
|
||||
$ENV{NODE_DIR}
|
||||
PATH_SUFFIXES bin
|
||||
DOC "Node.js interpreter"
|
||||
)
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
# If compat-libuv package exists, it must be at start of include path
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
|
||||
if (UV_ROOT_DIR)
|
||||
# set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
|
||||
add_include_dir(${UV_ROOT_DIR})
|
||||
endif()
|
||||
|
||||
# Now look for node. Flag an error if not found
|
||||
find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
|
||||
PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
|
||||
if (NODE_ROOT_DIR)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/src)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/node)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
|
||||
add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
|
||||
else()
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - node.h not found")
|
||||
endif()
|
||||
|
||||
# Check that v8.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT V8_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - v8.h not found")
|
||||
endif()
|
||||
|
||||
# Check that uv.h is in NODEJS_INCLUDE_DIRS
|
||||
find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
|
||||
if (NOT UV_ROOT_DIR)
|
||||
unset(NODEJS_INCLUDE_DIRS)
|
||||
message(ERROR " - uv.h not found")
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args (Nodejs DEFAULT_MSG
|
||||
NODEJS_EXECUTABLE
|
||||
NODEJS_INCLUDE_DIRS
|
||||
)
|
||||
|
||||
if (NODEJS_EXECUTABLE)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE _VERSION
|
||||
RESULT_VARIABLE _NODE_VERSION_RESULT)
|
||||
execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
|
||||
OUTPUT_VARIABLE _V8_VERSION
|
||||
RESULT_VARIABLE _V8_RESULT)
|
||||
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
|
||||
string (REPLACE "v" "" NODE_VERSION_STRING "${_VERSION}")
|
||||
string (REPLACE "." ";" _VERSION_LIST "${NODE_VERSION_STRING}")
|
||||
list (GET _VERSION_LIST 0 NODE_VERSION_MAJOR)
|
||||
list (GET _VERSION_LIST 1 NODE_VERSION_MINOR)
|
||||
list (GET _VERSION_LIST 2 NODE_VERSION_PATCH)
|
||||
set (V8_VERSION_STRING ${_V8_VERSION})
|
||||
string (REPLACE "." ";" _V8_VERSION_LIST "${_V8_VERSION}")
|
||||
list (GET _V8_VERSION_LIST 0 V8_VERSION_MAJOR)
|
||||
list (GET _V8_VERSION_LIST 1 V8_VERSION_MINOR)
|
||||
list (GET _V8_VERSION_LIST 2 V8_VERSION_PATCH)
|
||||
# we end up with a nasty newline so strip everything that isn't a number
|
||||
string (REGEX MATCH "^[0-9]*" V8_VERSION_PATCH ${V8_VERSION_PATCH})
|
||||
else ()
|
||||
set (NODE_VERSION_STRING "0.10.30")
|
||||
set (NODE_VERSION_MAJOR "0")
|
||||
set (NODE_VERSION_MINOR "10")
|
||||
set (NODE_VERSION_PATCH "30")
|
||||
set (V8_VERSION_MAJOR "3")
|
||||
set (V8_VERSION_MINOR"14")
|
||||
set (V8_VERSION_PATCH "5")
|
||||
set (V8_VERSION_STRING "3.28.72")
|
||||
message ("defaulted to node 0.10.30")
|
||||
endif ()
|
||||
string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
|
||||
string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
|
||||
message ("INFO - Node version is " ${NODE_VERSION_STRING})
|
||||
message ("INFO - Node using v8 " ${V8_VERSION_STRING})
|
||||
mark_as_advanced (NODEJS_EXECUTABLE)
|
||||
endif ()
|
||||
|
21
cmake/modules/FindUDEV.cmake
Normal file
21
cmake/modules/FindUDEV.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
# UDEV_FOUND - true if library and headers were found
|
||||
# UDEV_INCLUDE_DIRS - include directories
|
||||
# UDEV_LIBRARIES - library directories
|
||||
|
||||
find_package (PkgConfig)
|
||||
pkg_check_modules (PC_UDEV QUIET udev)
|
||||
|
||||
find_path (UDEV_INCLUDE_DIR libudev.h HINTS ${PC_UDEV_INCLUDEDIR}
|
||||
${PC_UDEV_INCLUDE_DIRS} PATH_SUFFIXES udev)
|
||||
|
||||
find_library (UDEV_LIBRARY NAMES udev libudev HINTS ${PC_UDEV_LIBDIR}
|
||||
${PC_UDEV_LIBRARY_DIRS})
|
||||
|
||||
set (UDEV_LIBRARIES ${UDEV_LIBRARY})
|
||||
set (UDEV_INCLUDE_DIRS ${UDEV_INCLUDE_DIR})
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (UDEV DEFAULT_MSG UDEV_LIBRARY UDEV_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced (UDEV_INCLUDE_DIR UDEV_LIBRARY)
|
21
cmake/modules/FindYuidoc.cmake
Normal file
21
cmake/modules/FindYuidoc.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
find_program (YUIDOC_EXECUTABLE NAMES yuidoc
|
||||
HINTS $ENV{YUIDOC_DIR}
|
||||
PATHS usr usr/local
|
||||
PATH_SUFFIXES bin
|
||||
DOC "Yuidoc documentation generator"
|
||||
)
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args (Yuidoc DEFAULT_MSG
|
||||
YUIDOC_EXECUTABLE
|
||||
)
|
||||
|
||||
# Get Yuidoc version
|
||||
if (YUIDOC_EXECUTABLE)
|
||||
execute_process(COMMAND ${YUIDOC_EXECUTABLE} --version
|
||||
ERROR_VARIABLE YUIDOC_VERSION)
|
||||
message ("INFO - Yuidoc version is " ${YUIDOC_VERSION})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced (YUIDOC_EXECUTABLE)
|
504
cmake/modules/LICENSE.LGPL
Normal file
504
cmake/modules/LICENSE.LGPL
Normal file
@@ -0,0 +1,504 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
@@ -2,11 +2,20 @@
|
||||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
||||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
||||
|
||||
# This file is under the terms of the GNU Lesser General Public License version
|
||||
# 2.1 as published by the Free Software Foundation and appearing in the file
|
||||
# LICENSE.LGPL included in the packaging of this file. Please review the
|
||||
# following information to ensure the GNU Lesser General Public License version
|
||||
# 2.1 requirements will be met:
|
||||
# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
|
||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
||||
# "There are many more known variants/revisions that we do not handle/detect."
|
||||
|
||||
set(archdetect_c_code "
|
||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__aarch64__)
|
||||
#error cmake_ARCH armv8
|
||||
#elif defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
||||
#if defined(__ARM_ARCH_7__) \\
|
||||
|| defined(__ARM_ARCH_7A__) \\
|
||||
|| defined(__ARM_ARCH_7R__) \\
|
||||
|
85
docs/banana_pi.md
Normal file
85
docs/banana_pi.md
Normal file
@@ -0,0 +1,85 @@
|
||||
Banana Pi/Pro {#bananapi}
|
||||
============
|
||||
|
||||
The Banana Pi/Pro is a clone of the well known Raspberry Pi. It has advantages
|
||||
compared to the 'old' Raspberry Pi A/B/A+/B+ devices as it is based on the
|
||||
Allwinner A20 Dual Core Cortex-A7. It also has 1G Ethernet compared to 100M
|
||||
Ethernet on the Raspberry.
|
||||
|
||||
There is a lot of effort on Mainline Kernel to fully support the Allwinner
|
||||
Chips, for example Fedora 22 Arm will come with support for BananaPi/Pro which
|
||||
means that you will be able to have HDMI Output and a number of periperal
|
||||
modules work out of the box.
|
||||
|
||||
Pin-wise the Banana Pi matches the Raspberry Pi, the Banana Pro has a connector
|
||||
similar to the Raspberry Pi A+/B+
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
Banana Pi
|
||||
Banana Pro
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**PWM** Whilst the Banana Pi is meant to have 1 PWM channel this is currently
|
||||
not supported.
|
||||
|
||||
**SPI** works fine when used with old 3.4 Kernels provided by Lemaker, on
|
||||
Mainline Kernel SPI does currently not work
|
||||
|
||||
**COM** I have created devicetree patches so that Mainline Kernel supports all
|
||||
COM-Interfaces, this is not yet visible in Kernel
|
||||
|
||||
Mainline Kernel requires the use of Device-Trees, mraa tries it's best to guess
|
||||
which gpio/serial/i2c/spi is connected where but there is currently no support
|
||||
to manipulate the Device-Tree settings from within mraa. If a device does not
|
||||
work as expected then please check syslog, mraa usually complains with a
|
||||
meaningful message when it is unable to initialize the device.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
This pin mapping refers to the Banana Pi but gives an idea
|
||||
as to what the values are from mraa. Note that there is an emum to use wiringPi
|
||||
style numbers.
|
||||
|
||||
| MRAA Number | Physical Pin | Function |
|
||||
|-------------|--------------|-----------|
|
||||
| 1 | P1-01 | 3V3 VCC |
|
||||
| 2 | P1-02 | 5V VCC |
|
||||
| 3 | P1-03 | I2C SDA |
|
||||
| 4 | P1-04 | 5V VCC |
|
||||
| 5 | P1-05 | I2C SCL |
|
||||
| 6 | P1-06 | GND |
|
||||
| 7 | P1-07 | GPIO(PI03)|
|
||||
| 8 | P1-08 | UART4 TX |
|
||||
| 9 | P1-09 | GND |
|
||||
| 10 | P1-10 | UART4 RX |
|
||||
| 11 | P1-11 | GPIO(PI19)|
|
||||
| 12 | P1-12 | GPIO(PH02)|
|
||||
| 13 | P1-13 | GPIO(PI18)|
|
||||
| 14 | P1-14 | GND |
|
||||
| 15 | P1-15 | GPIO(PI17)|
|
||||
| 16 | P1-16 | GPIO(PH20)|
|
||||
| 17 | P1-17 | 3V3 VCC |
|
||||
| 18 | P1-18 | GPIO(PH21)|
|
||||
| 19 | P1-19 | SPI MOSI |
|
||||
| 20 | P1-20 | GND |
|
||||
| 21 | P1-21 | SPI MISO |
|
||||
| 22 | P1-22 | GPIO(PI16)|
|
||||
| 23 | P1-23 | SPI SCL |
|
||||
| 24 | P1-24 | SPI CS0 |
|
||||
| 25 | P1-25 | GND |
|
||||
| 26 | P1-26 | SPI CS1 |
|
||||
|
||||
There is also a second 8-pin connector on the Banana Pi, the pins are as follows:
|
||||
|
||||
| 27 | P1-19 | 5V VCC |
|
||||
| 28 | P1-20 | 3V3 VCC |
|
||||
| 29 | P1-21 | GPIO(PH5) |
|
||||
| 30 | P1-22 | GPIO(PI22)|
|
||||
| 31 | P1-23 | GPIO(PH03)|
|
||||
| 32 | P1-24 | GPIO(PI20)|
|
||||
| 33 | P1-25 | GND |
|
||||
| 34 | P1-26 | GND |
|
74
docs/beaglebone.md
Normal file
74
docs/beaglebone.md
Normal file
@@ -0,0 +1,74 @@
|
||||
Beaglebone Black {#beaglebone}
|
||||
================
|
||||
|
||||
The Beaglebone Black is a very maker friendly Board with a huge amount of
|
||||
available I/O Pins. It consists of an Cortex-A8 single core CPU plus two
|
||||
additional microcontroller cores called 'pru' that can be used for realtime
|
||||
tasks.
|
||||
|
||||
The official Beaglebone Black Image runs Debian on a 3.8.13 Kernel. But there
|
||||
are also mainline kernels available, either from Robert C. Nelson or also as
|
||||
part of the upcoming Fedora 22 release.
|
||||
|
||||
The kernel releases from Robert C. Nelson have usually more complete support as
|
||||
not all code is yet commited to mainline kernel, your mileage may vary!
|
||||
|
||||
In Kernel 3.8.13 there is a Capemanager included, a mechanism to load
|
||||
configuration data for devices and extension boards from userland.
|
||||
|
||||
This mechanism does not (yet) exist in Mainline kernels, so for mainline
|
||||
kernels you need to either rely on the pre-delivered devicetree's or you will
|
||||
need to build your own devicetree to support hardware not available by default.
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
Beaglebone Black Rev. B
|
||||
Beaglebone Black Rev. C
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**SPI** works fine with 3.8.13 kernels, on Mainline Kernel SPI does currently
|
||||
not work. mraa will activate spi on 3.8.13 if it finds out that spi is not yet
|
||||
configured
|
||||
|
||||
**I2C** works both on 3.8.13 and mainline. i2c is activated if missing for
|
||||
3.8.13 kernels
|
||||
|
||||
Mainline Kernel requires the use of Device-Trees, mraa tries it's best to guess
|
||||
which gpio/serial/i2c/spi is connected where but there is currently no support
|
||||
to manipulate the Device-Tree settings from within mraa. If a device does not
|
||||
work as expected then please check syslog, mraa usually complains with a
|
||||
meaningful message when it is unable to initialize the device.
|
||||
|
||||
It will also tell you which overlay for SPI/COM/I2C/PWM it tries to load, on
|
||||
some older Debian distributions (or heaven forbid, on Angström) you may need to
|
||||
install thoses overlays to /lib/firmware
|
||||
|
||||
Capes and further documentation
|
||||
-------------------------------
|
||||
|
||||
Correctly configuring i2c/spi/serial can get a little challenging as some pins
|
||||
have double functionality or are not available at all because hdmi is enabled.
|
||||
When something does not work as expected make sure to first check the syslog,
|
||||
then check the Beaglebone documentation. Some pointers for good descriptions
|
||||
are:
|
||||
|
||||
http://elinux.org/BeagleBone_Black_Enable_SPIDEV
|
||||
http://elinux.org/Interfacing_with_I2C_Devices
|
||||
|
||||
When working with mainline kernels take every hit you have on google with a
|
||||
grain of salt, a lot of documentation is based on 3.8 and older kernels. Using
|
||||
mainline kernels can be very rewarding, but at least at time of writing also
|
||||
can have some nasty
|
||||
pitfalls.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
mraa will take into account if you have hdmi cape or mmc enabled and will show
|
||||
you the gpio's available for your given configuration.
|
||||
|
||||
To see the pin mapping use the command:
|
||||
|
||||
$ sudo mraa-gpio list
|
186
docs/building.md
186
docs/building.md
@@ -1,13 +1,32 @@
|
||||
Building libmraa {#building}
|
||||
===============
|
||||
libmraa uses cmake in order to make compilation relatively painless. CMake runs
|
||||
build out of tree so the recommended way is to clone from git and make a `build/`
|
||||
directory inside the clone directory.
|
||||
|
||||
libmraa uses cmake in order to make compilation relatively painless. Cmake runs
|
||||
build out of tree so the recommended way is to clone from git and make a build/ directory.
|
||||
For building imraa check [building imraa](../master/docs/imraa.md)
|
||||
## Build dependencies
|
||||
Not all these are required but if you're unsure of what you're doing this is
|
||||
what you'll need:
|
||||
* [SWIG](http://swig.org) 3.0.5+
|
||||
* [git](http://git-scm.com)
|
||||
* [python](http://python.org) 2.7 or 3.4+ (you'll need not just the interpreter but python-dev)
|
||||
* [node.js](http://nodejs.org) 0.10.x or 0.12.x (you'll need not just the interpreter but nodejs-dev)
|
||||
* [CMake](http://cmake.org) 2.8.8+ (3.1+ is recommended for node.js version 2+)
|
||||
|
||||
You'll need swig version 3.0.1+, currently I'm using
|
||||
8d226e39dc7a958013ff9ffd15e231ef206ba265 from the swig master branch. This is
|
||||
only required for javascript support and can be disabled with a cmake define
|
||||
(see below).
|
||||
For Debian-like distros the below command installs the basic set:
|
||||
|
||||
```bash
|
||||
sudo apt-get install git build-essential swig3.0 python-dev nodejs-dev cmake
|
||||
```
|
||||
|
||||
To build the documentation you'll also need:
|
||||
* [Doxygen](http://www.stack.nl/~dimitri/doxygen/) 1.8.9.1+
|
||||
* [Graphviz](http://graphviz.org/) 2+ (For Doxygen graph generation)
|
||||
* [Sphinx](http://sphinx-doc.org/) 1.1.3+ (For Python docs)
|
||||
|
||||
|
||||
## Basic build steps
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
mkdir build
|
||||
@@ -16,19 +35,150 @@ cmake ..
|
||||
make
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Our cmake configure has a number of options, `cmake -i` will ask you all sorts
|
||||
of interesting questions, you can disable swig modules, build documentation
|
||||
etc...
|
||||
If this goes wrong and you have all the dependencies installed, then please
|
||||
file an issue with the full output of `cmake ..` and `make` or however far you
|
||||
got.
|
||||
|
||||
Few recommended options:
|
||||
Changing install path from /usr/local to /usr
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=/usr
|
||||
After that you can install built files (into default path) by running:
|
||||
|
||||
Building debug build:
|
||||
-DCMAKE_BUILD_TYPE=DEBUG
|
||||
|
||||
Using clang instead of gcc:
|
||||
-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
Building with an older version of swig (swig 2.0+) requires the disabling of javascript:
|
||||
-DBUILDSWIGNODE=OFF
|
||||
See flags for adjusting install paths in the section below.
|
||||
|
||||
Currently our install logic puts Python bindings into standard paths, which
|
||||
do not work on Debian due to their
|
||||
[policy](http://www.debian.org/doc/packaging-manuals/python-policy/ch-python.html#s-paths).
|
||||
|
||||
We are working on a permanent solution, in the meanwhile please use this command
|
||||
after `make install` to link installed modules where Debian's Python expects them:
|
||||
|
||||
```bash
|
||||
sudo ln -s <your install prefix, e.g. /usr>/lib/python2.7/site-packages/* /usr/lib/python2.7/dist-packages
|
||||
```
|
||||
|
||||
Same approach works for Python 3, you'll just need to adjust the version number
|
||||
in the path accordingly.
|
||||
|
||||
## Configuration flags
|
||||
|
||||
Our CMake configuration has a number of options, `cmake-gui` or `ccmake` (`cmake -i` is
|
||||
no longer with us :() can show you all the options. A few of the more common
|
||||
ones are listed below. Note that when the option starts with `CMAKE_` it's an
|
||||
option that is made available by CMake and will be similar in all CMake
|
||||
projects. You need to add them after `cmake` but before `..`
|
||||
|
||||
A few recommended options:
|
||||
|
||||
Changing install path from `/usr/local` to `/usr`:
|
||||
`-DCMAKE_INSTALL_PREFIX:PATH=/usr`
|
||||
|
||||
Building debug build - adds `-g` and disables optimisations - this will force a
|
||||
full rebuild:
|
||||
`-DCMAKE_BUILD_TYPE=DEBUG`
|
||||
|
||||
Using `clang` instead of `gcc`:
|
||||
`-DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++`
|
||||
|
||||
Building with an older version of SWIG (< 3.0.2) requires the disabling of JavaScript:
|
||||
`-DBUILDSWIGNODE=OFF`
|
||||
|
||||
Disabling Python module building:
|
||||
`-DBUILDSWIGPYTHON=OFF`
|
||||
|
||||
Building doc, this will require [SPHINX](http://sphinx-doc.org) &
|
||||
[Doxygen](http://doxygen.org):
|
||||
`-DBUILDDOC=ON`
|
||||
|
||||
Building with Python 3 (careful you need to clear CMake cache between Python
|
||||
version switches!)
|
||||
`-DBUILDPYTHON3=ON`
|
||||
|
||||
Override build architecture (this is useful because on x86 ARM code is not
|
||||
compiled so use this flag to force the target arch)
|
||||
`-DBUILDARCH=arm`
|
||||
|
||||
## Dependencies continued
|
||||
|
||||
You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
|
||||
JavaScript & Python modules. If your version of SWIG is older than this then
|
||||
please see above for disabling `SWIGNODE`. Otherwise you will get a weird build
|
||||
failure when building the JavaScript module. The Python module builds with SWIG
|
||||
2.x.
|
||||
|
||||
During the build, we'll assume you're building from git, note that if you
|
||||
compile with `git` installed your version of mraa will be tagged `-dirty`. This
|
||||
simply means `git` wasn't installed or that you where building from a tarball.
|
||||
You can modify `build/src/version.c` before running `make` if this is incorrect.
|
||||
The instructions listed here all assume that `build/` is an empty dir that lives
|
||||
inside the cloned repository of mraa.
|
||||
|
||||
If you have multiple versions of Python then mraa can get confused, we
|
||||
recommend using virtualenv to select which version of Python you want. We test
|
||||
2.7 the most but SWIG will generate valid 3.x Python code but we do not
|
||||
generally support building both at once.
|
||||
|
||||
## Using a Yocto/OE toolchain
|
||||
|
||||
In order to compile with a Yocto/OE toolchain use the following toolchain file.
|
||||
This works well on the Edison 1.7.2 SDK. First source the environment file, then
|
||||
use our CMake toolchain file.
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
source /opt/poky-edison/1.7.2/environment-setup-core2-32-poky-linux
|
||||
mkdir build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/oe-sdk_cross.cmake ..
|
||||
make
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Using Coverity
|
||||
|
||||
Static analysis is routinely performed using Coverity on libmraa's codebase.
|
||||
This is the procedure to submit a build to Coverity. You'll need to install
|
||||
`coverity-submit` for your OS.
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
mkdir covbuild/ && cd covbuild
|
||||
cmake -DBUILDDOC=OFF -DBUILDSWIG=OFF ..
|
||||
cov-build --dir cov-int make
|
||||
tar caf mraa.tar.bz2 cov-int
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
## Building Java bindings
|
||||
Have JAVA_HOME set to JDK install directory. Most distributions set this from `/etc/profile.d/`
|
||||
and have a way of switching between alternatives. We support both OpenJDK and Oracle's JDK.
|
||||
On Arch Linux with OpenJDK 8 you'll have to set this yourself like this:
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
export JAVA_HOME=/usr/lib/jvm/default/
|
||||
~~~~~~~~~~~~~
|
||||
Then use the CMake configuration flag:
|
||||
`-DBUILDSWIGJAVA=ON`
|
||||
To compile `Example.java`
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
javac -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example.java
|
||||
~~~~~~~~~~~~~
|
||||
To run, make sure `libmraajava.so` is in `LD_LIBRARY_PATH`
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
jave -cp $DIR_WHERE_YOU_INSTALLED_MRAA/mraa.jar:. Example
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
If you want to add or improve Java bindings for mraa, please follow the [Creating Java Bindings Guide](https://github.com/intel-iot-devkit/upm/blob/master/docs/creating_java_bindings.md).
|
||||
|
||||
## Building an IPK/RPM package using `cpack`
|
||||
|
||||
You can get `cpack` to generate an IPK or RPM package fairly easily if you have
|
||||
the correct packaging tools
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
cmake -DIPK=ON -DCMAKE_INSTAL_PREFIX=/usr ..
|
||||
make package
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
To use RPM simply enable the RPM option. You'll need `rpmbuild` installed on your
|
||||
build machine.
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
cmake -DRPM=ON -DCMAKE_INSTAL_PREFIX=/usr ..
|
||||
~~~~~~~~~~~~~
|
||||
|
250
docs/changelog.md
Normal file
250
docs/changelog.md
Normal file
@@ -0,0 +1,250 @@
|
||||
Changelog {#changelog}
|
||||
=========
|
||||
|
||||
This changelog is meant as a quick & rough guide to what has changed between
|
||||
versions. The API is now fairly stable but when new calls/features are added
|
||||
they are listed here. Anything pre 0.2.x is ignored.
|
||||
|
||||
**0.10.0**
|
||||
* Add Firmata support with -DFIRMATA=ON
|
||||
* Add imraa with support for pinmuxing and arduino101 flashing
|
||||
* Add better support for NVM installed node via NODE_ROOT_DIR.
|
||||
* Mraa bindings now link to libmraa.so.x
|
||||
* mraa_init() now returns MRAA_SUCCESS if platform is already initialize
|
||||
* Mraa java bindings now support JNI 1.6+
|
||||
* Added support for a02082 rpi2
|
||||
* Mraa has a logo!
|
||||
|
||||
**0.9.6**
|
||||
* ftdi ft4222 now dynamically loaded
|
||||
* FT4222 improved ISR code
|
||||
|
||||
**0.9.5**
|
||||
* Add support for the UP board (up-board.org)
|
||||
* Support OpenJDK 7 as well as OpenJDK 8
|
||||
* 96board better pin numbering
|
||||
* node v4 improvements
|
||||
* Support for PCA9555 i2c expander read/write on FT4222
|
||||
|
||||
**0.9.4**
|
||||
* Fix issue with edison ADC initilisation
|
||||
* documentation update
|
||||
|
||||
**0.9.3**
|
||||
* Intel edison detection much improved
|
||||
* ftdi ft4222 interupt improvement
|
||||
* small fixes to java lib
|
||||
|
||||
**0.9.2**
|
||||
* Fix bug with mraa_init & USBPLAT
|
||||
* Add mraa_gpio_read_dir call
|
||||
* Enable cherryhill/braswell platform
|
||||
* Improved 96 board support
|
||||
|
||||
**0.9.1**
|
||||
* Minnowboard Turbot support
|
||||
* Change to java runables for ISR support
|
||||
* New platform version call
|
||||
* Default i2c bus on edison miniboard is now i2c-1
|
||||
* More compatibility with node.js versions > 0.10
|
||||
* New C++ get i2c default bus call
|
||||
* Various bug fixes & optimisations
|
||||
|
||||
**0.9.0**
|
||||
* Beta iio API in C & C++ (no SWIG support)
|
||||
* Added 96Board support
|
||||
* Added Brillo/Android support
|
||||
* Java ISR fixes
|
||||
* FT4222 gpio support
|
||||
|
||||
**0.8.1**
|
||||
* Nodejs 4.1.1 support
|
||||
* Java examples fixes
|
||||
* Nodejs SPI tweaks
|
||||
* Misc fixes
|
||||
|
||||
**0.8.0**
|
||||
* Better java support
|
||||
* Support for FT4222 subplatforms
|
||||
* New types.hpp improves C++ & SWIG APIs
|
||||
* Added support for minnowboard max compatible boards
|
||||
|
||||
**0.7.5**
|
||||
* 5th Generation NUC i2c support
|
||||
* NPM 0.10.x ia32 fix
|
||||
|
||||
**0.7.4**
|
||||
* Minnowboard i2c fix
|
||||
* Add NPM arm support
|
||||
* Uart initialisation improved
|
||||
* Better i2c bus detection on DE3815 & mmax
|
||||
|
||||
**0.7.3**
|
||||
* DE3815 i2c fix when using different kernels
|
||||
* Fixed various memory leaks in SWIG wrappers
|
||||
* gpio enums all prefixed with mraa_
|
||||
* Fix SPI CS pin caps causing mux_total to be > 0
|
||||
* Improved error checking/handling
|
||||
|
||||
**0.7.2**
|
||||
* Fix node.js npm builds with binding.gyp that didn't use --target-arch
|
||||
|
||||
**0.7.1**
|
||||
* Uart now uses binary arrays and has optional 'Str' functions in C++/SWIG
|
||||
* Various Uart module bugfixes
|
||||
* Node.js 0.12.4 support
|
||||
* Node.js documentation support
|
||||
|
||||
**0.7.0**
|
||||
* Uart module now contains read/write interactions and configuration
|
||||
* Python API contains more buffer checks
|
||||
* Java support
|
||||
* RPM cpack support
|
||||
|
||||
**0.6.2**
|
||||
* Node.js 0.12 support
|
||||
* NPM support
|
||||
* Formatting done with clang-format
|
||||
* Various examples and documentation updates
|
||||
* Supported added for Beaglebone Black + Banana Pi
|
||||
|
||||
**0.6.1**
|
||||
* 16bit spi iunctions added
|
||||
* Node.js ISR now supported
|
||||
|
||||
**0.6.0**
|
||||
* add device path queries for uart
|
||||
* add platform configuration querying
|
||||
* gpio sample added
|
||||
* improve i2c/spi write/read API for python & nodejs
|
||||
* performance improvements on edison & galileo
|
||||
|
||||
**0.5.4**
|
||||
* pwm read_* fix introduced in 0.5.3
|
||||
* improved npmpkg support
|
||||
|
||||
**0.5.3**
|
||||
* OE toolchain support added to CMake
|
||||
* Various UART fixes
|
||||
* SPI add CS exposure
|
||||
* Remove functions from mraa.c into modules
|
||||
* Rework of support for mmap
|
||||
* Intel Edison MMAP support added. Read and Write
|
||||
* I2C clean up, add cleaner functions
|
||||
* MinnowBoard Max support added
|
||||
* PWM period is written before duty
|
||||
* Node GYP build supported added
|
||||
* Add Get Platform Name function
|
||||
|
||||
**0.5.2**
|
||||
* pwm improvement & bugfix
|
||||
* spi mraa_spi_bit_per_word fix
|
||||
* new spi transfer function
|
||||
* i2c object api uses uint8_t
|
||||
* i2c readReg() calls added
|
||||
* edison i2c bus now defaults to a sensible value
|
||||
* edison uart enable support
|
||||
* edison hardware CS exposed as IO10
|
||||
* DE3815tykhe NUC support
|
||||
|
||||
**0.5.1**
|
||||
* Intel Edison - Mini breakout board support
|
||||
* Change to use syslog throughout instead of printing to stderr.
|
||||
* Fix misc issues brought up throuh coverity scans
|
||||
* Clear up Analog call documentation
|
||||
|
||||
**0.5.0**
|
||||
* Intel Edison - Arduino board support.
|
||||
* Boost Allowable i2c busses to 12
|
||||
* Additional platform hooks added
|
||||
* ADC is now 10bits by default on all platforms but can be changed
|
||||
|
||||
**0.4.5**
|
||||
* if only one spidev we default to it reguardless of number
|
||||
* mraa_pwm_config_ms & mraa_pwm_config_percent functions added
|
||||
* Uart C++ class added, adds python & node support
|
||||
* galileo gen2 gpio modes supported
|
||||
|
||||
**0.4.4**
|
||||
* prefix SPI mode with MRAA_SPI_
|
||||
* added C++ adc bitness calls
|
||||
|
||||
**0.4.3**
|
||||
* SPI Mode function now functional, API Change in SPI
|
||||
* I2C read in swig worked on.
|
||||
* Galileo Gen 2: PWM setting period sets all channel's period
|
||||
* Galileo Gen 2: I2C setup now specific to Gen 2.
|
||||
* General commits around freeing memory at the right times.
|
||||
|
||||
**0.4.2**
|
||||
* Barebone UART module added.
|
||||
* Hook branch merged.
|
||||
* I2C init hooks added.
|
||||
* Intel Galileo Gen 2, I2C gpio pins now go hiz input when I2C initialised.
|
||||
|
||||
**0.4.1**
|
||||
* Rename python & nodejs modules to mraa
|
||||
* common.hpp introduced for C++
|
||||
* python & nodejs modules can now take binary strings for Spi & I2c
|
||||
* improved Aio module and clear bitness
|
||||
* Improved Galileo Gen 2 support
|
||||
|
||||
**0.4.0**
|
||||
* Rename to mraa
|
||||
* get_platform_type function added.
|
||||
|
||||
**0.3.1**
|
||||
* Initial Intel Galileo Gen 2 support
|
||||
* mraa_gpio_isr parameters added.
|
||||
* Detection of different supported platforms added.
|
||||
|
||||
**0.3.0**
|
||||
* mraa_i2c_read now returns length of read
|
||||
|
||||
**0.2.9**
|
||||
* Add global mraa.h & mraa.hpp headers
|
||||
* usage of "gpio.h" is not legal you need to use "mraa/gpio.h" unless adding
|
||||
-L/usr/include/mraa
|
||||
|
||||
**0.2.8**
|
||||
* Added mraa_set_priority call
|
||||
* Added mmap gpio call mraa_gpio_use_mmaped
|
||||
|
||||
**0.2.7**
|
||||
* C++ API now uses basic types and not unistd types as C
|
||||
* Clearer and consistent use of unistd tpyes in C api
|
||||
|
||||
**0.2.6**
|
||||
* C++ examples added, using c++ headers/api.
|
||||
* moved to open instead of fopen in all modules
|
||||
* rename mraa_check functions and made them internal to mraa only.
|
||||
* removed "export" functions from api
|
||||
* Intel Galileo Gen 1 (rev d) fixes, incorrect definition of some items
|
||||
* SPI, implementation completed.
|
||||
* I2C internal function, completed.
|
||||
* PWM fix bug in period set method.
|
||||
* Swig upstream can be used for building.
|
||||
* No longer builds docs on default cmake, needs flag
|
||||
* GPIO/PWM ownership guard prevents closing on existing pins, still can be forced.
|
||||
|
||||
**0.2.5**
|
||||
* C++/Python/Node Enums/const names now do not contain MRAA_GPIO
|
||||
* Enum type declaration for C++ changed
|
||||
* Python/Node get_version() -> GetVersion()
|
||||
* i2c read calls don't use const char* and i2c write calls do
|
||||
|
||||
**0.2.4**
|
||||
* All mraa_ contexts now are pointers to the actual struct which is not
|
||||
delcared in the header. The only end user change is that instead of
|
||||
returning a type mraa_gpio_context pointer mraa_gpio_init() now returns a
|
||||
mraa_gpio_context (which is actually a pointer to struct _gpio internally).
|
||||
* C++ API is available, use the .hpp headers and add stdc++ to the linker
|
||||
flags.
|
||||
* Initial SPI implementation is provided
|
||||
|
||||
**0.2.3**
|
||||
* mraa_aio_read_u16() -> mraa_aio_read()
|
||||
* mraa_aio_read() now returns a uint16_t instead of an unsigned int
|
||||
|
||||
**0.2.2**
|
||||
* First version with API considered 'stable'
|
@@ -1,17 +0,0 @@
|
||||
Contributing to libmraa {#contributing}
|
||||
======================
|
||||
|
||||
libmraa is an opensource project and we are actively looking for people to help
|
||||
with:
|
||||
|
||||
- Writing platform supports for all types of embedded boards running linux
|
||||
- People to write cool samples
|
||||
- People to extend the functionality
|
||||
|
||||
The recommended method to contribute is to fork on github, and then send pull
|
||||
requests to the main project. Questions can be also be asked and issues raised
|
||||
on github.
|
||||
|
||||
If you'd rather not use github you are more than welcome to send git formatted
|
||||
patches to brendan.le.foll@intel.com.
|
||||
|
31
docs/debugging.md
Normal file
31
docs/debugging.md
Normal file
@@ -0,0 +1,31 @@
|
||||
Debugging libmraa {#debugging}
|
||||
=================
|
||||
|
||||
This page contains a few debugging tip. When filing an issue please go through
|
||||
this list as it's the first thing we'll ask you to do.
|
||||
|
||||
### Finding your mraa version
|
||||
|
||||
Getting the exact version of libmraa you're running is really important to us.
|
||||
The best way to get this is to call mraa_get_version() or mraa.getVersion(). If
|
||||
mraa returns x.x.x-dirty then your version was not built from a git tree or you
|
||||
built out of tree (see our building doc) - or you don't have git installed.
|
||||
|
||||
### Finding error logs
|
||||
|
||||
mraa logs pretty much everything that goes wrong to syslog. These days it'll go
|
||||
to the systemd journal so check with `sudo journalctl -f` whilst running your
|
||||
app or check all libmraa messages with `journalctl -t libmraa`. Grab all the
|
||||
messages from the initialisation message right up to your last one. Using a
|
||||
pastebin is always a good idea, I like dpaste.com. If your system does not have
|
||||
systemd likely your log is in /var/log/messages or a similar location.
|
||||
|
||||
### Common errors to check for
|
||||
|
||||
* Not running as root
|
||||
* Incorrect IO pin numbers, mraa uses physical connector pin numbering see your
|
||||
platform documentation for details
|
||||
* Your platform is unsupported
|
||||
* Using the wrong pin, check pin capabilities either using the API or your
|
||||
platform documentation
|
||||
|
114
docs/edison.md
114
docs/edison.md
@@ -1,16 +1,116 @@
|
||||
Intel Edison {#edison}
|
||||
=============
|
||||
|
||||
Edison is a dual core Silvermont Atom clocked at 500MHz. The Edison
|
||||
also features 4GB of storage, 1GB ram and onboard wifi and bluetooth.
|
||||
Intel(R) Edison is a dual-core Silvermont Atom(TM) clocked at 500MHz. The
|
||||
Edison also features 4GB of storage, 1GB ram and on-board WiFi and Bluetooth.
|
||||
|
||||
Currently the Arduino breakout board is supported by libmraa.
|
||||
Currently supported boards:
|
||||
- Intel Arduino board
|
||||
- Intel breakout board
|
||||
|
||||
UART
|
||||
----
|
||||
On both the Arduino board and the breakout board, The available UART interface is on /dev/ttyMFD1
|
||||
|
||||
Intel Arduino board
|
||||
-------------------
|
||||
The Edison used with the Arduino board has the following limitations
|
||||
in libmraa:
|
||||
|
||||
- i2c is exposed on i2c-6, therfore you must use bus 6 and not bus 0
|
||||
- PWM avaible on default swizzler postions. (3,5,6,9)
|
||||
- Do not use the 'reset' button on the arduino shields, there is a hardware
|
||||
bug and the platform will likely not come back up correctly
|
||||
- I2C is exposed on i2c-6, therefore you must use bus 6 and not bus 0
|
||||
- PWM available on default swizzler positions. (3,5,6,9)
|
||||
- SPI exposed is also used for the ADC. Try not to use your own CS.
|
||||
- ADC kernel module will return 12bit number but the ADC itself only has an
|
||||
accuracy of 10bits. This ADC is only included on the arduino board.
|
||||
- Max SPI speed is 25Mhz/4 ~6.25Mhz
|
||||
- SPI PM can sometimes do weird things you can disable it with:
|
||||
`echo on > /sys/devices/pci0000\:00/0000\:00\:07.1/power/control`
|
||||
- ADC kernel module will return 16bit number but the ADC itself only has an
|
||||
accuracy of maximum 12bits and in MRAA it's limited to 10bits by default.
|
||||
Use `mraa_aio_set_bit(12)` to switch to the maximum resolution mode.
|
||||
This ADC is only included on the Arduino board.
|
||||
- AIO pins are treated as 0-5 in `mraa_aio_init()` but as 14-19 for everything
|
||||
else. Therefore use `mraa_gpio_init(14)` to use A0 as a GPIO
|
||||
- Arduino pin 7 can sometimes negatively impact the WiFi capability, if using
|
||||
WiFi avoid using this pin
|
||||
- Edison's i2c-1 can be used using for example the sparkfun i2c breakout ontop
|
||||
of the Arduino breakout board, this is not supported officially so asking for
|
||||
mraa_i2c_init(1) will result in getting i2c bus 6 (the default one). However
|
||||
using raw mode (mraa_i2c_init_raw(1)) this bus is fully usable
|
||||
- If you want to use /dev/ttyMFD2 you have to use the raw uart mode passing a
|
||||
std::string or char* argument of "/dev/ttyMFD2" to mraa:Uart() or
|
||||
mraa_uart_init_raw. By default there is a getty running on that interface so
|
||||
you will need to disable that first
|
||||
|
||||
Because of the way IO is setup with the tristate on the Arduino breakout board
|
||||
IO will be flipped as it is setup. It's recommended to setup IO pins &
|
||||
direction before using them in a `setup()` method or similar. It's impossible on
|
||||
this platform to avoid some GPIOs flipping on setup.
|
||||
|
||||
Intel(R) breakout board
|
||||
-----------------------
|
||||
|
||||
- Both I2C buses are available 1 & 6
|
||||
- IO on the miniboard is 1.8V
|
||||
- Requesting GPIO 4 will break your FTDI UART console, so bear in mind when trying to use it
|
||||
|
||||
Please see the following table on how the physical pins map to mraa pin numbers
|
||||
|
||||
| MRAA Number | Physical Pin | Edison Pin | Notes | Pinmode0 | Pinmode1 | Pinmode2 |
|
||||
|-------------|--------------|---------------|-------------------------|----------|------------|----------|
|
||||
| 0 | J17-1 | GP182 | | GPIO-182 | PWM2 | |
|
||||
| 1 | J17-2 | NC | Nothing from mraa | | | |
|
||||
| 2 | J17-3 | NC | Nothing from mraa | | | |
|
||||
| 3 | J17-4 | VIN | Nothing from mraa | | | |
|
||||
| 4 | J17-5 | GP135 | | GPIO-135 | UART | |
|
||||
| 5 | J17-6 | RCVR_MODE | Nothing from mraa | | | |
|
||||
| 6 | J17-7 | GP27 | | GPIO-27 | I2C-6-SCL | |
|
||||
| 7 | J17-8 | GP20 | | GPIO-20 | I2C-1-SDA | |
|
||||
| 8 | J17-9 | GP28 | | GPIO-28 | I2C-6-SDA | |
|
||||
| 9 | J17-10 | GP111 | | GPIO-111 | SPI-5-CS1 | |
|
||||
| 10 | J17-11 | GP109 | | GPIO-109 | SPI-5-SCK | |
|
||||
| 11 | J17-12 | GP115 | | GPIO-115 | SPI-5-MOSI | |
|
||||
| 12 | J17-13 | OSC_CLK_OUT_0 | Nothing from mraa/check | | | |
|
||||
| 13 | J17-14 | GP128 | | GPIO-128 | UART-1-CTS | |
|
||||
| 14 | J18-1 | GP13 | | GPIO-13 | PWM1 | |
|
||||
| 15 | J18-2 | GP165 | | GPIO-165 | | |
|
||||
| 16 | J18-3 | GPI_PWRBTN_N | Nothing from mraa | | | |
|
||||
| 17 | J18-4 | MSIC_SLP_CLK2 | Nothing from mraa | | | |
|
||||
| 18 | J18-5 | V_VBAT_BKUP | Nothing from mraa | | | |
|
||||
| 19 | J18-6 | GP19 | | GPIO-19 | I2C-1-SCL | |
|
||||
| 20 | J18-7 | GP12 | PWM0 | GPIO-12 | PWM0 | |
|
||||
| 21 | J18-8 | GP183 | PWM3 | GPIO-183 | PWM3 | |
|
||||
| 22 | J18-9 | NC | Nothing from mraa | | | |
|
||||
| 23 | J18-10 | GP110 | | GPIO-110 | SPI-5-CS0 | |
|
||||
| 24 | J18-11 | GP114 | | GPIO-114 | SPI-5-MISO | |
|
||||
| 25 | J18-12 | GP129 | | GPIO-129 | UART-1-RTS | |
|
||||
| 26 | J18-13 | GP130 | | GPIO-130 | UART-1-RX | |
|
||||
| 27 | J18-14 | FW_RCVR | Nothing from mraa | | | |
|
||||
| 28 | J19-1 | NC | Nothing from mraa | | | |
|
||||
| 29 | J19-2 | V_V1P80 | Nothing from mraa | | | |
|
||||
| 30 | J19-3 | GND | Nothing from mraa | | | |
|
||||
| 31 | J19-4 | GP44 | | GPIO-44 | | |
|
||||
| 32 | J19-5 | GP46 | | GPIO-46 | | |
|
||||
| 33 | J19-6 | GP48 | | GPIO-48 | | |
|
||||
| 34 | J19-7 | RESET_OUT | Nothing from mraa | | | |
|
||||
| 35 | J19-8 | GP131 | | GPIO-131 | UART-1-TX | |
|
||||
| 36 | J19-9 | GP14 | | GPIO-14 | | |
|
||||
| 37 | J19-10 | GP40 | | GPIO-40 | SSP2_CLK | |
|
||||
| 38 | J19-11 | GP43 | | GPIO-43 | SSP2_TXD | |
|
||||
| 39 | J19-12 | GP77 | | GPIO-77 | SD | |
|
||||
| 40 | J19-13 | GP82 | | GPIO-82 | SD | |
|
||||
| 41 | J19-14 | GP83 | | GPIO-83 | SD | |
|
||||
| 42 | J20-1 | V_VSYS | Nothing from mraa | | | |
|
||||
| 43 | J20-2 | V_V3P30 | Nothing from mraa | | | |
|
||||
| 44 | J20-3 | GP134 | | | | |
|
||||
| 45 | J20-4 | GP45 | | GPIO-45 | | |
|
||||
| 46 | J20-5 | GP47 | | GPIO-47 | | |
|
||||
| 47 | J20-6 | GP49 | | GPIO-49 | | |
|
||||
| 48 | J20-7 | GP15 | | GPIO-15 | | |
|
||||
| 49 | J20-8 | GP84 | | GPIO-84 | SD | |
|
||||
| 50 | J20-9 | GP42 | | GPIO-42 | SSP2_RXD | |
|
||||
| 51 | J20-10 | GP41 | | GPIO-41 | SSP2_FS | |
|
||||
| 52 | J20-11 | GP78 | | GPIO-78 | SD | |
|
||||
| 53 | J20-12 | GP79 | | GPIO-79 | SD | |
|
||||
| 54 | J20-13 | GP80 | | GPIO-80 | SD | |
|
||||
| 55 | J20-14 | GP81 | | GPIO-81 | SD | |
|
||||
|
37
docs/firmata.md
Normal file
37
docs/firmata.md
Normal file
@@ -0,0 +1,37 @@
|
||||
Using Firmata board with mraa {#firmata}
|
||||
=============================
|
||||
|
||||
Mraa can use a Firmata board as a subplatform. This means one can access the
|
||||
native IO as well as the IO on a firmata compatible board
|
||||
|
||||
### Supported Firmata boards ###
|
||||
|
||||
- Genuino/Arduino 101 running either CustomFirmata or StandardFirmata
|
||||
- Other Arduino boards will likely work but are as of yet unsuported
|
||||
|
||||
### Using the subplatform API ###
|
||||
|
||||
Using the subplatform API is relatively simple, simply add '512', the platform
|
||||
offset to any IO calls. I2c 0 becomes I2c 512+0 etc... The API works from UPM
|
||||
or mraa in any of the bindings as long as you compiled mraa with -DFIRMATA=ON.
|
||||
Currently -DFIRMATA is not compatible with USBPLAT. Multiple subplatforms are
|
||||
not yet supported
|
||||
|
||||
### Sending custom SYSSEX messages ###
|
||||
|
||||
You can use the firmata API to send custom SYSEX messages.
|
||||
|
||||
### CurieImu Plugin ###
|
||||
|
||||
Using Customisable firmata we're able to use the onboard IMU to get data. This
|
||||
uses the public SYSEX firmata API from mraa and there is a UPM module that
|
||||
exposes this capability in a simple way. To use it your board needs to use
|
||||
CustomFirmata with the CurieIMU plugin
|
||||
|
||||
### Limitations ###
|
||||
|
||||
Only one instance of mraa (one process linking to mraa) can communicate to an
|
||||
firmata subplatform. This is a limitation due to only having one application
|
||||
using the Uart at once. In order to get around this a daemon type methodology
|
||||
has to be used. Technically you can mirror the TTY port from firmata but this
|
||||
is likely going to cause issues
|
80
docs/ftdi_ft4222.md
Normal file
80
docs/ftdi_ft4222.md
Normal file
@@ -0,0 +1,80 @@
|
||||
FTDI FT4222H {#ft4222}
|
||||
============
|
||||
|
||||
The FT4222H is a High/Full Speed USB2.0-to-Quad SPI/I2C device controller. Mraa
|
||||
supports it as a USB subplatform using the libft4222 library from FTDI which
|
||||
can be found
|
||||
[here](http://www.ftdichip.com/Support/SoftwareExamples/libft4222-1.2.1.4.tgz).
|
||||
You need the latest version for the GPIO to work.
|
||||
|
||||
The FT4222H has 4 configuration modes selected by {DCNF1, DCNF0}. The chip
|
||||
configuration mode will determine the number of USB interfaces for data streams
|
||||
and for GPIOs control. Mraa supports chip modes CNFMODE0 and CNFMODE3. In
|
||||
CNFMODE0 the chip can provide either 4 GPIOs and SPI, or 2 GPIOs and I2C
|
||||
since SCL/SDA are shared with GPIO0/GPIO1. It is possible to change this
|
||||
selection dynamically by calling the corresponding mraa init functions.
|
||||
CNFMODE3 on the other hand will only provide SPI or I2C.
|
||||
|
||||
By default, both modes start with I2C enabled and the driver will scan for
|
||||
known GPIO expanders on the I2C bus when the FT4222H is initialized.
|
||||
|
||||
Supported GPIO expanders:
|
||||
* PCA9672
|
||||
* PCA9555
|
||||
* PCF8575
|
||||
|
||||
Output from 'mraa-gpio list' would be as follows:
|
||||
~~~~~~~~~~~~~
|
||||
512 IGPIO0/SCL0: GPIO I2C
|
||||
513 IGPIO1/SDA0: GPIO I2C
|
||||
514 INT-GPIO2: GPIO
|
||||
515 INT-GPIO3: GPIO
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
When an I2C GPIO expander is present, the pins on the expander will appear after
|
||||
the 4 FT4222H GPIO pins (i.e. starting at physical pin #4, logical pin #516).
|
||||
~~~~~~~~~~~~~
|
||||
512 IGPIO0/SCL0: GPIO I2C
|
||||
513 IGPIO1/SDA0: GPIO I2C
|
||||
514 INT-GPIO2: GPIO
|
||||
515 INT-GPIO3: GPIO
|
||||
516 EXP-GPIO0: GPIO
|
||||
517 EXP-GPIO1: GPIO
|
||||
518 EXP-GPIO2: GPIO
|
||||
519 EXP-GPIO3: GPIO
|
||||
520 EXP-GPIO4: GPIO
|
||||
521 EXP-GPIO5: GPIO
|
||||
522 EXP-GPIO6: GPIO
|
||||
523 EXP-GPIO7: GPIO
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
If a PCA9545 I2C switch is detected an extra four I2C busses will appear,
|
||||
representing the four downstream busses. Output from 'mraa-i2c list'
|
||||
would be as follows:
|
||||
~~~~~~~~~~~~~
|
||||
Bus 512: id=00 type=ft4222 default
|
||||
Bus 513: id=01 type=ft4222
|
||||
Bus 514: id=02 type=ft4222
|
||||
Bus 515: id=03 type=ft4222
|
||||
Bus 516: id=04 type=ft4222
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Please note that some mraa features might not be fully implemented yet and they
|
||||
are still under development (e.g. SPI replacement functions).
|
||||
|
||||
We tested the module using FTDI's UMFT4222EV reference board. More details on
|
||||
this board can be found
|
||||
[here](http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_UMFT4222EV.pdf).
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
You will need to unload all ftdi kernel modules for libft4222 to work
|
||||
correctly. You will also have to compile mraa with FT4222 support which may not
|
||||
be enabled by default.
|
||||
|
||||
The cmake options to build this driver are:
|
||||
~~~~~~~~~~~~~
|
||||
FTDI4222=ON
|
||||
USBPLAT=ON
|
||||
~~~~~~~~~~~~~
|
@@ -1,11 +1,14 @@
|
||||
Galileo Gen 1 - Rev D {#galileorevd}
|
||||
=====================
|
||||
|
||||
Galileo is a microcontroller board based on the Intel® Quark SoC X1000
|
||||
Galileo is a microcontroller board based on the Intel(R) Quark(TM) SoC X1000
|
||||
Application Processor, a 32-bit Intel Pentium-class system on a chip.
|
||||
|
||||
The rev D board has the following limitations in libmraa:
|
||||
|
||||
- gpio 13 will not switch the LED as it's a different Gpio, use raw gpio '3' to do this
|
||||
- gpio register access via /dev/uio is limited to pin2 and 3
|
||||
- gpio interupts will only work on GPIO_EDGE_BOTH
|
||||
- adc kernel module will return 12bit number. MRAA defaults shift this to 10bits
|
||||
- AIO pins are treated as 0-5 in mraa_aio_init() but as 14-19 for everything
|
||||
else. Therefore use mraa_gpio_init(14) to use A0 as a Gpio
|
||||
|
@@ -1,14 +1,66 @@
|
||||
Galileo Gen 2 - Rev H {#galileorevh}
|
||||
=====================
|
||||
|
||||
Galileo is a microcontroller board based on the Intel® Quark SoC X1000
|
||||
Galileo is a microcontroller board based on the Intel(R) Quark(TM) SoC X1000
|
||||
Application Processor, a 32-bit Intel Pentium-class system on a chip.
|
||||
|
||||
The Gen 2 board has the following limitations in libmraa:
|
||||
|
||||
- i2c is set at 400Khz speed cannot be changed without reloading kernel module
|
||||
- i2c bus is shared with multiple devices, scanning it usually fails
|
||||
- i2c is set at 400Khz speed cannot be changed without reloading kernel module,
|
||||
the driver is intel_qrk_gip_i2c and the parameter is i2c_std_mode which must
|
||||
be set to 1 in order to set the i2c bus speed to 100Khz
|
||||
- i2c bus is shared with multiple devices in kernel space, scanning it usually
|
||||
fails
|
||||
- pwm period is set globally for all pwm channels, when changed this will halt
|
||||
all pwm channels
|
||||
- adc kernel module will return 12bit number but the ADC itself only has an
|
||||
accuracy of 10bits.
|
||||
- AIO pins are treated as 0-5 in mraa_aio_init() but as 14-19 for everything
|
||||
else. Therefore use mraa_gpio_init(14) to use A0 as a Gpio
|
||||
- To explicitly use GPIO 10 for SPI and allow the kernel to handle the chip select, set
|
||||
`intel_qrk_plat_galileo_gen2.gpio_cs=1` on the kernel line in the boot config on the
|
||||
galileo, this can be found at `/media/mmcblk0p1/boot/grub/grub.conf`
|
||||
- if done correctly it should look similiar to this:
|
||||
|
||||
<pre>
|
||||
title Quark X1000 kernel-MassStorage iot-devkit on SD IMR-On IO-APIC/HPET NoEMU debug
|
||||
root (hd0,0)
|
||||
kernel /bzImage root=/dev/mmcblk0p2 <b>intel_qrk_plat_galileo_gen2.gpio_cs=1</b> rootwait console=ttyS1,115200n8 earlycon=uart8250,mmio32,0x8010f000,115200n8 reboot=efi,warm apic=debug rw LABEL=boot debugshell=5
|
||||
</pre>
|
||||
|
||||
Uart 1 on gen2
|
||||
--------------
|
||||
|
||||
Uart 1 is connected to the FTDI header and the linux console. It's also
|
||||
possible to use it from A2(Rx)/A3(Tx). However mraa does not support this
|
||||
directly so you need to enable the muxing manually. Here is an example of how
|
||||
this is done, this was tested using an FTDI 3.3V TTL cable:
|
||||
|
||||
```
|
||||
$ systemctl stop serial-getty@ttyS1.service
|
||||
$ python
|
||||
>>> # Configure the Muxes for Uart1 on Aio2/3
|
||||
>>> import mraa as m
|
||||
>>> p77 = m.Gpio(77, False, True)
|
||||
>>> p76 = m.Gpio(76, False, True)
|
||||
>>> p16 = m.Gpio(16, False, True)
|
||||
>>> p17 = m.Gpio(17, False, True)
|
||||
>>> p77.write(1)
|
||||
>>> p76.write(1)
|
||||
>>> p16.dir(m.DIR_OUT)
|
||||
>>> p16.write(0)
|
||||
>>> p17.dir(m.DIR_OUT)
|
||||
>>> p17.write(1)
|
||||
|
||||
>>> # For Rx to work correctly switch the level shifter
|
||||
>>> p34 = m.Gpio(34, False, True)
|
||||
>>> p34.dir(m.DIR_OUT)
|
||||
>>> p34.write(1)
|
||||
|
||||
>>> # Use the uart
|
||||
>>> x = m.Uart(1)
|
||||
>>> x.setBaudRate(115200)
|
||||
>>> x.writeStr('hello')
|
||||
>>> x.read(5)
|
||||
bytearray(b'dsds\n')
|
||||
```
|
||||
|
44
docs/iio.md
Normal file
44
docs/iio.md
Normal file
@@ -0,0 +1,44 @@
|
||||
iio {#iio}
|
||||
===
|
||||
IIO is the kernel's framework for supporting sensors.
|
||||
## Using dummy_iio driver
|
||||
For platforms without IIO hardware the iio_dummy driver can be used. You can
|
||||
add the driver by either rebuilding the kernel with IIO component enabled or
|
||||
just building the IIO modules and load them. You must add the following config
|
||||
fragment. Known to work for kernel 3.19 and later.
|
||||
<pre><code>
|
||||
CONFIG_IIO_DUMMY_EVGEN=m
|
||||
CONFIG_IIO_SIMPLE_DUMMY=m
|
||||
CONFIG_IIO_SIMPLE_DUMMY_EVENTS=y
|
||||
CONFIG_IIO_SIMPLE_DUMMY_BUFFER=y
|
||||
</code></pre>
|
||||
### Add driver to kernel
|
||||
Boot with new kernel, then load modules
|
||||
<pre><code>
|
||||
$ modprobe iio_dummy
|
||||
$ modprobe iio_dummy_evgen
|
||||
</code></pre>
|
||||
### Load kernel modules
|
||||
Depending our your kernel config, some of these modules may already be loaded.
|
||||
<pre><code>
|
||||
$ insmod drivers/iio/industrialio.ko
|
||||
$ insmod drivers/iio/kfifo_buf.ko
|
||||
$ insmod drivers/staging/iio/iio_dummy_evgen.ko
|
||||
$ insmod drivers/staging/iio/iio_dummy.ko
|
||||
</code></pre>
|
||||
## 'RAW' access
|
||||
|
||||
Mraa supports raw access
|
||||
|
||||
###Channels
|
||||
|
||||
###Attributes
|
||||
|
||||
###Events
|
||||
|
||||
###Triggers
|
||||
|
||||
Activate the trigger in /sys/class/iio
|
||||
$ echo 1 > trigger0/trigger_now
|
||||
|
||||
|
63
docs/imraa.md
Normal file
63
docs/imraa.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Building mraa with imraa {#buildingimraa}
|
||||
Imraa allows seamless communication between the Arduino101 and your mraa
|
||||
projects. Imraa will flash an arduino101 and allow automatic loading of the
|
||||
MRAA_GENERIC_FIRMATA subplatform to the first process that calls imraa_init
|
||||
(done through mraa_init automatically)
|
||||
|
||||
## Build dependencies
|
||||
To build imraa, you'll need to build mraa with -DIMRAA=ON and all the normal
|
||||
dependencies for build mraa, see [Building mraa](../master/docs/building.md).
|
||||
You'll also need the following:
|
||||
* [dfu-utils-cross](https://github.com/arduino/dfu-utils-cross) or dfu 0.8 (0.9
|
||||
does not work well with the 101). Precompiled binaries can be found on
|
||||
[here](https://github.com/01org/intel-arduino-tools)
|
||||
* [json-c](https://github.com/json-c/json-c): likely called libjson-c-dev or
|
||||
json-c-devel
|
||||
* libudev: likely called libudev-dev or libudev-devel
|
||||
|
||||
## Basic build steps
|
||||
This will build mraa with imraa for the local default path. To build mraa for
|
||||
the system add `-DCMAKE_INSTALL_PREFIX=/usr` to the cmake command before
|
||||
running it.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DIMRAA=ON -DFIRMATA=ON ..
|
||||
make
|
||||
```
|
||||
|
||||
After you've built mraa you can install using `make install`.
|
||||
|
||||
## Running Imraa
|
||||
|
||||
Before being able to use mraa to program the Arduino101 you will need to run
|
||||
imraa to flash the sketch file onto the board. The sketch file that imraa will
|
||||
look for is located here: [Arduino101 Sketch](http://iotdk.intel.com/misc/ConfigurableFirmataCurieImu.ino.bin).
|
||||
Once downloaded the file needs to be renamed and moved to the where mraa was
|
||||
installed. This is dependant on whether you installed locally or for the
|
||||
system. The example below is for a locally installed copy. Note this sketch is
|
||||
using ConfigurableFirmata + the [CurieIMU plugin](https://github.com/intel-iot-devkit/FirmataCurieIMU).
|
||||
|
||||
|
||||
```bash
|
||||
$ mv ConfigurableFirmataCurieImu.ino.bin firmata101.ino.bin
|
||||
$ mv firmata101.ino.bin /usr/local/share/mraa
|
||||
```
|
||||
|
||||
You will also need to move the imraa config so that imraa can find it.
|
||||
```bash
|
||||
$ mv mraa/imraa/imraa.conf /etc/
|
||||
```
|
||||
|
||||
To flash the board run imraa and it will create the lockfile and flash the
|
||||
Arduino101. You may need root permissions or to add yourself to the uucp or
|
||||
modem group to access the device node (typically /dev/ttyACM0).
|
||||
```
|
||||
$ imraa
|
||||
```
|
||||
|
||||
After this is successful you will be able to use mraa like normal, in the
|
||||
background mraa will handle talking to the arduino101 by creating
|
||||
/tmp/imraa.lock which imraa_init() will parse on startup.
|
||||
|
69
docs/index.java.md
Normal file
69
docs/index.java.md
Normal file
@@ -0,0 +1,69 @@
|
||||
libmraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
|
||||
==============
|
||||
|
||||
Libmraa is a C/C++ library with bindings to Java, Python and JavaScript to
|
||||
interface with the I/O on Galileo, Edison & other platforms, with a structured
|
||||
and sane API where port names/numbering matches the board that you are on. Use
|
||||
of libmraa does not tie you to specific hardware with board detection done at
|
||||
runtime you can create portable code that will work across the supported
|
||||
platforms.
|
||||
|
||||
The intent is to make it easier for developers and sensor manufacturers to map
|
||||
their sensors & actuators on top of supported hardware and to allow control of
|
||||
low level communication protocol by high level languages & constructs.
|
||||
|
||||
## API
|
||||
|
||||
These interfaces allow you to interact with all libmraa functionality. The
|
||||
Java classes directly wrap the C/C++ API and provide a near 1:1 mapping of
|
||||
functionality.
|
||||
|
||||
<center>
|
||||
| C API Modules | Java API Classes |
|
||||
|:----------------------:|:----------------------------:|
|
||||
| @ref gpio.h "gpio" | @ref mraa::Gpio "Gpio class" |
|
||||
| @ref i2c.h "i2c" | @ref mraa::I2c "I2c class" |
|
||||
| @ref aio.h "aio" | @ref mraa::Aio "Aio class" |
|
||||
| @ref pwm.h "pwm" | @ref mraa::Pwm "Pwm class" |
|
||||
| @ref spi.h "spi" | @ref mraa::Spi "Spi class" |
|
||||
| @ref uart.h "uart" | @ref mraa::Uart "Uart class" |
|
||||
| @ref common.h "common" | @ref mraa::mraa "mraa class" |
|
||||
</center>
|
||||
|
||||
### Hello Mraa
|
||||
@snippet HelloEdison.java Interesting
|
||||
|
||||
## Supported platforms
|
||||
|
||||
Specific platform information for supported platforms is documented here:
|
||||
|
||||
- @ref galileorevd
|
||||
- @ref galileorevh
|
||||
- @ref edison
|
||||
- @ref de3815
|
||||
- @ref minnowmax
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref nuc5
|
||||
- @ref ft4222
|
||||
|
||||
## DEBUGGING
|
||||
|
||||
Sometimes it just doesn't want to work, let us try and help you, you can file
|
||||
issues in github or join us in #mraa on freenode IRC, hang around for a little
|
||||
while because we're not necessarily on 24/7, but we'll get back to you! Have a
|
||||
glance at our @debugging page too
|
||||
|
||||
## COMPILING
|
||||
|
||||
More information on compiling is @ref building page.
|
||||
|
||||
## CONTRIBUTING
|
||||
|
||||
Please see the @ref contributing page, the @ref internals page may also be of
|
||||
use.
|
||||
|
||||
## API Changelog
|
||||
|
||||
Version @ref changelog here.
|
138
docs/index.md
138
docs/index.md
@@ -1,9 +1,12 @@
|
||||
MRAA - Low Level Skeleton Library for Communication on Intel platforms
|
||||
libmraa - Low Level Skeleton Library for Communication on GNU/Linux platforms
|
||||
==============
|
||||
|
||||
Library in C/C++ to interface with Galileo & other Intel platforms, in a
|
||||
structured and sane API with port names/numbering that match boards & with
|
||||
bindings to javascript & python.
|
||||
Libmraa is a C/C++ library with bindings to Python, Javascript and Java to
|
||||
interface with the I/O on Galileo, Edison & other platforms, with a structured
|
||||
and sane API where port names/numbering matches the board that you are on. Use
|
||||
of libmraa does not tie you to specific hardware with board detection done at
|
||||
runtime you can create portable code that will work across the supported
|
||||
platforms.
|
||||
|
||||
The intent is to make it easier for developers and sensor manufacturers to map
|
||||
their sensors & actuators on top of supported hardware and to allow control of
|
||||
@@ -36,123 +39,32 @@ Specific platform information for supported platforms is documented here:
|
||||
|
||||
- @ref galileorevd
|
||||
- @ref galileorevh
|
||||
- @ref edison
|
||||
- @ref de3815
|
||||
- @ref minnowmax
|
||||
- @ref rasppi
|
||||
- @ref bananapi
|
||||
- @ref beaglebone
|
||||
- @ref nuc5
|
||||
- @ref up
|
||||
- @ref ft4222
|
||||
|
||||
### ENV RECOMENDATIONS
|
||||
## DEBUGGING
|
||||
|
||||
All of these are 'optional', however they are recommended. Only a C compiler,
|
||||
cmake, libm and pthreads are technically required to compile.
|
||||
|
||||
- Swig 3.0.1+ built with node.js & python support (0.10.x)
|
||||
- doxygen
|
||||
- sphinx (requires doxygen)
|
||||
- pygments
|
||||
Sometimes it just doesn't want to work, let us try and help you, you can file
|
||||
issues in github or join us in #mraa on freenode IRC, hang around for a little
|
||||
while because we're not necessarily on 24/7, but we'll get back to you! Have a
|
||||
glance at our @debugging page too
|
||||
|
||||
## COMPILING
|
||||
|
||||
More information on compiling is @ref building page
|
||||
More information on compiling is @ref building page.
|
||||
|
||||
## CONTRIBUTING
|
||||
|
||||
Please see the @ref contributing page
|
||||
Please see the @ref contributing page, the @ref internals page may also be of
|
||||
use.
|
||||
|
||||
## API Changelog
|
||||
|
||||
This changelog is meant as a quick & rough guide to what has changed between
|
||||
versions. The API is now fairly stable but when new calls/features are added
|
||||
they are listed here. Anything pre 0.2.x is ignored.
|
||||
|
||||
**0.5.0**
|
||||
* Intel Edison - Arduino board support.
|
||||
* Boost Allowable i2c busses to 12
|
||||
* Additional platform hooks added
|
||||
* ADC is now 10bits by default on all platforms but can be changed
|
||||
|
||||
**0.4.5**
|
||||
* if only one spidev we default to it reguardless of number
|
||||
* mraa_pwm_config_ms & mraa_pwm_config_percent functions added
|
||||
* Uart C++ class added, adds python & node support
|
||||
* galileo gen2 gpio modes supported
|
||||
|
||||
**0.4.4**
|
||||
* prefix SPI mode with MRAA_SPI_
|
||||
* added C++ adc bitness calls
|
||||
|
||||
**0.4.3**
|
||||
* SPI Mode function now functional, API Change in SPI
|
||||
* I2C read in swig worked on.
|
||||
* Galileo Gen 2: PWM setting period sets all channel's period
|
||||
* Galileo Gen 2: I2C setup now specific to Gen 2.
|
||||
* General commits around freeing memory at the right times.
|
||||
|
||||
**0.4.2**
|
||||
* Barebone UART module added.
|
||||
* Hook branch merged.
|
||||
* I2C init hooks added.
|
||||
* Intel Galileo Gen 2, I2C gpio pins now go hiz input when I2C initialised.
|
||||
|
||||
**0.4.1**
|
||||
* Rename python & nodejs modules to mraa
|
||||
* common.hpp introduced for C++
|
||||
* python & nodejs modules can now take binary strings for Spi & I2c
|
||||
* improved Aio module and clear bitness
|
||||
* Improved Galileo Gen 2 support
|
||||
|
||||
**0.4.0**
|
||||
* Rename to mraa
|
||||
* get_platform_type function added.
|
||||
|
||||
**0.3.1**
|
||||
* Initial Intel Galileo Gen 2 support
|
||||
* mraa_gpio_isr parameters added.
|
||||
* Detection of different supported platforms added.
|
||||
|
||||
**0.3.0**
|
||||
* mraa_i2c_read now returns length of read
|
||||
|
||||
**0.2.9**
|
||||
* Add global mraa.h & mraa.hpp headers
|
||||
* usage of "gpio.h" is not legal you need to use "mraa/gpio.h" unless adding
|
||||
-L/usr/include/mraa
|
||||
|
||||
**0.2.8**
|
||||
* Added mraa_set_priority call
|
||||
* Added mmap gpio call mraa_gpio_use_mmaped
|
||||
|
||||
**0.2.7**
|
||||
* C++ API now uses basic types and not unistd types as C
|
||||
* Clearer and consistent use of unistd tpyes in C api
|
||||
|
||||
**0.2.6**
|
||||
* C++ examples added, using c++ headers/api.
|
||||
* moved to open instead of fopen in all modules
|
||||
* rename mraa_check functions and made them internal to mraa only.
|
||||
* removed "export" functions from api
|
||||
* Intel Galileo Gen 1 (rev d) fixes, incorrect definition of some items
|
||||
* SPI, implementation completed.
|
||||
* I2C internal function, completed.
|
||||
* PWM fix bug in period set method.
|
||||
* Swig upstream can be used for building.
|
||||
* No longer builds docs on default cmake, needs flag
|
||||
* GPIO/PWM ownership guard prevents closing on existing pins, still can be forced.
|
||||
|
||||
**0.2.5**
|
||||
* C++/Python/Node Enums/const names now do not contain MRAA_GPIO
|
||||
* Enum type declaration for C++ changed
|
||||
* Python/Node get_version() -> GetVersion()
|
||||
* i2c read calls don't use const char* and i2c write calls do
|
||||
|
||||
**0.2.4**
|
||||
* All mraa_ contexts now are pointers to the actual struct which is not
|
||||
delcared in the header. The only end user change is that instead of
|
||||
returning a type mraa_gpio_context pointer mraa_gpio_init() now returns a
|
||||
mraa_gpio_context (which is actually a pointer to struct _gpio internally).
|
||||
* C++ API is available, use the .hpp headers and add stdc++ to the linker
|
||||
flags.
|
||||
* Initial SPI implementation is provided
|
||||
|
||||
**0.2.3**
|
||||
* mraa_aio_read_u16() -> mraa_aio_read()
|
||||
* mraa_aio_read() now returns a uint16_t instead of an unsigned int
|
||||
|
||||
**0.2.2**
|
||||
* First version with API considered 'stable'
|
||||
Version @ref changelog here.
|
||||
|
38
docs/intel_de3815.md
Normal file
38
docs/intel_de3815.md
Normal file
@@ -0,0 +1,38 @@
|
||||
Intel(R) NUC DE3815tykhe {#de3815}
|
||||
=============
|
||||
|
||||
The DE3815 NUC Kit is a single core Atom(TM) clocked at 1.46GHz.
|
||||
http://www.intel.com/content/www/us/en/nuc/nuc-kit-de3815tykhe.html
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
**GPIO** Not yet implemented.
|
||||
|
||||
**PWM** Functionality for the PWM is provided by the `pwm_lpss` module `CONFIG_PWM_LPSS`
|
||||
|
||||
**I2C** Depending on your system you may need to load `i2c-dev`
|
||||
|
||||
Custom Solutions Header mapping
|
||||
-------------------------------
|
||||
Based on: http://downloadmirror.intel.com/23745/eng/DE3815TYBE_TechProdSpec06.pdf
|
||||
|
||||
| MRAA Number | Physical Pin | Function | Notes |
|
||||
|-------------|--------------|--------------|----------------------|
|
||||
| 0 | 1 | 1.8V sby | |
|
||||
| 1 | 2 | GND | |
|
||||
| 2 | 3 | HDMI_CEC | |
|
||||
| 3 | 4 | DMIC_CLK | |
|
||||
| 4 | 5 | 3.3V sby | |
|
||||
| 5 | 6 | DMIC_DATA | |
|
||||
| 6 | 7 | Key (no pin) | |
|
||||
| 7 | 8 | SMB_ALERT# | |
|
||||
| 8 | 9 | 5V sby (2A) | |
|
||||
| 9 | 10 | SCI_SMI_GPIO | |
|
||||
| 10 | 11 | PWM[0] | PWM Chip 0 Channel 0 |
|
||||
| 11 | 12 | PWM[1] | PWM Chip 0 Channel 1 |
|
||||
| 12 | 13 | I2C0_CLK | /dev/i2c-0 SCL |
|
||||
| 13 | 14 | I2C0_DATA | /dev/i2c-0 SDA |
|
||||
| 14 | 15 | I2C1_CLK | /dev/i2c-1 SCL |
|
||||
| 15 | 16 | I2C1_DATA | /dev/i2c-1-SDA |
|
||||
| 16 | 17 | SMB_CLK | |
|
||||
| 17 | 18 | SMB_DATA | |
|
46
docs/intel_nuc5.md
Normal file
46
docs/intel_nuc5.md
Normal file
@@ -0,0 +1,46 @@
|
||||
Intel NUC NUC5i5MYBE {#nuc5}
|
||||
====================
|
||||
|
||||
Pinmuxing on the 5th generation Intel NUCs is done in the BIOS. This is only
|
||||
tested on bios 0024+ (MYBDWi5v.86A). By default the custom solution header is
|
||||
disabled, currently in Linux (as of 4.2). Both i2c buses are currently
|
||||
supported.
|
||||
|
||||
The NUCs supported are the NUC5i5MYBE & NUC5i3MYBE which also come as the
|
||||
NUC5i5MYHE and NUC5i3MYHE motherboards. It's possible that others expose the IO
|
||||
in a very similar way so could be supported, get in touch if you have one!
|
||||
|
||||
In the BIOS you are required to enable the following:
|
||||
Devices -> Onboard Devices - GPIO Lockdown
|
||||
Select I2c under GPIO for the 12/13 14/15 pins
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**I2C** Depending on your system you may need to load `i2c-dev`
|
||||
|
||||
Custom Solutions Header mapping
|
||||
-------------------------------
|
||||
|
||||
The mapping is the same as the DE3815tykhe.
|
||||
|
||||
| MRAA Number | Physical Pin | Function | Notes |
|
||||
|-------------|--------------|--------------|----------------------|
|
||||
| 0 | 1 | 1.8V sby | |
|
||||
| 1 | 2 | GND | |
|
||||
| 2 | 3 | HDMI_CEC | |
|
||||
| 3 | 4 | DMIC_CLK | |
|
||||
| 4 | 5 | 3.3V sby | |
|
||||
| 5 | 6 | DMIC_DATA | |
|
||||
| 6 | 7 | Key (no pin) | |
|
||||
| 7 | 8 | SMB_ALERT# | |
|
||||
| 8 | 9 | 5V sby (2A) | |
|
||||
| 9 | 10 | SCI_SMI_GPIO | |
|
||||
| 10 | 11 | PWM[0] | |
|
||||
| 11 | 12 | PWM[1] | |
|
||||
| 12 | 13 | I2C0_CLK | /dev/i2c-0 SCL |
|
||||
| 13 | 14 | I2C0_DATA | /dev/i2c-0 SDA |
|
||||
| 14 | 15 | I2C1_CLK | /dev/i2c-1 SCL |
|
||||
| 15 | 16 | I2C1_DATA | /dev/i2c-1-SDA |
|
||||
| 16 | 17 | SMB_CLK | |
|
||||
| 17 | 18 | SMB_DATA | |
|
180
docs/internals.md
Normal file
180
docs/internals.md
Normal file
@@ -0,0 +1,180 @@
|
||||
libmraa Internals {#internals}
|
||||
=================
|
||||
|
||||
For building see @ref building. This will describe the general internal build
|
||||
of libmraa and will be useful to developers who'd like to understand more of
|
||||
how libmraa works or who'd like to add additional platforms. The internals will
|
||||
deal with the C API as that is the low level API which libmraa is built around.
|
||||
Note that C++ is simply a header only wrapper of the C API.
|
||||
|
||||
libmraa has the philosophy that the board mapping is what we typically use in
|
||||
the API with the execption of i2c/spi bus numbering as they are typically not
|
||||
labelled on boards and so we use the kernel numbering scheme. Whilst this can
|
||||
confuse some, it's typically not an issue as platforms rarely expose more than
|
||||
one of these for user use and so when this is the case, libmraa will always use
|
||||
the bus in the pinmapper. For example edison uses i2c #6 but since there is
|
||||
only one, libmraa will try to be helpful and everything is treated as 6 when
|
||||
doing a mraa_i2c_init(). The _raw functions will override the pinmapper and can
|
||||
be accessed without a valid board configuration. This can be helpful either in
|
||||
development of platform configurations for mraa or when modifying kernels
|
||||
etc... Internally the mechanism is used heavily.
|
||||
|
||||
In libmraa, all code is split into 7 modules, src/{i2c, spi, gpio, uart, pwm,
|
||||
aio and common}. These should be fairly self explanatory in goals/purpose but a
|
||||
few work in different ways. Public APIs are stored in api/ and internal headers
|
||||
are in include/
|
||||
|
||||
### Logging ###
|
||||
|
||||
Logging is now done purely in syslog(). Note that on platforms running systemd
|
||||
journald will intercept syslog(3) calls and log to the journal instead. You can
|
||||
set the log mask by using mraa_set_log_level(). Doing a DEBUG build of libmraa
|
||||
will also cause the DEBUG macro to be defined which will cause the syslog mask
|
||||
to be unset.
|
||||
|
||||
### Contexts ###
|
||||
|
||||
libmraa uses contexts to store all information, this context cannot be accessed
|
||||
by the user and so it's layout can and may be changed without warning to users.
|
||||
If an init() function fails it will return NULL and further calls with this
|
||||
context will lead to undefined behaviour.
|
||||
|
||||
### Pinmapper ###
|
||||
|
||||
The mraa_board_t is defined in mraa/common.h. It's a mostly static structure
|
||||
initialised during mraa_init(). The pinmap file in
|
||||
src/{arch}/{manufacturer}_{boardname}_{revision}.c then fills this array. It's
|
||||
also where platform hooks can be defined, functions that will be run at various
|
||||
'hook' points in the code.
|
||||
|
||||
The mraa_pininfo_t structure needs to be set for the board pincount (set in a
|
||||
macro in the platform configuration header. Every pin will have a
|
||||
mraa_pincapabilities_t which will define what it can do. The doxygen
|
||||
documentation explains how this works but it's essentially a bitfield which
|
||||
needs to be set for every capability the pin can have. Gpios can have multiple
|
||||
muxes which will be set at the gpio init before it can be toggled.
|
||||
|
||||
### i2c ###
|
||||
|
||||
I2c from userspace in GNU/Linux is handled by character devices handled by the
|
||||
kernel driver i2c-dev. For more details the i2c/dev-interface documentation
|
||||
file in the kernel is the place to go.
|
||||
|
||||
In libmraa, we re-use part of a library - libi2c from RoadNarrows -
|
||||
i2c/smbus.c. This library simply makes it easier for us to handle the error
|
||||
conditions that can arrise when writing on i2c buses. Essentially the API is
|
||||
fairly simple consisting of writes & reads.
|
||||
|
||||
Careful - on alot of platforms i2cdetect will often crash. To findi your i2c
|
||||
addresses please look at your sensor's datasheet! If using i2cdetect most
|
||||
platforms do not support SMBus quick write so use the '-r' flag.
|
||||
|
||||
### spi ###
|
||||
|
||||
Mraa deals exclusively with spidev, so when we say bus we really mean bus +
|
||||
chip select from spidev. Spi(0) could lead to spidev5.1 and Spi(1) to
|
||||
spidev5.2. Typically on a micro using a random gpio as a chip select works
|
||||
well, and on some platforms if one is careful with threads this can work well
|
||||
with mraa. However when a kernel module shares the same bus as spidev (but on a
|
||||
different CS) this behaviour is *very* dangerous. Platforms such as Galileo
|
||||
Gen2 & Edison + Arduino breakout board work this way. Mraa will not help you in
|
||||
using a non hardware chip select, do so at your own peril!
|
||||
|
||||
### gpio ###
|
||||
|
||||
GPIO is probably the most complicated and odd module in libmraa. It is based on
|
||||
the gpiolib kernel driver framework which uses sysfs. There is a lot of good
|
||||
documentation in gpio/sysfs.txt in the kernel docs.
|
||||
|
||||
The main issue is that gpios on hobbyist boards typically come with a number of
|
||||
muxers or level shifters and are often mapped in crazy ways. libmraa's goal is
|
||||
to make the label on your board match the API :) We hope that pleases you.
|
||||
|
||||
Because boards are very different we use alot of platform hooks (@ref hooks) to
|
||||
make the initialisation work on all platforms. The hope is that simple
|
||||
platforms with no level shifters or expanders will work with just the pinmap
|
||||
definition.
|
||||
|
||||
GPIOs are typically interfaced via sysfs because that's easier for us but we
|
||||
can also work with fast gpio. This is typically preffered to do mmap gpio
|
||||
access. This is however trickier and typically relies on lots of platform
|
||||
hooks. By default we support hitting /dev/mem or another device at specific
|
||||
addresses to toggle gpios which is how mmap access works on some boards.
|
||||
|
||||
Note that in Linux gpios are numbered from ARCH_NR_GPIOS down. This means that
|
||||
if ARCH_NR_GPIOS is changed, the gpio numbering will change. In 3.18+ the
|
||||
default changed from 256 to 512, sadly the value cannot be viewed from
|
||||
userspace so we rely on the kernel version to extrapolate the likely value.
|
||||
|
||||
### uart ###
|
||||
|
||||
libmraa does not support UART/serial as there are many good libraries that do
|
||||
this already. In the future we may wrap or use one. However the class exists to
|
||||
set the pinmapper correctly for uart to work on some platforms.
|
||||
|
||||
### pwm ###
|
||||
|
||||
Internally everything with PWM in mraa is in microseconds because that's what
|
||||
the linux kernel uses and is probably all the granularity we'll ever
|
||||
need/achieve with the kind of hardware we're targetting. Board configuration
|
||||
pwm max/min values are always set in microseconds.
|
||||
|
||||
### aio ###
|
||||
|
||||
AIO pins are numbered after GPIO pins. This means that on Arduino style boards
|
||||
pin 14 is A0. Typically mraa will only support an ADC if a platform ships with
|
||||
one and has a good kernel module for it. Extra i2c/spi ADCs can be supported
|
||||
via something like UPM but are unlikely to receive support in mraa at the moment.
|
||||
|
||||
Note that giving mraa_aio_init(0) will literally query the pinmapper for
|
||||
board->gpio_count + 0 so you must place your aio pins after gpio_count. This is
|
||||
the default behaviour but can of course be overriden by advance function
|
||||
pointers. Whilst maybe not the sanest of defaults, most of the hobbyist boards
|
||||
we deal with follow a naming pattern similar to Arduino or have no ADC so for
|
||||
now we have considered this sensible.
|
||||
|
||||
### Initialisation ###
|
||||
|
||||
mraa_init() needs to be called in order to initialise the platform files or
|
||||
'pinmap'. Because calling this is tedious libmraa uses a C constructor to run
|
||||
mraa_init on library load. This means that it is not possible to stop this
|
||||
running and all function calls like mraa_set_log_level() will not work during
|
||||
mraa_init(). This feature is supported by most sane compilers and libcs but you
|
||||
can turn off CTORS in uclibc, though I've yet to find a configuration with
|
||||
someone doing that. mraa_init() can be called multiple times if you feel like
|
||||
being 'safe'.
|
||||
|
||||
In the SWIG modules mraa_init() is called during the %init stage of the module
|
||||
loading. This is simply to avoid mraa_init() running 'too' early, though I've
|
||||
never seen an issue in running it in a CTOR.
|
||||
|
||||
### SWIG ###
|
||||
|
||||
At the time when libmraa was created (still the case?) the only - working -
|
||||
API/wrapper generation tool that supported nodejs was SWIG. For more general
|
||||
information on SWIG please see the SWIG documentation.
|
||||
|
||||
The src/{javascript, python} & src/mraa.i folders contain all the files for the
|
||||
SWIG generation. The C++ headers in api/mraa/ are given as input sources to
|
||||
SWIG. SWIG modules do not link to libmraa (although maybe that would be a good
|
||||
idea...)
|
||||
|
||||
Typemaps are used heavily to map uint8_t* pointers to bytearrays and
|
||||
node_buffers. These are native python & node.js types that represent uint8_t
|
||||
data the best and are very well supported in both languages. Argument
|
||||
conversions and memory allocations are performed so the performance of using
|
||||
these functions compared to the C/C++ equivalent will likely be a little lower,
|
||||
however it is much more natural than using carrays.i typemap library.
|
||||
|
||||
### NPM ###
|
||||
|
||||
mraa is published on NPM, there is a target to prebuild a mraa src tarball that
|
||||
can be built with node-gyp. The way this works is to use the mraa_LIB_SRCS
|
||||
array to generate a binding.gyp file from the skeleton binding.gyp.cmake in
|
||||
src/javascript. Because we don't expect most NPM users to have SWIG we
|
||||
precompile the src/mraajsJAVASCRIPT_wrap.cxx. The src/version.c is already
|
||||
known since this is a static tarball so we write that too. These files are
|
||||
placed not in a build/ directory but in the main mraa directory. You can then
|
||||
tar the directory up and send it to NPM. This is done automatically on every
|
||||
commit by our automated build system.
|
||||
|
58
docs/minnow_max.md
Normal file
58
docs/minnow_max.md
Normal file
@@ -0,0 +1,58 @@
|
||||
Intel(R) Minnowboard Max {#minnowmax}
|
||||
========================
|
||||
MinnowBoard MAX is an open hardware embedded board designed with the Intel(R)
|
||||
Atom(TM) E38xx series SOC (Fromerly Bay Trail).
|
||||
|
||||
For product overview and faq see
|
||||
http://www.minnowboard.org/faq-minnowboard-max/
|
||||
|
||||
For technical details see http://www.elinux.org/Minnowboard:MinnowMax
|
||||
|
||||
Supported Firmware
|
||||
------------------
|
||||
mraa has only been tested with 64 bit firmware version 0.73 or later.
|
||||
|
||||
SPI
|
||||
---
|
||||
For SPI support you need to load the low_speed_spidev kernel module and that
|
||||
will create the /dev/spidev0.0 device node. Mraa only knows about this one SPI
|
||||
bus and no other.
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
The low speed I/O connector supported as per table below. This assumes default
|
||||
BIOS settings, as they are not dynamcially detected If any changes are mode
|
||||
(Device Manager -> System Setup -> South Cluster -> LPSS & CSS) them mraa calls
|
||||
will not behave as expected.
|
||||
|
||||
Documentation shows i2c on bus #5, ACPI shows it on bus #6, but driver uses
|
||||
bus #7.
|
||||
|
||||
| MRAA Number | Physical Pin | Function | Sysfs GPIO | Notes |
|
||||
|-------------|---------------|------------|------------|----------------------|
|
||||
| 1 | 1 | GND | | |
|
||||
| 2 | 2 | GND | | |
|
||||
| 3 | 3 | 5v | | |
|
||||
| 4 | 4 | 3.3v | | |
|
||||
| 5 | 5 | SPI_CS | 220 | SPI (via low_speed) |
|
||||
| 6 | 6 | UART1_TXD | 225 | UART1 |
|
||||
| 7 | 7 | SPI_MISO | 221 | SPI (via low_speed) |
|
||||
| 8 | 8 | UART1_RXD | 224 | UART1 |
|
||||
| 9 | 9 | SPI_MOSI | 222 | SPI (via low_speed) |
|
||||
| 10 | 10 | UART1_CTS | 227 | GPIO |
|
||||
| 11 | 11 | SPI_CLK | 223 | SPI (via low_speed) |
|
||||
| 12 | 12 | UART1_RTS | 226 | GPIO |
|
||||
| 13 | 13 | I2C_SCL | 243 | /dev/i2c-7 |
|
||||
| 14 | 14 | I2S_CLK | 216 | GPIO |
|
||||
| 15 | 15 | I2C_SDA | 242 | /dev/i2c-7 |
|
||||
| 16 | 16 | I2S_FRM | 217 | GPIO |
|
||||
| 17 | 17 | UART2_TXD | 229 | UART2 |
|
||||
| 18 | 18 | I2S_DO | 219 | GPIO |
|
||||
| 19 | 19 | UART2_RXD | 228 | UART2 |
|
||||
| 20 | 20 | I2S_DI | 218 | GPIO |
|
||||
| 21 | 21 | GPIO_S5_0 | 82 | GPIO |
|
||||
| 22 | 22 | PWM0 | 248 | PWM Chip 0 Channel 0 |
|
||||
| 23 | 23 | GPIO_S5_1 | 83 | GPIO |
|
||||
| 24 | 24 | PWM1 | 249 | PWM Chip 1 Channel 0 |
|
||||
| 25 | 25 | S5_4 | 84 | GPIO |
|
||||
| 26 | 26 | IBL_8254 | 208 | GPIO |
|
49
docs/npm.md
Normal file
49
docs/npm.md
Normal file
@@ -0,0 +1,49 @@
|
||||
mraa NPM pkg {#npmpkg}
|
||||
============
|
||||
|
||||
What you are looking at is a tarball made after 'make npmpkg' has been run on
|
||||
our build system. It contains a few prebuilt files in order to build easily
|
||||
with node-gyp on most systems. Note that this is not the preffered way of
|
||||
building libmraa and if you'd like to contribute, please learn how the build
|
||||
system works and get your sources from git.
|
||||
|
||||
Any patches for mraajsJAVASCRIPT_wrap.cxx or version.c will be ignored as these
|
||||
are automatically generated files. When you execute a build from node-gyp/npm
|
||||
you do not generate the mraajsJAVASCRIPT_wrap.cxx file but rather use one that
|
||||
we have generated for you.
|
||||
|
||||
Recreating tarball
|
||||
------------------
|
||||
|
||||
You can run the following commands to 'generate' this tarball from a checkout
|
||||
of mraa. It's important to not leave a .git directory as npm will then
|
||||
consider the tarball contains a full git tree. You also you need a top level
|
||||
dir which matches the npm pkg name so we create one with a symlink and add the
|
||||
'h' flag to tar to follow symlinks.
|
||||
|
||||
~~~~~~~~~~~~~{.sh}
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILDSWIGNODE=ON ..
|
||||
make npmpkg
|
||||
ln -s ../ mraa
|
||||
tar hczv --exclude='build*' --exclude='.gitignore' --exclude='.git' --exclude='build*/*' --exclude='.git/*' -f mraa.tar.gz mraa
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
Building with node-gyp
|
||||
----------------------
|
||||
|
||||
You can build with node-gyp using the binding.gyp file, obviously this requires
|
||||
either the prebuilt tarball from npm or to do the above to generate it with the
|
||||
npmpkg target. Note the --target='' flag will not work since binding.gyp will
|
||||
do a check for the running node v8 version, you'll also need to run that
|
||||
version (or close to) in your $PATH.
|
||||
|
||||
~~~~~~~~~~~{.sh}
|
||||
node-gyp configure --python=/usr/bin/python2
|
||||
node-gyp build --python=/usr/bin/python2 --verbose
|
||||
~~~~~~~~~~~
|
||||
|
||||
Note that no cross compilation is available without modifying the --arch flag
|
||||
manually. If you want to cross compile, it's recommended to use cmake.
|
||||
|
@@ -1,16 +1,25 @@
|
||||
Hooks can be defined per supported platform to allow for highly custom operations if needed.
|
||||
This feature of MRAA should only be used by developers defining the board definitions, NOT an end user.
|
||||
platform-hooks {#hooks}
|
||||
==============
|
||||
|
||||
Hooks can be defined per supported platform to allow for highly custom
|
||||
operations if needed. This feature of MRAA should only be used by developers
|
||||
defining the board definitions, NOT an end user.
|
||||
|
||||
##Types of Hooks
|
||||
|
||||
###REPLACE
|
||||
Defining a replace function will entirely replace the associate function. This should only be done if your new function can handle everything the mraa function would normally.
|
||||
Defining a replace function will entirely replace the associate function. This
|
||||
should only be done if your new function can handle everything the mraa
|
||||
function would normally.
|
||||
|
||||
###PRE
|
||||
Any functionality defined here will be performed when the main function is called.
|
||||
Any functionality defined here will be performed when the main function is
|
||||
called.
|
||||
|
||||
###POST
|
||||
Any functionality perfomed here is done just before the normal function returns. All post functions will have passed into them the return value that would normally be returned.
|
||||
Any functionality perfomed here is done just before the normal function
|
||||
returns. All post functions will have passed into them the return value that
|
||||
would normally be returned.
|
||||
|
||||
##Hooks
|
||||
### GPIO
|
||||
|
100
docs/raspberry_pi.md
Normal file
100
docs/raspberry_pi.md
Normal file
@@ -0,0 +1,100 @@
|
||||
Raspberry Pi {#rasppi}
|
||||
============
|
||||
|
||||
The Raspberry Pi is based on the Broadcom BCM2835 system on a chip, which
|
||||
includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU and was originally
|
||||
shipped with 256 megabytes of RAM, later upgraded (Model B & Model B+) to 512
|
||||
MB. The Raspberry Pi 2 is based on an armv7 CPU but shares a number of
|
||||
similarities with the original.
|
||||
|
||||
Revision Support
|
||||
----------------
|
||||
Raspberry Pi A/B/A+/B+
|
||||
Raspberry Pi 2 B
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**PWM** Whilst the Raspberry Pi is meant to have 1 PWM channel this is currently not supported.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
This pin mapping refers to the first generation 'B' model Pi but gives an idea
|
||||
as to what the values are from mraa. Note that there is an emum to use wiringPi
|
||||
style numbers.
|
||||
|
||||
| MRAA Number | Physical Pin | Function |
|
||||
|-------------|--------------|----------|
|
||||
| 1 | P1-01 | 3V3 VCC |
|
||||
| 2 | P1-02 | 5V VCC |
|
||||
| 3 | P1-03 | I2C SDA |
|
||||
| 4 | P1-04 | 5V VCC |
|
||||
| 5 | P1-05 | I2C SCL |
|
||||
| 6 | P1-06 | GND |
|
||||
| 7 | P1-07 | GPIO(4) |
|
||||
| 8 | P1-08 | UART TX |
|
||||
| 9 | P1-09 | GND |
|
||||
| 10 | P1-10 | UART RX |
|
||||
| 11 | P1-11 | GPIO(17) |
|
||||
| 12 | P1-12 | GPIO(18) |
|
||||
| 13 | P1-13 | GPIO(21) |
|
||||
| 14 | P1-14 | GND |
|
||||
| 15 | P1-15 | GPIO(22) |
|
||||
| 16 | P1-16 | GPIO(23) |
|
||||
| 17 | P1-17 | 3V3 VCC |
|
||||
| 18 | P1-18 | GPIO(24) |
|
||||
| 19 | P1-19 | SPI MOSI |
|
||||
| 20 | P1-20 | GND |
|
||||
| 21 | P1-21 | SPI MISO |
|
||||
| 22 | P1-22 | GPIO(25) |
|
||||
| 23 | P1-23 | SPI SCL |
|
||||
| 24 | P1-24 | SPI CS0 |
|
||||
| 25 | P1-25 | GND |
|
||||
| 26 | P1-26 | SPI CS1 |
|
||||
|
||||
|
||||
The following pin mapping applies to the new Raspberry Pi model 2 and B+. Note that GPIO(21) is now GPIO(27)
|
||||
|
||||
| MRAA Number | Physical Pin | Function |
|
||||
|-------------|--------------|----------|
|
||||
| 1 | P1-01 | 3V3 VCC |
|
||||
| 2 | P1-02 | 5V VCC |
|
||||
| 3 | P1-03 | I2C SDA |
|
||||
| 4 | P1-04 | 5V VCC |
|
||||
| 5 | P1-05 | I2C SCL |
|
||||
| 6 | P1-06 | GND |
|
||||
| 7 | P1-07 | GPIO(4) |
|
||||
| 8 | P1-08 | UART TX |
|
||||
| 9 | P1-09 | GND |
|
||||
| 10 | P1-10 | UART RX |
|
||||
| 11 | P1-11 | GPIO(17) |
|
||||
| 12 | P1-12 | GPIO(18) |
|
||||
| 13 | P1-13 | GPIO(27) |
|
||||
| 14 | P1-14 | GND |
|
||||
| 15 | P1-15 | GPIO(22) |
|
||||
| 16 | P1-16 | GPIO(23) |
|
||||
| 17 | P1-17 | 3V3 VCC |
|
||||
| 18 | P1-18 | GPIO(24) |
|
||||
| 19 | P1-19 | SPI MOSI |
|
||||
| 20 | P1-20 | GND |
|
||||
| 21 | P1-21 | SPI MISO |
|
||||
| 22 | P1-22 | GPIO(25) |
|
||||
| 23 | P1-23 | SPI SCL |
|
||||
| 24 | P1-24 | SPI CS0 |
|
||||
| 25 | P1-25 | GND |
|
||||
| 26 | P1-26 | SPI CS1 |
|
||||
| 27 | P1-27 | I2C SDA1 |
|
||||
| 28 | P1-28 | I2C SCL1 |
|
||||
| 29 | P1-29 | GPIO(5) |
|
||||
| 30 | P1-30 | GND |
|
||||
| 31 | P1-31 | GPIO(6) |
|
||||
| 32 | P1-32 | GPIO(12) |
|
||||
| 33 | P1-33 | GPIO(13) |
|
||||
| 34 | P1-34 | GND |
|
||||
| 35 | P1-35 | SPI MISO1|
|
||||
| 36 | P1-36 | GPIO(16) |
|
||||
| 37 | P1-37 | GPIO(26) |
|
||||
| 38 | P1-38 | SPI MOSI1|
|
||||
| 39 | P1-39 | GND |
|
||||
| 40 | P1-40 | SPI SCL1 |
|
42
docs/testing.md
Normal file
42
docs/testing.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# Testing mraa
|
||||
|
||||
Mraa has a test suite written in python which can be run by users to check
|
||||
their platform is working correctly. The aim is to have a full API coverage
|
||||
using python scripts using unittests. Currently the test suite is far from
|
||||
complete.
|
||||
|
||||
## Supported platforms
|
||||
|
||||
Intel Galileo v1 was used and is currently the only supported platform. Tests
|
||||
were conducted on Intel Galileo v2, but because of hardware differences, some
|
||||
failures may occur. Logic will be added to auto-select board to work on. To
|
||||
start with boards with an arduino type shield/layout should work
|
||||
|
||||
## How to run these tests
|
||||
|
||||
You need to compile from source with -DBUILDSWIGPYTHON=ON and then tests can be
|
||||
executed with:
|
||||
$ make test
|
||||
|
||||
More detail can be seen by running:
|
||||
$ ctest -VV
|
||||
|
||||
Note tests will not run on platforms which cannot initialise, checking the
|
||||
amount of 'skipped' tests can be useful
|
||||
|
||||
## What's next?
|
||||
|
||||
At this point tests were made to do a quick sanity check. In the future the
|
||||
followings will be implemented:
|
||||
* Create a physical layer that will emulate sensors behavior and generate I/O
|
||||
signals. This layer will be available to the community and will help replace
|
||||
the need of specific sensors. The simplest solution will be chosen allowing
|
||||
anyone to rapidly implement it.
|
||||
* Implement stress tests over long periods of time. This feature alone is
|
||||
possible only with the use of a physical layer since it will behave both as
|
||||
signals generator and interpreter.
|
||||
* Analyze a tests result collection solution (and after, interpretation). This
|
||||
is useful since tests mean nothing without a history and possibility to
|
||||
check on results.
|
||||
* Any idea welcome!
|
||||
|
84
docs/up.md
Normal file
84
docs/up.md
Normal file
@@ -0,0 +1,84 @@
|
||||
UP Board {#up}
|
||||
============
|
||||
|
||||
UP Board is based on the Intel(R) Atom(TM) x5-Z83xx SoC (formerly Cherry Trail).
|
||||
It includes 2GB RAM, 16/32GB eMMC flash, 6 USB2.0 ports, 1 USB 3.0 OTG port,
|
||||
1 Gigabit Ethernet, HDMI and DSI Graphics ports, RTC and a 40-pin I/O header.
|
||||
The form-factor for the board is based on the Raspberry Pi 2, and can be used
|
||||
with many of the add-on HAT boards designed for the Raspberry Pi 2.
|
||||
|
||||
Interface notes
|
||||
---------------
|
||||
|
||||
**PWM** PWM frequency range is from 293 Hz to 6.4 MHz. 8-bit resolution is
|
||||
supported for duty-cycle adjustments, but this reduces for frequencies > 97.6kHz
|
||||
|
||||
**I2C** 2 I2C channels support standard-mode (100kHz) and fast-mode (400kHz).
|
||||
Bus frequency can be selected in BIOS settings. Note that, unlike Raspberry Pi,
|
||||
the I2C controller issues Repeated-START commands for combined transactions
|
||||
(e.g. a write-then-read transaction) which may not be supported by some I2C
|
||||
slave devices. For such devices, it is advisable to use separate write and
|
||||
read transactions to ensure that Repeated-STARTs are not issued.
|
||||
|
||||
**SPI** Bus frequencies up to 25MHz are supported, in steps which are less
|
||||
granular at higher speeds. E.g. Available speeds include:
|
||||
25MHz, 12.5MHz, 8.33MHz, 6.25MHz, 5MHz, 4.167MHz, 3.571MHz, 3.125MHz, etc.
|
||||
Please be aware that speeds in between those steps will be rounded UP to the
|
||||
next nearest available speed, and capped at 25MHz.
|
||||
At the time of writing, only a single native chip-select is available (SPI CS0).
|
||||
|
||||
**UART** 2 high-speed UARTs are available, supporting baud rates up to
|
||||
support baud rates between 300 and 3686400. Hardware flow-control signals are
|
||||
not exposed, so software flow-control may be needed for rates above 115200.
|
||||
A console UART is also available but is not fully supported at this time.
|
||||
|
||||
Pin Mapping
|
||||
-----------
|
||||
|
||||
The GPIO numbering in the following pin mapping is based on the Raspberry Pi
|
||||
model 2 and B+ numbering scheme.
|
||||
|
||||
Note that there is an enum to use wiringPi style numbers.
|
||||
|
||||
| MRAA Number | Physical Pin | Function | Sysfs GPIO | Notes |
|
||||
|-------------|--------------|----------|------------|----------------------|
|
||||
| 1 | P1-01 | 3V3 VCC | | |
|
||||
| 2 | P1-02 | 5V VCC | | |
|
||||
| 3 | P1-03 | I2C SDA1 | 2 | I2C1 (/dev/i2c-1) |
|
||||
| 4 | P1-04 | 5V VCC | | |
|
||||
| 5 | P1-05 | I2C SCL1 | 3 | I2C1 (/dev/i2c-1) |
|
||||
| 6 | P1-06 | GND | | |
|
||||
| 7 | P1-07 | GPIO(4) | 4 | |
|
||||
| 8 | P1-08 | UART TX1 | 14 | UART1 (/dev/ttyS1) |
|
||||
| 9 | P1-09 | GND | | |
|
||||
| 10 | P1-10 | UART RX1 | 15 | UART1 (/dev/ttyS1) |
|
||||
| 11 | P1-11 | GPIO(17) | 17 | |
|
||||
| 12 | P1-12 | I2S CLK | 18 | I2S0 (PCM Audio) |
|
||||
| 13 | P1-13 | UART RX2 | 27 | UART2 (/dev/ttyS2) |
|
||||
| 14 | P1-14 | GND | | |
|
||||
| 15 | P1-15 | GPIO(22) | 22 | |
|
||||
| 16 | P1-16 | GPIO(23) | 23 | |
|
||||
| 17 | P1-17 | 3V3 VCC | | |
|
||||
| 18 | P1-18 | GPIO(24) | 24 | |
|
||||
| 19 | P1-19 | SPI MOSI | 10 | SPI2 (/dev/spidev2.x)|
|
||||
| 20 | P1-20 | GND | | |
|
||||
| 21 | P1-21 | SPI MISO | 9 | SPI2 (/dev/spidev2.x)|
|
||||
| 22 | P1-22 | UART TX2 | 25 | UART2 (/dev/ttyS2) |
|
||||
| 23 | P1-23 | SPI SCL | 11 | SPI2 (/dev/spidev2.x)|
|
||||
| 24 | P1-24 | SPI CS0 | 8 | SPI2 (/dev/spidev2.0)|
|
||||
| 25 | P1-25 | GND | | |
|
||||
| 26 | P1-26 | SPI CS1 | 7 | SPI2 (/dev/spidev2.1)|
|
||||
| 27 | P1-27 | I2C SDA0 | 0 | I2C0 (/dev/i2c-0) |
|
||||
| 28 | P1-28 | I2C SCL0 | 1 | I2C0 (/dev/i2c-0) |
|
||||
| 29 | P1-29 | GPIO(5) | 5 | |
|
||||
| 30 | P1-30 | GND | | |
|
||||
| 31 | P1-31 | GPIO(6) | 6 | |
|
||||
| 32 | P1-32 | PWM0 | 12 | PWM Chip 0 Channel 0 |
|
||||
| 33 | P1-33 | PWM1 | 13 | PWM Chip 1 Channel 0 |
|
||||
| 34 | P1-34 | GND | | |
|
||||
| 35 | P1-35 | I2S FRM | 19 | I2S0 (PCM Audio) |
|
||||
| 36 | P1-36 | GPIO(16) | 16 | |
|
||||
| 37 | P1-37 | GPIO(26) | 26 | |
|
||||
| 38 | P1-38 | I2S DIN | 20 | I2S0 (PCM Audio) |
|
||||
| 39 | P1-39 | GND | | |
|
||||
| 40 | P1-40 | I2S DOUT | 21 | I2S0 (PCM Audio) |
|
1
doxygen2jsdoc
Submodule
1
doxygen2jsdoc
Submodule
Submodule doxygen2jsdoc added at 9cc90b7976
@@ -8,9 +8,16 @@ add_executable (gpio_read6 gpio_read6.c)
|
||||
add_executable (spi_mcp4261 spi_mcp4261.c)
|
||||
add_executable (mmap-io2 mmap-io2.c)
|
||||
add_executable (blink_onboard blink_onboard.c)
|
||||
add_executable (uart_setup uart_setup.c)
|
||||
add_executable (uart uart.c)
|
||||
add_executable (mraa-gpio mraa-gpio.c)
|
||||
add_executable (mraa-i2c mraa-i2c.c)
|
||||
add_executable (spi_max7219 spi_max7219.c)
|
||||
add_executable (iio_driver iio_driver.c)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
# FIXME Hack to access mraa internal types used by mraa-i2c
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api/mraa)
|
||||
|
||||
target_link_libraries (hellomraa mraa)
|
||||
target_link_libraries (i2c_HMC5883L mraa m)
|
||||
@@ -22,8 +29,28 @@ target_link_libraries (gpio_read6 mraa)
|
||||
target_link_libraries (spi_mcp4261 mraa)
|
||||
target_link_libraries (mmap-io2 mraa)
|
||||
target_link_libraries (blink_onboard mraa)
|
||||
target_link_libraries (uart_setup mraa)
|
||||
target_link_libraries (uart mraa)
|
||||
target_link_libraries (mraa-gpio mraa)
|
||||
target_link_libraries (mraa-i2c mraa)
|
||||
target_link_libraries (spi_max7219 mraa)
|
||||
target_link_libraries (iio_driver mraa)
|
||||
|
||||
if (FIRMATA)
|
||||
add_executable (firmata_curie_imu firmata_curie_imu.c)
|
||||
add_executable (i2c_firmata i2c_firmata.c)
|
||||
target_link_libraries (firmata_curie_imu mraa)
|
||||
target_link_libraries (i2c_firmata mraa)
|
||||
endif ()
|
||||
|
||||
add_subdirectory (c++)
|
||||
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION share/mraa/examples)
|
||||
install (DIRECTORY ${PROJECT_SOURCE_DIR}/examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/mraa/examples)
|
||||
|
||||
if (INSTALLGPIOTOOL AND NOT INSTALLTOOLS)
|
||||
install (TARGETS mraa-gpio DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if (INSTALLTOOLS)
|
||||
install (TARGETS mraa-gpio DESTINATION bin)
|
||||
install (TARGETS mraa-i2c DESTINATION bin)
|
||||
endif()
|
||||
|
@@ -26,19 +26,23 @@
|
||||
//! [Interesting]
|
||||
#include "mraa/aio.h"
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_aio_context adc_a0;
|
||||
uint16_t adc_value = 0;
|
||||
float adc_value_float = 0.0;
|
||||
|
||||
adc_a0 = mraa_aio_init(0);
|
||||
if (adc_a0 == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
adc_value = mraa_aio_read(adc_a0);
|
||||
adc_value_float = mraa_aio_read_float(adc_a0);
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
|
||||
}
|
||||
|
||||
mraa_aio_close(adc_a0);
|
||||
|
@@ -45,7 +45,7 @@ sig_handler(int signo)
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t r = MRAA_SUCCESS;
|
||||
iopin = DEFAULT_IOPIN;
|
||||
@@ -57,14 +57,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mraa_init();
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n",
|
||||
mraa_get_version(), iopin);
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Blinking on IO%d\n", mraa_get_version(), iopin);
|
||||
|
||||
mraa_gpio_context gpio;
|
||||
gpio = mraa_gpio_init(iopin);
|
||||
if (gpio == NULL) {
|
||||
fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", iopin);
|
||||
exit(1);
|
||||
exit(1);
|
||||
}
|
||||
printf("Initialised pin%d\n", iopin);
|
||||
|
||||
|
@@ -29,29 +29,51 @@
|
||||
#include "mraa/gpio.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_platform_t platform = mraa_get_platform_type();
|
||||
mraa_gpio_context gpio;
|
||||
char board_name[] = "Some weird devboard that isn't recognised...";
|
||||
mraa_gpio_context gpio, gpio_in = NULL;
|
||||
const char* board_name = mraa_get_platform_name();
|
||||
int ledstate = 0;
|
||||
|
||||
switch (platform) {
|
||||
case MRAA_INTEL_GALILEO_GEN1:
|
||||
strcpy(board_name, "Intel Galileo Gen1");
|
||||
gpio = mraa_gpio_init_raw(3);
|
||||
break;
|
||||
case MRAA_INTEL_GALILEO_GEN2:
|
||||
strcpy(board_name, "Intel Galileo Gen2");
|
||||
case MRAA_INTEL_MINNOWBOARD_MAX:
|
||||
// there is no onboard LED that we can flash on the minnowboard max
|
||||
// but on the calamari lure pin 21 is an LED. If you don't have the
|
||||
// lure put an LED on pin 21
|
||||
gpio = mraa_gpio_init(21);
|
||||
break;
|
||||
default:
|
||||
gpio = mraa_gpio_init(13);
|
||||
}
|
||||
|
||||
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n",
|
||||
mraa_get_version(), board_name);
|
||||
fprintf(stdout, "Welcome to libmraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
|
||||
|
||||
|
||||
if (gpio == NULL) {
|
||||
fprintf(stdout, "Could not initilaize gpio\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// on platforms with physical button use gpio_in
|
||||
if (platform == MRAA_INTEL_MINNOWBOARD_MAX) {
|
||||
gpio_in = mraa_gpio_init(14);
|
||||
if (gpio_in != NULL) {
|
||||
mraa_gpio_dir(gpio_in, MRAA_GPIO_IN);
|
||||
// S1 on minnowboardmax's calamari lure maps to pin 14, SW1 != S1
|
||||
fprintf(stdout, "Press and hold S1 to stop, Press SW1 to shutdown!\n");
|
||||
}
|
||||
}
|
||||
|
||||
mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
|
||||
|
||||
for (;;) {
|
||||
if (gpio_in != NULL && mraa_gpio_read(gpio_in) == 0) {
|
||||
return 0;
|
||||
}
|
||||
ledstate = !ledstate;
|
||||
mraa_gpio_write(gpio, !ledstate);
|
||||
sleep(1);
|
||||
|
@@ -25,9 +25,11 @@
|
||||
//! [Interesting]
|
||||
#include "mraa.hpp"
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
uint16_t adc_value;
|
||||
float adc_value_float;
|
||||
mraa::Aio* a0;
|
||||
|
||||
a0 = new mraa::Aio(0);
|
||||
@@ -35,9 +37,11 @@ int main ()
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
adc_value = a0->read();
|
||||
adc_value_float = a0->readFloat();
|
||||
fprintf(stdout, "ADC A0 read %X - %d\n", adc_value, adc_value);
|
||||
fprintf(stdout, "ADC A0 read float - %.5f\n", adc_value_float);
|
||||
}
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
@@ -43,7 +42,8 @@ sig_handler(int signo)
|
||||
running = -1;
|
||||
}
|
||||
}
|
||||
int main (int argc, char **argv)
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("Provide an int arg if you want to flash on something other than %d\n", DEFAULT_IOPIN);
|
||||
@@ -54,13 +54,13 @@ int main (int argc, char **argv)
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa::Gpio* gpio = new mraa::Gpio(iopin);
|
||||
if (gpio == NULL) {
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
return mraa::ERROR_UNSPECIFIED;
|
||||
}
|
||||
mraa_result_t response = gpio->dir(mraa::DIR_OUT);
|
||||
if (response != MRAA_SUCCESS) {
|
||||
mraa::Result response = gpio->dir(mraa::DIR_OUT);
|
||||
if (response != mraa::SUCCESS) {
|
||||
mraa::printError(response);
|
||||
return 1;
|
||||
}
|
||||
@@ -73,5 +73,5 @@ int main (int argc, char **argv)
|
||||
}
|
||||
delete gpio;
|
||||
return response;
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
}
|
||||
|
@@ -1,8 +1,13 @@
|
||||
enable_language(CXX)
|
||||
|
||||
add_executable (AioA0 AioA0.cpp)
|
||||
add_executable (blink-io-cpp Blink-IO.cpp)
|
||||
add_executable (Pwm3-cycle Pwm3-cycle.cpp)
|
||||
add_executable (I2c-compass I2c-compass.cpp)
|
||||
add_executable (Spi-pot Spi-pot.cpp)
|
||||
add_executable (Uart Uart-example.cpp)
|
||||
add_executable (Isr-pin6 Isr-pin6.cpp)
|
||||
add_executable (Iio-dummy Iio-dummy.cpp)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api)
|
||||
|
||||
@@ -11,3 +16,6 @@ target_link_libraries (blink-io-cpp mraa stdc++)
|
||||
target_link_libraries (Pwm3-cycle mraa stdc++)
|
||||
target_link_libraries (I2c-compass mraa stdc++ m)
|
||||
target_link_libraries (Spi-pot mraa stdc++)
|
||||
target_link_libraries (Uart mraa stdc++)
|
||||
target_link_libraries (Isr-pin6 mraa stdc++)
|
||||
target_link_libraries (Iio-dummy mraa stdc++)
|
||||
|
@@ -32,14 +32,14 @@
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
#define HMC5883L_I2C_ADDR 0x1E
|
||||
|
||||
//configuration registers
|
||||
// configuration registers
|
||||
#define HMC5883L_CONF_REG_A 0x00
|
||||
#define HMC5883L_CONF_REG_B 0x01
|
||||
|
||||
//mode register
|
||||
// mode register
|
||||
#define HMC5883L_MODE_REG 0x02
|
||||
|
||||
//data register
|
||||
// data register
|
||||
#define HMC5883L_X_MSB_REG 0
|
||||
#define HMC5883L_X_LSB_REG 1
|
||||
#define HMC5883L_Z_MSB_REG 2
|
||||
@@ -48,10 +48,10 @@
|
||||
#define HMC5883L_Y_LSB_REG 5
|
||||
#define DATA_REG_SIZE 6
|
||||
|
||||
//status register
|
||||
// status register
|
||||
#define HMC5883L_STATUS_REG 0x09
|
||||
|
||||
//ID registers
|
||||
// ID registers
|
||||
#define HMC5883L_ID_A_REG 0x0A
|
||||
#define HMC5883L_ID_B_REG 0x0B
|
||||
#define HMC5883L_ID_C_REG 0x0C
|
||||
@@ -59,7 +59,7 @@
|
||||
#define HMC5883L_CONT_MODE 0x00
|
||||
#define HMC5883L_DATA_REG 0x03
|
||||
|
||||
//scales
|
||||
// scales
|
||||
#define GA_0_88_REG 0x00 << 5
|
||||
#define GA_1_3_REG 0x01 << 5
|
||||
#define GA_1_9_REG 0x02 << 5
|
||||
@@ -69,7 +69,7 @@
|
||||
#define GA_5_6_REG 0x06 << 5
|
||||
#define GA_8_1_REG 0x07 << 5
|
||||
|
||||
//digital resolutions
|
||||
// digital resolutions
|
||||
#define SCALE_0_73_MG 0.73
|
||||
#define SCALE_0_92_MG 0.92
|
||||
#define SCALE_1_22_MG 1.22
|
||||
@@ -91,13 +91,14 @@ sig_handler(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
float direction = 0;
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
char rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa::I2c* i2c;
|
||||
i2c = new mraa::I2c(0);
|
||||
|
||||
@@ -105,7 +106,7 @@ int main ()
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
i2c->write(rx_tx_buf, 2);
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
@@ -116,24 +117,25 @@ int main ()
|
||||
|
||||
while (running == 0) {
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->write(HMC5883L_DATA_REG);
|
||||
i2c->writeByte(HMC5883L_DATA_REG);
|
||||
|
||||
i2c->address(HMC5883L_I2C_ADDR);
|
||||
i2c->read(rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
|
||||
//scale and calculate direction
|
||||
// scale and calculate direction
|
||||
direction = atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||
|
||||
//check if the signs are reversed
|
||||
// check if the signs are reversed
|
||||
if (direction < 0)
|
||||
direction += 2 * M_PI;
|
||||
|
||||
printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG, z * SCALE_0_92_MG) ;
|
||||
printf("Heading : %f\n", direction * 180/M_PI);
|
||||
printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
|
||||
z * SCALE_0_92_MG);
|
||||
printf("Heading : %f\n", direction * 180 / M_PI);
|
||||
sleep(1);
|
||||
}
|
||||
delete i2c;
|
||||
|
157
examples/c++/Iio-dummy.cpp
Normal file
157
examples/c++/Iio-dummy.cpp
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Author: Henry Bruce
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include "mraa/iio.hpp"
|
||||
|
||||
#define EXPECT_FAILURE 0
|
||||
#define EXPECT_SUCCESS 1
|
||||
|
||||
#define IIO_TRY(func) \
|
||||
{ \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func; \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, "", true, success); \
|
||||
}
|
||||
|
||||
// Macro to run IIO method on attribute and log output
|
||||
#define IIO_RUN(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = true; \
|
||||
try { \
|
||||
iio_device->func(attr_name, value); \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
|
||||
// Macro to run IIO method on attribute and check for expected result and log output
|
||||
#define IIO_TEST(func, attr, value, expect) \
|
||||
{ \
|
||||
std::string attr_name = attr; \
|
||||
bool success = false; \
|
||||
try { \
|
||||
success = fabs(iio_device->func(attr_name) - value) < FLT_EPSILON; \
|
||||
} catch (std::exception& e) { \
|
||||
success = false; \
|
||||
} \
|
||||
log_result(#func, attr_name, expect, success); \
|
||||
}
|
||||
|
||||
mraa::Iio* iio_device;
|
||||
int eventCount = 0;
|
||||
|
||||
// Log result of test. Note a "fail" (i.e. success is false) will be displayed as a pass if a fail was expected
|
||||
void log_result(std::string test_name, std::string attr_name, bool expect_success, bool success)
|
||||
{
|
||||
std::string result;
|
||||
if (expect_success)
|
||||
result = success ? "PASS" : "FAIL";
|
||||
else
|
||||
result = success ? "FAIL" : "PASS";
|
||||
if (attr_name.empty())
|
||||
fprintf(stdout, "%s: %s\n", test_name.c_str(), result.c_str());
|
||||
else
|
||||
fprintf(stdout, "%s(%s): %s\n", test_name.c_str(), attr_name.c_str(), result.c_str());
|
||||
}
|
||||
|
||||
// Generate iio_dummy driver event by writing a string to a specific sysfs node
|
||||
bool generate_event()
|
||||
{
|
||||
FILE *fp = fopen("/sys/bus/iio/devices/iio_evgen/poke_ev0", "w");
|
||||
if (fp == NULL)
|
||||
return false;
|
||||
fprintf(fp, "1\n");
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// IIO event handler that checks for event from dummy_iio_evgen driver
|
||||
class IioTestHandler : public mraa::IioHandler
|
||||
{
|
||||
protected:
|
||||
void onIioEvent(const mraa::IioEventData& eventData) {
|
||||
if (eventData.channelType == IIO_VOLTAGE && eventData.direction == IIO_EV_DIR_RISING && eventData.type == IIO_EV_TYPE_THRESH)
|
||||
eventCount++;
|
||||
}
|
||||
};
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
IioTestHandler testHandler;
|
||||
std::string deviceName;
|
||||
try {
|
||||
mraa::Iio* iio_device0 = new mraa::Iio(0);
|
||||
std::cout << "IIO device 0 found by id." << std::endl;
|
||||
deviceName = iio_device0->getDeviceName();
|
||||
delete iio_device0;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "IIO device 0 not found." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
try {
|
||||
mraa::Iio* iio_device1 = new mraa::Iio(1);
|
||||
delete iio_device1;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "IIO device 1 not found. This is expected behavior." << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
iio_device = new mraa::Iio(deviceName);
|
||||
std::cout << "IIO device 0 found by name." << std::endl;
|
||||
} catch (std::exception& e) {
|
||||
std::cerr << "IIO device 0 not found." << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "Using IIO device0. Name is " << iio_device->getDeviceName() << std::endl;
|
||||
IIO_RUN(writeFloat, "in_accel_x_raw", 100, EXPECT_FAILURE);
|
||||
IIO_RUN(writeFloat, "in_voltage0_scale", 100, EXPECT_FAILURE);
|
||||
IIO_RUN(writeInt, "out_voltage0_raw", 100, EXPECT_SUCCESS);
|
||||
IIO_TEST(readInt, "in_accel_x_raw", 34, EXPECT_SUCCESS);
|
||||
IIO_TEST(readFloat, "in_voltage0_scale", 0.001333, EXPECT_SUCCESS);
|
||||
IIO_RUN(writeInt, "events/in_voltage0_thresh_rising_en", 1, EXPECT_SUCCESS);
|
||||
IIO_TRY(registerEventHandler(&testHandler));
|
||||
eventCount = 0;
|
||||
generate_event();
|
||||
usleep(500000);
|
||||
log_result("eventReceived", "", (eventCount == 1), true);
|
||||
|
||||
delete iio_device;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
57
examples/c++/Isr-pin6.cpp
Normal file
57
examples/c++/Isr-pin6.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
static volatile int counter = 0;
|
||||
static volatile int oldcounter = 0;
|
||||
|
||||
void
|
||||
interrupt(void* args)
|
||||
{
|
||||
++counter;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa::Gpio* x = new mraa::Gpio(6);
|
||||
|
||||
x->dir(mraa::DIR_IN);
|
||||
|
||||
x->isr(mraa::EDGE_BOTH, &interrupt, NULL);
|
||||
|
||||
for (;;) {
|
||||
if (counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
}
|
||||
// got to relieve our poor CPU!
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -38,10 +38,11 @@ sig_handler(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa::Pwm* pwm;
|
||||
|
||||
pwm = new mraa::Pwm(3);
|
||||
@@ -49,6 +50,7 @@ int main ()
|
||||
return MRAA_ERROR_UNSPECIFIED;
|
||||
}
|
||||
fprintf(stdout, "Cycling PWM on IO3 (pwm3) \n");
|
||||
pwm->enable(true);
|
||||
|
||||
float value = 0.0f;
|
||||
while (running == 0) {
|
||||
@@ -60,7 +62,7 @@ int main ()
|
||||
}
|
||||
}
|
||||
delete pwm;
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
|
@@ -39,37 +39,42 @@ sig_handler(int signo)
|
||||
}
|
||||
}
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa::Spi* spi;
|
||||
|
||||
spi = new mraa::Spi(0);
|
||||
|
||||
char data[] = {0x00, 100};
|
||||
char *recv;
|
||||
uint8_t data[] = { 0x00, 100 };
|
||||
uint8_t rxBuf[2];
|
||||
uint8_t* recv;
|
||||
while (running == 0) {
|
||||
int i;
|
||||
for (i = 90; i < 130; i++) {
|
||||
data[1] = i;
|
||||
recv = spi->write(data, 2);
|
||||
printf("Writing -%i",i);
|
||||
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
|
||||
printf("Writing -%i", i);
|
||||
if (recv) {
|
||||
printf("RECIVED-%i-%i\n", recv[0], recv[1]);
|
||||
free(recv);
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
for (i = 130; i > 90; i--) {
|
||||
data[1] = i;
|
||||
recv = spi->write(data, 2);
|
||||
printf("Writing -%i",i);
|
||||
printf("RECIVED-%i-%i\n",recv[0],recv[1]);
|
||||
if (spi->transfer(data, rxBuf, 2) == mraa::SUCCESS) {
|
||||
printf("Writing -%i", i);
|
||||
printf("RECIVED-%i-%i\n", rxBuf[0], rxBuf[1]);
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
}
|
||||
delete spi;
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
return MRAA_SUCCESS;
|
||||
return mraa::SUCCESS;
|
||||
}
|
||||
|
70
examples/c++/Uart-example.cpp
Normal file
70
examples/c++/Uart-example.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include "mraa.hpp"
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
// If you have a valid platform configuration use numbers to represent uart
|
||||
// device. If not use raw mode where std::string is taken as a constructor
|
||||
// parameter
|
||||
mraa::Uart* dev;
|
||||
try {
|
||||
dev = new mraa::Uart(0);
|
||||
} catch (std::exception& e) {
|
||||
std::cout << e.what() << ", likely invalid platform config" << std::endl;
|
||||
}
|
||||
|
||||
try {
|
||||
dev = new mraa::Uart("/dev/ttyACM0");
|
||||
} catch (std::exception& e) {
|
||||
std::cout << "Error while setting up raw UART, do you have a uart?" << std::endl;
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
if (dev->setBaudRate(115200) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting parity on UART" << std::endl;
|
||||
}
|
||||
|
||||
if (dev->setMode(8, mraa::UART_PARITY_NONE, 1) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting parity on UART" << std::endl;
|
||||
}
|
||||
|
||||
if (dev->setFlowcontrol(false, false) != mraa::SUCCESS) {
|
||||
std::cout << "Error setting flow control UART" << std::endl;
|
||||
}
|
||||
|
||||
dev->writeStr("Hello monkeys");
|
||||
//! [Interesting]
|
||||
|
||||
delete dev;
|
||||
|
||||
return mraa::SUCCESS;
|
||||
}
|
@@ -27,10 +27,10 @@
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main ()
|
||||
main()
|
||||
{
|
||||
mraa_init();
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa_pwm_context pwm;
|
||||
pwm = mraa_pwm_init(3);
|
||||
if (pwm == NULL) {
|
||||
@@ -50,6 +50,6 @@ main ()
|
||||
}
|
||||
float output = mraa_pwm_read(pwm);
|
||||
}
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
return 0;
|
||||
}
|
||||
|
92
examples/firmata_curie_imu.c
Normal file
92
examples/firmata_curie_imu.c
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mraa.h"
|
||||
#include "mraa/firmata.h"
|
||||
|
||||
#define FIRMATA_START_SYSEX 0xF0
|
||||
#define FIRMATA_END_SYSEX 0xF7
|
||||
#define FIRMATA_CURIE_IMU 0x11
|
||||
#define FIRMATA_CURIE_IMU_READ_ACCEL 0x00
|
||||
|
||||
void
|
||||
interrupt(uint8_t* buf, int length)
|
||||
{
|
||||
printf("reg read returned: %d, with buffer size %d\n", ((buf[6] & 0x7f) | ((buf[7] & 0x7f) << 7)), length);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_init();
|
||||
//! [Interesting]
|
||||
|
||||
/**
|
||||
* This example reads from the FirmataCurieIMU plugin
|
||||
*/
|
||||
|
||||
mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
|
||||
mraa_firmata_context firm = mraa_firmata_init(FIRMATA_CURIE_IMU);
|
||||
if (firm == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
mraa_firmata_response(firm, interrupt);
|
||||
|
||||
uint8_t* buffer = calloc(4, 0);
|
||||
if (buffer == NULL) {
|
||||
free(firm);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
buffer[0] = FIRMATA_START_SYSEX;
|
||||
buffer[1] = FIRMATA_CURIE_IMU;
|
||||
buffer[2] = FIRMATA_CURIE_IMU_READ_ACCEL;
|
||||
buffer[3] = FIRMATA_END_SYSEX;
|
||||
|
||||
mraa_firmata_write_sysex(firm, buffer, 4);
|
||||
|
||||
sleep(1);
|
||||
|
||||
// stop the isr and set it again
|
||||
mraa_firmata_response_stop(firm);
|
||||
mraa_firmata_response(firm, interrupt);
|
||||
mraa_firmata_write_sysex(firm, buffer, 4);
|
||||
|
||||
sleep(1);
|
||||
|
||||
// close everything and try again
|
||||
mraa_firmata_close(firm);
|
||||
firm = mraa_firmata_init(FIRMATA_CURIE_IMU);
|
||||
mraa_firmata_response(firm, interrupt);
|
||||
mraa_firmata_write_sysex(firm, buffer, 4);
|
||||
|
||||
sleep(10);
|
||||
|
||||
mraa_firmata_close(firm);
|
||||
//! [Interesting]
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@@ -28,13 +28,12 @@
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_init();
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n",
|
||||
mraa_get_version());
|
||||
fprintf(stdout, "MRAA Version: %s\nStarting Read on IO6\n", mraa_get_version());
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa_gpio_context gpio;
|
||||
|
||||
gpio = mraa_gpio_init(6);
|
||||
@@ -47,7 +46,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
mraa_gpio_close(gpio);
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
69
examples/helloedison.c
Normal file
69
examples/helloedison.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
//! [Interesting]
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t ret = MRAA_SUCCESS;
|
||||
mraa_platform_t platform_type = mraa_get_platform_type();
|
||||
|
||||
if (platform_type != MRAA_INTEL_EDISON_FAB_C) {
|
||||
fprintf(stderr, "Error: This program can only run on an edison\n");
|
||||
ret = MRAA_ERROR_INVALID_PLATFORM;
|
||||
goto end;
|
||||
}
|
||||
|
||||
// MRAA_INTEL_EDISON_GP182 == 0 so this will initialise pin0 on arduino
|
||||
// which is hardware gpio 130 and not 182
|
||||
mraa_gpio_context gpio182 = mraa_gpio_init(MRAA_INTEL_EDISON_GP182);
|
||||
if (gpio182 == NULL) {
|
||||
fprintf(stderr, "Error: Failed to open gpio182\n");
|
||||
ret = MRAA_ERROR_INVALID_PLATFORM;
|
||||
goto end;
|
||||
}
|
||||
mraa_gpio_dir(gpio182, MRAA_GPIO_OUT);
|
||||
|
||||
// we set the owner to false here, this makes sure that we do not close the
|
||||
// gpio from sysfs in mraa_gpio_close meaning it will stay as an output and
|
||||
// we will not always transition from 0->1 as gpio182 as output has the
|
||||
// default position of '0'. Note that the value could change as a result of
|
||||
// a mraa_gpio_dir however meaning we always go from 0->1 or 1->0
|
||||
mraa_gpio_owner(gpio182, false);
|
||||
int val = mraa_gpio_read(gpio182);
|
||||
printf("GPIO%d (mraa pin %d) was: %d, will set to %d\n", 182, mraa_gpio_get_pin(gpio182), val, !val);
|
||||
mraa_gpio_write(gpio182, !val);
|
||||
mraa_gpio_close(gpio182);
|
||||
|
||||
end:
|
||||
mraa_deinit();
|
||||
return ret;
|
||||
}
|
||||
//! [Interesting]
|
@@ -24,20 +24,18 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
//! [Interesting]
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_result_t ret;
|
||||
|
||||
ret = mraa_set_log_level(LOG_DEBUG);
|
||||
|
||||
fprintf(stdout, "hello mraa\n Version: %s\n", mraa_get_version());
|
||||
const char* board_name = mraa_get_platform_name();
|
||||
fprintf(stdout, "hello mraa\n Version: %s\n Running on %s\n", mraa_get_version(), board_name);
|
||||
|
||||
mraa_deinit();
|
||||
|
||||
return ret;
|
||||
return MRAA_SUCCESS;
|
||||
}
|
||||
//! [Interesting]
|
||||
|
@@ -28,14 +28,14 @@
|
||||
#define MAX_BUFFER_LENGTH 6
|
||||
#define HMC5883L_I2C_ADDR 0x1E
|
||||
|
||||
//configuration registers
|
||||
// configuration registers
|
||||
#define HMC5883L_CONF_REG_A 0x00
|
||||
#define HMC5883L_CONF_REG_B 0x01
|
||||
|
||||
//mode register
|
||||
// mode register
|
||||
#define HMC5883L_MODE_REG 0x02
|
||||
|
||||
//data register
|
||||
// data register
|
||||
#define HMC5883L_X_MSB_REG 0
|
||||
#define HMC5883L_X_LSB_REG 1
|
||||
#define HMC5883L_Z_MSB_REG 2
|
||||
@@ -44,10 +44,10 @@
|
||||
#define HMC5883L_Y_LSB_REG 5
|
||||
#define DATA_REG_SIZE 6
|
||||
|
||||
//status register
|
||||
// status register
|
||||
#define HMC5883L_STATUS_REG 0x09
|
||||
|
||||
//ID registers
|
||||
// ID registers
|
||||
#define HMC5883L_ID_A_REG 0x0A
|
||||
#define HMC5883L_ID_B_REG 0x0B
|
||||
#define HMC5883L_ID_C_REG 0x0C
|
||||
@@ -55,7 +55,7 @@
|
||||
#define HMC5883L_CONT_MODE 0x00
|
||||
#define HMC5883L_DATA_REG 0x03
|
||||
|
||||
//scales
|
||||
// scales
|
||||
#define GA_0_88_REG 0x00 << 5
|
||||
#define GA_1_3_REG 0x01 << 5
|
||||
#define GA_1_9_REG 0x02 << 5
|
||||
@@ -65,7 +65,7 @@
|
||||
#define GA_5_6_REG 0x06 << 5
|
||||
#define GA_8_1_REG 0x07 << 5
|
||||
|
||||
//digital resolutions
|
||||
// digital resolutions
|
||||
#define SCALE_0_73_MG 0.73
|
||||
#define SCALE_0_92_MG 0.92
|
||||
#define SCALE_1_22_MG 1.22
|
||||
@@ -76,14 +76,14 @@
|
||||
#define SCALE_4_35_MG 4.35
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_init();
|
||||
float direction = 0;
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
char rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
mraa_i2c_context i2c;
|
||||
i2c = mraa_i2c_init(0);
|
||||
|
||||
@@ -91,32 +91,46 @@ main(int argc, char **argv)
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
#if 0
|
||||
int i = 0;
|
||||
//alternative, equivalent method which helps to understand exactly what
|
||||
//the below does
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
for (i = 0; i < DATA_REG_SIZE; i++) {
|
||||
mraa_i2c_read_byte_data(i2c, HMC5883L_DATA_REG+i);
|
||||
}
|
||||
#endif
|
||||
// first 'select' the register we want to read from
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
mraa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
||||
|
||||
// then we read from that register incrementing with every read the
|
||||
// chosen register
|
||||
mraa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
// this call behaves very similarly to the Wire receive() call
|
||||
mraa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Y_LSB_REG] ;
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
|
||||
//scale and calculate direction
|
||||
// scale and calculate direction
|
||||
direction = atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||
|
||||
//check if the signs are reversed
|
||||
// check if the signs are reversed
|
||||
if (direction < 0)
|
||||
direction += 2 * M_PI;
|
||||
|
||||
printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG, z * SCALE_0_92_MG) ;
|
||||
printf("Heading : %f\n", direction * 180/M_PI) ;
|
||||
printf("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
|
||||
z * SCALE_0_92_MG);
|
||||
printf("Heading : %f\n", direction * 180 / M_PI);
|
||||
}
|
||||
}
|
||||
|
64
examples/i2c_firmata.c
Normal file
64
examples/i2c_firmata.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "mraa.h"
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
mraa_init();
|
||||
mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
|
||||
|
||||
mraa_i2c_context i2c;
|
||||
i2c = mraa_i2c_init(0 + 512);
|
||||
#if 0
|
||||
mraa_i2c_address(i2c, 0x62);
|
||||
|
||||
#if 1
|
||||
uint8_t rx_tx_buf[2];
|
||||
rx_tx_buf[0] = 0x0;
|
||||
rx_tx_buf[1] = 0x0;
|
||||
mraa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
#endif
|
||||
//mraa_i2c_write_byte_data(i2c, 0x0, 0x0);
|
||||
mraa_i2c_write_byte_data(i2c, 0x0, 0x1);
|
||||
|
||||
mraa_i2c_write_byte_data(i2c, 0xFF, 0x08);
|
||||
mraa_i2c_write_byte_data(i2c, 0x00, 0x04);
|
||||
mraa_i2c_write_byte_data(i2c, 0xA0, 0x02);
|
||||
#else
|
||||
mraa_i2c_address(i2c, 0x77);
|
||||
int res = mraa_i2c_read_byte_data(i2c, 0xd0);
|
||||
printf("res is 0x%x\n", res);
|
||||
|
||||
uint8_t data[2];
|
||||
mraa_i2c_write_byte(i2c, 0x77);
|
||||
mraa_i2c_read(i2c, data, 1);
|
||||
|
||||
res = mraa_i2c_read_word_data(i2c, 0xAA); // BMP085_CAL_AC1
|
||||
printf("res is %d\n", res);
|
||||
#endif
|
||||
sleep(10);
|
||||
|
||||
}
|
145
examples/iio_driver.c
Normal file
145
examples/iio_driver.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include "mraa/iio.h"
|
||||
|
||||
static void
|
||||
printword(uint16_t input, mraa_iio_channel* chan)
|
||||
{
|
||||
int16_t res;
|
||||
|
||||
if (!chan->lendian) {
|
||||
input = be16toh(input);
|
||||
} else {
|
||||
input = le16toh(input);
|
||||
}
|
||||
|
||||
input >>= chan->shift;
|
||||
input &= chan->mask;
|
||||
if (chan->signedd) {
|
||||
res = (int16_t)(input << (16 - chan->bits_used)) >> (16 - chan->bits_used);
|
||||
} else {
|
||||
res = input;
|
||||
}
|
||||
printf(" value = %05f\n", (float) res);
|
||||
}
|
||||
|
||||
mraa_iio_context iio_device0;
|
||||
mraa_iio_context iio_device6;
|
||||
|
||||
void
|
||||
interrupt(char* data)
|
||||
{
|
||||
mraa_iio_channel* channels = mraa_iio_get_channels(iio_device0);
|
||||
int i = 0;
|
||||
|
||||
for (i; i < mraa_iio_get_channel_count(iio_device0); i++) {
|
||||
if (channels[i].enabled) {
|
||||
printf("channel %d - bytes %d\n", channels[i].index, channels[i].bytes);
|
||||
switch (channels[i].bytes) {
|
||||
case 2:
|
||||
printword(*(uint16_t*) (data + channels[i].location), &channels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
event_interrupt(struct iio_event_data* data)
|
||||
{
|
||||
int chan_type;
|
||||
int modifier;
|
||||
int type;
|
||||
int direction;
|
||||
int channel;
|
||||
int channel2;
|
||||
int different;
|
||||
mraa_iio_event_extract_event(data, &chan_type, &modifier, &type, &direction, &channel, &channel2, &different);
|
||||
|
||||
printf("event time %lld id %lld extracted chan_type %d modifier %d type %d direction %d "
|
||||
"channel %d channel2 %d different %d\n",
|
||||
data->timestamp, data->id, chan_type, modifier, type, direction, channel, channel2, different);
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
//! [Interesting]
|
||||
iio_device0 = mraa_iio_init(0);
|
||||
if (iio_device0 == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
float iio_float;
|
||||
int iio_int;
|
||||
mraa_result_t ret;
|
||||
|
||||
ret = mraa_iio_write_float(iio_device0, "in_accel_scale", 0.019163);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO write success\n");
|
||||
}
|
||||
|
||||
ret = mraa_iio_read_float(iio_device0, "in_accel_scale", &iio_float);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO read %f\n", iio_float);
|
||||
}
|
||||
|
||||
ret = mraa_iio_write_int(iio_device0, "scan_elements/in_accel_x_en", 1);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO write success\n");
|
||||
}
|
||||
|
||||
ret = mraa_iio_read_int(iio_device0, "scan_elements/in_accel_x_en", &iio_int);
|
||||
if (ret == MRAA_SUCCESS) {
|
||||
fprintf(stdout, "IIO read %d\n", iio_int);
|
||||
}
|
||||
|
||||
if (mraa_iio_trigger_buffer(iio_device0, interrupt, NULL) == MRAA_SUCCESS) {
|
||||
sleep(100);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
struct iio_event_data event;
|
||||
iio_device6 = mraa_iio_init(6);
|
||||
if (iio_device6 == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
mraa_iio_write_int(iio_device6, "events/in_proximity2_thresh_either_en", 1);
|
||||
|
||||
|
||||
// Blocking until event fired
|
||||
if (mraa_iio_event_poll(iio_device6, &event) == MRAA_SUCCESS) {
|
||||
event_interrupt(&event); //just to show data
|
||||
}
|
||||
|
||||
if (mraa_iio_event_setup_callback(iio_device6, event_interrupt, NULL) == MRAA_SUCCESS) {
|
||||
sleep(100);
|
||||
return EXIT_SUCCESS;
|
||||
}*/
|
||||
|
||||
//! [Interesting]
|
||||
return EXIT_FAILURE;
|
||||
}
|
@@ -29,11 +29,14 @@
|
||||
static volatile int counter = 0;
|
||||
static volatile int oldcounter = 0;
|
||||
|
||||
void interrupt (void * args) {
|
||||
void
|
||||
interrupt(void* args)
|
||||
{
|
||||
++counter;
|
||||
}
|
||||
|
||||
int main ()
|
||||
int
|
||||
main()
|
||||
{
|
||||
mraa_init();
|
||||
mraa_gpio_context x;
|
||||
@@ -45,14 +48,14 @@ int main ()
|
||||
|
||||
mraa_gpio_dir(x, MRAA_GPIO_IN);
|
||||
|
||||
gpio_edge_t edge = MRAA_GPIO_EDGE_BOTH;
|
||||
|
||||
mraa_gpio_edge_t edge = MRAA_GPIO_EDGE_BOTH;
|
||||
|
||||
mraa_gpio_isr(x, edge, &interrupt, NULL);
|
||||
|
||||
for(;;) {
|
||||
if(counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
for (;;) {
|
||||
if (counter != oldcounter) {
|
||||
fprintf(stdout, "timeout counter == %d\n", counter);
|
||||
oldcounter = counter;
|
||||
}
|
||||
// got to relieve our poor CPU!
|
||||
sleep(1);
|
||||
|
56
examples/java/AioA0.java
Normal file
56
examples/java/AioA0.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: Nandkishor Sonar
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
//! [Interesting]
|
||||
import mraa.Aio;
|
||||
|
||||
public class AioA0 {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Aio a0 = new Aio(0);
|
||||
|
||||
while (true) {
|
||||
int adc_value = a0.read();
|
||||
float adc_value_float = a0.readFloat();
|
||||
System.out.println(String.format("ADC A0 read %X - %d", adc_value, adc_value));
|
||||
System.out.println(String.format("ADC A0 read %.5f", adc_value_float));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
72
examples/java/BlinkIO.java
Normal file
72
examples/java/BlinkIO.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
import mraa.Dir;
|
||||
import mraa.Gpio;
|
||||
import mraa.Result;
|
||||
import mraa.mraa;
|
||||
|
||||
public class BlinkIO {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
final static int DEFAULT_IOPIN = 8;
|
||||
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
int iopin = DEFAULT_IOPIN;
|
||||
if (argv.length == 0) {
|
||||
System.out.println("Provide an int arg if you want to flash on something other than " + DEFAULT_IOPIN);
|
||||
} else {
|
||||
iopin = Integer.valueOf(argv[0], DEFAULT_IOPIN);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
Gpio gpio = new Gpio(iopin);
|
||||
Result result = gpio.dir(Dir.DIR_OUT);
|
||||
if (result != Result.SUCCESS) {
|
||||
mraa.printError(result);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
gpio.write(1);
|
||||
Thread.sleep(1000);
|
||||
gpio.write(0);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
81
examples/java/BlinkOnboard.java
Normal file
81
examples/java/BlinkOnboard.java
Normal file
@@ -0,0 +1,81 @@
|
||||
import mraa.Dir;
|
||||
import mraa.Gpio;
|
||||
import mraa.Platform;
|
||||
import mraa.mraa;
|
||||
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Jakub Kramarz <jkramarz@virtuslab.com>
|
||||
* Copyright (c) 2015 VirtusLab
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class BlinkOnboard {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
Platform platform = mraa.getPlatformType();
|
||||
Gpio gpio, gpio_in;
|
||||
if (platform == Platform.INTEL_GALILEO_GEN1) {
|
||||
gpio = new Gpio(3);
|
||||
} else if (platform == Platform.INTEL_MINNOWBOARD_MAX) {
|
||||
gpio = new Gpio(21);
|
||||
} else {
|
||||
gpio = new Gpio(13);
|
||||
}
|
||||
System.out.format("Welcome to libmraa\n Version: %s\n Running on %s\n",
|
||||
mraa.getVersion(), platform.toString());
|
||||
|
||||
gpio.dir(Dir.DIR_OUT);
|
||||
// on platforms with physical button use gpio_in
|
||||
if (platform == Platform.INTEL_MINNOWBOARD_MAX) {
|
||||
gpio_in = new Gpio(14);
|
||||
gpio_in.dir(Dir.DIR_IN);
|
||||
System.out.println("Press and hold S1 to stop, Press SW1 to shutdown!");
|
||||
} else {
|
||||
gpio_in = null;
|
||||
}
|
||||
|
||||
boolean state = false;
|
||||
while (true) {
|
||||
if (gpio_in != null && gpio_in.read() == 0) {
|
||||
return;
|
||||
}
|
||||
if (state) {
|
||||
state = false;
|
||||
gpio.write(1);
|
||||
} else {
|
||||
state = true;
|
||||
gpio.write(0);
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
75
examples/java/Bmp85.java
Normal file
75
examples/java/Bmp85.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Author: Alexander Komarov <alexander.komarov@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class Bmp85 {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) {
|
||||
mraa.mraa.init();
|
||||
System.out.println(mraa.mraa.getVersion());
|
||||
|
||||
// helper function to go from hex val to dec
|
||||
// function char(x) { return parseInt(x, 16); }
|
||||
|
||||
mraa.I2c i2c = new mraa.I2c(0);
|
||||
i2c.address((byte)0x77);
|
||||
i2c.writeByte((byte)0xd0);
|
||||
/*
|
||||
SWIGTYPE_p_unsigned_char data0 = new SWIGTYPE_p_unsigned_char();*/
|
||||
byte[] data = new byte[1];
|
||||
i2c.read(data);
|
||||
System.out.println((new Integer(data[0])).toString());
|
||||
|
||||
i2c.writeReg((byte)0xf4, (byte)0x2e);
|
||||
// initialise device
|
||||
if (i2c.readReg((byte)0xd0) != 0x55) {
|
||||
System.out.println("error");
|
||||
}
|
||||
|
||||
// we want to read temperature so write 0x2e into control reg
|
||||
i2c.writeReg((byte)0xf4, (byte)0x2e);
|
||||
|
||||
// read a 16bit reg, obviously it's uncalibrated so mostly a useless value
|
||||
// :)
|
||||
System.out.println(i2c.readWordReg((byte)0xf6));
|
||||
|
||||
byte[] buf = new byte[2];
|
||||
buf[0] = (byte)0xf4;
|
||||
buf[1] = (byte)0x2e;
|
||||
i2c.write(buf);
|
||||
|
||||
i2c.writeByte((byte)0xf6);
|
||||
int d = i2c.readReg((byte)2);
|
||||
System.out.println((new Integer(d)).toString());
|
||||
};
|
||||
}
|
||||
;
|
57
examples/java/CyclePwm3.java
Normal file
57
examples/java/CyclePwm3.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Jakub Kramarz <jkramarz@virtuslab.com>
|
||||
* Copyright (c) 2015 VirtusLab
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import mraa.Pwm;
|
||||
|
||||
public class CyclePwm3 {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
Pwm pwm = new mraa.Pwm(3);
|
||||
pwm.period_us(200);
|
||||
pwm.enable(true);
|
||||
|
||||
float value = 0;
|
||||
while (true) {
|
||||
value += 0.01;
|
||||
pwm.write(value);
|
||||
Thread.sleep(50);
|
||||
if (value >= 1) {
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
49
examples/java/Example.java
Normal file
49
examples/java/Example.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//! [Interesting]
|
||||
import mraa.mraa;
|
||||
|
||||
public class Example {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) {
|
||||
String board = mraa.getPlatformName();
|
||||
String version = mraa.getVersion();
|
||||
System.out.println("hello mraa");
|
||||
System.out.println(String.format("Version: %s", version));
|
||||
System.out.println(String.format("Running on %s", board));
|
||||
};
|
||||
}
|
||||
//! [Interesting]
|
62
examples/java/FTDITest.java
Normal file
62
examples/java/FTDITest.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import mraa.*;
|
||||
|
||||
public class FTDITest {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
String board = mraa.getPlatformName();
|
||||
String version = mraa.getVersion();
|
||||
|
||||
System.out.println(String.format("Version: %s", version));
|
||||
System.out.println(String.format("Running on %s", board));
|
||||
|
||||
if (mraa.hasSubPlatform()) {
|
||||
System.out.println("Subplatform detected");
|
||||
|
||||
/* Print when button is pressed */
|
||||
Gpio button = new Gpio(515);
|
||||
button.dir(Dir.DIR_IN);
|
||||
button.isr(Edge.EDGE_FALLING, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Button pressed");
|
||||
}
|
||||
});
|
||||
|
||||
/* Blink FTDI board LED */
|
||||
Gpio led = new Gpio(514);
|
||||
led.dir(Dir.DIR_OUT);
|
||||
for (int i = 0;; i = (i + 1) % 2) {
|
||||
led.write(i);
|
||||
Thread.sleep(500);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Subplatform not detected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
examples/java/GpioMmapped.java
Normal file
60
examples/java/GpioMmapped.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import mraa.Gpio;
|
||||
import mraa.mraa;
|
||||
|
||||
public class GpioMmapped {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
//! [Interesting]
|
||||
String board = mraa.getPlatformName();
|
||||
String version = mraa.getVersion();
|
||||
System.out.println("hello mraa");
|
||||
System.out.println(String.format("Version: %s", version));
|
||||
|
||||
Gpio gpio = new Gpio(1);
|
||||
|
||||
gpio.useMmap(true);
|
||||
|
||||
while (true) {
|
||||
gpio.write(1);
|
||||
Thread.sleep(50);
|
||||
gpio.write(0);
|
||||
Thread.sleep(50);
|
||||
}
|
||||
//! [Interesting]
|
||||
};
|
||||
}
|
55
examples/java/GpioRead6.java
Normal file
55
examples/java/GpioRead6.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Jakub Kramarz <jkramarz@virtuslab.com>
|
||||
* Copyright (c) 2015 VirtusLab
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import mraa.Dir;
|
||||
import mraa.Gpio;
|
||||
import mraa.mraa;
|
||||
|
||||
public class GpioRead6 {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) throws InterruptedException {
|
||||
System.out.println(String.format("MRAA Version: %s\nStarting Read on IO6\n", mraa.getVersion()));
|
||||
//! [Interesting]
|
||||
Gpio gpio = new Gpio(6);
|
||||
|
||||
gpio.dir(Dir.DIR_IN);
|
||||
|
||||
while (true) {
|
||||
System.out.format("Gpio is %d\n", gpio.read());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
//! [Interesting]
|
||||
}
|
||||
}
|
73
examples/java/HelloEdison.java
Normal file
73
examples/java/HelloEdison.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
//! [Interesting]
|
||||
import mraa.Dir;
|
||||
import mraa.Gpio;
|
||||
import mraa.IntelEdison;
|
||||
import mraa.mraa;
|
||||
import mraa.Platform;
|
||||
import mraa.Result;
|
||||
|
||||
public class HelloEdison {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
public static void main(String argv[]) {
|
||||
Platform platform = mraa.getPlatformType();
|
||||
|
||||
if (platform != Platform.INTEL_EDISON_FAB_C) {
|
||||
System.err.println("Error: This program can only be run on edison");
|
||||
System.exit(Result.ERROR_INVALID_PLATFORM.swigValue());
|
||||
}
|
||||
|
||||
/*
|
||||
* MRAA_INTEL_EDISON_GP182 == 0, so this will initialise pin0 on arduino,
|
||||
* which is hardware GPIO 130 and not 182
|
||||
* We set the owner to false here, this makes sure that we do not close the
|
||||
* gpio from sysfs in mraa_gpio_close meaning it will stay as an output and
|
||||
* we will not always transition from 0->1 as gpio182 as output has the
|
||||
* default position of '0'. Note that the value could change as a result of
|
||||
* a mraa_gpio_dir however meaning we always go from 0->1 or 1->0
|
||||
*/
|
||||
Gpio gpio182 = new Gpio(IntelEdison.INTEL_EDISON_GP182.swigValue(), false);
|
||||
gpio182.dir(Dir.DIR_OUT);
|
||||
|
||||
int val = gpio182.read();
|
||||
|
||||
System.out.println(String.format("GPIO%d (mraa pin %d) was: %d, will set to %d\n", 182,
|
||||
gpio182.getPin(), val, val == 0 ? 1 : 0));
|
||||
|
||||
gpio182.write(val == 0 ? 1 : 0);
|
||||
};
|
||||
}
|
||||
//! [Interesting]
|
135
examples/java/I2cCompass.java
Normal file
135
examples/java/I2cCompass.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
||||
* Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
* Author: Petre Eftime <petre.p.eftime@intel.com>
|
||||
* Copyright (c) 2015 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import mraa.I2c;
|
||||
|
||||
public class I2cCompass {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("mraajava");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println(
|
||||
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
||||
e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
final static byte MAX_BUFFER_LENGTH = 6;
|
||||
final static byte CONF_BUFFER_LENGTH = 2;
|
||||
final static short HMC5883L_I2C_ADDR = 0x1E;
|
||||
|
||||
// configuration registers
|
||||
final static byte HMC5883L_CONF_REG_A = 0x00;
|
||||
final static byte HMC5883L_CONF_REG_B = 0x01;
|
||||
|
||||
// mode register
|
||||
final static byte HMC5883L_MODE_REG = 0x02;
|
||||
|
||||
// data register
|
||||
final static byte HMC5883L_X_MSB_REG = 0;
|
||||
final static byte HMC5883L_X_LSB_REG = 1;
|
||||
final static byte HMC5883L_Z_MSB_REG = 2;
|
||||
final static byte HMC5883L_Z_LSB_REG = 3;
|
||||
final static byte HMC5883L_Y_MSB_REG = 4;
|
||||
final static byte HMC5883L_Y_LSB_REG = 5;
|
||||
final static byte DATA_REG_SIZE = 6;
|
||||
|
||||
// status register
|
||||
final static byte HMC5883L_STATUS_REG = 0x09;
|
||||
|
||||
// ID registers
|
||||
final static byte HMC5883L_ID_A_REG = 0x0A;
|
||||
final static byte HMC5883L_ID_B_REG = 0x0B;
|
||||
final static byte HMC5883L_ID_C_REG = 0x0C;
|
||||
|
||||
final static byte HMC5883L_CONT_MODE = 0x00;
|
||||
final static byte HMC5883L_DATA_REG = 0x03;
|
||||
|
||||
// scales
|
||||
final static byte GA_0_88_REG = ((byte) (0x00 << 5));
|
||||
final static byte GA_1_3_REG = ((byte) (0x01 << 5));
|
||||
final static byte GA_1_9_REG = ((byte) (0x02 << 5));
|
||||
final static byte GA_2_5_REG = ((byte) (0x03 << 5));
|
||||
final static byte GA_4_0_REG = ((byte) (0x04 << 5));
|
||||
final static byte GA_4_7_REG = ((byte) (0x05 << 5));
|
||||
final static byte GA_5_6_REG = ((byte) (0x06 << 5));
|
||||
final static byte GA_8_1_REG = ((byte) (0x07 << 5));
|
||||
|
||||
// digital resolutions
|
||||
final static float SCALE_0_73_MG = 0.73f;
|
||||
final static float SCALE_0_92_MG = 0.92f;
|
||||
final static float SCALE_1_22_MG = 1.22f;
|
||||
final static float SCALE_1_52_MG = 1.52f;
|
||||
final static float SCALE_2_27_MG = 2.27f;
|
||||
final static float SCALE_2_56_MG = 2.56f;
|
||||
final static float SCALE_3_03_MG = 3.03f;
|
||||
final static float SCALE_4_35_MG = 4.35f;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
float direction = 0;
|
||||
int x, y, z;
|
||||
byte[] rx_tx_buf = new byte[MAX_BUFFER_LENGTH];
|
||||
byte[] conf_buf = new byte[CONF_BUFFER_LENGTH];
|
||||
|
||||
//! [Interesting]
|
||||
I2c i2c = new I2c(0);
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
conf_buf[0] = HMC5883L_CONF_REG_B;
|
||||
conf_buf[1] = GA_1_3_REG;
|
||||
i2c.write(conf_buf);
|
||||
//! [Interesting]
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
conf_buf[0] = HMC5883L_MODE_REG;
|
||||
conf_buf[1] = HMC5883L_CONT_MODE;
|
||||
i2c.write(conf_buf);
|
||||
|
||||
while (true) {
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.writeByte(HMC5883L_DATA_REG);
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.read(rx_tx_buf);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8) | rx_tx_buf[HMC5883L_X_LSB_REG];
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Z_LSB_REG];
|
||||
y = (rx_tx_buf[HMC5883L_Y_MSB_REG] << 8) | rx_tx_buf[HMC5883L_Y_LSB_REG];
|
||||
|
||||
direction = (float) Math.atan2(y * SCALE_0_92_MG, x * SCALE_0_92_MG);
|
||||
|
||||
if (direction < 0)
|
||||
direction += 2 * Math.PI;
|
||||
|
||||
System.out.println(String.format("Compass scaled data x : %f, y : %f, z : %f\n", x * SCALE_0_92_MG, y * SCALE_0_92_MG,
|
||||
z * SCALE_0_92_MG));
|
||||
System.out.println(String.format("Heading : %f\n", direction * 180 / Math.PI));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user