summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2016-08-19 00:02:24 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2016-08-19 00:02:24 +0200
commitd03d3fd350b89caa31e505d2cb7b7bdf674b3d30 (patch)
tree40e6da4dd5c9e78b634481a2ad6c1216fefd23c4
parent858354638e68319e2380a2927353c1eb67657253 (diff)
Turn on LED when card is detected.
-rw-r--r--main.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 95626f2..3a00d0d 100644
--- a/main.cpp
+++ b/main.cpp
@@ -22,7 +22,6 @@ desc_t conf_desc_p = {sizeof(conf_desc), (void*)&conf_desc};
USB_l0 usb(USB, dev_desc_p, conf_desc_p);
-
Pin nfc_sck = GPIOB[3];
Pin nfc_miso = GPIOB[4];
Pin nfc_mosi = GPIOB[5];
@@ -30,6 +29,9 @@ Pin nfc_ss = GPIOB[6];
Pin nfc_irq_out = GPIOB[7];
Pin nfc_irq_in = GPIOC[13];
+Pin button = GPIOA[3];
+Pin led = GPIOA[4];
+
class CR95HF {
private:
SPI_t& spi;
@@ -474,6 +476,8 @@ int main() {
RCC.enable(RCC.GPIOB);
RCC.enable(RCC.GPIOC);
+ led.set_mode(Pin::Output);
+
RCC.enable(RCC.USB);
usb.init();
@@ -516,6 +520,8 @@ int main() {
if(Time::time() < nfc_delay_until) {
// Just do nothing.
} else if(!cmd_sent) {
+ led.off();
+
cr95hf.send_cmd(0x04, 3, (uint8_t*)"\x26\x01\x00"); // INVENTORY
cmd_sent = true;
} else if(!nfc_irq_out.get()) {
@@ -523,6 +529,8 @@ int main() {
cmd_sent = false;
if(buf[0] == 128 && buf[14] == 0) {
+ led.on();
+
USB.reg.BCDR &= ~(1 << 15);
uint8_t* id_raw = &buf[11];
uint8_t* id_ascii = sectors[4];