Difference between revisions of "Unit UART"

From Ultibo.org
Jump to: navigation, search
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
----
 
----
  
'''Ultibo UART interface unit'''
+
'''Ultibo UART Interface unit'''
  
 
UART (Universal Asynchronous Receiver Transmitter) devices represent the industry standard serial communications devices that are available on almost every system.
 
UART (Universal Asynchronous Receiver Transmitter) devices represent the industry standard serial communications devices that are available on almost every system.
Line 51: Line 51:
 
| <code>UART_TYPE_16650 = 3;</code>
 
| <code>UART_TYPE_16650 = 3;</code>
 
| 16650 UART and similar variants (eg 16C650) (Differences are handled by driver)
 
| 16650 UART and similar variants (eg 16C650) (Differences are handled by driver)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_TYPE_MAX = 3;</code>
 +
| &nbsp;
 
|-
 
|-
 
|}
 
|}
Line 68: Line 73:
 
| <code>UART_MODE_SERIAL = 2;</code>
 
| <code>UART_MODE_SERIAL = 2;</code>
 
| The UART was opened as a Serial device so reads and writes are being buffered
 
| The UART was opened as a Serial device so reads and writes are being buffered
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_MODE_MAX = 2;</code>
 +
| &nbsp;
 
|-
 
|-
 
|}
 
|}
Line 81: Line 91:
 
|-
 
|-
 
| <code>UART_STATE_ENABLED = 1;</code>
 
| <code>UART_STATE_ENABLED = 1;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_STATE_MAX = 1;</code>
 
| &nbsp;
 
| &nbsp;
 
|-
 
|-
Line 166: Line 181:
 
| <code>UART_WRITE_NON_BLOCK = SERIAL_WRITE_NON_BLOCK;</code>
 
| <code>UART_WRITE_NON_BLOCK = SERIAL_WRITE_NON_BLOCK;</code>
 
| Do not block when transmitting, if the FIFO is full return immediately
 
| Do not block when transmitting, if the FIFO is full return immediately
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 20px; padding-bottom: 15px;">
 +
<div style="font-size: 14px; padding-left: 12px;">'''UART wait direction''' <code> UART_WAIT_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_WAIT_NONE = SERIAL_WAIT_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_WAIT_RECEIVE = SERIAL_WAIT_RECEIVE;</code>
 +
| Wait for data to be available in the receive FIFO
 +
|-
 +
| <code>UART_WAIT_TRANSMIT = SERIAL_WAIT_TRANSMIT;</code>
 +
| Wait for space to be available in the transmit FIFO
 
|-
 
|-
 
|}
 
|}
Line 236: Line 268:
 
| <code>UART_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 
| <code>UART_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 
| UART informational messages, such as a device being attached or detached
 
| UART informational messages, such as a device being attached or detached
 +
|-
 +
| <code>UART_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code>
 +
| UART warning messages
 
|-
 
|-
 
| <code>UART_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code>
 
| <code>UART_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code>
Line 341: Line 376:
 
|}
 
|}
  
'''UART device status'''
+
'''UART device wait'''
  
 
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 
|-
 
|-
| <code>TUARTDeviceStatus = function(UART:PUARTDevice):LongWord;</code>
+
| <code>TUARTDeviceWait = function(UART:PUARTDevice; Direction,Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device get status'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceGetStatus = function(UART:PUARTDevice):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device set status'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceSetStatus = function(UART:PUARTDevice; Status:LongWord):LongWord;</code>
 
| style="width: 40%;"|
 
| style="width: 40%;"|
 
|-
 
|-
Line 358: Line 411:
 
|-
 
|-
 
|}  
 
|}  
 +
 +
'''UART device set properties'''
 +
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceSetProperties = function(UART:PUARTDevice; Properties:PUARTProperties):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
  
 
'''UART device'''
 
'''UART device'''
Line 399: Line 461:
 
| A Device specific DeviceWrite method implementing the standard UART device interface (Mandatory)
 
| A Device specific DeviceWrite method implementing the standard UART device interface (Mandatory)
 
|-
 
|-
| <code>DeviceStatus:TUARTDeviceStatus;</code>
+
| <code>DeviceWait:TUARTDeviceWait;</code>
| A Device specific DeviceStatus method implementing the standard UART device interface (Or nil if the default method is suitable)
+
| A Device specific DeviceWait method implementing the standard UART device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceGetStatus:TUARTDeviceGetStatus;</code>
 +
| A Device specific DeviceGetStatus method implementing the standard UART device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceSetStatus:TUARTDeviceSetStatus;</code>
 +
| A Device specific DeviceSetStatus method implementing the standard UART device interface (Optional)
 
|-
 
|-
 
| <code>DeviceGetProperties:TUARTDeviceGetProperties;</code>
 
| <code>DeviceGetProperties:TUARTDeviceGetProperties;</code>
 
| A Device specific DeviceGetProperties method implementing the standard UART device interface (Or nil if the default method is suitable)
 
| A Device specific DeviceGetProperties method implementing the standard UART device interface (Or nil if the default method is suitable)
 +
|-
 +
| <code>DeviceSetProperties:TUARTDeviceSetProperties;</code>
 +
| A Device specific DeviceSetProperties method implementing the standard UART device interface (Or nil if the default method is suitable)
 
|-
 
|-
 
|colspan="2"|''Driver Properties''
 
|colspan="2"|''Driver Properties''
Line 482: Line 553:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Called only during system startup
 
| Called only during system startup
 
|-
 
|-
Line 497: Line 568:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to open
 
| The UART device to open
 
|-
 
|-
! '''BaudRate'''
+
! BaudRate
| Baud rate for the connection (eg 9600, 57600, 115200 etc
+
| Baud rate for the connection (eg 9600, 57600, 115200 etc)
 
|-
 
|-
! '''DataBits'''
+
! DataBits
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
| Size of the data (eg SERIAL_DATA_8BIT)
 
|-
 
|-
! '''StopBits'''
+
! StopBits
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
| Number of stop bits (eg SERIAL_STOP_1BIT)
 
|-
 
|-
! '''Parity'''
+
! Parity
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
| Parity type for the data (eg SERIAL_PARITY_NONE)
 
|-
 
|-
! '''FlowControl'''
+
! FlowControl
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 527: Line 598:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to close
 
| The UART device to close
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 542: Line 613:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to read from
 
| The UART device to read from
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer to receive the data
 
| Pointer to a buffer to receive the data
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control reading (eg UART_READ_NON_BLOCK)
 
| The flags to control reading (eg UART_READ_NON_BLOCK)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes read on return
 
| The number of bytes read on return
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 569: Line 640:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to write to
 
| The UART device to write to
 
|-
 
|-
! '''Buffer'''
+
! Buffer
 
| Pointer to a buffer of data to transmit
 
| Pointer to a buffer of data to transmit
 
|-
 
|-
! '''Size'''
+
! Size
 
| The size of the buffer
 
| The size of the buffer
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control writing (eg UART_WRITE_NON_BLOCK)
 
| The flags to control writing (eg UART_WRITE_NON_BLOCK)
 
|-
 
|-
! '''Count'''
+
! Count
 
| The number of bytes written on return
 
| The number of bytes written on return
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 591: Line 662:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceStatus(UART:PUARTDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceWait(UART:PUARTDevice; Direction,Timeout:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Wait for data to be available in the receive or transmit FIFO of a UART device</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! UART
 +
| The UART device to wait for
 +
|-
 +
! Direction
 +
| The direction of data to wait for (eg UART_WAIT_RECEIVE)
 +
|-
 +
! Timeout
 +
| The number of milliseconds to wait for data (INFINITE to wait forever)
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceStatus(UART:PUARTDevice):LongWord; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current line status of a UART device</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current line status of a UART device</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to get the status from
 
| The UART device to get the status from
 
|-
 
|-
! '''Return'''
+
! Return
 
| A set of flags containing the device status (eg UART_STATUS_RTS)
 
| A set of flags containing the device status (eg UART_STATUS_RTS)
 +
|-
 +
! Note
 +
| Replaced by UARTDeviceGetStatus for consistency
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceGetStatus(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current line status of a UART device</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! UART
 +
| The UART device to get the status from
 +
|-
 +
! Return
 +
| A set of flags containing the device status (eg UART_STATUS_RTS)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceSetStatus(UART:PUARTDevice;Status:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current line status of a UART device</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! UART
 +
| The UART device to set the status for
 +
|-
 +
! Status
 +
| The device status flags to be set (eg UART_STATUS_RTS)
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
! Note
 +
| Not all UART_STATUS_* flags can be set, the device may ignore invalid values.
 +
Not all UART devices support set status, returns ERROR_CALL_NOT_IMPLEMENTED if not supported.
 
|-
 
|-
 
|}
 
|}
Line 611: Line 743:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to get properties from
 
| The UART device to get properties from
 
|-
 
|-
! '''Properties'''
+
! Properties
 
| Pointer to a PUARTProperties structure to fill in
 
| Pointer to a PUARTProperties structure to fill in
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
! '''Note'''
+
! Note
 
| Replaced by UARTDeviceGetProperties for consistency
 
| Replaced by UARTDeviceGetProperties for consistency
 
|-
 
|-
Line 632: Line 764:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to get properties from
 
| The UART device to get properties from
 
|-
 
|-
! '''Properties'''
+
! Properties
 
| Pointer to a PUARTProperties structure to fill in
 
| Pointer to a PUARTProperties structure to fill in
 
|-
 
|-
! '''Return'''
+
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceSetProperties(UART:PUARTDevice; Properties:PUARTProperties):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the properties for the specified UART device</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! UART
 +
| The UART device to set properties for
 +
|-
 +
! Properties
 +
| Pointer to a PUARTProperties structure to use
 +
|-
 +
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 650: Line 800:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to new UART entry or nil if UART could not be created
 
| Pointer to new UART entry or nil if UART could not be created
 
|-
 
|-
Line 662: Line 812:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Size'''
+
! Size
 
| Size in bytes to allocate for new UART (Including the UART entry)
 
| Size in bytes to allocate for new UART (Including the UART entry)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to new UART entry or nil if UART could not be created
 
| Pointer to new UART entry or nil if UART could not be created
 
|-
 
|-
Line 677: Line 827:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to destroy
 
| The UART device to destroy
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 692: Line 842:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to register
 
| The UART device to register
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 707: Line 857:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to deregister
 
| The UART device to deregister
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 722: Line 872:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UARTId'''
+
! UARTId
 
| The Id number of the UART to find
 
| The Id number of the UART to find
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to UART device entry or nil if not found
 
| Pointer to UART device entry or nil if not found
 
|-
 
|-
Line 737: Line 887:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Name'''
+
! Name
 
| The name of the UART to find (eg UART0)
 
| The name of the UART to find (eg UART0)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to UART device entry or nil if not found
 
| Pointer to UART device entry or nil if not found
 
|-
 
|-
Line 752: Line 902:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Description'''
+
! Description
 
| The description of the UART to find (eg BCM2836 PL011 UART)
 
| The description of the UART to find (eg BCM2836 PL011 UART)
 
|-
 
|-
! '''Return'''
+
! Return
 
| Pointer to UART device entry or nil if not found
 
| Pointer to UART device entry or nil if not found
 
|-
 
|-
Line 767: Line 917:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The callback function to call for each UART in the table
 
| The callback function to call for each UART in the table
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback for each UART in the table
 
| A private data pointer to pass to callback for each UART in the table
 
|-
 
|-
! '''Return'''
+
! Return
 
| ERROR_SUCCESS if completed or another error code on failure
 
| ERROR_SUCCESS if completed or another error code on failure
 
|-
 
|-
Line 785: Line 935:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''UART'''
+
! UART
 
| The UART device to notify changes for (Optional, pass nil for all UART devices)
 
| The UART device to notify changes for (Optional, pass nil for all UART devices)
 
|-
 
|-
! '''Callback'''
+
! Callback
 
| The function to call when a notification event occurs
 
| The function to call when a notification event occurs
 
|-
 
|-
! '''Data'''
+
! Data
 
| A private data pointer to pass to callback when a notification event occurs
 
| A private data pointer to pass to callback when a notification event occurs
 
|-
 
|-
! '''Notification'''
+
! Notification
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 
|-
 
|-
! '''Flags'''
+
! Flags
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 
|-
 
|-
Line 812: Line 962:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceOpen instead
+
| Not intended to be called directly by applications, use SerialDeviceOpen instead.
 
|-
 
|-
 
|}
 
|}
Line 824: Line 974:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceClose instead
+
| Not intended to be called directly by applications, use SerialDeviceClose instead.
 
|-
 
|-
 
|}
 
|}
Line 836: Line 986:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceRead instead
+
| Not intended to be called directly by applications, use SerialDeviceRead instead.
 
|-
 
|-
 
|}
 
|}
Line 848: Line 998:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceWrite instead
+
| Not intended to be called directly by applications, use SerialDeviceWrite instead.
 
|-
 
|-
 
|}
 
|}
Line 855: Line 1,005:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function UARTSerialDeviceStatus(Serial:PSerialDevice):LongWord;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function UARTSerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceWait API for UART Serial</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| Not intended to be called directly by applications, use SerialDeviceWait instead.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTSerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceStatus API for UART Serial</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceStatus API for UART Serial</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceStatus instead
+
| Not intended to be called directly by applications, use SerialDeviceStatus instead.
 +
Replaced by UARTSerialDeviceGetStatus for consistency
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTSerialDeviceGetStatus(Serial:PSerialDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceGetStatus API for UART Serial</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| Not intended to be called directly by applications, use SerialDeviceGetStatus instead.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTSerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceSetStatus API for UART Serial</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| Not intended to be called directly by applications, use SerialDeviceSetStatus instead.
 
|-
 
|-
 
|}
 
|}
Line 872: Line 1,059:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
| Not intended to be called directly by applications, use SerialDeviceGetProperties instead
+
| Not intended to be called directly by applications, use SerialDeviceGetProperties instead.
 
|-
 
|-
 
|}
 
|}
Line 882: Line 1,069:
  
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function UARTGetCount:LongWord; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function UARTGetCount:LongWord;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current UART count</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current UART count</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 894: Line 1,081:
 
<br />
 
<br />
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceGetDefault:PUARTDevice; inline;</pre>
+
<pre style="border: 0; padding-bottom:0px;">function UARTDeviceGetDefault:PUARTDevice;</pre>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default UART device</div>
 
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get the current default UART device</div>
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 911: Line 1,098:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 923: Line 1,110:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTTypeToString(UARTType:LongWord):String;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a UART type value to a string</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTModeToString(UARTMode:LongWord):String;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a UART mode to a string</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">function UARTStateToString(UARTState:LongWord):String;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Convert a UART state value to a string</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 935: Line 1,158:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 947: Line 1,170:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 +
| None documented
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;">
 +
<pre style="border: 0; padding-bottom:0px;">procedure UARTLogWarn(UART:PUARTDevice; const AText:String); inline;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 959: Line 1,194:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 971: Line 1,206:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| None documented
 
| None documented
 
|-
 
|-
Line 986: Line 1,221:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 +
Caller must hold the lock on the serial device which owns the UART
 
|-
 
|-
 
|}
 
|}
Line 998: Line 1,234:
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
{| class="wikitable" style="font-size: 14px; background: white;"
 
|-
 
|-
! '''Note'''
+
! Note
 
| Not intended to be called directly by applications
 
| Not intended to be called directly by applications
 +
Caller must hold the lock on the serial device which owns the UART
 
|-
 
|-
 
|}
 
|}

Latest revision as of 02:33, 15 December 2022

Return to Unit Reference


Description


Ultibo UART Interface unit

UART (Universal Asynchronous Receiver Transmitter) devices represent the industry standard serial communications devices that are available on almost every system.

This unit implements the framework for UART devices and provides a standardized API to allow driver specific implementation to be abstracted. All UART devices are also represented as a serial device and this unit handles the relationship between the two devices.

Each UART device returns a set of properties that describe the capabilities of the device and includes a set of flags that indicate what features are supported.

Reads and writes to UART devices are unbuffered and simply pass raw data to and from the caller unless the serial interface is used instead which includes buffering of transmitted and received data. Both reads and writes allow for non blocking so that a caller can avoid waiting for received data to be available or the device to be ready to transmit.

Constants



[Expand]
UART specific constants UART_*


[Expand]
UART device type UART_TYPE_*


[Expand]
UART device mode UART_MODE_*


[Expand]
UART device state UART_STATE_*


[Expand]
UART device flag UART_FLAG_*


[Expand]
UART read flag UART_READ_*


[Expand]
UART write flag UART_WRITE_*


[Expand]
UART wait direction UART_WAIT_*


[Expand]
UART status flag UART_STATUS_*


[Expand]
UART logging UART_LOG_*


Type definitions



UART properties

[Expand]

PUARTProperties = ^TUARTProperties;

TUARTProperties = record

UART enumeration callback

TUARTEnumerate = function(UART:PUARTDevice; Data:Pointer):LongWord;

UART notification callback

TUARTNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;

UART device open

TUARTDeviceOpen = function(UART:PUARTDevice; BaudRate,DataBits,StopBits,Parity,FlowControl:LongWord):LongWord;

UART device close

TUARTDeviceClose = function(UART:PUARTDevice):LongWord;

UART device read

TUARTDeviceRead = function(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;

UART device write

TUARTDeviceWrite = function(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;

UART device wait

TUARTDeviceWait = function(UART:PUARTDevice; Direction,Timeout:LongWord):LongWord;

UART device get status

TUARTDeviceGetStatus = function(UART:PUARTDevice):LongWord;

UART device set status

TUARTDeviceSetStatus = function(UART:PUARTDevice; Status:LongWord):LongWord;

UART device get properties

TUARTDeviceGetProperties = function(UART:PUARTDevice; Properties:PUARTProperties):LongWord;

UART device set properties

TUARTDeviceSetProperties = function(UART:PUARTDevice; Properties:PUARTProperties):LongWord;

UART device

[Expand]

PUARTDevice = ^TUARTDevice;

TUARTDevice = record


Public variables



UART logging

UART_DEFAULT_LOG_LEVEL:LongWord = UART_LOG_LEVEL_DEBUG; Minimum level for UART messages. Only messages with level greater than or equal to this will be printed.
UART_LOG_ENABLED:Boolean;


Function declarations



Initialization functions

[Expand]
procedure UARTInit;
Description: Initialize the UART unit and UART device table


UART functions

[Expand]
function UARTDeviceOpen(UART:PUARTDevice; BaudRate,DataBits,StopBits,Parity,FlowControl:LongWord):LongWord;
Description: Open a UART device ready for sending and receiving


[Expand]
function UARTDeviceClose(UART:PUARTDevice):LongWord;
Description: Close a UART device and terminate sending and receiving


[Expand]
function UARTDeviceRead(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord;var Count:LongWord):LongWord;
Description: Read data from a UART device


[Expand]
function UARTDeviceWrite(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord;var Count:LongWord):LongWord;
Description: Write data to a UART device


[Expand]
function UARTDeviceWait(UART:PUARTDevice; Direction,Timeout:LongWord):LongWord;
Description: Wait for data to be available in the receive or transmit FIFO of a UART device


[Expand]
function UARTDeviceStatus(UART:PUARTDevice):LongWord; inline;
Description: Get the current line status of a UART device


[Expand]
function UARTDeviceGetStatus(UART:PUARTDevice):LongWord;
Description: Get the current line status of a UART device


[Expand]
function UARTDeviceSetStatus(UART:PUARTDevice;Status:LongWord):LongWord;
Description: Set the current line status of a UART device


[Expand]
function UARTDeviceProperties(UART:PUARTDevice; Properties:PUARTProperties):LongWord; inline;
Description: Get the properties for the specified UART device


[Expand]
function UARTDeviceGetProperties(UART:PUARTDevice;Properties:PUARTProperties):LongWord;
Description: Get the properties for the specified UART device


[Expand]
function UARTDeviceSetProperties(UART:PUARTDevice; Properties:PUARTProperties):LongWord;
Description: Set the properties for the specified UART device


[Expand]
function UARTDeviceCreate:PUARTDevice;
Description: Create a new UART entry


[Expand]
function UARTDeviceCreateEx(Size:LongWord):PUARTDevice;
Description: Create a new UART entry


[Expand]
function UARTDeviceDestroy(UART:PUARTDevice):LongWord;
Description: Destroy an existing UART entry


[Expand]
function UARTDeviceRegister(UART:PUARTDevice):LongWord;
Description: Register a new UART in the UART table


[Expand]
function UARTDeviceDeregister(UART:PUARTDevice):LongWord;
Description: Deregister a UART from the UART table


[Expand]
function UARTDeviceFind(UARTId:LongWord):PUARTDevice;
Description: Find a UART device by Id in the UART table


[Expand]
function UARTDeviceFindByName(const Name:String):PUARTDevice; inline;
Description: Find a UART device by name in the UART table


[Expand]
function UARTDeviceFindByDescription(const Description:String):PUARTDevice; inline;
Description: Find a UART device by description in the UART table


[Expand]
function UARTDeviceEnumerate(Callback:TUARTEnumerate; Data:Pointer):LongWord;
Description: Enumerate all UART devices in the UART table


[Expand]
function UARTDeviceNotification(UART:PUARTDevice; Callback:TUARTNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: Register a notification for UART device changes


UART serial functions

[Expand]
function UARTSerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;
Description: Implementation of SerialDeviceOpen API for UART Serial


[Expand]
function UARTSerialDeviceClose(Serial:PSerialDevice):LongWord;
Description: Implementation of SerialDeviceClose API for UART Serial


[Expand]
function UARTSerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Implementation of SerialDeviceRead API for UART Serial


[Expand]
function UARTSerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;
Description: Implementation of SerialDeviceWrite API for UART Serial


[Expand]
function UARTSerialDeviceWait(Serial:PSerialDevice; Direction,Timeout:LongWord; var Count:LongWord):LongWord;
Description: Implementation of SerialDeviceWait API for UART Serial


[Expand]
function UARTSerialDeviceStatus(Serial:PSerialDevice):LongWord; inline;
Description: Implementation of SerialDeviceStatus API for UART Serial


[Expand]
function UARTSerialDeviceGetStatus(Serial:PSerialDevice):LongWord;
Description: Implementation of SerialDeviceGetStatus API for UART Serial


[Expand]
function UARTSerialDeviceSetStatus(Serial:PSerialDevice; Status:LongWord):LongWord;
Description: Implementation of SerialDeviceSetStatus API for UART Serial


[Expand]
function UARTSerialDeviceGetProperties(Serial:PSerialDevice;Properties:PSerialProperties):LongWord;
Description: Implementation of SerialDeviceGetProperties API for UART Serial


UART helper functions

[Expand]
function UARTGetCount:LongWord;
Description: Get the current UART count


[Expand]
function UARTDeviceGetDefault:PUARTDevice;
Description: Get the current default UART device


[Expand]
function UARTDeviceSetDefault(UART:PUARTDevice):LongWord;
Description: Set the current default UART device


[Expand]
function UARTDeviceCheck(UART:PUARTDevice):PUARTDevice;
Description: Check if the supplied UART is in the UART table


[Expand]
function UARTTypeToString(UARTType:LongWord):String;
Description: Convert a UART type value to a string


[Expand]
function UARTModeToString(UARTMode:LongWord):String;
Description: Convert a UART mode to a string


[Expand]
function UARTStateToString(UARTState:LongWord):String;
Description: Convert a UART state value to a string


[Expand]
procedure UARTLog(Level:LongWord;UART:PUARTDevice; const AText:String);
Description: To be documented


[Expand]
procedure UARTLogInfo(UART:PUARTDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure UARTLogWarn(UART:PUARTDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure UARTLogError(UART:PUARTDevice; const AText:String); inline;
Description: To be documented


[Expand]
procedure UARTLogDebug(UART:PUARTDevice; const AText:String); inline;
Description: To be documented


UART serial helper functions

[Expand]
function UARTSerialDeviceReceive(UART:PUARTDevice):LongWord;
Description: Read data from a UART device into the receive buffer of the associated Serial device


[Expand]
function UARTSerialDeviceTransmit(UART:PUARTDevice):LongWord;
Description: Write data to a UART device from the transmit buffer of the associated Serial device


Return to Unit Reference