mesa_uart - An example component demonstrating how to access the Hostmot2 UART
loadrt mesa_uart [count=N|names=name1[,name2...]] |
This component creates 16 input and 16 output pins. It transmits {name}.N.tx-bytes on the selected UART every thread cycle and reads up to 16 bytes each cycle out of the receive FIFO and writes the values to the associated output pins. {name}.rx-bytes indicates how many pins have been written to. (pins > rx-bytes simply hold their previous value)
This module uses the names= mode of loadrt declaration to specify which UART instances to enable. A check is included to ensure that the count= option is not used instead.
The component takes parameters in the form of a comma-separated list of UART instance names, for example:
loadrt mesa_uart names=hm2_5i23.0.uart.0,hm2_5i23.0.uart.7
Note that no spaces are allowed in the string unless it is delimited by double quotes.
The UART instance names are printed to the dmesg buffer during the Hostmot2 setup sequence, one for each UART instance included in the bitfile loaded to each installed card during the Hostmot2 setup sequence. Type "dmesg" at the terminal prompt to view the output.
The component exports two functions, send and receive, which need to be added to a realtime thread.
The above example will output data on UART channels 0 and 7 and the pins will have the names of the individual UARTS. (they need not be on the same card, or even the same bus).
Read the documents on "halcompile" for help with writing realtime components: http://linuxcnc.org/docs/html/hal/comp.html
mesa-uart.N.send
(requires a floating-point thread)
mesa-uart.N.receive (requires a
floating-point thread)
mesa-uart.N.tx-data-MM u32 in (MM=00..15)
Data to be transmitted
mesa-uart.N.rx-data-MM u32 out (MM=00..15)
Data received
mesa-uart.N.tx-bytes s32 in
Number of bytes to transmit
mesa-uart.N.rx-bytes s32 out
Number of Bytes received
Andy Pugh andy@bodgesoc.org
GPL