X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Farm%2Fdrv%2Fi2c_lpc2.c;h=fd6a9fda45237c4a47d05225e852485b86101ce7;hb=2b74d29e47161c81ee4f055072a63a54310249c8;hp=2a0a2a412ec0d5852094ad9626fc361e0ab19d2e;hpb=953453d9b0d9edecc716ec1e74ca8aeba9d078d2;p=bertos.git diff --git a/bertos/cpu/arm/drv/i2c_lpc2.c b/bertos/cpu/arm/drv/i2c_lpc2.c index 2a0a2a41..fd6a9fda 100644 --- a/bertos/cpu/arm/drv/i2c_lpc2.c +++ b/bertos/cpu/arm/drv/i2c_lpc2.c @@ -44,10 +44,10 @@ #include #include // BV() -#include #include #include +#include #include #include @@ -74,17 +74,18 @@ struct I2cHardware * routine to do in that case. */ #define WAIT_SI(i2c) \ - do { \ - ticks_t start = timer_clock(); \ - while( !(HWREG(i2c->hw->base + I2C_CONSET_OFF) & BV(I2CON_SI)) ) \ - { \ - if (timer_clock() - start > ms_to_ticks(CONFIG_I2C_START_TIMEOUT)) \ + do { \ + ticks_t start = timer_clock(); \ + while( !(HWREG(i2c->hw->base + I2C_CONSET_OFF) & BV(I2CON_SI)) ) \ { \ - LOG_ERR("Timeout SI assert\n"); \ - LOG_ERR("[%08lx]\n", HWREG(i2c->hw->base + I2C_STAT_OFF)); \ - break; \ + if (timer_clock() - start > ms_to_ticks(CONFIG_I2C_START_TIMEOUT)) \ + { \ + LOG_ERR("Timeout SI assert\n"); \ + LOG_ERR("[%08lx]\n", HWREG(i2c->hw->base + I2C_STAT_OFF)); \ + break; \ + } \ + cpu_relax(); \ } \ - } \ } while (0) static void i2c_hw_restart(I2c *i2c) @@ -181,8 +182,6 @@ static uint8_t i2c_lpc2_getc(I2c *i2c) return 0xFF; } -MOD_DEFINE(i2c); - static void i2c_lpc2_start(struct I2c *i2c, uint16_t slave_addr) { if (I2C_TEST_START(i2c->flags) == I2C_START_W) @@ -266,7 +265,7 @@ static const I2cVT i2c_lpc_vt = .read = i2c_genericRead, }; -static const struct I2cHardware i2c_lpc2_hw[] = +static struct I2cHardware i2c_lpc2_hw[] = { { /* I2C0 */ .base = I2C0_BASE_ADDR, @@ -334,6 +333,4 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock) // Enable I2C HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_I2EN); - - MOD_INIT(i2c); }