Clean up. Remove module check where is unneeded.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jul 2010 10:39:13 +0000 (10:39 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 30 Jul 2010 10:39:13 +0000 (10:39 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/branches/i2c@4095 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/arm/drv/i2c_lpc2.c
bertos/cpu/avr/drv/i2c_avr.c
bertos/cpu/cortex-m3/drv/i2c_lm3s.c
bertos/cpu/cortex-m3/drv/i2c_stm32.c
bertos/drv/i2c.h

index 2a0a2a412ec0d5852094ad9626fc361e0ab19d2e..94de0c208ecd644a1d6b086c00ceb0357cb1ecb9 100644 (file)
 
 #include <cfg/debug.h>
 #include <cfg/macros.h> // BV()
-#include <cfg/module.h>
 
 #include <cpu/detect.h>
 #include <cpu/irq.h>
+#include <cpu/power.h>
 
 #include <drv/timer.h>
 #include <drv/i2c.h>
@@ -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);
 }
index 838d7780dc7bbd2fb58840447824744931b377b7..ebbe5a2938ff50fe04a5f8f6ec869fe3ff974a54 100644 (file)
@@ -452,6 +452,4 @@ void i2c_hw_init(I2c *i2c, int dev, uint32_t clock)
                TWSR = 0;
                TWCR = BV(TWEN);
        );
-
-       MOD_INIT(i2c);
 }
index 04848e5b984fc32a202c944a0d747ad6e93d6294..22777582679ad8cb53f0bab2a84a5c922e518a5e 100644 (file)
@@ -45,7 +45,6 @@
 
 #include <cfg/debug.h>
 #include <cfg/macros.h> // BV()
-#include <cfg/module.h>
 
 #include <cpu/detect.h>
 #include <cpu/irq.h>
@@ -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);
 }
index 97c491abd0234a006f27a51474230f276d4bf598..9fb1217153f3cfc01e77e5b42e48b56b314039c2 100644 (file)
@@ -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);
 }
index 661c87f29a0b3d19301a966ccb9a10638c274551..f0a3ec0dabb9bc445c577cfd97a288c653c465a9 100644 (file)
@@ -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