⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 haleep.c

📁 开发源代码的CPU卡的COS源程序。
💻 C
字号:
/* ============================================================================   Project Name : jayaCard   Module Name  : proto/hal/avr/haleep.c   Version : $Id: haleep.c,v 1.3 2004/01/11 09:56:32 dgil Exp $	Description: 		EEPROM read/write of byte/word/buffer    The Original Code is jayaCard code.    The Initial Developer of the Original Code is Gilles Dumortier.	Portions created by the Initial Developer are Copyright (C) 2002-2004 the    Initial Developer. All Rights Reserved.    Contributor(s):    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; see http://www.gnu.org/licenses/gpl.html   History Rev	Description   073103 dgil	wrote it from scratch   ============================================================================*/#include "precomp.h"/* =========================================================================	__hal_eeprom_read_byte()	Read a single byte from the EEPROM	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */jbyte __hal_eeprom_read_byte(jword src){	while( !eeprom_is_ready() ) {}	return eeprom_rb(src);}/* =========================================================================	__hal_eeprom_read_word()	Read a word from the EEPROM	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */jword __hal_eeprom_read_word(jword src){	LOCAL(jbyte,b);	while( !eeprom_is_ready() ) {}	b = eeprom_rb(src);	while( !eeprom_is_ready() ) {}	return ( ((jword)b)| (((jword)eeprom_rb(src))<<8) );}/* =========================================================================	__hal_eeprom_read()	Read a buffer from the EEPROM	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */void __hal_eeprom_read(jbyte xdata* dest, jword src,jbyte len){	while( len-- ) {		while( !eeprom_is_ready() ) {}		*dest++ = eeprom_rb( src++ );	}}/* =========================================================================	__hal_eeprom_write_byte()	Write a single byte to the EEPROM. Returns EEPROM_HAL_OK if the write was	successful, EEPROM_HAL_ERROR otherwise.	Note that this primitive *can* write to write-once and OTP areas	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */jbyte __hal_eeprom_write_byte(jword dest,jbyte val){	while( !eeprom_is_ready() ) {}	eeprom_wb( dest, val );	return EEPROM_HAL_OK;}/* =========================================================================	__hal_eeprom_write_word()	Write a word to the EEPROM. Returns EEPROM_HAL_OK if the write was	successful, EEPROM_HAL_ERROR otherwise.	Note that this primitive *can* write to write-once and OTP areas	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */jbyte __hal_eeprom_write_word(jword dest,jword w){	while( !eeprom_is_ready() ) {}	eeprom_wb( dest, LOBYTE(w) );	dest++;	while( !eeprom_is_ready() ) {}	eeprom_wb( dest, HIBYTE(w) );	return EEPROM_HAL_OK;}/* =========================================================================	__hal_eeprom_write()	Write a buffer to the EEPROM. Returns EEPROM_HAL_OK if the write was	successful, EEPROM_HAL_ERROR otherwise.	Note that this primitive *can* write to write-once and OTP areas	!this is an unsecure version! BIOS will handle the security around this	primitive   ========================================================================= */jbyte __hal_eeprom_write(jword dest, jbyte xdata* src,jbyte len){	while( len-- ) {		while( !eeprom_is_ready() ) {}		eeprom_wb( dest++, *src++ );	}	return EEPROM_HAL_OK;}/* =========================================================================	That's all folks !   ========================================================================= */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -