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

Clean up microcontrollers #289

Merged
merged 2 commits into from
Sep 5, 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
8 changes: 4 additions & 4 deletions electronics_lib/Microcontroller_Esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _io_pinmap(self) -> PinMapUtil:


@abstract_block
class Esp32_Base(Esp32_Ios, IoController, InternalSubcircuit, GeneratorBlock):
class Esp32_Base(Esp32_Ios, InternalSubcircuit, GeneratorBlock):
"""Base class for ESP32 series microcontrollers with WiFi and Bluetooth (classic and LE)

Chip datasheet: https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf
Expand All @@ -144,8 +144,8 @@ class Esp32_Base(Esp32_Ios, IoController, InternalSubcircuit, GeneratorBlock):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.pwr.init_from(self._vdd_model())
self.gnd.init_from(Ground())
self.pwr = self.Port(self._vdd_model(), [Power])
self.gnd = self.Port(Ground(), [Common])

dio_model = self._dio_model(self.pwr, self.gnd)
self.chip_pu = self.Port(dio_model) # power control, must NOT be left floating, table 1
Expand Down Expand Up @@ -173,7 +173,7 @@ def _system_pinmap(self) -> Dict[str, CircuitPort]:
}).remap(self.SYSTEM_PIN_REMAP)


class Esp32_Wroom_32_Device(IoControllerPowerRequired, Esp32_Base, FootprintBlock, JlcPart):
class Esp32_Wroom_32_Device(Esp32_Base, FootprintBlock, JlcPart):
"""ESP32-WROOM-32 module

Module datasheet: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
Expand Down
8 changes: 4 additions & 4 deletions electronics_lib/Microcontroller_Esp32c3.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Esp32c3_Interfaces(IoControllerSpiPeripheral, IoControllerI2cTarget, IoCon


@abstract_block
class Esp32c3_Base(Esp32c3_Interfaces, InternalSubcircuit, IoControllerPowerRequired, BaseIoControllerPinmapGenerator):
class Esp32c3_Base(Esp32c3_Interfaces, InternalSubcircuit, BaseIoControllerPinmapGenerator):
"""Base class for ESP32-C3 series devices, with RISC-V core, 2.4GHz WiF,i, BLE5.
PlatformIO: use board ID esp32-c3-devkitm-1

Expand All @@ -21,11 +21,11 @@ class Esp32c3_Base(Esp32c3_Interfaces, InternalSubcircuit, IoControllerPowerRequ
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.pwr.init_from(VoltageSink(
self.pwr = self.Port(VoltageSink(
voltage_limits=(3.0, 3.6)*Volt, # section 4.2
current_draw=(0.001, 335)*mAmp + self.io_current_draw.upper() # section 4.6, from power off to RF active
))
self.gnd.init_from(Ground())
), [Power])
self.gnd = self.Port(Ground(), [Common])

self._dio_model = DigitalBidir.from_supply( # table 4.4
self.gnd, self.pwr,
Expand Down
8 changes: 4 additions & 4 deletions electronics_lib/Microcontroller_Esp32s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _io_pinmap(self) -> PinMapUtil:


@abstract_block
class Esp32s3_Base(Esp32s3_Ios, IoControllerPowerRequired, InternalSubcircuit, GeneratorBlock):
class Esp32s3_Base(Esp32s3_Ios, InternalSubcircuit, GeneratorBlock):
"""Base class for ESP32-S3 series microcontrollers with WiFi and Bluetooth (classic and LE)
and AI acceleration

Expand All @@ -165,16 +165,16 @@ def _system_pinmap(self) -> Dict[str, CircuitPort]:
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.pwr.init_from(self._vdd_model())
self.gnd.init_from(Ground())
self.pwr = self.Port(self._vdd_model(), [Power])
self.gnd = self.Port(Ground(), [Common])

dio_model = self._dio_model(self.gnd, self.pwr)
self.chip_pu = self.Port(dio_model) # table 2-5, power up/down control, do NOT leave floating
self.io0 = self.Port(dio_model, optional=True) # table 2-11, default pullup (SPI boot), set low to download boot
self.uart0 = self.Port(UartPort(dio_model), optional=True) # programming


class Esp32s3_Wroom_1_Device(Esp32s3_Base, IoControllerPowerRequired, FootprintBlock, JlcPart):
class Esp32s3_Wroom_1_Device(Esp32s3_Base, FootprintBlock, JlcPart):
SYSTEM_PIN_REMAP: Dict[str, Union[str, List[str]]] = {
'VDD': '2',
'GND': ['1', '40', '41'], # 41 is EP
Expand Down
9 changes: 5 additions & 4 deletions electronics_lib/Microcontroller_nRF52840.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@non_library
class Nrf52840_Interfaces(IoControllerSpiPeripheral, IoControllerI2cTarget, IoControllerUsb, IoControllerI2s,
IoControllerBle, BaseIoController):
IoControllerBle):
"""Defines base interfaces for nRF52840 microcontrollers"""


Expand Down Expand Up @@ -170,7 +170,7 @@ def _io_pinmap(self) -> PinMapUtil:


@abstract_block
class Nrf52840_Base(Nrf52840_Ios, IoControllerPowerRequired, InternalSubcircuit, GeneratorBlock):
class Nrf52840_Base(Nrf52840_Ios, InternalSubcircuit, GeneratorBlock):
SYSTEM_PIN_REMAP: Dict[str, Union[str, List[str]]] # pin name in base -> pin name(s)

def _gnd_vddio(self) -> Tuple[Port[VoltageLink], Port[VoltageLink]]:
Expand All @@ -187,8 +187,8 @@ def _system_pinmap(self) -> Dict[str, CircuitPort]:
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

self.pwr.init_from(self._vdd_model())
self.gnd.init_from(Ground())
self.pwr = self.Port(self._vdd_model(), [Power])
self.gnd = self.Port(Ground(), [Common])

self.pwr_usb = self.Port(VoltageSink(
voltage_limits=(4.35, 5.5)*Volt,
Expand Down Expand Up @@ -283,6 +283,7 @@ def contents(self):
self.connect(self.reset_node, self.ic.nreset)

def generate(self):
super().generate()
if self.get(self.reset.is_connected()):
self.connect(self.reset, self.ic.nreset)

Expand Down
Loading