2002-11-09 Theodore A. Roth * include/avr/eeprom.h (eeprom_read_byte): New function, replaces eeprom_rb. (eeprom_read_word): New function, replaces eeprom_rw. (eeprom_write_byte): New function, replaces eeprom_wb. (eeprom_read_block): Change interface to take pointer to eeprom addr. (eeprom_rb): Deprecate and make macro to eeprom_read_byte. (eeprom_rw): Deprecate and make macro to eeprom_read_word. (eeprom_rw): Deprecate and make macro to eeprom_write_byte. * libc/misc/ee_rb.S: L_eeprom_rb -> L_eeprom_read_byte. * libc/misc/ee_rw.S: L_eeprom_rw -> L_eeprom_read_word. * libc/misc/ee_wb.S: L_eeprom_wb -> L_eeprom_write_byte. * libc/misc/eeprom.S: Convert to use new interfaces. Index: include/avr/eeprom.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/avr/eeprom.h,v retrieving revision 1.4 diff -u -r1.4 eeprom.h --- include/avr/eeprom.h 10 Nov 2002 04:37:43 -0000 1.4 +++ include/avr/eeprom.h 10 Nov 2002 04:50:05 -0000 @@ -35,6 +35,7 @@ #define __need_size_t #include +#include #include @@ -57,6 +58,7 @@ /** \name avr-libc declarations */ /address@hidden/ + /** \def eeprom_is_ready \ingroup avr_eeprom \returns 1 if EEPROM is ready for a new read/write operation, 0 if not. */ @@ -70,23 +72,23 @@ /** \ingroup avr_eeprom Read one byte from EEPROM address \c addr. */ -extern unsigned char eeprom_rb(unsigned int addr); +extern uint8_t eeprom_read_byte (uint8_t *addr); /** \ingroup avr_eeprom Read one 16-bit word (little endian) from EEPROM address \c addr. */ -extern unsigned int eeprom_rw(unsigned int addr); +extern uint16_t eeprom_read_word (uint16_t *addr); /** \ingroup avr_eeprom Write a byte \c val to EEPROM address \c addr. */ -extern void eeprom_wb(unsigned int addr, unsigned char val); +extern void eeprom_write_byte (uint8_t *addr, uint8_t val); /** \ingroup avr_eeprom Read a block of \c n bytes from EEPROM address \c addr to \c buf. */ -extern void eeprom_read_block(void *buf, unsigned int addr, size_t n); +extern void eeprom_read_block (void *buf, void *addr, size_t n); #ifdef __cplusplus } @@ -94,19 +96,46 @@ /address@hidden/ +/** \name Backwards compatibility defines */ + +/address@hidden/ + +/** \def eeprom_rb + \ingroup avr_eeprom + \deprecated + Use eeprom_read_byte() in new programs. */ + +#define eeprom_rb(addr) eeprom_read_byte ((uint8_t *)(addr)) + +/** \def eeprom_rw + \ingroup avr_eeprom + \deprecated + Use eeprom_read_word() in new programs. */ + +#define eeprom_rw(addr) eeprom_read_word ((uint16_t *)(addr)) + +/** \def eeprom_wb + \ingroup avr_eeprom + \deprecated + Use eeprom_write_byte() in new programs. */ + +#define eeprom_wb(addr,val) eeprom_write_byte ((uint8_t *)(addr), (uint8_t)(val)) + +/address@hidden/ + /** \name IAR C compatibility defines */ /address@hidden/ /** \def _EEPUT \ingroup avr_eeprom - write a byte to EEPROM */ + Write a byte to EEPROM. */ #define _EEPUT(addr, val) eeprom_wb(addr, val) /** \def _EEGET \ingroup avr_eeprom - read a byte from EEPROM */ + Read a byte from EEPROM. */ #define _EEGET(var, addr) (var) = eeprom_rb(addr) Index: libc/misc/ee_rb.S =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/libc/misc/ee_rb.S,v retrieving revision 1.1 diff -u -r1.1 ee_rb.S --- libc/misc/ee_rb.S 5 Jul 2002 20:38:44 -0000 1.1 +++ libc/misc/ee_rb.S 10 Nov 2002 04:50:05 -0000 @@ -26,5 +26,5 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define L_eeprom_rb 1 +#define L_eeprom_read_byte 1 #include "eeprom.S" Index: libc/misc/ee_rw.S =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/libc/misc/ee_rw.S,v retrieving revision 1.1 diff -u -r1.1 ee_rw.S --- libc/misc/ee_rw.S 5 Jul 2002 20:38:44 -0000 1.1 +++ libc/misc/ee_rw.S 10 Nov 2002 04:50:05 -0000 @@ -26,5 +26,5 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define L_eeprom_rw 1 +#define L_eeprom_read_word 1 #include "eeprom.S" Index: libc/misc/ee_wb.S =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/libc/misc/ee_wb.S,v retrieving revision 1.1 diff -u -r1.1 ee_wb.S --- libc/misc/ee_wb.S 5 Jul 2002 20:38:44 -0000 1.1 +++ libc/misc/ee_wb.S 10 Nov 2002 04:50:05 -0000 @@ -26,5 +26,5 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define L_eeprom_wb 1 +#define L_eeprom_write_byte 1 #include "eeprom.S" Index: libc/misc/eeprom.S =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/libc/misc/eeprom.S,v retrieving revision 1.1 diff -u -r1.1 eeprom.S --- libc/misc/eeprom.S 5 Jul 2002 20:38:44 -0000 1.1 +++ libc/misc/eeprom.S 10 Nov 2002 04:50:05 -0000 @@ -47,17 +47,17 @@ #define res_hi rP0 #define res_lo rP1 -#ifdef L_eeprom_rb +#ifdef L_eeprom_read_byte /* read one byte from EEPROM */ -/* unsigned char eeprom_rb(unsigned int addr); */ +/* uint8_t eeprom_read_byte(uint8_t *addr); */ /* addr = r25:r24, result = r25(=0):r24 */ .section .text - .global _U(eeprom_rb) + .global _U(eeprom_read_byte) -_U(eeprom_rb): +_U(eeprom_read_byte): sbic _SFR_IO_ADDR(EECR), EEWE - rjmp _U(eeprom_rb) /* make sure EEPROM is ready */ + rjmp _U(eeprom_read_byte) /* make sure EEPROM is ready */ #ifdef EEARH out _SFR_IO_ADDR(EEARH), addr_hi #endif @@ -66,18 +66,18 @@ clr res_hi /* gcc wants result extended to "int"? */ in res_lo, _SFR_IO_ADDR(EEDR) ret -#endif /* L_eeprom_rb */ +#endif /* L_eeprom_read_byte */ -#ifdef L_eeprom_rw +#ifdef L_eeprom_read_word /* read a little endian 16-bit word from EEPROM */ -/* unsigned int eeprom_rw(unsigned int addr); */ +/* uint16_t eeprom_read_word(uint16_t *addr); */ /* addr = r25:r24, result = r25:r24 */ - .global _U(eeprom_rw) + .global _U(eeprom_read_word) -_U(eeprom_rw): +_U(eeprom_read_word): sbic _SFR_IO_ADDR(EECR), EEWE - rjmp _U(eeprom_rw) /* make sure EEPROM is ready */ + rjmp _U(eeprom_read_word) /* make sure EEPROM is ready */ #ifdef EEARH out _SFR_IO_ADDR(EEARH), addr_hi #endif @@ -93,19 +93,19 @@ mov res_lo, __tmp_reg__ in res_hi, _SFR_IO_ADDR(EEDR) ret -#endif /* L_eeprom_rw */ +#endif /* L_eeprom_read_word */ -#ifdef L_eeprom_wb +#ifdef L_eeprom_write_byte /* write a byte to EEPROM */ -/* void eeprom_wb(unsigned int addr, unsigned char val); */ +/* void eeprom_write_byte(uint8_t *addr, uint8_t val); */ /* addr = r25:r24, val = r22 */ #define val rP3 - .global _U(eeprom_wb) + .global _U(eeprom_write_byte) -_U(eeprom_wb): +_U(eeprom_write_byte): sbic _SFR_IO_ADDR(EECR), EEWE - rjmp _U(eeprom_wb) /* make sure EEPROM is ready */ + rjmp _U(eeprom_write_byte) /* make sure EEPROM is ready */ #ifdef EEARH out _SFR_IO_ADDR(EEARH), addr_hi #endif @@ -118,7 +118,7 @@ out _SFR_IO_ADDR(SREG), __tmp_reg__ ret #undef val -#endif /* L_eeprom_wb */ +#endif /* L_eeprom_write_byte */ #undef addr_hi #undef addr_lo @@ -134,7 +134,7 @@ #ifdef L_eeprom_read_block /* read a block of bytes from EEPROM */ -/* void eeprom_read_block(void *buf, unsigned int addr, size_t n); */ +/* void eeprom_read_block(void *buf, void *addr, size_t n); */ /* buf = r25:r24, addr = r23:r22, n = r21:r20 */ .global _U(eeprom_read_block)