Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabConnections.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labdev
LabConnections.jl
Commits
d9d3a81b
Commit
d9d3a81b
authored
7 years ago
by
Marcus Greiff
Browse files
Options
Downloads
Patches
Plain Diff
Add functional GPIO code for writing high/low to any pin
parent
8db93c0d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/BeagleBone/BeagleBone.jl
+2
-1
2 additions, 1 deletion
src/BeagleBone/BeagleBone.jl
src/BeagleBone/GPIO.jl
+84
-0
84 additions, 0 deletions
src/BeagleBone/GPIO.jl
with
86 additions
and
1 deletion
src/BeagleBone/BeagleBone.jl
+
2
−
1
View file @
d9d3a81b
...
...
@@ -3,9 +3,10 @@
# read(::T, identifier)
include
(
"SysLED.jl"
)
include
(
"GPIO.jl"
)
#List of available devices and their constructors
const
DEVICES
=
Dict
(
"sysled"
=>
SysLED
())
const
DEVICES
=
Dict
(
"sysled"
=>
SysLED
()
,
"gpio"
=>
GPIO
()
)
"""
dev = getdev(devname)
...
...
This diff is collapsed.
Click to expand it.
src/BeagleBone/GPIO.jl
0 → 100644
+
84
−
0
View file @
d9d3a81b
"""
Lowest form of communication woth the GPIO pins. The available pins are
listed in the "
channel
" parameter, and appear as directories in /sys/class.
Any of these GPIOs can be run in various ways, with any operation specified
by a sequence of three entries
(channel, operation, entry) = (int32, int32, String)
For instance, if the GPIO "
gpio30
" is to be configured as a output pin and set
to high, the following two writes aould be done.
write!(GPIO, 14, 2, "
out
")
write!(GPIO, 14, 1, "
1
")
"""
struct
GPIO
end
writeOperations
=
[
Dict
(
"dir"
=>
"value"
,
"entries"
=>
[
"1"
,
"0"
])
Dict
(
"dir"
=>
"direction"
,
"entries"
=>
[
"in"
,
"out"
])
]
readOperations
=
[
"value"
"direction"
"edge"
]
channels
=
[
"gpio112"
"gpio114"
"gpio115"
"gpio116"
"gpio14"
"gpio15"
"gpio2"
"gpio20"
"gpio22"
"gpio23"
"gpio26"
"gpio27"
"gpio3"
"gpio30"
"gpio31"
"gpio4"
"gpio44"
"gpio45"
"gpio46"
"gpio47"
"gpio48"
"gpio49"
"gpio5"
"gpio50"
"gpio51"
"gpio60"
"gpio61"
"gpio65"
"gpio66"
"gpio67"
"gpio68"
"gpio69"
"gpio7"
]
function
write!
(
::
GPIO
,
index
::
Int32
,
operation
::
Int32
,
entry
::
Bool
)
(
index
<=
0
||
index
>
length
(
channels
))
&&
error
(
"Invalid GPIO index:
$
index"
)
(
operation
<=
0
||
operation
>
length
(
writeOperations
))
&&
error
(
"Invalid GPIO operation:
$
operation"
)
filename
=
"/sys/class/gpio/
$
(channels[index])/
$
(writeOperations[operation]["
dir
"])"
value
=
writeOperations
[
operation
][
"entries"
][
entry
?
1
:
2
]
file
=
open
(
filename
,
"r+"
)
write
(
file
,
"
$(value)
"
)
close
(
file
)
return
end
#function Base.read(::SysLED, ind::Int32)
# (ind < 0 || ind > length(channels)) && error("Invalid SysLEND ind: $ind")
# println("not yet supported")
# l = 0
# return l == "1"
#end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment