This is the mail archive of the ecos-discuss@sources.redhat.com 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]

Re: assabet_BCR



"Trenton D. Adams" <tadams@extremeeng.com> writes:
> What's the purpose of this function?  Other than the fact that it
> manipulates the board control register.

It's only a function because that register is write only, and you can only
write the whole thing, so the function privately keeps the last value you
wrote in order that you can modify a subset of the bits without affecting
the ones you want left untouched.  No other magic than that.  If it were a
read/write register the client code could go
	*ASSABET_BCR |= BITS_TO_SET;
and/or
	*ASSABET_BCR &=~BITS_TO_CLEAR;
or
	*ASSABET_BCR = ((*ASSABET_BCR) & ~SOME_BIT_RANGE) | BITS_TO_SET;
instead of using a function.

> I assume it's some sort of generic register for various tasks?  Is there

It controls the vibrating alert (yes, the assabet really has one), the
LCD on/off mode and backlight, as far as I can see from a quick grep.

All the function does is
	// Board control register support
	// Update the board control register (write only).  Only the bits
	// specified by 'mask' are changed to 'value'.
	void assabet_BCR(unsigned long mask, unsigned long value)
	{
	    _assabet_BCR = (_assabet_BCR & ~mask) | (mask & value);
	    *SA1110_BOARD_CONTROL = _assabet_BCR;
	}
so nothing special. (_assabet_BCR is a static variable)

You only need to write functions to control registers if the hardware
demands tricks like this.  Otherwise it's a matter of style and flamewar
whether you write macros to set and get reg value, or just use *FOO =
BAR.... (with enough "volatiles" and the like in the definition of FOO).

HTH,

	- Huge


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