AW: [En-Nut-Discussion] Ethernut, UART HW Flowcontrol andmaybe Bluetooth

Harald Kipp harald.kipp at egnite.de
Wed Dec 10 10:08:53 CET 2003


>
> >
> > Btw. Any idea anyone, how to add UART1 without copying code
> > or spoil the code with ifdefs? Nah...no code in include
> > files. I fear that this may confuse other tools like debuggers.
>
>What about storing all needed registers in a two-dimensional array. One
>dimension for the different registers and the other one for uart0 and uart1.
>
>In the device or dcb structure the index for the second dimension must be
>stored and all accesses to the uart registers must be "translated" by this
>array. Thus you can use the complete code from usart0avr.c for both usarts.

That's very esthetic code for men, but machines won't
like it. :-)

The reason why I want to scrap the base address in
NutRegisterDevice() is, that port I/O and port bit
manipulations are compiled to native CPU commands
only, if the port address is a constant.

outb(UDR0, 'A') compiles to two machine instructions.
outb(base, 'A') will not contain any out instruction,
and cbi(base, 1) is worse.

Harald




More information about the En-Nut-Discussion mailing list