Difference between revisions of "Unit UART"

From Ultibo.org
Jump to: navigation, search
 
(26 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
=== Description ===
 
=== 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.
 
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
+
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.
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.
 
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.
Line 17: Line 18:
 
----
 
----
  
''To be documented''
+
 
 +
<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 specific constants''' <code> UART_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_NAME_PREFIX = 'UART';</code>
 +
| Name prefix for UART Devices
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_PUSH_TIMEOUT = SERIAL_PUSH_TIMEOUT;</code>
 +
| Timeout (Milliseconds) for Push RX/TX (Implementation specific)
 +
|-
 +
|}
 +
</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 device type''' <code> UART_TYPE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_TYPE_NONE = 0;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_TYPE_8250 = 1;</code>
 +
| 8250 UART and similar variants (Differences are handled by driver)
 +
|-
 +
| <code>UART_TYPE_16550 = 2;</code>
 +
| 16550 UART and similar variants (eg 16550A) (Differences are handled by driver)
 +
|-
 +
| <code>UART_TYPE_16650 = 3;</code>
 +
| 16650 UART and similar variants (eg 16C650) (Differences are handled by driver)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_TYPE_MAX = 3;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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 device mode''' <code> UART_MODE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_MODE_NONE = 0;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_MODE_UART = 1;</code>
 +
| The UART was opened as a UART device and all reads and writes are direct
 +
|-
 +
| <code>UART_MODE_SERIAL = 2;</code>
 +
| 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;
 +
|-
 +
|}
 +
</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 device state''' <code> UART_STATE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_STATE_DISABLED = 0;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>UART_STATE_ENABLED = 1;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>UART_STATE_MAX = 1;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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 device flag''' <code> UART_FLAG_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_FLAG_NONE = SERIAL_FLAG_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_FLAG_DATA_8BIT = SERIAL_FLAG_DATA_8BIT;</code>
 +
| Device supports 8 data bits
 +
|-
 +
| <code>UART_FLAG_DATA_7BIT = SERIAL_FLAG_DATA_7BIT;</code>
 +
| Device supports 7 data bits
 +
|-
 +
| <code>UART_FLAG_DATA_6BIT = SERIAL_FLAG_DATA_6BIT;</code>
 +
| Device supports 6 data bits
 +
|-
 +
| <code>UART_FLAG_DATA_5BIT = SERIAL_FLAG_DATA_5BIT;</code>
 +
| Device supports 5 data bits
 +
|-
 +
| <code>UART_FLAG_STOP_1BIT = SERIAL_FLAG_STOP_1BIT;</code>
 +
| Device supports 1 stop bit
 +
|-
 +
| <code>UART_FLAG_STOP_2BIT = SERIAL_FLAG_STOP_2BIT;</code>
 +
| Device supports 2 stop bits
 +
|-
 +
| <code>UART_FLAG_STOP_1BIT5 = SERIAL_FLAG_STOP_1BIT5;</code>
 +
| Device supports 1.5 stop bits
 +
|-
 +
| <code>UART_FLAG_PARITY_ODD = SERIAL_FLAG_PARITY_ODD;</code>
 +
| Device supports odd parity
 +
|-
 +
| <code>UART_FLAG_PARITY_EVEN = SERIAL_FLAG_PARITY_EVEN;</code>
 +
| Device supports even parity
 +
|-
 +
| <code>UART_FLAG_PARITY_MARK = SERIAL_FLAG_PARITY_MARK;</code>
 +
| Device supports mark parity
 +
|-
 +
| <code>UART_FLAG_PARITY_SPACE = SERIAL_FLAG_PARITY_SPACE;</code>
 +
| Device supports space parity
 +
|-
 +
| <code>UART_FLAG_FLOW_RTS_CTS = SERIAL_FLAG_FLOW_RTS_CTS;</code>
 +
| Device supports RTS/CTS flow control
 +
|-
 +
| <code>UART_FLAG_FLOW_DSR_DTR = SERIAL_FLAG_FLOW_DSR_DTR;</code>
 +
| Device supports DSR/DTR flow control
 +
|-
 +
| <code>UART_FLAG_PUSH_RX = SERIAL_FLAG_PUSH_RX;</code>
 +
| Device requires pushed receive (Implementation specific)
 +
|-
 +
| <code>UART_FLAG_PUSH_TX = SERIAL_FLAG_PUSH_TX;</code>
 +
| Device requires pushed transmit (Implementation specific)
 +
|-
 +
|}
 +
</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 read flag''' <code> UART_READ_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_READ_NONE = SERIAL_READ_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_READ_NON_BLOCK = SERIAL_READ_NON_BLOCK;</code>
 +
| Do not block when receiving, if the FIFO is empty 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 write flag''' <code> UART_WRITE_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_WRITE_NONE = SERIAL_WRITE_NONE;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_WRITE_NON_BLOCK = SERIAL_WRITE_NON_BLOCK;</code>
 +
| 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
 +
|-
 +
|}
 +
</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 status flag''' <code> UART_STATUS_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_STATUS_NONE = SERIAL_STATUS_NONE;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>UART_STATUS_RTS = SERIAL_STATUS_RTS;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_CTS = SERIAL_STATUS_CTS;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_DSR = SERIAL_STATUS_DSR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_DTR = SERIAL_STATUS_DTR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_RX_FULL = SERIAL_STATUS_RX_FULL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_RX_EMPTY = SERIAL_STATUS_RX_EMPTY;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_TX_FULL = SERIAL_STATUS_TX_FULL;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_TX_EMPTY = SERIAL_STATUS_TX_EMPTY;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_BUSY = SERIAL_STATUS_BUSY;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_BREAK_ERROR = SERIAL_STATUS_BREAK_ERROR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_PARITY_ERROR = SERIAL_STATUS_PARITY_ERROR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_FRAMING_ERROR = SERIAL_STATUS_FRAMING_ERROR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_OVERRUN_ERROR = SERIAL_STATUS_OVERRUN_ERROR;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_DCD = SERIAL_STATUS_DCD;</code>
 +
| &nbsp;
 +
|-
 +
| <code>UART_STATUS_RI = SERIAL_STATUS_RI;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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 logging''' <code> UART_LOG_* </code></div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>UART_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;</code>
 +
| UART debugging messages
 +
|-
 +
| <code>UART_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code>
 +
| 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>
 +
| UART error messages
 +
|-
 +
| <code>UART_LOG_LEVEL_NONE = LOG_LEVEL_NONE;</code>
 +
| No UART messages
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Type definitions ===
 
=== Type definitions ===
 
----
 
----
  
''To be documented''
+
 
 +
'''UART properties'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PUARTProperties = ^TUARTProperties;</code>
 +
 
 +
<code>TUARTProperties = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Device flags (eg UART_FLAG_DATA_8BIT)
 +
|-
 +
| <code>MinRate:LongWord;</code>
 +
| Minimum supported baud rate
 +
|-
 +
| <code>MaxRate:LongWord;</code>
 +
| Maximum supported baud rate
 +
|-
 +
| <code>BaudRate:LongWord;</code>
 +
| Current baud rate setting
 +
|-
 +
| <code>DataBits:LongWord;</code>
 +
| Current data bits setting
 +
|-
 +
| <code>StopBits:LongWord;</code>
 +
| Current stop bits setting
 +
|-
 +
| <code>Parity:LongWord;</code>
 +
| Current parity setting
 +
|-
 +
| <code>FlowControl:LongWord;</code>
 +
| Current flow control setting
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''UART enumeration callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTEnumerate = function(UART:PUARTDevice; Data:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART notification callback'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device open'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceOpen = function(UART:PUARTDevice; BaudRate,DataBits,StopBits,Parity,FlowControl:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device close'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceClose = function(UART:PUARTDevice):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device read'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceRead = function(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device write'''
 +
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceWrite = function(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device wait'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <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%;"|
 +
|-
 +
|}
 +
 
 +
'''UART device get properties'''
 +
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TUARTDeviceGetProperties = function(UART:PUARTDevice; Properties:PUARTProperties):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''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'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PUARTDevice = ^TUARTDevice;</code>
 +
 
 +
<code>TUARTDevice = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Device Properties''
 +
|-
 +
| <code>Device:TDevice;</code>
 +
| The Device entry for this UART
 +
|-
 +
|colspan="2"|''UART Properties''
 +
|-
 +
| <code>UARTId:LongWord;</code>
 +
| Unique Id of this UART in the UART table
 +
|-
 +
| <code>UARTMode:LongWord;</code>
 +
| UART mode (eg UART_MODE_SERIAL)
 +
|-
 +
| <code>UARTState:LongWord;</code>
 +
| UART state (eg UART_STATE_ENABLED)
 +
|-
 +
| <code>UARTStatus:LongWord;</code>
 +
| UART status (eg UART_STATUS_RX_FULL)(May not be real time status depending on the driver)
 +
|-
 +
| <code>DeviceOpen:TUARTDeviceOpen;</code>
 +
| A Device specific DeviceOpen method implementing the standard UART device interface (Mandatory)
 +
|-
 +
| <code>DeviceClose:TUARTDeviceClose;</code>
 +
| A Device specific DeviceClose method implementing the standard UART device interface (Mandatory)
 +
|-
 +
| <code>DeviceRead:TUARTDeviceRead;</code>
 +
| A Device specific DeviceRead method implementing the standard UART device interface (Mandatory)
 +
|-
 +
| <code>DeviceWrite:TUARTDeviceWrite;</code>
 +
| A Device specific DeviceWrite method implementing the standard UART device interface (Mandatory)
 +
|-
 +
| <code>DeviceWait:TUARTDeviceWait;</code>
 +
| 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>
 +
| 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''
 +
|-
 +
| <code>Lock:TMutexHandle;</code>
 +
| Device lock
 +
|-
 +
| <code>ReceiveWait:TEventHandle;</code>
 +
| Read wait event
 +
|-
 +
| <code>TransmitWait:TEventHandle;</code>
 +
| Write wait event
 +
|-
 +
| <code>Properties:TUARTProperties;</code>
 +
| Device properties
 +
|-
 +
''Serial Properties''
 +
|-
 +
| <code>Serial:PSerialDevice;</code>
 +
| The Serial device represented by this UART
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| <code>ReceiveCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>ReceiveErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>TransmitCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>TransmitErrors:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PUARTDevice;</code>
 +
| Previous entry in UART table
 +
|-
 +
| <code>Next:PUARTDevice;</code>
 +
| Next entry in UART table
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===
 
----
 
----
  
''To be documented''
+
 
 +
'''UART logging'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>UART_DEFAULT_LOG_LEVEL:LongWord = UART_LOG_LEVEL_DEBUG;</code>
 +
| style="width: 40%;"|Minimum level for UART messages. Only messages with level greater than or equal to this will be printed.
 +
|-
 +
|}
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>UART_LOG_ENABLED:Boolean;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
  
 
=== Function declarations ===
 
=== Function declarations ===
 
----
 
----
  
''To be documented''
 
  
 +
'''Initialization functions'''
 +
 +
<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 UARTInit;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Initialize the UART unit and UART device table</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Note
 +
| Called only during system startup
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''UART functions'''
 +
 +
<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 UARTDeviceOpen(UART:PUARTDevice; BaudRate,DataBits,StopBits,Parity,FlowControl:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Open a UART device ready for sending and receiving</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 open
 +
|-
 +
! BaudRate
 +
| Baud rate for the connection (eg 9600, 57600, 115200 etc)
 +
|-
 +
! DataBits
 +
| Size of the data (eg SERIAL_DATA_8BIT)
 +
|-
 +
! StopBits
 +
| Number of stop bits (eg SERIAL_STOP_1BIT)
 +
|-
 +
! Parity
 +
| Parity type for the data (eg SERIAL_PARITY_NONE)
 +
|-
 +
! FlowControl
 +
| Flow control for the connection (eg SERIAL_FLOW_NONE)
 +
|-
 +
! 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 UARTDeviceClose(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Close a UART device and terminate sending and receiving</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 close
 +
|-
 +
! 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 UARTDeviceRead(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord;var Count:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read data from 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 read from
 +
|-
 +
! Buffer
 +
| Pointer to a buffer to receive the data
 +
|-
 +
! Size
 +
| The size of the buffer
 +
|-
 +
! Flags
 +
| The flags to control reading (eg UART_READ_NON_BLOCK)
 +
|-
 +
! Count
 +
| The number of bytes read on 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 UARTDeviceWrite(UART:PUARTDevice; Buffer:Pointer; Size,Flags:LongWord;var Count:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to 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 write to
 +
|-
 +
! Buffer
 +
| Pointer to a buffer of data to transmit
 +
|-
 +
! Size
 +
| The size of the buffer
 +
|-
 +
! Flags
 +
| The flags to control writing (eg UART_WRITE_NON_BLOCK)
 +
|-
 +
! Count
 +
| The number of bytes written on 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 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 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)
 +
|-
 +
! 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.
 +
|-
 +
|}
 +
</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 UARTDeviceProperties(UART:PUARTDevice; Properties:PUARTProperties):LongWord; inline;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get 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 get properties from
 +
|-
 +
! Properties
 +
| Pointer to a PUARTProperties structure to fill in
 +
|-
 +
! Return
 +
| ERROR_SUCCESS if completed or another error code on failure
 +
|-
 +
! Note
 +
| Replaced by UARTDeviceGetProperties 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 UARTDeviceGetProperties(UART:PUARTDevice;Properties:PUARTProperties):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Get 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 get properties from
 +
|-
 +
! Properties
 +
| Pointer to a PUARTProperties structure to fill in
 +
|-
 +
! 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
 +
|-
 +
|}
 +
</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 UARTDeviceCreate:PUARTDevice;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new UART entry</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Return
 +
| Pointer to new UART entry or nil if UART could not be created
 +
|-
 +
|}
 +
</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 UARTDeviceCreateEx(Size:LongWord):PUARTDevice;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Create a new UART entry</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Size
 +
| Size in bytes to allocate for new UART (Including the UART entry)
 +
|-
 +
! Return
 +
| Pointer to new UART entry or nil if UART could not be created
 +
|-
 +
|}
 +
</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 UARTDeviceDestroy(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Destroy an existing UART entry</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 destroy
 +
|-
 +
! 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 UARTDeviceRegister(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a new UART in the UART table</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 register
 +
|-
 +
! 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 UARTDeviceDeregister(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Deregister a UART from the UART table</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 deregister
 +
|-
 +
! 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 UARTDeviceFind(UARTId:LongWord):PUARTDevice;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a UART device by Id in the UART table</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! UARTId
 +
| The Id number of the UART to find
 +
|-
 +
! Return
 +
| Pointer to UART device entry or nil if not found
 +
|-
 +
|}
 +
</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 UARTDeviceFindByName(const Name:String):PUARTDevice; inline;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a UART device by name in the UART table</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Name
 +
| The name of the UART to find (eg UART0)
 +
|-
 +
! Return
 +
| Pointer to UART device entry or nil if not found
 +
|-
 +
|}
 +
</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 UARTDeviceFindByDescription(const Description:String):PUARTDevice; inline;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Find a UART device by description in the UART table</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Description
 +
| The description of the UART to find (eg BCM2836 PL011 UART)
 +
|-
 +
! Return
 +
| Pointer to UART device entry or nil if not found
 +
|-
 +
|}
 +
</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 UARTDeviceEnumerate(Callback:TUARTEnumerate; Data:Pointer):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Enumerate all UART devices in the UART table</div>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
! Callback
 +
| The callback function to call for each UART in the table
 +
|-
 +
! Data
 +
| A private data pointer to pass to callback for each UART in the table
 +
|-
 +
! 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 UARTDeviceNotification(UART:PUARTDevice; Callback:TUARTNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Register a notification for UART device changes</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 notify changes for (Optional, pass nil for all UART devices)
 +
|-
 +
! Callback
 +
| The function to call when a notification event occurs
 +
|-
 +
! Data
 +
| A private data pointer to pass to callback when a notification event occurs
 +
|-
 +
! Notification
 +
| The events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
 +
|-
 +
! Flags
 +
| The flags to control the notification (eg NOTIFIER_FLAG_WORKER)
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''UART serial functions'''
 +
 +
<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 UARTSerialDeviceOpen(Serial:PSerialDevice; BaudRate,DataBits,StopBits,Parity,FlowControl,ReceiveDepth,TransmitDepth:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceOpen 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 SerialDeviceOpen 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 UARTSerialDeviceClose(Serial:PSerialDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceClose 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 SerialDeviceClose 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 UARTSerialDeviceRead(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceRead 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 SerialDeviceRead 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 UARTSerialDeviceWrite(Serial:PSerialDevice; Buffer:Pointer; Size,Flags:LongWord; var Count:LongWord):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceWrite 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 SerialDeviceWrite 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 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 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 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.
 +
|-
 +
|}
 +
</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 UARTSerialDeviceGetProperties(Serial:PSerialDevice;Properties:PSerialProperties):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Implementation of SerialDeviceGetProperties 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 SerialDeviceGetProperties instead.
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''UART helper functions'''
 +
 +
<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;</pre>
 +
<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;">
 +
{| 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 UARTDeviceGetDefault:PUARTDevice;</pre>
 +
<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;">
 +
{| 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 UARTDeviceSetDefault(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Set the current default UART device</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 UARTDeviceCheck(UART:PUARTDevice):PUARTDevice;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Check if the supplied UART is in the UART table</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 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
 +
|-
 +
|}
 +
</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 UARTLog(Level:LongWord;UART:PUARTDevice; const AText:String);</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
 +
|-
 +
|}
 +
</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 UARTLogInfo(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
 +
|-
 +
|}
 +
</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
 +
|-
 +
|}
 +
</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 UARTLogError(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
 +
|-
 +
|}
 +
</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 UARTLogDebug(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
 +
|-
 +
|}
 +
</div></div>
 +
<br />
 +
 +
'''UART serial helper functions'''
 +
 +
<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 UARTSerialDeviceReceive(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Read data from a UART device into the receive buffer of the associated Serial device</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
 +
Caller must hold the lock on the serial device which owns the UART
 +
|-
 +
|}
 +
</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 UARTSerialDeviceTransmit(UART:PUARTDevice):LongWord;</pre>
 +
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' Write data to a UART device from the transmit buffer of the associated Serial device</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
 +
Caller must hold the lock on the serial device which owns the UART
 +
|-
 +
|}
 +
</div></div>
 +
<br />
  
 
Return to [[Unit_Reference|Unit Reference]]
 
Return to [[Unit_Reference|Unit Reference]]

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