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

Commit

Permalink
Quick HF tests, initial mag_device commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyweiss committed Dec 29, 2022
1 parent 8770ff6 commit 9d92e65
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Other misc things to investigate / build:


HF coil notes:
NFC reader field can be turned on / off with `furi_hal_nfc_field_on();` and `furi_hal_nfc_field_off();` respectively, as seen in nfc_scene_field.c (used for debug purposes). At a lower level, that consists of `furi_hal_nfc_exit_sleep();` and `st25r3916TxRxOn();` to turn on, and `st25r3916TxRxOff();` and `furi_hal_nfc_start_sleep();` to turn off. May be worth trying directly (wake from sleep at setup, toggle on and off corresponding with bit direction, send to sleep on exit). If this doesn't work, will likely need to consider lower-level control.
NFC reader field can be turned on / off with `furi_hal_nfc_field_on();` and `furi_hal_nfc_field_off();` respectively, as seen in nfc_scene_field.c (used for debug purposes). Initial tests with `furi_hal_nfc_field_on();` are promising signal-wise, but the delay introduced by the wake/sleep initialization renders it impossible to toggle rapidly. At a lower level, that consists of `furi_hal_nfc_exit_sleep();` and `st25r3916TxRxOn();` to turn on, and `st25r3916TxRxOff();` and `furi_hal_nfc_start_sleep();` to turn off. May be worth trying directly (wake from sleep at setup, toggle on and off corresponding with bit direction, send to sleep on exit). Initial tests have been difficult to get work as some of the st25r3916 symbols are unresolved; need to figure out how to import and call it properly, or how to get another layer lower of control.

2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ App(
order=20,
fap_icon="mag_10px.png",
fap_category="Tools",
fap_icon_assets="imgs",
fap_icon_assets="icons",
)
File renamed without changes
7 changes: 7 additions & 0 deletions mag_device.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "mag_device.h"

#include <toolbox/path.h>
#include <flipper_format/flipper_format.h>

//static const char* mag_file_header = "Flipper Mag device";
//static const uint32_t mag_file_version = 1;
8 changes: 8 additions & 0 deletions mag_device.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <stdint.h>
#include <stdbool.h>
#include <storage/storage.h>
#include <dialogs/dialogs.h>

#include "mag_icons.h"
16 changes: 16 additions & 0 deletions scenes/mag_scene_emulate_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ static void play_bit(uint8_t send_bit) {
gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);
furi_delay_us(CLOCK_US);

// NFC tests
//(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
//(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();

if (send_bit) {
magspoof_bit_dir ^= 1;
gpio_item_set_rfid_pin(PIN_A, magspoof_bit_dir);
gpio_item_set_rfid_pin(PIN_B, !magspoof_bit_dir);

//(magspoof_bit_dir) ? st25r3916TxRxOn() : st25r3916TxRxOff();
//(magspoof_bit_dir) ? furi_hal_nfc_field_on() : furi_hal_nfc_field_off();
}
furi_delay_us(CLOCK_US);
}
Expand Down Expand Up @@ -65,6 +72,9 @@ static void mag_spoof(FuriString *track_str, uint8_t track) {
furi_hal_ibutton_start_drive();
furi_hal_ibutton_pin_low();

// NFC TEST
furi_hal_nfc_exit_sleep();

// Initializing at GpioSpeedLow seems sufficient for our needs; no improvements seen by increasing speed setting

// this doesn't seem to make a difference, leaving it in
Expand Down Expand Up @@ -129,10 +139,16 @@ static void mag_spoof(FuriString *track_str, uint8_t track) {

gpio_item_set_rfid_pin(PIN_A, 0);
gpio_item_set_rfid_pin(PIN_B, 0);
// NFC TEST
//st25r3916TxRxOff();
//furi_hal_nfc_field_off();

// end critical timing section
FURI_CRITICAL_EXIT();

// NFC TEST
//furi_hal_nfc_start_sleep();

furi_hal_rfid_pins_reset();
furi_hal_power_disable_otg();
}
Expand Down

0 comments on commit 9d92e65

Please sign in to comment.