Permalink
Browse files

Adapt to GPIO mode changes in the WiringPi API

Remove the gpio_mode function, since the wiringPiGpioMode function in
the WiringPi C API has been removed and replaced by new setup
functions. Note that this library currently only supports
wiringPiSetup(), not wiringPiSetupGpio() nor wiringPiSetupSys().

This means that it's currently only possible to use the WiringPi pin
numbering scheme outlined here:

    https://projects.drogon.net/raspberry-pi/wiringpi/pins/
  • Loading branch information...
1 parent f26bc78 commit a104cd854cec7c15249df52b8dbc7ab2786abd41 @klajo committed Jul 21, 2012
Showing with 10 additions and 23 deletions.
  1. +10 −4 README.md
  2. +0 −13 c_src/wpi.c
  3. +0 −6 src/wpi.erl
View
@@ -17,10 +17,10 @@ useful constants (matches those of WiringPi):
-include_lib("wpi/include/wpi.hrl").
-Then you can start setting up the pins and use them:
+Then you can start setting up the [pins][4] and use them:
- Pin = 4,
- wpi:gpio_mode(?WPI_MODE_GPIO),
+ application:start(wpi),
+ Pin = 7,
wpi:pin_mode(Pin, ?WPI_OUTPUT),
wpi:digital_write(Pin, ?WPI_HIGH),
@@ -31,6 +31,11 @@ This NIF is entirely experimental - use at your own risk. It has been
used to both write to (LED) and read from (button) pins successfully,
while some functionality may be untested.
+This library currently only supports wiringPiSetup(), not
+wiringPiSetupGpio() nor wiringPiSetupSys(). This means that it's
+currently only possible to use the WiringPi pin numbering scheme
+outlined in the [pins][4] section.
+
Contributions
-------------
@@ -43,4 +48,5 @@ Credits go to Gordon Henderson for the WiringPi library.
[1]: https://projects.drogon.net/raspberry-pi/wiringpi/
[2]: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
-[3]: https://github.com/basho/rebar/
+[3]: https://github.com/basho/rebar/
+[4]: https://projects.drogon.net/raspberry-pi/wiringpi/pins/
View
@@ -23,18 +23,6 @@ load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
return wiringPiSetup(); // returns -1 in case of error ==> loading fails
}
-static ERL_NIF_TERM
-gpio_mode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
-{
- int mode;
- if (!enif_get_int(env, argv[0], &mode))
- {
- return enif_make_badarg(env);
- }
- wiringPiGpioMode(mode);
- return enif_make_atom(env, "ok");
-}
-
static ERL_NIF_TERM
pin_mode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
@@ -113,7 +101,6 @@ pull_up_dn_control(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
static ErlNifFunc nif_funcs[] =
{
- {"gpio_mode", 1, gpio_mode},
{"pin_mode", 2, pin_mode},
{"digital_write", 2, digital_write},
{"pwm_write", 2, pwm_write},
View
@@ -18,7 +18,6 @@
-include_lib("wpi/include/wpi.hrl").
--export([gpio_mode/1]).
-export([pin_mode/2]).
-export([digital_write/2]).
-export([pwm_write/2]).
@@ -30,7 +29,6 @@
-on_load(on_load/0).
--type wpi_gpio_mode() :: 0..1. % WPI_MODE_PINS|WPI_MODE_GPIO
-type wpi_pin_mode() :: 0..2. % WPI_INPUT|WPI_OUTPUT|WPI_PWM_OUTPUT
-type wpi_pin_number() :: integer().
-type wpi_digital_value() :: 0..1. % WPI_LOW|WPI_HIGH
@@ -40,10 +38,6 @@
on_load() ->
ok = erlang:load_nif(filename:join(code:priv_dir(wpi), "./wpi_drv"), 0).
--spec gpio_mode(wpi_gpio_mode()) -> ok.
-gpio_mode(_Mode) ->
- ?nif_stub.
-
-spec pin_mode(wpi_pin_number(), wpi_pin_mode()) -> ok.
pin_mode(_Pin, _Mode) ->
?nif_stub.

0 comments on commit a104cd8

Please sign in to comment.