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

📄 reg652x.h

📁 TDK 6521 SOC 芯片 DEMO程序
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
 * 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 - 652x Special Function Registers.
// 
//  AUTHOR:  MTF
//
//  HISTORY: See end of file.
//**************************************************************************
// File: REG652x.H
//               
#ifndef _REG652x
#define _REG652x

/*  More Bit-addressable Registers  */
sfr USER0  = 0x80;                      // Digital IO_00-07. 
sfr USER1  = 0x90;                      // Digital IO_08-15.
sfr USER2  = 0xA0;                      // Digital IO_16-21. 
sfr IFLAGS = 0xE8;                      // Enable of multiplexed interrupts.
sfr INTBIT = 0xF8;                      // Interrupt bits. Allows polling of external INT bits.

//=======================================================================//
#define IO_INT0_IV              EX0_IV  // Interrupt vector address index.  
#define IO_INT1_IV              EX1_IV  
#define FWCOL_IV                EX2_IV
#define CE_BUSYZ_IV             EX3_IV
#define PLL_IV                  EX4_IV
#define EEPROM_IV               EX5_IV
#define XFER_RTC_IV             EX6_IV

//=======================================================================//
#define EX_IO_INT0              EX0     // Interrupt enable bits.
#define EX_IO_INT1              EX1
#define EX_FWCOL01           	EX2
#define EX_CE_BUSYZ             EX3
#define EX_PLL_OK               EX4
#define EX_EEPROM               EX5
#define EX_XFER_RTC             EX6
                                       
#define EX_IO_INT0_             EX0_    // Interrupt enable masks.
#define EX_IO_INT1_             EX1_
#define EX_FWCOL01_            	EX2_
#define EX_CE_BUSYZ_            EX3_
#define EX_PLL_OK_              EX4_
#define EX_EEPROM_              EX5_
#define EX_XFER_RTC_            EX6_

//=======================================================================//
#define IE_IO_INT0              IE0     // Interrupt flag bits.
#define IE_IO_INT1              IE1
#define IE_FWCOL             	IE2
#define IE_CE_BUSYZ             IE3
#define IE_PLL                  IE4
#define IE_EEPROM               IE5
#define IE_XFER_RTC             IE6

#define IE_IO_INT0_             IE0_    // Interrupt flag masks.
#define IE_IO_INT1_             IE1_
#define IE_FWCOL_            	IE2_
#define IE_CE_BUSYZ_            IE3_
#define IE_PLL_                 IE4_
#define IE_EEPROM_              IE5_
#define IE_XFER_RTC_            IE6_
//=======================================================================//
// S0/S1REL reload values, assuming MPU running @ 4.9152MHz.
// Used by code that automatically adjusts to MPU_DIV
#define BPS_153600             -1
#define BPS_76800              -2
#define BPS_38400              -4
#define BPS_19200              -8
#define BPS_9600               -16
#define BPS_4800               -32
#define BPS_2400               -64
#define BPS_1200               -128
#define BPS_600                -256
#define BPS_300                -512
#if XTAL_FREQ == 32768
#define BPS_BROWNOUT_300       0x10000-3  // UART clock is 7/8 of xtal_freq
#elif XTAL_FREQ == 4194304
#define BPS_BROWNOUT_300       0xff26  	// UART clock is 1/2 xtal_freq
#else
#error "unknown crystal frequency"
#endif


// sfr USER0 = 0x80;                      // Digital IO_0 
sbit USER0_7 = USER0^7;
sbit USER0_6 = USER0^6;
sbit USER0_5 = USER0^5;
sbit USER0_4 = USER0^4;
sbit USER0_3 = USER0^3;
sbit USER0_2 = USER0^2;
sbit USER0_1 = USER0^1;
sbit USER0_0 = USER0^0;

sfr DIR0  = 0xA2;                       // 1 => output, 0 => input pin.
#define USER0_7_               BIT7
#define USER0_6_               BIT6
#define USER0_5_               BIT5
#define USER0_4_               BIT4
#define USER0_3_               BIT3
#define USER0_2_               BIT2
#define USER0_1_               BIT1
#define USER0_0_               BIT0

// sfr USER1 = 0x90;                    // Digital IO_1 
sbit USER1_7 = USER1^7;
sbit USER1_6 = USER1^6;
sbit USER1_5 = USER1^5;
sbit USER1_4 = USER1^4;
sbit USER1_3 = USER1^3;
sbit USER1_2 = USER1^2;
sbit USER1_1 = USER1^1;
sbit USER1_0 = USER1^0;

sfr DIR1  = 0x91;                       // 1 => output, 0 => input pin.
#define USER1_7_               BIT7
#define USER1_6_               BIT6
#define USER1_5_               BIT5
#define USER1_4_               BIT4
#define USER1_3_               BIT3
#define USER1_2_               BIT2
#define USER1_1_               BIT1
#define USER1_0_               BIT0

//sfr USER2 = 0xA0;                     // Digital IO_2 
sbit USER2_5 = USER2^5;
sbit USER2_4 = USER2^4;
sbit USER2_3 = USER2^3;
sbit USER2_2 = USER2^2;
sbit USER2_1 = USER2^1;
sbit USER2_0 = USER2^0;

sfr DIR2  = 0xA1;                       // 1 => output, 0 => input pin.
#define USER2_5_               BIT5
#define USER2_4_               BIT4     
#define USER2_3_               BIT3
#define USER2_2_               BIT2
#define USER2_1_               BIT1
#define USER2_0_               BIT0

//=======================//
//     ------      ------//
//     ------      ------//
//     ------      ------//
//     ------      ------//
#define DIO_17     USER2_1
#define DIO_16     USER2_0
//-------------------------
#define DIO_15     USER1_7  
#define DIO_14     USER1_6
//     ------      ------//
//     ------      ------//
#define DIO_11     USER1_3
#define DIO_10     USER1_2
#define DIO_9      USER1_1
#define DIO_8      USER1_0
//-------------------------
#define DIO_7      USER0_7
#define DIO_6      USER0_6
#define DIO_5      USER0_5
#define DIO_4      USER0_4
#define DIO_3      USER0_3
#define DIO_2      USER0_2
#define DIO_1      USER0_1
#define DIO_0      USER0_0
//     ------      ------//
//=======================//
//     ------      ------//
//     ------      ------//
//     ------      ------//
//     ------      ------//
#define DIO_17_    USER2_1_
#define DIO_16_    USER2_0_
//-------------------------
#define DIO_15_    USER1_7_ 
#define DIO_14_    USER1_6_
//     ------      -------
//     ------      -------
#define DIO_11_    USER1_3_
#define DIO_10_    USER1_2_
#define DIO_9_     USER1_1_
#define DIO_8_     USER1_0_
//-------------------------
#define DIO_7_     USER0_7_
#define DIO_6_     USER0_6_
#define DIO_5_     USER0_5_
#define DIO_4_     USER0_4_
#define DIO_3_     USER0_3_
#define DIO_2_     USER0_2_
#define DIO_1_     USER0_1_
//     ------      -------
//=======================//

#define DIO_BUTTON      DIO_0     //  "push button"
#define DIO_BUTTON_PRESSED 1      // when pressed
#define BUTTON_PRESSED (DIO_BUTTON == DIO_BUTTON_PRESSED)
#define PULSE3       DIO_1        // pin 4 of JP12 (conflicts with OPT_RX)
#define PULSE4       DIO_2        // pin 2 of JP12 (conflicts with OPT_TX)
#define BATTERY_MODE_ENABLE (DIO_8 == 1) // pin 2 of JP13
#define MAGNETIC_TAMPER 0         // pin 2 of JP13
#define NEUTRAL_DETECTED DIO_16    // pin 3 of debug connector (on some PCBs)

sfr EEDATA = 0x9E;                      // Serial EEPROM interface data.
sfr EECTRL = 0x9F;                      // Serial EEPROM interface control.
//--------------------------------------// 2-wire interface.
#define EE_ERROR      BIT7              // RO: Illegal command is rcv'd.
#define EE_BUSY       BIT6              // RO: Serial data bus is busy.
#define EE_RX_ACK     BIT5              // RO: EEPROM sent an ACK.
#define EE_TX_ACK     BIT4              // RO: ACK sent to EEPROM.
#define EE_CMD        0x0F              // RW: Command for EEPROM interface.
#define  EE_NOOP      0x00              // No-op.
#define  EE_RCV_ACK   0x02              // Receive byte, send ACK.
#define  EE_TX        0x03              // Transmit byte.
#define  EE_STOP      0x05              // Issue 'STOP' sequence.
#define  EE_RCV       0x06              // Receive last byte, do not send ACK.
#define  EE_START     0x09              // Issue 'START' sequence. 
#define  EE_RX (EE_RCV_ACK | EE_RCV)
//--------------------------------------// 3-wire interface.   
#define EE_WFR     BIT7                 // RW: Wait for READY.
//      EE_BUSY    BIT6                 // RO: Serial data bus is busy.
#define EE_HiZ     BIT5                 // RW: SD is to be floated immediately after last SCK rising edge.
#define EE_RD      BIT4                 // RW: EEDATA is to be filled with data from EEPROM.
#define EE_CNT     0x0F                 // RW: Number of clocks to be issued; Allowed values: 0 thru 8.

// Flash SFR Register Definitions.
//

⌨️ 快捷键说明

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