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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? main.c

?? TDK 6521 SOC 芯片 DEMO程序
?? C
?? 第 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 - Main.
// 
//  AUTHOR:  MTF/RGV
//
//  HISTORY: See end of file.
//**************************************************************************
// File:  MAIN.C
//               
#include "options.h"        // compile flags and system constants
#include "irq.h"            // interrupt disabling logic
#include "library.h"        // data copying functions
#include "batmodes.h"       // battery mode logic
#include "wd.h"             // software watchdogs
#include "stm.h"            // software timers
#include "error.h"          // error recording
#include "ce.h"             // compute engine hardware access
#if SERIAL0
#include "ser0.h"           // uart 0 hardware access
#endif
#if SERIAL1
#include "ser1.h"           // uart 1 hardware access
#endif
#include "rtc.h"            // real time clock hardware access
#include "lcd.h"            // liquid crystal display
#include "meter.h"          // meter logic
#include "defaults.h"       // default data tables
#include "pcnt.h"           // meter pulse counting (normally disabled)
#include "psoft.h"          // meter software pulse outputs (normally disabled)
#include "calibration.h"    // meter calibration logic
#include "cal_ldr.h"        // calibration loader protocol
#include "flag0.h"          // FLAG protocol(s)
#include "flag1.h"
#include "cli.h"            // command line interface- parsing commands
#include "io.h"             // command line interface- io routines
#include "ser0cli.h"        // queued serial buffering for uart 0
#include "ser1cli.h"        // queued serial buffering for uart 1
#include "sercli.h"         // shared tables and logic for serial
#include "delay.h"          // shared delay loop
//#include "oscope.h"         // scope loop debugging code
#include "main.h"           // Test the interface in main.h vs. main.c

/*** Public variables declared within this module ***/
// None.

/*** Private functions declared within this module ***/
void main_init (void);
void main_run (void);

/*** Private variables declared within this module ***/
// None.

#if BROWNOUT_BATMODE || CLI || M6520
// This routine is called when you want to "fake" a power on reset w/o really doing one.
// It sets all the I/O registers to their power-on state, 
// and ensures that any pending interrupts are cleared.
//
// Inputs:  None.
//
// Outputs: None.
//
static void null_int (void) interrupt 31
{                             // '31' is a dummy interrupt,..
}                             // ..it forces 'RET' compiled into a 'RETI'.

#pragma save
#pragma NOAREGS
void main_soft_reset (void) small reentrant
{
    IE = 0;                       // Turn ALL interrupts OFF.

    #if HARD_RESET_USABLE
    // assumes that the hard reset is a wire from DIO_8 to RESET.
    USER1 =0xFF; // DIO_8 is bit 0 of port 1
    DIR1 = 0x01; // set DIO_8 as an output; should reset right here
    for(px = 10; px > 0; --px)
    {
        USER1 += 1;  // but just in case, toggle the bit for awhile
    }
    #endif
    // so, if it falls through?  Do a soft reset anyway.
 
    #if M6520
    // Interrupt enable registers
    IEN0 = 0;
    IEN1 = 0;
    IEN2 = 0;

    memset_x ((uint8x_t *)0x2000, 0, 0x80); // 2000..207F
    *(uint8x_t *)0x2080 = 0xff; // PLS_WIDTH
    memset_x ((uint8x_t *)0x2081, 0, 0x27); // 2081..20A7
    *(uint8x_t *)0x20A8 = 31;  // CE_LCTN
    *(uint8x_t *)0x20A9 = 1; // WAKE_PRD
    *(uint8x_t *)0x20AA = 0x02; // TMUX; the hardware's default
    memset_x ((uint8x_t *)0x20AB, 0, 0x54); // 20AB..20FF

    // Initialize all 652x specific internal SFRs.
    DIR0 = 0;                     // init direction first
    USER0 = 0xFF;
    DIR1 = 0;                  
    USER1 = 0xFF;
    DIR2 = 0;                  
    USER2 = 0x00;
    P3 = 0xFF;
    EEDATA = 0;
    EECTRL = 0;  

    FCTRL = 0x00;                 // Init FLASH SFRs.
    FPAGE = 0x00;
    ERASE = 0x00;

    // Initialize remaining standard 80515 SFRs.
    // Interrupt priority registers
    IP = 0;
    IP1 = 0;

    // Peripheral control and interrupt registers
    CKCON = 1; 
    PCON = 0;                     
    TCON = 0;
    T2CON = 0;
    TMOD = 0;
    SCON = 0;
    S1CON = 0;
    WDCON = 0;

    // Interrupt registers
    IRCON = 0;

    DPL1 = 0;                     // Initialize all standard 80515 SFRs.
    DPH1 = 0;
    WDTREL = 0;
    TH0 = 0;
    TL0 = 0;
    TH1 = 0;
    TL1 = 0;
    DPS = 0;
    S1RELL = 0;
    S0RELL = 0xD9;
    S0RELH = 3;
    S1RELH = 3;
    PSW = 0;

    ((void (code *) (void)) null_int) (); // Clear 1st priority level.
    ((void (code *) (void)) null_int) (); // Clear 2nd priority level. 
    ((void (code *) (void)) null_int) (); // Clear 3rd priority level. 
    ((void (code *) (void)) null_int) (); // Clear 4th priority level. 

    B  = 0;
    DPH = 0;
    DPL = 0;
    SP = 5;  // two less than default 7; call below, will fix this
    PSW = 0;
    ACC = 0;

    ((void (code *) (void)) 0x0000) ();   // Jump to 0x0000.

    #elif TRACE10
    //defaults for IO
    // Disable interrupts
    IEN0 = 0;
    IEN1 = 0;
    IEN2 = 0;

    // initialize the IO ram
    memset_x ((uint8x_t *)0x2000, 0, 0x100); // 2000..20FF

    // Initialize all specific internal SFRs.
    DIR0 = 0;                     // init direction first
    USER0 = 0xFF;                 // P0
    DIR1 = 0;                  
    USER1 = 0xFF;
    DIR2 = 0;                  
    USER2 = 0x00;
    P3 = 0xFF;
    EEDATA = 0;
    EECTRL = 0;  

    FCTRL = 0x00;                 // Init FLASH SFRs.
    FPAGE = 0x00;
    ERASE = 0x00;

    // Initialize remaining standard 80515 SFRs.
    // Interrupt priority registers
    IPH = 0;
    IPL = 0;

    // initialize the control and interrupt registers
    CKCON = 1; 
    PCON = 0;                     
    TCON = 0;
    T2CON = 0;
    TMOD = 0;
    SCON = 0;
    S1CON = 0;
    WDCON = 0;

    // Other interrupt registers
    IRCON = 0;

    DPL1 = 0;                     // Initialize all standard 80515 SFRs.
    DPH1 = 0;
    WDTREL = 0;
    TH0 = 0;
    TL0 = 0;
    TH1 = 0;
    TL1 = 0;
    DPS = 0;
    S1RELL = 0;
    S0RELL = 0xD9;
    S0RELH = 3;
    S1RELH = 3;
    PSW = 0;

    ((void (code *) (void)) null_int) (); // Clear 1st priority level.
    ((void (code *) (void)) null_int) (); // Clear 2nd priority level. 
    ((void (code *) (void)) null_int) (); // Clear 3rd priority level. 
    ((void (code *) (void)) null_int) (); // Clear 4th priority level. 

    B  = 0;
    DPH = 0;
    DPL = 0;
    SP = 5;  // two less than default 7; call below, will fix this
    PSW = 0;
    ACC = 0;

    ((void (code *) (void)) 0x0000) ();   // Jump to 0x0000.

    #else
    #error unhandled device type
    #endif
}
#pragma restore
#endif // battery modes are defined

//===========================================================================//
static void default_setup(void)
{
    set_defaults ();                    // Set most default values.

    #if LCD_ACTIVE
    LCD_Hello ();                       // LCD reads 'HELLO'.
    #endif
    RESET_WD();                         // Reset watchdog.

    #if BROWNOUT_BATMODE
    if ( !batmode_is_brownout() )       // eeprom reads are slow
    {
    #endif
    
        meter_initialize ();            // prepare the power meter logic

        #if PULSE_CNT
        pcnt_init ();                   // prepare to count pulses
        #endif

    #if BROWNOUT_BATMODE
    }
    #endif

    CE2 |= EX_RTC;                      // The 1 second interrupt always runs
    // clear both flags at once, forcing an edge to cause interrupt 6
    // If this is not done, the unit can deadlock at reset.
    IFLAGS = ~(IE_XFER_ | IE_RTC_);

    if (0 != cal_i0)                    // if the compute engine is set-up
        CE_ENABLE();                    // start the compute engine

    #ifdef OSCOPE_H
    OSCOPE_INIT;
    #endif
}

//===========================================================================//
static void main_init (void)
{

    // system interrupt priorities are assembled in main\options_gbl.h
    // Interrupt priorities are best set one place, before any interrupts
    // should be possible.
    IPH = SYSTEM_PRIORITY >> 8;         // set interrupt priorities.
    IPL = SYSTEM_PRIORITY & 0xFF;

    irq_init ();      // initialize the interrupt disable logic

    #if TIMERS
    stm_init ();      // initalize the software timers
    #endif

    #if BROWNOUT_BATMODE || LCD_BATMODE || SLEEP_BATMODE
    batmode_init ();  // initialize the battery mode management
    #endif

    // Initializes most I/O functions that control the hardware.
    #if WATCHDOG
    wd_destroy (WD_ALL);                // Delete all the software watchdogs.
    #endif

    #ifdef WD_MAIN_LOOP
    wd_create (WD_MAIN_LOOP);           // Add a software watchdog
    #endif

    default_setup();                    // standard set up; reads power regs.

    irq_enable ();                      // enable interrupts
 
    #if CAL_SAVE
    #if BROWNOUT_BATMODE
    if ( !batmode_is_brownout () )     // no need for calibration, etc.
    {
    #endif
        if (0 == cal_restore())             // Restore saved calibration.
        {   // if it failed
            irq_disable ();
            Status |= CAL_BAD;
            default_setup ();
            irq_enable ();                  // enable interrupts
        }


        #if AUTOCAL | (!CLI && CAL_LDR)
        // Self-calibrate or call the calibration loader
        // On the 6511 and 6513, hold sw2 on the debug PCB and press reset.
        // On the 6520, hold the push button and push reset.
        // if the CLI is in, access the cal loader via its CLI command: CLC
        // The cal loader ignores the CLC if invoked here.
        if (BUTTON_PRESSED /* && add an anti-tampering test here */ )
        {
            // If needed, calibration loader first to give more control
            // in a manufacturing cycle.  It can set changed defaults,
            // etc.  After autocalibration and a reset, the calibration loader
            // can read or modify the meter's cal. data. 
            // With auto. test equip., the cal. loader can read registers, 
            // so the ATE can can calculate and set calibrations.
            // #if CAL_LDR
            // cal_ldr ();
            // #endif
            #if AUTOCAL
            cal_begin();
            #endif

            // The operation does not proceed until the button is released.
            while (BUTTON_PRESSED)  // wait for the jumper to be removed
            {
                RESET_WD();         // Reset watchdog.
                delay_clks (3);     // Delay before next time.
            }
        }
        #endif
    #if BROWNOUT_BATMODE
    } // if not brownout mode
    #endif

    #endif // Calibration.

    #if REAL_TIME_DATE
    RTClk_Reset ();                     // Reset RTC to defaults, if necessary.
    #endif

    #if ERROR_RECORDING
    Error_Init ();                      // Initialize error recording
    #endif

    #if CLI
    send_crlf ();
    send_copyright ();
    send_a_result (OK_ID);
    #endif
}                                       // Start CE_BUSYZ, XFER_BUSYZ & RTC interrupts.

// guts of the main loop
static void main_run (void)
{
    main_background ();

    #if CLI
    // This is the command line interface.
    if (cmd_pending ())     cli();
    #elif CAL_LDR
    // The calibration loader is run here in order to read and
    // write during operation, to better demonstrate chip operation.  
    // For a production meter, it makes more sense to run  the 
    // calibration loader optionally, just after reset.  See above.
    // The calibration loader can be invoked from the CLI using "CLC"
    if (cmd_pending ())     cal_ldr ();
    #endif

    // execute a subroutine on behalf of the flag logic
    #if FLAG0
    flag0_run ();                       // run flag0
    #endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人精品鲁一区一区二区| 国产精品自拍三区| 国产亚洲制服色| 日本道色综合久久| 国产又粗又猛又爽又黄91精品| 亚洲欧洲在线观看av| 欧美一区日本一区韩国一区| 91亚洲大成网污www| 国产原创一区二区| 日韩av中文在线观看| 亚洲欧美二区三区| 国产视频一区在线观看| 日韩一区二区三区高清免费看看| 97久久超碰国产精品| 国产精品88av| 免费成人在线影院| 亚洲va天堂va国产va久| 亚洲人妖av一区二区| 国产三级一区二区| 亚洲精品在线观看网站| 欧美一区二区在线看| 欧美亚洲综合一区| 91视视频在线观看入口直接观看www | 99视频一区二区| 国产乱码字幕精品高清av| 美女免费视频一区二区| 日韩在线播放一区二区| 一区二区三区日韩精品| 亚洲四区在线观看| 中文字幕欧美一| 国产精品日韩成人| 欧美国产禁国产网站cc| 久久久不卡影院| 国产女人18毛片水真多成人如厕| 欧美精品一区二区在线播放| 欧美欧美欧美欧美| 欧美日韩成人一区二区| 欧美军同video69gay| 欧美日韩一区二区三区四区| 精品视频1区2区| 欧美日韩精品专区| 日韩一二三区不卡| 日韩欧美中文字幕制服| 日韩欧美成人一区二区| 精品国产三级电影在线观看| 精品国产免费一区二区三区香蕉| 欧美大黄免费观看| 亚洲国产cao| 亚洲二区视频在线| 日本vs亚洲vs韩国一区三区| 麻豆91精品91久久久的内涵| 精品亚洲成a人在线观看| 国产一区二区h| 成人91在线观看| 色综合久久88色综合天天 | 色综合天天视频在线观看| 国产精品中文字幕日韩精品| 国产精品亚洲а∨天堂免在线| 亚洲婷婷综合色高清在线| 国产精品家庭影院| 亚洲私人影院在线观看| 国产日韩欧美a| 首页综合国产亚洲丝袜| 成人性视频网站| 欧美老肥妇做.爰bbww视频| 欧美国产日韩亚洲一区| 秋霞电影一区二区| 一本一道久久a久久精品综合蜜臀| 日韩视频在线观看一区二区| 日韩理论片在线| 国内外成人在线| 欧美人与性动xxxx| 亚洲欧洲日韩女同| 国产精品一区在线| 91精品国产入口在线| 一区二区三区四区中文字幕| 国产精品白丝jk黑袜喷水| 欧美一级一级性生活免费录像| 亚洲欧美日韩中文播放| 国产成人高清视频| 精品美女在线观看| 婷婷成人激情在线网| 色8久久精品久久久久久蜜| 亚洲国产高清aⅴ视频| 久久99精品网久久| 欧美一区二区三区四区五区| 一区二区三区日韩欧美| 不卡av电影在线播放| 国产欧美一区二区在线观看| 精品夜夜嗨av一区二区三区| 日韩一区国产二区欧美三区| 天堂va蜜桃一区二区三区 | 91在线国产福利| 欧美激情一区二区三区在线| 国产一区二区三区在线看麻豆| 欧美一卡二卡三卡| 天天av天天翘天天综合网色鬼国产 | 97se亚洲国产综合自在线不卡| 视频在线观看一区二区三区| 亚洲日本丝袜连裤袜办公室| 欧美日韩综合不卡| 一色屋精品亚洲香蕉网站| 一区二区三区蜜桃| 国产精品国产三级国产普通话99 | 欧美一区日韩一区| 五月婷婷欧美视频| 欧美日韩国产a| 亚洲成人av中文| 91精品国产综合久久久蜜臀图片| 日韩欧美一级二级三级| 精品理论电影在线| 亚洲欧洲av色图| 日韩高清一区在线| 欧美日韩精品专区| 日本伊人精品一区二区三区观看方式| 欧美久久免费观看| 日韩在线观看一区二区| 日韩精品专区在线影院重磅| 精品一区二区三区免费播放| 久久久久久久久97黄色工厂| 国产一区二区伦理片| 国产视频一区在线播放| 成人精品视频一区二区三区| 自拍偷拍欧美激情| 色狠狠色狠狠综合| 首页国产丝袜综合| 久久无码av三级| 99re66热这里只有精品3直播| 一区二区日韩av| 日韩欧美国产一区二区在线播放| 激情久久久久久久久久久久久久久久| 亚洲精品一区二区三区影院 | 欧美丰满美乳xxx高潮www| 美女视频黄免费的久久| 国产日韩精品一区二区三区在线| av一区二区三区黑人| 亚洲大片免费看| 久久蜜桃av一区精品变态类天堂| fc2成人免费人成在线观看播放| 亚洲激情五月婷婷| 欧美电影免费提供在线观看| 成人免费精品视频| 亚洲电影一区二区三区| 日韩精品一区二区三区在线播放 | 成人丝袜18视频在线观看| 一区二区三区四区激情| 日韩欧美一二区| 91在线视频观看| 另类的小说在线视频另类成人小视频在线| 国产三级一区二区| 欧美日韩国产乱码电影| 国产99一区视频免费| 亚洲v日本v欧美v久久精品| 久久久久久久综合色一本| 在线观看不卡一区| 国产一区视频在线看| 亚洲夂夂婷婷色拍ww47| 国产亚洲精品资源在线26u| 欧美在线观看一区二区| 国产麻豆午夜三级精品| 亚洲图片有声小说| 国产目拍亚洲精品99久久精品| 欧美日韩一级视频| 成人网页在线观看| 麻豆91精品视频| 亚洲电影视频在线| ㊣最新国产の精品bt伙计久久| 日韩欧美一区二区久久婷婷| 色呦呦日韩精品| 国产激情一区二区三区四区| 丝袜国产日韩另类美女| 亚洲丝袜精品丝袜在线| 久久综合av免费| 欧美老年两性高潮| 色中色一区二区| 成人av网站在线| 国产一区二区精品久久| 五月婷婷另类国产| 亚洲精品免费在线播放| 国产视频在线观看一区二区三区 | 午夜天堂影视香蕉久久| 自拍偷自拍亚洲精品播放| 国产偷国产偷亚洲高清人白洁| 日韩亚洲欧美高清| 欧美色男人天堂| 色综合久久综合| 成人午夜短视频| 国产麻豆一精品一av一免费| 看电视剧不卡顿的网站| 亚洲成av人片一区二区三区| 亚洲精选一二三| 国产精品久久精品日日| 久久久久久久网| 欧美α欧美αv大片| 欧美一区二区三区在| 欧美美女bb生活片| 欧美在线视频全部完| 91高清视频免费看| 日本道免费精品一区二区三区| 91免费观看国产|