0.1.2 FastShiftInOut

This commit is contained in:
rob tillaart 2022-11-06 20:27:03 +01:00
parent da4aa5057d
commit c965e8355f
8 changed files with 54 additions and 15 deletions

View File

@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.2] - 2022-11-06
- redo clock pulse to match fastShiftOut
(after write and before read)
## [0.1.1] - 2022-11-05
- optimize AVR

View File

@ -1,7 +1,7 @@
//
// FILE: FastShiftInOut.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.1.2
// PURPOSE: Arduino library for (AVR) optimized shiftInOut (simultaneously)
// URL: https://github.com/RobTillaart/FastShiftInOut
//
@ -74,12 +74,14 @@ uint8_t FastShiftInOut::writeLSBFIRST(uint8_t data)
{
uint8_t oldSREG = SREG;
noInterrupts();
// write one bit
*_clockRegister |= cbmask1;
// write one bit
if ((value & m) == 0) *_dataOutRegister &= outmask2;
else *_dataOutRegister |= outmask1;
// clock pulse HIGH
*_clockRegister |= cbmask1;
// read one bit
if ((*_dataInRegister & inmask1) > 0) rv |= m;
// clock pulse LOW
*_clockRegister &= cbmask2;
SREG = oldSREG;
}
@ -90,12 +92,14 @@ uint8_t FastShiftInOut::writeLSBFIRST(uint8_t data)
for (uint8_t i = 0; i < 8; i++)
{
// write one bit
digitalWrite(_clockPin, HIGH);
digitalWrite(_dataPinOut, value & 0x01);
value >>= 1;
// clock pulse
digitalWrite(_clockPin, HIGH);
// read one bit
rv >>= 1;
if (digitalRead(_dataPinIn) == HIGH) rv |= 0x80;
// clock pulse
digitalWrite(_clockPin, LOW);
}
@ -123,12 +127,14 @@ uint8_t FastShiftInOut::writeMSBFIRST(uint8_t data)
{
uint8_t oldSREG = SREG;
noInterrupts();
// write one bit
*_clockRegister |= cbmask1;
// write one bit
if ((value & m) == 0) *_dataOutRegister &= outmask2;
else *_dataOutRegister |= outmask1;
// clock pulse HIGH
*_clockRegister |= cbmask1;
// read one bit
if ((*_dataInRegister & inmask1) > 0) rv |= m;
// clock pulse LOW
*_clockRegister &= cbmask2;
SREG = oldSREG;
}
@ -139,12 +145,14 @@ uint8_t FastShiftInOut::writeMSBFIRST(uint8_t data)
for (uint8_t i = 0; i < 8; i++)
{
// write one bit
digitalWrite(_clockPin, HIGH);
digitalWrite(_dataPinOut, value & 0x80);
value <<= 1;
// clock pulse
digitalWrite(_clockPin, HIGH);
// read one bit
rv <<= 1;
if (digitalRead(_dataPinIn) == HIGH) rv |= 1;
// clock pulse
digitalWrite(_clockPin, LOW);
}

View File

@ -2,14 +2,15 @@
//
// FILE: FastShiftInOut.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// VERSION: 0.1.2
// PURPOSE: Arduino library for (AVR) optimized shiftInOut (simultaneously)
// URL: https://github.com/RobTillaart/FastShiftInOut
#include "Arduino.h"
#define FASTSHIFTINOUT_LIB_VERSION (F("0.1.1"))
#define FASTSHIFTINOUT_LIB_VERSION (F("0.1.2"))
class FastShiftInOut

View File

@ -8,10 +8,13 @@
# FastShiftInOut
Arduino library for (AVR) optimized shiftInOut (simultaneously).
Arduino library for **AVR** optimized shiftInOut (simultaneously).
- library for FastShiftIn only - https://github.com/RobTillaart/FastShiftIn
- library for FastShiftOut only - https://github.com/RobTillaart/FastShiftOut
Related libraries
- https://github.com/RobTillaart/FastShiftIn
- https://github.com/RobTillaart/FastShiftOut
- https://github.com/RobTillaart/ShiftInSlow
- https://github.com/RobTillaart/ShiftOutSlow
## Description

View File

@ -22,7 +22,7 @@ done ...
IDE: 1.8.19
Board: ESP32
FASTSHIFTINOUT_LIB_VERSION: 0.1.0
FASTSHIFTINOUT_LIB_VERSION: 0.1.1
Performance - time in us
write: 4.37

View File

@ -0,0 +1,22 @@
IDE: 1.8.19
Board: UNO
FASTSHIFTINOUT_LIB_VERSION: 0.1.2
Performance - time in us
write: 27.86
write: 54.69
Delta: 26.84
writeLSBFIRST: 26.60
writeLSBFIRST: 53.06
Delta: 26.46
writeMSBFIRST: 26.60
writeMSBFIRST: 53.06
Delta: 26.46
done ...

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/FastShiftInOut.git"
},
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

@ -1,5 +1,5 @@
name=FastShiftInOut
version=0.1.1
version=0.1.2
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for (AVR) optimized shiftInOut (simultaneously)