libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
button.c File Reference

Example: get state of a button. More...

#include "stdio.h"
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include "../c_wrapper/pruio.h"
#include "../c_wrapper/pruio_pins.h"
Include dependency graph for button.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE   1
 Message for the compiler.
 
#define PIN   P8_07
 The header pin to use.
 

Functions

int isleep (unsigned int mseconds)
 Wait for keystroke or timeout. More...
 
int main (int argc, char **argv)
 The main function. More...
 

Detailed Description

Example: get state of a button.

This file contains an example on how to use libpruio to get the state of a button connetect to a GPIO pin on the beaglebone board. Here pin 7 on header P8 is used as input with pullup resistor. Connect the button between P8_07 (GPIO input) and P8_01 (GND).

Licence: GPLv3

Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net

Compile by: gcc -Wall -o button button.c -lpruio

Definition in file button.c.

Function Documentation

int isleep ( unsigned int  mseconds)

Wait for keystroke or timeout.

Parameters
msecondsTimeout value in milliseconds.
Returns
0 if timeout, 1 if input available, -1 on error.

Wait for a keystroke or timeout and return which of the events happened.

Definition at line 41 of file button.c.

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

The main function.

create new driver structure

Definition at line 60 of file button.c.

Here is the call graph for this function: