From 601da777ad2719eb3cc413a5bf1c46be2b10df47 Mon Sep 17 00:00:00 2001 From: tharexde Date: Wed, 17 Jun 2020 23:38:49 +0200 Subject: [PATCH] replaced function msb2lsb(...) by already existing function reflect8(...) --- armsrc/em4x50.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/armsrc/em4x50.c b/armsrc/em4x50.c index 60f271c21..eb2704a2c 100644 --- a/armsrc/em4x50.c +++ b/armsrc/em4x50.c @@ -12,6 +12,7 @@ #include "ticks.h" #include "dbprint.h" #include "lfadc.h" +#include "commonutil.h" #include "em4x50.h" // 4 data bytes @@ -118,28 +119,16 @@ static uint8_t bits2byte(uint8_t bits[8], int length) { return byte; } -static uint8_t msb2lsb(uint8_t byte) { - - // returns byte with bit positions in reverse order - - uint8_t tmp = 0; - - for (int i = 0; i < 8; i++) - tmp |= ((byte >> (7-i)) & 1) << i; - - return tmp; -} - static void msb2lsb_word(uint8_t *word) { // reorders given according to EM4x50 datasheet (msb -> lsb) uint8_t buff[4]; - buff[0] = msb2lsb(word[3]); - buff[1] = msb2lsb(word[2]); - buff[2] = msb2lsb(word[1]); - buff[3] = msb2lsb(word[0]); + buff[0] = reflect8(word[3]); + buff[1] = reflect8(word[2]); + buff[2] = reflect8(word[1]); + buff[3] = reflect8(word[0]); word[0] = buff[0]; word[1] = buff[1];