static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr,

                          const uint8_t *buf, uint16_t len)

{

    OMAPI2C *s = (OMAPI2C *)i2c;

    uint16_t data;



    omap_i2c_set_slave_addr(s, addr);



    data = len;

    memwrite(s->addr + OMAP_I2C_CNT, &data, 2);



    data = OMAP_I2C_CON_I2C_EN |

           OMAP_I2C_CON_TRX |

           OMAP_I2C_CON_MST |

           OMAP_I2C_CON_STT |

           OMAP_I2C_CON_STP;

    memwrite(s->addr + OMAP_I2C_CON, &data, 2);

    memread(s->addr + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) != 0);



    memread(s->addr + OMAP_I2C_STAT, &data, 2);

    g_assert((data & OMAP_I2C_STAT_NACK) == 0);



    while (len > 1) {

        memread(s->addr + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->addr + OMAP_I2C_DATA, buf, 2);

        buf = (uint8_t *)buf + 2;

        len -= 2;

    }

    if (len == 1) {

        memread(s->addr + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->addr + OMAP_I2C_DATA, buf, 1);

    }



    memread(s->addr + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) == 0);

}

static void omap_i2c_send(I2CAdapter *i2c, uint8_t addr,

                          const uint8_t *buf, uint16_t len)

{

    OMAPI2C *s = (OMAPI2C *)i2c;

    uint16_t data;



    omap_i2c_set_slave_addr(s, addr);



    data = len;

    memwrite(s->addr + OMAP_I2C_CNT, &data, 2);



    data = OMAP_I2C_CON_I2C_EN |

           OMAP_I2C_CON_TRX |

           OMAP_I2C_CON_MST |

           OMAP_I2C_CON_STT |

           OMAP_I2C_CON_STP;

    memwrite(s->addr + OMAP_I2C_CON, &data, 2);

    memread(s->addr + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) != 0);



    memread(s->addr + OMAP_I2C_STAT, &data, 2);

    g_assert((data & OMAP_I2C_STAT_NACK) == 0);



    while (len > 1) {

        memread(s->addr + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->addr + OMAP_I2C_DATA, buf, 2);

        buf = (uint8_t *)buf + 2;

        len -= 2;

    }

    if (len == 1) {

        memread(s->addr + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->addr + OMAP_I2C_DATA, buf, 1);

    }



    memread(s->addr + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) == 0);

}

    memwrite(s->addr + OMAP_I2C_CNT, &data, 2);     memwrite(s->addr + OMAP_I2C_CON, &data, 2);     memread(s->addr + OMAP_I2C_CON, &data, 2);     memread(s->addr + OMAP_I2C_STAT, &data, 2);         memread(s->addr + OMAP_I2C_STAT, &data, 2);         memwrite(s->addr + OMAP_I2C_DATA, buf, 2);         memread(s->addr + OMAP_I2C_STAT, &data, 2);         memwrite(s->addr + OMAP_I2C_DATA, buf, 1);     memread(s->addr + OMAP_I2C_CON, &data, 2);     memwrite(s->addr + OMAP_I2C_CNT, &data, 2);     memwrite(s->addr + OMAP_I2C_CON, &data, 2);     memread(s->addr + OMAP_I2C_CON, &data, 2);     memread(s->addr + OMAP_I2C_STAT, &data, 2);         memread(s->addr + OMAP_I2C_STAT, &data, 2);     memread(s->addr + OMAP_I2C_CON, &data, 2);
static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,

                          const uint8_t *VAR_2, uint16_t VAR_3)

{

    OMAPI2C *s = (OMAPI2C *)VAR_0;

    uint16_t data;



    omap_i2c_set_slave_addr(s, VAR_1);



    data = VAR_3;

    memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2);



    data = OMAP_I2C_CON_I2C_EN |

           OMAP_I2C_CON_TRX |

           OMAP_I2C_CON_MST |

           OMAP_I2C_CON_STT |

           OMAP_I2C_CON_STP;

    memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2);

    memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) != 0);



    memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);

    g_assert((data & OMAP_I2C_STAT_NACK) == 0);



    while (VAR_3 > 1) {

        memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 2);

        VAR_2 = (uint8_t *)VAR_2 + 2;

        VAR_3 -= 2;

    }

    if (VAR_3 == 1) {

        memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2);

        g_assert((data & OMAP_I2C_STAT_XRDY) != 0);



        memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 1);

    }



    memread(s->VAR_1 + OMAP_I2C_CON, &data, 2);

    g_assert((data & OMAP_I2C_CON_STP) == 0);

}

static void FUNC_0(I2CAdapter *VAR_0, uint8_t VAR_1,
const uint8_t *VAR_2, uint16_t VAR_3)
{ OMAPI2C *s = (OMAPI2C *)VAR_0; uint16_t data; omap_i2c_set_slave_addr(s, VAR_1); data = VAR_3; memwrite(s->VAR_1 + OMAP_I2C_CNT, &data, 2); data = OMAP_I2C_CON_I2C_EN |
OMAP_I2C_CON_TRX |
OMAP_I2C_CON_MST |
OMAP_I2C_CON_STT |
OMAP_I2C_CON_STP; memwrite(s->VAR_1 + OMAP_I2C_CON, &data, 2); memread(s->VAR_1 + OMAP_I2C_CON, &data, 2); g_assert((data & OMAP_I2C_CON_STP) != 0); memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2); g_assert((data & OMAP_I2C_STAT_NACK) == 0); while (VAR_3 > 1) { memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2); g_assert((data & OMAP_I2C_STAT_XRDY) != 0); memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 2); VAR_2 = (uint8_t *)VAR_2 + 2; VAR_3 -= 2; } if (VAR_3 == 1) { memread(s->VAR_1 + OMAP_I2C_STAT, &data, 2); g_assert((data & OMAP_I2C_STAT_XRDY) != 0); memwrite(s->VAR_1 + OMAP_I2C_DATA, VAR_2, 1); } memread(s->VAR_1 + OMAP_I2C_CON, &data, 2); g_assert((data & OMAP_I2C_CON_STP) == 0); }