PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
setDirections.c
1 /*
2  * @file count.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 count 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" // Include simpletools function defs
18 
19 void set_directions(int endPin, int startPin, unsigned int pattern)
20 {
21  if(endPin < startPin) // Handle reverse pin size
22  {
23  int temp = startPin;
24  startPin = endPin;
25  endPin = temp;
26  }
27  unsigned int andMask = -1;
28  andMask <<= (31 - (endPin-startPin));
29  andMask >>= (31 - endPin);
30  andMask = ~andMask;
31  unsigned int orMask = pattern << (startPin);
32  DIRA = (DIRA & andMask) | orMask;
33 }
34 
set_directions
void set_directions(int endPin, int startPin, unsigned int pattern)
Set directions for a contiguous group of I/O pins.
Definition: setDirections.c:19
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
DIRA
#define DIRA
Use to set pins to input (0) or output (1).
Definition: propeller1.h:161