PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
input.c
1 /*
2  * @file input.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 input 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 int input(int pin) // input function definition
20 {
21  int mask = 1 << pin; // Set up mask
22  DIRA &= ~mask; // AND DIRA with NOT mask
23  return (INA & mask) >> pin; // Return input state
24 }
25 
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,...
input
int input(int pin)
Set an I/O pin to input and return 1 if pin detects a high signal, or 0 if it detects low.
Definition: input.c:19
DIRA
#define DIRA
Use to set pins to input (0) or output (1).
Definition: propeller1.h:161