Donny9 opened a new pull request, #17746:
URL: https://github.com/apache/nuttx/pull/17746

   
   ## Summary
   
   This commit adds a new lower-half driver implementation for I2C bit-bang 
that uses IO expander pins as the GPIO backend, enabling I2C bit-bang 
functionality on systems where direct GPIO access is not available or when I2C 
needs to be implemented using IO expander pins.
   
   Background:
   The existing I2C bit-bang driver (i2c_bitbang.c) provides a generic 
upper-half implementation that requires a platform-specific lower-half to 
control the SDA and SCL GPIO lines. Previously, each platform had to implement 
its own lower-half using direct GPIO access.
   
   Usage Example:
   ```c
   FAR struct ioexpander_dev_s *ioe = /* get IO expander */; FAR struct 
i2c_master_s *i2c;
   
   /* Initialize I2C bit-bang using IO expander pins 10 (SCL) and 11 (SDA) */ 
i2c = i2c_bitbang_ioexpander_initialize(ioe, 10, 11, 0); if (i2c)
     {
       /* Use i2c master device normally */
     }
   ```
   
   ## Impact
   
   This commit introduces a reusable lower-half implementation that:
   - Uses the standard IO expander API (IOEXP_WRITEPIN, IOEXP_READPIN)
   - Configures pins as open-drain outputs for proper I2C operation
   - Provides a simple initialization function that takes:
     * Pointer to IO expander device
     * SCL pin number
     * SDA pin number
     * I2C bus number
   
   ## Testing
   
   test for tc4d9 evb,
   <img width="1040" height="122" alt="image" 
src="https://github.com/user-attachments/assets/4792f8e4-bcda-48ae-9078-9c612611177f";
 />
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to