久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1065|回復(fù): 0
收起左側(cè)

關(guān)于STM32單片機(jī)PCF8563 IIC驅(qū)動 pcf8563.c pcf8563.h文件

[復(fù)制鏈接]
ID:1118668 發(fā)表于 2024-4-28 11:33 | 顯示全部樓層 |閱讀模式
代碼直接貼出來嗷 需要的友友直接下載就好了

pcf8563.c
  1. /**
  2.   *****************************************************************************
  3.   *                            時鐘芯片PCF8563驅(qū)動
  4.   * @File    : pcf8563.c
  5.   * @By      : shun
  6.   * @Version : V1.0
  7.   * @Date    : 2018 / 12 / 13
  8.   *
  9.   *****************************************************************************
  10. **/


  11. #include "pcf8563.h"


  12. /******************************************************************************
  13.                             定義相關(guān)的變量函數(shù)
  14. ******************************************************************************/

  15. unsigned char buffer[4];   //年月日周
  16. unsigned char buffer1[4];  //時分秒

  17. /**
  18.   *****************************************************************************
  19.   * @Name   : 將BIN轉(zhuǎn)換為BCD
  20.   *
  21.   * @Brief  : none
  22.   *
  23.   * @Input  : BINValue: 輸入BIN
  24.   *
  25.   * @Output : none
  26.   *
  27.   * @Return : BCD格式數(shù)值
  28.   *****************************************************************************
  29. **/
  30. static unsigned char RTC_BinToBcd2(unsigned char BINValue)
  31. {
  32.         unsigned char bcdhigh = 0;
  33.         
  34.         while (BINValue >= 10)
  35.         {
  36.                 bcdhigh++;
  37.                 BINValue -= 10;
  38.         }
  39.    
  40.         return ((unsigned char)(bcdhigh << 4) | BINValue);
  41. }

  42. /**
  43.   *****************************************************************************
  44.   * @Name   : 將BCD轉(zhuǎn)換為BIN
  45.   *
  46.   * @Brief  : none
  47.   *
  48.   * @Input  : BCDValue: 輸入BCD
  49.   *
  50.   * @Output : none
  51.   *
  52.   * @Return : BIN格式數(shù)值
  53.   *****************************************************************************
  54. **/
  55. static unsigned char RTC_Bcd2ToBin(unsigned char BCDValue)
  56. {
  57.         unsigned char tmp = 0;
  58.         
  59.         tmp = ((unsigned char)(BCDValue & (unsigned char)0xF0) >> (unsigned char)0x04) * 10;
  60.         return (tmp + (BCDValue & (unsigned char)0x0F));
  61. }

  62. /******************************************************************************
  63.   * @Name   : PCF8563某寄存器寫入一個字節(jié)數(shù)據(jù)
  64.   *
  65.   * @Brief  : none
  66.   *
  67.   * @Input  : REG_ADD:要操作寄存器地址
  68.   *           dat:    要寫入的數(shù)據(jù)
  69.   *
  70.   * @Output : none
  71.   *
  72.   * @Return : none
  73. **/
  74. void PCF8563_Write_Byte(unsigned char REG_ADD, unsigned char dat)
  75. {
  76.         IIC_Start();                          //啟動IIC
  77.         if(!(IIC_Write_Byte(PCF8563_Write)))  //發(fā)送寫命令并檢查應(yīng)答位
  78.         {
  79.                 IIC_Write_Byte(REG_ADD);          //寫入地址
  80.                 IIC_Write_Byte(dat);              //發(fā)送數(shù)據(jù)
  81.         }
  82.         IIC_Stop();                           //關(guān)閉IIC
  83. }

  84. /******************************************************************************
  85.   * @Name   : PCF8563某寄存器讀取一個字節(jié)數(shù)據(jù)
  86.   *
  87.   * @Brief  : none
  88.   *
  89.   * @Input  : REG_ADD:要操作寄存器地址
  90.   *
  91.   * @Output : none
  92.   *
  93.   * @Return : 讀取得到的寄存器的值
  94.   *****************************************************************************
  95. **/
  96. unsigned char PCF8563_Read_Byte(unsigned char REG_ADD)
  97. {
  98.         unsigned char ReData;                 //定義變量接收數(shù)據(jù)
  99.         
  100.         IIC_Start();                          //啟動IIC
  101.         if(!(IIC_Write_Byte(PCF8563_Write)))  //發(fā)送寫命令并檢查應(yīng)答位
  102.         {
  103.                 IIC_Write_Byte(REG_ADD);          //確定要操作的寄存器
  104.                 IIC_Start();                      //重啟總線
  105.                 IIC_Write_Byte(PCF8563_Read);     //發(fā)送讀取命令
  106.                 ReData = IIC_Read_Byte( );        //讀取數(shù)據(jù)
  107.                 IIC_Ack(1);                       //發(fā)送非應(yīng)答信號結(jié)束數(shù)據(jù)傳送
  108.         }
  109.         IIC_Stop();                           //關(guān)閉IIC
  110.         return ReData;
  111. }

  112. /******************************************************************************
  113.   * @Name   : PCF8563寫入多組數(shù)據(jù)
  114.   *
  115.   * @Brief  : none
  116.   *
  117.   * @Input  : REG_ADD:要操作寄存器起始地址
  118.   *           num:    寫入數(shù)據(jù)數(shù)量
  119.   *           *WBuff: 寫入數(shù)據(jù)緩存
  120.   *
  121.   * @Output : none
  122.   *
  123.   * @Return : none
  124.   *****************************************************************************
  125. **/
  126. void PCF8563_Write_nByte(unsigned char REG_ADD, unsigned char num, unsigned char *pBuff)
  127. {
  128.         unsigned char i = 0;                  //定義i輔助循環(huán)發(fā)送
  129.                         
  130.         IIC_Start();                          //啟動IIC
  131.         if(!(IIC_Write_Byte(PCF8563_Write)))  //發(fā)送寫命令并檢查應(yīng)答位
  132.         {
  133.                 IIC_Write_Byte(REG_ADD);          //定位起始寄存器地址
  134.                 for(i = 0;i < num;i++)            //循環(huán)num次,達(dá)到多個數(shù)據(jù)寫入
  135.                 {
  136.                         IIC_Write_Byte(*pBuff);       //寫入數(shù)據(jù)
  137.                         pBuff++;                      //數(shù)據(jù)緩存地址增加
  138.                 }
  139.         }
  140.         IIC_Stop();                           //關(guān)閉IIC
  141. }

  142. /******************************************************************************
  143.   * @Name   : PCF8563讀取多組數(shù)據(jù)
  144.   *
  145.   * @Brief  : none
  146.   *
  147.   * @Input  : REG_ADD:要操作寄存器起始地址
  148.   *           num:    讀取數(shù)據(jù)數(shù)量
  149.   *
  150.   * @Output : *WBuff: 讀取數(shù)據(jù)緩存
  151.   *
  152.   * @Return : none
  153.   *****************************************************************************
  154. **/
  155. void PCF8563_Read_nByte(unsigned char REG_ADD, unsigned char num, unsigned char *pBuff)
  156. {
  157.         unsigned char i = 0;                  //定義變量i輔助多次讀取
  158.         
  159.         IIC_Start();                          //啟動IIC
  160.         if(!(IIC_Write_Byte(PCF8563_Write)))  //發(fā)送寫命令并檢查應(yīng)答位
  161.         {
  162.                 IIC_Write_Byte(REG_ADD);          //定位起始寄存器地址
  163.                 IIC_Start();                      //重啟總線
  164.                 IIC_Write_Byte(PCF8563_Read);     //發(fā)送讀取命令
  165.                 for(i = 0;i < num;i++)            //循環(huán)num次完成多次讀取
  166.                 {
  167.                         *pBuff = IIC_Read_Byte();     //讀取數(shù)據(jù)
  168.                         if(i == (num - 1)) IIC_Ack(1);//發(fā)送非應(yīng)答信號,知道完成數(shù)據(jù)量
  169.                         else IIC_Ack(0);              //發(fā)送應(yīng)答信號
  170.                         pBuff++;                      //讀取緩沖區(qū)地址增加
  171.                 }
  172.         }
  173.         IIC_Stop();                                  //關(guān)閉IIC
  174. }

  175. /******************************************************************************
  176.   * @Name   : PCF8563檢測是否存在
  177.   *
  178.   * @Brief  : 向定時器倒計(jì)時寄存器寫入一個數(shù)值再讀取出來做對比,相同正確,不同則錯誤
  179.   *
  180.   * @Input  : none
  181.   *
  182.   * @Output : none
  183.   *
  184.   * @Return : 0: 正常
  185.   *           1: PCF8563錯誤或者損壞
  186.   *****************************************************************************
  187. **/
  188. unsigned char PCF8563_Check(void)
  189. {
  190.         unsigned char test_value = 0;
  191.         unsigned char Time_Count = 0;          //定時器倒計(jì)時數(shù)據(jù)緩存

  192.         if(PCF8563_Read_Byte(PCF8563_Address_Timer) & 0x80)             //如果打開了定時器,則先關(guān)閉
  193.         {
  194.                 PCF8563_Write_Byte(PCF8563_Address_Timer, PCF_Timer_Close); //先關(guān)閉定時器
  195.                 Time_Count = PCF8563_Read_Byte(PCF8563_Address_Timer_VAL);  //先保存計(jì)數(shù)值
  196.         }

  197.         PCF8563_Write_Byte(PCF8563_Address_Timer_VAL, PCF8563_Check_Data);  //寫入檢測值
  198.         for(test_value = 0;test_value < 50;test_value++)  {}  //延時一定時間再讀取
  199.         test_value = PCF8563_Read_Byte(PCF8563_Address_Timer_VAL);  //再讀取回來

  200.         if(Time_Count != 0)  //啟動了定時器功能,則恢復(fù)
  201.         {
  202.                 PCF8563_Write_Byte(PCF8563_Address_Timer_VAL, Time_Count);  //恢復(fù)現(xiàn)場
  203.                 PCF8563_Write_Byte(PCF8563_Address_Timer, PCF_Timer_Open);  //啟動定時器
  204.         }

  205.         if(test_value != PCF8563_Check_Data)  return 1;  //器件錯誤或者損壞
  206.         
  207.         return 0;  //正常
  208. }

  209. /**
  210.   *****************************************************************************
  211.   * @Name   : PCF8563啟動
  212.   *
  213.   * @Brief  : none
  214.   *
  215.   * @Input  : none
  216.   *
  217.   * @Output : none
  218.   *
  219.   * @Return : none
  220.   *****************************************************************************
  221. **/
  222. void PCF8563_Start(void)
  223. {
  224.         unsigned char temp = 0;
  225.         
  226.         temp = PCF8563_Read_Byte(PCF8563_Address_Control_Status_1);  //讀取控制/狀態(tài)寄存器1
  227.         if (temp & PCF_Control_ChipStop)
  228.         {
  229.                 temp &= PCF_Control_ChipRuns;  //運(yùn)行芯片
  230.         }
  231.         if ((temp & (1<<7)) == 0)  //普通模式
  232.         {
  233.                 temp &= PCF_Control_TestcClose;  //電源復(fù)位模式失效
  234.         }
  235.         PCF8563_Write_Byte(PCF8563_Address_Control_Status_1, temp);  //再寫入數(shù)值
  236. }

  237. /**
  238.   *****************************************************************************
  239.   * @Name   : PCF8563停止
  240.   *
  241.   * @Brief  : 時鐘頻率輸出CLKOUT 在 32.768kHz 時可用
  242.   *
  243.   * @Input  : none
  244.   *
  245.   * @Output : none
  246.   *
  247.   * @Return : none
  248.   *****************************************************************************
  249. **/
  250. void PCF8563_Stop(void)
  251. {
  252.         unsigned char temp = 0;
  253.         
  254.         temp = PCF8563_Read_Byte(PCF8563_Address_Control_Status_1);  //讀取控制/狀態(tài)寄存器1
  255.         temp |= PCF_Control_ChipStop;  //停止運(yùn)行
  256.         PCF8563_Write_Byte(PCF8563_Address_Control_Status_1, temp);  //再寫入數(shù)值
  257. }

  258. /**
  259.   *****************************************************************************
  260.   * @Name   : PCF8563設(shè)置運(yùn)行模式
  261.   *
  262.   * @Brief  : none
  263.   *
  264.   * @Input  : Mode: 運(yùn)行模式
  265.   *                 = PCF_Mode_Normal
  266.   *                 = PCF_Mode_EXT_CLK
  267.   *
  268.   * @Output : none
  269.   *
  270.   * @Return : none
  271.   *****************************************************************************
  272. **/
  273. void PCF8563_SetMode(unsigned char Mode)
  274. {
  275.         unsigned char temp = 0;
  276.         
  277.         temp = PCF8563_Read_Byte(PCF8563_Address_Control_Status_1);  //讀取寄存器值
  278.         if (Mode == PCF_Mode_EXT_CLK)  //EXT_CLK測試模式
  279.         {
  280.                 temp |= PCF_Control_Status_EXT_CLKMode;
  281.         }
  282.         else if (Mode == PCF_Mode_Normal)
  283.         {
  284.                 temp &= PCF_Control_Status_NormalMode;
  285.                 temp &= ~(1<<3);  //電源復(fù)位功能失效
  286.         }
  287.         PCF8563_Write_Byte(PCF8563_Address_Control_Status_1, temp);
  288. }

  289. /**
  290.   *****************************************************************************
  291.   * @Name   : PCF8563設(shè)置電源復(fù)位功能開啟與關(guān)閉
  292.   *
  293.   * @Brief  : none
  294.   *
  295.   * @Input  : NewState: 狀態(tài),PCF8563_PowerResetEnablePCF8563_PowerResetDisable
  296.   *
  297.   * @Output : none
  298.   *
  299.   * @Return : none
  300.   *****************************************************************************
  301. **/
  302. void PCF8563_SetPowerReset(unsigned char NewState)
  303. {
  304.         unsigned char TestC = 0;
  305.         
  306.         TestC = PCF8563_Read_Byte(PCF8563_Address_Control_Status_1);  //獲取寄存器值
  307.         TestC &= ~(1<<3);  //清除之前設(shè)置
  308.         if (NewState == PCF8563_PowerResetEnable)  //復(fù)位功能有效
  309.         {
  310.                 TestC |= PCF8563_PowerResetEnable;
  311.         }
  312.         else if (NewState == PCF8563_PowerResetDisable)
  313.         {
  314.                 TestC &= ~PCF8563_PowerResetEnable;  //失效,普通模式是值邏輯0,即失效
  315.         }
  316.         PCF8563_Write_Byte(PCF8563_Address_Control_Status_1, TestC);  //寫入數(shù)值
  317. }

  318. /**
  319.   *****************************************************************************
  320.   * @Name   : PCF8563設(shè)置輸出頻率
  321.   *
  322.   * @Brief  : none
  323.   *
  324.   * @Input  :*PCF_CLKOUTStruct: 頻率結(jié)構(gòu)指針
  325.   *
  326.   * @Output : none
  327.   *
  328.   * @Return : none
  329.   *****************************************************************************
  330. **/
  331. void PCF8563_SetCLKOUT(_PCF8563_CLKOUT_Typedef* PCF_CLKOUTStruct)
  332. {
  333.         unsigned char tmp = 0;
  334.         
  335.         tmp = PCF8563_Read_Byte(PCF8563_Address_CLKOUT);  //讀取寄存器值
  336.         tmp &= 0x7c;  //清除之前設(shè)置
  337.         if (PCF_CLKOUTStruct->CLKOUT_NewState == PCF_CLKOUT_Open)
  338.         {
  339.                 tmp |= PCF_CLKOUT_Open;
  340.         }
  341.         else
  342.         {
  343.                 tmp &= PCF_CLKOUT_Close;
  344.         }
  345.         tmp |= PCF_CLKOUTStruct->CLKOUT_Frequency;
  346.         
  347.         PCF8563_Write_Byte(PCF8563_Address_CLKOUT, tmp);
  348. }

  349. /**
  350.   *****************************************************************************
  351.   * @Name   : PCF8563設(shè)置定時器
  352.   *
  353.   * @Brief  : none
  354.   *
  355.   * @Input  :*PCF_TimerStruct: 定時器結(jié)構(gòu)指針
  356.   *
  357.   * @Output : none
  358.   *
  359.   * @Return : none
  360.   *****************************************************************************
  361. **/
  362. void PCF8563_SetTimer(_PCF8563_Timer_Typedef* PCF_TimerStruct)
  363. {
  364.         unsigned char Timer_Ctrl = 0;
  365.         unsigned char Timer_Value = 0;
  366.         
  367.         Timer_Ctrl = PCF8563_Read_Byte(PCF8563_Address_Timer);  //獲的控制寄存器值
  368.         Timer_Value = PCF8563_Read_Byte(PCF8563_Address_Timer_VAL);  //獲取倒計(jì)時數(shù)值
  369.         //
  370.         //先停止定時器
  371.         //
  372.         Timer_Ctrl &= PCF_Timer_Close;
  373.         PCF8563_Write_Byte(PCF8563_Address_Timer, Timer_Ctrl);
  374.         
  375.         Timer_Ctrl &= 0x7c;  //清除定時器之前設(shè)置
  376.         
  377.         if (PCF_TimerStruct->RTC_Timer_NewState == PCF_Timer_Open)  //開啟
  378.         {
  379.                 Timer_Ctrl |= PCF_Timer_Open;
  380.                 Timer_Ctrl |= PCF_TimerStruct->RTC_Timer_Frequency;  //填上新的工作頻率
  381.                 if (PCF_TimerStruct->RTC_Timer_Value)  //需要填上新的計(jì)數(shù)值
  382.                 {
  383.                         Timer_Value = PCF_TimerStruct->RTC_Timer_Value;  //填上新的計(jì)數(shù)值
  384.                 }
  385.         }
  386.         else
  387.         {
  388.                 Timer_Ctrl &= PCF_Timer_Close;
  389.         }
  390.         PCF8563_Write_Byte(PCF8563_Address_Timer_VAL, Timer_Value);  //寫入倒計(jì)時數(shù)值
  391.         
  392.         if (PCF_TimerStruct->RTC_Timer_Interrupt == PCF_Time_INT_Open)  //開啟了中斷輸出
  393.         {
  394.                 Timer_Value = PCF8563_Read_Byte(PCF8563_Address_Control_Status_2);  //獲取控制/狀態(tài)寄存器2數(shù)值
  395.                 Timer_Value &= PCF_Time_INT_Close;  //清除定時器中斷使能
  396.                 Timer_Value &= ~(1<<2);  //清除定時器中斷標(biāo)志
  397.                 Timer_Value &= ~(1<<4);  //當(dāng) TF 有效時 INT 有效 (取決于 TIE 的狀態(tài))
  398.                 Timer_Value |= PCF_Time_INT_Open;  //開啟定時器中斷輸出
  399.                 PCF8563_Write_Byte(PCF8563_Address_Control_Status_2, Timer_Value);
  400.         }
  401.         else
  402.         {
  403.                 Timer_Value = PCF8563_Read_Byte(PCF8563_Address_Control_Status_2);  //獲取控制/狀態(tài)寄存器2數(shù)值
  404.                 Timer_Value &= PCF_Time_INT_Close;  //清除定時器中斷使能
  405.                 Timer_Value |= PCF_Time_INT_Open;  //開啟定時器中斷輸出
  406.                 PCF8563_Write_Byte(PCF8563_Address_Control_Status_2, Timer_Value);
  407.         }
  408.         
  409.         PCF8563_Write_Byte(PCF8563_Address_Timer, Timer_Ctrl);  //設(shè)置定時器控制寄存器
  410. }

  411. /**
  412.   *****************************************************************************
  413.   * @Name   : 設(shè)置時間,主要用于后臺調(diào)用,或者初始化時間用
  414.   *
  415.   * @Brief  : 秒默認(rèn)就設(shè)置成0x00了,形參里面不體現(xiàn),星期值范圍:0 ~ 6
  416.   *
  417.   * @Input  : PCF_Format:  數(shù)據(jù)格式
  418.   *                        = PCF_Format_BIN
  419.   *                        = PCF_Format_BCD
  420.   *           PCF_Century: 世紀(jì)位設(shè)定
  421.   *                        = PCF_Century_19xx
  422.   *                        = PCF_Century_20xx
  423.   *           Year:        年
  424.   *           Month:       月
  425.   *           Date:        日
  426.   *           Week:        星期
  427.   *           Hour:        時
  428.   *           Minute:      分
  429.   *
  430.   * @Output : none
  431.   *
  432.   * @Return : none
  433.   *****************************************************************************
  434. **/
  435. void PCF8563_Set_Times(unsigned char PCF_Format,\
  436.                        unsigned char PCF_Century,\
  437.                            unsigned char Year, unsigned char Month, unsigned char Date, unsigned char Week,\
  438.                        unsigned char Hour, unsigned char Minute)
  439. {
  440.         _PCF8563_Time_Typedef Time_InitStructure;
  441.         _PCF8563_Date_Typedef Date_InitStructure;
  442.         
  443.         if (PCF_Format == PCF_Format_BIN)
  444.         {
  445.                 //
  446.                 //判斷數(shù)據(jù)是否符合范圍
  447.                 //
  448.                 if (Year > 99)   Year  = 0;  //恢復(fù)00年
  449.                 if (Month > 12)  Month = 1;  //恢復(fù)1月
  450.                 if (Date > 31)   Date  = 1;  //恢復(fù)1日
  451.                 if (Week > 6)    Week  = 1;  //恢復(fù)星期一
  452.                
  453.                 if (Hour > 23)    Hour   = 0;  //恢復(fù)0小時
  454.                 if (Minute > 59)  Minute = 0;  //恢復(fù)0分鐘
  455.                
  456.                 //
  457.                 //轉(zhuǎn)換一下
  458.                 //
  459.                 Date_InitStructure.RTC_Years    = RTC_BinToBcd2(Year);
  460.                 Date_InitStructure.RTC_Months   = RTC_BinToBcd2(Month);
  461.                 Date_InitStructure.RTC_Days     = RTC_BinToBcd2(Date);
  462.                 Date_InitStructure.RTC_WeekDays = RTC_BinToBcd2(Week);
  463.                
  464.                 Time_InitStructure.RTC_Hours    = RTC_BinToBcd2(Hour);
  465.                 Time_InitStructure.RTC_Minutes  = RTC_BinToBcd2(Minute);
  466.         }
  467.         Time_InitStructure.RTC_Seconds = 0x00;  //恢復(fù)0秒
  468.         Time_InitStructure.RTC_Seconds &= PCF_Accuracy_ClockYes;  //保證準(zhǔn)確的時間
  469.         //
  470.         //判斷世紀(jì)位
  471.         //
  472.         if (PCF_Century == PCF_Century_19xx)
  473.         {
  474.                 Date_InitStructure.RTC_Months |= PCF_Century_SetBitC;
  475.         }
  476.         else
  477.         {
  478.                 Date_InitStructure.RTC_Months &= ~PCF_Century_SetBitC;
  479.         }
  480.         //
  481.         //寫入信息到寄存器
  482.         //
  483.         buffer[0] = Time_InitStructure.RTC_Seconds;
  484.         buffer[1] = Time_InitStructure.RTC_Minutes;
  485.         buffer[2] = Time_InitStructure.RTC_Hours;
  486.         PCF8563_Write_nByte(PCF8563_Address_Seconds, 3, buffer);  //寫入時間信息
  487.         
  488.         buffer[0] = Date_InitStructure.RTC_Days;
  489.         buffer[1] = Date_InitStructure.RTC_WeekDays;
  490.         buffer[2] = Date_InitStructure.RTC_Months;
  491.         buffer[3] = Date_InitStructure.RTC_Years;
  492.         PCF8563_Write_nByte(PCF8563_Address_Days,    4, buffer);  //寫入日期信息
  493. }

  494. /**
  495.    ============================================================================
  496.                      #### 所有寄存器全部操作功能函數(shù) ####
  497.    ============================================================================
  498. **/

  499. /**
  500.   *****************************************************************************
  501.   * @Name   : 判斷時間信息是否符合范圍,超出將恢復(fù)初值
  502.   *
  503.   * @Brief  : 星期值范圍:0 ~ 6
  504.   *
  505.   * @Input  : PCF_DataStruct: 寄存器結(jié)構(gòu)指針
  506.   *
  507.   * @Output : none
  508.   *
  509.   * @Return : none
  510.   *****************************************************************************
  511. **/
  512. static void IS_PCF8563_Data(_PCF8563_Register_Typedef* PCF_DataStruct)
  513. {
  514.         if (PCF_DataStruct->Years > 99)           PCF_DataStruct->Years          = 0;  //恢復(fù)00年
  515.         if (PCF_DataStruct->Months_Century > 12)  PCF_DataStruct->Months_Century = 1;  //恢復(fù)1月
  516.         if (PCF_DataStruct->Days > 31)            PCF_DataStruct->Days           = 1;  //恢復(fù)1日
  517.         if (PCF_DataStruct->WeekDays > 6)         PCF_DataStruct->WeekDays       = 1;  //恢復(fù)星期一
  518.         
  519.         if (PCF_DataStruct->Hours > 23)           PCF_DataStruct->Hours          = 0;  //恢復(fù)0小時
  520.         if (PCF_DataStruct->Minutes > 59)         PCF_DataStruct->Minutes        = 0;  //恢復(fù)0分鐘
  521.         if (PCF_DataStruct->Seconds > 59)         PCF_DataStruct->Seconds        = 0;  //恢復(fù)0秒
  522. }

  523. /**
  524.   *****************************************************************************
  525.   * @Name   : PCF8563寫入寄存器
  526.   *
  527.   * @Brief  : 星期數(shù)值范圍是: 0 ~ 6,十進(jìn)制格式
  528.   *
  529.   * @Input  : PCF_Format:     數(shù)據(jù)格式
  530.   *                           = PCF_Format_BIN
  531.   *                           = PCF_Format_BCD
  532.   *           PCF_Century:    世紀(jì)位設(shè)定
  533.   *                           = PCF_Century_19xx
  534.   *                           = PCF_Century_20xx
  535.   *           PCF_DataStruct: 寄存器結(jié)構(gòu)指針
  536.   *
  537.   * @Output : none
  538.   *
  539.   * @Return : none
  540.   *****************************************************************************
  541. **/
復(fù)制代碼

這邊有點(diǎn)亂碼 我就直接上傳文件了  有什么問題歡迎討論
51hei.png
注意代碼里面只有上圖2個文件,請自行移植到各MCU系統(tǒng)中去:
c文件和h文件下載.7z (9.45 KB, 下載次數(shù): 13)


回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 在线国产视频 | 成人在线视频一区 | 国产成人精品免费 | 区一区二在线观看 | 日韩不卡视频在线观看 | 一区二区三区av | 99re在线视频观看 | 日韩av.com| 成人在线免费观看 | 天天草草草 | 在线观看一区 | 亚洲视频 欧美视频 | 欧美专区日韩专区 | 涩在线| 自拍偷拍亚洲视频 | 久久久99精品免费观看 | 4hu最新网址 | 91成人精品| 色狠狠一区 | 99福利视频 | 香蕉视频久久久 | 操操网站 | 欧美aⅴ | 新疆少妇videos高潮 | 中文字幕亚洲欧美日韩在线不卡 | 亚洲人成人一区二区在线观看 | 久久精品在线 | 欧美一区二区三区在线观看 | 国产精品久久久久一区二区三区 | 日韩免费视频一区二区 | 天堂va在线 | 国产精品久久久久久久岛一牛影视 | av一二三区| 九九九久久国产免费 | 欧美一区二区三区在线播放 | 成人精品 | 精品亚洲一区二区 | 最近最新中文字幕 | 欧美 日韩 国产 成人 在线 91 | 国产乱码精品1区2区3区 | 久久国产精品视频 |