Skip to content

Patch for i2c driver to support sht21 sensors #211

Closed
@oliverju

Description

@oliverju

The bcm2708 default clock stretching timeout is too short to allow waiting for conversions of sht21. Without this patch accesses to the sensor would result in an I/O-Error.

--- a/i2c-bcm2708.c
+++ b/i2c-bcm2708.c
@@ -151,6 +151,8 @@ static inline void bcm2708_bsc_setup(struct bcm2708_i2c *bi)
u32 cdiv;
u32 c = BSC_C_I2CEN | BSC_C_INTD | BSC_C_ST | BSC_C_CLEAR_1;

  •   u32 clkt;
    
    • bus_hz = clk_get_rate(bi->clk);
      cdiv = bus_hz / baudrate;

@@ -163,6 +165,11 @@ static inline void bcm2708_bsc_setup(struct bcm2708_i2c *bi
bcm2708_wr(bi, BSC_A, bi->msg->addr);
bcm2708_wr(bi, BSC_DLEN, bi->msg->len);
bcm2708_wr(bi, BSC_C, c);
+

  •   /\* longer clock stretching timeout (needed by sht21), */
    
  •   /\* default timeout is 64 i2c clock cycles (0x40) */
    
  •   clkt = baudrate / 10; /\* set to 100 ms */
    
  •   bcm2708_wr(bi, BSC_CLKT, clkt);
    
    }

Greetings Oliver

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions