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

📄 pcf8563.c

📁 pcf8583实时时钟芯片单片机C51几口程序
💻 C
字号:
/*******************************************************************************
**                            (c) Copyright 2004-2005, xujiajun
**                                    All Rights Reserved
**                                        V040723
**--------------文件信息--------------------------------------------------------
**创   建   人: 徐家俊
**创建日期: 2006年1月20日
**描        述:PCF8563驱动
**--------------版本修订历史----------------------------------------------------
** 修改人:徐家俊
** 版  本: V
** 日 期: 年月日
** 描 述:
**--------------当前版本修订----------------------------------------------------
** 修改人:徐家俊
** 版  本:
** 日 期:年月日
** 描 述:
**------------------------------------------------------------------------------
*******************************************************************************/
#define IN_PCF8563
#include"main.h"

#define ADDR_8563       0xA2       //地址(时钟)
/********************************************************************************************************
 Descriptions:          initial PCF8563
 input parameters:      None
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
bit InitialPCF8563(void)
{
    uchar Data = 0x08;
    return ISendStr(ADDR_8563, 0, &Data, 1);
}
/********************************************************************************************************
 Descriptions:          read second
 input parameters:      None
 Returned value:        return second in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
uchar ReadSecond(void)
{
    uchar sec;
    IRcvStr(ADDR_8563, 0x02, &sec, 1);
    sec &= 0x7f;
    return sec;
}
/********************************************************************************************************
 Descriptions:          set second
 input parameters:      Sec : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetSecond(uchar Sec)
//{
//  return ISendStr(ADDR_8563, 0x02, &Sec, 1);
//}
/********************************************************************************************************
 Descriptions:          read minute
 input parameters:      None
 Returned value:        return second in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
uchar ReadMinute(void)
{
    uchar Min;
    IRcvStr(ADDR_8563, 0x03, &Min, 1);
    Min &= 0x7f;
    return Min;
}
/********************************************************************************************************
 Descriptions:          set minute
 input parameters:      minute : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetMinute(uchar Min)
//{
//  return ISendStr(ADDR_8563, 0x03, &Min, 1);
//}
/********************************************************************************************************
 Descriptions:          read hour
 input parameters:      None
 Returned value:        return in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
uchar ReadHour(void)
{
    uchar Hour;
    IRcvStr(ADDR_8563, 0x04, &Hour, 1);
    Hour &= 0x3f;
    return Hour;
}
/********************************************************************************************************
 Descriptions:          set Hour
 input parameters:      Hour : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetHour(uchar Hour)
//{
//  return ISendStr(ADDR_8563, 0x04, &Hour, 1);
//}
/********************************************************************************************************
 Descriptions:          read date
 input parameters:      None
 Returned value:        return in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//uchar ReadDate(void)
//{
//  uchar Date;
//  IRcvStr(ADDR_8563, 0x05, &Date, 1);
//  Date &= 0x3f;
//  return Date;
//}
/********************************************************************************************************
 Descriptions:          set date
 input parameters:      date : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetDate(uchar Date)
//{
//  return ISendStr(ADDR_8563, 0x05, &Date, 1);
//}
/********************************************************************************************************
 Descriptions:          read week
 input parameters:      None
 Returned value:        return in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//uchar ReadWeek(void)
//{
//  uchar Week;
//  IRcvStr(ADDR_8563, 0x06, &Week, 1);
//  Week &= 0x07;
//  return Week;
//}
/********************************************************************************************************
 Descriptions:          set week
 input parameters:      week : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetWeek(uchar Week)
//{
//  return ISendStr(ADDR_8563, 0x06, &Week, 1);
//}
/********************************************************************************************************
 Descriptions:          read month
 input parameters:      None
 Returned value:        return in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//uchar ReadMonth(void)
//{
//  uchar Month;
//  IRcvStr(ADDR_8563, 0x07, &Month, 1);
//  Month &= 0x1f;
//  return Month;
//}
/********************************************************************************************************
 Descriptions:          set month
 input parameters:      month : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetMonth(uchar Month)
//{
//  return ISendStr(ADDR_8563, 0x07, &Month, 1);
//}
/********************************************************************************************************
 Descriptions:          read year
 input parameters:      None
 Returned value:        return in the format BCD code
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//uchar ReadYear(void)
//{
//  uchar Year;
//  IRcvStr(ADDR_8563, 0x08, &Year, 1);
//  Year &= 0x1f;
//  return Year;
//}
/********************************************************************************************************
 Descriptions:          set year
 input parameters:      year : in the format of BCD code
 Returned value:        return 1 success; 0 failed
 Used global variables: None
 Calling modules:       None
 Created by:            xjj 2006/01/20
-------------------------------------------------------------------------------------------------------
 Modified by:
********************************************************************************************************/
//bit SetYear(uchar Year)
//{
//  return ISendStr(ADDR_8563, 0x08, &Year, 1);
//}

⌨️ 快捷键说明

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