[ECOS] Does eCos provide bit manipulate macros?

Wang Cui iucgnaw@msn.com
Wed Sep 27 02:37:00 GMT 2006


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



More information about the Ecos-discuss mailing list