GY-63_MS5611/libraries/FastShiftIn/FastShiftIn.h
2023-11-01 12:23:10 +01:00

60 lines
1.1 KiB
C++

#pragma once
//
// FILE: FastShiftIn.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.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.3.3"))
class FastShiftIn
{
public:
// bitOrder = { LSBFIRST, MSBFIRST };
FastShiftIn(uint8_t dataIn, uint8_t clockPin, uint8_t bitOrder = LSBFIRST);
uint16_t read(void);
uint16_t read16(void);
uint32_t read24(void);
uint32_t read32(void);
uint32_t lastRead(void);
// returns false if bitOrder out of range.
bool setBitOrder(uint8_t bitOrder);
uint8_t getBitOrder(void);
// overrule bitOrder (most optimized).
uint8_t readLSBFIRST(void);
uint8_t readMSBFIRST(void);
private:
uint8_t _bitOrder;
uint32_t _lastValue;
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
volatile uint8_t *_dataInRegister;
uint8_t _dataInBit;
volatile uint8_t *_clockRegister;
uint8_t _clockBit;
#else
uint8_t _dataPinIn;
uint8_t _clockPin;
#endif
};
// -- END OF FILE --