Register definitions: get rid of some macro magic that doesn't help much
Instead of e.g. GPIO.DATA.GPIO_08, you now use GPIO->DATA.GPIO_08.
This commit is contained in:
parent
091e4cd84e
commit
5e00219a9c
5 changed files with 22 additions and 30 deletions
|
@ -30,7 +30,7 @@
|
|||
* This file is part of libmc1322x: see http://mc1322x.devl.org
|
||||
* for details.
|
||||
*
|
||||
* $Id: tmr.h,v 1.6 2010/11/07 14:21:06 maralvira Exp $
|
||||
* $Id: tmr.h,v 1.7 2010/11/07 14:24:11 maralvira Exp $
|
||||
*/
|
||||
|
||||
#ifndef TMR_H
|
||||
|
@ -48,12 +48,12 @@
|
|||
|
||||
/* Structure-based register definitions */
|
||||
/* Example use:
|
||||
TMR2.CTRL = 0x1234;
|
||||
TMR2.CTRLbits = (struct TMR_CTRL) {
|
||||
TMR2->CTRL = 0x1234;
|
||||
TMR2->CTRLbits = (struct TMR_CTRL) {
|
||||
.DIR = 1,
|
||||
.OUTPUT_MODE = 2,
|
||||
};
|
||||
TMR2.CTRLbits.PRIMARY_CNT_SOURCE = 3;
|
||||
TMR2->CTRLbits.PRIMARY_CNT_SOURCE = 3;
|
||||
*/
|
||||
|
||||
struct TMR_struct {
|
||||
|
@ -134,21 +134,16 @@ struct TMR_struct {
|
|||
};
|
||||
};
|
||||
|
||||
static volatile struct TMR_struct * const _TMR0 = (void *) (TMR0_BASE);
|
||||
static volatile struct TMR_struct * const _TMR1 = (void *) (TMR1_BASE);
|
||||
static volatile struct TMR_struct * const _TMR2 = (void *) (TMR2_BASE);
|
||||
static volatile struct TMR_struct * const _TMR3 = (void *) (TMR3_BASE);
|
||||
#define TMR0 (*_TMR0)
|
||||
#define TMR1 (*_TMR1)
|
||||
#define TMR2 (*_TMR2)
|
||||
#define TMR3 (*_TMR3)
|
||||
static volatile struct TMR_struct * const TMR0 = (void *) (TMR0_BASE);
|
||||
static volatile struct TMR_struct * const TMR1 = (void *) (TMR1_BASE);
|
||||
static volatile struct TMR_struct * const TMR2 = (void *) (TMR2_BASE);
|
||||
static volatile struct TMR_struct * const TMR3 = (void *) (TMR3_BASE);
|
||||
|
||||
/* Used to compute which enable bit to set for a particular timer, e.g.
|
||||
TMR0.ENBL |= TMR_ENABLE_BIT(TMR2);
|
||||
Helpful when you're using macros to define timers
|
||||
*/
|
||||
#define TMR_ENABLE_BIT(x) ((&(x) == &(TMR0)) ? 1 : (&(x) == &(TMR1)) ? 2 : (&(x) == &(TMR2)) ? 4 : (&(x) == &(TMR3)) ? 8 : 0)
|
||||
|
||||
#define TMR_ENABLE_BIT(x) (((x) == TMR0) ? 1 : ((x) == TMR1) ? 2 : ((x) == TMR2) ? 4 : ((x) == TMR3) ? 8 : 0)
|
||||
#define TMR0_PIN GPIO_08
|
||||
#define TMR1_PIN GPIO_09
|
||||
#define TMR2_PIN GPIO_10
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue