Index: UART.py =================================================================== --- UART.py (revision 581) +++ UART.py (working copy) @@ -20,15 +20,28 @@ along with pyBusPirate. If not, see . """ -from .BitBang import BBIO +from .BitBang import BBIO, PinCfg FOSC = (32000000/2) class UARTCfg: OUTPUT_TYPE = 0x10 + OUTPUT_TOTEM = OUTPUT_TYPE # Normal totem-pole output + OUTPUT_OPENC = 0 # Open-collector output + DATABITS = 0x0C + DATA_9N = 0x0C # 9 data, no parity + DATA_8O = 0x08 # 8 data, odd parity + DATA_8E = 0x04 # 8 data, even parity + DATA_8N = 0x00 # 8 data, no parity + STOPBITS = 0x02 + STOP_1 = 0 # One stop bit + STOP_2 = STOPBITS # Two stop bits + POLARITY = 0x01 + RX_NORMAL = 0 # Receive normal polarity + RX_INVERT = POLARITY # Receive inverted polarity class UARTSpeed: _300 = 0b0000 @@ -57,10 +70,14 @@ return self.response() def begin_input(self): - self.port.write("\x04") + self.port.write("\x02") + self.timeout(0.1) + return self.response(1, True) def end_input(self): - self.port.write("\x05") + self.port.write("\x03") + self.timeout(0.1) + return self.response(1, True) def enter_bridge_mode(self): self.port.write("\x0F") @@ -68,7 +85,7 @@ return self.response(1, True) def set_cfg(self, cfg): - self.port.write(0xC0 | cfg) + self.port.write(chr(0x80 | cfg)) self.timeout(0.1) return self.response(1, True)