PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
getState.c
1 /*
2  * @file getState.c
3  *
4  * @author Andy Lindsay
5  *
6  * @version 0.85
7  *
8  * @copyright Copyright (C) Parallax, Inc. 2012. See end of file for
9  * terms of use (MIT License).
10  *
11  * @brief getState function source, see simpletools.h for documentation.
12  *
13  * @detail Please submit bug reports, suggestions, and improvements to
14  * this code to editor@parallax.com.
15  */
16 
17 #include "simpletools.h" // simpletools function prototypes
18 
19 unsigned int get_state(int pin) // getState function definition
20 {
21  unsigned int pinstate = INA; // Copy INA
22  return (pinstate >> pin) & 1; // Shift right, mask, return
23 }
24 
INA
#define INA
Use to read the pins when corresponding DIRA bits are 0.
Definition: propeller1.h:153
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
get_state
unsigned int get_state(int pin)
Check the state of an I/O pin without setting it to input.
Definition: getState.c:19