diff --git a/README.md b/README.md index 6fad1eb8db4407557db4050c62a0618ad1ef53f9..2fa2bb0ebd0f9488d1052d2c4ad557abbeec8e81 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,63 @@ [](https://gitlab.control.lth.se/labdev/LabConnections.jl/commits/master) [](https://gitlab.control.lth.se/labdev/LabConnections.jl/commits/master) -Documentation available at [Documentation](https://gitlab.control.lth.se/labdev/LabConnections.jl/blob/master/docs/build/index.html) +# Welcome to LabConnections.jl - the IO-software part of the LabDev project -# OBS! SPI development -The SPI development is done in C and in a forked repository, currently -separated from the julia project. If you wish to work on the SPI implementation, -simply clone the repository "serbus", a small C stack available at -`github.com/mgreiff/serbus` into your julia package directory (for example -`~/.julia/v0.6`). Then, in the LabConnections package on the host computer, run -`flash_BB.sh` in the `/utils` directory transferring both LabConnections and -serbus to the BB. +The goal of this project is to develop a software package in [Julia](https://julialang.org/) +for interfacing with lab processes using either the [BeagleBone Black Rev C](http://beagleboard.org/) (BBB) +with custom [IO-board cape](https://gitlab.control.lth.se/labdev/ioboards), or the old IO-boxes in the labs using Comedi. +With this package, the user is able to setup a connection between the +host computer and the IO-device, and send and +receive control signals and measurements from the lab process. -On the BB, run +The full documentation of the package is available [here](https://gitlab.control.lth.se/labdev/LabConnections.jl/blob/master/docs/build/index.md). - cp /home/debian/juliapackages/serbus/bb_spi.sh /home/debian +## Package Overview +The `LabConnections.jl` package is subdivided into two main modules; `Computer.jl` +and `BeagleBone.jl`. `Computer.jl` defines the user interface on the host +computer side, while `BeagleBone.jl` defines low-level types and functions meant +to be used locally on the BBB. -and then execute +### BeagleBone.jl +This module defines types representing different pins and LEDs on the BBB, and +functions to change their status and behaviour. There are currently 4 different types defined +(each has the abstract super type `IO_Object`): +* `GPIO` : Represents the BBB's General Purpose Input Output (GPIO) pins. +Each instance will correspond to a physical GPIO pin on the board, and can be +set as an input or output pin, and to output high (1) or low (0). +* `PWM` : Represents the BBB's Pulse Width Modulation (PWM) pins. +Each instance will correspond to a physical PWM pin on the board, which can be +turned on/off, and whose period, duty cycle and polarity can be specified. +* `SysLED` : Represents the 4 system LEDs on the BBB, and can be turned on/off. +Used to perform simple tests and debugging on the BBB. +* `Debug` : Used for debugging and pre-compilation on the BBB. It does +not represent any physical pin or LED on the board. + +**Note:** In addition to GPIO and PWM, the BBB also has pins dedicated for [Serial Peripheral +Interface](https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus) (SPI). +Work to feature this functionality in `BeagleBone.jl` is currently ongoing. More +information can be found [here](https://gitlab.control.lth.se/labdev/LabConnections.jl/blob/master/docs/build/man/introduction.md#spi-development) + + +### Computer.jl +This module contains the user interface on the host computer side, and defines +types for devices/connections to the lab process, and filestreams between the +host computer and different IO-devices (BBB or Comedi). There are currently 3 +different device/connection types (each has the abstract super type `AbstractDevice`): +* `AnalogInput10V` : Represents ±10V connections from the lab process to the IO-device. Each instance will correspond to a physical ±10V measurement signal from the lab process, whose value can be read. +* `AnalogOutput10V` : Represents ±10V connections from the IO-device to the lab process. Each instance will correspond to a physical ±10V input signal to the lab process, whose value can be set. +* `SysLED` : Represents the System LEDs on the BBB. Used for simple testing and debugging from the host computer side. + +There are 2 different filestream types (each has the abstract super type `LabStream`): +* `BeagleBoneStream` : Represents the data stream between the host computer and the BBB. +* `ComediStream` : Represent the data stream between the host computer and the old IO-boxes using Comedi. + +## Getting Started +Instructions on installing the required software and setting up a connection between +the host computer and the BBB are found [here](https://gitlab.control.lth.se/labdev/LabConnections.jl/blob/master/docs/build/man/installation.md#installation-instructions) + +After successfully setting up a connection between host computer and BBB, there +are several examples found [here](https://gitlab.control.lth.se/labdev/LabConnections.jl/blob/master/docs/build/examples/examples.md#examples) +which let's you test out the functionality of `LabConnections.jl`. - ./bb_spi.sh -in the `/home/debian` directory to run the SPI example with the ADC from SPI0. diff --git a/docs/build/index.md b/docs/build/index.md index ddd957b0faf8eb3551cac6b4e046969214f8155d..7a600d2400f08f4982cab32e7c9317edc6082139 100644 --- a/docs/build/index.md +++ b/docs/build/index.md @@ -43,8 +43,8 @@ - [`Base.read`](lib/functions.md#Base.read) - [`Base.read`](lib/functions.md#Base.read) - [`LabConnections.BeagleBone.assert_pwm_write`](lib/functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}) -- [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}) - [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any}) +- [`LabConnections.BeagleBone.bbparse`](lib/functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}) - [`LabConnections.BeagleBone.closedev`](lib/functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32}) - [`LabConnections.BeagleBone.export_gpio`](lib/functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32}) - [`LabConnections.BeagleBone.export_led`](lib/functions.md#LabConnections.BeagleBone.export_led) diff --git a/docs/build/lib/functions.md b/docs/build/lib/functions.md index 7cf7ae807a57f77682efd2438a1e519e3c213a66..bed9fee32dd3a6aaaf3351503d15300e9198a076 100644 --- a/docs/build/lib/functions.md +++ b/docs/build/lib/functions.md @@ -2,8 +2,8 @@ - [`Base.read`](functions.md#Base.read) - [`Base.read`](functions.md#Base.read) - [`LabConnections.BeagleBone.assert_pwm_write`](functions.md#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}) -- [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}) - [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Any}) +- [`LabConnections.BeagleBone.bbparse`](functions.md#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}) - [`LabConnections.BeagleBone.closedev`](functions.md#LabConnections.BeagleBone.closedev-Tuple{String,Int32}) - [`LabConnections.BeagleBone.export_gpio`](functions.md#LabConnections.BeagleBone.export_gpio-Tuple{Int32}) - [`LabConnections.BeagleBone.export_led`](functions.md#LabConnections.BeagleBone.export_led) @@ -37,7 +37,7 @@ run_server(port=2001; debug=false) ``` -Run a server on `port` that listens for commands from computer Optional debug keyword disables blinking system leds +Run a server on `port` that listens for commands from computer Optional debug keyword disables blinking system leds. <a id='Base.read' href='#Base.read'>#</a> **`Base.read`** — *Function*. @@ -55,14 +55,22 @@ Reads the current brightness value from the LED 'SysLED'. -l = read(gpio::GPIO, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO. +``` +l = read(pwm::PWM, operation::Int32, debug::Bool=false) +``` + +Reads the current value from an operation on a GPIO. <a id='Base.read' href='#Base.read'>#</a> **`Base.read`** — *Function*. -l = read(pwm::PWM, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO. +``` +l = read(gpio::GPIO, operation::Int32, debug::Bool=false) +``` + +Reads the current value from an operation on a GPIO. <a id='LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}' href='#LabConnections.BeagleBone.assert_pwm_write-Tuple{Int32,String}'>#</a> **`LabConnections.BeagleBone.assert_pwm_write`** — *Method*. @@ -73,7 +81,7 @@ l = read(pwm::PWM, operation::Int32, debug::Bool=false) Reads the current value assert_pwm_write(operation::Int32, entry::String) ``` -Assertsion for the PWM input data +Assertsion for the PWM input data. <a id='LabConnections.BeagleBone.bbparse-Tuple{Any}' href='#LabConnections.BeagleBone.bbparse-Tuple{Any}'>#</a> **`LabConnections.BeagleBone.bbparse`** — *Method*. @@ -84,7 +92,7 @@ Assertsion for the PWM input data bbparse(cmd) ``` -Parse and execute the command `cmd` +Parse and execute the command `cmd`. <a id='LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}' href='#LabConnections.BeagleBone.bbparse-Tuple{Tuple,Any}'>#</a> **`LabConnections.BeagleBone.bbparse`** — *Method*. @@ -95,23 +103,29 @@ Parse and execute the command `cmd` bbparse(l::Tuple, sock) ``` -Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)` where if `iswrite` `cmdi = (devname, id, val)` and if not `iswrite` `cmdi = (devname, id)` - -and send back on socket (vals, timestamps) +Parse input on the form `l=(iswrite, ndev, cmd1, cmd2, ..., cmdn)` where if `iswrite` `cmdi = (devname, id, val)` and if not `iswrite` `cmdi = (devname, id)` and send back on socket (vals, timestamps). <a id='LabConnections.BeagleBone.closedev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.closedev-Tuple{String,Int32}'>#</a> **`LabConnections.BeagleBone.closedev`** — *Method*. -closedev(dev_name::String, i::Int32) Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, and removes it from the dict of currently active devices. +``` +closedev(dev_name::String, i::Int32) +``` + +Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, and removes it from the dict of currently active devices. <a id='LabConnections.BeagleBone.export_gpio-Tuple{Int32}' href='#LabConnections.BeagleBone.export_gpio-Tuple{Int32}'>#</a> **`LabConnections.BeagleBone.export_gpio`** — *Method*. -export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for real-time or testing usecases. +``` +export_gpio(i::Int32, debug::Bool=false) +``` + +Export the GPIO file system, either for real-time or testing usecases. <a id='LabConnections.BeagleBone.export_led' href='#LabConnections.BeagleBone.export_led'>#</a> **`LabConnections.BeagleBone.export_led`** — *Function*. @@ -129,7 +143,11 @@ Exports a dummy filesystem for testing the LED implementation -export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for real-time or testing usecases. +``` +export_gpio(i::Int32, debug::Bool=false) +``` + +Export the GPIO file system, either for real-time or testing usecases. <a id='LabConnections.BeagleBone.getdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.getdev-Tuple{String,Int32}'>#</a> **`LabConnections.BeagleBone.getdev`** — *Method*. @@ -140,14 +158,18 @@ export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for dev = getdev(dev_name::String, i::Int32) ``` -Retrieves the active device of type `dev_name` at index 'i' +Retrieves the active device of type `dev_name` at index 'i'. <a id='LabConnections.BeagleBone.initdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.initdev-Tuple{String,Int32}'>#</a> **`LabConnections.BeagleBone.initdev`** — *Method*. -active_device = initdev(dev_name::String, i:Int32) Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, and adds it to the dict of currently active devices. Returns the initialized device 'active_device'. +``` +active_device = initdev(dev_name::String, i:Int32) +``` + +Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, and adds it to the dict of currently active devices. Returns the initialized device 'active_device'. <a id='LabConnections.BeagleBone.listdev-Tuple{}' href='#LabConnections.BeagleBone.listdev-Tuple{}'>#</a> **`LabConnections.BeagleBone.listdev`** — *Method*. @@ -158,7 +180,7 @@ active_device = initdev(dev_name::String, i:Int32) Initializes a new device of t message = listdev() ``` -Lists all the active devices as an insidence array for testing +Lists all the active devices as an insidence array for testing. <a id='LabConnections.BeagleBone.printdev-Tuple{String,Int32}' href='#LabConnections.BeagleBone.printdev-Tuple{String,Int32}'>#</a> **`LabConnections.BeagleBone.printdev`** — *Method*. @@ -169,7 +191,7 @@ Lists all the active devices as an insidence array for testing message = printdev() ``` -Prints all the active devices and writes out specifics of a single devices +Prints all the active devices and writes out specifics of a single devices. <a id='LabConnections.BeagleBone.teardown' href='#LabConnections.BeagleBone.teardown'>#</a> **`LabConnections.BeagleBone.teardown`** — *Function*. @@ -177,17 +199,21 @@ Prints all the active devices and writes out specifics of a single devices ``` -teardown!(pwd::PWM) +teardown(gpio::GPIO, debug::Bool=false) ``` -Closes all open streams on the PWM, and unexports it from the file system +Closes all open streams on the GPIO, and unexports it from the file system. <a id='LabConnections.BeagleBone.teardown' href='#LabConnections.BeagleBone.teardown'>#</a> **`LabConnections.BeagleBone.teardown`** — *Function*. -teardown(gpio::GPIO, debug::Bool=false) Closes all open streams on the GPIO, and unexports it from the file system. +``` +teardown(led::SysLED, debug::Bool=false) +``` + +Closes all open filestreams for the SysLED 'led'. <a id='LabConnections.BeagleBone.teardown' href='#LabConnections.BeagleBone.teardown'>#</a> **`LabConnections.BeagleBone.teardown`** — *Function*. @@ -195,31 +221,43 @@ teardown(gpio::GPIO, debug::Bool=false) Closes all open streams on the GPIO, and ``` -teardown(led::SysLED, debug::Bool=false) +teardown!(pwd::PWM) ``` -Closes all open filestreams for the SysLED 'led'. +Closes all open streams on the PWM, and unexports it from the file system <a id='LabConnections.BeagleBone.to_string' href='#LabConnections.BeagleBone.to_string'>#</a> **`LabConnections.BeagleBone.to_string`** — *Function*. -to_string(pwm::PWM,, debug::Bool=false) Generates a string representation of the GPIO device. +``` +to_string(gpio::GPIO, debug::Bool=false) +``` + +Generates a string representation of the GPIO device. <a id='LabConnections.BeagleBone.to_string' href='#LabConnections.BeagleBone.to_string'>#</a> **`LabConnections.BeagleBone.to_string`** — *Function*. -to_string(gpio::GPIO, debug::Bool=false) Generates a string representation of the GPIO device. +``` +to_string(led::SysLED, debug::Bool=false) +``` + +Generates a string representation of the GPIO device. <a id='LabConnections.BeagleBone.to_string' href='#LabConnections.BeagleBone.to_string'>#</a> **`LabConnections.BeagleBone.to_string`** — *Function*. -to_string(led::SysLED, debug::Bool=false) Generates a string representation of the GPIO device. +``` +to_string(pwm::PWM,, debug::Bool=false) +``` + +Generates a string representation of the GPIO device. <a id='LabConnections.BeagleBone.write!' href='#LabConnections.BeagleBone.write!'>#</a> **`LabConnections.BeagleBone.write!`** — *Function*. @@ -227,10 +265,10 @@ to_string(led::SysLED, debug::Bool=false) Generates a string representation of t ``` -write!(led::SysLED, val::Bool, debug::Bool=false) +write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) ``` -Turns the LED 'SysLed' on/off for val = true/false respectively. +Writes an entry to an operation on a GPIO, of the form args = (operation, entry). <a id='LabConnections.BeagleBone.write!' href='#LabConnections.BeagleBone.write!'>#</a> **`LabConnections.BeagleBone.write!`** — *Function*. @@ -248,5 +286,9 @@ Writes an entry to an operation on the PWM, of the form args = (operation, entry -write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) Writes an entry to an operation on a GPIO, of the form args = (operation, entry). +``` +write!(led::SysLED, val::Bool, debug::Bool=false) +``` + +Turns the LED 'SysLed' on/off for val = true/false respectively. diff --git a/docs/build/lib/io_devices.md b/docs/build/lib/io_devices.md index ad6bf2fcfddf1bb39168e263ef1fd75d45cd6213..f01fba905118a159d8d2bb8c9e4eca9849f418de 100644 --- a/docs/build/lib/io_devices.md +++ b/docs/build/lib/io_devices.md @@ -15,25 +15,33 @@ ``` -Debug() +Debug(i::Int32) ``` -Type for debugging and precompile +Type for debugging and precompile. <a id='LabConnections.BeagleBone.GPIO' href='#LabConnections.BeagleBone.GPIO'>#</a> **`LabConnections.BeagleBone.GPIO`** — *Type*. -Lowest form of communication with the GPIO pins. The available pins are listed in the "channel" parameter, and appear as directories in /sys/class/gpio after being exported. +``` +GPIO(i::Int32) +``` -For instance, to setup a GPIO on "gpio112", configure it as an output pin and set it to high, the following code would be used. +Lowest form of communication with the GPIO pins. The available pins are listed in the "channel" parameter, and appear as directories in /sys/class/gpio after being exported. For instance, to setup a GPIO on "gpio112", configure it as an output pin and set it to high, the following code would be used. -gpio = GPIO(1) write!(gpio, (2,"out")) write!(gpio, (1, "1")) +``` +`gpio = GPIO(1)` +`write!(gpio, (2,"out"))` +`write!(gpio, (1, "1"))` +``` The operation of reading the current output value of the GPIO is done by -read(gpio, 1) +``` +`read(gpio, 1)` +``` See the test/BeagleBone/GPIO_test.jl for more examples. @@ -49,19 +57,19 @@ Define abstract type for pins/LEDS on the BeagleBone -This script allows for low level PWM control of selected pins The valid pins dictionary relates to memory adresses in of the AM3359 chip, see p.182 in - ``` -www.ti.com/product/AM3359/technicaldocuments +PWM(i::Int32) ``` +This device allows for low level PWM control of selected pins. The valid pins dictionary pwm_pins relates to memory adresses in of the AM3359 chip, see p.182 in www.ti.com/product/AM3359/technicaldocuments. + <a id='LabConnections.BeagleBone.SysLED' href='#LabConnections.BeagleBone.SysLED'>#</a> **`LabConnections.BeagleBone.SysLED`** — *Type*. ``` -SysLED +SysLED(i::Int32) ``` Type representing the system LEDs on the BeagleBone. The LEDs are indexed by i ∈ [1,2,3,4]. diff --git a/docs/build/man/introduction.md b/docs/build/man/introduction.md index 6d7027ef1e3ba510996217a5a0058ff93ca89e6d..e8b361a7360ab652a5f3be4f73beb051a5f15611 100644 --- a/docs/build/man/introduction.md +++ b/docs/build/man/introduction.md @@ -1,4 +1,3 @@ - <a id='Introduction-1'></a> # Introduction @@ -8,3 +7,24 @@ ## Installation +## Future Work + +### SPI Development +The SPI development is done in C and in a forked repository, currently +separated from the julia project. If you wish to work on the SPI implementation, +simply clone the repository "serbus", a small C stack available at +`github.com/mgreiff/serbus` into your julia package directory (for example +`~/.julia/v0.6`). Then, in the LabConnections package on the host computer, run +`flash_BB.sh` in the `/utils` directory transferring both LabConnections and +serbus to the BB. + +On the BB, run + + cp /home/debian/juliapackages/serbus/bb_spi.sh /home/debian + +and then execute + + ./bb_spi.sh + +in the `/home/debian` directory to run the SPI example with the ADC from SPI0. + diff --git a/src/BeagleBone/BeagleBone.jl b/src/BeagleBone/BeagleBone.jl index 3038aae44afad252697fd26bb585e08a5769c7cf..9aa402b155546dbaddf4cb17c7b1b7f82eed6629 100644 --- a/src/BeagleBone/BeagleBone.jl +++ b/src/BeagleBone/BeagleBone.jl @@ -11,10 +11,12 @@ const DEVICES = Dict("debug" => Debug, "sysled" => SysLED, "gpio" => GPIO, "pwm" active_devices = Dict{String,Dict{Int32,IO_Object}}("debug" => Dict{Int32,Debug}(), "sysled" => Dict{Int32,SysLED}(), "gpio" => Dict{Int32,GPIO}(), "pwm" => Dict{Int32,PWM}()) -@doc """ active_device = initdev(dev_name::String, i:Int32) +""" + active_device = initdev(dev_name::String, i:Int32) Initializes a new device of type 'dev_name' at index 'i' on the BeagleBone, and adds it to the dict of currently active devices. Returns the initialized -device 'active_device'."""-> +device 'active_device'. +""" function initdev(dev_name::String, i::Int32) #Check if the type of device is valid dev_constr = try @@ -30,10 +32,11 @@ function initdev(dev_name::String, i::Int32) return active_device end -@doc """ closedev(dev_name::String, i::Int32) +""" + closedev(dev_name::String, i::Int32) Closes down a currently active device of type 'dev_name' at index 'i' on the BeagleBone, and removes it from the dict of currently active devices. -""" -> +""" function closedev(dev_name::String, i::Int32) active_device = try active_devices[dev_name][i] @@ -50,7 +53,7 @@ end """ dev = getdev(dev_name::String, i::Int32) -Retrieves the active device of type `dev_name` at index 'i' +Retrieves the active device of type `dev_name` at index 'i'. """ function getdev(dev_name::String, i::Int32) dev = try @@ -63,8 +66,8 @@ end """ message = listdev() -Lists all the active devices as an insidence array for testing -""" +Lists all the active devices as an insidence array for testing. + """ function listdev() message = "Complete overview of active devices" count = zeros(length(keys(DEVICES))) @@ -76,7 +79,7 @@ end """ message = printdev() -Prints all the active devices and writes out specifics of a single devices +Prints all the active devices and writes out specifics of a single devices. """ function printdev(dev_name::String, i::Int32) println("Complete overview of active devices") @@ -93,11 +96,10 @@ end """ bbparse(cmd) -Parse and execute the command `cmd` +Parse and execute the command `cmd`. """ bbparse(any) = error("Unexpected input: $any") - function bbsend(sock, vals)#, timestamps) serialize(sock, vals)#, (timestamps...))) end @@ -109,8 +111,7 @@ where if `iswrite` `cmdi = (devname, id, val)` and if not `iswrite` `cmdi = (devname, id)` - -and send back on socket (vals, timestamps) +and send back on socket (vals, timestamps). """ function bbparse(l::Tuple, sock) iswrite = l[1]::Bool #True if write command, false if read @@ -141,7 +142,7 @@ global __waiting_first_connection__ = false """ run_server(port=2001; debug=false) Run a server on `port` that listens for commands from computer -Optional debug keyword disables blinking system leds +Optional debug keyword disables blinking system leds. """ function run_server(port=2001; debug=false) global __waiting_first_connection__ = true diff --git a/src/BeagleBone/Debug.jl b/src/BeagleBone/Debug.jl index 9c3b0337cde30719fddf6674a4835afe9a8d8a8c..e2fd3693b9f4e921a609da4fd6025f844f070306 100644 --- a/src/BeagleBone/Debug.jl +++ b/src/BeagleBone/Debug.jl @@ -1,6 +1,6 @@ """ - Debug() -Type for debugging and precompile + Debug(i::Int32) +Type for debugging and precompile. """ type Debug <: IO_Object i::Int32 diff --git a/src/BeagleBone/GPIO.jl b/src/BeagleBone/GPIO.jl index 1dca4909b3272c920f9ca73c885fa94ed8dd7968..cc03657f6f81630a3eea0c6ab8249184b95e1fb0 100644 --- a/src/BeagleBone/GPIO.jl +++ b/src/BeagleBone/GPIO.jl @@ -1,18 +1,17 @@ """ + GPIO(i::Int32) Lowest form of communication with the GPIO pins. The available pins are listed in the "channel" parameter, and appear as directories in /sys/class/gpio -after being exported. - -For instance, to setup a GPIO on "gpio112", configure it as an output pin and set +after being exported. For instance, to setup a GPIO on "gpio112", configure it as an output pin and set it to high, the following code would be used. - gpio = GPIO(1) - write!(gpio, (2,"out")) - write!(gpio, (1, "1")) + `gpio = GPIO(1)` + `write!(gpio, (2,"out"))` + `write!(gpio, (1, "1"))` The operation of reading the current output value of the GPIO is done by - read(gpio, 1) + `read(gpio, 1)` See the test/BeagleBone/GPIO_test.jl for more examples. """ @@ -37,7 +36,7 @@ type GPIO <: IO_Object end """ - write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) + write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) Writes an entry to an operation on a GPIO, of the form args = (operation, entry). """ function write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) @@ -55,7 +54,7 @@ function write!(gpio::GPIO, args::Tuple{Int32,String}, debug::Bool=false) end """ - l = read(gpio::GPIO, operation::Int32, debug::Bool=false) + l = read(gpio::GPIO, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO. """ function read(gpio::GPIO, operation::Int32, debug::Bool=false) @@ -67,9 +66,10 @@ function read(gpio::GPIO, operation::Int32, debug::Bool=false) return l end -@doc """ teardown(gpio::GPIO, debug::Bool=false) +""" + teardown(gpio::GPIO, debug::Bool=false) Closes all open streams on the GPIO, and unexports it from the file system. -""" -> +""" function teardown(gpio::GPIO, debug::Bool=false) debug && return @@ -96,7 +96,7 @@ function teardown(gpio::GPIO, debug::Bool=false) end """ - export_gpio(i::Int32, debug::Bool=false) + export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for real-time or testing usecases. """ function export_gpio(i::Int32) @@ -124,7 +124,8 @@ function export_gpio(i::Int32) end """ - to_string(gpio::GPIO, debug::Bool=false) + to_string(gpio::GPIO, debug::Bool=false) + Generates a string representation of the GPIO device. """ function to_string(gpio::GPIO, debug::Bool=false) diff --git a/src/BeagleBone/IO_Object.jl b/src/BeagleBone/IO_Object.jl index 3a53ab5502cbe8ce8a4530d77a35f162d80ac4c0..9215ea2189e76697d5781172f3d8260cd9226d5c 100644 --- a/src/BeagleBone/IO_Object.jl +++ b/src/BeagleBone/IO_Object.jl @@ -3,9 +3,6 @@ Define abstract type for pins/LEDS on the BeagleBone """ abstract type IO_Object end -""" -GPIO interfaces -""" const gpio_operations = [ ["1", "0"], ["in", "out"], diff --git a/src/BeagleBone/PWM.jl b/src/BeagleBone/PWM.jl index 9689e89c7be8653f72b6aec79b5ed6260095fd56..33fa9c473e22602917026da0d0a781f5849bd9f1 100644 --- a/src/BeagleBone/PWM.jl +++ b/src/BeagleBone/PWM.jl @@ -1,9 +1,8 @@ """ -This script allows for low level PWM control of selected pins -The valid pins dictionary relates to memory adresses in of the -AM3359 chip, see p.182 in - - www.ti.com/product/AM3359/technicaldocuments + PWM(i::Int32) +This device allows for low level PWM control of selected pins. The valid pins +dictionary pwm_pins relates to memory adresses in of the AM3359 chip, see p.182 +in www.ti.com/product/AM3359/technicaldocuments. """ type PWM <: IO_Object @@ -53,7 +52,7 @@ end """ assert_pwm_write(operation::Int32, entry::String) -Assertsion for the PWM input data +Assertsion for the PWM input data. """ function assert_pwm_write(operation::Int32, entry::String) if operation == "1" @@ -69,7 +68,7 @@ function assert_pwm_write(operation::Int32, entry::String) end """ - l = read(pwm::PWM, operation::Int32, debug::Bool=false) + l = read(pwm::PWM, operation::Int32, debug::Bool=false) Reads the current value from an operation on a GPIO. """ function read(pwm::PWM, operation::Int32, debug::Bool=false) @@ -112,7 +111,7 @@ function teardown(pwm::PWM, debug::Bool=false) end """ - export_gpio(i::Int32, debug::Bool=false) + export_gpio(i::Int32, debug::Bool=false) Export the GPIO file system, either for real-time or testing usecases. """ function export_pwm(i::Int32) @@ -153,7 +152,7 @@ function export_pwm(i::Int32) end """ - to_string(pwm::PWM,, debug::Bool=false) + to_string(pwm::PWM,, debug::Bool=false) Generates a string representation of the GPIO device. """ function to_string(pwm::PWM, debug::Bool=false) diff --git a/src/BeagleBone/SysLED.jl b/src/BeagleBone/SysLED.jl index f18c85004c963f9605bb2564ec1a47f756105421..03cca51cafc65897a903464b4d78b61031bc502f 100644 --- a/src/BeagleBone/SysLED.jl +++ b/src/BeagleBone/SysLED.jl @@ -1,5 +1,5 @@ """ - SysLED + SysLED(i::Int32) Type representing the system LEDs on the BeagleBone. The LEDs are indexed by i ∈ [1,2,3,4]. """ @@ -88,7 +88,7 @@ function export_led(i::Int32, debug::Bool=false) end """ - to_string(led::SysLED, debug::Bool=false) + to_string(led::SysLED, debug::Bool=false) Generates a string representation of the GPIO device. """ function to_string(led::SysLED, debug::Bool=false)