konashi.Io package

Submodules

konashi.Io.AIO module

class konashi.Io.AIO.ADCRef(value)

Bases: IntEnum

An enumeration.

DISABLE = 0
REF_1V25 = 1
REF_2V5 = 2
REF_VDD = 3
class konashi.Io.AIO.AIOPinConfig(enabled: bool, direction: AIOPinDirection = AIOPinDirection.INPUT, send_on_change: bool = True)

Bases: Structure

_fields_ = [('direction', <class 'ctypes.c_ubyte'>, 1), ('send_on_change', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 1), ('enabled', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 4)]
_pack_ = 1
direction

Structure/Union member

enabled

Structure/Union member

send_on_change

Structure/Union member

class konashi.Io.AIO.AIOPinControl(control_value: int, transition_duration: int = 0)

Bases: Structure

_fields_ = [('control_value', <class 'ctypes.c_ushort'>), ('transition_duration', <class 'ctypes.c_uint'>)]
_pack_ = 1
control_value

Structure/Union member

transition_duration

Structure/Union member

class konashi.Io.AIO.AIOPinDirection(value)

Bases: IntEnum

An enumeration.

INPUT = 0
OUTPUT = 1
class konashi.Io.AIO.IDACRange(value)

Bases: IntEnum

An enumeration.

DISABLE = 0
RANGE0 = 1
RANGE1 = 2
RANGE2 = 3
RANGE3 = 4
class konashi.Io.AIO.VDACRef(value)

Bases: IntEnum

An enumeration.

DISABLE = 0
REF_1V25 = 3
REF_1V25LN = 1
REF_2V5 = 4
REF_2V5LN = 2
REF_VDD = 5
class konashi.Io.AIO._AIO(konashi)

Bases: _KonashiElementBase

_calc_voltage_for_value(value: int) float
_ntf_cb_config(sender, data)
_ntf_cb_input(sender, data)
_ntf_cb_output(sender, data)
async _on_connect() None
calc_control_value_for_current(current: float) int

Calculate the control value for the wanted current.

Parameters

current (float) – The wanted current in Amperes.

Raises
Returns

The corresponding control value.

Return type

int

calc_control_value_for_voltage(voltage: float) int

Calculate the control value for the wanted voltage.

Parameters

voltage (float) – The wanted voltage in Volts.

Raises
Returns

The corresponding control value.

Return type

int

async config_adc_period(period: float) None

Configure the ADC read period. The valid range is [0.1,25.6] seconds, in steps of 100ms.

Parameters

period (float) – The read period in seconds.

Raises

ValueError – The period is out of range.

async config_adc_ref(ref: ADCRef) None

Configure the ADC voltage reference.

Parameters

ref (ADCRef) – The voltage reference.

async config_idac_range(range: IDACRange) None

Configure the IDAC current range.

Parameters

range (IDACRange) – The current range.

async config_pins(configs: Sequence(Tuple[int, AIOPinConfig])) None

Configure analog pins.

Parameters

configs (Sequence[Tuple[int, AIOPinConfig]]) – The list of pin configurations. For each Tuple: int: A bitmask of the pins to apply the configuration to. AIOPinConfig: The configuration for the specified pins.

async config_vdac_ref(ref: VDACRef) None

Configure the VDAC voltage reference.

Parameters

ref (VDACRef) – The voltage reference.

async control_pins(controls: Sequence(Tuple[int, AIOPinControl])) None

Control analog pins.

Parameters

controls (Sequence[Tuple[int, AIOPinControl]]) – The list of pin controls. For each Tuple: int: A bitmask of the pins to apply the control to. AIOPinControl: The control for the specified pins.

async get_analog_config() _AIOConfig

Get the analog configuration. This holds the configuration of the ADC, VDAC and IDAC.

Returns

The analog configuration.
This class has 4 members:

adc_update_period: The ADC update period. adc_voltage_reference: The ADC voltage reference. vdac_voltage_reference: The VDAC voltage reference. idac_current_step: The IDAC current step.

Return type

AIOConfig

async get_pins_config(pin_bitmask: int) List[AIOPinConfig]

Get the configuration of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the configuration for.

Returns

The configurations of the specified pins.

Return type

List[AIOPinConfig]

async get_pins_control(pin_bitmask: int) List[AIOPinControl]

Get the output control of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the output control for.

Returns

The output control of the specified pins.

Return type

List[AIOPinControl]

async read_pins(pin_bitmask: int) List[int]

Get the input value of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the input value for.

Returns

The input value of the specified pins in Volts.

Return type

List[int]

set_input_cb(notify_callback: Callable[[int, int], None]) None

Set an analog input callback function.

Parameters

notify_callback (Callable[[int, int], None]) – The callback function. The function takes 2 parameters and returns nothing: int: The input pin number. int: The pin input value.

class konashi.Io.AIO._AIOAllConfig

Bases: Structure

_fields_ = [('pin', <class 'konashi.Io.AIO.AIOPinConfig_Array_3'>), ('analog', <class 'konashi.Io.AIO._AIOConfig'>)]
_pack_ = 1
analog

Structure/Union member

pin

Structure/Union member

class konashi.Io.AIO._AIOConfig

Bases: Structure

_fields_ = [('adc_update_period', <class 'ctypes.c_ubyte'>), ('adc_voltage_reference', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('vdac_voltage_reference', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('idac_current_step', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4)]
_pack_ = 1
adc_update_period

Structure/Union member

adc_voltage_reference

Structure/Union member

idac_current_step

Structure/Union member

vdac_voltage_reference

Structure/Union member

class konashi.Io.AIO._AIOPinIn

Bases: Structure

_fields_ = [('valid', <class 'ctypes.c_ubyte'>), ('value', <class 'ctypes.c_ushort'>)]
_pack_ = 1
valid

Structure/Union member

value

Structure/Union member

class konashi.Io.AIO._AIOPinOut

Bases: Structure

_fields_ = [('valid', <class 'ctypes.c_ubyte'>), ('control', <class 'konashi.Io.AIO.AIOPinControl'>)]
_pack_ = 1
control

Structure/Union member

valid

Structure/Union member

class konashi.Io.AIO._AIOPinsIn

Bases: Structure

_fields_ = [('adc_voltage_reference', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('pin', <class 'konashi.Io.AIO._AIOPinIn_Array_3'>)]
_pack_ = 1
adc_voltage_reference

Structure/Union member

pin

Structure/Union member

class konashi.Io.AIO._AIOPinsOut

Bases: Structure

_fields_ = [('idac_current_step', <class 'ctypes.c_ubyte'>, 4), ('vdac_voltage_reference', <class 'ctypes.c_ubyte'>, 4), ('pin', <class 'konashi.Io.AIO._AIOPinOut_Array_3'>)]
_pack_ = 1
idac_current_step

Structure/Union member

pin

Structure/Union member

vdac_voltage_reference

Structure/Union member

konashi.Io.GPIO module

class konashi.Io.GPIO.GPIOPinConfig(direction: GPIOPinDirection, pull: GPIOPinPull = GPIOPinPull.NONE, send_on_change: bool = True)

Bases: Structure

_fields_ = [('function', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('pull_down', <class 'ctypes.c_ubyte'>, 1), ('pull_up', <class 'ctypes.c_ubyte'>, 1), ('wired_fct', <class 'ctypes.c_ubyte'>, 2), ('direction', <class 'ctypes.c_ubyte'>, 1), ('send_on_change', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 2)]
_pack_ = 1
direction

Structure/Union member

function

Structure/Union member

pull_down

Structure/Union member

pull_up

Structure/Union member

send_on_change

Structure/Union member

wired_fct

Structure/Union member

class konashi.Io.GPIO.GPIOPinControl(value)

Bases: IntEnum

An enumeration.

HIGH = 1
LOW = 0
TOGGLE = 2
class konashi.Io.GPIO.GPIOPinDirection(value)

Bases: IntEnum

An enumeration.

DISABLED = 0
INPUT = 1
OPEN_DRAIN = 3
OPEN_SOURCE = 4
OUTPUT = 2
class konashi.Io.GPIO.GPIOPinFunction(value)

Bases: IntEnum

An enumeration.

DISABLED = 0
GPIO = 1
I2C = 3
PWM = 2
SPI = 4
class konashi.Io.GPIO.GPIOPinLevel(value)

Bases: IntEnum

An enumeration.

HIGH = 1
INVALID = 2
LOW = 0
class konashi.Io.GPIO.GPIOPinPull(value)

Bases: IntEnum

An enumeration.

DOWN = 2
NONE = 0
UP = 1
class konashi.Io.GPIO._GPIO(konashi)

Bases: _KonashiElementBase

_ntf_cb_config(sender, data)
_ntf_cb_input(sender, data)
_ntf_cb_output(sender, data)
async _on_connect() None
async config_pins(configs: Sequence(Tuple[int, GPIOPinConfig])) None

Configure GPIO pins.

Parameters

configs (Sequence[Tuple[int, GPIOPinConfig]]) – The list of pin configurations. For each Tuple: int: A bitmask of the pins to apply the configuration to. GPIOPinConfig: The configuration for the specified pins.

Raises

PinUnavailableError – At least one of the specified pins is confgured with a function other than GPIO.

async control_pins(controls: Sequence(Tuple[int, GPIOPinControl])) None

Control GPIO pins.

Parameters

controls (Sequence[Tuple[int, GPIOPinControl]]) – A list of pin controls. For each Tuple: int: A bitmask of the pins to apply the control to. GPIOPinControl: The control for the specified pins.

Raises

PinUnavailableError – At least one pin is not configured as GPIO.

async get_pins_config(pin_bitmask: int) List[GPIOPinConfig]

Get the configuration of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the configuration for.

Returns

The configurations of the specified pins.

Return type

List[GPIOPinConfig]

async get_pins_control(pin_bitmask: int) List[GPIOPinLevel]

Get the output control of the specified pin.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the output control for.

Returns

The output control of the specified pins.

Return type

List[GPIOPinLevel]

async read_pins(pin_bitmask: int) List[GPIOPinLevel]

Get the input value of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the input value for.

Returns

The input value of the specified pins.

Return type

List[GPIOPinLevel]

set_input_cb(notify_callback: Callable[[int, int], None]) None

Set a GPIO input callback function. The callback will also be called if the pin is set as open drain or open source.

Parameters

notify_callback (Callable[[int, int], None]) – The callback function. The function takes 2 parameters and returns nothing: int: The pin number. int: The pin value.

class konashi.Io.GPIO._PinIO

Bases: Structure

_fields_ = [('level', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 3), ('valid', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 3)]
_pack_ = 1
level

Structure/Union member

valid

Structure/Union member

konashi.Io.GPIO._PinsConfig

alias of GPIOPinConfig_Array_8

konashi.Io.GPIO._PinsIO

alias of _PinIO_Array_8

konashi.Io.HardPWM module

class konashi.Io.HardPWM.HardPWMClock(value)

Bases: IntEnum

An enumeration.

CASCADE = 1
HFCLK = 0
class konashi.Io.HardPWM.HardPWMConfig(clock: HardPWMClock, prescale: HardPWMPrescale, top: int)

Bases: Structure

_fields_ = [('prescale', <class 'ctypes.c_ubyte'>, 4), ('clock', <class 'ctypes.c_ubyte'>, 4), ('top', <class 'ctypes.c_ushort'>)]
_pack_ = 1
clock

Structure/Union member

prescale

Structure/Union member

top

Structure/Union member

class konashi.Io.HardPWM.HardPWMPinControl(control_value: int, transition_duration: int = 0)

Bases: Structure

_fields_ = [('control_value', <class 'ctypes.c_ushort'>), ('transition_duration', <class 'ctypes.c_uint'>)]
_pack_ = 1
control_value

Structure/Union member

transition_duration

Structure/Union member

class konashi.Io.HardPWM.HardPWMPrescale(value)

Bases: IntEnum

An enumeration.

DIV1 = 0
DIV1024 = 10
DIV128 = 7
DIV16 = 4
DIV2 = 1
DIV256 = 8
DIV32 = 5
DIV4 = 2
DIV512 = 9
DIV64 = 6
DIV8 = 3
class konashi.Io.HardPWM._Config

Bases: Structure

_fields_ = [('pin', <class 'konashi.Io.HardPWM._HardPWMPinConfig_Array_4'>), ('pwm', <class 'konashi.Io.HardPWM.HardPWMConfig'>)]
_pack_ = 1
pin

Structure/Union member

pwm

Structure/Union member

class konashi.Io.HardPWM._HardPWM(konashi, gpio)

Bases: _KonashiElementBase

_calc_duty_for_control_value(value: int) float
_calc_pwm_config_for_period(period: float) HardPWMConfig
_ntf_cb_config(sender, data)
_ntf_cb_output(sender, data)
async _on_connect() None
calc_control_value_for_duty(duty: float) int

Calculate the control value for the wanted duty.

Parameters

duty (float) – The wanted duty cycle value in %.

Returns

The corresponding control value.

Return type

int

async config_pins(configs: Sequence(Tuple[int, bool])) None

Configure the specified Hardware PWM pins.

Parameters

configs (Sequence[Tuple[int, bool]]) – The list of pin configurations. For each Tuple: int: A bitmask of the pins to apply the configuration to. bool: True to enable, False to disable the specified pins.

Raises

PinUnavailableError – At least one of the specified pins is already configured with another function.

async config_pwm(period: float) None

Configure the Hardware PWM with the given period.

Parameters

period (float) – The period in seconds.

Raises

ValueError – A suitable configuration could not be found for the given period.

async control_pins(controls: Sequence(Tuple[int, HardPWMPinControl])) None

Control Hardware PWM pins.

Parameters

controls (Sequence[Tuple[int, HardPWMPinControl]]) – A list of pin controls. For each Tuple: int: A bitmask of the pins to apply the control to. HardPWMPinControl: The control for the specified pins.

Raises

PinUnavailableError – At least one pin is not configured as a Hardware PWM pin.

async get_pins_config(pin_bitmask: int) List[_HardPWMPinConfig]

Get the configuration of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the configuration for.

Returns

The configurations of the specified pins.

Each class in the list has the following member: enabled: True if the pin is enabled, otherwise False

Return type

List[HardPWMPinConfig]

async get_pins_control(pin_bitmask: int) List[HardPWMPinControl]

Get the output control of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the output control for.

Returns

The output control of the specified pins.

Return type

List[HardPWMPinControl]

async get_pwm_config() HardPWMConfig

Get the current Hardware PWM configuration.

Returns

The Hardware PWM configuration.

Return type

HardPWMConfig

set_transition_end_cb(notify_callback: Callable[[int, float], None]) None

Set a transition end callback function.

Parameters

notify_callback (Callable[[int, float], None]) – The callback function. The function takes 2 parameters and returns nothing: int: The pin number. float: The current duty in %.

class konashi.Io.HardPWM._HardPWMPinConfig

Bases: Structure

_fields_ = [('enabled', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 7)]
_pack_ = 1
enabled

Structure/Union member

konashi.Io.HardPWM._PinsControl

alias of HardPWMPinControl_Array_4

konashi.Io.I2C module

class konashi.Io.I2C.I2CConfig(enable: bool, mode: I2CMode)

Bases: Structure

_fields_ = [('mode', <class 'ctypes.c_ubyte'>, 1), ('enabled', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 6)]
_pack_ = 1
enabled

Structure/Union member

mode

Structure/Union member

class konashi.Io.I2C.I2CMode(value)

Bases: IntEnum

An enumeration.

FAST = 1
STANDARD = 0
class konashi.Io.I2C.I2COperation(value)

Bases: IntEnum

An enumeration.

READ = 1
WRITE = 0
WRITE_READ = 2
class konashi.Io.I2C.I2CResult(value)

Bases: IntEnum

An enumeration.

ARB_LOST = 3
BUS_ERR = 2
DONE = 0
NACK = 1
SW_FAULT = 5
USAGE_FAULT = 4
class konashi.Io.I2C._I2C(konashi, gpio)

Bases: _KonashiElementBase

_ntf_cb_config(sender, data)
_ntf_cb_data_in(sender, data)
async _on_connect() None
async config(config: I2CConfig) None

Configure I2C.

Parameters

config (I2CConfig) – The configuration.

Raises

PinUnavailableError – One of the I2C pins is set to another function.

async get_config() I2CConfig

Get the current I2C configuration

Returns

The I2C configuration.

Return type

I2CConfig

async transaction(operation: I2COperation, address: int, read_len: int, write_data: bytes) Tuple[I2CResult, int, bytes]

Perform an I2C transaction.

Parameters
  • operation (I2COperation) – The transaction operation.

  • address (int) – The I2C slave address (address range is 0x00 to 0x7F).

  • read_len (int) – The length of the data to read (0 to 126 bytes).

  • write_data (bytes) – The data to write (valid length 0 to 124 bytes).

Returns

result, address, bytes.

I2CResult: The transaction result. int: The transaction slave address. bytes: The read data (if there is no read data, the length will be 0).

Return type

Tuple[I2CResult, int, bytes]

Raises

ValueError – The read length or slave address is out of range, or the write data is too long.

konashi.Io.SPI module

class konashi.Io.SPI.SPIConfig(enable: bool, mode: SPIMode = SPIMode.MODE0, endian: SPIEndian = SPIEndian.LSB_FIRST, bitrate: int = 0)

Bases: Structure

_fields_ = [('mode', <class 'ctypes.c_ubyte'>, 2), ('', <class 'ctypes.c_ubyte'>, 1), ('endian', <class 'ctypes.c_ubyte'>, 1), ('', <class 'ctypes.c_ubyte'>, 3), ('enabled', <class 'ctypes.c_ubyte'>, 1), ('bitrate', <class 'ctypes.c_uint'>)]
_pack_ = 1
bitrate

Structure/Union member

enabled

Structure/Union member

endian

Structure/Union member

mode

Structure/Union member

class konashi.Io.SPI.SPIEndian(value)

Bases: IntEnum

An enumeration.

LSB_FIRST = 0
MSB_FIRST = 1
class konashi.Io.SPI.SPIMode(value)

Bases: IntEnum

An enumeration.

MODE0 = 0
MODE1 = 1
MODE2 = 2
MODE3 = 3
class konashi.Io.SPI._SPI(konashi, gpio)

Bases: _KonashiElementBase

_ntf_cb_config(sender, data)
_ntf_cb_data_in(sender, data)
async _on_connect() None
async config(config: SPIConfig) None

Configure the SPI peripheral.

Parameters

config (SPIConfig) – The configuration.

Raises

PinUnavailableError – At least one of the pins is already configured with another function.

async get_config() SPIConfig

Get the current SPI configuration.

Returns

The SPI configuration.

Return type

SPIConfig

async transaction(write_data: bytes) bytes

Perform an SPI transaction.

Parameters

write_data (bytes) – The data to send (length range is [1,127]).

Raises

ValueError – The write data length is out of range.

Returns

The received data (the length should be the same the write data length).

Return type

bytes

konashi.Io.SoftPWM module

class konashi.Io.SoftPWM.SoftPWMControlType(value)

Bases: IntEnum

An enumeration.

DISABLED = 0
DUTY = 1
PERIOD = 2
class konashi.Io.SoftPWM.SoftPWMPinConfig(control_type: SoftPWMControlType, fixed_value: int = 0)

Bases: Structure

_fields_ = [('control_type', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('fixed_value', <class 'ctypes.c_ushort'>)]
_pack_ = 1
control_type

Structure/Union member

fixed_value

Structure/Union member

class konashi.Io.SoftPWM.SoftPWMPinControl(control_value: int, transition_duration: int = 0)

Bases: Structure

_fields_ = [('control_type', <class 'ctypes.c_ubyte'>, 4), ('', <class 'ctypes.c_ubyte'>, 4), ('control_value', <class 'ctypes.c_ushort'>), ('transition_duration', <class 'ctypes.c_uint'>)]
_pack_ = 1
control_type

Structure/Union member

control_value

Structure/Union member

transition_duration

Structure/Union member

konashi.Io.SoftPWM._PinsConfig

alias of SoftPWMPinConfig_Array_4

konashi.Io.SoftPWM._PinsControl

alias of SoftPWMPinControl_Array_4

class konashi.Io.SoftPWM._SoftPWM(konashi, gpio)

Bases: _KonashiElementBase

_ntf_cb_config(sender, data)
_ntf_cb_output(sender, data)
async _on_connect() None
async config_pins(configs: Sequence(Tuple[int, SoftPWMPinConfig])) None

Configure the specified Software PWM pins.

Parameters

configs (Sequence[Tuple[int, SoftPWMPinConfig]]) – The list of pin configurations. For each Tuple: int: A bitmask of the pins to apply the configuration to. SoftPWMPinConfig: The configuration for the specified pins.

Raises

PinUnavailableError – At least one of the specified is already configured with another function.

async control_pins(controls: Sequence(Tuple[int, SoftPWMPinControl])) None

Control Software PWM pins.

Parameters

controls (Sequence[Tuple[int, SoftPWMPinControl]]) – A list of pin controls. For each Tuple: int: A bitmask of the pins to apply the control to. SoftPWMPinControl: The control for the specified pins.

Raises
  • PinUnavailableError – At least one pin is not configured as a Software PWM pin.

  • ValueError – The control value is out of range.

async get_pins_config(pin_bitmask: int) List[SoftPWMPinConfig]

Get the configuration of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the configuration for.

Returns

The configuration of the specified pins.

Return type

List[SoftPWMPinConfig]

async get_pins_control(pin_bitmask: int) List[SoftPWMPinControl]

Get the output control of the specified pins.

Parameters

pin_bitmask (int) – A bitmask of the pins to get the output control for.

Returns

The output control of the specified pins.

Return type

List[SoftPWMPinControl]

set_transition_end_cb(notify_callback: Callable[[int, SoftPWMControlType, int], None]) None

Set a transition end callback function.

Parameters

notify_callback (Callable[[int, SoftPWMControlType, int], None]) – The callback function. The function takes 3 parameters and returns nothing: int: The pin number. SoftPWMControlType: The pins control type. int: The current control value.

konashi.Io.UART module

class konashi.Io.UART.UARTConfig(enable: bool, baudrate: int = 0, parity: UARTParity = UARTParity.NONE, stop_bits: UARTStopBits = UARTStopBits.ONE)

Bases: Structure

_fields_ = [('stop_bits', <class 'ctypes.c_ubyte'>, 2), ('parity', <class 'ctypes.c_ubyte'>, 2), ('', <class 'ctypes.c_ubyte'>, 3), ('enabled', <class 'ctypes.c_ubyte'>, 1), ('baudrate', <class 'ctypes.c_uint'>)]
_pack_ = 1
baudrate

Structure/Union member

enabled

Structure/Union member

parity

Structure/Union member

stop_bits

Structure/Union member

class konashi.Io.UART.UARTParity(value)

Bases: IntEnum

An enumeration.

EVEN = 2
NONE = 0
ODD = 1
class konashi.Io.UART.UARTStopBits(value)

Bases: IntEnum

An enumeration.

HALF = 0
ONE = 1
ONEANDAHALF = 2
TWO = 3
class konashi.Io.UART._UART(konashi)

Bases: _KonashiElementBase

_ntf_cb_config(sender, data)
_ntf_cb_data_in(sender, data)
_ntf_cb_send_done(sender, data)
async _on_connect() None
async config(config: UARTConfig) None

Configure the UART peripheral.

Parameters

config (UARTConfig) – The configuration.

async get_config() UARTConfig

Get the current UART configuration.

Returns

The UART configuration.

Return type

UARTConfig

async send(write_data: bytes) bool

Send UART data.

Parameters

write_data (bytes) – The data to send (length range is [1,127]).

Raises

ValueError – The write data length is out of range.

Returns

True if successful, False otherwise.

Return type

bool

set_data_in_cb(callback: Callable[[bytes], None]) None

Set a callback for received UART data.

Parameters

callback (Callable[[bytes], None]) – The callback. The function takes 1 parameter and return nothing: bytes: The received data.

Module contents

class konashi.Io._Io(konashi)

Bases: object

async _on_connect()
property analog: _AIO

This Konashi devices AIO interface.

property gpio: _GPIO

This Konashi devices GPIO interface.

property hardpwm: _HardPWM

This Konashi devices Hardware PWM interface.

property i2c: _I2C

This Konashi devices I2C interface.

property softpwm: _SoftPWM

This Konashi devices Software PWM interface.

property spi: _SPI

This Konashi devices SPI interface.

property uart: _UART

This Konashi devices UART interface.