#define CONFIG_I2C_START_TIMEOUT 100
/**
- * I2C backend the driver should use.
+ * Check this to disable I2c deprecated API support.
*
- * I2C_BACKEND_BUILTIN: Use (if present) the builtin i2c hardware.
- * I2C_BACKEND_BITBANG: Use the emulated bitbang driver.
- * \see drv/i2c.h for more information.
- *
- * $WIZ$ type = "enum"
- * $WIZ$ value_list = "i2c_backend"
+ * $WIZ$ type = "boolean"
*/
-#define CONFIG_I2C_BACKEND I2C_BACKEND_BUILTIN
+#define CONFIG_I2C_DISABLE_OLD_API 0
/**
* Module logging level.
* \author Daniele Basile <asterix@develer.com>
*/
-#include <hw/hw_cpufreq.h> /* CPU_FREQ */
#include "cfg/cfg_i2c.h"
+#include <hw/hw_cpufreq.h> /* CPU_FREQ */
+
#define LOG_LEVEL I2C_LOG_LEVEL
#define LOG_FORMAT I2C_LOG_FORMAT
#include <compat/twi.h>
+#if !CONFIG_I2C_DISABLE_OLD_API
/* Wait for TWINT flag set: bus is ready */
#define WAIT_TWI_READY do {} while (!(TWCR & BV(TWINT)))
MOD_INIT(i2c);
}
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
+
/*
* New Api
*/
-
-
struct I2cHardware
{
};
#include "i2c.h"
+#include "cfg/cfg_i2c.h"
+
+#if !CONFIG_I2C_DISABLE_OLD_API
+
/**
* Send a sequence of bytes in master transmitter mode
* to the selected slave device through the I2C bus.
return true;
}
-
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
void i2c_genericWrite(struct I2c *i2c, const void *_buf, size_t count)
{
* $WIZ$ module_name = "i2c"
* $WIZ$ module_configuration = "bertos/cfg/cfg_i2c.h"
* $WIZ$ module_hw = "bertos/hw/hw_i2c_bitbang.h"
+ * $WIZ$ module_depends = "i2c_bitbang"
* $WIZ$ module_supports = "not atmega103 and not atmega168 and not at91"
*/
#define i2c_start_r(args...) PP_CAT(i2c_start_r ## _, COUNT_PARMS(args)) (args)
#endif
+
+#if !CONFIG_I2C_DISABLE_OLD_API
/**
* I2C Backends.
* Sometimes your cpu does not have a builtin
* i2c driver or you don't want, for some reason, to
* use that.
* With this you can choose, at compile time, which backend to use.
- *
- * $WIZ$ i2c_backend = "I2C_BACKEND_BUILTIN", "I2C_BACKEND_BITBANG"
*/
#define I2C_BACKEND_BUILTIN 0 ///< Uses cpu builtin i2c driver
#define I2C_BACKEND_BITBANG 1 ///< Uses emulated bitbang driver
int i2c_bitbang_get(bool ack);
/*\}*/
+#ifndef CONFIG_I2C_BACKEND
+#define CONFIG_I2C_BACKEND I2C_BACKEND_BUILTIN
+#endif
+
#if CONFIG_I2C_BACKEND == I2C_BACKEND_BUILTIN
#define i2c_init_0 i2c_builtin_init
#define i2c_start_w_1 i2c_builtin_start_w
bool i2c_send(const void *_buf, size_t count);
bool i2c_recv(void *_buf, size_t count);
+#endif
/*
* I2c new api
#define LM75_ADDRESS_BYTE 0x91
#define LM75_PAD_BYTE 0x0
+
+#if !CONFIG_I2C_DISABLE_OLD_API
+
deg_t lm75_read_1(uint8_t sens_addr)
{
uint8_t data[2];
MOD_CHECK(i2c);
LM75_HW_INIT();
}
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
+
/*
* New API
#define lm75_read(args...) PP_CAT(lm75_read ## _, COUNT_PARMS(args)) (args)
#endif
+#if CONFIG_I2C_DISABLE_OLD_API
+
DEPRECATED deg_t lm75_read_1(uint8_t sens_addr);
DEPRECATED void lm75_init_0(void);
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
+
+
deg_t lm75_read_2(I2c *i2c, uint8_t sens_addr);
void lm75_init_1(I2c *i2c);
#include "pcf8574.h"
+#include "cfg/cfg_i2c.h"
+
#include <cfg/module.h>
#include <drv/i2c.h>
+#if !CONFIG_I2C_DISABLE_OLD_API
INLINE int pcf8574_get_priv(Pcf8574 *pcf)
{
return data;
}
-
/**
* Read PCF8574 \a pcf bit status.
* \return the pins status or EOF on errors.
pcf->addr = addr;
return pcf8574_get_priv(pcf) != EOF;
}
-
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
/*
#ifndef DRV_PCF8574_H
#define DRV_PCF8574_H
+#include "cfg/cfg_i2c.h"
+
#include <cfg/compiler.h>
#include <drv/i2c.h>
#define PCF8574ID 0x40 ///< I2C address
+#if !CONFIG_I2C_DISABLE_OLD_API
+
DEPRECATED int pcf8574_get_1(Pcf8574 *pcf);
DEPRECATED bool pcf8574_put_2(Pcf8574 *pcf, uint8_t data);
DEPRECATED bool pcf8574_init_2(Pcf8574 *pcf, pcf8574_addr addr);
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
int pcf8574_get_2(I2c *i2c, Pcf8574 *pcf);
*
*
* \author Francesco Sacchi <batt@develer.com>
+ * \author Daniele Basile <asterix@develer.com>
*/
#include "tas5706a.h"
#include "hw/hw_tas5706a.h"
#include "cfg/cfg_tas5706a.h"
+#include "cfg/cfg_i2c.h"
#include <cfg/module.h>
#define CH3_VOL_REG 0x0A
#define CH4_VOL_REG 0x0B
+
+#if !CONFIG_I2C_DISABLE_OLD_API
+
static bool tas5706a_send(tas_addr_t addr, const void *buf, size_t len)
{
bool ret = i2c_start_w(TAS_ADDR) && i2c_put(addr) && i2c_send(buf, len);
TAS5706A_SETPOWERDOWN(val);
TAS5706A_SETMUTE(val);
}
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
/*
* New API
*/
-
INLINE bool tas5706a_putc(I2c *i2c, tas_addr_t addr, uint8_t ch)
{
i2c_start_w(i2c, TAS_ADDR, 2, I2C_STOP);
#ifndef DRV_TAS5706A_H
#define DRV_TAS5706A_H
+#include "cfg/cfg_i2c.h"
+
#include <cfg/compiler.h>
#include <drv/i2c.h>
*/
void tas5706a_init_1(I2c *i2c);
+#if !CONFIG_I2C_DISABLE_OLD_API
DEPRECATED void tas5706a_setVolume_2(Tas5706aCh ch, tas5706a_vol_t vol);
DEPRECATED void tas5706a_setLowPower_1(bool val);
DEPRECATED void tas5706a_init_0(void);
+#endif /* !CONFIG_I2C_DISABLE_OLD_API */
#endif /* DRV_TAS5706A_H */