Changeset ff8f05b in rtems


Ignore:
Timestamp:
Mar 27, 2010, 2:42:26 PM (9 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, master
Children:
ff8dd26
Parents:
91df983e
Message:

code changes to remove warnings

Location:
c/src/lib/libcpu/powerpc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/powerpc/ChangeLog

    r91df983e rff8f05b  
     12010-03-27      Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
     2
     3        * mpc83xx/gtm/gtm.c: code changes to remove warnings
     4
    152010-03-25      Thomas Doerfler <Thomas.Doerfler@embedded-brains.de>
    26
  • c/src/lib/libcpu/powerpc/mpc83xx/gtm/gtm.c

    r91df983e rff8f05b  
    3131        }
    3232
    33 #define MPC83XX_GTM_VARIABLES( timer) \
    34         int module = (timer) / 4; \
    35         int module_timer = (timer) % 4; \
    36         int high = module_timer / 2; \
    37         int low = module_timer % 2; \
    38         rtems_interrupt_level level;
     33#define GTM_MODULE(timer)       ((timer)/4)
     34#define GTM_MODULE_TIMER(timer) ((timer)%4)
     35#define GTM_HIGH(timer)         (GTM_MODULE_TIMER(timer)/2)
     36#define GTM_LOW(timer)          (GTM_MODULE_TIMER(timer)%2)
    3937
    4038#define MPC83XX_GTM_CLOCK_MASK MPC83XX_GTM_CLOCK_EXTERN
     
    4745{
    4846        rtems_status_code sc = RTEMS_SUCCESSFUL;
    49 
    50         MPC83XX_GTM_VARIABLES( timer);
    51 
    52         unsigned mask = 0xfU << (low * 4);
    53         unsigned flags = 0x3U << (low * 4);
     47        rtems_interrupt_level level;
     48
     49        unsigned mask = 0xfU << (GTM_LOW(timer) * 4);
     50        unsigned flags = 0x3U << (GTM_LOW(timer) * 4);
    5451        uint8_t reg = 0;
    5552
     
    5855        rtems_interrupt_disable( level);
    5956
    60         reg = mpc83xx.gtm [module].gtcfr [high].reg;
    61         mpc83xx.gtm [module].gtcfr [high].reg = (uint8_t) ((reg & ~mask) | flags);
    62 
    63         mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] = 0;
     57        reg = mpc83xx.gtm [GTM_MODULE(timer)].gtcfr [GTM_HIGH(timer)].reg;
     58        mpc83xx.gtm [GTM_MODULE(timer)].gtcfr [GTM_HIGH(timer)].reg =
     59          (uint8_t) ((reg & ~mask) | flags);
     60
     61        mpc83xx.gtm [GTM_MODULE(timer)]
     62          .gt_tim_regs [GTM_HIGH(timer)]
     63          .gtmdr [GTM_LOW(timer)] = 0;
    6464
    6565        rtems_interrupt_enable( level);
     
    8282rtems_status_code mpc83xx_gtm_enable_restart( int timer, bool enable)
    8383{
    84         MPC83XX_GTM_VARIABLES( timer);
    85 
     84        rtems_interrupt_level level;
    8685        MPC83XX_GTM_CHECK_INDEX( timer);
    8786
     
    8988
    9089        if (enable) {
    91                 mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] |= 0x0008;
     90                mpc83xx.gtm [GTM_MODULE(timer)]
     91                  .gt_tim_regs [GTM_HIGH(timer)]
     92                  .gtmdr [GTM_LOW(timer)] |= 0x0008;
    9293        } else {
    93                 mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] &= ~0x0008;
     94                mpc83xx.gtm [GTM_MODULE(timer)]
     95                  .gt_tim_regs [GTM_HIGH(timer)]
     96                  .gtmdr [GTM_LOW(timer)] &= ~0x0008;
    9497        }
    9598
     
    101104rtems_status_code mpc83xx_gtm_set_clock( int timer, int clock)
    102105{
    103         MPC83XX_GTM_VARIABLES( timer);
    104 
     106        rtems_interrupt_level level;
    105107        uint16_t reg = 0;
    106108
     
    113115        rtems_interrupt_disable( level);
    114116
    115         reg = mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low];
    116         mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] = (reg & ~MPC83XX_GTM_CLOCK_MASK) | clock;
     117        reg = mpc83xx.gtm [GTM_MODULE(timer)]
     118          .gt_tim_regs [GTM_HIGH(timer)]
     119          .gtmdr [GTM_LOW(timer)];
     120        mpc83xx.gtm [GTM_MODULE(timer)]
     121          .gt_tim_regs [GTM_HIGH(timer)]
     122          .gtmdr [GTM_LOW(timer)] = (reg & ~MPC83XX_GTM_CLOCK_MASK) | clock;
    117123
    118124        rtems_interrupt_enable( level);
     
    123129rtems_status_code mpc83xx_gtm_get_clock( int timer, int *clock)
    124130{
    125         MPC83XX_GTM_VARIABLES( timer);
    126 
    127         MPC83XX_GTM_CHECK_INDEX( timer);
    128 
    129         *clock = mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] & MPC83XX_GTM_CLOCK_MASK;
     131        MPC83XX_GTM_CHECK_INDEX( timer);
     132
     133        *clock = mpc83xx.gtm [GTM_MODULE(timer)]
     134          .gt_tim_regs [GTM_HIGH(timer)]
     135          .gtmdr [GTM_LOW(timer)] & MPC83XX_GTM_CLOCK_MASK;
    130136
    131137        return RTEMS_SUCCESSFUL;
     
    134140rtems_status_code mpc83xx_gtm_start( int timer)
    135141{
    136         MPC83XX_GTM_VARIABLES( timer);
    137 
    138         uint8_t flags = 0x2 << (low * 4);
    139 
    140         MPC83XX_GTM_CHECK_INDEX( timer);
    141 
    142         rtems_interrupt_disable( level);
    143         mpc83xx.gtm [module].gtcfr [high].reg &= ~flags;
     142        rtems_interrupt_level level;
     143        uint8_t flags = 0x2 << (GTM_LOW(timer) * 4);
     144
     145        MPC83XX_GTM_CHECK_INDEX( timer);
     146
     147        rtems_interrupt_disable( level);
     148        mpc83xx.gtm [GTM_MODULE(timer)]
     149.gtcfr [GTM_HIGH(timer)].reg &= ~flags;
    144150        rtems_interrupt_enable( level);
    145151
     
    149155rtems_status_code mpc83xx_gtm_stop( int timer)
    150156{
    151         MPC83XX_GTM_VARIABLES( timer);
    152 
    153         uint8_t flags = 0x2 << (low * 4);
    154 
    155         MPC83XX_GTM_CHECK_INDEX( timer);
    156 
    157         rtems_interrupt_disable( level);
    158         mpc83xx.gtm [module].gtcfr [high].reg |= flags;
     157        rtems_interrupt_level level;
     158        uint8_t flags = 0x2 << (GTM_LOW(timer) * 4);
     159
     160        MPC83XX_GTM_CHECK_INDEX( timer);
     161
     162        rtems_interrupt_disable( level);
     163        mpc83xx.gtm [GTM_MODULE(timer)].gtcfr [GTM_HIGH(timer)].reg |= flags;
    159164        rtems_interrupt_enable( level);
    160165
     
    164169rtems_status_code mpc83xx_gtm_set_value( int timer, uint16_t value)
    165170{
    166         MPC83XX_GTM_VARIABLES( timer);
    167 
    168         MPC83XX_GTM_CHECK_INDEX( timer);
    169 
    170         mpc83xx.gtm [module].gt_tim_regs [high].gtcnr [low] = value;
     171        MPC83XX_GTM_CHECK_INDEX( timer);
     172
     173        mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtcnr [GTM_LOW(timer)] = value;
    171174
    172175        return RTEMS_SUCCESSFUL;
     
    175178rtems_status_code mpc83xx_gtm_get_value( int timer, uint16_t *value)
    176179{
    177         MPC83XX_GTM_VARIABLES( timer);
    178 
    179         MPC83XX_GTM_CHECK_INDEX( timer);
    180 
    181         *value = mpc83xx.gtm [module].gt_tim_regs [high].gtcnr [low];
     180        MPC83XX_GTM_CHECK_INDEX( timer);
     181
     182        *value = mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtcnr [GTM_LOW(timer)];
    182183
    183184        return RTEMS_SUCCESSFUL;
     
    186187rtems_status_code mpc83xx_gtm_set_reference( int timer, uint16_t reference)
    187188{
    188         MPC83XX_GTM_VARIABLES( timer);
    189 
    190         MPC83XX_GTM_CHECK_INDEX( timer);
    191 
    192         mpc83xx.gtm [module].gt_tim_regs [high].gtrfr [low] = reference;
     189        MPC83XX_GTM_CHECK_INDEX( timer);
     190
     191        mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtrfr [GTM_LOW(timer)] = reference;
    193192
    194193        return RTEMS_SUCCESSFUL;
     
    197196rtems_status_code mpc83xx_gtm_get_reference( int timer, uint16_t *reference)
    198197{
    199         MPC83XX_GTM_VARIABLES( timer);
    200 
    201         MPC83XX_GTM_CHECK_INDEX( timer);
    202 
    203         *reference = mpc83xx.gtm [module].gt_tim_regs [high].gtrfr [low];
     198        MPC83XX_GTM_CHECK_INDEX( timer);
     199
     200        *reference = mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtrfr [GTM_LOW(timer)];
    204201
    205202        return RTEMS_SUCCESSFUL;
     
    208205rtems_status_code mpc83xx_gtm_set_prescale( int timer, uint8_t prescale)
    209206{
    210         MPC83XX_GTM_VARIABLES( timer);
    211 
    212         MPC83XX_GTM_CHECK_INDEX( timer);
    213 
    214         mpc83xx.gtm [module].gtpsr [module_timer] = prescale;
     207        MPC83XX_GTM_CHECK_INDEX( timer);
     208
     209        mpc83xx.gtm [GTM_MODULE(timer)].gtpsr [GTM_MODULE_TIMER(timer)] = prescale;
    215210
    216211        return RTEMS_SUCCESSFUL;
     
    219214rtems_status_code mpc83xx_gtm_get_prescale( int timer, uint8_t *prescale)
    220215{
    221         MPC83XX_GTM_VARIABLES( timer);
    222 
    223         MPC83XX_GTM_CHECK_INDEX( timer);
    224 
    225         *prescale = mpc83xx.gtm [module].gtpsr [module_timer];
     216        MPC83XX_GTM_CHECK_INDEX( timer);
     217
     218        *prescale = mpc83xx.gtm [GTM_MODULE(timer)].gtpsr [GTM_MODULE_TIMER(timer)];
    226219
    227220        return RTEMS_SUCCESSFUL;
     
    239232rtems_status_code mpc83xx_gtm_interrupt_enable( int timer)
    240233{
    241         MPC83XX_GTM_VARIABLES( timer);
    242 
    243         MPC83XX_GTM_CHECK_INDEX( timer);
    244 
    245         rtems_interrupt_disable( level);
    246         mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] |= 0x0010;
     234        rtems_interrupt_level level;
     235        MPC83XX_GTM_CHECK_INDEX( timer);
     236
     237        rtems_interrupt_disable( level);
     238        mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtmdr [GTM_LOW(timer)] |= 0x0010;
    247239        rtems_interrupt_enable( level);
    248240
     
    252244rtems_status_code mpc83xx_gtm_interrupt_disable( int timer)
    253245{
    254         MPC83XX_GTM_VARIABLES( timer);
    255 
    256         MPC83XX_GTM_CHECK_INDEX( timer);
    257 
    258         rtems_interrupt_disable( level);
    259         mpc83xx.gtm [module].gt_tim_regs [high].gtmdr [low] &= ~0x0010;
     246        rtems_interrupt_level level;
     247        MPC83XX_GTM_CHECK_INDEX( timer);
     248
     249        rtems_interrupt_disable( level);
     250        mpc83xx.gtm [GTM_MODULE(timer)].gt_tim_regs [GTM_HIGH(timer)].gtmdr [GTM_LOW(timer)] &= ~0x0010;
    260251        rtems_interrupt_enable( level);
    261252
     
    265256rtems_status_code mpc83xx_gtm_interrupt_clear( int timer)
    266257{
    267         MPC83XX_GTM_VARIABLES( timer);
    268 
    269         MPC83XX_GTM_CHECK_INDEX( timer);
    270 
    271         mpc83xx.gtm [module].gtevr [module_timer] = 0x0002;
    272 
    273         return RTEMS_SUCCESSFUL;
    274 }
     258        MPC83XX_GTM_CHECK_INDEX( timer);
     259
     260        mpc83xx.gtm [GTM_MODULE(timer)].gtevr [GTM_MODULE_TIMER(timer)] = 0x0002;
     261
     262        return RTEMS_SUCCESSFUL;
     263}
Note: See TracChangeset for help on using the changeset viewer.