G
Glenn Møller-Holst
Hi!
Is it possible to transform these macro definitions to a c++/c
"variable" at specific address? It is going to be used on an ARM-processor:
#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
to some native C++, C? So it is possible to write:
unsigned long iopin0 /*some declaration defining iopin0 at the address
0xE0028000*/;
Applications:
iodir0 |= 0x00400000;
iopin0 = 0x00400000;
/*some instruction write sequence*/;
iodir0 &= (~0x00400000);
/*some instruction read sequence*/;
x= iopin0; // read pin.
-
The purpose is to be able to send the variable (eg. io) as a
const-parameter:
typedef struct io_iog_t { // iog: io-group.
volatile unsigned int pin; // 32 bit.
volatile unsigned int set;
volatile unsigned int dir;
volatile unsigned int clr;
} io_iog_t;
typedef struct iopin_t { // iopin: io-consecutive pin group.
unsigned char pingroup; // 8 bits.
unsigned char firstpinselected; // 8 bits.
unsigned int consecutivepinselection; // 32 bits.
} iopin_t;
struct io_iog_t iog[3] /* start address 0xE0028000 */;
const struct iopin_t io= { // Will normally be passed
pingroup= 0, // to a class or function as const.
firstpinselected= 5,
consecutivepinselection= 0x01 };
Applications:
iog[io.pingroup].dir &= (~(consecutivepinselection<<io.firstpinselected));
/*some instruction read sequence*/;
x= ((iog[io.pingroup].pin)>>io.firstpinselected)&io.consecutivepinselection;
iog[io.pingroup].dir |= (consecutivepinselection<<io.firstpinselected);
iog[io.pingroup].pin = (1<<io.firstpinselected);
/*some instruction write sequence*/;
regards,
Glenn
Is it possible to transform these macro definitions to a c++/c
"variable" at specific address? It is going to be used on an ARM-processor:
#define IOPIN0 (*((volatile unsigned long *) 0xE0028000))
#define IOSET0 (*((volatile unsigned long *) 0xE0028004))
#define IODIR0 (*((volatile unsigned long *) 0xE0028008))
#define IOCLR0 (*((volatile unsigned long *) 0xE002800C))
to some native C++, C? So it is possible to write:
unsigned long iopin0 /*some declaration defining iopin0 at the address
0xE0028000*/;
Applications:
iodir0 |= 0x00400000;
iopin0 = 0x00400000;
/*some instruction write sequence*/;
iodir0 &= (~0x00400000);
/*some instruction read sequence*/;
x= iopin0; // read pin.
-
The purpose is to be able to send the variable (eg. io) as a
const-parameter:
typedef struct io_iog_t { // iog: io-group.
volatile unsigned int pin; // 32 bit.
volatile unsigned int set;
volatile unsigned int dir;
volatile unsigned int clr;
} io_iog_t;
typedef struct iopin_t { // iopin: io-consecutive pin group.
unsigned char pingroup; // 8 bits.
unsigned char firstpinselected; // 8 bits.
unsigned int consecutivepinselection; // 32 bits.
} iopin_t;
struct io_iog_t iog[3] /* start address 0xE0028000 */;
const struct iopin_t io= { // Will normally be passed
pingroup= 0, // to a class or function as const.
firstpinselected= 5,
consecutivepinselection= 0x01 };
Applications:
iog[io.pingroup].dir &= (~(consecutivepinselection<<io.firstpinselected));
/*some instruction read sequence*/;
x= ((iog[io.pingroup].pin)>>io.firstpinselected)&io.consecutivepinselection;
iog[io.pingroup].dir |= (consecutivepinselection<<io.firstpinselected);
iog[io.pingroup].pin = (1<<io.firstpinselected);
/*some instruction write sequence*/;
regards,
Glenn