Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add I2C target and SPI peripheral ports to IoController base, update SPI and I2C naming #277

Merged
merged 7 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion electronics_abstract_parts/AbstractSpiMemory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, size: RangeLike) -> None:
self.pwr = self.Port(VoltageSink.empty(), [Power])
self.gnd = self.Port(Ground.empty(), [Common])

self.spi = self.Port(SpiSlave.empty())
self.spi = self.Port(SpiPeripheral.empty())
self.cs = self.Port(DigitalSink.empty())

self.size = self.ArgParameter(size)
Expand Down
2 changes: 1 addition & 1 deletion electronics_abstract_parts/AbstractTestPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class I2cTestPoint(TypedTestPoint, Block):
"""Two test points for I2C SDA and SCL"""
def __init__(self):
super().__init__()
self.io = self.Port(I2cSlave(DigitalBidir.empty()), [InOut])
self.io = self.Port(I2cTarget(DigitalBidir.empty()), [InOut])
self.tp_scl = self.Block(DigitalTestPoint())
self.connect(self.tp_scl.io, self.io.scl)
self.tp_sda = self.Block(DigitalTestPoint())
Expand Down
14 changes: 10 additions & 4 deletions electronics_abstract_parts/IdealIoController.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class IdealIoController(IoControllerDac, IoControllerCan, IoControllerUsb, IoCon
def __init__(self) -> None:
super().__init__()
self.generator_param(self.adc.requested(), self.dac.requested(), self.gpio.requested(), self.spi.requested(),
self.i2c.requested(), self.uart.requested(), self.usb.requested(), self.can.requested(),
self.i2s.requested())
self.spi_peripheral.requested(), self.i2c.requested(), self.i2c_target.requested(),
self.uart.requested(), self.usb.requested(), self.can.requested(), self.i2s.requested())

def generate(self) -> None:
self.pwr.init_from(VoltageSink(
Expand Down Expand Up @@ -48,10 +48,16 @@ def generate(self) -> None:

self.spi.defined()
for elt in self.get(self.spi.requested()):
self.spi.append_elt(SpiMaster(dio_model), elt)
self.spi.append_elt(SpiController(dio_model), elt)
self.spi_peripheral.defined()
for elt in self.get(self.spi_peripheral.requested()):
self.spi_peripheral.append_elt(SpiPeripheral(dio_model), elt)
self.i2c.defined()
for elt in self.get(self.i2c.requested()):
self.i2c.append_elt(I2cMaster(dio_model), elt)
self.i2c.append_elt(I2cController(dio_model), elt)
self.i2c_target.defined()
for elt in self.get(self.i2c_target.requested()):
self.i2c_target.append_elt(I2cTarget(dio_model), elt)
self.uart.defined()
for elt in self.get(self.uart.requested()):
self.uart.append_elt(UartPort(dio_model), elt)
Expand Down
9 changes: 6 additions & 3 deletions electronics_abstract_parts/IoController.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ def __init__(self, *args, **kwargs) -> None:
self.gpio = self.Port(Vector(DigitalBidir.empty()), optional=True)
self.adc = self.Port(Vector(AnalogSink.empty()), optional=True)

self.spi = self.Port(Vector(SpiMaster.empty()), optional=True)
self.i2c = self.Port(Vector(I2cMaster.empty()), optional=True)
self.spi = self.Port(Vector(SpiController.empty()), optional=True)
self.i2c = self.Port(Vector(I2cController.empty()), optional=True)
self.uart = self.Port(Vector(UartPort.empty()), optional=True)

self.spi_peripheral = self.Port(Vector(SpiPeripheral.empty()), optional=True)
self.i2c_target = self.Port(Vector(I2cTarget.empty()), optional=True)

self.io_current_draw = self.Parameter(RangeExpr()) # total current draw for all leaf-level IO sinks

self._io_ports: List[BasePort] = [ # ordered by assignment order, most restrictive should be first
self.adc, self.spi, self.i2c, self.uart, self.gpio]
self.adc, self.spi, self.i2c, self.uart, self.spi_peripheral, self.i2c_target, self.gpio]

def _type_of_io(self, io_port: BasePort) -> Type[Port]:
if isinstance(io_port, Vector):
Expand Down
10 changes: 5 additions & 5 deletions electronics_abstract_parts/MergedBlocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def connected_from(self, *inputs: Port[AnalogLink]) -> 'MergedAnalogSource':
return self


class MergedSpiMaster(DummyDevice, GeneratorBlock):
class MergedSpiController(DummyDevice, GeneratorBlock):
def __init__(self) -> None:
super().__init__()
self.ins = self.Port(Vector(SpiSlave.empty()))
self.out = self.Port(SpiMaster.empty())
self.ins = self.Port(Vector(SpiPeripheral.empty()))
self.out = self.Port(SpiController.empty())
self.generator_param(self.ins.requested())

def generate(self):
Expand All @@ -125,12 +125,12 @@ def generate(self):

self.ins.defined()
for in_request in self.get(self.ins.requested()):
in_port = self.ins.append_elt(SpiSlave.empty(), in_request)
in_port = self.ins.append_elt(SpiPeripheral.empty(), in_request)
self.connect(miso_net, in_port.miso)
self.connect(self.sck_merge.ins.request(in_request), in_port.sck)
self.connect(self.mosi_merge.ins.request(in_request), in_port.mosi)

def connected_from(self, *ins: Port[SpiLink]) -> 'MergedSpiMaster':
def connected_from(self, *ins: Port[SpiLink]) -> 'MergedSpiController':
for in_port in ins:
cast(Block, builder.get_enclosing_block()).connect(in_port, self.ins.request())
return self
2 changes: 1 addition & 1 deletion electronics_abstract_parts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@

from .DummyDevices import DummyPassive, DummyVoltageSource, DummyVoltageSink, DummyDigitalSink, DummyAnalogSink
from .DummyDevices import ForcedVoltageCurrentDraw, ForcedVoltage, ForcedDigitalSinkCurrentDraw
from .MergedBlocks import MergedVoltageSource, MergedDigitalSource, MergedAnalogSource, MergedSpiMaster
from .MergedBlocks import MergedVoltageSource, MergedDigitalSource, MergedAnalogSource, MergedSpiController
2 changes: 1 addition & 1 deletion electronics_lib/AdcSpi_Mcp3201.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self) -> None:
input_threshold_factor=(0.3, 0.7)
)
# Datasheet section 6.2, minimum clock speed
self.spi = self.Port(SpiSlave(dio_model, frequency_limit=(10, 1600)*kHertz))
self.spi = self.Port(SpiPeripheral(dio_model, frequency_limit=(10, 1600) * kHertz))
self.cs = self.Port(dio_model)

def contents(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/AdcSpi_Mcp3561.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self) -> None:
input_threshold_factor=(0.3, 0.7)
)
# Datasheet table 1.1
self.spi = self.Port(SpiSlave(dio_model, frequency_limit=(0, 10)*MHertz)) # note 20MHz for >2.7V DVdd
self.spi = self.Port(SpiPeripheral(dio_model, frequency_limit=(0, 10) * MHertz)) # note 20MHz for >2.7V DVdd
self.cs = self.Port(dio_model)

def contents(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/Camera_Ov2640_Fpc24.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self) -> None:
# formally this is SCCB (serial camera control bus), but is I2C compatible
# https://e2e.ti.com/support/processors-group/processors/f/processors-forum/6092/sccb-vs-i2c
# 0x60 for write, 0x61 for read, translated to the 7-bit address
self.sio = self.Port(I2cSlave(DigitalBidir.empty(), [0x30]))
self.sio = self.Port(I2cTarget(DigitalBidir.empty(), [0x30]))
self.connect(self.sio.scl, self.conn.pins.request('20').adapt_to(dio_model))
self.connect(self.sio.sda, self.conn.pins.request('22').adapt_to(dio_model))

Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/DacSpi_Mcp4901.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self) -> None:
input_threshold_factor=(0.2, 0.7)
)
self.ldac = self.Port(dio_model)
self.spi = self.Port(SpiSlave(dio_model, frequency_limit=(0, 20)*MHertz))
self.spi = self.Port(SpiPeripheral(dio_model, frequency_limit=(0, 20) * MHertz))
self.cs = self.Port(dio_model)

def contents(self) -> None:
Expand Down
8 changes: 4 additions & 4 deletions electronics_lib/Distance_Vl53l0x.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self) -> None:
self.gpio1 = self.Port(gpio_model, optional=True)

# TODO: support addresses, the default is 0x29 though it's software remappable
self.i2c = self.Port(I2cSlave(self._i2c_io_model(self.vss, self.vdd)), [Output])
self.i2c = self.Port(I2cTarget(self._i2c_io_model(self.vss, self.vdd)), [Output])

def contents(self):
super().contents()
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(self) -> None:
self.pwr = self.Port(VoltageSink().empty(), [Power])
self.gnd = self.Port(Ground().empty(), [Common])

self.i2c = self.Port(I2cSlave.empty())
self.i2c = self.Port(I2cTarget.empty())
self.xshut = self.Port(DigitalSink.empty(), optional=True)
self.gpio1 = self.Port(DigitalBidir.empty(), optional=True)

Expand All @@ -103,7 +103,7 @@ def generate(self):
i2c_io_model = self._i2c_io_model(self.gnd, self.pwr)
self.connect(self.i2c.scl, self.conn.pins.request('3').adapt_to(i2c_io_model))
self.connect(self.i2c.sda, self.conn.pins.request('4').adapt_to(i2c_io_model))
self.i2c.init_from(I2cSlave(DigitalBidir.empty(), []))
self.i2c.init_from(I2cTarget(DigitalBidir.empty(), []))

gpio_model = self._gpio_model(self.gnd, self.pwr)
if self.get(self.xshut.is_connected()):
Expand Down Expand Up @@ -144,7 +144,7 @@ def __init__(self, count: IntLike, *, first_xshut_fixed: BoolLike = False):
super().__init__()
self.pwr = self.Port(VoltageSink.empty(), [Power])
self.gnd = self.Port(Ground.empty(), [Common])
self.i2c = self.Port(I2cSlave.empty())
self.i2c = self.Port(I2cTarget.empty())
self.xshut = self.Port(Vector(DigitalSink.empty()))
self.gpio1 = self.Port(Vector(DigitalBidir.empty()), optional=True)

Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/EInk_E2154fs091.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self) -> None:
self.reset = self.Port(DigitalSink.from_bidir(dio_model))
self.dc = self.Port(DigitalSink.from_bidir(dio_model))
self.cs = self.Port(DigitalSink.from_bidir(dio_model))
self.spi = self.Port(SpiSlave(model=dio_model))
self.spi = self.Port(SpiPeripheral(model=dio_model))

# TODO model all these parts, then fix all the Passive connections
self.gdr = self.Port(Passive())
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/EInk_Er_Epd027_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self) -> None:
self.dc = self.Export(self.conn.pins.request('11').adapt_to(din_model), optional=True)
self.csb = self.Export(self.conn.pins.request('12').adapt_to(din_model))

self.spi = self.Port(SpiSlave.empty())
self.spi = self.Port(SpiPeripheral.empty())
self.connect(self.spi.sck, self.conn.pins.request('13').adapt_to(din_model)) # SCL
self.connect(self.spi.mosi, self.conn.pins.request('14').adapt_to(din_model)) # SDA
self.miso_nc = self.Block(DigitalBidirNotConnected())
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/EnvironmentalSensor_Bme680.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self) -> None:
voltage_limit_abs=(-0.3*Volt, self.vddio.voltage_limits.upper()+0.3),
input_threshold_factor=(0.2, 0.8)
)
self.i2c = self.Port(I2cSlave(dio_model, [0x76]))
self.i2c = self.Port(I2cTarget(dio_model, [0x76]))

def contents(self) -> None:
self.footprint(
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/EnvironmentalSensor_Sensirion.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self) -> None:
self.vss, self.vdd,
input_threshold_factor=(0.42, 0.7)
)
self.i2c = self.Port(I2cSlave(dio_model, [0x70]))
self.i2c = self.Port(I2cTarget(dio_model, [0x70]))

def contents(self) -> None:
self.footprint(
Expand Down
10 changes: 5 additions & 5 deletions electronics_lib/Fpga_Ice40up.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self):
super().__init__()
self.pwr = self.Port(VoltageSink.empty(), [Power]) # in practice this can power the target
self.gnd = self.Port(Ground.empty(), [Common]) # TODO pin at 0v
self.spi = self.Port(SpiMaster.empty())
self.spi = self.Port(SpiController.empty())
self.cs = self.Port(DigitalSource.empty())
self.reset = self.Port(DigitalSource.empty())

Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(self, **kwargs) -> None:

# TODO requirements on SPI device frequency
# TODO this is really bidirectional, so this could be either separate ports or split ports
self.spi_config = self.Port(SpiMaster(self._dpio1_model))
self.spi_config = self.Port(SpiController(self._dpio1_model))
self.spi_config_cs = self.Port(self._dpio1_model)

def _system_pinmap(self) -> Dict[str, CircuitPort]: # names consistent with pinout spreadsheet
Expand Down Expand Up @@ -119,8 +119,8 @@ def _io_pinmap(self) -> PinMapUtil:


# hard macros, not tied to any particular pin
i2c_model = I2cMaster(DigitalBidir.empty()) # user I2C, table 4.7
spi_model = SpiMaster(DigitalBidir.empty(), (0, 45)*MHertz) # user SPI, table 4.10
i2c_model = I2cController(DigitalBidir.empty()) # user I2C, table 4.7
spi_model = SpiController(DigitalBidir.empty(), (0, 45) * MHertz) # user SPI, table 4.10

return PinMapUtil([ # names consistent with pinout spreadsheet
PinResource('IOB_0a', {'IOB_0a': pio2_model}),
Expand Down Expand Up @@ -285,7 +285,7 @@ def contents(self):

# this defaults to flash programming, but to use CRAM programming you can swap the
# SDI/SDO pins on the debug probe and disconnect the CS line
self.spi_merge = self.Block(MergedSpiMaster()).connected_from(self.ic.spi_config, self.prog.spi)
self.spi_merge = self.Block(MergedSpiController()).connected_from(self.ic.spi_config, self.prog.spi)
self.connect(self.spi_merge.out, self.mem.spi)
self.connect(self.ic.spi_config_cs, self.prog.cs)
(self.cs_jmp, ), _ = self.chain(self.ic.spi_config_cs, self.Block(DigitalJumper()), self.mem.cs)
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/Fusb302b.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self) -> None:
input_thresholds=(0.51, 1.32)*Volt,
output_thresholds=(0.35, float('inf')) * Volt,
)
self.i2c = self.Port(I2cSlave(i2c_model, [0x22]))
self.i2c = self.Port(I2cTarget(i2c_model, [0x22]))
self.int_n = self.Port(DigitalSingleSource.low_from_supply(self.gnd), optional=True)

def contents(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/Imu_Lsm6ds3trc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self) -> None:
current_limits=(-4, 4)*mAmp,
input_threshold_factor=(0.3, 0.7)
)
self.i2c = self.Port(I2cSlave(dio_model))
self.i2c = self.Port(I2cTarget(dio_model))

dout_model = DigitalSingleSource.low_from_supply(self.gnd)
self.int1 = self.Port(dout_model, optional=True)
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/IoExpander_Pcf8574.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, addr_lsb: IntLike, **kwags) -> None:
voltage_limit_tolerance=(-0.5, 0.5)*Volt,
input_threshold_factor=(0.3, 0.7)
)
self.i2c = self.Port(I2cSlave(i2c_model))
self.i2c = self.Port(I2cTarget(i2c_model))

self.io = self.Port(Vector(DigitalBidir().empty()), optional=True)

Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/Lcd_Qt096t_if09.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self) -> None:
self.rs = self.Export(self.conn.pins.request('4').adapt_to(io_model))
self.cs = self.Export(self.conn.pins.request('8').adapt_to(io_model))

self.spi = self.Port(SpiSlave.empty())
self.spi = self.Port(SpiPeripheral.empty())
self.connect(self.spi.sck, self.conn.pins.request('6').adapt_to(io_model)) # scl
self.connect(self.spi.mosi, self.conn.pins.request('5').adapt_to(io_model)) # sda

Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/LightSensor_Bh1750.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self) -> None:
self.gnd, self.vcc,
input_threshold_factor=(0.3, 0.7)
)
self.i2c = self.Port(I2cSlave(dio_model, [0x23]))
self.i2c = self.Port(I2cTarget(dio_model, [0x23]))

def contents(self) -> None:
self.footprint(
Expand Down
2 changes: 1 addition & 1 deletion electronics_lib/Mag_Qmc5883l.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self) -> None:
voltage_limit_abs=(-0.3*Volt, self.vddio.voltage_limits.upper()+0.3),
input_threshold_factor=(0.3, 0.7)
)
self.i2c = self.Port(I2cSlave(dio_model))
self.i2c = self.Port(I2cTarget(dio_model))
self.drdy = self.Port(DigitalSource.from_bidir(dio_model), optional=True)

self.setp = self.Port(Passive())
Expand Down
10 changes: 8 additions & 2 deletions electronics_lib/Microcontroller_Esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ def _io_pinmap(self) -> PinMapUtil:
dac_model = AnalogSource.from_supply(gnd, pwr) # TODO: no specs in datasheet?!

uart_model = UartPort(DigitalBidir.empty())
spi_model = SpiMaster(DigitalBidir.empty(), (0, 80)*MHertz) # section 4.1.17
i2c_model = I2cMaster(DigitalBidir.empty()) # section 4.1.11, 100/400kHz and up to 5MHz
spi_model = SpiController(DigitalBidir.empty(), (0, 80) * MHertz) # section 4.1.17
spi_peripheral_model = SpiPeripheral(DigitalBidir.empty(), (0, 80) * MHertz)
i2c_model = I2cController(DigitalBidir.empty()) # section 4.1.11, 100/400kHz and up to 5MHz
i2c_target_model = I2cTarget(DigitalBidir.empty())
can_model = CanControllerPort(DigitalBidir.empty()) # aka TWAI
i2s_model = I2sController(DigitalBidir.empty())
dvp8_model = Dvp8Host(DigitalBidir.empty())
Expand Down Expand Up @@ -112,10 +114,14 @@ def _io_pinmap(self) -> PinMapUtil:

PeripheralAnyResource('I2CEXT0', i2c_model),
PeripheralAnyResource('I2CEXT1', i2c_model),
PeripheralAnyResource('I2CEXT0_T', i2c_target_model), # TODO shared resource w/ I2C controller
PeripheralAnyResource('I2CEXT1_T', i2c_target_model), # TODO shared resource w/ I2C controller

# PeripheralAnyResource('SPI', spi_model), # for flash, non-allocatable
PeripheralAnyResource('HSPI', spi_model),
PeripheralAnyResource('VSPI', spi_model),
PeripheralAnyResource('HSPI_P', spi_peripheral_model), # TODO shared resource w/ SPI controller
PeripheralAnyResource('VSPI_P', spi_peripheral_model), # TODO shared resource w/ SPI controller

PeripheralAnyResource('TWAI', can_model),

Expand Down
8 changes: 6 additions & 2 deletions electronics_lib/Microcontroller_Esp32c3.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ def _io_pinmap(self) -> PinMapUtil:
)

uart_model = UartPort(DigitalBidir.empty())
spi_model = SpiMaster(DigitalBidir.empty(), (0, 60)*MHertz) # section 3.4.2, max block in GP master mode
i2c_model = I2cMaster(DigitalBidir.empty()) # section 3.4.4, supporting 100/400 and up to 800 kbit/s
spi_model = SpiController(DigitalBidir.empty(), (0, 60) * MHertz) # section 3.4.2, max block in GP controller mode
spi_peripheral_model = SpiPeripheral(DigitalBidir.empty(), (0, 60) * MHertz)
i2c_model = I2cController(DigitalBidir.empty()) # section 3.4.4, supporting 100/400 and up to 800 kbit/s
i2c_target_model = I2cTarget(DigitalBidir.empty())

return PinMapUtil([ # section 2.2
PinResource('GPIO0', {'GPIO0': self._dio_model, 'ADC1_CH0': adc_model}), # also XTAL_32K_P
Expand All @@ -92,7 +94,9 @@ def _io_pinmap(self) -> PinMapUtil:
# }),
PeripheralAnyResource('U1', uart_model),
PeripheralAnyResource('I2C', i2c_model),
PeripheralAnyResource('I2C_T', i2c_target_model), # TODO shared resource w/ I2C controller
PeripheralAnyResource('SPI2', spi_model),
PeripheralAnyResource('SPI2_P', spi_peripheral_model), # TODO shared resource w/ SPI controller
PeripheralAnyResource('I2S', I2sController.empty()),
])

Expand Down
12 changes: 9 additions & 3 deletions electronics_lib/Microcontroller_Esp32s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def _io_pinmap(self) -> PinMapUtil:
adc_model = AnalogSink.from_supply(gnd, pwr) # table 4-5, no other specs given

uart_model = UartPort(DigitalBidir.empty()) # section 3.5.5, up to 5Mbps
spi_model = SpiMaster(DigitalBidir.empty(), (0, 80)*MHertz) # section 3.5.2, 80MHz in master, 60MHz in slave
i2c_model = I2cMaster(DigitalBidir.empty()) # section 3.5.6, 100/400kHz and up to 800kbit/s
spi_model = SpiController(DigitalBidir.empty(), (0, 80) * MHertz) # section 3.5.2, 80MHz in controller, 60MHz in peripheral
spi_peripheral_model = SpiPeripheral(DigitalBidir.empty(), (0, 80) * MHertz)
i2c_model = I2cController(DigitalBidir.empty()) # section 3.5.6, 100/400kHz and up to 800kbit/s
i2c_target_model = I2cController(DigitalBidir.empty())
can_model = CanControllerPort(DigitalBidir.empty()) # aka TWAI, up to 1Mbit/s
i2s_model = I2sController(DigitalBidir.empty())
dvp8_model = Dvp8Host(DigitalBidir.empty())
Expand Down Expand Up @@ -119,9 +121,13 @@ def _io_pinmap(self) -> PinMapUtil:
PeripheralAnyResource('U2', uart_model),
PeripheralAnyResource('I2CEXT0', i2c_model),
PeripheralAnyResource('I2CEXT1', i2c_model),
PeripheralAnyResource('I2CEXT0_T', i2c_target_model), # TODO shared resource w/ I2C controller
PeripheralAnyResource('I2CEXT1_T', i2c_target_model), # TODO shared resource w/ I2C controller
# SPI0/1 may be used for (possibly on-chip) flash / PSRAM
PeripheralAnyResource('SPI2', spi_model),
PeripheralAnyResource('SPI3', spi_model),
PeripheralAnyResource('SPI2_P', spi_peripheral_model), # TODO shared resource w/ SPI controller
PeripheralAnyResource('SPI3_P', spi_peripheral_model), # TODO shared resource w/ SPI controller
PeripheralAnyResource('TWAI', can_model),
PeripheralAnyResource('I2S0', i2s_model),
PeripheralAnyResource('I2S1', i2s_model),
Expand Down Expand Up @@ -329,7 +335,7 @@ def _system_pinmap(self) -> Dict[str, CircuitPort]:
def _io_pinmap(self) -> PinMapUtil: # allow the camera I2C pins to be used externally
gnd, pwr = self._gnd_vddio()
return super()._io_pinmap().add([
PeripheralFixedPin('CAM_SCCB', I2cMaster(self._dio_model(gnd, pwr), has_pullup=True), {
PeripheralFixedPin('CAM_SCCB', I2cController(self._dio_model(gnd, pwr), has_pullup=True), {
'scl': '4', 'sda': '3'
})
])
Expand Down
Loading
Loading