2020-11-27 05:16:22 -05:00
|
|
|
#pragma once
|
2013-09-29 13:10:03 -04:00
|
|
|
//
|
|
|
|
// FILE: FastShiftIn.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2020-11-27 05:16:22 -05:00
|
|
|
// VERSION: 0.2.1
|
|
|
|
// PURPOSE: Fast ShiftIn for 74HC165 register, AVR optimized
|
2013-09-29 13:10:03 -04:00
|
|
|
// DATE: 2013-09-29
|
2020-11-27 05:16:22 -05:00
|
|
|
// URL: https://github.com/RobTillaart/FastShiftIn
|
2013-09-29 13:10:03 -04:00
|
|
|
//
|
|
|
|
|
2015-03-06 09:09:11 -05:00
|
|
|
#include "Arduino.h"
|
2013-09-29 13:10:03 -04:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
#define FASTSHIFTIN_LIB_VERSION (F("0.2.1"))
|
2013-09-29 13:10:03 -04:00
|
|
|
|
|
|
|
class FastShiftIn
|
|
|
|
{
|
2015-03-06 09:09:11 -05:00
|
|
|
public:
|
2020-11-27 05:16:22 -05:00
|
|
|
// bitorder = { LSBFIRST, MSBFIRST };
|
|
|
|
FastShiftIn(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
|
|
|
|
int read(void);
|
|
|
|
|
|
|
|
// overrule bitorder (most optimized).
|
|
|
|
int readLSBFIRST(void);
|
|
|
|
int readMSBFIRST(void);
|
2013-09-29 13:10:03 -04:00
|
|
|
|
2015-03-06 09:09:11 -05:00
|
|
|
private:
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _bitorder;
|
|
|
|
int _value;
|
2015-03-06 09:09:11 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _databit;
|
|
|
|
volatile uint8_t *_datain;
|
2015-03-06 09:09:11 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _clockbit;
|
|
|
|
volatile uint8_t *_clockin;
|
2013-09-29 13:10:03 -04:00
|
|
|
};
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
// -- END OF FILE --
|