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

📄 clock.c

📁 驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
}

void set_day(Uint16 _data)
/*函数功能:设置日*/
/*参    数:_data:日:1--31*/
{
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)| 0x80;	//write a data to register B

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x07;					//latch the address of date
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=_data;					//write the _data to date

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)& 0x7f;	//write a data to register B

}

void set_hour(Uint16 _data)
/*函数功能:设置小时*/
/*参    数:_data:小时:0--23*/
{
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)| 0x80;	//write a data to register B

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x04;					//latch the address of hours
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=_data;					//write the _data to hours

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)& 0x7f;	//write a data to register B

}

void set_minute(Uint16 _data)
/*函数功能:设置分钟*/
/*参    数:_data:日:0--59*/
{
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)| 0x80;	//write a data to register B

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x02;					//latch the address of minuts
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=_data;					//write the _data to minuts

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)& 0x7f;	//write a data to register B

}

void set_second(Uint16 _data)
/*函数功能:设置秒*/
/*参    数:_data:日:0--59*/
{
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)| 0x80;	//write a data to register B

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x00;					//latch the address of second
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=_data;					//write the _data to second

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0b;					//latch the address of register B 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	(*pRt_Dcs_Addr)=(*pRt_Dcs_Addr)& 0x7f;	//write a data to register B


}

Uint16 century(void)
/*函数功能:读世纪*/
/*返    回:世纪:0--99*/
{
	Uint16 c;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	c=(Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(c !=0) {};	//

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0e;					//latch the address of century

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	c=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(c);								//read the century & renturn it to main-subrouting

}

Uint16 year(void)
/*函数功能:读年*/
/*返    回:年:0--99*/
{
	Uint16 y;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	y=(Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(y !=0) {};						//	

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x09;					//latch the address of year

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	y=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(y);								//read the year & renturn it to main-subrouting

}

Uint16 month(void)
/*函数功能:读月*/
/*返    回:月:1--12*/
{
	Uint16 m;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
		
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	m=(Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(m !=0) {};						//

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x08;					//latch the address of month

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	m=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(m);								//read the month & renturn it to main-subrouting

}

Uint16 day(void)
/*函数功能:读日*/
/*返    回:日:1--31*/
{
	Uint16 d;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	d= (Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(d !=0) {};						//

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x07;					//latch the address of day
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	d=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(d);								//read the day & renturn it to main-subrouting

}

Uint16 hour(void)
/*函数功能:读小时*/
/*返    回:小时:0--23*/
{
	Uint16 h;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
		
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	h= (Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(h !=0) {};						//

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x04;					//latch the address of hours

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	h= (Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(h);								//read the hours & renturn it to main-subrouting

}

Uint16 minute(void)
/*函数功能:读分钟*/
/*返    回:分钟:0--59*/
{
	Uint16 m;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
	
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	m=(Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(m !=0) {};		//

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x02;					//latch the address of minuts

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	m=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(m);					//read the minuts & renturn it to main-subrouting

}

Uint16 second(void)
/*函数功能:读秒*/
/*返    回:秒:0--59*/
{
	Uint16 s;
	Uint16 *pRt_Acs_Addr,*pRt_Dcs_Addr;
/*		
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	s=(Uint16) ((*pRt_Dcs_Addr) & 0x80);
	while(s !=0) {};						//
*/
	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x0a;					//latch the address of register A 
	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	s=(Uint16) ((*pRt_Dcs_Addr) & 0x80);

	pRt_Acs_Addr =(Uint16 *)ADD_RT_ACS;
	(*pRt_Acs_Addr)=0x00;					//latch the address of second

	pRt_Dcs_Addr =(Uint16 *)ADD_RT_DCS;
	s=(Uint16) ((*pRt_Dcs_Addr) & 0x0ff);
	return(s);								//read the second & renturn it to main-subrouting

}
//===========================================================================
// No more.
//===========================================================================

⌨️ 快捷键说明

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