Skip to content

Conversation

@Suke0811
Copy link
Collaborator

@Suke0811 Suke0811 commented Mar 26, 2025

This will add:

  • STM32G431KB variant
  • IoControllerUsbCc in mixin
  • This component will be tested on hardware very soon

The following comments from @ducky64 have been reviewed and should be applied to it

  • PB8 is BOOT0, I think from factory it is configured to sense that pin to determine boot location. I've been handling boot pins inconsistently, but I think the argument should be for that pin to be not allocated by default, like is the case on the stm32f103 model
  • you have a 100uF cap for pwr_cap2, just a tad high for chip level decoupling 🤣
  • you might need more caps, 1x100nF per Vss/Vdd pair (3), 1x 10uF for bulk component-level decupling, 1x1uF for VddA/VssA
  • I2S2.ws is PF0
  • consider renaming dio_tt_model to dio_tta_model
  • analog function name for PA2 is ADC1_IN3, PA3 is ADC1_IN4 (not ADC12)
  • you also have the I2C3 peripheral
  • consider renaming the CAN peripheral 'FDCAN' to be inline with the manufacturer naming
  • tt IOs are rated up to Vdd+0.3 instead of an absolute 3.6 max
  • ftc model is rated for up to 5v absolute, the model is not shared with other IOs
  • DAC signal_out_bound only applies when output buffer on (probably just needs a comment)
  • consider adding USB peripheral mode (USP DP and USB DM)
  • IO pin current ratings are in table 15
  • DAC output impedance is spec'd between 9.6-13.8kOhm
  • ADC input input impedance is not the same as the external input impedance limit
  • for adc_model: ADCs are mostly on TT IOs, which are only tolerant up to Vdd+0.3 (aside from the FTfa and FTa ones, but I would be surprised if in ADC mode they could tolerate up to 5v)
  • consider adding usb power delivery support, I think the CC pins directly connect to the micro, you might need to add a IoControllerUsbCc port type mixin

@Suke0811 Suke0811 requested review from Copilot and ducky64 March 26, 2025 19:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the STM32G431KB microcontroller variant along with a new USB CC mixin to enable USB power delivery support. Key changes include:

  • Addition of the new microcontroller model file with updated pin resources and peripheral mappings.
  • Introduction of the IoControllerUsbCc interface mixin for handling USB CC pins.
  • Updates to module imports and registration for the new microcontroller.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
edg/parts/Microcontroller_Stm32g431.py New microcontroller variant with updated peripheral pin assignments
edg/abstract_parts/IoControllerInterfaceMixins.py Added IoControllerUsbCc mixin for USB power delivery CC support
edg/abstract_parts/init.py Registers the new IoControllerUsbCc mixin
edg/parts/init.py Registers the new STM32G431KB variant
Comments suppressed due to low confidence (2)

edg/parts/Microcontroller_Stm32g431.py:184

  • The string 'PB6,' contains an extraneous comma; consider removing it to simply use 'PB6'.
            PeripheralFixedResource('USBCC', UsbCcPort(DigitalBidir.empty()), { 'cc1': ['PB6,'], 'cc2': ['PB4'] }),

edg/parts/Microcontroller_Stm32g431.py:174

  • [nitpick] Consider renaming the 'FDCAN' peripheral to align with the manufacturer's naming conventions if applicable.
            PeripheralFixedResource('FDCAN', CanControllerPort(DigitalBidir.empty()), { 'tx': ['PA12', 'PB9'], 'rx': ['PA11', 'PB8'] }),

@Suke0811 Suke0811 requested a review from Copilot March 26, 2025 19:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for the STM32G431KB microcontroller variant by adding its dedicated implementation and updating associated system and interface mixins. Key changes include:

  • Adding a new microcontroller variant (Stm32g431kb) and its implementation in edg/parts/Microcontroller_Stm32g431.py.
  • Updating edg/parts/init.py to import the new variant.
  • Adding the IoControllerUsbCc mixin to edg/abstract_parts to support USB CC functionality.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
edg/parts/init.py Import added for the new STM32G431KB variant
edg/parts/Microcontroller_Stm32g431.py Complete implementation of the STM32G431KB microcontroller
edg/abstract_parts/init.py Updated import list to include IoControllerUsbCc
edg/abstract_parts/IoControllerInterfaceMixins.py New mixin class IoControllerUsbCc has been added
Comments suppressed due to low confidence (2)

edg/parts/Microcontroller_Stm32g431.py:174

  • [nitpick] Consider renaming 'FDCAN' to 'CAN' to align with the manufacturer's naming conventions.
            PeripheralFixedResource('FDCAN', CanControllerPort(DigitalBidir.empty()), {

edg/parts/Microcontroller_Stm32g431.py:69

  • [nitpick] Consider directly renaming the variable 'dio_tt_model' to 'dio_tta_model' at the time of its assignment to enhance clarity.
            dio_tta_model = dio_tt_model

Copy link
Collaborator

@ducky64 ducky64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, but a few style issues and one correctness issue (related to current draw).

# Power and ground
self.pwr = self.Port(VoltageSink(
voltage_limits=(1.71, 3.6) * Volt,
current_draw=(0.001, 150.0) * mAmp # table 15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

150mA is a max limit, not the actual draw of the device. Table 21 gives the core running current, which specifies a worst-case max of 44mA (at a toasty 125C) and low of 14nA in sleep mode (Table 32).

At some point it would probably be worth modeling these limits (total current into device pins, total IO current), but we don't currently.

)
dac_model = AnalogSource.from_supply(
self.gnd, self.pwr,
# signal_out_bound=(0.2*Volt, -0.2*Volt), signal_out_bound only applies when output buffer on
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code is generally discouraged style-wise. Consider just leaving the bound in there (as a safe bound) and having a comment that it only applies in a specific case.

'sck': ['PB13', 'PF1'], 'ws': ['PB12', 'PF0'], 'sd': ['PA11', 'PB15']
}),
PeripheralFixedResource('I2S3', I2sController(DigitalBidir.empty()), {
'sck': ['PB3', ], 'ws': ['PA4', 'PA15'], 'sd': ['PB5']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'sck': ['PB3', ], 'ws': ['PA4', 'PA15'], 'sd': ['PB5']
'sck': ['PB3'], 'ws': ['PA4', 'PA15'], 'sd': ['PB5']

style nit

"apply_defaults_to_fp_shapes": false,
"apply_defaults_to_fp_text": false,
"board_outline_line_width": 0.0381,
"board_outline_line_width": 0.038099999999999995,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't be changed since it's not relevant to this PR - can you revert it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped this commit, hence creating a new PR

@Suke0811 Suke0811 mentioned this pull request Mar 29, 2025
4 tasks
@Suke0811
Copy link
Collaborator Author

Moved to #401

@Suke0811 Suke0811 closed this Mar 29, 2025
Suke0811 added a commit that referenced this pull request Mar 31, 2025
This is the same as #400, but it removed the accidental commit/push of
EspLora.
Also applies the fix to the comments. 

- [x]
#400 (comment)
- [x]
#400 (comment)
- [x]
#400 (comment)
- [x]
#400 (comment)
@Suke0811 Suke0811 deleted the stm32g4 branch March 31, 2025 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants