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

📄 options_gbl.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: 71M65xx POWER METER - Global Compile-time OPTIONS.
// 
//  AUTHOR:  MTF
//
//  HISTORY: See end of file
//**************************************************************************
// File: OPTIONS_GBL.H
//**************************************************************************
//  Compile time option switches.
//
#ifndef _OPTIONS_GBL
#define _OPTIONS_GBL

#define max(_v0_,_v1_) ((_v0_ > _v1_) ? _v0_ : _v1_)
#define min(_v0_,_v1_) ((_v0_ < _v1_) ? _v0_ : _v1_)
#define NULL ((void*)0)

/*** W A R N I N G *** Never use 'using 0' for ISRs, it won't preserve the registers. ***/
#define   ES0_BANK 1
#define   ES1_BANK 2
#define   CE_BANK  3
/*** W A R N I N G *** Never use 'using 0' for ISRs, it won't preserve the registers. ***/

#if M6520
// Interrupt priorities; each level can preempt levels below
#define PLL_OK_PRIORITY    HIGHEST_PLL_OK // also sets TIMER1 (shared)
#define TIMER1_PRIORITY    HIGHEST_TIMER1 // also sets PLL_OK (shared)
#define CE_BUSYZ_PRIORITY  HIGH_CE_BUSYZ // also sets EXT1
#define PULSE_CNT_PRIORITY (HIGH_IO_INT0 | HIGH_IO_INT1) // Also sets ser1, ce_bisy
#define SERIAL1_PRIORITY   HIGH_SERIAL1 // shares INT0's priority
#define SERIAL0_PRIORITY   LOW_SERIAL0
#define TIMER0_PRIORITY    LOW_TIMER0 // also sets FWCOL, unused
#define RTC_XFER_PRIORITY  LOWEST_XFER_BUSYZ // XFER_BUSYZ and RTC_1_SEC interrupt (slow...)
#define SYSTEM_PRIORITY ( \
        PLL_OK_PRIORITY \
        | TIMER1_PRIORITY \
        | CE_BUSYZ_PRIORITY \
        | PULSE_CNT_PRIORITY \
        | SERIAL1_PRIORITY \
        | SERIAL0_PRIORITY \
        | TIMER0_PRIORITY \
        | RTC_XFER_PRIORITY)

// The clock speed is actually set in ri_defaults() in defaults.c
//#define CLK_FREQ 4915200L             // Max speed.
//#define CLK_FREQ 2457600L           // 1/2
#define CLK_FREQ 1228800L           // 1/4
//#define CLK_FREQ  614400L             // 1/8 speed for specified power.
//#define CLK_FREQ  307200L           // 1/16
//#define CLK_FREQ  153600L           // 1/32
//#define CLK_FREQ   76800L           // 1/64
//#define CLK_FREQ   38400L               // 1/128

#elif TRACE13
// Interrupt priorities; each level can preempt levels below
#define CE_BUSYZ_PRIORITY  HIGH_CE_BUSYZ // also sets EXT1
#define PULSE_CNT_PRIORITY (HIGH_IO_INT0 | HIGH_IO_INT1) // Also sets ser1, ce_bisy
#define SERIAL1_PRIORITY   HIGH_SERIAL1 // shares INT0's priority
#define SERIAL0_PRIORITY   LOW_SERIAL0
#define TIMER0_PRIORITY    LOW_TIMER0 // also sets COMP_FALL, unused
#define COMP_RISE_PRIORITY LOW_COMP_RISE // also sets TIMER1 (shared)
#define TIMER1_PRIORITY    LOW_TIMER1 // also sets COMP_RISE (shared)
#define RTC_XFER_PRIORITY  LOWEST_XFER_BUSYZ // XFER_BUSYZ and RTC_1_SEC interrupt (slow...)
#define SYSTEM_PRIORITY ( \
        CE_BUSYZ_PRIORITY \
        | PULSE_CNT_PRIORITY \
        | SERIAL1_PRIORITY \
        | SERIAL0_PRIORITY \
        | TIMER0_PRIORITY \
        | COMP_RISE_PRIORITY \
        | TIMER1_PRIORITY \
        | RTC_XFER_PRIORITY)
#define CLK_FREQ 4915200L             // Max speed.
//#define CLK_FREQ 2457600L           // 1/2
//#define CLK_FREQ 1228800L           // 1/4
//#define CLK_FREQ  614400L             // 1/8 speed for specified power.
//#define CLK_FREQ  307200L           // 1/16
//#define CLK_FREQ  153600L           // 1/32
//#define CLK_FREQ   76800L           // 1/64
//#define CLK_FREQ   38400L               // 1/128

#elif TRACE11
// Interrupt priorities; each level can preempt levels below
#define CE_BUSYZ_PRIORITY  HIGH_CE_BUSYZ // also sets EXT1
#define PULSE_CNT_PRIORITY (HIGH_IO_INT0 | HIGH_IO_INT1) // Also sets ser1, ce_bisy
#define SERIAL1_PRIORITY   HIGH_SERIAL1 // shares INT0's priority
#define SERIAL0_PRIORITY   LOW_SERIAL0
#define TIMER0_PRIORITY    LOW_TIMER0 // also sets COMP_FALL, unused
#define COMP_RISE_PRIORITY LOW_COMP_RISE // also sets TIMER1 (shared)
#define TIMER1_PRIORITY    LOW_TIMER1 // also sets COMP_RISE (shared)
#define RTC_XFER_PRIORITY  LOWEST_XFER_BUSYZ // XFER_BUSYZ and RTC_1_SEC interrupt (slow...)
#define SYSTEM_PRIORITY ( \
        CE_BUSYZ_PRIORITY \
        | PULSE_CNT_PRIORITY \
        | SERIAL1_PRIORITY \
        | SERIAL0_PRIORITY \
        | TIMER0_PRIORITY \
        | COMP_RISE_PRIORITY \
        | TIMER1_PRIORITY \
        | RTC_XFER_PRIORITY)
#define CLK_FREQ 4915200L             // Max speed.
//#define CLK_FREQ 2457600L           // 1/2
//#define CLK_FREQ 1228800L           // 1/4
//#define CLK_FREQ  614400L           // 1/8 speed for specified power.
//#define CLK_FREQ  307200L           // 1/16
//#define CLK_FREQ  153600L           // 1/32
//#define CLK_FREQ   76800L           // 1/64
//#define CLK_FREQ   38400L           // 1/128

#else
#error unknown device
#endif

#if     CLK_FREQ == 4915200L
#define MPU_FREQ _4915200Hz

#elif   CLK_FREQ == 2457600L
#define MPU_FREQ _2457600Hz

#elif   CLK_FREQ == 1228800L 
#define MPU_FREQ _1228800Hz
                 
#elif   CLK_FREQ == 614400L 
#define MPU_FREQ _614400Hz

#elif   CLK_FREQ == 307200L
#define MPU_FREQ _307200Hz

#elif   CLK_FREQ == 153600L
#define MPU_FREQ _153600Hz

#elif   CLK_FREQ == 76800L
#define MPU_FREQ _76800Hz

#elif   CLK_FREQ == 38400L 
#define MPU_FREQ _38400Hz
#endif

#define STRETCH_OFF STRETCH_0_          // Max speed
#define STRETCH_CE  STRETCH_6_          // Speed suitable for access to the CE

#if CLK_FREQ < 4915200L && PULSE_SOFT
#error software pulse outputs fail at 614kHz, and were debugged at 4.9mHz
#endif

#include "reg80515.h"   // CPU registers.

// The flag ID describes the meter's abilities.
// It is a chip ID, and the last date at which the protocol changed.
// The date is yyymmdd
#if M6520               // The flag ID describes the meter's abilities. 
#if M6521F
#define FLAG_ID '6','5','2','1','F','0','0','5','0','8','1','7'
#elif M6521D || M6521B
#define FLAG_ID '6','5','2','1','-','0','0','5','0','8','1','7'
#else
#error undefined device type
#endif
#include "reg652x.h"    // Register I/O.
#include "ce652x.h"     // CE interface; the CE was mapped to this interface.
#include "io652x.h"     // Memory mapped I/O.
#include "priority2x.h" // Interrupt priority constants
#elif TRACE10           // Experimental.
#define FLAG_ID 'T','R','A','C','E','3','0','5','0','9','1','4'
#include "reg651x.h"    // Register I/O.
#include "ce651x.h"     // CE interface; the CE was mapped to this interface.
#include "io651x.h"     // Memory mapped I/O.
#include "priority1x.h" // Interrupt priority constants
#else
#error undefined device type
#endif
#include "ce65xx.h"
#include "dio.h"        // direct I/O

#if NV_SELECT == NV_EEPROM
#define EEPROM_CALIBRATION 0  // adr. of calibration data
#define EEPROM_ERRORS 0x300  // adr. of error data
#define EEPROM_REGISTERS 0x400  // adr. of power register data
#endif

#if FLAG                                    /* Interface between meter and FLAG serial protocol. */
#define REG_VALID register_available        /* From 'meter.c'.                                   */
#define REG_WRITE register_write            /* From ce.c                                         */
#define REG_LOCKED register_locked          /* From 'meter.c'.                                   */
#define REG_SOURCE_OK (!xfer_update)        /* From 'ce.c'.                                      */
#define REG_UPDATE() Update_register()      /* From 'meter.c'.                                   */
#define CALB_SAVE()   cal_save()            /* From 'calibration.c'.                             */
#endif

// figure temperature limits
#define TEMP_CAL 230               // 23C, room temperature of calibration
#define TEMP_MAX (850 - TEMP_CAL)  // 85C, relative to calibration temp
#define TEMP_MIN ((-400) - TEMP_CAL) // -40C, relative to calibration temp

// Linkage to RTC variables
#define FILE_DEFINING_RTC "meter.h"
// Linkage to error variables
#define FILE_DEFINING_ERROR "meter.h"

#endif /* options_gbl.h */
/***************************************************************************
 * History:
 * $Log: options_gbl.h,v $
 * Revision 1.34  2006/10/13 00:48:14  tvander
 * Removed compile options for 6530, 6515;
 * renamed 6511 and 6513 to trace11 and trace13;
 * Binary verified unchanged from previous version.
 *
 * Revision 1.33  2006/09/29 09:42:28  tvander
 * TRACE11 needs 4.9Mhz because it has software pulses.
 *
 * Revision 1.32  2006/09/27 01:02:32  tvander
 * 6520 has a "Battery mode jumper" on DIO_8, added comments.
 * Changes baud rate depending on battery mode jumper.
 *
 * Revision 1.31  2006/09/20 23:50:27  tvander
 * Set interrupt priorities only once, during startup
 *
 * Revision 1.30  2006/09/18 20:27:20  tvander
 * *** empty log message ***
 *
 * Revision 1.29  2006/09/18 19:28:46  tvander
 * Centralizes the definition of interrupt priorities
 *
 * Revision 1.28  2006/09/09 01:11:00  gmikef
 * *** empty log message ***
 *
 * Revision 1.27  2006/08/30 02:09:30  gmikef
 * *** empty log message ***
 *
 * Revision 1.26  2006/08/18 00:32:59  tvander
 * Added a warning for an attempt to combine software pulse outputs and slow MPU
 * clock.
 *
 * Revision 1.25  2006/08/09 00:56:58  tvander
 * *** empty log message ***
 *
 * Revision 1.24  2006/08/08 21:57:29  tvander
 * Changed 6520 default clock rate to 600kHz
 *
 * Revision 1.23  2006/07/06 21:02:40  tvander
 * 4.9 mHz clock
 *
 * Revision 1.22  2006/06/20 20:33:27  tvander
 * Added comments for 614kHz
 *
 * Revision 1.21  2006/06/14 02:59:06  tvander
 * Simplifiedthe brownout, regressing to 17april06 version, but with hang
 * removed, and a brownout display that always executes before entering sleep mode.
 *
 * Reduced the MPU clock 8x from 4.9mHz to 614kHz
 *
 * Revision 1.20  2006/06/06 05:17:03  tvander
 * clean build
 *
 * Revision 1.19  2006/06/06 04:13:10  tvander
 * Added "errors" to EEPROM map.
 * Added a linkage to error file structure location.
 *
 * Revision 1.18  2006/05/18 23:18:47  tvander
 * 16K and 32K
 * First cut at new requirements.
 * 32K 6521 is grossly tested.
 * All others have a clean compile with C51 8.02
 *
 * Revision 1.17  2006/04/19 01:16:10  tvander
 * Now defines where rtc puts its data.
 *
 * Revision 1.16  2006/03/17 00:22:05  tvander
 * EEPROM power moved to 512; this is to support an AT24C08 eeprom
 *
 * Revision 1.15  2006/03/08 03:07:45  gmikef
 * *** empty log message ***
 *
 * Revision 1.14  2006/03/08 00:02:47  tvander
 * Disabled oscope.
 * Made date automatically the date of compilation.
 * Clean build, tested dates.
 *
 * Revision 1.13  2006/03/06 03:33:49  Michael T. Fischer
 * More 6530 prep.
 *
 * Revision 1.12  2006/03/03 11:27:15  Michael T. Fischer
 * Prep for 6530 LCD, etc.
 *
 * Revision 1.11  2006/01/16 20:11:25  tvander
 * Clean Keil build, all versions
 *
 * Revision 1.10  2006/01/11 00:50:34  gmikef
 * *** empty log message ***
 *
 * Revision 1.9  2006/01/10 04:00:02  gmikef
 * Added PDATA support for CE Outputs.
 *
 * Revision 1.7  2005/12/21 01:29:23  tvander
 * 6513
 *
 * Revision 1.5  2005/11/10 22:51:33  tvander
 * 6520 has battery mode commands.
 * Brownout always has decimal point 7.
 * LCD Mode always has decimal points 7 and 6.
 * Sag detection is disabled.
 *
 * Revision 1.4  2005/11/05 01:57:25  tvander
 * Added code to clear pushbutton and wake flags.
 *
 * Revision 1.3  2005/09/22 23:45:10  tvander
 * Clean build all models and unit tests, updated copyright to be fore Teridian
 *
 * Revision 1.2  2005/08/30 18:13:40  gmikef
 * *** empty log message ***
 *
 * Revision 1.1  2005/08/28 02:18:58  gmikef
 * *** empty log message ***
 *
 * Revision 1.5  2005/08/23 02:12:19  gmikef
 * *** empty log message ***
 *
 * Revision 1.3  2005/08/18 20:44:46  tvander
 * Added temperature measurement to GUI-available fields.
 * FIxed memory-space problem in add8_8
 * Added temp_x, temp_nom, ppmc and ppmc2 to register def. file.,
 * moved many other registers, whcih where in the way.
 *
 * Revision 1.2  2005/08/12 21:57:25  tvander
 * Fixed EEPROM option for calibrations.
 *
 * Revision 1.1  2005/08/10 02:07:55  gmikef
 * *** empty log message ***
 *
 * Revision 1.2  2005/07/15 01:20:10  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.         *
 ***************************************************************************/

⌨️ 快捷键说明

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