CR95F X-Nucleo NFC03A1 Shield STM
Dependents: Nucleo_NFC03A1_Demo
CR95HF.cpp@0:57769c77d24e, 2018-08-24 (annotated)
- Committer:
- duchonic
- Date:
- Fri Aug 24 13:12:48 2018 +0000
- Revision:
- 0:57769c77d24e
- Child:
- 1:549e63ac990c
first
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duchonic | 0:57769c77d24e | 1 | #include <CR95HF.h> |
duchonic | 0:57769c77d24e | 2 | #include "main.h" |
duchonic | 0:57769c77d24e | 3 | |
duchonic | 0:57769c77d24e | 4 | DigitalOut InterfacePin(D9); |
duchonic | 0:57769c77d24e | 5 | DigitalOut myLed4(D4); |
duchonic | 0:57769c77d24e | 6 | |
duchonic | 0:57769c77d24e | 7 | CR95HF::CR95HF(PinName tx, PinName rx) : serial(tx,rx) |
duchonic | 0:57769c77d24e | 8 | { |
duchonic | 0:57769c77d24e | 9 | /* Set Uart on Interface Pin */ |
duchonic | 0:57769c77d24e | 10 | InterfacePin = false; |
duchonic | 0:57769c77d24e | 11 | } |
duchonic | 0:57769c77d24e | 12 | |
duchonic | 0:57769c77d24e | 13 | CR95HF::~CR95HF() {}; |
duchonic | 0:57769c77d24e | 14 | |
duchonic | 0:57769c77d24e | 15 | uint8_t CR95HF::CR95HF_Init() |
duchonic | 0:57769c77d24e | 16 | { |
duchonic | 0:57769c77d24e | 17 | char commandInfo[] = {0x01, 0x00}; |
duchonic | 0:57769c77d24e | 18 | char commandSetProtocoll[] = {0x02, 0x01, 0x02, 0x00}; |
duchonic | 0:57769c77d24e | 19 | |
duchonic | 0:57769c77d24e | 20 | |
duchonic | 0:57769c77d24e | 21 | uint8_t position; |
duchonic | 0:57769c77d24e | 22 | |
duchonic | 0:57769c77d24e | 23 | printf("CR95HF_Init\r\n"); |
duchonic | 0:57769c77d24e | 24 | |
duchonic | 0:57769c77d24e | 25 | serial.baud(57600); |
duchonic | 0:57769c77d24e | 26 | |
duchonic | 0:57769c77d24e | 27 | serial.attach(this, &CR95HF::readLineCallback); |
duchonic | 0:57769c77d24e | 28 | |
duchonic | 0:57769c77d24e | 29 | wait_ms(500); |
duchonic | 0:57769c77d24e | 30 | for(position=0;position<2;position++) |
duchonic | 0:57769c77d24e | 31 | { |
duchonic | 0:57769c77d24e | 32 | wait_us(10); |
duchonic | 0:57769c77d24e | 33 | serial.putc(commandInfo[position]); |
duchonic | 0:57769c77d24e | 34 | } |
duchonic | 0:57769c77d24e | 35 | |
duchonic | 0:57769c77d24e | 36 | wait_ms(500); |
duchonic | 0:57769c77d24e | 37 | for(position=0;position<4;position++) |
duchonic | 0:57769c77d24e | 38 | { |
duchonic | 0:57769c77d24e | 39 | wait_us(10); |
duchonic | 0:57769c77d24e | 40 | serial.putc(commandSetProtocoll[position]); |
duchonic | 0:57769c77d24e | 41 | } |
duchonic | 0:57769c77d24e | 42 | |
duchonic | 0:57769c77d24e | 43 | |
duchonic | 0:57769c77d24e | 44 | |
duchonic | 0:57769c77d24e | 45 | return(0); |
duchonic | 0:57769c77d24e | 46 | } |
duchonic | 0:57769c77d24e | 47 | |
duchonic | 0:57769c77d24e | 48 | uint8_t CR95HF::CR95HF_ConfigManagerTagHunting() |
duchonic | 0:57769c77d24e | 49 | { |
duchonic | 0:57769c77d24e | 50 | uint8_t returnValue = false; |
duchonic | 0:57769c77d24e | 51 | uint8_t position; |
duchonic | 0:57769c77d24e | 52 | |
duchonic | 0:57769c77d24e | 53 | char detectCard[] = {0x00, 0x04, 0x02, 0x26, 0x07}; |
duchonic | 0:57769c77d24e | 54 | |
duchonic | 0:57769c77d24e | 55 | wait_ms(500); |
duchonic | 0:57769c77d24e | 56 | for(position=0;position<5;position++) |
duchonic | 0:57769c77d24e | 57 | { |
duchonic | 0:57769c77d24e | 58 | wait_us(10); |
duchonic | 0:57769c77d24e | 59 | serial.putc(detectCard[position]); |
duchonic | 0:57769c77d24e | 60 | } |
duchonic | 0:57769c77d24e | 61 | |
duchonic | 0:57769c77d24e | 62 | return(returnValue); |
duchonic | 0:57769c77d24e | 63 | } |
duchonic | 0:57769c77d24e | 64 | |
duchonic | 0:57769c77d24e | 65 | /** private functions */ |
duchonic | 0:57769c77d24e | 66 | |
duchonic | 0:57769c77d24e | 67 | void CR95HF::readLineCallback() |
duchonic | 0:57769c77d24e | 68 | { |
duchonic | 0:57769c77d24e | 69 | myLed4 = !myLed4; |
duchonic | 0:57769c77d24e | 70 | printf("%u", serial.getc()); |
duchonic | 0:57769c77d24e | 71 | } |