Skip to content

Instantly share code, notes, and snippets.

@mokele
Created April 15, 2013 22:45
Show Gist options
  • Save mokele/5391922 to your computer and use it in GitHub Desktop.
Save mokele/5391922 to your computer and use it in GitHub Desktop.
static ERL_NIF_TERM
gpio_read_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
int pin;
if (!enif_get_int(env, argv[0], &pin))
{
return enif_make_badarg(env);
}
int read = gpio_read(pin);
if(read == -1) {
return error_failed_tuple;
} else {
return enif_make_int(env, read);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment