[En-Nut-Discussion] Hardware Register Access Using Volatile Pointer

Bernd Walter enut at cicely.de
Tue Apr 26 21:55:41 CEST 2011


On Tue, Apr 26, 2011 at 07:25:54PM +0200, Harald Kipp wrote:
> On 4/26/2011 6:45 PM, Bernd Walter wrote:
> > On Tue, Apr 26, 2011 at 02:55:28PM +0200, Harald Kipp wrote:
> 
> >> Definitely there are no pros for using the "Atmel style", except
> >> personal preference:
> >
> > It personally think typesafe controller pointers are pro.
> 
> That's a problem with macros. inr() can and should be defined as an 
> inline function. Again, see the flexibility.

It's not typesafe for controller pointer.
e.g. imagine a function like this:
uint8_t rxbyte(struct _AT91S_USART* usart)
{
	usart->registerX
}

The function don't need to care about which usart it handles and
the cmpiler can warn about passing a SSC pointer.

> >> This is even tricky within Nut/OS. Following the good old style of
> >> avr-libc, we try to use port and bit names from the datasheet. This
> >> helps to remember the names. The bad thing is that Atmel datasheets are
> >> not written with C programming in mind.
> >
> > Yes - that's definitive a pro for the other way.
> 
> No. The other style only works, because it ignores assembly language. 

Ok - that's true.
I'm not using assembly quite often, so I missed that point.

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.



More information about the En-Nut-Discussion mailing list