Skip to content

Commit c749402

Browse files
committed
Add UART entries for the PocketBeagle (issue #242)
PocketBeagle pins with UART pin mode: P1_30 uart0_txd P1_32 uart0_rxd P2_11 uart1_rxd P2_09 uart1_txd P1_08 uart2_rxd P1_10 uart2_txd P2_29 uart3_txd Available UART names on PocketBeagle: PB-UART0: /dev/ttyO0, Rx: P1_30, Tx: P1_32 PB-UART1: /dev/ttyO1, Rx: P2_11, Tx: P2_09 PB-UART2: /dev/ttyO2, Rx: P1_08, Tx: P1_10 PB-UART3: /dev/ttyO3, Rx: P2_29, Tx: none Signed-off-by: Drew Fustini <drew@pdp7.com>
1 parent 829f97a commit c749402

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ if ser.isOpen():
206206
ser.write("Hello World!")
207207
ser.close()
208208
```
209+
* Available UART names on BeagleBone
210+
* `UART1`: /dev/ttyO1, Rx: P9_26, Tx: P9_24
211+
* `UART2`: /dev/ttyO2, Rx: P9_22, Tx: P9_21
212+
* `UART3`: /dev/ttyO3, Rx: P9_42, Tx: none
213+
* `UART4`: /dev/ttyO4, Rx: P9_11, Tx: P9_13
214+
* `UART5`: /dev/ttyO5, Rx: P8_38, Tx: P8_37
215+
* note: `UART5` requires `disable_uboot_overlay_video=1` in `/boot/uEnv.txt`
216+
* Available UART names on PocketBeagle
217+
* `PB-UART0`: /dev/ttyO0, Rx: P1_30, Tx: P1_32
218+
* `PB-UART1`: /dev/ttyO1, Rx: P2_11, Tx: P2_09
219+
* `PB-UART2`: /dev/ttyO2, Rx: P1_08, Tx: P1_10
209220
* [Loopback test with UART1 and UART2](https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart#testing-and-using-the-uart)
210221

211222

source/common.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,24 @@ pins_t table[] = {
263263
{ NULL, NULL, 0, 0, 0 }
264264
};
265265

266+
// Issue #243: UART setup not working for pocket beagle pins
267+
// Add UART entries for the PocketBeagle:
268+
// P1_30 uart0_txd
269+
// P1_32 uart0_rxd
270+
// P2_11 uart1_rxd
271+
// P2_09 uart1_txd
272+
// P1_08 uart2_rxd
273+
// P1_10 uart2_txd
274+
266275
uart_t uart_table[] = {
267276
{ "UART1", "/dev/ttyO1", "ADAFRUIT-UART1", "P9_26", "P9_24"},
268277
{ "UART2", "/dev/ttyO2", "ADAFRUIT-UART2", "P9_22", "P9_21"},
269278
{ "UART3", "/dev/ttyO3", "ADAFRUIT-UART3", "P9_42", ""},
270279
{ "UART4", "/dev/ttyO4", "ADAFRUIT-UART4", "P9_11", "P9_13"},
271280
{ "UART5", "/dev/ttyO5", "ADAFRUIT-UART5", "P8_38", "P8_37"},
281+
{ "PB-UART0", "/dev/ttyO0", "ADAFRUIT-UART0", "P1_30", "P1_32"},
282+
{ "PB-UART1", "/dev/ttyO1", "ADAFRUIT-UART1", "P2_11", "P2_09"},
283+
{ "PB-UART2", "/dev/ttyO2", "ADAFRUIT-UART2", "P1_08", "P1_10"},
272284
{ NULL, NULL, 0, 0, 0 }
273285
};
274286

test/test_uart.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import serial
23
import platform
34

45
import Adafruit_BBIO.UART as UART
@@ -11,7 +12,7 @@ def teardown_module(module):
1112
# ADC.cleanup()
1213

1314

14-
class TestAdc:
15+
class TestUart:
1516
def test_setup_uart_wrong_name(self):
1617
if kernel >= '4.1.0':
1718
pass
@@ -25,9 +26,39 @@ def test_setup_adc(self):
2526
else:
2627
UART.setup("UART1")
2728

28-
def test_setup_adc_multiple(self):
29+
def test_setup_uart_multiple(self):
2930
if kernel >= '4.1.0':
3031
pass
3132
else:
3233
UART.setup("UART1")
3334
UART.setup("UART1")
35+
36+
# test UART entries for the PocketBeagle (issue #243)
37+
def test_pocketbeagle(self):
38+
if kernel < '4.1.0':
39+
pass
40+
value = open('/proc/device-tree/model').read()
41+
if(value.startswith("TI AM335x PocketBeagle")):
42+
uarts = {
43+
'PB-UART0': '/dev/ttyO0',
44+
'PB-UART1': '/dev/ttyO1',
45+
'PB-UART2': '/dev/ttyO2',
46+
}
47+
else:
48+
uarts = {
49+
'UART1': '/dev/ttyO1',
50+
'UART2': '/dev/ttyO2',
51+
'UART4': '/dev/ttyO4'
52+
# note: UART5 requires
53+
# "disable_uboot_overlay_video=1" in /boot/uEnv.txt
54+
#'UART5': '/dev/ttyO5'
55+
}
56+
57+
for name, device in sorted(uarts.items()):
58+
UART.setup(name)
59+
uart = serial.Serial(port = device, baudrate=9600)
60+
uart.close()
61+
uart.open()
62+
if uart.isOpen():
63+
uart.write("hello world".encode("utf-8"))
64+
uart.close()

0 commit comments

Comments
 (0)