2020-11-27 05:16:22 -05:00
|
|
|
#pragma once
|
2013-08-28 16:30:00 -04:00
|
|
|
//
|
|
|
|
// FILE: FastShiftOut.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2020-11-27 05:16:22 -05:00
|
|
|
// VERSION: 0.2.1
|
2013-08-29 05:39:24 -04:00
|
|
|
// PURPOSE: shiftout that implements the Print interface
|
2013-09-29 06:38:05 -04:00
|
|
|
// DATE: 2013-08-22
|
2020-11-27 05:16:22 -05:00
|
|
|
// URL: https://github.com/RobTillaart/FastShiftOut
|
2013-08-28 16:30:00 -04:00
|
|
|
//
|
|
|
|
|
2015-03-06 09:37:48 -05:00
|
|
|
#include "Arduino.h"
|
2013-08-29 05:39:24 -04:00
|
|
|
#include "Print.h"
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
#define FASTSHIFTOUT_LIB_VERSION (F("0.2.1"))
|
|
|
|
|
2013-08-29 05:39:24 -04:00
|
|
|
class FastShiftOut : public Print
|
2013-08-28 16:30:00 -04:00
|
|
|
{
|
2015-03-06 09:37:48 -05:00
|
|
|
public:
|
2020-11-27 05:16:22 -05:00
|
|
|
// bitorder = { LSBFIRST, MSBFIRST };
|
|
|
|
FastShiftOut(const uint8_t datapin, const uint8_t clockpin, const uint8_t bitOrder = LSBFIRST);
|
|
|
|
size_t write(const uint8_t data);
|
|
|
|
|
|
|
|
// overrule bitorder (most optimized).
|
|
|
|
size_t writeLSBFIRST(const uint8_t data);
|
|
|
|
size_t writeMSBFIRST(const uint8_t data);
|
2013-08-28 16:30:00 -04:00
|
|
|
|
2015-03-06 09:37:48 -05:00
|
|
|
private:
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _bitorder;
|
2015-03-06 09:37:48 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _databit;
|
|
|
|
volatile uint8_t *_dataout;
|
2015-03-06 09:37:48 -05:00
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
uint8_t _clockbit;
|
|
|
|
volatile uint8_t *_clockout;
|
2013-08-28 16:30:00 -04:00
|
|
|
};
|
|
|
|
|
2020-11-27 05:16:22 -05:00
|
|
|
// -- END OF FILE --
|