From: asterix Date: Mon, 26 Jul 2010 14:07:48 +0000 (+0000) Subject: Clean up. X-Git-Tag: 2.6.0~288^2~26 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=19a950685707ef3071371b10060ec5c310f2357a;p=bertos.git Clean up. git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4069 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/arm/drv/i2c_lpc2.c b/bertos/cpu/arm/drv/i2c_lpc2.c index 1f2e4339..284f345c 100644 --- a/bertos/cpu/arm/drv/i2c_lpc2.c +++ b/bertos/cpu/arm/drv/i2c_lpc2.c @@ -129,17 +129,12 @@ static void i2c_hw_stop(void) static void i2c_lpc2_put(I2c *i2c, uint8_t data) { I2C_DAT = data; - -// kprintf("w %02x\n", data); - I2C_CONCLR = BV(I2CON_SIC); WAIT_SI(); uint32_t status = GET_STATUS(); - //kprintf("w %08lx\n", status); - /* if (status == I2C_STAT_DATA_ACK) */ /* Generate the stop if we finish to send all programmed bytes */ if (i2c->xfer_size == 1) @@ -180,9 +175,6 @@ static uint8_t i2c_lpc2_get(I2c *i2c) uint32_t status = GET_STATUS(); uint8_t data = (uint8_t)(I2C_DAT & 0xFF); -// kprintf("r %02x\n", data); -// kprintf("r %08lx\n", status); - if (status == I2C_STAT_RDATA_ACK) { return data; @@ -230,13 +222,9 @@ static void i2c_lpc2_start(struct I2c *i2c, uint16_t slave_addr) if (status == I2C_STAT_SLAW_ACK) break; - else if (status == I2C_STAT_ARB_LOST) - { - LOG_ERR("Arbitration lost\n"); - i2c->errors |= I2C_ARB_LOST; - i2c_hw_stop(); - break; - } + + if (status == I2C_STAT_ARB_LOST) + goto error; if (timer_clock() - start > ms_to_ticks(CONFIG_I2C_START_TIMEOUT)) { @@ -263,28 +251,26 @@ static void i2c_lpc2_start(struct I2c *i2c, uint16_t slave_addr) WAIT_SI(); status = GET_STATUS(); -/* - if (status == I2C_STAT_SLAR_ACK) - break; -*/ + if (status == I2C_STAT_SLAR_NACK) { LOG_ERR("SLAR NACK:%02x\n", status); i2c->errors |= I2C_NO_ACK; i2c_hw_stop(); } - else if (status == I2C_STAT_ARB_LOST) - { - LOG_ERR("Arbitration lost\n"); - i2c->errors |= I2C_ARB_LOST; - i2c_hw_stop(); - } + + if (status == I2C_STAT_ARB_LOST) + goto error; } else { ASSERT(0); } +error: + LOG_ERR("Arbitration lost\n"); + i2c->errors |= I2C_ARB_LOST; + i2c_hw_stop(); } static const I2cVT i2c_lpc_vt =