On Nov 3, 2005, at 11:35 PM, Vincent Trouilliez wrote:
static void log_address_set( uint32_t address )
{
...
...
if (address & 0x00040000)
PORTB |= LOG_SDA;
else
PORTB &= ~LOG_SDA;
...
}
On Nov 4, 2005, at 1:20 AM, Ian Caddy wrote:
I haven't tried this, but it might be better:
unsigned char temp;
temp = (address >> 16) & 0xFF;
if(temp & 0x04)
{
/* Your code */
}
In other messages & has been replaced with &&.
Ian is close to how I would have handled it. I use a "union32_t" type
a fair bit in my code for no other purpose than to pluck values out
of the middle painlessly.
typedef union union32_t {
struct __attribute__ ((packed)) {
uint8_t a, b, c, d;
} u8;
struct __attribute__ ((packed)) {
uint8_t a;
uint16_t bc;
uint8_t d;
} mixed;
struct __attribute__ ((packed)) {
uint16_t ab, cd;
} u16;
uint32_t u32;
};
union32_t address;
if( address.u8.c && 0x04 )
...
avr-gcc does the expected without "__attribute__ ((packed))" but if
you get to playing in Linux or FreeBSD its needed to do the same as
what avr-gcc does.
Also note the above is sensitive to machine endianess. Macintosh,
Sun, and Irix are big-endian.
--
David Kelly N4HHE, [EMAIL PROTECTED]
========================================================================
Whom computers would destroy, they must first drive mad.
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list