[En-Nut-Discussion] Uart SPI initialization
Robert Mutke
robert.mutke at gmail.com
Wed Feb 9 19:01:24 CET 2005
Hi,
While going through SPI initializtion I found a strange thing:
In dev/uarts.c:73:
NUTDEVICE devUarts[] = {
{
0, /*!< Pointer to next device. */
{'u', 'a', 'r', 't', 's', '0', 0, 0, 0}, /*!< Unique device name. */
IFTYP_STREAM, /*!< Type of device. */
1, /*!< Base address. */
0, /*!< First interrupt number. */
0, /*!< Interface control block. */
&dcb_uart1, /*!< Driver control block. */
UartSpiInit, /*!< Driver initialization routine. */
UartSpiIOCtl /*!< Driver specific control function. */
},
...
I register a device in this way:
NUTDEVICE* devSpi = &devUarts[0];
if (NutRegisterDevice(devSpi, 0, 0))
{
puts( "NutRegisterDevice(): failed" );
for(;;);
}
So NutRegisterDevice() takes dev_base from devUarts[0], which is 1.
After that it calls initialization routine, which is UartSpiInit in
this case. This one checks dev_base if it is zero. If it is not, it
returns -1, which prohibits registering the device.
What should I do? Change the dev_base in devUarts to 0 or remove
checking in UartSpiInit? What do you think?
Cheers,
Robert
More information about the En-Nut-Discussion
mailing list