Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.4.pdf
Скачиваний:
31
Добавлен:
23.08.2013
Размер:
2.79 Mб
Скачать

ARM-specific Functions

10.15.5 uart_init()

This function initializes the UART subsystem.

Syntax

int uart_init(int unit)

where:

unit

is the number of the UART to be initialized (ignored).

Return value

Always returns zero.

Usage

This function establishes an interrupt handler by calling irqInit(), then initializes all the UARTs using calls to uart_setup().

10.15.6 uart_irq()

This function handles UART interrupts.

Syntax

void uart_irq(unsigned status)

where:

status is the contents of the interrupt status register.

Usage

This function uses the value of the status argument, passed from the irqDispatch() function, to determine which of the UARTs has caused the interrupt. It then calls uart_do_irq() with a pointer to the appropriate UART structure.

10-26

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B

ARM-specific Functions

10.15.7 uart_putc()

This function queues a character for transmission.

Syntax

void uart_putc(int unit, int ch)

where:

 

unit

is the UART unit number.

ch

is the character to be sent.

Usage

This function busy waits (without calling YIELD()) for space to become available in the transmit ring buffer. When space is available, if the transmitter is already enabled, the character is added to the ring buffer. If the transmit interrupt is not currently enabled, the character is written directly to the UART and transmit interrupts are enabled. A transmit interrupt will occur when the character has been sent.

10.15.8 uart_ready()

This function returns the amount of transmit space available for a UART.

Syntax

int uart_ready(int unit)

where:

unit

is the UART unit number.

Return value

Returns the number of characters that could be added to the transmit ring buffer of the UART.

Usage

This function is called to determine when it is possible to send more characters to the UART ring buffer without blocking.

ARM DUI 0079B

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

10-27

ARM-specific Functions

10.15.9 uart_reset()

This function resets a UART.

Syntax

void uart_reset(int unit)

where:

unit

is the UART unit number.

Usage

When uart_reset() is called, the indicated UART is reset by first setting the DTR signal to the inactive state and then removing all the data from the receive and transmit ring buffers. The DTR signal is held inactive for one second and then reset and held active for one second. This should cause any modem device attached to the UART to hang up the phone line and return to the command mode.

10-28

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B

ARM-specific Functions

10.15.10 uart_setup()

This function initializes a UART.

Syntax

static void uart_setup(struct uart *pUart, unsigned unit, struct uartregs *pRegs,

unsigned int Baud)

where:

pUart is the pointer to the UART structure to initialized.

unit

is the UART unit number.

pRegs is the pointer to UART registers.

Baud

is the baud rate divisor value.

Return value

None.

Usage

This function initializes the various fields of the UART structure, creates a pair of ring buffers (of size 1600 bytes), and initializes the UART hardware registers.

ARM DUI 0079B

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

10-29