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

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

?? ce.c

?? TDK 6521 SOC 芯片 DEMO程序
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
/***************************************************************************
 * 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 - COMPUTE ENGINE Interface.
// 
//  AUTHOR:  MTF
//
//  HISTORY: See end of file.
//**************************************************************************
// File: CE.C
//               
#include "options.h"   // controls the features
#include "irq.h"       // interrupt disabling
#include "batmodes.h"  // battery mode management
#include "ce_ce.h"     // CE's microcode file.
#include "ce_dat.h"    // CE's data area initialization file.
#include "wd.h"        // used to manage the watchdog
#include "library.h"   // to copy data around
#if TIMERS
#include "stm.h"       // software timers. to wait till CE's data is valid
#endif
#include "main.h"      // to get soft reset
#include "meter.h"     // main meter code, to get creep logic
#include "pcnt.h"      // pulse counting
#include "psoft.h"     // software pulse generation
#include "eeprom.h"    // EEPROM interface, used to save data on sag
//#include "oscope.h"  // scope loop debugging code
#include "ce.h"        // check the prototypes

#define FIRST_PASSES 2         // passes to ignore after the CE's filters settle
#define FULL_SCALE 0x00A6D45L  // CE outputs full scale values; 683333.
#define CEB_DECIMATION 8       // software pulsing depends on this value

/*** Public functions declared within this module ***/
// See "ce.h".

/*** Public variables declared within this module *** settible via "defaults" */
volatile bool meter_had_power;
uint8_t      ce_first_pass;
const uint8r_t pre_samps[]   = { 42, 50, 84, 100 };
uint16x_t    samples;
bool         xfer_update;               // Enables update only if changed.
bool         xfer_busy;
uint8_t data decimate_ce_busy = CEB_DECIMATION;   // decimates code in ce_busy

/*** Private functions declared within this module ***/

/*** Private variables declared within this module ***/
#if TRACE10
static uint8_t chop = _POSITIVE;
#endif

//===========================================================================//
// This runs each time the CE executes its halt instruction- once per pass.
// That is, this runs 2520.6 times per second.  It collects the sag
// data, and performs other logic that must be synchronized to the CE.
#pragma save
#pragma REGISTERBANK (CE_BANK)
void ce_busyz_isr (void) small reentrant interrupt CE_BUSYZ_IV using CE_BANK
{
    #if 1 // enable this entire interrupt's code

    #if M6520
    #elif TRACE10
    CE2 = (CE2 & ~CHOP_EN) | CHOP_EN;
    #endif
    if ((IFLAGS & IE_XFER_) && xfer_busy)
    {
        xfer_busy = 0;
        CONFIG1 &= ~MUX_ALT;  // Clear, force alternate MUX sequence.
        CONFIG1 |= MUX_ALT;   // Set.
    }

    // This interrupt runs every 396us, and these tasks
    // can be handled much less often without problems.
    if ((--decimate_ce_busy) == 0)
    {
        #if STATUS
        uint8_t ck;
        uint8_t status_ce;
        #define ea TRUE
        #endif

        // 8 * 396 = 3.2ms; psoft_out() depends on this running every 8th time
        decimate_ce_busy = CEB_DECIMATION;

        #if STATUS
        ck = CKCON;
        BEGIN_CE_CRITICAL_SECTION;
        CLK_STRETCH;                 // Change stretch to '6' equivalent.
        status_ce = * (uint8x_t *) &CE_Outputs.O_cestatus; // Just grab high order byte.
        CLK_RELAX;                   // Back to default value.
        END_CE_CRITICAL_SECTION;
        // preserve the 3 conductor sag bits; F0 and 1_SEC are current data
        Totals.Sums.T_Status.c[HI_HI] = status_ce;
        // Are the compute-engine's sag detection bits set for all the phases
        // that power the meter?  (POWERED_PHASE is in options.h)
        if ((status_ce & POWERED_PHASE) == POWERED_PHASE)
        {
            // Save when the power fails, not when it is off.
            if (meter_had_power)
            {
                uint8_t ckcon = CONFIG0; // save clock speed
                extern enum EEPROM_RC data eeprom_state;
                EA = 0;  // disable interrupts
                // Changing the MPU speed causes serial communication
                // to fail, since the uarts are clocked by the same clock.
                // This is reasonable in code to manage power failure.
                CONFIG0 &= ~MPU_DIV;  // MPU to full speed

                RESET_WD(); // push off the hardware watchdog

                meter_had_power = FALSE;

                #if EEPROM
                // prepare to save the registers
                // eeprom_enable();
                eeprom_state = _OK;
                memcpy_prx (
                    EEPROM_REGISTERS, 
                    (uint8x_t*)&Totals.Acc, // The start of the data
                    // the second copy will be valid if the first is
                    // being recalculated, and vice-versa
                    (2*sizeof(struct Accumulators_t)));  // save two copies
                #endif

                CONFIG0 = ckcon;  // restore clock speed
                EA = 1;  // enable interrupts
            }
        }
        else
        {
            meter_had_power = TRUE;
        }
        #undef ea
        #endif // STATUS

        #if PULSE_SOFT
        psoft_out ();                // software pulse outputs
        #endif

        #ifdef WD_CE_BUSYZ
        wd_reset ( WD_CE_BUSYZ );    // notify the watchdog handler
        #endif
    }
    #endif // this interrupt's code is enabled
}
#pragma restore

#if EXTRAS
// wait till CE busy completes
void ce_wait_for_busy (void)
{
    uint8_t now;
    uint16_t cnt;
    now = decimate_ce_busy;
    for (cnt = 400; (cnt > 0) && (now == decimate_ce_busy); --cnt)
        ;
}
#endif

//============================================================================//
// This runs from either of two interrupts, either the data available
// interrupt: xfer_busy, or the real-time-clock's one-second interrupt.
// The xfer_busy interrupt transfers data from the CE to the MPU on each
// accumulation interval- a few times per second, usually.
// The RTC interrupt performs the temperature compensation, and any other
// items that must be performed on precise one-second intervals.
// Both interrupts are rather infrequent.
#pragma save
#pragma NOAREGS
// called from the interrupt decode routines in io65??.c
void ce_xfer_busyz_isr (void) small reentrant
{
    #if TRACE10
    CE2 = (CE2 & ~CHOP_EN) | chop;
    chop ^= CHOP_EN;         // Toggle chop between 1 (01b) and 2 (10b).
    #endif

    // On the first two passes, the CE's calculations are incorrect,..
    // ..so the results are not worth recording.
    if (0 == ce_first_pass)
    {
        uint8p_t *pDst;
        uint8x_t *pSrc;
        uint8_t  len;

        // variables to save interrupt state for a CE transfer
        CE_XFER_DEFINES;

        // save a snapshot of the state
        CE_XFER_SAVE;

        // copy CE values to the MPU       
        pDst = MPU_Outputs; 
        pSrc = (uint8x_t *) &CE_Outputs;
        len  = sizeof (CE_Outputs) / sizeof (int32_t);
        do
        {
            MEMCPY_MCE;               // Copy single 32-bit word from CE to XRAM.
            NEXT_MCE;                 // Point to start of next Dst & Src.
        } while (--len);

        xfer_update = TRUE;          // Inform the main loop to process the data.
    }
    else if (0 == --ce_first_pass)
    {
        DIO |= DIO_PW;              // Enable WPULSE.
        DIO |= DIO_PV;              // Enable VARPULSE.
    }

    #ifdef WD_XFER_BUSYZ  // if it's required, reset it 
    wd_reset ( WD_XFER_BUSYZ );
    #endif

    #ifdef OSCOPE_H
    OSCOPE_TOGGLE;
    #endif

    xfer_busy = 1;  // permit ce_busy_isr to set alt_mux
}
#pragma restore

//============================================================================//
// This routine runs one second after the CE is started.  At that point
// the CE's software PLL has locked to the line frequency, and the digital
// filtering is operating.  Acquisition of data should be delayed till
// the second set of data is available after the PLL settles.
#if TIMERS
#pragma save
#pragma NOAREGS
static void ce_start(void) small reentrant
{
    ce_first_pass = FIRST_PASSES;  // Ignore CE data until the data is right.
}
#pragma restore
#endif

//============================================================================//
// Initialize the compute engine in the analog front end.
void ce_init (void)
{
    uint16_t s =  (NumCeCode * sizeof (CeCode[0]));  // the size of CE code
    #if PULSE_SOURCE && M6520
    uint32_t temp;
    #endif

    // I/O constants at 2000 are set-up in defaults.c
 
    CE_DISABLE ();                      // Turn off the CE.
 
    // figure the samples per accumulation interval, needed to display data
    samples = pre_samps[ (CE1 & PRE_SAMPS) >> 6 ] * (CE1 & SUM_CYCLES);

    #if BROWNOUT_BATMODE
    // In brownout return without setting up the CE; the CE can't
    // run anyway because the ADCs are off.  Copying the data
    // takes time, and at a 32KHz clock rate, that's waste.
    if (batmode_is_brownout ())
    {
        // note that samples is set up (see above), 
        // so display routines work.
        // note that CE is disabled (see above)
        EX_CE_BUSYZ = FALSE;            // Disable busyz interrupt.
        // The xfer interrupt is shared with the RTC clock, which continues
        // to operate.
        // 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_);
        EX_XFER_RTC = TRUE;            // Enable external interrupt 6
        CE2 &= ~EX_XFER;               // Disable the xfer interrupt
        #ifdef WD_RTC
        wd_create ( WD_RTC );
        #endif
        return;
    }
    #endif

    irq_disable ();  // start of a critical section

    // set up the sag-detect flag
    meter_had_power = FALSE;

    #if TIMERS
    // The CE's software PLL and filtering take one second to settle.
    // Valid data occurs on the second collection after that.
    ce_first_pass = 0xFF;       // Ignore CE data until the timer runs
    stm_start (milliseconds(1000), 0, ce_start);  // start a software timer
    #else
    ce_first_pass = 2;          // approximate the requirement
    #endif

    #if TRACE10
    // Copy CE_CODE image to the CE's microcode RAM.
    memcpy_xr ((int8x_t *) CE_CODE_BASE, (int8r_t *) CeCode, s);
    // Assure that it halts.
    * (uint16x_t *) (CE_CODE_BASE + ((CE_CODE_SIZE - 1) << 1)) = 0xFFFF;
    #else // it's a 652x, with the CE code in flash.
    CE3 = (uint16_t) CeCode >> 10;  // tell the CE where its code is.
    #endif                           

    // Copy the CE's initial variable values to the CE's RAM.
    if (NumCeData)
    {
        memcpy_cer (
           (int32x_t *)CE_DATA_BASE,
           (int32r_t *)&CeData[0],
           (uint8_t)(0xff & NumCeData)
           );
    }
    else
    {
        memset_x (
           (uint8x_t *)CE_DATA_BASE,
           0,
           (CE_PARM_SIZE * 4) 
           );
    }

    #if PULSE_SOURCE
    #if M6520
    temp = memget_ce(&cestate);
    temp |= CE_EXT_PULSE;
    memset_ce (&cestate, temp);
    #elif TRACE10
//    memset_ce (&ext_pulse, 15);  // experimental
    #else
    #error unknown device type
    #endif
    #endif

    #if CONSTANTS_DBG
    // Make CE defaults visible to the AMD-51 ICE.
    // Note, if this code is enabled, overlap errors occur in the link,
    // but they do not cause defective operation.
    get_ce_constants ();
    #endif

    // After this, the watchdog is reset only if these interrupts
    // have run.
    RESET_WD();                    // Reset watchdog.


    // Set up the interrupts.
    // Interrupt priorities are set in main.
    I3FR = FALSE;                  // FALLING_EDGE_CE_BUSYZ. 
    EX_CE_BUSYZ = TRUE;            // Enable busyz interrupt.
    decimate_ce_busy = CEB_DECIMATION;
    #ifdef WD_CE_BUSYZ
    wd_create (WD_CE_BUSYZ);       // if wd.h says, watch this interrupt
    #endif
 

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区视频在线播放| 成人免费视频视频| 国产精品灌醉下药二区| 日韩精品一区二区三区蜜臀| 成人动漫在线一区| 青青青伊人色综合久久| 国产精品久久777777| 日韩精品一区二区三区中文精品| 国产成人免费在线视频| 日韩激情视频网站| 综合久久久久综合| 久久精品视频免费观看| 日韩午夜精品视频| 欧美日韩一级视频| 99re视频精品| 国产98色在线|日韩| 亚洲一区二区精品视频| 国产精品天干天干在线综合| 日韩视频免费观看高清完整版| 色一区在线观看| 成人黄色片在线观看| 国产精品一区一区| 另类欧美日韩国产在线| 日日摸夜夜添夜夜添亚洲女人| **性色生活片久久毛片| 国产欧美综合色| 久久久国产一区二区三区四区小说| 欧美一区二区三区四区五区| 欧美综合一区二区三区| 99久久伊人网影院| 大胆亚洲人体视频| 国产成人精品亚洲777人妖| 美女免费视频一区二区| 日产国产高清一区二区三区| 亚洲成人av在线电影| 亚洲成人自拍网| 亚洲综合久久久| 亚洲一区在线播放| 午夜精品福利视频网站| 午夜精品久久一牛影视| 亚洲午夜激情网站| 亚洲超碰精品一区二区| 午夜天堂影视香蕉久久| 五月天婷婷综合| 日韩精品成人一区二区三区| 丝袜诱惑亚洲看片| 久久99久久久久久久久久久| 奇米色777欧美一区二区| 欧美96一区二区免费视频| 日韩在线一区二区| 日韩电影免费在线观看网站| 日本不卡中文字幕| 精品一区二区三区免费毛片爱 | 中文字幕在线播放不卡一区| 中文在线一区二区| 亚洲精品乱码久久久久久日本蜜臀| 亚洲男人天堂一区| 午夜欧美大尺度福利影院在线看 | 18欧美乱大交hd1984| 亚洲欧洲国产日韩| 亚洲成人av在线电影| 免费精品视频在线| 国产精品自拍av| 9i看片成人免费高清| 欧美色综合网站| 日韩美女视频在线| 日本一区二区三区四区在线视频 | 国产美女视频91| 成人免费高清视频在线观看| 91美女精品福利| 91精品国产综合久久精品| 久久综合国产精品| 亚洲人成亚洲人成在线观看图片| 亚洲二区视频在线| 久久爱www久久做| av一二三不卡影片| 91精品国产91综合久久蜜臀| 久久精品夜色噜噜亚洲a∨| 亚洲黄网站在线观看| 蜜桃一区二区三区在线| caoporn国产精品| 日韩一区二区三区电影| 亚洲国产精品精华液ab| 亚洲一区二区欧美| 国产精品一区专区| 在线观看欧美精品| 337p粉嫩大胆噜噜噜噜噜91av| 国产精品久久久久久久午夜片 | 26uuu久久天堂性欧美| 亚洲色图视频网| 秋霞电影网一区二区| 白白色亚洲国产精品| 欧美一区二区精美| 最新欧美精品一区二区三区| 看国产成人h片视频| 91色|porny| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲一区二区偷拍精品| 国产精品 日产精品 欧美精品| 欧美日韩精品欧美日韩精品| 国产精品亲子乱子伦xxxx裸| 日本欧美韩国一区三区| 91国偷自产一区二区开放时间 | 亚洲地区一二三色| 成人蜜臀av电影| 日韩久久免费av| 亚洲国产视频网站| 91在线国产福利| 欧美激情综合五月色丁香小说| 奇米精品一区二区三区在线观看| 在线视频一区二区三区| 国产日韩av一区| 捆绑变态av一区二区三区| 欧美久久久久久久久中文字幕| 亚洲男同性恋视频| 99在线精品一区二区三区| 欧美精品一区在线观看| 奇米四色…亚洲| 91精品国产综合久久香蕉的特点| 一区二区成人在线观看| 成人av影院在线| 国产精品久久久久久妇女6080| 国产精品一区二区在线看| 日韩欧美一级片| 蜜臀精品久久久久久蜜臀| 欧美日韩www| 亚洲福利国产精品| 欧美日本在线一区| 无码av免费一区二区三区试看 | 精品999在线播放| 日韩福利电影在线| 欧美日韩另类一区| 亚洲高清视频的网址| 精品视频色一区| 午夜av一区二区三区| 欧美私模裸体表演在线观看| 中文字幕成人在线观看| 成人小视频免费在线观看| 国产人成一区二区三区影院| 国产精一区二区三区| 欧美精品一区二区三区蜜桃视频 | 在线精品视频小说1| 亚洲啪啪综合av一区二区三区| 91在线视频官网| 亚洲精品免费看| 欧美日本在线视频| 丝袜诱惑制服诱惑色一区在线观看 | 欧美国产日韩亚洲一区| 国产精选一区二区三区| 久久先锋影音av鲁色资源网| 国产伦理精品不卡| 国产精品毛片无遮挡高清| 99视频在线精品| 亚洲第一电影网| 日韩欧美国产一区二区在线播放| 韩国欧美一区二区| 国产精品色噜噜| 色婷婷激情一区二区三区| 亚洲不卡一区二区三区| 欧美一区二区三区人| 国产在线精品一区二区三区不卡 | 亚洲精品在线免费播放| 国产99久久久久| 亚洲综合在线五月| 91精品国产一区二区三区蜜臀| 激情深爱一区二区| 国产精品色在线| 欧美吞精做爰啪啪高潮| 极品美女销魂一区二区三区免费| 久久精品亚洲国产奇米99| 91免费国产在线| 日韩av电影免费观看高清完整版在线观看 | 国产精品视频一二三| 日本高清视频一区二区| 玖玖九九国产精品| 国产精品色噜噜| 3d成人动漫网站| 成人午夜视频在线| 午夜私人影院久久久久| 国产亚洲精品aa午夜观看| 欧美性一二三区| 国内精品伊人久久久久av影院| 亚洲欧美自拍偷拍| 欧美精品丝袜中出| 国产精品影音先锋| 亚洲一区二区三区影院| 久久嫩草精品久久久精品一| 日本道免费精品一区二区三区| 免费成人在线观看视频| 亚洲图片欧美激情| 精品精品欲导航| 在线精品视频一区二区| 国产精品一区二区在线观看不卡 | 国产精品99久久久久| 亚洲最大色网站| 国产精品美女久久久久aⅴ | 免费精品99久久国产综合精品| 综合久久久久久久| 久久久综合九色合综国产精品| 欧美日韩一区二区欧美激情|