#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>
* 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)
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)
// Enable I2C
HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_I2EN);
-
- MOD_INIT(i2c);
}
#include <cfg/debug.h>
#include <cfg/macros.h> // BV()
-#include <cfg/module.h>
#include <cpu/detect.h>
#include <cpu/irq.h>
return data;
}
-MOD_DEFINE(i2c);
-
static const I2cVT i2c_lm3s_vt =
{
.start = i2c_lm3s_start,
* 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);
}