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

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

?? eepst24512.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) 2006 Teridian Semiconductor Corp. All Rights Reserved.    *
 ***************************************************************************/
//**************************************************************************
//  DESCRIPTION: 71M65xx POWER METER - Serial EEPROM Routines. 
// 
//  AUTHOR:  RGV
//
//  HISTORY: See end of file
//**************************************************************************
// File: eepromp.c
//**************************************************************************
// High speed polling eeprom API for an ST24512
// This can use only iicdio.c, a fast bit-banging interface.
// Most I2C eeprom drivers can also use iiceep.c, a slower, 
// less power-hungry interface that uses the chip's on-board I2C hardware.
// However, the ST24512 requires an illegal bus transition state
// in its "random read" operation (See ST's data sheet, rev. 5, section
// 3.12.  It requires a "start" without a "stop".  Setting up this condition
// requires an illegal bus transition.)  Conforming I2C hardware cannot 
// perform this operation.
//
#include "options.h"
#if EEPROM && I2C_POLLED
#include "stm.h"
#include "eeprom.h"
#include "iic.h" // polling IIC/I2C interface.

static uint16x_t time_to_write;
static int16x_t timeout_cnt;
enum EEPROM_RC data eeprom_state;

// timeout routines;
#pragma save
#pragma NOAREGS
void timeout_start (void) small reentrant
{
    timeout_cnt = 10000;
}
#pragma restore

#pragma save
#pragma NOAREGS
uint8_t timeout_ok (void) small reentrant
{
    --timeout_cnt;
    if (timeout_cnt < 0)
    {
        eeprom_state = _ERR_NACK;
        timeout_cnt = 0;
        return 0;
    }
    return 1;
}
#pragma restore

// Initialize the EEPROM interface for polling access
#pragma save
#pragma NOAREGS
void EEProm_Config (uint8_t access, uint16_t spg, uint8_t tWr) small reentrant
{
    eeprom_state = _OK;
    if (access)
    {
       time_to_write = tWr;
   
       IICInit();  // initialize the IIC bus
   
       IICStart();

       IICStop();
    }
    else
    {
       EX_EEPROM  = FALSE;           // Disable EEPROM non-busy interrupt.
       #if TRACE10 || M6520
       DIO &= ~DIO_EEX;              // Disconnect from external EEPROM.
       #else
       #error unhandled device type
       #endif
    }    
}
#pragma restore

// Write EEPROM Data; returns 0 when OK
#pragma save
#pragma NOAREGS
static uint8_t EPWritePage(uint32_t dst, uint8x_t *pchOut, 
    uint16_t cnt) small reentrant
{
    static uint8_t xdata cmd;
    static uint16_t xdata xdst;

    if (eeprom_state != _OK)
        return 1;

    // should address up to eight EEPROMs
    cmd = 0xA0 | (0xE & (dst >> 15)); // page write command
    xdst = (uint16_t)dst;
    timeout_start(); // long, but not forever
    IICStart();
    // while the EEPROM is busy, wait
    while(IICWrite(&cmd, 1) && timeout_ok())
    {
        IICStop();  
        IICStart();
    }
    // write the address
    if(IICWrite((uint8x_t *)&xdst, 2) || !timeout_ok())
    {
        IICStop();
        eeprom_state = _ERR_NACK;
        return 1;
    }
    // write the rest of the page's data
    if(IICWrite(pchOut, cnt) || !timeout_ok())
    {
        IICStop();
        eeprom_state = _ERR_NACK;
        return 1;
    }
    IICStop();
    return 0; // no error
}
#pragma restore

// copy any number of bytes from xdata to eeprom; 
#pragma save
#pragma NOAREGS
enum EEPROM_RC data *memcpy_prx(uint32_t dst, 
    uint8x_t *src, int16_t len) small reentrant
{
    int16_t lenInPage;

    // figure the number of bytes to the end of the first page
    lenInPage = PAGE_SIZE - (dst & (PAGE_SIZE - 1));
    // if the number of bytes is zero, then the write
    // starts on a page boundary
    if (lenInPage != 0)
    {
        // if the write is less than one page, finish it
        if (lenInPage > len)
            lenInPage = len;
        if(EPWritePage(dst, src, lenInPage))
            return &eeprom_state;
        src += (int)lenInPage;
        dst += (uint32_t)lenInPage;
        len -= lenInPage;
    }
    // write pages as quickly as possible
    while (len > PAGE_SIZE)
    {
        // write pages
        if(EPWritePage(dst, src, PAGE_SIZE))
            return &eeprom_state;
        src += PAGE_SIZE;
        dst += PAGE_SIZE;
        len -= PAGE_SIZE;
    }
    // write the last partial page, if any
    if (0 != len)
    {
        // write the last few bytes
        if(EPWritePage(dst, src, len))
            return &eeprom_state;
    }
    eeprom_state = _OK; 
    return &eeprom_state;
}
#pragma restore

#if CLI
// Clear EEPROM Data; returns 0 when OK
static bool EPClearPage(uint32_t dst)
{
    uint8_t xdata cmd;
    uint16_t xdata xdst;

    if (eeprom_state != _OK)
        return 1;

    // should address up to eight EEPROMs
    cmd = 0xA0 | (0xE & (dst >> 15)); // page write command
    xdst = (uint16_t)dst;
    timeout_start ();
    IICStart();
    while(IICWrite(&cmd, 1) && timeout_ok()) // while the EEPROM is busy, wait
    {
        IICStop();  
        IICStart();
    }
    if(IICWrite((uint8x_t *)&xdst, 2) || !timeout_ok()) // write the address
    {
        IICStop();
        eeprom_state = _ERR_NACK;
        return 1;
    }
    // write the rest of the page's data
    if(IICPad(PAGE_SIZE, 0xFF) || !timeout_ok())
    {
        IICStop();
        eeprom_state = _ERR_NACK;
        return 1;
    }
    IICStop();
    eeprom_state = _OK;
    return 0; // no error
}
#endif

#if CLI
// clear the ROM; 
enum EEPROM_RC data *memclr_pr (void)
{
    uint32_t len = EEPROM_SIZE;
    uint32_t dst = 0;

    // write pages as quickly as possible
    while (len > 0)
    {
        // write pages
        if(EPClearPage(dst))
            return &eeprom_state;
        dst += PAGE_SIZE;
        len -= PAGE_SIZE;
    }
    eeprom_state = _OK; 
    return &eeprom_state;
}
#endif

// read bytes; a return of nonzero is a fail.
#pragma save
#pragma NOAREGS
enum EEPROM_RC data *memcpy_xpr(
    uint8x_t *dst, 
    uint32_t src, 
    int16_t len
    ) small reentrant
{
    static uint8_t  xdata cmd;
    static uint16_t xdata xsrc;

    if (eeprom_state != _OK)
        return &eeprom_state;

    // should address up to eight EEPROMs
    cmd = 0xA0 | (0xE & (src >> 15)); // page read command
    xsrc = (uint16_t)src;

    // do dummy write to load address to chip
    timeout_start();
    IICStart();
    // while there's a write in progress, wait
    while(IICWrite(&cmd, 1) && timeout_ok())
    {
        // retry
        IICStop();
        IICStart();
    }
    // write the address
    if(IICWrite((uint8x_t *)&xsrc, 2) || !timeout_ok())
    {
        IICStop();
        eeprom_state = _ERR_NACK; 
        return &eeprom_state;
    }
    cmd |= 0xA1; // sequential read command, address bits preserved
    timeout_start();
    IICStart();
    while(IICWrite(&cmd, 1) && timeout_ok()) // while there's an error, wait
    {
        // retry
        IICStop();
        IICStart();
    }
    if (!timeout_ok())
    {
        IICStop();
        eeprom_state = _ERR_NACK; 
        return &eeprom_state;
    }
    IICRead(dst, (uint16_t)len); // read the rest of the page's data
    IICStop();

    eeprom_state = _OK; 
    return &eeprom_state;
}
#pragma restore

#if CAL_SAVE && NV_SELECT == NV_EEPROM
// returns 1 if it worked, 0 if it timed out or failed
#pragma save
#pragma NOAREGS
bool eeprom_ok (enum EEPROM_RC data *pstatus) small reentrant
{
    RESET_WD();
    return (_OK == *pstatus);
}
#pragma restore
#endif // extras

#endif // EEPROM
/***************************************************************************
 *  $Log: eepst24512.c,v $
 *  Revision 1.4  2006/10/13 00:47:28  tvander
 *  Removed compile options for 6530, 6515;
 *  renamed 6511 and 6513 to trace11 and trace13;
 *  Binary verified unchanged from previous version.
 *
 *  Revision 1.3  2006/09/09 01:09:27  gmikef
 *  *** empty log message ***
 *
 *  Revision 1.2  2006/08/09 00:56:34  tvander
 *  *** empty log message ***
 *
 *  Revision 1.1  2006/08/08 00:43:39  tvander
 *  Added debugged ST24512 EEPROM driver.
 *
 *
 * Copyright (C) 2006 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.         *
 ***************************************************************************/

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区观看视频| 亚洲国产一区二区在线播放| 欧美一二三区在线观看| 欧美三级电影网站| 欧美综合天天夜夜久久| 欧美色区777第一页| 在线影院国内精品| 色伊人久久综合中文字幕| 一本色道久久综合亚洲精品按摩 | 色狠狠桃花综合| 91片在线免费观看| 一本久久a久久精品亚洲| 日本伦理一区二区| 欧美在线|欧美| 欧美日韩日日夜夜| 欧美一区二区播放| 2023国产精华国产精品| 国产婷婷色一区二区三区四区 | 激情都市一区二区| 国产一区二区在线看| 国产一区 二区| 粉嫩久久99精品久久久久久夜| 成人美女视频在线观看18| 91在线观看一区二区| 在线亚洲欧美专区二区| 欧美久久免费观看| 日韩欧美国产一区二区在线播放| 精品国产乱码久久久久久浪潮 | 亚洲激情图片小说视频| 亚洲第一成人在线| 久久精品免费观看| 懂色av中文一区二区三区| 99国产精品久| 欧美精品自拍偷拍| 久久久久久免费毛片精品| 国产精品水嫩水嫩| 亚洲成av人片| 国产一区视频导航| 色综合久久综合| 日韩精品专区在线| 国产精品久久久久三级| 亚洲图片欧美综合| 黄色小说综合网站| 91免费在线视频观看| 日韩欧美久久久| 中文字幕一区不卡| 美女网站色91| 成人av网站在线| 欧美一区二区三区在线观看| 中文一区一区三区高中清不卡| 夜夜爽夜夜爽精品视频| 国产一区二区三区香蕉| 91蝌蚪porny九色| 日韩一区二区三区电影在线观看| 国产视频一区二区在线观看| 亚洲电影在线播放| 国内成人自拍视频| 欧美性视频一区二区三区| 欧美精品一区二区三区久久久| 亚洲日本电影在线| 经典一区二区三区| 欧美日韩一卡二卡三卡| 国产精品理论在线观看| 日韩中文字幕一区二区三区| www.在线成人| 欧美草草影院在线视频| 亚洲曰韩产成在线| 成人免费观看男女羞羞视频| 日韩午夜在线观看| 一区二区三区成人在线视频| 国产福利一区二区三区| 日韩一级黄色片| 亚洲国产一区在线观看| 99久免费精品视频在线观看| 欧美成人乱码一区二区三区| 亚洲国产日产av| 91女神在线视频| 国产精品色哟哟| 国产精品自拍在线| 制服丝袜成人动漫| 亚洲综合一区二区精品导航| av在线播放一区二区三区| 精品久久久久久久一区二区蜜臀| 亚洲国产日韩一区二区| 色综合久久综合中文综合网| 中文字幕av一区二区三区免费看 | 欧美高清激情brazzers| 亚洲美女免费视频| aaa欧美大片| 国产精品热久久久久夜色精品三区| 人人超碰91尤物精品国产| 欧美日韩国产电影| 亚洲一区二区三区爽爽爽爽爽| 97精品超碰一区二区三区| 中文字幕av一区二区三区高| 国产精品夜夜嗨| 久久久久久久久久久久电影| 国产一区亚洲一区| 精品成人在线观看| 精品一区中文字幕| 精品理论电影在线观看| 久久99久久久欧美国产| 欧美大肚乱孕交hd孕妇| 青青草原综合久久大伊人精品| 欧美日韩高清一区| 亚洲成av人片| 欧美一区二区日韩一区二区| 天堂蜜桃一区二区三区| 91精品久久久久久久91蜜桃| 日韩av高清在线观看| 欧美一区二区视频观看视频| 免费看精品久久片| 精品捆绑美女sm三区| 国产乱码精品一区二区三| 久久久久久久久久久黄色| 丰满少妇在线播放bd日韩电影| 欧美国产视频在线| 国产.精品.日韩.另类.中文.在线.播放| 久久中文字幕电影| 国产99久久久精品| 亚洲精品一卡二卡| 欧美理论片在线| 激情五月婷婷综合网| 国产欧美视频一区二区| 色综合 综合色| 舔着乳尖日韩一区| 日韩欧美一二三四区| 国产精品综合一区二区| 国产精品福利一区二区三区| 91丨porny丨户外露出| 午夜av电影一区| 精品国产免费一区二区三区四区 | 午夜精品一区二区三区三上悠亚| 91精品国产福利在线观看| 精品一二三四区| 国产精品福利av | 亚洲永久免费av| 在线成人av网站| 国产传媒久久文化传媒| 亚洲欧美偷拍卡通变态| 欧美日韩成人一区二区| 国产一区二区三区蝌蚪| 一区二区三区在线观看视频| 欧美卡1卡2卡| 成人午夜精品在线| 亚洲无人区一区| 国产午夜精品福利| 在线观看亚洲精品视频| 国产做a爰片久久毛片| 一区二区三区中文字幕| 日韩欧美第一区| 色综合激情五月| 韩国av一区二区三区在线观看| 亚洲欧美偷拍另类a∨色屁股| 日韩一区二区三区电影在线观看 | 日韩一卡二卡三卡| 成人美女在线视频| 日本不卡在线视频| 18成人在线观看| 欧美成人一区二区| 一本一道综合狠狠老| 国模冰冰炮一区二区| 亚洲一二三区视频在线观看| 久久久久久日产精品| 在线播放亚洲一区| av在线播放成人| 国产主播一区二区| 婷婷夜色潮精品综合在线| 国产精品天天看| 欧美一区二区三区性视频| 91在线精品一区二区| 国产一级精品在线| 日韩精品成人一区二区在线| 国产精品成人免费| 精品福利一二区| 欧美乱熟臀69xxxxxx| 色综合久久99| 成人激情动漫在线观看| 另类小说欧美激情| 五月天丁香久久| 一区二区三区资源| 国产精品九色蝌蚪自拍| 久久综合色天天久久综合图片| 欧美日韩国产区一| 91麻豆123| 不卡的av中国片| 国产凹凸在线观看一区二区| 久久成人免费电影| 日本v片在线高清不卡在线观看| 夜夜精品视频一区二区| 中文字幕一区二区三区在线观看| 久久久久久久一区| 日韩欧美不卡一区| 欧美日韩精品一区二区天天拍小说| 91色porny蝌蚪| 91麻豆免费看片| 91视频一区二区| 99热精品国产| 91污在线观看| 91丨国产丨九色丨pron|