mirror of
https://github.com/whowechina/aic_pico.git
synced 2024-11-14 09:37:35 +01:00
PN5180 tx tweak for some weird module
This commit is contained in:
parent
c42847bda6
commit
62b080fead
@ -35,6 +35,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
bool debug;
|
||||
bool pn5180_tx_tweak;
|
||||
} nfc_runtime_t;
|
||||
|
||||
extern nfc_runtime_t nfc_runtime;
|
||||
@ -52,6 +53,8 @@ void nfc_init();
|
||||
/* should be called only after init */
|
||||
void nfc_set_wait_loop(nfc_wait_loop_t loop);
|
||||
|
||||
void nfc_pn5180_tx_tweak(bool enable);
|
||||
|
||||
void nfc_rf_field(bool on);
|
||||
|
||||
nfc_card_t nfc_detect_card();
|
||||
|
@ -38,6 +38,9 @@ static void display_nfc()
|
||||
{
|
||||
printf("[NFC Module]\n");
|
||||
printf(" %s (%s)\n", nfc_module_name(), nfc_module_version());
|
||||
if (strstr(nfc_module_name(), "5180") != NULL) {
|
||||
printf(" TX Tweak: %s\n", aic_cfg->tweak.pn5180_tx ? "ON" : "OFF");
|
||||
}
|
||||
}
|
||||
|
||||
static void display_light()
|
||||
@ -250,6 +253,25 @@ static void handle_lcd(int argc, char *argv[])
|
||||
display_lcd();
|
||||
}
|
||||
|
||||
static void handle_pn5180_tweak(int argc, char *argv[])
|
||||
{
|
||||
const char *usage = "Usage: pn5180_tweak <on|off>\n";
|
||||
if (argc != 1) {
|
||||
printf("%s", usage);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *commands[] = { "on", "off" };
|
||||
int match = cli_match_prefix(commands, 4, argv[0]);
|
||||
if (match < 0) {
|
||||
return;
|
||||
}
|
||||
aic_cfg->tweak.pn5180_tx = (match == 0);
|
||||
printf("PN5180 TX Tweak: %s\n", aic_cfg->tweak.pn5180_tx ? "ON" : "OFF");
|
||||
nfc_pn5180_tx_tweak(aic_cfg->tweak.pn5180_tx);
|
||||
config_changed();
|
||||
}
|
||||
|
||||
static void handle_debug()
|
||||
{
|
||||
aic_runtime.debug = !aic_runtime.debug;
|
||||
@ -268,5 +290,6 @@ void commands_init()
|
||||
cli_register("light", handle_light, "Turn on/off lights.");
|
||||
cli_register("level", handle_level, "Set light level.");
|
||||
cli_register("lcd", handle_lcd, "Touch LCD settings.");
|
||||
cli_register("pn5180_tweak", handle_pn5180_tweak, "PN5180 TX tweak.");
|
||||
cli_register("debug", handle_debug, "Toggle debug.");
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ aic_cfg_t *aic_cfg;
|
||||
static aic_cfg_t default_cfg = {
|
||||
.light = { .level_idle = 24, .level_active = 128, .rgb = true, .led = true },
|
||||
.reader = { .virtual_aic = true, .mode = MODE_AUTO },
|
||||
.lcd = { .backlight = 200, }
|
||||
.lcd = { .backlight = 200, },
|
||||
.tweak = { .pn5180_tx = false },
|
||||
};
|
||||
|
||||
aic_runtime_t aic_runtime;
|
||||
|
@ -25,6 +25,9 @@ typedef struct __attribute__((packed)) {
|
||||
struct {
|
||||
uint8_t backlight;
|
||||
} lcd;
|
||||
struct {
|
||||
bool pn5180_tx;
|
||||
} tweak;
|
||||
uint32_t reserved;
|
||||
} aic_cfg_t;
|
||||
|
||||
|
@ -165,6 +165,11 @@ const char *nfc_module_version()
|
||||
return api[nfc_module].firmware_ver();
|
||||
}
|
||||
|
||||
void nfc_pn5180_tx_tweak(bool enable)
|
||||
{
|
||||
nfc_runtime.pn5180_tx_tweak = enable;
|
||||
}
|
||||
|
||||
static bool nfc_detect_mifare(nfc_card_t *card)
|
||||
{
|
||||
uint8_t id[20] = { 0 };
|
||||
@ -297,4 +302,4 @@ void nfc_deselect()
|
||||
if (api[nfc_module].deselect) {
|
||||
api[nfc_module].deselect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,6 +270,9 @@ static void poll_mifare_0()
|
||||
{
|
||||
pn5180_reset();
|
||||
pn5180_load_rf_config(0x00, 0x80);
|
||||
if (nfc_runtime.pn5180_tx_tweak) {
|
||||
write_reg(CMD_WRITE_REG, 0x21, 0x789);
|
||||
}
|
||||
pn5180_rf_field(true);
|
||||
rf_crc_off();
|
||||
}
|
||||
|
@ -413,6 +413,7 @@ void init()
|
||||
nfc_init_spi(SPI_PORT, SPI_MISO, SPI_SCK, SPI_MOSI, SPI_RST, SPI_NSS, SPI_BUSY);
|
||||
nfc_init();
|
||||
nfc_set_wait_loop(wait_loop);
|
||||
nfc_pn5180_tx_tweak(aic_cfg->tweak.pn5180_tx);
|
||||
|
||||
aime_init(cdc_reader_putc);
|
||||
aime_virtual_aic(aic_cfg->reader.virtual_aic);
|
||||
|
Loading…
Reference in New Issue
Block a user