CR95F X-Nucleo NFC03A1 Shield STM
Dependents: Nucleo_NFC03A1_Demo
CR95HF.cpp
- Committer:
- duchonic
- Date:
- 2018-08-30
- Revision:
- 1:549e63ac990c
- Parent:
- 0:57769c77d24e
- Child:
- 2:c7006765c441
File content as of revision 1:549e63ac990c:
#include <CR95HF.h> #include "main.h" DigitalOut InterfacePin(D9); DigitalOut led1(D7); DigitalOut led2(D6); DigitalOut led3(D5); DigitalOut led4(D4); CR95HF::CR95HF(PinName tx, PinName rx) : nfcDevice(tx,rx) { InterfacePin = false; } CR95HF::~CR95HF() {}; uint8_t CR95HF::Init() { uint8_t commandInfo[] = {0x01, 0x00}; uint8_t commandSetProtocoll[] = {0x02, 0x01, 0x02, 0x00}; printf("CR95HF_Init\r\n"); nfcDevice.baud(57600); nfcDevice.attach(this, &CR95HF::rxCallbackNFC); wait(1); nfcWrite(commandInfo, 2); wait(1); nfcWrite(commandSetProtocoll, 4); return(0); } uint8_t CR95HF::ConfigManagerTagHunting() { uint8_t returnValue = false; uint8_t detectCard[] = {0x00, 0x04, 0x02, 0x26, 0x07}; nfcWrite(detectCard, 5); return(returnValue); } /** private functions */ void CR95HF::nfcWrite(uint8_t cmd[], uint8_t len) { for(int pos=0; pos<len;pos++) { nfcDevice.putc(cmd[pos]); } } void CR95HF::rxCallbackNFC() { uint8_t chr; while(nfcDevice.readable()) { printf("%c", nfcDevice.getc()); led3 = !led3; } }