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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22355: Feature request: eeprom_read_32 and eeprom_write_32

Submitter:  Shaun Jackman <sjackman>
Submitted:  Mon 18 Feb 2008 06:02:32 PM UTC
   
 
Category:  Feature Request Severity:  1 - Wish
Priority:  3 - Low Item Group:  libc code
Status:  Fixed Assigned to:  dmix
Percent Complete:  100% Open/Closed:  Closed
Release:  None Fixed Release:  None

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>
Group administrator
Sat 08 Mar 2008 02:21:07 PM UTC, comment #2: 

Changing owner to Dmitry.

Eric Weddington <arcanum>
Group 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.)

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
  • -email is unavailable- added by dmix (Posted a comment)
  • -email is unavailable- added by arcanum (Updated the item)
  • -email is unavailable- added by sjackman
  • -email is unavailable- added by sjackman (Submitted the item)
  •  

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-03-19 arcanum Open/ClosedOpen Closed
    2008-03-17 arcanum CategoryLibrary Feature Request
        Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
    2008-03-08 dmix StatusNone Fixed
        Percent Complete0% 100%
    2008-03-08 arcanum Assigned toarcanum dmix
    2008-02-25 arcanum Assigned toNone arcanum
    2008-02-18 sjackman Attached File- Added eeprom32.c, #15067
    2008-02-18 sjackman Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code