⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lpc2129_paypass_ttal1_functions.c

📁 读RF卡的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
//=============================================================================
//                  Copyright (C) INSIDE Contactless 1998-2005
//
// INSIDE Contactless reserves the right to make changes, without notice,
// to any product (including application note) herein to improve
// reliability, functionality, or design. INSIDE Contactless advises its
// customers to obtain the latest version of device data sheets to verify,
// before placing orders, that the information being relied upon by the
// customer is current.
//
// INSIDE Contactless makes no warranty that the use will not infringe any
// third party patent, copyright or trademark.
//
// Information furnished by INSIDE Contactless is believed to be accurate
// and reliable. However, INSIDE Contactless does not assume any liability
// resulting from the application or use of any product described within.
//
// All rights are reserved. Reproduction in whole or in part is prohibited
// without the written consent of the copyright owner.
//
//      Bat 11a,
//      Parc Club du Golf,
//      Z.A.C. du Pichaury                      Tel :   +33 (0)4.42.39.33.00
//      13856 Aix-en-Provence Cedex 3           Fax :   +33 (0)4.42.39.63.19
//      FRANCE                                  Email : info@insidefr.com
//
//-----------------------------------------------------------------------------
// Project Code : PICOREAD RF ISO15693-3 READER
// Project Name : APPLICATION NOTE
// Module Name  : LPC2103_functions.c
// Platform dev : Keil 礦ision 3 (IDE ) + Keil ARM Compiler
// Target       : LPC2129 (ARM7TDMI Core)
// Language     : C ANSI
// Revision     : 1.0
// Description  : Special functions requiring to be modified according to the target and the user needs (i.e Choice of IO for the SPI)
//				  also SDO_MASK SDI_MASK SCK_MASK and CS_MASK must be modified according to 
//                IOs choosen for SPI communication



// Defines for common C writting
#include "Defines_C.h"  			// TRUE, FALSE, etc

// Defines for PicoRead
#include "PRD_PicoReadRF_Pages_Parameters.h" // Definition of PicoRead chip registers

#include "TARGET.h"

unsigned char APBDivider;

//-----------------------------------------------------------------------------
// Function name : kbhit
//-----------------------------------------------------------------------------
// Description : Detect if a button is pressed.
//
// IN       :   - none -
// OUT      :   - none -
// RETURN   :   '0' if no button pressed, '1' if button pressed
// Notes    :   Not used in this application note
//-----------------------------------------------------------------------------
int kbhit()
{ 
	return (U0LSR & 0x01);
}

//-----------------------------------------------------------------------------
// Function name : bit_testChar
//-----------------------------------------------------------------------------
// Description : This function test a bit of an unsigned char 
//
// IN       :   RegisterAdd : Address of an unsigned char
//				bitNumber : Number of the bit to set
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   - none -
//-----------------------------------------------------------------------------
unsigned char bit_testChar(unsigned char* RegisterAdd,unsigned int bitNumber)
{
  if(((*RegisterAdd) & (1<<bitNumber))>0)
  {
   	return 0x01;
  }
  else
  {
   	return 0x00;
  }

}


//-----------------------------------------------------------------------------
// Function name : bit_setChar
//-----------------------------------------------------------------------------
// Description : This function set a bit of an unsigned char 
//
// IN       :   RegisterAdd : Address of an unsigned char
//				bitNumber : Number of the bit to set
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   - none -
//-----------------------------------------------------------------------------
void bit_setChar(unsigned char* RegisterAdd,unsigned int bitNumber)
{
	*RegisterAdd |= (1<<bitNumber); 
}


//-----------------------------------------------------------------------------
// Function name : bit_clearChar
//-----------------------------------------------------------------------------
// Description : This function clear a bit of an unsigned char
//
// IN       :   RegisterAdd : Address of an unsigned char
//				bitNumber : Number of the bit to clear
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   - none -
//-----------------------------------------------------------------------------
void bit_clearChar(unsigned char* RegisterAdd,unsigned int bitNumber)
{
	*RegisterAdd &= 0xFFFFFFFF^(1<<bitNumber);  
}


//-----------------------------------------------------------------------------
// Function name : bit_setREG
//-----------------------------------------------------------------------------
// Description : This function set a of an unsigned long 
//
// IN       :   RegisterAdd : Address of an unsigned char
//				bitNumber : Number of the bit to clear
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   - none -
//-----------------------------------------------------------------------------
void bit_setREG(unsigned long* RegisterAdd,unsigned int bitNumber)
{
	*RegisterAdd |= (1<<bitNumber);
}


//-----------------------------------------------------------------------------
// Function name : bit_testREG
//-----------------------------------------------------------------------------
// Description : This function test a bit of an unsigned long (commonly used to clear a register bit)
//
// IN       :   RegisterAdd : Address of an unsigned long
//				bitMask : Mask of the bit to test (i.e to test bit 3 : bitMask=0x08)
// OUT      :   - none -
// RETURN   :   The value of the focused bit (0 or 1)
// Notes    :   - none -
//
//
//
//	i.e : 	bit_testREG(&TOIR,0x00000001);    Test the bit 0 of the register TOIR
//			bit_testREG(&TOIR,0x00000002);    Test the bit 1 of the register TOIR
//			bit_testREG(&TOIR,0x00000004);    Test the bit 2 of the register TOIR
//			bit_testREG(&TOIR,0x00000008);    Test the bit 3 of the register TOIR
//
//-----------------------------------------------------------------------------
unsigned char bit_testREG(unsigned long* RegisterAdd,unsigned long bitMask)
{
	if ((*(unsigned long*)RegisterAdd & bitMask)!=0)
	{
		return (TRUE);	
	}  
	else 
	{
		return(FALSE);
	}
}

 
//-----------------------------------------------------------------------------
// Function name : delay_us
//-----------------------------------------------------------------------------
// Description : This function waits X 祍    
//
// IN       :   delayus : Number of 祍 to wait  (here MINIMUM IS 50)
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   Here Timer 1 of the LP2129 is used
//				This function set the Timer 1 Matching Register value of the LP2129
//				with "Timer 1 Matching register value"= delayus * (Timer value of 1祍), then start the timer 1 from 0,
//				End wait until "Timer 1 value" < "Time 1 Matching Register value"  (until a timer event occurs)
//				
//-----------------------------------------------------------------------------
void delay_us(unsigned short delayus)
{

	unsigned short l_bdelay1us=ONE_U_SECOND;	 // Process l_bdelay1us according to the PLL settings for 1祍 value 
																	 // If a fixed PLL is used, or the PCLK is fast enough
																 // ,remove PLL_MSEL & PLL_PSEL from the l_bdelay1us calculation
  																	 // i.e  "unsigned long l_bdelay1us=0x03;"  0x03 should be change according to the target internal clock
																 // in order that when "delayus"=1, the function wait 1 祍	


  //STOP TIMER1 
                     
	T1TC=(unsigned long)0x00000000;									      // Reset Timer Counter 
	T1MCR = (unsigned long)0x00000001;                                    // Interrupt on MR0 and don't reset TC on match
	T1MR0 = (unsigned long)(l_bdelay1us * delayus);              // TC Init //ASSIGN TIME OUT 	 
	T1IR = (unsigned long)0x01;                            		  // Clear interrupt flag
	T1PR =(unsigned long) 0x00 ;		 						  // Prescale 0
	
	//START TIMER1
	T1TCR = (unsigned long)0x01;
	while(!(bit_testTimer1MR0IF()));
	T1TCR = (unsigned long)0x02;										// Timer1 Disable
	
}

//-----------------------------------------------------------------------------
// Function name : delay_ms
//-----------------------------------------------------------------------------
// Description : This function waits X ms    
//
// IN       :   delayus : Number of ms to wait  (here MINIMUM IS 50)
// OUT      :   - none -
// RETURN   :   - none -
// Notes    :   Here Timer 1 of the LP2129 is used
//				This function set the Timer 1 Matching Register value of the LP2129
//				with "Timer 1 Matching register value"= delayus * (Timer value of 1祍), then start the timer 1 from 0,
//				End wait until "Timer 1 value" < "Time 1 Matching Register value"  (until a timer event occurs)
//				
//-----------------------------------------------------------------------------
void delay_ms(unsigned char delayms)
{ 
	unsigned char l_iTemp;

	for(l_iTemp=0;l_iTemp<delayms;l_iTemp++)
	{
		delay_us(1000);								

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -