ShiftIn/developers

From Wiring

Jump to: navigation, search
This page is intended as a reference for core developers only, and the content is only changed after a consensus has been reached through discussion of any such changes. Please use the Discussion page to talk about any changes or issues you have with the current implementation.
shiftIn()
Classification Bit shifting methods
Suggested location WShift.h
C++ required No
Timing constraints None
Version introduced 1.0 (0100)
Framework dependencies None
Prototype(s)
uint16_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t count, uint8_t delayTime)
Required? Yes
Issues None


Contents

Description

The shiftIn() method reads data one bit at a time.

Black Box Input

The pin used to receive data, the pin used as clock, the bit order (from MSBFIRST or LSBFIRST), the number of bits to read and the delay time are provided.

Black Box Output

int. The data read from the pin is returned.

Overloading

None. Single signature only.

Notes

shiftIn() can start from the most or the least significant bit (starts from leftmost or rightmost bit). This method is very useful to manage shift registers (like CD4021), which are devices that convert data from parallel to serial using one Wiring pin for receiving data, one for the clock, and one for the strobe (latch).

MSBFIRST stands for most significant bit first (leftmost bit), LSBFIRST stands for less significant bit first (rightmost bit).

Proposed Changes

For Wiring 1.1

According to Issue 9, pinRead() will be defined as:

uint16_t shiftIn(pin_t dataPin, pin_t clockPin, uint8_t bitOrder, uint8_t count, uint8_t delayTime)

See Issue 9 for more details.

Personal tools