From b266d1e8fc98258132f79aca886cc0fda8c33f2a Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 30 Jul 2010 10:39:13 +0000 Subject: [PATCH] Clean up. Remove module check where is unneeded. git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4095 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/arm/drv/i2c_lpc2.c | 25 +++++++++++-------------- bertos/cpu/avr/drv/i2c_avr.c | 2 -- bertos/cpu/cortex-m3/drv/i2c_lm3s.c | 5 ----- bertos/cpu/cortex-m3/drv/i2c_stm32.c | 4 ---- bertos/drv/i2c.h | 1 - 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/bertos/cpu/arm/drv/i2c_lpc2.c b/bertos/cpu/arm/drv/i2c_lpc2.c index 2a0a2a41..94de0c20 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) @@ -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); } diff --git a/bertos/cpu/avr/drv/i2c_avr.c b/bertos/cpu/avr/drv/i2c_avr.c index 838d7780..ebbe5a29 100644 --- a/bertos/cpu/avr/drv/i2c_avr.c +++ b/bertos/cpu/avr/drv/i2c_avr.c @@ -452,6 +452,4 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock) TWSR = 0; TWCR = BV(TWEN); ); - - MOD_INIT(i2c); } diff --git a/bertos/cpu/cortex-m3/drv/i2c_lm3s.c b/bertos/cpu/cortex-m3/drv/i2c_lm3s.c index 04848e5b..22777582 100644 --- a/bertos/cpu/cortex-m3/drv/i2c_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/i2c_lm3s.c @@ -45,7 +45,6 @@ #include #include // BV() -#include #include #include @@ -197,8 +196,6 @@ static uint8_t i2c_lm3s_getc(I2c *i2c) return data; } -MOD_DEFINE(i2c); - static const I2cVT i2c_lm3s_vt = { .start = i2c_lm3s_start, @@ -256,6 +253,4 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock) * to the desired clock, never greater. */ HWREG(i2c->hw->base + I2C_O_MTPR) = ((CPU_FREQ + (2 * 10 * clock) - 1) / (2 * 10 * clock)) - 1; - - MOD_INIT(i2c); } diff --git a/bertos/cpu/cortex-m3/drv/i2c_stm32.c b/bertos/cpu/cortex-m3/drv/i2c_stm32.c index 97c491ab..9fb12171 100644 --- a/bertos/cpu/cortex-m3/drv/i2c_stm32.c +++ b/bertos/cpu/cortex-m3/drv/i2c_stm32.c @@ -317,8 +317,6 @@ struct I2cHardware i2c_stm32_hw[] = }, }; -MOD_DEFINE(i2c); - /** * Initialize I2C module. */ @@ -352,6 +350,4 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock) i2c->hw->base->TRISE |= (CR2_FREQ_36MHZ + 1); i2c->hw->base->CR1 |= CR1_PE_SET; - - MOD_INIT(i2c); } diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index 661c87f2..f0a3ec0d 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -327,7 +327,6 @@ INLINE void i2c_init_3(I2c *i2c, int dev, uint32_t clock) i2c_hw_bitbangInit(i2c, dev); else i2c_hw_init(i2c, dev, clock); - } #endif -- 2.25.1