Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
timing fix for rf emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
arha committed Jan 28, 2023
1 parent a9dac27 commit 33fcf44
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions helpers/mag_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const uint8_t bitlen[] = {7, 5, 5};
// char offset by track
const int sublen[] = {32, 48, 48};
uint8_t bit_dir = 0;
uint8_t last_value = 2;

void bitbang_raw(bool value, MagSetting* setting)
{
Expand All @@ -29,24 +30,32 @@ void bitbang_raw(bool value, MagSetting* setting)
break;
case MagTxCC1101_434:
case MagTxCC1101_868:
furi_hal_gpio_write(&gpio_cc1101_g0, true);
furi_delay_us(64);
furi_hal_gpio_write(&gpio_cc1101_g0, false);
if (last_value == 2 || value != (bool)last_value)
{
furi_hal_gpio_write(&gpio_cc1101_g0, true);
furi_delay_us(64);
furi_hal_gpio_write(&gpio_cc1101_g0, false);
}
break;
default:
break;
}

last_value = value;
}

void play_bit_rf(bool bit, MagSetting* setting) {

bit_dir ^= 1;
furi_hal_gpio_write(&gpio_cc1101_g0, bit_dir);
furi_hal_gpio_write(&gpio_cc1101_g0, true);
furi_delay_us(64);
furi_hal_gpio_write(&gpio_cc1101_g0, false);
furi_delay_us(setting->us_clock);

if(bit) {
bit_dir ^= 1;
furi_hal_gpio_write(&gpio_cc1101_g0, bit_dir);
furi_hal_gpio_write(&gpio_cc1101_g0, true);
furi_delay_us(64);
furi_hal_gpio_write(&gpio_cc1101_g0, false);
}
furi_delay_us(setting->us_clock);
furi_delay_us(setting->us_interpacket);
Expand Down Expand Up @@ -334,7 +343,7 @@ void mag_spoof_bitwise(Mag* mag) {
}

if(!tx_init(setting)) return;

last_value = 2;
FURI_CRITICAL_ENTER();
bool bit = false;

Expand Down

0 comments on commit 33fcf44

Please sign in to comment.