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

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

?? battest.c

?? TDK 6521 SOC 芯片 DEMO程序
?? C
字號:
/***************************************************************************
 * 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 - battery test code.
//  If BME, bit 6 of 0x2020, is set, then a load is applied and on the
//  next alternate conversion cycle, the battery voltage is measured.
//  Since this loads the battery, it should be as short as possible,
//  and done only rarely, e.g. once per day.
//  Therefore, the real-time logic is in the CE interrupts in ce.c
//  In xfer_busy, which starts the almux cycle to mesure temperature,
//  there's code to start a battery test.  In ce-busy, which runs
//  after every mux cycle, there's code to collect the battery test
//  data.
//  The code here commands the battery test, and then interprets it.
// 
//  AUTHOR:  RGV
//
//  HISTORY: See end of file.
//**************************************************************************
// File: BATTEST.C
//               
#include "options.h"
#if BATTERY_TEST
#include "meter.h"       // access to day of month
#include "ce.h"          // memget_ce()
#include "lcd.h"         // liquid crystal display
#include "battest.h"     // test the fn prototypes
                                                                              
/*** External variables referenced by this module ***/
// See "math.h"
// Refer to "ce652x.h"  include file.
// VBat is in Totals, in meter.h (so it can be displayed, saved, etc.)
// VBatMin is in Totals.Parms, in meter.h (so it can be calibrated)

/*** Public variables declared within this module ***/
uint8_t data bat_sample_cnt = 0;  // counts samples not yet collected
int32_t xdata bat_samples; // sum of samples

/*** Private functions declared within this module ***/
static int32_t mVBat (int32_t v); // calculate the battery voltage, in mV

/*** Private variables declared within this module ***/
#if REAL_TIME_DATE
static uint8_t last_day = 0;  // the last day that a battery test was done
#elif OPERATING_TIME
static uint32_t last_day = 0;  // the last day that a battery test was done
#else
#error battery test needs a way to find the next day
#endif

// This routine may be called from the command line to start a battery
// test.  The xfer_busy_interrupt, in ce.c, reads bat_sample_cnt to start
// a measurement.
void battest_start (void)
{
    if (bat_sample_cnt)  // if a measurement is in progress, don't mess it up
        return;
    #if REAL_TIME_DATE
    last_day = Rtc_Date;
    #elif OPERATING_TIME
    last_day = OperatingSeconds + 86400L;
    #else
    #error needs a day sensor
    #endif
    LCDX |= BME;  // start reading the battery
    bat_sample_cnt = 3;
}

// This routine is called from the part of meter_run() that only
// operates when the CE is active.  This is because the battery test
// can only run when the CE is active.  It can't run in brownout mode,
// for example.
void battest_run (void)
{
    // Schedule a battery test every day at midnight, and ASAP when the meter 
    // is turned on.  With a 3.6V battery at the worst case battery load 
    // resistor, 27 kiloOhms, this nominally draws 133 microamps for 
    // 2 seconds each day. 
    // If mains power never fails, this depletes a 1Amp/Hour battery 
    // (typical small 3.6V lithium) in ten years.
    #if REAL_TIME_DATE
    if (last_day != Rtc_Date)
    #elif OPERATING_TIME
    if (last_day < OperatingSeconds)
    #else
    #error needs a day sensor
    #endif
    {
        battest_start ();
    } 
    else if (bat_sample_cnt > 0)
    {
        --bat_sample_cnt;
        if (bat_sample_cnt == 0)
        {
            VBat = ((uint32_t) memget_ce (&vbat) ) >> 9;
            LCDX &= ~BME;  // stop measuring
        }
    }
    // if mesurement is done, and the battery exists
    else if (bat_sample_cnt == BATTERY_MODE_ENABLE)
    {
        // report the results
        // VBatMin can be calibrated. It's in the parameter table 
        // in meter\meter.h with other calibrations.
        // NOT AN ERROR!! The ADC count is bigger for smaller VBat voltage
        if (VBat > VBatMin) // e.g. 0V = 7FFFFF adc counts, 5V = 0x600000
        {
            // report an error
            Status |= BATTERY_BAD;
        }
        else
        {
            // report a success
            Status &= ~BATTERY_BAD;
        }
    }
}

// display the most recent battery voltage on the LCD
void battest_lcd (void) // there's only one battery! Don't pass the value.
{
   LCD_Number (mVBat(VBat), 6, 3);     
   LCD_3DP ();		  	// Three decimal places.
   battest_start ();  	// start another measurement, so display adjusts
}

// calculate the battery voltage in millivolts
int32_t mVBat (int32_t v)
{
    // The ADC sample has to be shifted right 9 bits.  
    // So the float constant (-2.298e-6, from official testing) is divided by 2.
    // The most accurate place in the ADC is 3.3V, roughly 0x69d800
    // For a perfectly accurate scheme, the chip-to-chip variations in
    // offset and LSB have to be calibrated, and they have 5% variations.
    // This is not done, because the display is a gross mesurement.
    // The code is designed so the failure voltage can be calibrated.
    return (3300L + (int32_t)((-2.298e-3) * (float)((v - 0x69D800L))));
}


/***************************************************************************
 * History
 * $Log: battest.c,v $
 * Revision 1.9  2006/09/27 01:34:19  tvander
 * Battery mode moved to DIO-8
 *
 * Revision 1.8  2006/09/12 02:44:49  gmikef
 * *** empty log message ***
 *
 * Revision 1.7  2006/08/09 00:57:33  tvander
 * *** empty log message ***
 *
 * Revision 1.6  2006/07/07 01:04:19  tvander
 * Only reports a battery error when there's supposed to be a battery.
 *
 * Revision 1.5  2006/06/14 02:41:26  tvander
 * New, derated battery test runs at 1/8 MPU speed, but uses 150x more battery
 * current.
 *
 * Revision 1.4  2006/06/06 03:57:33  tvander
 * Modified to run with hardware timers as well as software timers.
 *
 * Revision 1.3  2006/05/30 17:18:49  tvander
 * Made it possible to compile this on non-6520s
 *
 * Revision 1.2  2006/05/18 23:18:50  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.1  2006/05/17 19:07:59  tvander
 * Battery test works.
 * Power factor works for instantaneous value.  Periodic value compiles, but is
 * untested.
 *
 *
 * 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.         *
 ***************************************************************************/
/* battest.c */
#endif // BATTERY_TEST

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美视频一区二区在线观看| 午夜久久久影院| 色婷婷狠狠综合| 久久99这里只有精品| 国产欧美日韩不卡| 欧日韩精品视频| 国产成人自拍网| 日韩成人一级片| 中文字幕成人av| 欧美一卡二卡在线观看| 成人av小说网| 国产精品亚洲午夜一区二区三区| 国产精品国产三级国产aⅴ中文| 欧美视频在线一区二区三区| 国产999精品久久久久久绿帽| 午夜伦理一区二区| 亚洲精品日韩一| 国产精品丝袜黑色高跟| 欧美精品一区二区精品网| 欧美日本在线视频| 欧美在线观看你懂的| 99re热这里只有精品视频| 国产一区二区三区不卡在线观看| 亚洲国产综合色| 亚洲乱码国产乱码精品精小说| 日本一区二区三级电影在线观看| 欧美一区二视频| 欧美日韩高清在线| 欧美视频第二页| 91福利社在线观看| 91免费看视频| 欧美日韩一本到| 欧美男人的天堂一二区| 777a∨成人精品桃花网| 欧美videofree性高清杂交| 欧美一区二区三区四区在线观看| 91性感美女视频| 国产精品一区三区| 国产在线精品国自产拍免费| 国产精品99久久久久久久女警 | 亚洲日本免费电影| 久久精品综合网| 欧美国产日韩精品免费观看| 国产日韩成人精品| 亚洲精品亚洲人成人网在线播放| 亚洲美女屁股眼交3| 婷婷开心久久网| 国产精品一区一区| 91亚洲精品久久久蜜桃网站| 欧美精品v日韩精品v韩国精品v| 欧美电影免费观看高清完整版在线观看| 欧美男生操女生| 欧美岛国在线观看| 久久一日本道色综合| 中文字幕高清不卡| 日本v片在线高清不卡在线观看| 国产很黄免费观看久久| 在线视频你懂得一区二区三区| 日韩欧美区一区二| 亚洲欧美电影一区二区| 日本成人在线视频网站| 91女神在线视频| 国产精品午夜在线观看| 三级亚洲高清视频| 色偷偷成人一区二区三区91| 91精品国产入口| 一区二区三区在线视频免费 | 激情欧美一区二区| 欧美性受xxxx黑人xyx性爽| 日本一区二区三区电影| 国内精品免费**视频| 欧美精品三级日韩久久| 中文字幕一区二区三区不卡| 国产成人8x视频一区二区| 精品成人免费观看| 精一区二区三区| 国产欧美综合在线| 91在线国内视频| 一区二区三区在线视频免费观看| 91国模大尺度私拍在线视频| 亚洲精品ww久久久久久p站| 欧美亚洲一区二区在线| 肉肉av福利一精品导航| 久久网站最新地址| 国产成人av在线影院| 亚洲欧美一区二区视频| 欧美日韩国产色站一区二区三区| 日韩av在线播放中文字幕| 久久综合五月天婷婷伊人| 99这里都是精品| 日本不卡免费在线视频| 日本一区二区三区免费乱视频| 91麻豆国产福利精品| 精品午夜一区二区三区在线观看| 精品国产一区二区三区av性色| 99综合电影在线视频| 极品美女销魂一区二区三区| 久久精品在这里| 91九色02白丝porn| 国产69精品久久99不卡| 水野朝阳av一区二区三区| 国产精品美女一区二区三区 | 日韩精品国产精品| 欧美国产激情二区三区| 91精选在线观看| 欧美挠脚心视频网站| 91蜜桃传媒精品久久久一区二区| 精品在线播放免费| 蜜臀精品一区二区三区在线观看| 中文字幕在线观看一区二区| 26uuu欧美| 精品福利一区二区三区免费视频| 欧美综合欧美视频| 91毛片在线观看| gogo大胆日本视频一区| 国产精品2024| 国产99久久久久| 国产黄色成人av| 国产成人aaa| 极品少妇xxxx精品少妇| 美国三级日本三级久久99| 午夜欧美视频在线观看| 亚洲影院久久精品| 亚洲精品伦理在线| 亚洲国产精品尤物yw在线观看| 一区二区三区资源| 一区二区三区日韩在线观看| 怡红院av一区二区三区| 天天色综合天天| 精品一区二区久久久| 国产精选一区二区三区| 色婷婷综合久久| 欧美一区日本一区韩国一区| 久久免费看少妇高潮| 国产亚洲精久久久久久| 中文字幕一区二区三区不卡| 午夜欧美电影在线观看| 国产在线视频精品一区| 成人国产亚洲欧美成人综合网| 欧美视频一二三区| 久久久久综合网| 亚洲精品成a人| 九一九一国产精品| 91网站在线观看视频| 欧美一级生活片| 亚洲激情成人在线| 久久91精品国产91久久小草| 91久久久免费一区二区| 精品国产1区二区| 亚洲在线视频网站| 国产一区二区三区久久悠悠色av| 欧美日韩免费观看一区二区三区 | 亚洲一区二区三区四区在线免费观看| 美女视频免费一区| 99r国产精品| 亚洲国产精品国自产拍av| 免费在线观看精品| 欧美一区二区国产| 一个色综合av| 91麻豆6部合集magnet| 国产欧美一区二区精品婷婷| 奇米精品一区二区三区四区| 欧美自拍偷拍一区| 亚洲一区在线观看网站| 成人av小说网| 国产精品成人一区二区艾草| 成人免费视频免费观看| 久久久国产精品午夜一区ai换脸 | 日韩电影在线免费观看| 欧美喷水一区二区| 亚洲精品中文字幕乱码三区| caoporm超碰国产精品| 国产精品女主播av| 国产精品888| 亚洲视频狠狠干| 91啪在线观看| 日日夜夜精品视频免费| 欧美一区二区三区白人| 蜜桃在线一区二区三区| 欧美tickling挠脚心丨vk| 美女被吸乳得到大胸91| 久久久美女艺术照精彩视频福利播放| 激情六月婷婷久久| 亚洲图片欧美色图| 欧美老年两性高潮| 另类的小说在线视频另类成人小视频在线| 欧美精品1区2区3区| 久久精品99国产精品日本| www成人在线观看| 在线观看网站黄不卡| 久久不见久久见免费视频1 | 欧美日韩视频专区在线播放| 热久久免费视频| 国产欧美精品一区二区色综合| 在线观看三级视频欧美| 久久国产尿小便嘘嘘尿| 亚洲一区在线看| 国产欧美日韩综合| 欧美日韩中文字幕一区| 国产成人精品三级|