This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Does eCos provide bit manipulate macros?
- From: "Wang Cui" <iucgnaw at msn dot com>
- To: <ecos-discuss at sourceware dot org>
- Date: Wed, 27 Sep 2006 10:37:45 +0800
- Subject: [ECOS] Does eCos provide bit manipulate macros?
When we write hardware drivers, we always need access registers and
manipulate bit part of them.
So, does eCos provide bit manipulate macros? If not, should it provide a
common macro set(like in the Infra package) for convenience?
As I look through the drivers of eCos, I don't find such macros. So, I'm
using my own version of these macros. Such as:
#define SET_BITS(dest, mask) \
{ \
(dest) |= (mask); \
} \
#define CLEAR_BITS(dest, mask) \
{ \
(dest) &= ~(mask); \
} \
#define WRITE_BITS(dest, mask, value) \
{ \
(dest) &= ~(mask); \
(dest) |= (value) & (mask); \
} \
#define READ_BITS(src, mask) \
( \
(src) & (mask) \
) \
#define TEST_BITS(src, mask, value) \
( \
((src) & (mask)) == (value) ? TRUE : FALSE \
) \
#define TOGGLE_BITS(dest, mask) \
{ \
(dest) = ((dest) & ~(mask)) | ((~dest) & (mask)); \
} \
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss