Skip to content

Commit

Permalink
Updated documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
malotte committed May 28, 2013
1 parent 4e5caf5 commit e284492
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 11 deletions.
80 changes: 73 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,81 @@
exodev_gpio
gpio
===========

sysfs GPIO port driver and erlang module.
gpio is a device driver application for GPIO (General Purpose IO) written in erlang and C.

Please ensure that the exodev_gpio repo is cloned to a local directory called "gpio":
git clone git@github.com:Feuerlabs/exodev_gpio gpio
IO-pins are accessed either in a generic, Linux-based, way using control files or by direct memory acces. <br>
Direct memory acces is currently implemented for the following processors:
<ul>
<li>bcm 2835 (Raspberry Pi)</li>
</ul>

If this is not done, the code:priv_dir() will bomb out and gpio:open_pin() will fail.
### Dependencies

application:start(gpio), gpio:open_pin(1, output, low), gpio:sequence(1, [ 2000, 2000, 2000 ]).
To build gpio you will need a working installation of Erlang R15B (or
later).<br/>
Information on building and installing [Erlang/OTP](http://www.erlang.org)
can be found [here](https://github.com/erlang/otp/wiki/Installation)
([more info](https://github.com/erlang/otp/blob/master/INSTALL.md)).

gpio:sequence(1, [2000, 2000, 2000]).
gpio is built using rebar that can be found [here](https://github.com/basho/rebar), with building instructions [here](https://github.com/basho/rebar/wiki/Building-rebar).

### Downloading

Clone the repository in a suitable location:

```
$ git clone git://github.com/tonyrog/gpio.git
```
### Run

gpio is started in a standard erlang fashion:

```
$ erl
```

```
(node@host) 1> application:start(gpio).
```

### API

The interface has the following functions for accessing a single pin:
<ul>
<li>init</li>
<li>init_direct</li>
<li>release</li>
<li>set</li>
<li>get</li>
<li>clr</li>
<li>input</li>
<li>output</li>
<li>set_direction</li>
<li>get_direction</li>
<li>set_interrupt</li>
<li>get_interrupt</li>
</ul>

The interface has the following functions for accessing several pins using a mask:
<ul>
<li>set_mask</li>
<li>get_mask</li>
<li>clr_mask</li>
</ul>

For details see the generated documentation.

### Documentation

gpio is documented using edoc.
To generate the documentation do:

```
$ cd gpio
```

```
$ rebar doc
```

The result is a collection of html-documents under ```gpio/doc```.
10 changes: 9 additions & 1 deletion src/gpio_app.erl
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
%%%---- BEGIN COPYRIGHT -------------------------------------------------------
%%%
%%% Copyright (C) 2012 Feuerlabs, Inc. All rights reserved.
%%% Copyright (C) 2013 Feuerlabs, Inc. All rights reserved.
%%%
%%% This Source Code Form is subject to the terms of the Mozilla Public
%%% License, v. 2.0. If a copy of the MPL was not distributed with this
%%% file, You can obtain one at http://mozilla.org/MPL/2.0/.
%%%
%%%---- END COPYRIGHT ---------------------------------------------------------
%%% @author Magnus Feuer <magnus@feuerlabs.com>
%%% @author Malotte W Lönne <malotte@malotte.net>
%%% @copyright (C) 2013, Feuerlabs, Inc.
%%% @doc
%%% GPIO application
%%%
%%% Created: 2012 by Magnus Feuer
%%% @end
-module(gpio_app).

-behaviour(application).
Expand Down
14 changes: 13 additions & 1 deletion src/gpio_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
-include("gpio.hrl").

%% API
-export([start_link/1]).
-export([start_link/1,
stop/0]).

%% gen_server callbacks
-export([init/1,
Expand Down Expand Up @@ -56,6 +57,17 @@ start_link(Args) ->

gen_server:F({local, ?GPIO_SRV}, ?MODULE, Args, []).

%%--------------------------------------------------------------------
%% @doc
%% Stops the server.
%% @end
%%--------------------------------------------------------------------
-spec stop() -> ok | {error, Error::term()}.

stop() ->
gen_server:call(?GPIO_SRV, stop).


%%--------------------------------------------------------------------
%% @private
%% @doc
Expand Down
13 changes: 11 additions & 2 deletions src/gpio_sup.erl
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
%%%---- BEGIN COPYRIGHT -------------------------------------------------------
%%%
%%% Copyright (C) 2012 Feuerlabs, Inc. All rights reserved.
%%% Copyright (C) 2013 Feuerlabs, Inc. All rights reserved.
%%%
%%% This Source Code Form is subject to the terms of the Mozilla Public
%%% License, v. 2.0. If a copy of the MPL was not distributed with this
%%% file, You can obtain one at http://mozilla.org/MPL/2.0/.
%%%
%%%---- END COPYRIGHT ---------------------------------------------------------
%%% @author Magnus Feuer <magnus@feuerlabs.com>
%%% @author Malotte W Lönne <malotte@malotte.net>
%%% @copyright (C) 2013, Feuerlabs, Inc.
%%% @doc
%%% GPIO application supervisor
%%%
%%% Created: 2012 by Magnus Feuer
%%% @end

-module(gpio_sup).
-behaviour(supervisor).
Expand All @@ -32,8 +40,9 @@
%%--------------------------------------------------------------------
-type option()::
no_auto_create |
chipset |
debug |
chip_set.
linked.

-spec start_link(Args::list({option(), Value::term()})) ->
{ok, Pid::pid()} |
Expand Down

0 comments on commit e284492

Please sign in to comment.