46 lines
1004 B
C
Raw Normal View History

2020-11-27 11:16:22 +01:00
#pragma once
2013-08-28 22:30:00 +02:00
//
// FILE: FastShiftOut.h
// AUTHOR: Rob Tillaart
2021-12-17 15:24:28 +01:00
// VERSION: 0.2.4
// PURPOSE: shiftOut class that implements the Print interface
// DATE: 2013-08-22
2020-11-27 11:16:22 +01:00
// URL: https://github.com/RobTillaart/FastShiftOut
2013-08-28 22:30:00 +02:00
2021-05-28 13:26:27 +02:00
#include "Arduino.h"
#include "Print.h"
2021-12-17 15:24:28 +01:00
#define FASTSHIFTOUT_LIB_VERSION (F("0.2.4"))
2021-05-28 13:26:27 +02:00
2020-11-27 11:16:22 +01:00
class FastShiftOut : public Print
2013-08-28 22:30:00 +02:00
{
public:
2021-12-17 15:24:28 +01:00
// bitOrder = { LSBFIRST, MSBFIRST };
2020-11-27 11:16:22 +01:00
FastShiftOut(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
2021-12-17 15:24:28 +01:00
2021-01-29 12:31:58 +01:00
size_t write(const uint8_t data);
uint8_t lastWritten(void) { return _value; };
bool setBitOrder(const uint8_t bitOrder);
uint8_t getBitOrder(void) { return _bitorder; };
2020-11-27 11:16:22 +01:00
2021-12-17 15:24:28 +01:00
// overrule bitOrder (most optimized).
2021-01-29 12:31:58 +01:00
size_t writeLSBFIRST(const uint8_t data);
size_t writeMSBFIRST(const uint8_t data);
2013-08-28 22:30:00 +02:00
private:
2020-11-27 11:16:22 +01:00
uint8_t _bitorder;
2021-01-29 12:31:58 +01:00
int _value;
2020-11-27 11:16:22 +01:00
uint8_t _databit;
volatile uint8_t *_dataout;
2020-11-27 11:16:22 +01:00
uint8_t _clockbit;
volatile uint8_t *_clockout;
2013-08-28 22:30:00 +02:00
};
2021-05-28 13:26:27 +02:00
2020-11-27 11:16:22 +01:00
// -- END OF FILE --