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

📄 rtc.h

📁 TDK 6521 SOC 芯片 DEMO程序
💻 H
字号:
/***************************************************************************
 * This code and information is provided "as is" without warranty of any   *
 * kind, either expressed or implied, including but not limited to the     *
 * implied warranties of merchantability and/or fitness for a particular   *
 * purpose.                                                                *
 *                                                                         *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//  DESCRIPTION: 71M652x POWER METER - RTC structures, enumerates, and defines.
//
//  AUTHOR:  MTF
//
//  HISTORY: see end of file.
//***************************************************************************
//  File: RTC.H
//       
#ifndef RTC_H
#define RTC_H 1

/////////////////////////////////////////////////////////////////////////////
//  Real Time Clock.
/////////////////////////////////////////////////////////////////////////////

struct RTC_t 
{                        
    uint8_t         Sec;           
    uint8_t         Min;
    uint8_t         Hour;
    enum eDAY       Day;
    uint8_t         Date;
    enum eMONTH     Month;
    uint8_t         Year;
    uint8_t         Adjust;             // Sec++ or Sec--).
    uint8_t         LRC;                // LRC of Non-Volatile.
};

struct RTC_TRIM_t
{
    volatile int8_t trim_slow;          // 1 => trim slow clock, 0 => trim fast clock.
    volatile int32_t trim_value;        // Current 'trim value'.
    volatile uint8_t LRC;               // LRC of Non-Volatile.
    volatile int32_t trim_count;        // Count to add to 'trim value'.
};

extern bool rtc_ready;  // this is set once per second by the interrupt

/*** Public functions. ***/
void RTClk_Reset (void); // reset RTC to defaults if needed
void RTClk_Read (void); // Read the RTC
void RTClk_Write (void); // Write the RTC

// Recalculate the RTC temperature compensation
void RTC_Adjust_Trim (bool clr_cnt, int32_t value);
void RTC_Compensation (void);              // Do manual temperature compensation of RTC.   
bool RTC_Tic (void);

int32_t OperatingHours (void); // return hours of operation
// figure the seconds between two events
int32_t Delta_Seconds (struct RTC_t xdata *start, struct RTC_t xdata *end);

// interrupt service routine, adjusts the RTC's trim
void rtc_isr (void) small reentrant;

// LCD display routines.
void date_lcd (void);
void operating_lcd (void);
void time_lcd (void);

// RTC calibration control
#define RTC_Calibration_On() DIO &= ~DIO_PV 
#define RTC_Calibration_Off() DIO |= DIO_PV 

/***************************************************************************
 * History
 * $Log: rtc.h,v $
 * Revision 1.10  2006/09/09 01:09:50  gmikef
 * *** empty log message ***
 *
 * Revision 1.9  2006/04/27 00:06:52  tvander
 * Added tamper resistance, mostly to wh.c; Added a calibration signal to rtc.c
 *
 * Revision 1.8  2006/04/25 01:09:49  tvander
 * Integrated improved RTC.  Compensates for time off, has default constant
 * compensation.  Computes true hours of operation.
 *
 * Revision 1.7  2006/04/19 01:15:34  tvander
 * Integrated with unit test/clock.  The big thing was to uncouple it from the
 * data structure Totals in meter.h.  Now the options define where it puts its
 * data.
 *
 * Revision 1.6  2006/01/10 03:58:39  gmikef
 * Added PDATA support for CE Outputs.
 *
 * Revision 1.4  2005/10/08 04:41:20  tvander
 * Fixed priority inversion.
 * Rewrote watchdog to work in brownout, but of course it doesn't work.
 * Watchdog can now be defeated by clearing watchdog option to 0.
 * Reorganized watt hour modules (at last!).
 * Disabled reading of STATUS in 6521_cli because the CE's status is always SAG.
 * Tested with 6521_CLI; measurements seem to work.
 * Fixed other builds.
 *
 * Revision 1.3  2005/09/22 23:45:06  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.2  2005/08/28 02:14:39  gmikef
 * *** empty log message ***
 *
 * Revision 1.1  2005/08/26 00:54:28  gmikef
 * *** empty log message ***
 *
 * Revision 1.6  2005/05/13 00:34:49  tvander
 * 6511/32k works
 * Integrated and debugged self-calibration.
 * The build has one unused segment, and no other errors or warnings.
 * default LCD and pulse displays appear OK.
 * EEPROM, software timers and hardware timers are all integrated.
 *
 * Revision 1.5  2005/04/30 02:20:40  gmikef
 * *** empty log message ***
 *
 * Revision 1.4  2005/04/28 19:12:28  tvander
 * Comments only!  Restored history comments.
 *
 * Revision 1.3  2005/04/27 23:49:12  gmikef
 * Some MATH rountines now use 'idata'.
 * Added MATH_FAST flag to 'options.h".
 * Changed "6521B.Uv2" to max optimization.
 *
 * Revision 1.2  2005/04/21 02:09:11  gmikef
 * *** empty log message ***
 *
 * Revision 1.1  2005/04/06 18:12:11  gmikef
 * *** empty log message ***
 *
 * Copyright (C) 2005 Teridian Semiconductor Corp. All Rights Reserved.    *
 * this program is fully protected by the United States copyright          *
 * laws and is the property of Teridian Semiconductor Corporation.         *
 ***************************************************************************/
#endif  /* rtc.h */

⌨️ 快捷键说明

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