Component: UART (CAL) (Peripheral CAL)
Author | Matrix TSL |
Version | 2.0 (Release) |
Category | Peripheral CAL |
Contents
UART (CAL) component
CAL = Code Abstraction Layer - Allows one code base to run on a wide range of chips. A low level implementation giving direct access to the UART peripheral. Includes simulation functionality to commmunicate via a COM port or an Injector component. Also includes timestamped logging via the console and Data Recorder trace monitoring support.
Examples
Example showing how to build a component using a CAL component Using CAL Components.
Downloadable macro reference
ControlPin
Allows direct control over the TX and RTS pins
Also allows for reading of the state of the RX and CTS pins.
Only available when the UART is uninitialised.
Parameters
- BYTE Pin
- 0=TX, 1=RX, 2=RTS, 3=CTS
- BYTE State
Return value
UpdateBaud
Changes the UART Baud rate.
0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200
Parameters
- BYTE new_baud
- 0=1200, 1=2400, 2=4800, 3=9600, 4=19200, 5=38400, 6=57600, 7=115200
Return value
- This call does not return a value
TestProperty
A simple macro to allow us to test the value of a single property during runtime.
Parameters
- BYTE Property
- 0=UseTX, 1=UseRX, 2=UseFlowControl
Return value
Receive
Receive a Character
Parameters
- BYTE Timeout
- Period to wait for the character to be received
Return value
Send
Send the Character
Parameters
- UINT Char
- The Character to send
Return value
- This call does not return a value
Init
Initialize the component with the specified properties
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Delay
Software UART Bit Delay
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Uninit
Un-initialize the UART and release the resources
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
GetValue
Get Value of Named property
Parameters
- STRING Name
Return value
GetConsoleHandle
No additional information
Parameters
- This macro has no parameters
Return value
SetValue
set Value of Named property
Parameters
- STRING Name
- STRING Value
Return value
- This call does not return a value
GetList
Gets Named property List
Parameters
- STRING Name
Return value
Property reference
Component Enable
This property is of type True or false and can be referenced with the variable name UseUART.
A global flag to enable or disable the UART component from producing code.
Useful for generating components with multiple communications options.
Channel
This property is of type Fixed list of ints and can be referenced with the variable name CHANNEL.
UART Channel selector
Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels.
Hardware channels use the selected peripheral on-board the target microcontroller.
Use TX
This property is of type True or false and can be referenced with the variable name UseTX.
Selects if the Transmit pin is used by the component.
Yes: The TX pin is active and used to transmit data for the UART.
No: The TX pin is disabled and free to be used as general I/O.
TX
This property is of type Single digital pin and can be referenced with the variable name TX.
Pin to be used for Transmit data
Use RX
This property is of type True or false and can be referenced with the variable name UseRX.
Selects if the Receive pin is used by the component.
Yes: The RX pin is active and used to receive data for the UART.
No: The RX pin is disabled and free to be used as general I/O.
RX
This property is of type Single digital pin and can be referenced with the variable name RX.
Pin to be used for Receive data
Use Flow Control
This property is of type Fixed list of ints and can be referenced with the variable name FLOWEN.
Flow Control (Handshake) enable or disable.
On: Two I/O pins are used to control the flow of data in and out of the device.
Off: Flow control is disabled.
Baud Options
This property is of type Fixed list of ints and can be referenced with the variable name BAUD_LIST.
Baud rate option selector
Baud Rate
This property is of type Signed integer and can be referenced with the variable name BAUD.
No additional information
Data Bits
This property is of type Fixed list of ints and can be referenced with the variable name DBITS.
Number of data bits
Return
This property is of type Fixed list of ints and can be referenced with the variable name RETURN.
Return data width from Receive macro.
8-bit data mode always returns a byte ranging from 0-255, 255 could mean a timeout or could be a valid data.
16-bit data mode rereturns 0-255 for valid data, 256 for a timeout, return data must be stored into an INT or UINT variable.
Echo
This property is of type Fixed list of ints and can be referenced with the variable name ECHO.
Automatically echoes back any received data when enabled by re-transmitting the received byte.
Interrupt
This property is of type Fixed list of ints and can be referenced with the variable name INT.
Automatic receive interrupt mode enable or disable.
Used on components such as the GSM or GPS where data can come in at any time.
Software channel is disabled when interrupt is enabled, for interrupt with a software channel use an I/O edge triggered interrupt.
Scope Traces
This property is of type True or false and can be referenced with the variable name ScopeTraces.
Selects if the scope traces are automatically added to the data recorder window or not.
Simulation - draws an approximation of the UART data onto the scope trace.
ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.
Console Data
This property is of type True or false and can be referenced with the variable name ConsoleData.
Selects if the console data is automatically generated or not
Console Columns
This property is of type Unsigned integer and can be referenced with the variable name ConsoleColumns.
Number of characters that can be displayed on a single line of the console.
Data Source
This property is of type Fixed list of ints and can be referenced with the variable name DataSource.
Simulation data source used to allow the component to connect to various remote devices
Nothing - Simulation data is ignored
COM port - Routes the communication data to and from a physical or virtual COM port
Injector - Routes the communication data via a data injector component on the Panel.