Nut/OS  5.0.5
API Reference
USART

Universal synchronous / asynchronous receiver / transmitter registers. More...

Collaboration diagram for USART:

Defines

#define ASCII_XON   0x11
#define ASCII_XOFF   0x13
#define XON_PENDING   0x10
#define XOFF_PENDING   0x20
#define XOFF_SENT   0x40
#define XOFF_RCVD   0x80
#define US_OVRE   0x00000020
 Overrun error.
#define ASCII_XON   0x11
#define ASCII_XOFF   0x13
#define XON_PENDING   0x10
#define XOFF_PENDING   0x20
#define XOFF_SENT   0x40
#define XOFF_RCVD   0x80

Functions

int Sc16is752RegWrite (uint8_t dev, uint8_t ch, uint8_t reg, uint8_t val)
int Sc16is752RegRead (uint8_t dev, uint8_t ch, uint8_t reg, uint8_t *val)
int selectRegisterSet (uint8_t dev, uint8_t ch, uint8_t reg)
void Sc16is752UsartProcessChannelInterrupt (uint8_t dev, uint8_t ch, uint8_t iir)
void Sc16is752UsartInterruptProcessing (void *arg)
void Sc16is752UsartEnable (uint8_t dev, uint8_t ch)
 Carefully enable USART hardware functions.
void Sc16is752UsartDisable (uint8_t dev, uint8_t ch)
 Carefully disable USART hardware functions.
uint32_t Sc16is752UsartGetSpeed (uint8_t dev, uint8_t ch)
 Query the USART hardware for the selected speed.
int Sc16is752UsartSetSpeed (uint32_t rate, uint8_t dev, uint8_t ch)
 Set the USART hardware bit rate.
uint8_t Sc16is752UsartGetDataBits (uint8_t dev, uint8_t ch)
 Query the USART hardware for the number of data bits.
int Sc16is752UsartSetDataBits (uint8_t bits, uint8_t dev, uint8_t ch)
 Set the USART hardware to the number of data bits.
uint8_t Sc16is752UsartGetParity (uint8_t dev, uint8_t ch)
 Query the USART hardware for the parity mode.
int Sc16is752UsartSetParity (uint8_t mode, uint8_t dev, uint8_t ch)
 Set the USART hardware to the specified parity mode.
uint8_t Sc16is752UsartGetStopBits (uint8_t dev, uint8_t ch)
 Query the USART hardware for the number of stop bits.
int Sc16is752UsartSetStopBits (uint8_t bits, uint8_t dev, uint8_t ch)
 Set the USART hardware to the number of stop bits.
uint32_t Sc16is752UsartGetStatus (uint8_t dev, uint8_t ch)
 Query the USART hardware status.
int Sc16is752UsartSetStatus (uint32_t flags, uint8_t dev, uint8_t ch)
 Set the USART hardware status.
uint8_t Sc16is752UsartGetClockMode (uint8_t dev, uint8_t ch)
 Query the USART hardware for synchronous mode.
int Sc16is752UsartSetClockMode (uint8_t mode, uint8_t dev, uint8_t ch)
 Set asynchronous or synchronous mode.
uint32_t Sc16is752UsartGetFlowControl (uint8_t dev, uint8_t ch)
 Query flow control mode.
int Sc16is752UsartSetFlowControl (uint32_t flags, uint8_t dev, uint8_t ch)
 Set flow control mode.
void Sc16is752UsartTxStart (uint8_t dev, uint8_t ch)
 Start the USART transmitter hardware.
void Sc16is752UsartRxStart (uint8_t dev, uint8_t ch)
 Start the USART receiver hardware.
int Sc16is752UsartInit (uint8_t dev, uint8_t ch, NUTDEVICE *nutDev, IRQ_HANDLER *irq)
 Initialize the USART hardware driver.
int Sc16is752UsartDeinit (uint8_t dev, uint8_t ch, IRQ_HANDLER *irq)
 Deinitialize the USART hardware driver.

USART Control Register

#define US_CR_OFF   0x00000000
 USART control register offset.
#define US0_CR   (USART0_BASE + US_CR_OFF)
 Channel 0 control register address.
#define US1_CR   (USART1_BASE + US_CR_OFF)
 Channel 1 control register address.
#define US_RSTRX   0x00000004
 Reset receiver.
#define US_RSTTX   0x00000008
 Reset transmitter.
#define US_RXEN   0x00000010
 Receiver enable.
#define US_RXDIS   0x00000020
 Receiver disable.
#define US_TXEN   0x00000040
 Transmitter enable.
#define US_TXDIS   0x00000080
 Transmitter disable.
#define US_RSTSTA   0x00000100
 Reset status bits.
#define US_STTBRK   0x00000200
 Start break.
#define US_STPBRK   0x00000400
 Stop break.
#define US_STTTO   0x00000800
 Start timeout.
#define US_SENDA   0x00001000
 Send next byte with address bit set.

Mode Register

#define US_MR_OFF   0x00000004
 USART mode register offset.
#define US0_MR   (USART0_BASE + US_MR_OFF)
 Channel 0 mode register address.
#define US1_MR   (USART1_BASE + US_MR_OFF)
 Channel 1 mode register address.
#define US_CLKS   0x00000030
 Clock selection mask.
#define US_CLKS_MCK   0x00000000
 Master clock.
#define US_CLKS_MCK8   0x00000010
 Master clock divided by 8.
#define US_CLKS_SCK   0x00000020
 External clock.
#define US_CLKS_SLCK   0x00000030
 Slow clock.
#define US_CHRL   0x000000C0
 Masks data length.
#define US_CHRL_5   0x00000000
 5 data bits.
#define US_CHRL_6   0x00000040
 6 data bits.
#define US_CHRL_7   0x00000080
 7 data bits.
#define US_CHRL_8   0x000000C0
 8 data bits.
#define US_SYNC   0x00000100
 Synchronous mode enable.
#define US_PAR   0x00000E00
 Parity mode mask.
#define US_PAR_EVEN   0x00000000
 Even parity.
#define US_PAR_ODD   0x00000200
 Odd parity.
#define US_PAR_SPACE   0x00000400
 Space parity.
#define US_PAR_MARK   0x00000600
 Marked parity.
#define US_PAR_NO   0x00000800
 No parity.
#define US_PAR_MULTIDROP   0x00000C00
 Multi-drop mode.
#define US_NBSTOP   0x00003000
 Masks stop bit length.
#define US_NBSTOP_1   0x00000000
 1 stop bit.
#define US_NBSTOP_1_5   0x00001000
 1.5 stop bits.
#define US_NBSTOP_2   0x00002000
 2 stop bits.
#define US_CHMODE   0x0000C000
 Channel mode mask.
#define US_CHMODE_NORMAL   0x00000000
 Normal mode.
#define US_CHMODE_AUTOMATIC_ECHO   0x00004000
 Automatic echo.
#define US_CHMODE_LOCAL_LOOPBACK   0x00008000
 Local loopback.
#define US_CHMODE_REMOTE_LOOPBACK   0x0000C000
 Remote loopback.
#define US_MODE9   0x00020000
 9 bit mode.
#define US_CLKO   0x00040000
 Baud rate output enable.

Status and Interrupt Register

#define US_CSR_OFF   0x00000014
 USART status register offset.
#define US0_CSR   (USART0_BASE + US_CSR_OFF)
 Channel 0 status register address.
#define US1_CSR   (USART1_BASE + US_CSR_OFF)
 Channel 1 status register address.
#define US_IER_OFF   0x00000008
 USART interrupt enable register offset.
#define US0_IER   (USART0_BASE + US_IER_OFF)
 Channel 0 interrupt enable register address.
#define US1_IER   (USART1_BASE + US_IER_OFF)
 Channel 1 interrupt enable register address.
#define US_IDR_OFF   0x0000000C
 USART interrupt disable register offset.
#define US0_IDR   (USART0_BASE + US_IDR_OFF)
 Channel 0 interrupt disable register address.
#define US1_IDR   (USART1_BASE + US_IDR_OFF)
 Channel 1 interrupt disable register address.
#define US_IMR_OFF   0x00000010
 USART interrupt mask register offset.
#define US0_IMR   (USART0_BASE + US_IMR_OFF)
 Channel 0 interrupt mask register address.
#define US1_IMR   (USART1_BASE + US_IMR_OFF)
 Channel 1 interrupt mask register address.
#define US_RXRDY   0x00000001
 Receiver ready.
#define US_TXRDY   0x00000002
 Transmitter ready.
#define US_RXBRK   0x00000004
 Receiver break.
#define US_ENDRX   0x00000008
 End of receiver PDC transfer.
#define US_ENDTX   0x00000010
 End of transmitter PDC transfer.
#define US_OVRE   0x00000020
 Overrun error.
#define US_FRAME   0x00000040
 Framing error.
#define US_PARE   0x00000080
 Parity error.
#define US_TIMEOUT   0x00000100
 Receiver timeout.
#define US_TXEMPTY   0x00000200
 Transmitter empty.
#define US_RXBUFF   0x00001000
 Receive buffer full.
#define AT91_US_BAUD(baud)   ((NUT_CPU_FREQ / (8 * (baud)) + 1) / 2)
 Baud rate calculation helper macro.

Receiver Holding Register

#define US_RHR_OFF   0x00000018
 USART receiver holding register offset.
#define US0_RHR   (USART0_BASE + US_RHR_OFF)
 Channel 0 receiver holding register address.
#define US1_RHR   (USART1_BASE + US_RHR_OFF)
 Channel 1 receiver holding register address.

Transmitter Holding Register

#define US_THR_OFF   0x0000001C
 USART transmitter holding register offset.
#define US0_THR   (USART0_BASE + US_THR_OFF)
 Channel 0 transmitter holding register address.
#define US1_THR   (USART1_BASE + US_THR_OFF)
 Channel 1 transmitter holding register address.

Baud Rate Generator Register

#define US_BRGR_OFF   0x00000020
 USART baud rate register offset.
#define US0_BRGR   (USART0_BASE + US_BRGR_OFF)
 Channel 0 baud rate register address.
#define US1_BRGR   (USART1_BASE + US_BRGR_OFF)
 Channel 1 baud rate register address.

Receiver Timeout Register

#define US_RTOR_OFF   0x00000024
 USART receiver timeout register offset.
#define US0_RTOR   (USART0_BASE + US_RTOR_OFF)
 Channel 0 receiver timeout register address.
#define US1_RTOR   (USART1_BASE + US_RTOR_OFF)
 Channel 1 receiver timeout register address.

Transmitter Time Guard Register

#define US_TTGR_OFF   0x00000028
 USART transmitter time guard register offset.
#define US0_TTGR   (USART0_BASE + US_TTGR_OFF)
 Channel 0 transmitter time guard register address.
#define US1_TTGR   (USART1_BASE + US_TTGR_OFF)
 Channel 1 transmitter time guard register address.

FI DI Ratio Register

#define US_FIDI_OFF   0x00000040
 USART FI DI ratio register offset.
#define US0_FIDI   (USART0_BASE + US_FIDI_OFF)
 Channel 0 FI DI ratio register address.
#define US1_FIDI   (USART1_BASE + US_FIDI_OFF)
 Channel 1 FI DI ratio register address.

Error Counter Register

#define US_NER_OFF   0x00000044
 USART error counter register offset.
#define US0_NER   (USART0_BASE + US_NER_OFF)
 Channel 0 error counter register address.
#define US1_NER   (USART1_BASE + US_NER_OFF)
 Channel 1 error counter register address.

IrDA Filter Register

#define US_IF_OFF   0x0000004C
 USART IrDA filter register offset.
#define US0_IF   (USART0_BASE + US_IF_OFF)
 Channel 0 IrDA filter register address.
#define US1_IF   (USART1_BASE + US_IF_OFF)
 Channel 1 IrDA filter register address.

AT91 USART0 Device

NUTDEVICE devUsartAt910
 USART0 device information structure.

AT91 USART1 Device

NUTDEVICE devUsartAt911
 USART1 device information structure.

AT91 DBGU Device

NUTDEVICE devDbguAt91
 USART0 device information structure.

AT91 DBGU Device

NUTDEVICE devDebug
 USART0 device information structure.

SC16IS752 USARTa Device

NUTDEVICE devUsartsc16is752a
 USART0 device information structure.

SC16IS752 USARTa Device

NUTDEVICE devUsartsc16is752b
 USART0 device information structure.

SC16IS752 USARTc Device

NUTDEVICE devUsartsc16is752c
 USART2 device information structure.

SC16IS752 USARTd Device

NUTDEVICE devUsartsc16is752d
 USART3 device information structure.

Detailed Description

Universal synchronous / asynchronous receiver / transmitter registers.


Define Documentation

#define US_CR_OFF   0x00000000

USART control register offset.

#define US0_CR   (USART0_BASE + US_CR_OFF)

Channel 0 control register address.

#define US1_CR   (USART1_BASE + US_CR_OFF)

Channel 1 control register address.

Referenced by AhdlcAt91Init(), and AhdlcAt91Open().

#define US_RSTRX   0x00000004

Reset receiver.

Referenced by AhdlcAt91Init().

#define US_RSTTX   0x00000008

Reset transmitter.

Referenced by AhdlcAt91Init().

#define US_RXEN   0x00000010

Receiver enable.

Referenced by AhdlcAt91Open().

#define US_RXDIS   0x00000020

Receiver disable.

Referenced by AhdlcAt91Init().

#define US_TXEN   0x00000040

Transmitter enable.

Referenced by AhdlcAt91Open().

#define US_TXDIS   0x00000080

Transmitter disable.

Referenced by AhdlcAt91Init().

#define US_RSTSTA   0x00000100

Reset status bits.

#define US_STTBRK   0x00000200

Start break.

#define US_STPBRK   0x00000400

Stop break.

#define US_STTTO   0x00000800

Start timeout.

Referenced by AhdlcAt91Open().

#define US_SENDA   0x00001000

Send next byte with address bit set.

#define US_MR_OFF   0x00000004

USART mode register offset.

Referenced by AhdlcAt91IOCtl().

#define US0_MR   (USART0_BASE + US_MR_OFF)

Channel 0 mode register address.

#define US1_MR   (USART1_BASE + US_MR_OFF)

Channel 1 mode register address.

Referenced by AhdlcAt91Init().

#define US_CLKS   0x00000030

Clock selection mask.

Referenced by AhdlcAt91IOCtl().

#define US_CLKS_MCK   0x00000000

Master clock.

Referenced by AhdlcAt91IOCtl().

#define US_CLKS_MCK8   0x00000010

Master clock divided by 8.

Referenced by AhdlcAt91IOCtl().

#define US_CLKS_SCK   0x00000020

External clock.

#define US_CLKS_SLCK   0x00000030

Slow clock.

#define US_CHRL   0x000000C0

Masks data length.

#define US_CHRL_5   0x00000000

5 data bits.

#define US_CHRL_6   0x00000040

6 data bits.

#define US_CHRL_7   0x00000080

7 data bits.

#define US_CHRL_8   0x000000C0

8 data bits.

Referenced by AhdlcAt91Init().

#define US_SYNC   0x00000100

Synchronous mode enable.

#define US_PAR   0x00000E00

Parity mode mask.

#define US_PAR_EVEN   0x00000000

Even parity.

#define US_PAR_ODD   0x00000200

Odd parity.

#define US_PAR_SPACE   0x00000400

Space parity.

#define US_PAR_MARK   0x00000600

Marked parity.

#define US_PAR_NO   0x00000800

No parity.

Referenced by AhdlcAt91Init().

#define US_PAR_MULTIDROP   0x00000C00

Multi-drop mode.

#define US_NBSTOP   0x00003000

Masks stop bit length.

#define US_NBSTOP_1   0x00000000

1 stop bit.

Referenced by AhdlcAt91Init().

#define US_NBSTOP_1_5   0x00001000

1.5 stop bits.

#define US_NBSTOP_2   0x00002000

2 stop bits.

#define US_CHMODE   0x0000C000

Channel mode mask.

#define US_CHMODE_NORMAL   0x00000000

Normal mode.

Referenced by AhdlcAt91Init().

#define US_CHMODE_AUTOMATIC_ECHO   0x00004000

Automatic echo.

#define US_CHMODE_LOCAL_LOOPBACK   0x00008000

Local loopback.

#define US_CHMODE_REMOTE_LOOPBACK   0x0000C000

Remote loopback.

#define US_MODE9   0x00020000

9 bit mode.

#define US_CLKO   0x00040000

Baud rate output enable.

#define US_CSR_OFF   0x00000014

USART status register offset.

#define US0_CSR   (USART0_BASE + US_CSR_OFF)

Channel 0 status register address.

#define US1_CSR   (USART1_BASE + US_CSR_OFF)

Channel 1 status register address.

#define US_IER_OFF   0x00000008

USART interrupt enable register offset.

#define US0_IER   (USART0_BASE + US_IER_OFF)

Channel 0 interrupt enable register address.

#define US1_IER   (USART1_BASE + US_IER_OFF)

Channel 1 interrupt enable register address.

Referenced by AhdlcAt91Open(), and AhdlcAt91Put().

#define US_IDR_OFF   0x0000000C

USART interrupt disable register offset.

#define US0_IDR   (USART0_BASE + US_IDR_OFF)

Channel 0 interrupt disable register address.

#define US1_IDR   (USART1_BASE + US_IDR_OFF)

Channel 1 interrupt disable register address.

Referenced by AhdlcAt91Init().

#define US_IMR_OFF   0x00000010

USART interrupt mask register offset.

#define US0_IMR   (USART0_BASE + US_IMR_OFF)

Channel 0 interrupt mask register address.

#define US1_IMR   (USART1_BASE + US_IMR_OFF)

Channel 1 interrupt mask register address.

#define US_RXRDY   0x00000001

Receiver ready.

#define US_TXRDY   0x00000002

Transmitter ready.

Referenced by AhdlcAt91Put().

#define US_RXBRK   0x00000004

Receiver break.

#define US_ENDRX   0x00000008

End of receiver PDC transfer.

Referenced by AhdlcAt91Open().

#define US_ENDTX   0x00000010

End of transmitter PDC transfer.

#define US_OVRE   0x00000020

Overrun error.

#define US_FRAME   0x00000040

Framing error.

#define US_PARE   0x00000080

Parity error.

#define US_TIMEOUT   0x00000100

Receiver timeout.

Referenced by AhdlcAt91Open().

#define US_TXEMPTY   0x00000200

Transmitter empty.

#define US_RXBUFF   0x00001000

Receive buffer full.

Referenced by AhdlcAt91Open().

#define AT91_US_BAUD (   baud)    ((NUT_CPU_FREQ / (8 * (baud)) + 1) / 2)

Baud rate calculation helper macro.

Deprecated:
Use NutGetCpuClock() and calculate the divider value locally.
#define US_RHR_OFF   0x00000018

USART receiver holding register offset.

#define US0_RHR   (USART0_BASE + US_RHR_OFF)

Channel 0 receiver holding register address.

#define US1_RHR   (USART1_BASE + US_RHR_OFF)

Channel 1 receiver holding register address.

#define US_THR_OFF   0x0000001C

USART transmitter holding register offset.

#define US0_THR   (USART0_BASE + US_THR_OFF)

Channel 0 transmitter holding register address.

#define US1_THR   (USART1_BASE + US_THR_OFF)

Channel 1 transmitter holding register address.

#define US_BRGR_OFF   0x00000020

USART baud rate register offset.

Referenced by AhdlcAt91IOCtl(), and At91DevDebugIOCtl().

#define US0_BRGR   (USART0_BASE + US_BRGR_OFF)

Channel 0 baud rate register address.

#define US1_BRGR   (USART1_BASE + US_BRGR_OFF)

Channel 1 baud rate register address.

Referenced by AhdlcAt91Init().

#define US_RTOR_OFF   0x00000024

USART receiver timeout register offset.

#define US0_RTOR   (USART0_BASE + US_RTOR_OFF)

Channel 0 receiver timeout register address.

#define US1_RTOR   (USART1_BASE + US_RTOR_OFF)

Channel 1 receiver timeout register address.

Referenced by AhdlcAt91Open().

#define US_TTGR_OFF   0x00000028

USART transmitter time guard register offset.

#define US0_TTGR   (USART0_BASE + US_TTGR_OFF)

Channel 0 transmitter time guard register address.

#define US1_TTGR   (USART1_BASE + US_TTGR_OFF)

Channel 1 transmitter time guard register address.

#define US_FIDI_OFF   0x00000040

USART FI DI ratio register offset.

#define US0_FIDI   (USART0_BASE + US_FIDI_OFF)

Channel 0 FI DI ratio register address.

#define US1_FIDI   (USART1_BASE + US_FIDI_OFF)

Channel 1 FI DI ratio register address.

#define US_NER_OFF   0x00000044

USART error counter register offset.

#define US0_NER   (USART0_BASE + US_NER_OFF)

Channel 0 error counter register address.

#define US1_NER   (USART1_BASE + US_NER_OFF)

Channel 1 error counter register address.

#define US_IF_OFF   0x0000004C

USART IrDA filter register offset.

#define US0_IF   (USART0_BASE + US_IF_OFF)

Channel 0 IrDA filter register address.

#define US1_IF   (USART1_BASE + US_IF_OFF)

Channel 1 IrDA filter register address.

#define ASCII_XON   0x11
#define ASCII_XOFF   0x13
#define XON_PENDING   0x10
#define XOFF_PENDING   0x20
#define XOFF_SENT   0x40
#define XOFF_RCVD   0x80
#define US_OVRE   0x00000020

Overrun error.

#define ASCII_XON   0x11
#define ASCII_XOFF   0x13
#define XON_PENDING   0x10
#define XOFF_PENDING   0x20
#define XOFF_SENT   0x40
#define XOFF_RCVD   0x80

Function Documentation

int Sc16is752RegWrite ( uint8_t  dev,
uint8_t  ch,
uint8_t  reg,
uint8_t  val 
)
int Sc16is752RegRead ( uint8_t  dev,
uint8_t  ch,
uint8_t  reg,
uint8_t val 
)
int selectRegisterSet ( uint8_t  dev,
uint8_t  ch,
uint8_t  reg 
)

Select the register set depending on the register address The device can only address 16 registers directly. The other registers are accessible indirectly only.

References DEFSEL, ERSSEL, MSR, MYPRINT, REGSEL_MASK, SPR, SRSSEL, TCRBIT, and TCRSEL.

void Sc16is752UsartProcessChannelInterrupt ( uint8_t  dev,
uint8_t  ch,
uint8_t  iir 
)
void Sc16is752UsartInterruptProcessing ( void *  arg)

UART Interrupt Processing Thread

References IIR, MYPRINT, NUT_WAIT_INFINITE, NutEventWait(), NutThreadSetPriority(), Sc16is752RegRead(), and Sc16is752UsartProcessChannelInterrupt().

Referenced by Sc16is752UsartInit().

Here is the call graph for this function:

void Sc16is752UsartEnable ( uint8_t  dev,
uint8_t  ch 
)

Carefully enable USART hardware functions.

Always enabale transmitter and receiver, even on read-only or write-only mode. So we can support software flow control.

References printf.

Referenced by Sc16is752UsartSetSpeed().

void Sc16is752UsartDisable ( uint8_t  dev,
uint8_t  ch 
)

Carefully disable USART hardware functions.

References printf.

Referenced by Sc16is752UsartSetSpeed().

uint32_t Sc16is752UsartGetSpeed ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware for the selected speed.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
The currently selected baudrate.

References printf.

int Sc16is752UsartSetSpeed ( uint32_t  rate,
uint8_t  dev,
uint8_t  ch 
)

Set the USART hardware bit rate.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Parameters:
rateNumber of bits per second.
Returns:
0 on success, -1 otherwise.

References printf, Sc16is752UsartDisable(), and Sc16is752UsartEnable().

Here is the call graph for this function:

uint8_t Sc16is752UsartGetDataBits ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware for the number of data bits.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
The number of data bits set.

References printf.

int Sc16is752UsartSetDataBits ( uint8_t  bits,
uint8_t  dev,
uint8_t  ch 
)

Set the USART hardware to the number of data bits.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
0 on success, -1 otherwise.

References printf.

uint8_t Sc16is752UsartGetParity ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware for the parity mode.

This routine is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
Parity mode, either 0 (disabled), 1 (odd), 2 (even) or 9 (multidrop).

References printf.

int Sc16is752UsartSetParity ( uint8_t  mode,
uint8_t  dev,
uint8_t  ch 
)

Set the USART hardware to the specified parity mode.

This routine is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Parameters:
mode0 (disabled), 1 (odd) or 2 (even)
Returns:
0 on success, -1 otherwise.

References printf.

uint8_t Sc16is752UsartGetStopBits ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware for the number of stop bits.

This routine is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
The number of stop bits set, either 1, 2 or 3 (1.5 bits).

References printf.

int Sc16is752UsartSetStopBits ( uint8_t  bits,
uint8_t  dev,
uint8_t  ch 
)

Set the USART hardware to the number of stop bits.

This routine is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
0 on success, -1 otherwise.

References printf.

uint32_t Sc16is752UsartGetStatus ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware status.

Returns:
Status flags.

References printf, and rc.

int Sc16is752UsartSetStatus ( uint32_t  flags,
uint8_t  dev,
uint8_t  ch 
)

Set the USART hardware status.

Parameters:
flagsStatus flags.
Returns:
0 on success, -1 otherwise.

References printf.

uint8_t Sc16is752UsartGetClockMode ( uint8_t  dev,
uint8_t  ch 
)

Query the USART hardware for synchronous mode.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
Or-ed combination of UART_SYNC, UART_MASTER, UART_NCLOCK and UART_HIGHSPEED.

References printf, and rc.

Referenced by Sc16is752UsartSetClockMode().

int Sc16is752UsartSetClockMode ( uint8_t  mode,
uint8_t  dev,
uint8_t  ch 
)

Set asynchronous or synchronous mode.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Parameters:
modeMust be an or-ed combination of USART_SYNC, USART_MASTER, USART_NCLOCK and USART_HIGHSPEED.
Returns:
0 on success, -1 otherwise.

References printf, and Sc16is752UsartGetClockMode().

Here is the call graph for this function:

uint32_t Sc16is752UsartGetFlowControl ( uint8_t  dev,
uint8_t  ch 
)

Query flow control mode.

This routine is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Returns:
See UsartIOCtl().

References printf, rc, and USART_MF_XONXOFF.

Referenced by Sc16is752UsartSetFlowControl().

int Sc16is752UsartSetFlowControl ( uint32_t  flags,
uint8_t  dev,
uint8_t  ch 
)

Set flow control mode.

This function is called by ioctl function of the upper level USART driver through the USARTDCB jump table.

Parameters:
flagsSee UsartIOCtl().
Returns:
0 on success, -1 otherwise.

References printf, and Sc16is752UsartGetFlowControl().

Here is the call graph for this function:

void Sc16is752UsartTxStart ( uint8_t  dev,
uint8_t  ch 
)

Start the USART transmitter hardware.

The upper level USART driver will call this function through the USARTDCB jump table each time it added one or more bytes to the transmit buffer.

TODO Check if Tx interrupt is generated immediately or if a first char needs to sent

References IER, printf, Sc16is752RegRead(), and Sc16is752RegWrite().

Here is the call graph for this function:

void Sc16is752UsartRxStart ( uint8_t  dev,
uint8_t  ch 
)

Start the USART receiver hardware.

The upper level USART driver will call this function through the USARTDCB jump table each time it removed enough bytes from the receive buffer. Enough means, that the number of bytes left in the buffer is below the low watermark.

References printf.

int Sc16is752UsartInit ( uint8_t  dev,
uint8_t  ch,
NUTDEVICE nutDev,
IRQ_HANDLER irq 
)

Initialize the USART hardware driver.

This function is called during device registration by the upper level USART driver through the USARTDCB jump table.

Returns:
0 on success, -1 otherwise.

TODO Check if Rx interrupt is generated immediately or if a first char needs to sent

References DLH, DLL, FCR, IER, INIT_BAUDRATE, LCR, MYPRINT, NUT_IRQMODE_FALLINGEDGE, NutIrqEnable(), NutIrqSetMode(), NutRegisterIrqHandler(), NutThreadCreate(), printf, Sc16is752RegRead(), Sc16is752RegWrite(), and Sc16is752UsartInterruptProcessing().

Here is the call graph for this function:

int Sc16is752UsartDeinit ( uint8_t  dev,
uint8_t  ch,
IRQ_HANDLER irq 
)

Deinitialize the USART hardware driver.

This function is called during device deregistration by the upper level USART driver through the USARTDCB jump table.

Returns:
0 on success, -1 otherwise.

References NutRegisterIrqHandler(), and printf.

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '0', 0, 0, 0, 0},    
    IFTYP_CHAR,                 
    0,                          
    0,                          
    0,                          
    &dcb_usart0,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 
    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART0 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART0.

The device is named uart0.

Referenced by AhdlcAt91IOCtl().

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '1', 0, 0, 0, 0},    
    IFTYP_CHAR,                 
    1,                          
    0,                          
    0,                          
    &dcb_usart1,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 
    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART1 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART1.

The device is named uart1.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', 'd', 0, 0, 0, 0},    
    IFTYP_CHAR,                 
    DBGU_BASE,                  
    0,                          
    0,                          
    &dcb_dbgu,                  
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 
    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART0 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART0.

The device is named uart0.

Initial value:
 {
    0,                          
    {'d', 'b', 'g', 'u', 0, 0, 0, 0, 0},    
    IFTYP_CHAR,                 
    AT91C_BASE_DBGU,            
    0,                          
    0,                          
    &dcb_dbgu,                  
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 
    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART0 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART0.

The device is named uart0.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '_', 'a', 0, 0, 0},    
    IFTYP_CHAR,                 
    (SCDEV<<8)|CH_,              
    0,                          
    0,                          
    &dcb_usarta,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 

    UsartWrite_P,               

    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART0 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART0.

The device is named uarta.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '_', 'b', 0, 0, 0},    
    IFTYP_CHAR,                 
    0,                          
    0,                          
    0,                          
    &dcb_usartb,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 

    UsartWrite_P,               

    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART0 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART0.

The device is named uarta.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '_', 'c', 0, 0, 0},    
    IFTYP_CHAR,                 
    (SCDEV<<8)|CH_,              
    0,                          
    0,                          
    &dcb_usartc,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 

    UsartWrite_P,               

    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART2 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART2.

The device is named uartc.

Initial value:
 {
    0,                          
    {'u', 'a', 'r', 't', '_', 'd', 0, 0, 0},    
    IFTYP_CHAR,                 
    (SCDEV<<8)|CH_,              
    0,                          
    0,                          
    &dcb_usartd,                
    UsartInit,                  
    UsartIOCtl,                 
    UsartRead,                  
    UsartWrite,                 

    UsartWrite_P,               

    UsartOpen,                  
    UsartClose,                 
    UsartSize                   
}

USART3 device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using the serial communication driver of the AT91's on-chip USART3.

The device is named uartd.