Skip to content

Add M5Stack Core2 #7854

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

Merged
merged 8 commits into from
Apr 20, 2023
Merged

Add M5Stack Core2 #7854

merged 8 commits into from
Apr 20, 2023

Conversation

CDarius
Copy link

@CDarius CDarius commented Apr 11, 2023

Add baord M5Stack Core2

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

It looks like the AXP192 is used on on the M5 Stick C as well. Is this just the same code, or close? Could you refactor so that the code is in a common place, say in a couple of files in ports/espressif, in a directory or not?

@CDarius
Copy link
Author

CDarius commented Apr 11, 2023

The AXP192 is used in several M5Stack products:

  • Stick C
  • StickC Plus
  • Core2
  • Station

Each of these devices use some AXP192 LDO/GPIO lines in the same way but other lines in different ways. For example all board use DCDC1 for MCU_VDD but only on Core2 LDO3 drive the vibration motors.
It would make sense to create a common AXP192 module that can set LDOs and GPIOs and then for each board create a custom initialization using its functions.

I think it would be nice also to create a custom "pmic" module exposed to python for each of these board. The pmic module then can user the AXP192 functions to control LDOs and GPIOs.

For example the pmic module of M5Stack Core2 will expose a public property to set the vibration motor instensity. Internally it use the AXP192 module to set LDO3 voltage.

It will be convenient to have the pmic module built in the circuitpython firmware, it will control all the board devices: lcd backlight, microphone power supply, speaker power supply, etc..

I'm a very newbby to CircuitPython development. What it would the best way to create the pmic custom module for each board. A c module? Something else?

@dhalbert
Copy link
Collaborator

@CDarius could the AXP code just be written as a CircuitPython library? I don't know how low-level it needs to be. For instance, if a non-espressif board had an AXP192 attached, or the AXP192 were on a breakout, would you just want a library?

There are examples of port-specific modules, such as samd or espulp. Look in ports/*/bindings.

@CDarius
Copy link
Author

CDarius commented Apr 11, 2023

@dhalbert Yes it could be written as CircuitPython python library, AXP192 is just an I2C device with some register that handler LDOs and GPIOs.
The AXP192 must be initialize at boot on M5Stack boards to make them work properly, is not optional. It's possible to achieve this with a CircuitPython library?

@dhalbert
Copy link
Collaborator

The AXP192 must be initialize at boot on M5Stack boards to make them work properly,

Could you explain this in more detail? What makes that necessary compared with just initializing them in code.py?

@CDarius
Copy link
Author

CDarius commented Apr 12, 2023

Could you explain this in more detail? What makes that necessary compared with just initializing them in code.py?

The AXP192 is a power management IC, it handle the board power supply from different sources (battery, usb, m-bus) and power the different on board devices.

For example on Core2 the board_init intialize the built in display but before initiliaze the display board_init need to power up the display via AXP192.
Another example that require a mandatory initialization is on StickC. By default AXP192 charge the StickC LiPo battery with a 780mA current but this is too high, it is mandatory to lower the charging current to 100mA.

For your reference the Core2 schematics

@dhalbert
Copy link
Collaborator

Thanks, got it. So adjusting the power management in, say, boot.py, sounds like it would be a bad idea. It should be done properly, always on startup, because if it's not done, the battery could be charging at a dangerous level, etc. If you can refactor the common code for the AXP192 that would be more elegant and would make updating it easier if things change.

@CDarius CDarius requested a review from dhalbert April 13, 2023 14:20
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks!

@dhalbert dhalbert merged commit 5014ddb into adafruit:main Apr 20, 2023
@CDarius CDarius deleted the m5stack_core2 branch April 21, 2023 07:17
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.

2 participants