pihwm
A lightweight C library for Raspberry Pi hardware modules.
 All Data Structures Files Functions Groups Pages
pi_gpio.h File Reference

gpio library headers More...

Go to the source code of this file.

Macros

#define INPUT   1
 
#define OUTPUT   0
 
#define IN   INPUT
 
#define OUT   OUTPUT
 
#define HIGH   1
 
#define LOW   0
 
#define ON   HIGH
 
#define OFF   LOW
 
#define pinMode(pin, dir)   gpio_init(pin, dir);
 
#define digitalWrite(pin, val)   gpio_write(pin, val);
 
#define digitalRead(pin)   gpio_read(pin);
 
#define attachInterrupt(pin, isr, mode)   gpio_set_int(pin, isr, mode);
 
#define detachInterrupt(pin)   gpio_clear_int(pin);
 

Functions

int gpio_init (unsigned int pin, unsigned int dir)
 Initialize the GPIO interface for the pin numbered pin on the Raspberry Pi P1 header in the direction specified by dir. dir should be either "in" or "out", for which the defined constants INPUT, IN, OUTPUT or OUT may be used.
 
int gpio_set_int (unsigned int pin, void(*isr)(int), char *mode)
 Set isr as the interrupt service routine (ISR) for pin numbered pin on the Raspberry Pi P1 header. mode should be one of the strings "rising", "falling" or "both" to indicate which edge(s) the ISR is to be triggered on. The function isr is called whenever the edge specified occurs, receiving as argument the number of the pin which triggered the interrupt.
 
int gpio_clear_int (unsigned int pin)
 Clears any interrupt service routine (ISR) set on the pin numbered pin on the Raspberry Pi P1 header. The ISR will have been set originally by a call to gpio_set_int.
 
int gpio_write (unsigned int pin, unsigned int val)
 Set the pin numbered pin on the Raspberry Pi P1 header to the value specified by val. dir should be either "0" or "1". The defined constants LOW or OFF may be used instead of 0 and HIGH or ON instead of 1/.
 
int gpio_read (unsigned int pin)
 Read the value on the pin numbered pin on the Raspberry Pi P1 header.
 
int gpio_release (unsigned int pin)
 The inverse of gpio_init. Frees the pin numbered pin on the Raspberry Pi P1 header, so it can be used for other purposes.
 

Detailed Description

gpio library headers

Author
Omer Kilic omerk.nosp@m.ilic.nosp@m.@gmai.nosp@m.l.co.nosp@m.m - Erlang Solutions
Jeremy Bennett jerem.nosp@m.y.be.nosp@m.nnett.nosp@m.@emb.nosp@m.ecosm.nosp@m..com - Embecosm Limited

LICENSE

Copyright (C) 2013 Omer Kilic omerk.nosp@m.ilic.nosp@m.@gmai.nosp@m.l.co.nosp@m.m - Erlang Solutions Copyright (C) 2013 Jeremy Bennett jerem.nosp@m.y.be.nosp@m.nnett.nosp@m.@emb.nosp@m.ecosm.nosp@m..com - Embecosm Limited

This file is part of pihwm http://omerk.github.io/pihwm

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition in file pi_gpio.h.