Skip to content

Commit

Permalink
fix wrong usage of variable for pin_direction
Browse files Browse the repository at this point in the history
  • Loading branch information
ftylitak committed Feb 10, 2021
1 parent dec7a16 commit 22fc5e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions microsdi12.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ def __init__(self, pin_txd, pin_rxd, pin_direction=None, uart_bus_id=1):
self.pin_txd = pin_txd
self.pin_rxd = pin_rxd
self.p_tx = Pin(pin_txd, mode=Pin.OUT)
self.p_dir = None
if pin_direction:
self.p_dir = Pin(pin_direction, mode=Pin.OUT)
self.uart = UART(uart_bus_id)

def _send(self, cmd):
self.uart.deinit()
self.p_tx.value(0)
if pin_direction:
if self.p_dir:
self.p_dir.value(1) # set output dir
utime.sleep_us(12500) # send BREAK
self.p_tx.value(1)
Expand All @@ -24,7 +25,7 @@ def _send(self, cmd):
print("SDI12 > [" + cmd + "]")
self.uart.write(cmd) # send command
utime.sleep_us(8333 * len(cmd)) # wait to send command (byte time * command length)
if pin_direction:
if self.p_dir:
self.p_dir.value(0) # output set to read
line = self.uart.readline() # read data from UART
if line:
Expand Down

0 comments on commit 22fc5e5

Please sign in to comment.