Forums

Re: Bit Definitions of IO regs in GNU vs Metrowerks

Started by bitjockey1 June 15, 2004
Hello All!

Thanks for the response to the bit banging question. I Looked in the
ports_def.h file in the Gel package and found use of the "1<<(x)". I
believe the << creates a constant with only the (x) being set. What
does the (byte) do in the following:

#define CC_S (byte)(1<<7) //Stop disable
#define CC_X (1<<6) //X-interrupt mask
#define CC_H (1<<5) //Half carry flag

This is what Metrowerks does in their register definition file.

#define _IO_BASE_ADDR 0x0800
#define _IO_AT(x) @(_IO_BASE_ADDR+(x))

#ifndef __DECL__6812D60_H__
#define __DECL__6812D60_H__ extern
#endif

/* DEFINE PORT A */

__DECL__6812D60_H__ volatile union {
struct {
unsigned char _PA0:1;
unsigned char _PA1:1;
unsigned char _PA2:1;
unsigned char _PA3:1;
unsigned char _PA4:1;
unsigned char _PA5:1;
unsigned char _PA6:1;
unsigned char _PA7:1;
} PORTA_BITS;
unsigned char PORTA_BYTE;
}PORTA1 _IO_AT(0x00);

/* DEFINE PORT A REGISTER */
#define PORTA PORTA1.PORTA_BYTE

/*DEFINE PORTA REGISTER BITS*/

#define PA0 PORTA1.PORTA_BITS._PA0
#define PA1 PORTA1.PORTA_BITS._PA1
#define PA2 PORTA1.PORTA_BITS._PA2
#define PA3 PORTA1.PORTA_BITS._PA3
#define PA4 PORTA1.PORTA_BITS._PA4
#define PA5 PORTA1.PORTA_BITS._PA5
#define PA6 PORTA1.PORTA_BITS._PA6
#define PA7 PORTA1.PORTA_BITS._PA7

__DECL__6812D60_H__ volatile unsigned char DDRA _IO_AT
(0x02); /* data direction port A */

Anyone with any thoughts if this can be done in GNU HC12??

Thanks,

Brian