From e28449207e84cb1f6c1552a73854bd9418540d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malotte=20Westman=20Lo=CC=88nne?= Date: Tue, 28 May 2013 15:10:11 +0200 Subject: [PATCH] Updated documentation. --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++---- src/gpio_app.erl | 10 +++++- src/gpio_server.erl | 14 +++++++- src/gpio_sup.erl | 13 ++++++-- 4 files changed, 106 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ee90cf3..bae3726 100644 --- a/README.md +++ b/README.md @@ -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.
+Direct memory acces is currently implemented for the following processors: + -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).
+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: + + +The interface has the following functions for accessing several pins using a mask: + + +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```. diff --git a/src/gpio_app.erl b/src/gpio_app.erl index ede83f7..48e7f93 100644 --- a/src/gpio_app.erl +++ b/src/gpio_app.erl @@ -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 +%%% @author Malotte W Lönne +%%% @copyright (C) 2013, Feuerlabs, Inc. +%%% @doc +%%% GPIO application +%%% +%%% Created: 2012 by Magnus Feuer +%%% @end -module(gpio_app). -behaviour(application). diff --git a/src/gpio_server.erl b/src/gpio_server.erl index 7d34ef2..ca1a200 100644 --- a/src/gpio_server.erl +++ b/src/gpio_server.erl @@ -24,7 +24,8 @@ -include("gpio.hrl"). %% API --export([start_link/1]). +-export([start_link/1, + stop/0]). %% gen_server callbacks -export([init/1, @@ -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 diff --git a/src/gpio_sup.erl b/src/gpio_sup.erl index 69818e7..6e68097 100644 --- a/src/gpio_sup.erl +++ b/src/gpio_sup.erl @@ -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 +%%% @author Malotte W Lönne +%%% @copyright (C) 2013, Feuerlabs, Inc. +%%% @doc +%%% GPIO application supervisor +%%% +%%% Created: 2012 by Magnus Feuer +%%% @end -module(gpio_sup). -behaviour(supervisor). @@ -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()} |