[En-Nut-Discussion] Interfacing a memory mapped (Oxford Quad UART) device to an EtherNut

Ralph Mason ralph.mason at telogis.com
Wed Sep 17 20:57:47 CEST 2003


To save yourself some work and codespace I suggest you use the 'virtualised'
AVR uart if possible from nut os.

I wrote a 16550 driver in a few hours that way.

Here is my declaration, you can see how much of the avr driver I used

static UARTDCB dcb_uarta;

NUTDEVICE devUartA = {
    0,                          /*!< Pointer to next device. */
    {'u', 'a', 'r', 't', 'a', 0, 0, 0, 0},      /*!< Unique device name. */
    IFTYP_STREAM,               /*!< Type of device. */
    (u_char*)0xf900,            /*!< Base address. */
    4,                          /*!< First interrupt number. */
    0,                			 /*!< Interface control block. */
    &dcb_uarta,                 /*!< Driver control block. */
    UartExtInit,                /*!< Driver initialization routine. */
    UartExtIOCtl,               /*!< Driver specific control function. */
    UartAvrRead,
    UartAvrWrite,
    UartAvrWrite_P,
    UartAvrOpen,
    UartAvrClose
};

THere are only 2 of my own functions there.

In the init I setup the stream (so that the memory for it can be allocated
from the heap) and put my own stream handler functions in.


int UartExtInit(NUTDEVICE *dev)
{
    IFSTREAM *ifs;

    //Already done
    if ( dev->dev_icb )
    	return 0;

    ifs = NutHeapAllocClear(sizeof(IFSTREAM));
    dev->dev_icb = ifs;

    ifs->if_input = UartAvrInput;
    ifs->if_output = UartExtOutput;
    ifs->if_flush = UartAvrFlush;

    /*
     * Initialize driver control block.
     */
    memset(dev->dev_dcb, 0, sizeof(UARTDCB));

    Init16550((volatile u_char*)dev->dev_base,38400);

So you can see, I only provided 3 functions to the
driver(UartExtOutput,UartExtInit,UartExtInit) and my own interupt handler.

Hope this is of some help


Regards
Ralph






> -----Original Message-----
> From: en-nut-discussion-admin at egnite.de
> [mailto:en-nut-discussion-admin at egnite.de]On Behalf Of Pearless
> Sent: Wednesday, 17 September 2003 10:37
> To: en-nut-discussion at egnite.de
> Subject: RE: [En-Nut-Discussion] Interfacing a memory mapped (Oxford
> Quad UART) device to an EtherNut
>
>
> Hi Harald,
>
> Thanks for the feedback.
>
> I am creating a new file, rather than modifing uartavr.c.
>
> cheers Douglas
>
> -----Original Message-----
> From: en-nut-discussion-admin at egnite.de
> [mailto:en-nut-discussion-admin at egnite.de]On Behalf Of Harald Kipp
> Sent: Wednesday, 17 September 2003 10:18 p.m.
> To: en-nut-discussion at egnite.de
> Subject: RE: [En-Nut-Discussion] Interfacing a memory mapped (Oxford
> Quad UART) device to an EtherNut
>
>
> Douglas,
>
> I'd suggest to write a simple program first (no Nut/OS!)
> and use outb and inb statements to access the hardware.
>
> 1. Initialize QUART registers
> 2. Try to output one character
> 3. Test interrupts
>
> After this is working fine, you should be ready to modify
> uartavr.c. Btw. I recommend to use a different file. Do not
> intend to make uartavr.c working with both devices, on-chip
> UART and external QUAD.
>
>
> Harald
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.518 / Virus Database: 316 - Release Date: 11/09/2003
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.518 / Virus Database: 316 - Release Date: 11/09/2003
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.515 / Virus Database: 313 - Release Date: 1/09/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 1/09/2003




More information about the En-Nut-Discussion mailing list