00001 /* 00002 eeprom.h 00003 00004 Contributors: 00005 Created by Marek Michalkiewicz <marekm@linux.org.pl> 00006 00007 THIS SOFTWARE IS NOT COPYRIGHTED 00008 00009 This source code is offered for use in the public domain. You may 00010 use, modify or distribute it freely. 00011 00012 This code is distributed in the hope that it will be useful, but 00013 WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00014 DISCLAIMED. This includes but is not limited to warranties of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 */ 00017 00018 #ifndef _EEPROM_H_ 00019 #define _EEPROM_H_ 1 00020 00021 #define __need_size_t 00022 #include <stddef.h> 00023 00024 #include <io.h> 00025 00026 /* return 1 if EEPROM is ready for a new read/write operation, 0 if not */ 00027 #define eeprom_is_ready() bit_is_clear(EECR, EEWE) 00028 00029 /* read one byte from EEPROM address ADDR */ 00030 extern unsigned char eeprom_rb(unsigned int addr); 00031 00032 /* read one 16-bit word (little endian) from EEPROM address ADDR */ 00033 extern unsigned int eeprom_rw(unsigned int addr); 00034 00035 /* write a byte VAL to EEPROM address ADDR */ 00036 extern void eeprom_wb(unsigned int addr, unsigned char val); 00037 00038 /* read a block of SIZE bytes from EEPROM address ADDR to BUF */ 00039 extern void eeprom_read_block(void *buf, unsigned int addr, size_t n); 00040 00041 /* IAR C compatibility defines */ 00042 #define _EEPUT(addr, val) eeprom_wb(addr, val) 00043 #define _EEGET(var, addr) (var) = eeprom_rb(addr) 00044 00045 #endif /* _EEPROM_H_ */