This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]