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

📄 x1226.h

📁 详细介绍了arm7-at91r40008,的开发全过程
💻 H
字号:
/*----------------------------------------------------------------------------
* File Name           : x1226.h
* Object              : DF9311zk Board clock and eeprom Definition File.
*
* 1.0 23/Apr/00  PFi  : Creation
* 1.1 11/Jan/02  PFi  : Internal/External SRAM Definition Clean-up
*----------------------------------------------------------------------------
*/
#ifndef x1226_h
#define x1226_h

#define		TARGET		"DF9311"

//x1226命令定义
#define CCR	            0xde	    //时钟控制寄存器前七位
#define Eeprom_Array 	0xae		//eeprom控制寄存器前七位
//#define Read	0x01			    //读命令	寄存器最低位
//#define Write   0x00			    //写命令	寄存器最低位
//x1226 状态寄存器
#define	STATUSREG	0x3f			//状态寄存器
#define BAT	(1<<7)			        //电池提供电源1
#define AL1	(1<<6)			        //AL1报警
#define AL0	(1<<5)			        //AL0报警
#define RWEL	(1<<2)			    //寄存器写使能闭锁
#define WEL	(1<<1)			        //写使能闭锁
#define RTCF    (1<<0)			    //试时时钟失败位
//x1226 寄存器地址
#define RTC_Y2K	0x37			    //千年位	19/20
#define Y2K21  	(1<<5)
#define Y2K20	(1<<4)
#define Y2K13	(1<<3)
#define Y2K10	(1<<0)

#define RTC_DW 	0x36			//星期位	0---6
#define DY2	(1<<2)
#define DY1	(1<<1)
#define DY0	(1<<0)

#define RTC_YR	0x35			//年位		00--99
#define Y23	(1<<7)
#define Y22	(1<<6)
#define Y21	(1<<5)
#define Y20	(1<<4)
#define Y13	(1<<3)
#define Y12	(1<<2)
#define Y11	(1<<1)
#define Y10	(1<<0)

#define RTC_MO  0x34			//月位		1----12
#define G20	(1<<4)
#define G13	(1<<3)
#define G12	(1<<2)
#define G11	(1<<1)
#define G10	(1<<0)

#define RTC_DT	0x33			//日位		1---31
#define D21	(1<<5)
#define D20	(1<<4)
#define D13	(1<<3)
#define D12	(1<<2)
#define D11	(1<<1)
#define D10	(1<<0)

#define	RTC_HR	0x32			//小时位	0----23
#define MIL	(1<<7)
#define H21	(1<<5)
#define H20	(1<<4)
#define H13	(1<<3)
#define H12	(1<<2)
#define H11	(1<<1)
#define H10	(1<<0)

#define	RTC_MN  0x31			//分钟位	0----59
#define M22	(1<<6)
#define M21	(1<<5)
#define M20	(1<<4)
#define M13	(1<<3)
#define M12	(1<<2)
#define M11	(1<<1)
#define M10	(1<<0)

#define	RTC_SC	0x30			//秒位		0----59
#define S22	(1<<6)
#define S21	(1<<5)
#define S20	(1<<4)
#define S13	(1<<3)
#define S12	(1<<2)
#define S11	(1<<1)
#define S10	(1<<0)


#define	Control_DTR	0x13		//数字清理寄存器
#define DTR2	(1<<2)
#define DTR1	(1<<1)
#define DTR0	(1<<0)
/*----------------------------------------------------------------*/
//	DTR2   DTR1    DTR0		Estimated Frequency PPM
//	 0      0       0			0
//	 0      1       0			+10
//	 0      0       1			+20
//	 0      1       1			+30
//	 1      0       0			0
//	 1      1       0			-10
//	 1      0       1			-20
//	 1      1       1			-30
/*-----------------------------------------------------------------*/
#define	Control_ATR	0x12		//模拟清理寄存器

#define	Control_INT	0x11		//中断控制和频率输出寄存器
#define IM	(1<<7)			//中断/报警频率
#define AL1E	(1<<6)			//报警1使能
#define AL0E	(1<<5)			//报警0使能
#define FO1	(1<<4)			//可编程频率输出位
#define FO0	(1<<3)			//可编程频率输出位
/*------------------------------------------------------------------*/
//	FO1	FO0	output frequency
//	0	0	报警中断输出
//	0	1	32.768kHz
//	1	0	4096Hz
//	1	1	1Hz
/*------------------------------------------------------------------*/
#define	Control_BL	0x10		//块保护位
#define BP2		(1<<7)
#define BP1		(1<<6)
#define BP0		(1<<5)
/*------------------------------------------------------------------*/
//	BP2	BP1	BP0	保护地址	Array Lock
//	0	0	0	None		None
//	0	0	1	6000h-7fffh	Upper 1/4
//	0	1	0	4000h-7fffh	Uppre 1/2
//	0	1	1	0000h-7fffh	Full Array
//	1	0	0	0000h-007fh	First Page
//	1	0	1	0000h-00ffh	first 2 Page
//	1	1	0	0000h-01ffh	first 4 Page
//	1	1	1	0000h-03ffh	first 8 Page
/*-------------------------------------------------------------------*/
#define	Alarm1_Y2K1	0x0f		//报警1千年位	19/20
#define A1Y2K21  	(1<<5)
#define A1Y2K20		(1<<4)
#define A1Y2K13		(1<<3)
#define A1Y2K10		(1<<0)

#define	Alarm1_DWA1	0x0e		//报警1星期位	0---6
#define EWD1	(1<<7)
#define DY2	(1<<2)
#define DY1	(1<<1)
#define DY0	(1<<0)

#define	Alarm1_YRA1	0x0d		//报警1年位	00--99

#define	Alarm1_MOA1	0x0c		//报警1月位	1----12
#define EMO1	(1<<7)
#define A1G20	(1<<4)
#define A1G13	(1<<3)
#define A1G12	(1<<2)
#define A1G11	(1<<1)
#define A1G10	(1<<0)

#define	Alarm1_DTA1	0x0b		//报警1日位	1----31
#define EDT1	(1<<7)
#define A1D21	(1<<5)
#define A1D20	(1<<4)
#define A1D13	(1<<3)
#define A1D12	(1<<2)
#define A1D11	(1<<1)
#define A1D10	(1<<0)
#define	Alarm1_HRA1	0x0a		//报警1小时位	0----23
#define EHR1	(1<<7)
#define A1H21	(1<<5)
#define A1H20	(1<<4)
#define A1H13	(1<<3)
#define A1H12	(1<<2)
#define A1H11	(1<<1)
#define A1H10	(1<<0)

#define	Alarm1_MNA1	0x09		//报警1分钟位	0----59
#define EMN1	(1<<7)
#define A1M22	(1<<6)
#define A1M21	(1<<5)
#define A1M20	(1<<4)
#define A1M13	(1<<3)
#define A1M12	(1<<2)
#define A1M11	(1<<1)
#define A1M10	(1<<0)

#define	Alarm1_SCA1	0x08		//报警1秒位	0----59
#define	ESA1	(1<<7)
#define A1S22	(1<<6)
#define A1S21	(1<<5)
#define A1S20	(1<<4)
#define A1S13	(1<<3)
#define A1S12	(1<<2)
#define A1S11	(1<<1)
#define A1S10	(1<<0)

#define	A0arm0_Y2K0	0x07		//报警0千年位	19/20
#define A0Y2K21  	(1<<5)
#define A0Y2K20		(1<<4)
#define A0Y2K13		(1<<3)
#define A0Y2K10		(1<<0)

#define	A0arm0_DWA0	0x06		//报警0星期位	0---6
#define EWD0	(1<<7)
#define DY2	(1<<2)
#define DY1	(1<<1)
#define DY0	(1<<0)
#define	A0arm0_YRA0	0x05		//报警0年位	00--99
#define	A0arm0_MOA0	0x04		//报警0月位	1----12
#define EMO0	(1<<7)
#define A0G20	(1<<4)
#define A0G13	(1<<3)
#define A0G12	(1<<2)
#define A0G11	(1<<1)
#define A0G10	(1<<0)
#define	A0arm0_DTA0	0x03		//报警0日位	1----31
#define EDT0	(1<<7)
#define A0D21	(1<<5)
#define A0D20	(1<<4)
#define A0D13	(1<<3)
#define A0D12	(1<<2)
#define A0D11	(1<<1)
#define A0D10	(1<<0)
#define	A0arm0_HRA0	0x02		//报警0小时位	0----23
#define EHR0	(1<<7)
#define A0H21	(1<<5)
#define A0H20	(1<<4)
#define A0H13	(1<<3)
#define A0H12	(1<<2)
#define A0H11	(1<<1)
#define A0H10	(1<<0)
#define	A0arm0_MNA0	0x01		//报警0分钟位	0----59
#define EMN0	(1<<7)
#define A0M22	(1<<6)
#define A0M21	(1<<5)
#define A0M20	(1<<4)
#define A0M13	(1<<3)
#define A0M12	(1<<2)
#define A0M11	(1<<1)
#define A0M10	(1<<0)
#define	A0arm0_SCA0	0x00		//报警0秒位	0----59
#define	ESA0	(1<<7)
#define A0S22	(1<<6)
#define A0S21	(1<<5)
#define A0S20	(1<<4)
#define A0S13	(1<<3)
#define A0S12	(1<<2)
#define A0S11	(1<<1)
#define A0S10	(1<<0)



//* The write cycle time X1226_TWR is the time from a valid stop condition
//* of a write sequence to the end of the internal clear/write cycle.

#define     X1226_TWR                5          //* 10 ms for VCC >= 2.7 V//20

#define     X1226_PAGE_LENGTH        8     //* x1226 structure
#define     X1226_NB_PAGE            8
#define     X1226_EPROM_SIZE         (X1226_NB_PAGE*X1226_PAGE_LENGTH) //* 64 Kbyte
#define     X1226_EEPROM_LENGTH      64
/*---------------------------  Structure definition -------------------------*/

extern      I2Cdesc     I2C_line ;

/*---------------------------  Function Prototyping -------------------------*/
typedef struct
{
  u_char Second;
  u_char Minute;
  u_char Hour;
  u_char Day;
  u_char Month;
  u_char Year;
  u_char Week;
  u_char YearH;
}TSysTime;

extern void tc2_interrupt_handler(void) ;
void no_handler_tc (I2Cdesc *I2C_pt);
void at91_I2CError(I2Cdesc *I2C_pt);

void IIC_Init(const PioCtrlDesc *pio_pt, INT32U speed, INT32U sda, INT32U scl );
void IIC_TransfertEnd(void);

void Clock_Write( INT16U address, INT8U *data_array, INT32U num_bytes, INT32U mck );
void Clock_Read(INT16U address, INT8U *data_array, INT32U num_bytes );
 
 
void EEprom_Write( INT16U address, INT8U *data_array, INT32U num_bytes, INT32U mck );
void EEprom_Read(INT16U address, INT8U *data_array, INT32U num_bytes );

void WriteSysTime(TSysTime *);
void ReadSysTime(TSysTime *);

void WriteEEprom(INT16U addr,INT8U *buf,INT16U num);
void ReadEEprom(INT16U addr,INT8U *buf,INT16U num);

void Timer2SwitchToI2C(void);      //将定时器2切换到I2C模式;
void Timer2SwitchToFreq(void);     //将定时器2切换到采集频率模式;

 
#endif /* df9311zk_h */

⌨️ 快捷键说明

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