Make style

This commit is contained in:
Artem Gnatyuk 2020-03-21 21:39:30 +07:00
commit c36d86bc01
2 changed files with 156 additions and 156 deletions

View file

@ -25,27 +25,27 @@
// low & high - array for storage IDs. Its length must be equal.
// Predefined IDs must be stored in low[].
// In high[] must be nulls
uint64_t low[] = {0x565A1140BE,0x365A398149,0x5555555555,0xFFFFFFFFFF};
uint32_t high[] = {0,0,0,0};
uint8_t *bba,slots_count;
uint64_t low[] = {0x565A1140BE, 0x365A398149, 0x5555555555, 0xFFFFFFFFFF};
uint32_t high[] = {0, 0, 0, 0};
uint8_t *bba, slots_count;
int buflen;
void ModInfo(void) {
DbpString(" LF EM4100 simulator standalone mode");
}
uint64_t ReversQuads(uint64_t bits){
uint64_t ReversQuads(uint64_t bits) {
uint64_t result = 0;
for (int i = 0; i < 16; i++){
result += ((bits >> (60 - 4 *i)) & 0xf) << (4 * i);
for (int i = 0; i < 16; i++) {
result += ((bits >> (60 - 4 * i)) & 0xf) << (4 * i);
}
return result >> 24;
}
void FillBuff(uint8_t bit) {
memset (bba + buflen, bit, CLOCK / 2);
memset(bba + buflen, bit, CLOCK / 2);
buflen += (CLOCK / 2);
memset (bba + buflen, bit^1,CLOCK / 2);
memset(bba + buflen, bit ^ 1, CLOCK / 2);
buflen += (CLOCK / 2);
}
@ -75,7 +75,7 @@ void LED_Slot(int i) {
if (slots_count > 4) {
LED(i % MAX_IND, 0); //binary indication for slots_count > 4
} else {
LED(1 << i,0); //simple indication for slots_count <=4
LED(1 << i, 0); //simple indication for slots_count <=4
}
}
@ -83,7 +83,7 @@ void RunMod() {
StandAloneMode();
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
int selected = 0; //selected slot after start
slots_count = sizeof(low)/sizeof(low[0]);
slots_count = sizeof(low) / sizeof(low[0]);
bba = BigBuf_get_addr();
for (;;) {
WDT_HIT();

View file

@ -38,27 +38,27 @@
// low & high - array for storage IDs. Its length must be equal.
// Predefined IDs must be stored in low[].
// In high[] must be nulls
uint64_t low[] = {0x565AF781C7,0x540053E4E2,0x1234567890,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint32_t high[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8_t *bba,slots_count;
uint64_t low[] = {0x565AF781C7, 0x540053E4E2, 0x1234567890, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint32_t high[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint8_t *bba, slots_count;
int buflen;
void ModInfo(void) {
DbpString(" LF EM4100 simulate standalone V2");
}
uint64_t ReversQuads(uint64_t bits){
uint64_t ReversQuads(uint64_t bits) {
uint64_t result = 0;
for (int i = 0; i < 16; i++){
result += ((bits >> (60 - 4 *i)) & 0xf) << (4 * i);
for (int i = 0; i < 16; i++) {
result += ((bits >> (60 - 4 * i)) & 0xf) << (4 * i);
}
return result >> 24;
}
void FillBuff(uint8_t bit) {
memset (bba + buflen, bit, CLOCK / 2);
memset(bba + buflen, bit, CLOCK / 2);
buflen += (CLOCK / 2);
memset (bba + buflen, bit^1,CLOCK / 2);
memset(bba + buflen, bit ^ 1, CLOCK / 2);
buflen += (CLOCK / 2);
}
@ -88,7 +88,7 @@ void LED_Slot(int i) {
if (slots_count > 4) {
LED(i % MAX_IND, 0); //binary indication, usefully for slots_count > 4
} else {
LED(1 << i,0); //simple indication for slots_count <=4
LED(1 << i, 0); //simple indication for slots_count <=4
}
}
@ -103,14 +103,14 @@ void FlashLEDs(uint32_t speed, uint8_t times) {
}
#ifdef WITH_FLASH
void SaveIDtoFlash (int addr, uint64_t id) {
void SaveIDtoFlash(int addr, uint64_t id) {
uint8_t bt[5];
char *filename = "emdump";
rdv40_spiffs_mount();
for (int i = 0; i < 5; i++) {
bt[4-i] = (uint8_t) (id >> 8 * i & 0xff);
bt[4 - i] = (uint8_t)(id >> 8 * i & 0xff);
}
if (exists_in_spiffs(filename) == false){
if (exists_in_spiffs(filename) == false) {
rdv40_spiffs_write(filename, &bt[0], 5, RDV40_SPIFFS_SAFETY_NORMAL);
} else {
rdv40_spiffs_append(filename, &bt[0], 5, RDV40_SPIFFS_SAFETY_NORMAL);
@ -127,7 +127,7 @@ void RunMod() {
// 2 - simulate tag from selected slot
// 3 - write to T5555 tag
uint8_t state = 0;
slots_count = sizeof(low)/sizeof(low[0]);
slots_count = sizeof(low) / sizeof(low[0]);
bba = BigBuf_get_addr();
LED_Slot(selected);
for (;;) {
@ -135,7 +135,7 @@ void RunMod() {
if (data_available()) break;
int button_pressed = BUTTON_HELD(1000);
SpinDelay(300);
switch (state){
switch (state) {
case 0:
// Select mode
if (button_pressed == 1) {
@ -159,10 +159,10 @@ void RunMod() {
} else if (button_pressed < 0) {
// Click - exit to select mode
CmdEM410xdemod(1, &high[selected], &low[selected], 0);
FlashLEDs(100,5);
#ifdef WITH_FLASH
FlashLEDs(100, 5);
#ifdef WITH_FLASH
SaveIDtoFlash(selected, low[selected]);
#endif
#endif
state = 0;
}
break;
@ -177,7 +177,7 @@ void RunMod() {
// Click - start simulating. Click again to exit from simulate mode
LED_Slot(selected);
ConstructEM410xEmulBuf(ReversQuads(low[selected]));
FlashLEDs(100,5);
FlashLEDs(100, 5);
SimulateTagLowFrequency(buflen, 0, 1);
LED_Slot(selected);
state = 0; // Switch to select mode
@ -192,7 +192,7 @@ void RunMod() {
state = 0;
} else if (button_pressed < 0) {
// Click - write ID to tag
WriteEM410x(0, (uint32_t) (low[selected] >> 32), (uint32_t) (low[selected] & 0xffffffff));
WriteEM410x(0, (uint32_t)(low[selected] >> 32), (uint32_t)(low[selected] & 0xffffffff));
LED_Slot(selected);
state = 0; // Switch to select mode
}