标题:
MSP430开发TFR7979读卡器源程序
[打印本页]
作者:
小小菜菜
时间:
2019-4-22 14:48
标题:
MSP430开发TFR7979读卡器源程序
亲测试可以用。支持14443a、15693、nfc。
0.png
(11.52 KB, 下载次数: 118)
下载附件
2019-4-22 21:39 上传
单片机源程序如下:
//===============================================================
// Program with hardware USART and paralel communication ;
// interface with TRF reader chip. ;
// ;
// PORT4.0 - 4.7 - (IO0-IO7) for parallel interface ;
// with reader chip ;
// PORT3.0 - PORT3.3 - USCI_B0 ---> SPI interface with reader ;
// PORT3.4 - PORT3.5 - USCI_A0 ---> USB/UART control signals ;
// PORT2.1 - IRQ ;
// PORT3.3 - DATA_CLK ;
// PORT1.7 - PORT1.3 - signaling LEDs ;
// PORT1.0 - TRF Enable ;
//===============================================================
//#include <MSP430x23x0.h> // prozessor spezific header
#include <stdlib.h> // general purpose standard library
#include <stdio.h> // standard input/output header
#include "host.h"
#include "iso14443a.h"
#include "iso14443b.h"
#include "iso15693.h"
#include "felica.h"
#include "mcu.h"
#include "trf797x.h"
#include "types.h"
#include "uart.h"
//===============================================================
u08_t buf[300];
u08_t enable = 0;
u08_t i_reg = 0x01; // interrupt register
u08_t irq_flag = 0x00;
u08_t rx_error_flag = 0x00;
s08_t rxtx_state = 1; // used for transmit recieve byte count
s16_t nfc_state;
u08_t remote_flag = 0;
u08_t stand_alone_flag = 1;
u08_t reader_mode = 0x00; // determines how interrups will be handled
//===============================================================
//
//===============================================================
void main (void) {
// settings
WDTCTL = WDTPW + WDTHOLD; // stop watchdog timer
#ifdef ENABLE_HOST
UartSetup(); // settings for UART
#endif
ENABLE_SET; // P1.0 is switched in output direction
TRF_ENABLE;
McuDelayMillisecond(1); // wait until system clock started
Trf797xCommunicationSetup(); // settings for communication with TRF
Trf797xInitialSettings(); // Set MCU Clock Frequency to 6.78 MHz and OOK Modulation
// Now switch from DCO to external 6.78 MHz clock
McuOscSel(0x00); // set the oscillator
McuDelayMillisecond(10);
// Re-configure the USART with this external clock
Trf797xReConfig();
ENABLE_INTERRUPTS; // General enable interrupts
LED_POWER_ON; // board ist powered, green LED
OOK_DIR_IN; // set OOK port tristate
enable = 1; // indicates, that setting are done
reader_mode = 0x00;
stand_alone_flag = 1; // stand alone mode
remote_flag = 0; // host is not activ
// settings done
while(1) // infinite loop
{
#if TRIGGER // in Mcu.h
LED_OPEN1_ON;
McuDelayMillisecond(1);
LED_OPEN1_OFF;
#endif
if(remote_flag == 1) // if in remote mode
{ // remote mode can be disabled in host.h
#ifdef ENABLE_HOST
buf[4] = 0xff; // "TRF7960 EVM" message in GUI
HostCommands(); // device works according host commands
#endif
}
else
{
#ifdef ENABLE15693 // this standard can be disabled in ISO15693.h
Iso15693FindTag(); // detects ISO15693 in stand-alone mode
#endif
if(remote_flag == 0)
{
#ifdef ENABLE14443A // this standard can be disabled in ISO14443A.h
Iso14443aFindTag(); // detects ISO14443A in stand-alone mode
#endif
}
if(remote_flag == 0)
{
#ifdef ENABLE14443B // this standard can be disabled in ISO14443B.h
Iso14443bFindTag(); // detects ISO14443B in stand-alone mode
#endif
}
if(remote_flag == 0)
{
#ifdef ENABLE_FELICA // this standard can be disabled in felica.h
FindFelica(); // detects FeliCa in stand-alone mode
#endif
}
}
}
}
复制代码
所有资料51hei提供下载:
下位机程序_原厂_CCS4环境.zip
(223.63 KB, 下载次数: 5)
2019-4-22 14:48 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1