dwfpy.protocols.Protocols
- class Protocols(device)[source]
Bases:
objectDigital Protocols module.
Methods
Attributes
Gets the CAN protocol unit.
Gets the I2C protocol unit.
Gets the SPI protocol unit.
Gets the UART protocol unit.
- class CAN(device)[source]
Bases:
objectCAN protocol.
- property inverted: bool
Gets or sets the polarity.
- Return type
bool
- property pin_rx: int
Gets or sets the DIO channel to use for reception.
- Return type
int
- property pin_tx: int
Gets or sets the DIO channel to use for transmission.
- Return type
int
- property rate: float
Gets or sets the data rate.
- Return type
float
- read()[source]
Returns the received CAN frames since the last call.
- Return type
Tuple[bytes,int,int,int,int]
- class I2C(device)[source]
Bases:
objectI2C protocol.
- clear()[source]
Verifies and tries to solve eventual bus lockup. Returns true, if the bus is free.
- Return type
bool
- property pin_scl: int
Gets or sets the DIO channel to use for I2C clock.
- Return type
int
- property pin_sda: int
Gets or sets the DIO channel to use for I2C data.
- Return type
int
- property rate: float
Gets or sets the data rate.
- Return type
float
- read(address, bytes_to_read)[source]
Performs an I2C read. Returns (rx_buffer, nak_index).
- Return type
Tuple[bytes,int]
- property read_nak: bool
Gets or sets a value indicating if the last read byte should be acknowledged or not.
- Return type
bool
- setup(pin_scl, pin_sda, rate=None, timeout=None, read_nak=None, stretch=None)[source]
Sets up the I2C configuration.
- Return type
None
- property stretch: bool
Enables or disables clock stretching.
- Return type
bool
- property timeout: float
Gets or sets the time-out.
- Return type
float
- class Spi(device)[source]
Bases:
objectSPI protocol.
- property frequency: float
Gets or sets the DIO channel to use for SPI data.
- Return type
float
- property mode: int
Gets or sets the SPI mode.
- Return type
int
- property msb_first: bool
Gets or sets the bit order for SPI data.
- Return type
bool
- property pin_clock: int
Gets or sets the DIO channel to use for SPI clock.
- Return type
int
- property pin_dq0: int
Gets or sets the DIO channel to use for SPI data.
- Return type
int
- property pin_dq1: int
Gets or sets the DIO channel to use for SPI data.
- Return type
int
- property pin_dq2: int
Gets or sets the DIO channel to use for SPI data.
- Return type
int
- property pin_dq3: int
Gets or sets the DIO channel to use for SPI data.
- Return type
int
- property pin_select: int
Gets or sets the DIO channel to use for SPI clock.
- Return type
int
- read(words_to_receive, dq_mode=None, bits_per_word=8)[source]
Performs a SPI read.
- Return type
Union[bytes,array]
- read_one(dq_mode=None, bits_per_word=8)[source]
Performs a SPI reception of up to 32 bits.
- Return type
None
- set_idle(pin, idle)[source]
Specifies the DQ signal idle output state. DQ2 and DQ3 may be used for alternative purpose like for write protect (should be driven low) or for hold (should be in high impendance).
- Return type
None
- setup(pin_clock, pin_mosi, pin_miso=None, pin_select=None, frequency=None, mode=0, msb_first=True)[source]
Sets up the SPI pin configuration in standard mode.
- Return type
None
- setup_dual(pin_clock, pin_dq0, pin_dq1, pin_select=None, frequency=None, mode=0, msb_first=True)[source]
Sets up the SPI pin configuration in Dual mode.
- Return type
None
- setup_quad(pin_clock, pin_dq0, pin_dq1, pin_dq2, pin_dq3, pin_select=None, frequency=None, mode=0, msb_first=True)[source]
Sets up the SPI pin configuration in Quad mode.
- Return type
None
- setup_three_wire(pin_clock, pin_siso, pin_select=None, frequency=None, mode=0, msb_first=True)[source]
Sets up the SPI pin configuration in Three-wire mode.
- Return type
None
- class Uart(device)[source]
Bases:
objectUART protocol.
- property data_bits: Optional[int]
Gets or sets the number of data bits.
- Return type
Optional[int]
- property inverted: bool
Gets or sets the polarity.
- Return type
bool
- property parity: str
Gets or sets the parity.
- Return type
str
- property pin_rx: Optional[int]
Gets or sets the DIO channel to use for reception.
- Return type
Optional[int]
- property pin_tx: Optional[int]
Gets or sets the DIO channel to use for transmission.
- Return type
Optional[int]
- property rate: float
Gets or sets the baud rate.
- Return type
float
- read(buffer_size=8192)[source]
Returns the received characters since the last call. Returns (rx_buffer, parity).
- Return type
Tuple[bytes,int]
- setup(pin_rx=None, pin_tx=None, rate=9600, data_bits=8, stop_bits=1, parity='n', inverted=False)[source]
Sets up the UART configuration.
- Return type
None
- property stop_bits: float
Gets or sets the number of stop bits.
- Return type
float