[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: [avr-gcc-list] Macro to read /write long to eeprom
From: |
Haase Bjoern (PT-BEU/EMT) * |
Subject: |
AW: [avr-gcc-list] Macro to read /write long to eeprom |
Date: |
Wed, 10 Aug 2005 08:54:20 +0200 |
Hi,
If you are using avr-libc-1.2.5 you could write a fairly efficient function by
using the following code.
You will be having 4 calls, but never the less this will be more efficient than
the wrapper function using read_block that forces all the values once to memory.
Yours,
Björn
/* Code functional only with avr-libc-1.2.5 */
uint16_t static inline __attribute__ ((always_inline))
eeprom_read_long_word (const uint32_t *addr);
uint16_t
eeprom_read_long_word (const uint32_t *addr)
{
uint32_t result;
asm ( XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov %A1,__tmp_reg__" CR_TAB
XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov %B1,__tmp_reg__" CR_TAB
XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov %C1,__tmp_reg__" CR_TAB
XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov %D1,__tmp_reg__"
: "+x" (addr),
"=r" (result)
: );
return result;
}
void static inline __attribute__ ((always_inline))
eeprom_write_long_word (uint16_t *addr,uint32_t value);
void
eeprom_write_long_word (uint16_t *addr,uint32_t value)
{
asm volatile (
"mov __tmp_reg__,%A1" CR_TAB
XCALL " __eeprom_write_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov __tmp_reg__,%B1" CR_TAB
XCALL " __eeprom_write_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov __tmp_reg__,%C1" CR_TAB
XCALL " __eeprom_write_byte_" _REG_LOCATION_SUFFIX CR_TAB
"mov __tmp_reg__,%D1" CR_TAB
XCALL " __eeprom_write_byte_" _REG_LOCATION_SUFFIX
: "+x" (addr)
: "r" (value)
: "memory"
);
}
-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Royce Pereira
Gesendet: Dienstag, 9. August 2005 20:54
An: AVR-GCC
Betreff: [avr-gcc-list] Macro to read /write long to eeprom
Hi,
Is there a macro to read or write a long word (32 bits) to eeprom?
For the last hour I've been trying to write one unsuccessfully.
Thanks,
--Royce.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- AW: [avr-gcc-list] Macro to read /write long to eeprom,
Haase Bjoern (PT-BEU/EMT) * <=