1
0
mirror of https://github.com/whowechina/aic_pico.git synced 2025-02-17 19:09:24 +01:00

Decouple runtime object

This commit is contained in:
whowechina 2024-04-30 08:51:51 +08:00
parent c6b0ebc392
commit ab4fdc2f1d
5 changed files with 11 additions and 4 deletions

View File

@ -33,6 +33,12 @@ typedef struct {
uint8_t syscode[2];
} nfc_card_t;
typedef struct {
bool debug;
} nfc_runtime_t;
extern nfc_runtime_t nfc_runtime;
/* should init or attach i2c and spi port before init */
void nfc_attach_i2c(i2c_inst_t *port);
void nfc_attach_spi(spi_inst_t *port, uint8_t rst, uint8_t nss, uint8_t busy);

View File

@ -201,6 +201,7 @@ static void handle_level(int argc, char *argv[])
static void handle_debug()
{
aic_runtime.debug = !aic_runtime.debug;
nfc_runtime.debug = aic_runtime.debug;
printf("Debug: %s\n", aic_runtime.debug ? "ON" : "OFF");
}

View File

@ -14,12 +14,11 @@
#include "hardware/gpio.h"
#include "hardware/i2c.h"
#include "config.h"
#include "nfc.h"
#include "aime.h"
static bool debug = false;
#define DEBUG(...) if (aic_runtime.debug) printf(__VA_ARGS__)
#define DEBUG(...) if (nfc_runtime.debug) printf(__VA_ARGS__)
#define AIME_EXPIRE_TIME 10000000ULL

View File

@ -14,12 +14,11 @@
#include "hardware/gpio.h"
#include "hardware/i2c.h"
#include "config.h"
#include "nfc.h"
#include "bana.h"
static bool debug = false;
#define DEBUG(...) if (aic_runtime.debug) printf(__VA_ARGS__)
#define DEBUG(...) if (nfc_runtime.debug) printf(__VA_ARGS__)
#define BANA_EXPIRE_TIME 10000000ULL

View File

@ -15,6 +15,8 @@
#include "pn532.h"
#include "pn5180.h"
nfc_runtime_t nfc_runtime;
static enum {
NFC_MODULE_PN532 = 0,
NFC_MODULE_PN5180,