有一个函数想把多个值传出函数,用指针,试了一下没法编译成功,想请问一下是什么原因?这个函数写在DS1302.C 里
void GET_TIME_DS1302(char *hour , char *min , char *mon , char *date)
{
uchar ho,mi,mo,da;
ho = RW_DATA_DS1302(0x83); //read min
mi = RW_DATA_DS1302(0x85); //read hour
mo = RW_DATA_DS1302(0x87); //read date
da = RW_DATA_DS1302(0x89); //read mon
*hour = &ho;
*min = &mi;
*mon = &mo;
*date = &da;
}
把取出的时间日期使用指针在main函数中调用,但是没成功,这是怎么回事?想请教一下大家我这样调用是不是有问题?
#include"STC12.H"
#include"74HC595.H"
#include"DS1302.H"
#define uchar unsigned char
#define uint unsigned int
void main ()
{
char hour,min,mon,date;
SET_TIME_DS1302();
while(1)
{
GET_TIME_DS1302(char & hour , char & min , char & mon , char & date);
if(*min < 0x01)//看取出的分钟是否小于0x01
{
WR_595(0xff);//是的话就让74hc595全部输出1
OUT_595();
}
else
{
WR_595(0x0f);//是的话就让74hc595 4个通道输出1
OUT_595();
}
}
}
|