GY-63_MS5611/libraries/FastShiftIn/FastShiftIn.h

46 lines
918 B
C
Raw Normal View History

2020-11-27 05:16:22 -05:00
#pragma once
//
// FILE: FastShiftIn.h
// AUTHOR: Rob Tillaart
2021-12-17 09:14:55 -05:00
// VERSION: 0.2.3
2020-11-27 05:16:22 -05:00
// PURPOSE: Fast ShiftIn for 74HC165 register, AVR optimized
// DATE: 2013-09-29
2020-11-27 05:16:22 -05:00
// URL: https://github.com/RobTillaart/FastShiftIn
2021-01-29 06:31:58 -05:00
#include "Arduino.h"
2021-01-29 06:31:58 -05:00
2021-12-17 09:14:55 -05:00
#define FASTSHIFTIN_LIB_VERSION (F("0.2.3"))
2021-01-29 06:31:58 -05:00
class FastShiftIn
{
public:
2021-12-17 09:14:55 -05:00
// bitOrder = { LSBFIRST, MSBFIRST };
2020-11-27 05:16:22 -05:00
FastShiftIn(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
2021-01-29 06:31:58 -05:00
int read(void);
int lastRead(void) { return _value; };
bool setBitOrder(const uint8_t bitOrder);
uint8_t getBitOrder(void) { return _bitorder; };
2020-11-27 05:16:22 -05:00
2021-12-17 09:14:55 -05:00
// overrule bitOrder (most optimized).
2021-01-29 06:31:58 -05:00
int readLSBFIRST(void);
int readMSBFIRST(void);
private:
2020-11-27 05:16:22 -05:00
uint8_t _bitorder;
2021-01-29 06:31:58 -05:00
int _value;
2020-11-27 05:16:22 -05:00
uint8_t _databit;
volatile uint8_t *_datain;
2020-11-27 05:16:22 -05:00
uint8_t _clockbit;
volatile uint8_t *_clockin;
};
2021-12-17 09:14:55 -05:00
2020-11-27 05:16:22 -05:00
// -- END OF FILE --