annotate include/GPIOcontrol.h @ 456:aa3f38d8a9b6 prerelease

using relative links in examples/core
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 20 Jun 2016 01:10:16 +0100
parents 8a575ba3ab52
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 * SimpleGPIO.h
andrewm@0 3 *
andrewm@0 4 * Copyright Derek Molloy, School of Electronic Engineering, Dublin City University
andrewm@0 5 * www.derekmolloy.ie
andrewm@0 6 *
andrewm@0 7 * Based on Software by RidgeRun
andrewm@0 8 * Copyright (c) 2011, RidgeRun
andrewm@0 9 * All rights reserved.
andrewm@0 10 *
andrewm@0 11 * Redistribution and use in source and binary forms, with or without
andrewm@0 12 * modification, are permitted provided that the following conditions are met:
andrewm@0 13 * 1. Redistributions of source code must retain the above copyright
andrewm@0 14 * notice, this list of conditions and the following disclaimer.
andrewm@0 15 * 2. Redistributions in binary form must reproduce the above copyright
andrewm@0 16 * notice, this list of conditions and the following disclaimer in the
andrewm@0 17 * documentation and/or other materials provided with the distribution.
andrewm@0 18 * 3. All advertising materials mentioning features or use of this software
andrewm@0 19 * must display the following acknowledgement:
andrewm@0 20 * This product includes software developed by the RidgeRun.
andrewm@0 21 * 4. Neither the name of the RidgeRun nor the
andrewm@0 22 * names of its contributors may be used to endorse or promote products
andrewm@0 23 * derived from this software without specific prior written permission.
andrewm@0 24 *
andrewm@0 25 * THIS SOFTWARE IS PROVIDED BY RIDGERUN ''AS IS'' AND ANY
andrewm@0 26 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
andrewm@0 27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
andrewm@0 28 * DISCLAIMED. IN NO EVENT SHALL RIDGERUN BE LIABLE FOR ANY
andrewm@0 29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
andrewm@0 30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
andrewm@0 31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
andrewm@0 32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
andrewm@0 33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
andrewm@0 34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
andrewm@0 35 */
andrewm@0 36
andrewm@0 37 #ifndef SIMPLEGPIO_H_
andrewm@0 38 #define SIMPLEGPIO_H_
andrewm@0 39
andrewm@0 40 /****************************************************************
andrewm@0 41 * Constants
andrewm@0 42 ****************************************************************/
andrewm@0 43
andrewm@0 44 #define SYSFS_GPIO_DIR "/sys/class/gpio"
andrewm@0 45 #define SYSFS_LED_DIR "/sys/class/leds"
andrewm@0 46 #define POLL_TIMEOUT (3 * 1000) /* 3 seconds */
andrewm@0 47 #define MAX_BUF 128
andrewm@0 48
andrewm@0 49 enum PIN_DIRECTION{
andrewm@0 50 INPUT_PIN=0,
andrewm@0 51 OUTPUT_PIN=1
andrewm@0 52 };
andrewm@0 53
andrewm@0 54 enum PIN_VALUE{
andrewm@0 55 LOW=0,
andrewm@0 56 HIGH=1
andrewm@0 57 };
andrewm@0 58
andrewm@0 59 /****************************************************************
andrewm@0 60 * gpio_functions
andrewm@0 61 ****************************************************************/
andrewm@0 62 int gpio_setup(unsigned int gpio, int out_flag);
andrewm@0 63 int gpio_export(unsigned int gpio);
andrewm@0 64 int gpio_unexport(unsigned int gpio);
andrewm@0 65 int gpio_set_dir(unsigned int gpio, int out_flag);
andrewm@0 66 int gpio_set_value(unsigned int gpio, int value);
andrewm@0 67 int gpio_get_value(unsigned int gpio, unsigned int *value);
andrewm@0 68 int gpio_set_edge(unsigned int gpio, char *edge);
andrewm@0 69 int gpio_fd_open(unsigned int gpio, int writeFlag);
andrewm@0 70 int gpio_fd_close(int fd);
andrewm@0 71 int gpio_write(int fd, int value);
andrewm@0 72 int gpio_read(int fd, unsigned int *value);
andrewm@0 73 int gpio_dismiss(int fd, unsigned int gpio);
andrewm@0 74
andrewm@0 75 int led_set_trigger(unsigned int lednum, const char *trigger);
andrewm@0 76
andrewm@0 77 #endif /* SIMPLEGPIO_H_ */