[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] 32-bits time
From: |
David Kelly |
Subject: |
Re: [avr-gcc-list] 32-bits time |
Date: |
Thu, 13 Oct 2005 20:12:09 -0500 |
On Thu, Oct 13, 2005 at 09:10:17AM +0200, Bjarne Laursen wrote:
A few additions to David Kelly's code:
inline uint32_t timer32_now(void)
{
int8_t sreg;
union {
struct {
uint16_t lo, hi;
} w;
uint32_t l;
uint8_t b[4]; // <------ added: access as bytes
} temp;
Below is the way I usually do the above. Didn't have it under my mouse
last night:
typedef union {
uint32_t u32;
int32_t i32;
struct {
uint16_t lo, hi;
} u16;
struct {
uint8_t lo;
uint16_t mid;
uint8_t hi;
} hml;
struct {
uint8_t lo, b, c, hi;
} u8;
struct {
int8_t lo, b, c, hi;
} i8;
} union32_t;
Easy enough to hack into whatever shape desired. The idea is to use
named members of a union rather than type casting and shifting.
--
David Kelly N4HHE, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.
- [avr-gcc-list] 32-bits time, Eric Pasquier, 2005/10/12
- RE: [avr-gcc-list] 32-bits time, Gavin Jackson, 2005/10/12
- RE: [avr-gcc-list] 32-bits time, Eric Pasquier, 2005/10/12
- Re: [avr-gcc-list] 32-bits time, Galen Seitz, 2005/10/12
- Re: [avr-gcc-list] 32-bits time, Eric Pasquier, 2005/10/13
- [avr-gcc-list] After ATMega, Eric Pasquier, 2005/10/13
- Re: [avr-gcc-list] After ATMega, Galen Seitz, 2005/10/13
- Re: [avr-gcc-list] After ATMega, Patrick Blanchard, 2005/10/13
- RE: [avr-gcc-list] After ATMega, Trampas, 2005/10/13
- RE: [avr-gcc-list] After ATMega, Patrick Blanchard, 2005/10/13
Re: [avr-gcc-list] 32-bits time, Dmitry K., 2005/10/13