📄 main.c
字号:
#include <msp430x12x2.h>
#include "timer.h"
#include "flash.h"
#include "2401A.h"
#define PERIED 30 //define how many times send out a search writer code
#define CardNumber 32 //every card should change this number!!!!!!!!!!!!!!!!
unsigned char BUFFER[26]; //used to store the information of the card
unsigned char CardInf[26];
unsigned char ADR[4]={0x66,0x88,0x88,0x66}; //要读取的卡号
unsigned char counter;
/*****************************************************/
/*****************************************************/
void main(void)
{
unsigned char i;
// unsigned char *Flash_ptr;
unsigned int temp;
// unsigned char tembuff[26]={0,0,0,14, 1, 48,74,53,23, 0,36, 0x1c,0,0,0,4,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff};
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
intPORT();
powerUP2401A();
initFlash();
// write_SegB(tembuff,26);
//testRF();
Nrf2401Config();
powerOFF2401A();
//counter is used to let card receive write command
counter = 0;
//read the 29 bytes information from the flash
// Flash_ptr = (unsigned char *) 0x1000; //information is stored in flashB of information flash
for(i=0; i<26; i++)
{
CardInf[i] = 0;
}
temp = CardNumber;
CardInf[0] = temp & 0xff;
CardInf[1] = (temp>>8) & 0xff;
initTimerA();
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
// unsigned char flag;
// unsigned char i;
_BIC_SR(GIE); //close interupt
TACTL = MC_0 + TACLR; //stop the timerA
CCTL0 = 0; // CCR0 interrupt enabled
//power up the 2401A
powerUP2401A();
/*
//send out the information
if(counter == PERIED)
{
//send 0xaaaa5555 to writer
BUFFER[0] = 0xaa;
BUFFER[1] = 0xaa;
BUFFER[2] = 0x55;
BUFFER[3] = 0x55;
BUFFER[4] = CardInf[0];
BUFFER[5] = CardInf[1];
BUFFER[6] = CardInf[2];
BUFFER[7] = CardInf[3];
Nrf2401TX(BUFFER,ADR);
}
else
{
*/
Nrf2401TX(CardInf,ADR);
delayNms(5);
/*
}
if(counter == PERIED)
{
counter = 0;
//change to receive mode
SetRxMode();
//wait 30 ms to see if there is a writer instrument there
flag = 0;
flag = Nrf2401RXDelay(BUFFER);
//if there is no writer, go back to LPM3 state. if there is one there, receive the information and write them
//to the flash, configure the 2401A again for new power emition. and go to LPM3 at last.
if(flag == 1)
{
Nrf2401RX(BUFFER);
write_SegB (BUFFER,26);
for(i=0; i<26; i++)
{
CardInf[i] = BUFFER[i];
}
}
//set to send mode
intPORT();
powerUP2401A();
Nrf2401Config();
}
*/
powerOFF2401A();
initTimerA();
P2OUT = P2OUT ^ 0x01;
counter ++;
if(counter == 40)
counter = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -