Skip to content

Expander CH422G does not work due to missing device registration #337

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

Open
getznerh opened this issue Apr 30, 2025 · 1 comment
Open

Expander CH422G does not work due to missing device registration #337

getznerh opened this issue Apr 30, 2025 · 1 comment

Comments

@getznerh
Copy link

Describe the bug
When yue use the CH422G expander with the build command EXPANDER=ch422g, the dirver will be included in the firmware. When you later init the driver with

            import ch422g # kommt neu von kdschlooser, hat meine Änderung übernommen
            # but we need to create a new device on the bus for the io_expander
            io_expander_device = I2C.Device(I2C_BUS, dev_id=ch422g.I2C_ADDR, reg_bits=ch422g.BITS)
            # Now we need to set the I2C device to the io expander driver
            ch422g.Pin.set_device(io_expander_device)

the function Pin.set_device shout set the device in the base class in io_expander_framework. via the call of "cls._device = device" in the Pin Class of ch422g line 39.
This does not work, possibly due to misfunction in micropython.

When you later on call

            tp_reset_pin =  ch422g.Pin(
                ch422g.EXIO1,  # sets the pin to use on the IO expander
                mode=ch422g.Pin.OUT,  # sets the mode as output
                # 0 if the pin needs to be high to to reset
                # 1 if the state needs to be low to perform a reset
              value=0)
  ```
you will get an error "_device not registered. When you call "        io_expander_framework.Pin.set_device( device)
" instead of "cls._device = device" ther driver is OK.

**Expected behavior**
the device should be registred in the class.

@kdschlosser
Copy link
Collaborator

I will dive into it deeper to see what is going on. it could be MicroPython's internal mechanics not playing nice nice with me...

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

No branches or pull requests

2 participants