Help please!
typedef unsigned long int hcc_u32;
extern hcc_u32 mcf5xxx_byterev(hcc_u32 val);
#define WR_LE32(a, v) ((*(hcc_u32*)(a))=mcf5xxx_byterev(v))
#define WR_LE16(a, v) ((*(hcc_u16*)(a))=(hcc_u16)(mcf5xxx_byterev(v) >> 16))
#define RD_LE32(a) (mcf5xxx_byterev(*(hcc_u32*)(a)))
#define RD_LE16(a) ((hcc_u16)(mcf5xxx_byterev((hcc_u32)*(hcc_u16*)(a))>>16))
void main(void) {
WR_LE32(&BDT_CTL_RX(1,0),1);
}
mcf5xxx_byterev is undefined!
Thank you
Hi
You may find that this routine is in an assembly file somewhere since the Coldfire has a specal assembler instruction that can be used to reverse bytes very efficiently:
CodeWarrior assembler is:
_byte_rev:
byterev.l d0
rts
GCC assembler may be:
byte_rev:
move.l 4(%SP),%D0
byterev.l %D0
rts
If not, it can also be replaced by a macro similar to the following:
#define fnLE_add(x) ((x >> 24) | ((x >> 8) & 0x0000ff00) | ((x << 8) & 0x00ff0000) | ((x << 24) & 0xff000000))
Regards
Mark