mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
46 lines
918 B
C++
46 lines
918 B
C++
#pragma once
|
|
//
|
|
// FILE: FastShiftIn.h
|
|
// AUTHOR: Rob Tillaart
|
|
// VERSION: 0.2.3
|
|
// PURPOSE: Fast ShiftIn for 74HC165 register, AVR optimized
|
|
// DATE: 2013-09-29
|
|
// URL: https://github.com/RobTillaart/FastShiftIn
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
#define FASTSHIFTIN_LIB_VERSION (F("0.2.3"))
|
|
|
|
|
|
class FastShiftIn
|
|
{
|
|
public:
|
|
// bitOrder = { LSBFIRST, MSBFIRST };
|
|
FastShiftIn(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
|
|
|
|
int read(void);
|
|
int lastRead(void) { return _value; };
|
|
|
|
bool setBitOrder(const uint8_t bitOrder);
|
|
uint8_t getBitOrder(void) { return _bitorder; };
|
|
|
|
// overrule bitOrder (most optimized).
|
|
int readLSBFIRST(void);
|
|
int readMSBFIRST(void);
|
|
|
|
private:
|
|
uint8_t _bitorder;
|
|
int _value;
|
|
|
|
uint8_t _databit;
|
|
volatile uint8_t *_datain;
|
|
|
|
uint8_t _clockbit;
|
|
volatile uint8_t *_clockin;
|
|
};
|
|
|
|
|
|
// -- END OF FILE --
|