📄 sweep.c
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: sweep.c
*
* Purpose: EEPROM hardware accessing functions
*
* Author: Tevin Chen
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__SWITCH_H__)
#include "switch.h"
#endif
#if !defined(__SWREG_H__)
#include "swreg.h"
#endif
/*--------------------- Static Definitions ------------------------*/
#define EEP_CMD_RD 0xA1
#define EEP_CMD_WR 0xA0
#define PTN_STATUS_OK 0x02
#define PTN_STATUS_ERR 0x04
/*--------------------- Static Types ------------------------------*/
/*--------------------- Static Macros -----------------------------*/
/*--------------------- Static Classes ----------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Functions --------------------------*/
/*--------------------- Export Variables --------------------------*/
BOOL SWEEP_bReadB(UINT16 wAddr, PBYTE pbyData) DIRECT_FUNTYPE_REENT
{
// Set address
SWREG_vWriteB(EEPROM_ADDR, (BYTE)(wAddr & 0xFF));
// Set device id and issue read command
// (0~255 => dev id = 0; 256~511 => dev id = 1....)
SWREG_vWriteB(EEPROM_DEV_ADDR, ((BYTE)(wAddr >> 7)) & 0x0E | EEP_CMD_RD );
// loop to wait for EEPROM operation complete
if (!SWREG_bWaitStatus(EEPROM_STATUS, PTN_STATUS_OK, TRUE))
return FALSE;
// get data and return true
SWREG_vReadB(EEPROM_DATA, pbyData);
return TRUE;
}
BOOL SWEEP_bWriteB(UINT16 wAddr, BYTE byData) DIRECT_FUNTYPE_REENT
{
// Set address
SWREG_vWriteB(EEPROM_ADDR, (BYTE)(wAddr & 0xFF));
// Set written value
SWREG_vWriteB(EEPROM_DATA, byData);
// Set device id and issue write command
// (0~255 => dev id = 0; 256~511 => dev id = 1....)
SWREG_vWriteB(EEPROM_DEV_ADDR, ((BYTE)(wAddr >> 7)) & 0x0E | EEP_CMD_WR );
// loop to wait for EEPROM operation complete
if (!SWREG_bWaitStatus(EEPROM_STATUS, PTN_STATUS_OK, TRUE))
return FALSE;
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -