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

66 lines
1.3 KiB
C
Raw Normal View History

2020-11-27 05:16:22 -05:00
#pragma once
2013-08-28 16:30:00 -04:00
//
// FILE: FastShiftOut.h
// AUTHOR: Rob Tillaart
2024-09-19 08:17:25 -04:00
// VERSION: 0.4.0
2021-12-17 09:24:28 -05:00
// PURPOSE: shiftOut class that implements the Print interface
// 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
2021-05-28 07:26:27 -04:00
#include "Arduino.h"
#include "Print.h"
2024-09-19 08:17:25 -04:00
#define FASTSHIFTOUT_LIB_VERSION (F("0.4.0"))
// uncomment next line to get SPEED OPTIMIZED CODE
#define FASTSHIFTOUT_AVR_LOOP_UNROLLED 1
2021-05-28 07:26:27 -04:00
2020-11-27 05:16:22 -05:00
class FastShiftOut : public Print
2013-08-28 16:30:00 -04:00
{
public:
2021-12-17 09:24:28 -05:00
// bitOrder = { LSBFIRST, MSBFIRST };
2022-11-06 14:23:19 -05:00
FastShiftOut(uint8_t dataOut, uint8_t clockPin, uint8_t bitOrder = LSBFIRST);
2021-12-17 09:24:28 -05:00
2022-11-06 14:23:19 -05:00
size_t write(uint8_t data);
uint8_t lastWritten(void);
2021-01-29 06:31:58 -05:00
2024-07-23 07:33:00 -04:00
// EXPERIMENTAL (wrappers)
size_t write16(uint16_t data);
size_t write24(uint32_t data);
size_t write32(uint32_t data);
size_t write(uint8_t * array, size_t size);
// META
2022-11-06 14:23:19 -05:00
bool setBitOrder(uint8_t bitOrder);
uint8_t getBitOrder(void);
2020-11-27 05:16:22 -05:00
2024-07-23 07:33:00 -04:00
// overrule bitOrder, most optimized.
2022-11-06 14:23:19 -05:00
size_t writeLSBFIRST(uint8_t data);
size_t writeMSBFIRST(uint8_t data);
2013-08-28 16:30:00 -04:00
private:
2022-11-06 14:23:19 -05:00
uint8_t _bitOrder;
2024-09-19 08:17:25 -04:00
uint8_t _lastValue;
2022-11-06 14:23:19 -05:00
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR)
volatile uint8_t *_dataOutRegister;
uint8_t _dataOutBit;
volatile uint8_t *_clockRegister;
uint8_t _clockBit;
#else
uint8_t _dataPinOut;
uint8_t _clockPin;
#endif
2013-08-28 16:30:00 -04:00
};
2021-05-28 07:26:27 -04:00
2024-09-19 08:17:25 -04:00
// -- END OF FILE --