From a5c40fa07b475db11db688304df6e5bddfeb7646 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 27 Jan 2021 23:30:37 +0100 Subject: [PATCH] minor renaming --- armsrc/Standalone/lf_em4100emul.c | 41 ++++++++++++++++++------------- armsrc/Standalone/lf_em4100rswb.c | 22 ++++++++--------- armsrc/Standalone/lf_em4100rwc.c | 12 ++++----- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/armsrc/Standalone/lf_em4100emul.c b/armsrc/Standalone/lf_em4100emul.c index e6ac2f6ff..dd44c843e 100644 --- a/armsrc/Standalone/lf_em4100emul.c +++ b/armsrc/Standalone/lf_em4100emul.c @@ -21,19 +21,19 @@ #include "commonutil.h" #define MAX_IND 16 // 4 LEDs - 2^4 combinations -#define CLOCK 64 //for 125kHz +#define LF_CLOCK 64 // for 125kHz // low & high - array for storage IDs. Its length must be equal. // Predefined IDs must be stored in low[]. static uint64_t low[] = {0x565A1140BE, 0x365A398149, 0x5555555555, 0xFFFFFFFFFF}; -static uint8_t *bba, slots_count; +static uint8_t slots_count; static int buflen; void ModInfo(void) { DbpString(" LF EM4100 simulator standalone mode"); } -static uint64_t ReversQuads(uint64_t bits) { +static uint64_t rev_quads(uint64_t bits) { uint64_t result = 0; for (int i = 0; i < 16; i++) { result += ((bits >> (60 - 4 * i)) & 0xf) << (4 * i); @@ -41,32 +41,40 @@ static uint64_t ReversQuads(uint64_t bits) { return result >> 24; } -static void FillBuff(uint8_t bit) { - memset(bba + buflen, bit, CLOCK / 2); - buflen += (CLOCK / 2); - memset(bba + buflen, bit ^ 1, CLOCK / 2); - buflen += (CLOCK / 2); +static void fill_buff(uint8_t bit) { + uint8_t *bba = BigBuf_get_addr(); + memset(bba + buflen, bit, LF_CLOCK / 2); + buflen += (LF_CLOCK / 2); + memset(bba + buflen, bit ^ 1, LF_CLOCK / 2); + buflen += (LF_CLOCK / 2); } static void ConstructEM410xEmulBuf(uint64_t id) { - int i, j, binary[4], parity[4]; + int i, j; + int binary[4] = {0,0,0,0}; + int parity[4] = {0,0,0,0}; buflen = 0; + for (i = 0; i < 9; i++) - FillBuff(1); - parity[0] = parity[1] = parity[2] = parity[3] = 0; + fill_buff(1); + for (i = 0; i < 10; i++) { for (j = 3; j >= 0; j--, id /= 2) binary[j] = id % 2; + for (j = 0; j < 4; j++) - FillBuff(binary[j]); - FillBuff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); + fill_buff(binary[j]); + + fill_buff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); for (j = 0; j < 4; j++) parity[j] ^= binary[j]; } + for (j = 0; j < 4; j++) - FillBuff(parity[j]); - FillBuff(0); + fill_buff(parity[j]); + + fill_buff(0); } static void LED_Slot(int i) { @@ -85,14 +93,13 @@ void RunMod(void) { int selected = 0; //selected slot after start slots_count = ARRAYLEN(low); - bba = BigBuf_get_addr(); for (;;) { WDT_HIT(); if (data_available()) break; SpinDelay(100); SpinUp(100); LED_Slot(selected); - ConstructEM410xEmulBuf(ReversQuads(low[selected])); + ConstructEM410xEmulBuf(rev_quads(low[selected])); SimulateTagLowFrequency(buflen, 0, true); selected = (selected + 1) % slots_count; } diff --git a/armsrc/Standalone/lf_em4100rswb.c b/armsrc/Standalone/lf_em4100rswb.c index e6e55f340..8e723185f 100644 --- a/armsrc/Standalone/lf_em4100rswb.c +++ b/armsrc/Standalone/lf_em4100rswb.c @@ -53,8 +53,8 @@ #include "flashmem.h" #endif -#define LF_CLOCK 64 //for 125kHz -#define LF_RWSB_T55XX_TYPE 1 //Tag type: 0 - T5555, 1-T55x7 +#define LF_CLOCK 64 // for 125kHz +#define LF_RWSB_T55XX_TYPE 1 // Tag type: 0 - T5555, 1-T55x7 #define LF_RWSB_UNKNOWN_RESULT 0 #define LF_RWSB_BRUTE_STOPED 1 @@ -90,7 +90,7 @@ static uint64_t rev_quads(uint64_t bits) { return result >> 24; } -static void FillBuff(uint8_t bit) { +static void fill_buff(uint8_t bit) { uint8_t *bba = BigBuf_get_addr(); memset(bba + buflen, bit, LF_CLOCK / 2); buflen += (LF_CLOCK / 2); @@ -99,30 +99,30 @@ static void FillBuff(uint8_t bit) { } static void ConstructEM410xEmulBuf(uint64_t id) { - int i, j, binary[4], parity[4]; + int i, j; + int binary[4] = {0,0,0,0}; + int parity[4] = {0,0,0,0}; buflen = 0; for (i = 0; i < 9; i++) - FillBuff(1); - - parity[0] = parity[1] = parity[2] = parity[3] = 0; + fill_buff(1); for (i = 0; i < 10; i++) { for (j = 3; j >= 0; j--, id /= 2) binary[j] = id % 2; for (j = 0; j < 4; j++) - FillBuff(binary[j]); + fill_buff(binary[j]); - FillBuff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); + fill_buff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); for (j = 0; j < 4; j++) parity[j] ^= binary[j]; } for (j = 0; j < 4; j++) - FillBuff(parity[j]); + fill_buff(parity[j]); - FillBuff(0); + fill_buff(0); } static void LED_Update(int mode, int slot) { diff --git a/armsrc/Standalone/lf_em4100rwc.c b/armsrc/Standalone/lf_em4100rwc.c index 911f97f0e..9240feb47 100644 --- a/armsrc/Standalone/lf_em4100rwc.c +++ b/armsrc/Standalone/lf_em4100rwc.c @@ -56,7 +56,7 @@ static uint64_t rev_quads(uint64_t bits) { return result >> 24; } -static void fillbuff(uint8_t bit) { +static void fill_buff(uint8_t bit) { uint8_t *bba = BigBuf_get_addr(); memset(bba + buflen, bit, LF_CLOCK / 2); buflen += (LF_CLOCK / 2); @@ -72,24 +72,24 @@ static void construct_EM410x_emul(uint64_t id) { buflen = 0; for (i = 0; i < 9; i++) - fillbuff(1); + fill_buff(1); for (i = 0; i < 10; i++) { for (j = 3; j >= 0; j--, id /= 2) binary[j] = id % 2; for (j = 0; j < 4; j++) - fillbuff(binary[j]); + fill_buff(binary[j]); - fillbuff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); + fill_buff(binary[0] ^ binary[1] ^ binary[2] ^ binary[3]); for (j = 0; j < 4; j++) parity[j] ^= binary[j]; } for (j = 0; j < 4; j++) - fillbuff(parity[j]); + fill_buff(parity[j]); - fillbuff(0); + fill_buff(0); } static void led_slot(int i) {