Skip to content

Commit 2781322

Browse files
committed
README.md updated
1 parent 7cd1b29 commit 2781322

File tree

2 files changed

+149
-3
lines changed

2 files changed

+149
-3
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: loboris
2+
custom: https://www.paypal.me/BLovosevic

README.md

Lines changed: 147 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,158 @@
66

77
This project shows how to use **GD32VF103** board as USBtoUART bridge.
88

9-
The project is intended to be run on **Longan Nano** board. If testing on another board (without a display), edit the source files to remove display support.
9+
> The project is intended to be run on **Longan Nano** board.<br>
10+
> If testing on another board (without a display), edit `lib/usbcdc/include/cdc_acm_core.h` to remove display and/or LED support.
1011
11-
Features:
12+
### Features:
1213

1314
* The project implements USB CDC/ACM device with some additional features.
1415
* Bridging USB to **two** UARTS is supported.
1516
* Display support, displays status and statictics.
1617
* Baudrates from 2400 ~ 4000000 Bd are supported
1718
* Python CDC driver with examples included
1819

19-
_More information soon..._
20+
### Pins used for UARTs:
21+
22+
**UART0**:
23+
* `PA9 Tx`
24+
* `PA10 Rx`
25+
* `PA13 RTS`
26+
* `PA14 DTR`
27+
28+
**UART1**:
29+
* `PB10 Tx`
30+
* `PB11 Rx`
31+
* `PB13 RTS`
32+
* `PB14 DTR`
33+
34+
### Details
35+
36+
After the board is connected to PC it will be enumerated as USB device `28e9:018a`.
37+
```
38+
Bus 003 Device 028: ID 28e9:018a
39+
Device Descriptor:
40+
bLength 18
41+
bDescriptorType 1
42+
bcdUSB 2.00
43+
bDeviceClass 2 Communications
44+
bDeviceSubClass 0
45+
bDeviceProtocol 0
46+
bMaxPacketSize0 64
47+
idVendor 0x28e9
48+
idProduct 0x018a
49+
bcdDevice 1.00
50+
iManufacturer 1 GigaDevice
51+
iProduct 2 GD32VF USB CDC ACM in FS Mode
52+
iSerial 3 GD32VF-3.0.0-012020
53+
bNumConfigurations 1
54+
...
55+
```
56+
57+
The device can be accessed for serial communication as `/dev/ttyACMn`, for example via Minicom, Putty etc.
58+
```
59+
[24377.013615] usb 3-9: new full-speed USB device number 28 using xhci_hcd
60+
[24377.167007] usb 3-9: New USB device found, idVendor=28e9, idProduct=018a, bcdDevice= 1.00
61+
[24377.167011] usb 3-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3
62+
[24377.167013] usb 3-9: Product: GD32VF USB CDC ACM in FS Mode
63+
[24377.167015] usb 3-9: Manufacturer: GigaDevice
64+
[24377.167017] usb 3-9: SerialNumber: GD32VF-3.0.0-012020
65+
[24377.168506] cdc_acm 3-9:1.0: ttyACM0: USB ACM device
66+
```
67+
68+
As the device has some non-standard CDC features, it is recommended to use it via the provided Python driver `cdc_driver.py`.
69+
70+
### Switching UARTS
71+
72+
GD32VF103 does not have enough USB endpoints to implement a composite CDC device.<br>
73+
The UART ports can be changed using one of two methods:
74+
* sending a `break` condition, this is usually used from standard communication program
75+
* sending a special CDC command, this is fully supported and described in `cdc_driver.py`
76+
77+
### Notes
78+
79+
If _Longan Nano_ is used and `USE_LEDS` enabled in configuration, green LED will be active when `UART1` is selected.
80+
81+
If _Longan Nano_ is used and `USE_DISPLAY` enabled in configuration, UART format and DTR/RTS status will be shown on display.<br>
82+
Special CDC command can be used to display the communication statistics (USB number of sent/received bytes, UART number of sent/received byted, number of UART receive errors,...).
83+
84+
DTR and RTS outputs can be configured as push-pull or open colector (`UARTn_RTS_DTR_MODE` define in `lib/usbcdc/include/cdc_acm_core.h`).
85+
86+
Using `break` for UART change can be disabled/enabled using `UART_USE_BREAK_TO_CHANGE` define in `lib/usbcdc/include/cdc_acm_core.h`.
87+
88+
<br>
89+
90+
### Functions supported in `cdc_driver.py`:
91+
```python
92+
# -------------------------------------------------------
93+
# Show the current status on the device display (if used)
94+
# If the 'reset' argument id 1, reset the counters
95+
# -------------------------------------------------------
96+
showStatus(reset = 0)
97+
98+
# -----------------------------------
99+
# Set DTR and RTS line state
100+
# -----------------------------------
101+
setLineState(dtr=1, rts=1)
102+
103+
# ------------------------------------------------------
104+
# Set active device UART, 0 or 1 can be used as argument
105+
# ------------------------------------------------------
106+
setUART(uartno=0)
107+
108+
# -----------------------------------------------------------
109+
# Set the UART communication format
110+
# bdr: baudrate, 2400 - 4000000
111+
# bits: 8 or 7
112+
# parity: 0 - None; 2 - Even, 3 - Odd
113+
# stop: number of stop bits; 0 = 1, 1 = 0.5, 2 = 2, 3 = 1.5
114+
# -----------------------------------------------------------
115+
setFormat(bdr=115200, bits=8, parity=0, stop=0)
116+
117+
# ----------------------------------------------------------
118+
# Get the current UART communication format from the device
119+
# If 'prn' argument is True, prints the format
120+
# Returns tuple: (bdr, stop, parity, bits)
121+
# ----------------------------------------------------------
122+
getFormat(prn=False)
123+
124+
# --------------------------------------------
125+
# Get the current transmition status
126+
# If 'prn' argument is True, prints the format
127+
# Returns tuple:
128+
# (
129+
# active_uart,
130+
# dtr_state,
131+
# rts_state,
132+
# usb_sent,
133+
# usb_received,
134+
# uart_sent,
135+
# uart_received,
136+
# uart_receive_errors
137+
# )
138+
# --------------------------------------------
139+
getStatus(prn=False)
140+
141+
# -------------------------------------------------
142+
# Return number of received bytes in receive buffer
143+
# -------------------------------------------------
144+
received()
145+
146+
# ----------------------------------
147+
# Read data from receive buffer
148+
# count: max number of bytes to read
149+
# Returns array of bytes
150+
# ----------------------------------
151+
read(count=1)
152+
153+
# -------------------------------------------------
154+
# Read data from receive buffer converted to string
155+
# count: max number of bytes to read
156+
# -------------------------------------------------
157+
readString(count=1)
158+
159+
# --------------------
160+
# Write data
161+
# --------------------
162+
write(data)
163+
```

0 commit comments

Comments
 (0)