PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
setOutputs.c
1 /*
2  * @file setOutputs.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 setOutputs 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 // setOutputs function definition
20 void set_outputs(int endPin, int startPin, unsigned int pattern)
21 {
22  if(endPin < startPin) // Handle reverse pin size
23  {
24  int temp = startPin;
25  startPin = endPin;
26  endPin = temp;
27  }
28  unsigned int andMask = -1;
29  andMask <<= (31 - (endPin-startPin));
30  andMask >>= (31 - endPin);
31  andMask = ~andMask;
32  unsigned int orMask = pattern << (startPin);
33  OUTA = (OUTA & andMask) | orMask;
34 }
35 
OUTA
#define OUTA
Use to set output pin states when corresponding DIRA bits are 1.
Definition: propeller1.h:157
set_outputs
void set_outputs(int endPin, int startPin, unsigned int pattern)
Set output states for a contiguous group of I/O pins.
Definition: setOutputs.c:20
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...