1 """UART Class for NXP LPC4330"""
2 from greatfet import GreatFET
3 from greatfet.interfaces.uart import UART as _UART
6 """Custom UART Class for NXP LPC4330"""
11 PARITY_STUCK_AT_ONE = 3
12 PARITY_STUCK_AT_ZERO = 4
14 # pylint: disable=too-many-arguments
27 self._uart = _UART(self._gf, baud=baudrate, data_bits=bits, stop_bits=stop, parity=parity, uart_number=portid)
29 if flow is not None: # default None
30 raise NotImplementedError(
31 "Parameter '{}' unsupported on GreatFET One".format("flow")
34 # pylint: enable=too-many-arguments
38 self._uart.initialized = False
40 def read(self, nbytes=None):
41 """Read data from UART and return it"""
44 return self._uart.read(nbytes)
46 def readinto(self, buf, nbytes=None):
47 """Read data from UART and into the buffer"""
50 result = self.read(nbytes)
51 for _ in range(nbytes):
56 """Read a single line of data from UART"""
57 out = self.read(nbytes=1)
60 out = self.read(nbytes=1)
65 """Write data from the buffer to UART"""
66 return self._uart.write(buf)