patchAVR C Runtime Library - Patches: patch #8563, Generalize power reduction macros...

 
 

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

patch #8563: Generalize power reduction macros in power.h by removing hard coded device names

Submitted by:  Pitchumani <pitchumani>
Submitted on:  Tue 04 Nov 2014 09:52:19 AM UTC  
 
Category:  None Priority:  6
Status:  Done Privacy:  Public
Assigned to:  Pitchumani <pitchumani> Open/Closed:  Closed

Wed 03 Dec 2014 06:03:52 AM UTC, comment #1:

Committed as rev #2460 and #2461

Pitchumani <pitchumani>
Project MemberIn charge of this item.
Tue 04 Nov 2014 09:52:19 AM UTC, original submission:

power.h is one of header files in avr-libc that hard codes device name, needs an update for every new device.

Attached patches generalizes the power reduction macros in power.h and adds required conditional macros in device header files.

power.h:
Power reduction macros are enabled conditionally based on specific macro for power reduction register (instead of device name macro).
Eg.
#if defined(__AVR_HAVE_PRR_PRADC)
#define power_adc_enable() (PRR &= (uint8_t)~(1 << PRADC))
#define power_adc_disable() (PRR |= (uint8_t)(1 << PRADC))
#endif

Macro '__AVR_HAVE_PRR_PRADC' shall be defined in the device header file along with power reduction register and bitfields.

To enable/ disable all following function shall be used.

static __inline void
_attribute_ ((_always_inline_))
__power_all_enable()
{
#ifdef __AVR_HAVE_PRR
PRR &= (uint8_t)~(__AVR_HAVE_PRR);
#endif

#ifdef __AVR_HAVE_PRR0
PRR0 &= (uint8_t)~(__AVR_HAVE_PRR0);
#endif

#ifdef __AVR_HAVE_PRR1
PRR1 &= (uint8_t)~(__AVR_HAVE_PRR1);
#endif

#ifdef __AVR_HAVE_PRR2
PRR2 &= (uint8_t)~(__AVR_HAVE_PRR2);
#endif

#ifdef __AVR_HAVE_PRGEN
PR_PRGEN &= (uint8_t)~(__AVR_HAVE_PRGEN);
#endif

#ifdef __AVR_HAVE_PRPA
PR_PRPA &= (uint8_t)~(__AVR_HAVE_PRPA);
#endif

#ifdef __AVR_HAVE_PRPB
PR_PRPB &= (uint8_t)~(__AVR_HAVE_PRPB);
#endif

#ifdef __AVR_HAVE_PRPC
PR_PRPC &= (uint8_t)~(__AVR_HAVE_PRPC);
#endif

#ifdef __AVR_HAVE_PRPD
PR_PRPD &= (uint8_t)~(__AVR_HAVE_PRPD);
#endif

#ifdef __AVR_HAVE_PRPE
PR_PRPE &= (uint8_t)~(__AVR_HAVE_PRPE);
#endif

#ifdef __AVR_HAVE_PRPF
PR_PRPF &= (uint8_t)~(__AVR_HAVE_PRPF);
#endif
}

where __AVR_HAVE_PRR, __AVR_HAVE_PRGEN etc expands to sum of bitfields in respective register/port (defined in device header).

In this case, we don't have to power reduction macros for new devices, it is automatically derived from the device header file. power.h may require update only for exceptional cases like new power reduction register/ ports/ bitfields.

device header files:
Adds macros for each power reduction register and its bitfields.

Eg: iom1284.h
#define __AVR_HAVE_PRR0 ((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI))
#define __AVR_HAVE_PRR0_PRADC
#define __AVR_HAVE_PRR0_PRSPI
#define __AVR_HAVE_PRR0_PRTIM1
#define __AVR_HAVE_PRR0_PRUSART0
#define __AVR_HAVE_PRR0_PRUSART1
#define __AVR_HAVE_PRR0_PRTIM0
#define __AVR_HAVE_PRR0_PRTIM2
#define __AVR_HAVE_PRR0_PRTWI

---
Thanks to Joern Rennecke (Embecosm) who proposed this idea to make power reduction macros generic.

Pitchumani <pitchumani>
Project MemberIn charge of this item.

 

Attached Files
file #32362:  generalize-power-reduction-macros.patch added by pitchumani (116KiB - application/octet-stream)
file #32363:  power-reduction-macros-mega.patch added by pitchumani (45KiB - application/octet-stream)
file #32364:  power-reduction-macros-xmega.patch added by pitchumani (74KiB - application/octet-stream)
file #32365:  power-reduction-macros-others.patch added by pitchumani (24KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pitchumani (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-12-03 pitchumani StatusIn Progress => Done
        Open/ClosedOpen => Closed
    2014-11-04 pitchumani Attached File- => Added generalize-power-reduction-macros.patch, #32362
        Attached File- => Added power-reduction-macros-mega.patch, #32363
        Attached File- => Added power-reduction-macros-xmega.patch, #32364
        Attached File- => Added power-reduction-macros-others.patch, #32365

    Back to the top


    Powered by Savane 3.4