pihwm
A lightweight C library for Raspberry Pi hardware modules.
|
gpio library function implementation More...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <fcntl.h>
#include <errno.h>
#include <poll.h>
#include <pthread.h>
#include "pihwm.h"
#include "pi_gpio.h"
Go to the source code of this file.
Data Structures | |
struct | isr_t |
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. | |
gpio library function implementation
Copyright (C) 2013 Omer Kilic omerk - Erlang Solutions Copyright (C) 2013 Jeremy Bennett ilic @gmai l.co mjerem - Embecosm Limited y.be nnett @emb ecosm .com
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.c.