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

📄 lpc2129_paypass_ttal1_functions.h

📁 读RF卡的源代码
💻 H
字号:
//=============================================================================
//                  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 : PAYPASS LIBRARY
// Project Name : PAYPASS LIBRARY
// Module Name  : LPC2129_PAYPASS_TTAL1_FUNCTIONS.H
// Platform dev : Keil 礦ision 3 (IDE ) + Keil ARM Compiler
// Target       : LPC2129 (ARM7TDMI Core) MCB2100 Vers.3
// Language     : C ANSI
// Revision     : 1.2
// 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

#ifndef __LPC2129_PAYPASS_TTAL1_FUNCTIONS_H__
#define __LPC2129_PAYPASS_TTAL1_FUNCTIONS_H__

/* bit Mask Macros */
#define BIT0_MASK  0x00000001
#define BIT1_MASK  0x00000002
#define BIT2_MASK  0x00000004
#define BIT3_MASK  0x00000008
#define BIT4_MASK  0x00000010
#define BIT5_MASK  0x00000020
#define BIT6_MASK  0x00000040
#define BIT7_MASK  0x00000080
#define BIT8_MASK  0x00000100
#define BIT9_MASK  0x00000200
#define BIT10_MASK 0x00000400
#define BIT11_MASK 0x00000800
#define BIT12_MASK 0x00001000
#define BIT13_MASK 0x00002000
#define BIT14_MASK 0x00004000
#define BIT15_MASK 0x00008000
#define BIT16_MASK 0x00010000
#define BIT17_MASK 0x00020000
#define BIT18_MASK 0x00040000
#define BIT19_MASK 0x00080000
#define BIT20_MASK 0x00100000
#define BIT21_MASK 0x00200000
#define BIT22_MASK 0x00400000
#define BIT23_MASK 0x00800000

#define T0MR0IF			0
#define T1MR0IF			0


/*-------HERE IS THE CODE THAT AS TO BE MODIFIED ACCORDING TO THE USER NEEDS-------  */
/* IO PORT CHOOSEN HERE IS PORT 0   */
/* Change to your own IOs */
#define SDO_MASK 		BIT10_MASK		 //P0.10  SDO 礐    bit 10 of the choosen IO port
#define SDI_MASK		BIT11_MASK		 //P0.11  SDI 礐	...
#define SCK_MASK 		BIT12_MASK		 //P0.12  SCK 礐	...
#define CS_MASK  		BIT13_MASK		 //P0.13  CS  礐	...


#define DEBUGPIN_MASK 	BIT8_MASK  	 	 // Optional
#define DEBUGPIN2_MASK 	BIT16_MASK  	 // Optional


/* see also PLL settings and IO Initialization in v_fnInitRegsAndPorts function
/*----------------------------------------------------------------------------------------------*/


/* CLOCK DEFINES      see also PLL settings and IO Initialization in v_fnInitRegsAndPorts function
/*----------------------------------------------------------------------------------------------*/
// DEFINES FOR THE PLL   See LPC2103 datasheet

#define XTAL	13560

#define PLL_MSEL 	0x03		// M=4
#define PLL_PSEL	0x01		// P=2  

#define APBDIV_DIVIDER	1		   //PCLK=XTAL
//#define APBDIV_DIVIDER	2		   //PCLK=XTAL/2
//#define APBDIV_DIVIDER	4		   //PCLK=XTAL/4

/* --------------------------------------------- */

#define PLL_M	(PLL_MSEL+1)		// Integer value M
#define PLL_P	(PLL_PSEL+1)		// Integer value P 

#define PLLCFG_VALUE	((PLL_PSEL<<5) | PLL_MSEL)

/* APBDIV VPBDIV DEFINES  */

#define CCLK    (XTAL*PLL_M)




#if (APBDIV_DIVIDER==1)
#define APBDIV_REGVALUE  0x01
#endif
#if (APBDIV_DIVIDER==2)
#define APBDIV_REGVALUE  0x02
#endif
#if (APBDIV_DIVIDER==4)
#define APBDIV_REGVALUE  0x00
#endif

#define PCLK	 (CCLK/APBDIV_DIVIDER)

/* --------------------------------------------- */


/* TIMERS DEFINES   */
/*----------------------------------------------------------------------------------------------*/
//#define ONE_U_SECOND	((0x0E*APBDIV_DIVIDER)*PLL_M)

#define ONE_U_SECOND	0x37  //55				// FOR APDIV=1 & PLL_M=4	 = 1,014 US

#define TIMER_0_PRESCALER  0x00000000L



/*Macro functions*/
#define setDEBUG_PIN() 				IOSET0 = DEBUGPIN_MASK	 //Optional   Set DEBUG PIN to 1
#define clearDEBUG_PIN() 			IOCLR0 = DEBUGPIN_MASK	 //Optional	  Set DEBUG PIN to 0

#define setDEBUG_PIN2() 			IOSET0 = DEBUGPIN2_MASK	 //Optional	  Set DEBUG PIN 2 to 1
#define clearDEBUG_PIN2() 			IOCLR0 = DEBUGPIN2_MASK	 //Optional   Set DEBUG PIN 2 to 0


//Timer 0 is used in v_fnDefineTimeout & v_fnStartTimeOut functions																 // Test if time out occurs
#define bit_testTimer0MR0IF() 		((T0IR & 0x00000001)==1)	 // Test if Timer 0 Interrupt Flag is set (Test if "Timer 0 value" > "Timer 0 Matching Register value")

//Timer 0 is used in v_fnDefineTimeout & v_fnStartTimeOut functions
#define bit_clearTimer0MR0IF()      bit_setREG(&T0IR,T0MR0IF)	 // Clear Timer 0 Interrupt Flag IF (Set to 1 in fact = clear IF)

//Timer 1 is used in delay_us function							// Test if time defined in delay_us is out
#define bit_testTimer1MR0IF() 	((T1IR & 0x00000001)==1)  // Test if Timer 1 Interrupt Flag is set (Test if "Timer 1 value" > "Timer 1 Matching Register value")

#define testSDI_PIN() 	(IOPIN0 & SDI_MASK)     // TEST VALUE OF SDI PIN of MCU	(IO PORT 0 Pointed)

#define setSDO_PIN() 	IOSET0 = SDO_MASK	  // SET SD0 PIN OF MCU TO 1
#define clearSDO_PIN()	IOCLR0 = SDO_MASK	  // SET SD0 PIN OF MCU TO 0

#define setSDI_PIN()	IO0SET = SDI_MASK	  // SET SDI PIN OF MCU TO 1
#define clearSDI_PIN()	IO0CLR = SDI_MASK	  // SET SDI PIN OF MCU TO 0

#define setSCK_PIN()	IOSET0 = SCK_MASK	  // SET SCK PIN OF MCU TO 1
#define clearSCK_PIN()	IOCLR0 = SCK_MASK	  // SET SCK PIN OF MCU TO 0

#define setCS_PIN()	IOSET0 = CS_MASK	  	  // SET CS PIN OF MCU TO 1
#define clearCS_PIN()	IOCLR0 = CS_MASK	  	  // SET CS PIN OF MCU TO 0




extern int 				kbhit				();
extern unsigned char 		bit_testChar		(unsigned char* RegisterAdd,unsigned int bitNumber);
extern void 			bit_setChar			(unsigned char* RegisterAdd, unsigned int bitNumber);
extern void 			bit_clearChar		(unsigned char* RegisterAdd, unsigned int bitNumber);
extern void				bit_setREG			(unsigned long* RegisterAdd, unsigned int bitNumber);
extern unsigned char		bit_testREG			(unsigned long* RegisterAdd, unsigned long bitMask);
extern void 			delay_us			(unsigned short delayus);
extern void 			delay_ms			(unsigned char delayms);
extern void				v_fnDefineTimeout	(unsigned long p_lTimeout);
extern void				v_fnTimeOutStart	();
extern void				v_fnInitRegsAndPorts();
extern unsigned char 		APBDivider;

#endif // __LPC2129_PAYPASS_TTAL1_FUNCTIONS_H__

⌨️ 快捷键说明

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