This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Ever learning, setting individual bits
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Chuck McManis <ecos at mcmanis dot com>
- Cc: ECOS Discussion Group <ecos-discuss at sources dot redhat dot com>
- Date: Sun, 19 Feb 2006 17:11:53 +0100
- Subject: Re: [ECOS] Ever learning, setting individual bits
- References: <6.1.2.0.2.20060218162645.04e06550@66.125.189.29>
> ------------BIT set/clear macros for I/O registers
> /*
> * A bit of syntactic sugar around setting and resetting bits in
> * 8 and 16 bit IO registers. A number of registers have reserved
> * bits that are marked "do not program" which means don't ever
> * change them if you expect your driver to work. So these macros
> * automate the process of reading the old value, oring in or anding
> * out the bits that are set in the pattern 'bits' and then writing
> * the result back to the register.
> */
> #define IO_BIT_SET_8(base, offset, bits) \
> CYG_MACRO_START \
> cyg_uint8 datum; \
> HAL_PCI_IO_READ_UINT8((base) + (offset), datum); \
> datum |= (cyg_uint8)(bits); \
> HAL_PCI_IO_wRITE_UINT8((base) + (offset), datum); \
> CYG_MACRO_END
I suggest you keep to the HAL_PCI_IO_ naming convention. eg:
#define HAL_IO_BIT_SET_UINT8(_register_, _bits_) \
CYG_MACRO_START \
cyg_uint8 _datum_; \
HAL_PCI_IO_READ_UINT8((_register_), _datum_); \
_datum_ |= (cyg_uint8)(_bits_); \
HAL_PCI_IO_wRITE_UINT8((_register_) _datum_); \
CYG_MACRO_END
If you write macros for all three types, UINT8, UINT16 and UINT32 i
should be able to find some suitable header file to place them in.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss