Skip to content

Commit b727f5b

Browse files
authored
Formatting errors in hm2_pktuart.3.adoc
Fix some formatting errors, and shorten the argument lists for easier reading
1 parent 26fb90d commit b727f5b

1 file changed

Lines changed: 39 additions & 13 deletions

File tree

docs/src/man/man3/hm2_pktuart.3.adoc

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,26 @@ hm2_pktuart - functions to access the Mesa FPGA card packeted UARTs
99

1010
*#include hostmot2-serial.h*
1111

12+
1213
*int hm2_pktuart_setup(char *name, int bitrate, rtapi_s32 tx_mode, rtapi_s32 rx_mode, int txclear, int rxclear)*
14+
1315
*int hm2_pktuart_send(char *name, unsigned char data[], rtapi_u8 *num_frames, rtapi_u16 frame_sizes[])*
16+
1417
*int hm2_pktuart_read(char *name, unsigned char data[], rtapi_u8 *num_frames, rtapi_u16 *max_frame_length, rtapi_u16 frame_sizes[])*
18+
1519
*int hm2_pktuart_queue_get_frame_sizes(char *name, rtapi_u32 fsizes[])*
20+
1621
*int hm2_pktuart_queue_read_data(char *name, rtapi_u32 *data, int bytes)*
22+
1723
*int hm2_pktuart_get_clock(char *name)*
24+
1825
*int hm2_pktuart_get_version(char *name)*
26+
1927
*rtapi_u32 hm2_pktuart_get_rx_status(char *name)*
28+
2029
*rtapi_u32 hm2_pktuart_get_tx_status(char *name)*
2130

31+
2232
== DESCRIPTION
2333

2434
In this context a "Packeted UART" sends data as a burst of bytes
@@ -33,8 +43,8 @@ Instead interfaxes are created to allow secondary drivers to use them.
3343
In LinuxCNC v2.8 and earlier the PktUART driver was entirely inactive.
3444
In LinuxCNC v2.9 onwards the driver polls the Rx and Tx status registers
3545
every servo thread, and these can be read with the functions
36-
rtapi_u32 hm2_pktuart_get_rx_status(char *name) and
37-
rtapi_u32 hm2_pktuart_get_tx_status(char *name).
46+
rtapi_u32 hm2_pktuart_get_rx_status() and
47+
rtapi_u32 hm2_pktuart_get_tx_status().
3848

3949
=== Acessing the UARTs ===
4050

@@ -58,7 +68,7 @@ You should refer to the Hostmot2 "regmap" file for up-to-date register
5868
setup information. The latest version will normally be found at
5969
http://freeby.mesanet.com/regmap.
6070

61-
You should use the function **hm2_pktuart_get_version(char *name)** to
71+
You should use the function **hm2_pktuart_get_version()** to
6272
check the module version loaded to the FPGA board. This documentation
6373
is valid for Rx v0 / v1 and Tx v0. The return value of the function is
6474
16 * Tx + Rx. If viewed in Hex then 0x01 would indicate Tx v0 and Rx v1
@@ -71,13 +81,14 @@ when read or written.
7181

7282
To configure the UART use
7383

74-
*int hm2_pktuart_setup(char *name, int bitrate, rtapi_s32 tx_mode, rtapi_s32 rx_mode, int txclear, int rxclear)*
84+
*int hm2_pktuart_setup(name, bitrate, tx_mode, rx_mode, txclear, rxclear)*
7585

7686
**bitrate** is simply the bitrate. (eg 9600, 115200 etc).
7787

7888
**txmode** is built up from the following bits (directly copied from the
7989
regmap)
8090

91+
----
8192
Bit 17 Parity enable WO
8293
Bit 18 Odd Parity WO (1=odd, 0=even)
8394
Bits 15..8 InterFrame delay in bit times RW
@@ -88,9 +99,12 @@ regmap)
8899
to start of data transmit. In Clock Low periods RW
89100
Drive enable delay is important to avoid start bit timing errors
90101
at high baud rates in RS-485 (half duplex) modes
102+
----
91103

92104
A reasonable starting value for txmode is **0x00000A20**
93105

106+
----
107+
94108
**rxmode** is built from the following:
95109
96110
Bits 29..22 RX data digital filter (in ClockLow periods)
@@ -102,11 +116,11 @@ A reasonable starting value for txmode is **0x00000A20**
102116
Bit 6 RXMask RO
103117
Bit 3 RXEnable (must be set to receive packets) RW
104118
Bit 2 RXMask Enable (enables input data masking when transmitting) RW
105-
119+
----
106120
For low baudrates **0x3FC0140C** will generally work, but the filter bits
107121
should really be set according to the actual baudrate.
108122

109-
The function **int hm2_pktuart_get_clock(char *name)** is provided to
123+
The function **int hm2_pktuart_get_clock(name)** is provided to
110124
enable calculation of the required filter period. It returns units of Hz.
111125

112126
[Note] It is expected that v2 of Rx will extend the number of bits in
@@ -115,12 +129,15 @@ the filter definition for better behaviour at low bitrates.
115129
=== Direct reads and writes ===
116130

117131
The function:
118-
*int hm2_pktuart_send(char *name, unsigned char data[], rtapi_u8 *num_frames, rtapi_u16 frame_sizes[])*
132+
133+
*int hm2_pktuart_send()*
119134

120135
Will always use the hm2_llio_queue_write function where available.
121136

122137
However:
123-
*int hm2_pktuart_read(char *name, unsigned char data[], rtapi_u8 *num_frames, rtapi_u16 *max_frame_length, rtapi_u16 frame_sizes[])*
138+
139+
*int hm2_pktuart_read()*
140+
124141
Will force an immediate read transaction. It may be used in setup and
125142
teardown code, but should not be called in the realtime functions as
126143
this will cause extra packets to be transmitted.
@@ -132,8 +149,9 @@ In the realtime threads the queued reads and writes should be used. This
132149
means that most transactions will be spread over more than one thread
133150
period.
134151

135-
*rtapi_u32 hm2_pktuart_get_rx_status(char *name)*
136-
*rtapi_u32 hm2_pktuart_get_tx_status(char *name)*
152+
*rtapi_u32 hm2_pktuart_get_rx_status(name)*
153+
154+
*rtapi_u32 hm2_pktuart_get_tx_status(name)*
137155

138156
These functions will always return the latest status from the most
139157
recent data packet from the FPGA. The status should be used to check if
@@ -142,13 +160,18 @@ transmissions.
142160

143161
The Tx status is encoded as:
144162

163+
----
164+
145165
Bit 21 FrameBuffer Has Data RO
146166
Bits 20..16 Frames to send RO
147167
Bit 7 Send busy RO
148168
Bit 4 SCFIFO Error RO
169+
----
149170

150171
The Rx status is:
151172

173+
----
174+
152175
Bit 21 FrameBuffer has data RO
153176
Bits 20..16 Frames received RO
154177
Bit 7 Buffer error (RX idle but data in RX data FIFO) RO
@@ -157,14 +180,15 @@ Bit 5 Parity Error RW
157180
Bit 4 RCFIFO Error RW
158181
Bit 1 Overrun error (no stop bit when expected) (sticky) RW
159182
Bit 0 False Start bit error (sticky) RW
183+
----
160184

161185
Based on the status of the Rx and Tx components reads or writes from the
162186
FPGA can then be set up. This is typically a multi-step process:
163187

164188
1) rxstatus indicates that there are packets of data, but at this point
165189
we need to know how big each packet is (and reading two much or two
166190
little data from the FIFOs will cause problems).
167-
2) Queue a read of the frame sizes. **hm2_pktuart_queue_get_frame_sizes(char *name, rtapi_u32 fsizes[])**
191+
2) Queue a read of the frame sizes. **hm2_pktuart_queue_get_frame_sizes(name, fsizes[])**
168192
On return, the fsizes[] array will have been loaded with the frame sizes
169193
(size in bytes). If fsizes are [8] [7] [6] and you only read 1 frame from
170194
the data FIFO then on the next call to get_frame_sizes the returned array
@@ -173,7 +197,7 @@ would be [7] [6].
173197
latency here, the data is already on the FPGA but we can only know how
174198
much data to request once we know the packet size
175199
4) Queue enough data reads to get all the data frames that the packet
176-
is spread over. **int hm2_pktuart_queue_read_data(char *name, rtapi_u32 *data, int bytes)**
200+
is spread over. **int hm2_pktuart_queue_read_data(name, data, bytes)**
177201
On return the data[] array will have been loaded with enough 32-bit
178202
frames to include "bytes" bytes.
179203
5) Parse the data.
@@ -204,6 +228,8 @@ some steps will have serial-port latency delays it is recommended to use
204228
a state machine in the realtime code where waiting on input is not
205229
possible.
206230

231+
[source, C]
232+
----
207233
int process(void *arg, long period) {
208234
static int state = START;
209235
@@ -261,7 +287,7 @@ int process(void *arg, long period) {
261287
break;
262288
}
263289
}
264-
290+
----
265291

266292

267293
== PINS

0 commit comments

Comments
 (0)