GPIO library functions.
More...
|
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.
|
|
GPIO library functions.
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.
- Parameters
-
Pin | number which has an interrupt attached |
- Returns
- Returns 1 on success. Never fails
Definition at line 304 of file pi_gpio.c.
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.
- Parameters
-
pin | Pin number |
dir | Direction of pin (input or output) |
- Returns
- 1 for success, -1 for failure
Definition at line 125 of file pi_gpio.c.
int gpio_read |
( |
unsigned int |
pin | ) |
|
Read the value on the pin numbered pin on the Raspberry Pi P1 header.
- Parameters
-
pin | Pin number to read from |
- Returns
- On success, returns 0 or 1 depending on whether the pin is low or high respectively. On failure returns -1.
Definition at line 366 of file pi_gpio.c.
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.
- Parameters
-
- Returns
- 1 for success, -1 for failure
Definition at line 398 of file pi_gpio.c.
int gpio_set_int |
( |
unsigned int |
pin, |
|
|
void(*)(int) |
isr, |
|
|
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.
- Parameters
-
pin | Pin number to attach interrupt to |
isr | Interrupt service routine to call |
mode | Interrupt mode |
- Returns
- Returns 1 on success. Never fails
Definition at line 275 of file pi_gpio.c.
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/.
- Parameters
-
pin | Pin number to write to |
val | Value to set (0 or 1) |
- Returns
- 1 for success, -1 for failure
Definition at line 322 of file pi_gpio.c.