From e695543ca6226f54b10c7f387b9dec704c462de2 Mon Sep 17 00:00:00 2001 From: RobTillaart Date: Thu, 27 Apr 2017 00:43:41 +0200 Subject: [PATCH] + FastShiftIn version 0.1.3 + optimized masking --- libraries/FastShiftIn/FastShiftIn.cpp | 8 ++++---- libraries/FastShiftIn/FastShiftIn.h | 4 ++-- libraries/FastShiftIn/library.json | 2 +- libraries/FastShiftIn/library.properties | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/FastShiftIn/FastShiftIn.cpp b/libraries/FastShiftIn/FastShiftIn.cpp index 616b4f59..e3e22d25 100644 --- a/libraries/FastShiftIn/FastShiftIn.cpp +++ b/libraries/FastShiftIn/FastShiftIn.cpp @@ -1,7 +1,7 @@ // // FILE: FastShiftIn.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.02 +// VERSION: 0.1.3 // PURPOSE: shiftin // DATE: 2013-09-29 // URL: @@ -37,7 +37,7 @@ int FastShiftIn::read() { _value = 0; - for (uint8_t i = 0; i < 8; i++) + for (uint8_t i = 0, m = 1, n = 128; i < 8; i++, m <<=1, n >>= 1) { uint8_t oldSREG = SREG; cli(); @@ -46,9 +46,9 @@ int FastShiftIn::read() if ((*_datain & _databit) > 0) { if (_bitorder == LSBFIRST) - _value |= (1 << i); + _value |= m; else - _value |= (1 << (7 - i)); + _value |= n; } *_clockin &= ~_clockbit; SREG = oldSREG; diff --git a/libraries/FastShiftIn/FastShiftIn.h b/libraries/FastShiftIn/FastShiftIn.h index a408506b..2b163bfe 100644 --- a/libraries/FastShiftIn/FastShiftIn.h +++ b/libraries/FastShiftIn/FastShiftIn.h @@ -1,7 +1,7 @@ // // FILE: FastShiftIn.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.01 +// VERSION: 0.1.3 // PURPOSE: shiftin // DATE: 2013-09-29 // URL: @@ -18,7 +18,7 @@ #include "WProgram.h" #endif -#define FASTSHIFTIN_LIB_VERSION "0.1.01" +#define FASTSHIFTIN_LIB_VERSION "0.1.3" #define FASTSHIFTIN_NOVALUE -1 diff --git a/libraries/FastShiftIn/library.json b/libraries/FastShiftIn/library.json index 8f06781b..c20e24e7 100644 --- a/libraries/FastShiftIn/library.json +++ b/libraries/FastShiftIn/library.json @@ -1,7 +1,7 @@ { "name": "FastShiftIn", "keywords": "Shift in serial ", - "description": "Class for up to 2x faster shift in.", + "description": "Class for up to 3x faster shift in.", "authors": [ { diff --git a/libraries/FastShiftIn/library.properties b/libraries/FastShiftIn/library.properties index 79ee75de..cd7b34e8 100644 --- a/libraries/FastShiftIn/library.properties +++ b/libraries/FastShiftIn/library.properties @@ -1,8 +1,8 @@ name=FastShiftIn -version=0.1.01 +version=0.1.3 author=Rob Tillaart maintainer=Rob Tillaart -sentence=Class for up to 2x faster shift in. +sentence=Class for up to 3x faster shift in. paragraph= category=Signal Input/Output url=https://github.com/RobTillaart/Arduino/Libraries/