亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? rtc.c

?? Analog 公司 ADE7169 SOC 電表方案DEMO程序
?? C
字號:
/*
-02/24/2006: Petre M.
  -this file contains functions that deal with Real Time Clock
*/

#include "ioADE7169F16.h"
#include "extern_declarations.h"
#include "EEPROM_locations.h"


//this function initializes the RTC
void Setup_RTC(void) {

  //!!!!!!!!!!!!all these settings of the time and date should be
  //introduced using UART. They should be at a certain point eliminated!!!!!!!!!!!!!!!!!!!!!!!
  //disable RTC in order to synchronize the time with the Date
//  TIMECON_bit.RTCEN = 0;
  //set the initial time at 00:00:00
//  SEC = 30;
//  MIN = 59;
//  HOUR= 23;
//////////////////////////////////////////////////////////////////////////////
  /*x=MIDNIGHT is a status bit
     1=24 hour mode
      00=interval timer is based on 1/128 seconds
        0=interval timer is set after 1 time interval
         x=ALARM is a status bit
          1=interval timer is enabled
           1=RTC enabled
  */
  TIMECON = (TIMECON & (NBit5 & NBit4 & NBit3)) | (Bit6 | Bit1 | Bit0);

  //every 0.5sec=64 1/128 sec, the interval timer generates an interrupt
  INTVAL = 64;

  //read RTCCOMP value from EEPROM
  Tx_CTRL_byte(Nr_Bytes_1, RTCCOMP_val,(unsigned char __idata  *)&Temporary[0]);
  RTCCOMP = Temporary[0];

  //RTC interrupt with Low Priority (Bit6=PTI=0)
  //Enable RTC interrupt (Bit2=ETI=1)
  IEIP2_bit.PTI = 0;

  //enable RTC interrupt
  IEIP2_bit.ETI = 1;

  return;
}

//this function is called in PSM1 mode and only enables the RTC interrupt
void Setup_RTC_PSM1(void) {

  /*x=MIDNIGHT is a status bit
     1=24 hour mode
      00=interval timer is based on 1/128 seconds
        0=interval timer is set after 1 time interval
         x=ALARM is a status bit
          0=interval timer disabled
           1=RTC enabled
  */
  TIMECON = (TIMECON & (NBit5 & NBit4 & NBit3 & NBit1)) | (Bit6 | Bit0);

  INTVAL = 64;

  //RTC interrupt with Low Priority
  IEIP2_bit.PTI = 0;

  //enable RTC interrupt
  IEIP2_bit.ETI = 1;



  return;
}

//this function modifies the calendar and stores it into EEPROM
void Update_calendar(void) {
  char __code const *iram_ptr1;
  char Month_length;

  //increment the weekday. It varies between 0 and 6, 0=Sunday, 6=Saturday
  Date.Weekday = Date.Weekday +1;
    if (Date.Weekday>6)
      Date.Weekday = 0;

    Date.Day = Date.Day + 1;

    iram_ptr1 = &Months[0];

    //read the length of the current Month
    Month_length = *(iram_ptr1+Date.Month-1);

    //a leap year is defined as a year divisible by 4. But if the number is
    //divisible by 100, then it must be divisible by 400 to be leap year
    //Because we represent only years between 2000 and 2099, and the next leap year
    //divisible by 400 is 2400, we don't need to verify if the year is divisible by 400.
    //In the leap year case, if Date.Month=2, Month_length=29

    if ((Date.Year & 0x03) == 0x00) {
      if (Date.Month==2) {
        Month_length = 29;
      }
    }

    //if the end of month is reached, then set Day=1 and Month++
    if (Date.Day > Month_length) {
      Date.Day = 1;
      Date.Month = Date.Month + 1;

      //order monthly storing of the energies in the EEPROM because
      //this is the end of the month
      Set_flag(Bit5,&Low_Priority_Command[0]);

      //if end of the year, Month=1 and Year++
      if (Date.Month == 13) {
        Date.Month = 1;

        //the year is incremented. It varies only between 0 and 99
        Date.Year = Date.Year + 1;
        if (Date.Year>99)
          Date.Year=0;

      }
    }

    //start the storage of the bytes representing the
    //energies at Day_Ac_Energy address into EEPROM
    Active_Energy_write();

    //the new updated Calendar is stored into EEPROM
    Calendar_write();

  return;
}

//this function updates the calendar and stores it into EEPROM
void Midnight_Management(void) {

  //update the calendar only if a Midnight event has been ordered
  if (TIMECON_bit.MIDNIGHT) {
    //clear MIDNIGHT flag
    TIMECON_bit.MIDNIGHT = 0;

    //update calendar and store it together with the energy into EEPROM
    Update_calendar();
  }

  return;
}

//this function manages the Midnight event in PSM1 mode.
//The ALARM bit in TIMECON is disabled in PSM1 and PSM2 modes. For this
//reason, the midnight event does not trigger an interrupt and therefore
//the program tests TIMECON_bit.MIDNIGHT instead of Bit2 of Low_Priority_Command[0]
//It waits until the EEPROM storage finishes because in PSM1
//there is no loop to execute other tasks
void Midnight_Management_PSM1(void) {

  //update the calendar only if a Midnight event has been ordered
  if (TIMECON_bit.MIDNIGHT) {
    //clear MIDNIGHT flag
    TIMECON_bit.MIDNIGHT = 0;

    //first, bring energies and current Date from EEPROM and
    //wait until data arrives in IRAM
    Reload_from_EEPROM();

    //update calendar and store it together with the energy into EEPROM
    Update_calendar();

    //we read this byte to ensure the write process ends before the processor enters in sleep mode
    Tx_CTRL_byte(Nr_Bytes_1, EEPROM_Fault_Days,&Fault_Days);

  }

  return;
}

//this function writes the Calendar into EEPROM
void Calendar_write(void) {

  Tx_byte(Nr_Bytes_4, EEPROM_Date,(unsigned char __idata *)&Date.Weekday);
  return;
}

//this function reads the Calendar from EEPROM
void Calendar_read(void) {

  Tx_CTRL_byte(Nr_Bytes_4, EEPROM_Date,(unsigned char __idata *)&Date.Weekday);

  return;
}


//this function stores SEC, MIN and HOUR registers in a buffer indicated by the pointer
//Buffer[0]=HTHSEC
//Buffer[1]=SEC
//Buffer[2]=MIN
//Buffer[3]=HOUR
void Store_time(char __idata *ptr) {
  char a, b, c, d;

  IE_bit.EA = 0;//disable all interrupts

    a=HTHSEC;
    b=SEC;
    c=MIN;
    d=HOUR;
    if (a!=HTHSEC){
      b=SEC;
      c=MIN;
      d=HOUR;
    }

  IE_bit.EA = 1;//enable all interrupts

  *ptr = a;
  *(ptr+1) = b;
  *(ptr+2) = c;
  *(ptr+3) = d;

  return;
}






?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩aaaaa| 26uuu欧美日本| 久久国产麻豆精品| 国产精品久久久久久久蜜臀 | 久久一区二区三区四区| 99久免费精品视频在线观看| 免费人成精品欧美精品| 亚洲免费在线视频| 久久精品视频在线免费观看| 欧美二区三区的天堂| 亚洲高清免费一级二级三级| 国产精品久久福利| 久久综合久久综合亚洲| 欧美日韩不卡一区二区| 97se狠狠狠综合亚洲狠狠| 国模套图日韩精品一区二区| 亚洲18影院在线观看| 亚洲天堂福利av| 久久看人人爽人人| 精品久久一二三区| 91精品午夜视频| 欧美三级视频在线播放| 色哟哟一区二区三区| 国产传媒日韩欧美成人| 久久99精品国产| 美女视频免费一区| 丝袜诱惑制服诱惑色一区在线观看 | 成人三级在线视频| 国产一区亚洲一区| 久草在线在线精品观看| 免费在线成人网| 日本午夜精品一区二区三区电影| 亚洲自拍偷拍网站| 一区二区三区蜜桃| 亚洲免费在线观看| 亚洲激情图片小说视频| 亚洲少妇30p| 亚洲人成亚洲人成在线观看图片| 国产女同性恋一区二区| 国产欧美精品一区| 中文乱码免费一区二区| 中文字幕国产一区二区| 欧美精彩视频一区二区三区| 日本一区二区三级电影在线观看 | 美腿丝袜亚洲一区| 青青草国产精品97视觉盛宴| 日韩一区精品视频| 久久99在线观看| 国产精品中文有码| 国产精品一级片| 国产.欧美.日韩| eeuss鲁片一区二区三区在线看| 懂色av噜噜一区二区三区av| 成人激情小说网站| 色综合天天综合| 欧美亚洲综合在线| 欧美高清视频一二三区| 日韩欧美国产成人一区二区| 久久青草国产手机看片福利盒子| 国产午夜精品美女毛片视频| 中文字幕制服丝袜一区二区三区| 综合色中文字幕| 亚洲高清不卡在线观看| 精品一区二区在线视频| 国产91色综合久久免费分享| 91视频91自| 91精品国产综合久久久蜜臀粉嫩 | 欧美在线综合视频| 69久久99精品久久久久婷婷| 久久夜色精品国产欧美乱极品| 欧美高清一级片在线观看| 专区另类欧美日韩| 天天做天天摸天天爽国产一区| 紧缚奴在线一区二区三区| 不卡视频免费播放| 欧美精品久久一区二区三区| 久久先锋资源网| 亚洲精品视频自拍| 久久99精品久久久久久动态图 | 国产在线视频精品一区| 99re视频精品| 日韩一区二区三区在线| 欧美高清在线精品一区| 亚洲一区二区三区视频在线| 久久精品国产99| 99re视频精品| 日韩精品一区二区在线| 亚洲人成亚洲人成在线观看图片 | 久久久电影一区二区三区| 亚洲欧美日韩久久| 奇米888四色在线精品| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美美女一区二区三区| 国产日韩在线不卡| 天天色天天操综合| 波多野结衣亚洲| 日韩欧美中文字幕制服| 伊人婷婷欧美激情| 国产毛片精品视频| 欧美丰满高潮xxxx喷水动漫| 国产精品高潮呻吟| 久久精工是国产品牌吗| 欧美中文字幕久久| 国产精品免费人成网站| 美女视频黄免费的久久| 欧美在线观看一二区| 国产欧美精品区一区二区三区 | 欧美日韩一级大片网址| 国产精品短视频| 国产一区二区精品久久| 欧美精品aⅴ在线视频| 亚洲欧美影音先锋| 国产不卡视频一区二区三区| 日韩女优av电影| 视频一区视频二区中文字幕| 91免费国产在线观看| 亚洲国产精品成人综合色在线婷婷| 麻豆精品久久精品色综合| 欧美日韩精品一二三区| 一区二区三区欧美视频| av欧美精品.com| 国产精品久久久久三级| 国产不卡一区视频| 国产婷婷色一区二区三区四区| 裸体一区二区三区| 91精品国产综合久久香蕉麻豆| 亚洲一区二区中文在线| 在线观看欧美精品| 亚洲综合一区二区精品导航| 91亚洲精品久久久蜜桃| 中文字幕一区二区三区色视频| 国产91精品露脸国语对白| 久久精品欧美日韩| 国产福利一区二区三区视频| 国产性色一区二区| 风流少妇一区二区| 国产色产综合产在线视频| 国产精品一区二区三区99| 精品99一区二区三区| 久久国产精品72免费观看| 亚洲精品一区二区三区香蕉| 久久99精品久久久| 久久久一区二区三区| 国产·精品毛片| 国产精品久久久久久久第一福利| 成人99免费视频| 一区二区三区欧美久久| 欧美日韩国产精品成人| 视频一区二区不卡| 精品欧美一区二区久久| 国产精品亚洲人在线观看| 国产精品久久久久影院老司 | 在线观看日韩高清av| 亚洲成av人片在线| 欧美mv日韩mv国产网站| 国产成人精品一区二区三区四区| 国产午夜精品福利| 99久久免费精品| 亚洲小少妇裸体bbw| 91精品国产综合久久国产大片| 另类小说欧美激情| 欧美韩国日本一区| 色综合久久久久久久| 舔着乳尖日韩一区| 久久欧美一区二区| 91免费在线看| 免费成人在线视频观看| 国产欧美日韩亚州综合| 91精品1区2区| 精品一区二区av| 亚洲三级在线播放| 欧美一区二区视频观看视频| 国产麻豆精品视频| 夜夜嗨av一区二区三区四季av| 91精品国产高清一区二区三区蜜臀| 国产乱理伦片在线观看夜一区| 成人欧美一区二区三区白人 | 2021中文字幕一区亚洲| 91在线精品一区二区| 日韩高清不卡一区二区三区| 国产欧美日韩精品a在线观看| 欧美性猛片aaaaaaa做受| 久久91精品久久久久久秒播| 亚洲啪啪综合av一区二区三区| 91精品国产高清一区二区三区| 成人久久18免费网站麻豆 | 亚洲国产综合91精品麻豆| 日韩欧美中文字幕制服| 99riav一区二区三区| 久久99精品一区二区三区| 亚洲精品视频一区| 久久久久久亚洲综合影院红桃 | 久久精品夜夜夜夜久久| 欧美日韩黄色影视| 成人av在线电影| 裸体在线国模精品偷拍| 亚洲一区在线观看网站| 中文字幕av一区二区三区| 欧美一二三四在线| 日本韩国欧美国产|