X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fi2c_lm3s.c;fp=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Fi2c_lm3s.c;h=29b120ed0b3904538bf9efd455575099cbb0140b;hb=9184cbe31f8030b5422782e110ce4bd208a1404f;hp=c74a667ed4c320046cbbbd2e00b9a0e155315662;hpb=5f71a5cfc0bd0ef139b754c737c10a299d9110bd;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/i2c_lm3s.c b/bertos/cpu/cortex-m3/drv/i2c_lm3s.c index c74a667e..29b120ed 100644 --- a/bertos/cpu/cortex-m3/drv/i2c_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/i2c_lm3s.c @@ -101,9 +101,10 @@ INLINE bool wait_addrAck(I2c *i2c, uint32_t mode_mask) static void i2c_lm3s_put(I2c *i2c, const uint8_t data) { - if ((i2c->xfer_size == 1) && (i2c->hw->first_send)) + HWREG(i2c->hw->base + I2C_O_MDR) = data; + + if (i2c->hw->first_send) { - HWREG(i2c->hw->base + I2C_O_MDR) = data; HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_RUN | I2C_MCS_START; while( HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); @@ -116,46 +117,18 @@ static void i2c_lm3s_put(I2c *i2c, const uint8_t data) return; } - if (I2C_TEST_STOP(i2c->flags) == I2C_STOP) - { - HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_STOP; - while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); - } - i2c->hw->first_send = false; - return; } else { - HWREG(i2c->hw->base + I2C_O_MDR) = data; - if (i2c->hw->first_send) - { - HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_RUN | I2C_MCS_START; - while( HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); - - if (!wait_addrAck(i2c, I2C_MCS_RUN | I2C_MCS_START)) - { - LOG_ERR("Start timeout\n"); - i2c->errors |= I2C_START_TIMEOUT; - HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_STOP; - while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); - return; - } - - i2c->hw->first_send = false; - return; - } - else - { - HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_RUN; - while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); + HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_RUN; + while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY); + } - if ((i2c->xfer_size == 1) && (I2C_TEST_STOP(i2c->flags) == I2C_STOP)) - { - HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_STOP; - while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); - } - } + if ((i2c->xfer_size == 1) && (I2C_TEST_STOP(i2c->flags) == I2C_STOP)) + { + HWREG(i2c->hw->base + I2C_O_MCS) = I2C_MCS_STOP; + while (HWREG(i2c->hw->base + I2C_O_MCS) & I2C_MCS_BUSY ); } }