bugAVR C Runtime Library - Bugs: bug #22355, Feature request: eeprom_read_32...

 
 

bug #22355: Feature request: eeprom_read_32 and eeprom_write_32

Submitted by:  Shaun Jackman <sjackman>
Submitted on:  Mon 18 Feb 2008 06:02:32 PM UTC  
 
Category: Feature RequestSeverity: 1 - Wish
Priority: 3 - LowItem Group: libc code
Status: FixedPercent Complete: 100%
Assigned to: Dmitry Xmelkov <dmix>Open/Closed: Closed
Release: NoneFixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 08 Mar 2008 10:52:25 PM UTC, comment #3:

Fixed in CVS HEAD and 1_6 branches.
Functions eeprom_read_dword() and eeprom_write_dword() are
added.

Dmitry Xmelkov <dmix>
Project AdministratorIn charge of this item.
Sat 08 Mar 2008 02:21:07 PM UTC, comment #2:

Changing owner to Dmitry.

Eric Weddington <arcanum>
Project Administrator
Mon 18 Feb 2008 06:04:10 PM UTC, comment #1:

Ack. My code was munged by the rich markup. I'll resubmit the code in a patch.

Shaun Jackman <sjackman>
Mon 18 Feb 2008 06:02:32 PM UTC, original submission:

eeprom_read_block and eeprom_write_block product terrible code when used with a 32-bit variable stored in the register file, since the 32-bit variable must be first copied to the stack, which usually includes adjusting the stack-pointer and allocating a frame-pointer, leading to all sorts of ugly overhead. For this reason, I suggest adding eeprom_read_32 and eeprom_write_32. Simple definitions of these functions follow.

With the current state of optimization, the line `return (uint32_t)hi << 16 | lo;' does not produce very tight code. Using a union will produce smaller code. Alternatively, I would love to see the GCC optimizer fixed to make the shift and or produce tight code, but that's a bigger task.

n.b. I don't have AVR hardware at the moment, so these functions are untested.

Cheers,
Shaun

uint32_t eeprom_read_32(const uint32_t *src)
{
const uint16_t p = (const uint16_t )src;
uint16_t lo = eeprom_read_word(&p[0]);
uint16_t hi = eeprom_read_word(&p[1]);
return (uint32_t)hi << 16 | lo;
}

void eeprom_write_32(uint32_t *dest, uint32_t value)
{
uint16_t p = (uint16_t )dest;
eeprom_write_word(&p[0], (uint16_t)value);
eeprom_write_word(&p[1], value >> 16);
}

Shaun Jackman <sjackman>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #15067:  eeprom32.c added by sjackman (447B - text/x-csrc - [PATCH])

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dmix (Posted a comment)
  • -unavailable- added by arcanum (Updated the item)
  • -unavailable- added by sjackman
  • -unavailable- added by sjackman (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 19 Mar 2008 10:27:57 PM UTCarcanumOpen/ClosedOpen=>Closed
    Mon 17 Mar 2008 04:29:23 PM UTCarcanumCategoryLibrary=>Feature Request
      Severity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
    Sat 08 Mar 2008 10:52:25 PM UTCdmixStatusNone=>Fixed
      Percent Complete0%=>100%
    Sat 08 Mar 2008 02:21:07 PM UTCarcanumAssigned toarcanum=>dmix
    Mon 25 Feb 2008 06:51:39 PM UTCarcanumAssigned toNone=>arcanum
    Mon 18 Feb 2008 06:06:38 PM UTCsjackmanAttached File-=>Added eeprom32.c, #15067
    Mon 18 Feb 2008 06:02:33 PM UTCsjackmanCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1