From: asterix Date: Wed, 28 Jul 2010 15:48:28 +0000 (+0000) Subject: Refactor to works with new api. Clean up. X-Git-Tag: 2.6.0~288^2~11 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=9184cbe31f8030b5422782e110ce4bd208a1404f;p=bertos.git Refactor to works with new api. Clean up. git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4084 38d2e660-2303-0410-9eaa-f027e97ec537 --- 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 ); } }