From: asterix Date: Fri, 30 Jul 2010 15:34:00 +0000 (+0000) Subject: Remove from wizart i2c backend selection. Add deprecate switch to disable old i2c... X-Git-Tag: 2.6.0~281 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=53a85c63e98a7ec7456db33b665484df3da33fdb;p=bertos.git Remove from wizart i2c backend selection. Add deprecate switch to disable old i2c api support. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4109 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cfg/cfg_i2c.h b/bertos/cfg/cfg_i2c.h index 7df0d097..ea599a81 100644 --- a/bertos/cfg/cfg_i2c.h +++ b/bertos/cfg/cfg_i2c.h @@ -56,16 +56,11 @@ #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. diff --git a/bertos/cpu/avr/drv/i2c_avr.c b/bertos/cpu/avr/drv/i2c_avr.c index ebbe5a29..8e56d135 100644 --- a/bertos/cpu/avr/drv/i2c_avr.c +++ b/bertos/cpu/avr/drv/i2c_avr.c @@ -37,10 +37,11 @@ * \author Daniele Basile */ -#include /* CPU_FREQ */ #include "cfg/cfg_i2c.h" +#include /* CPU_FREQ */ + #define LOG_LEVEL I2C_LOG_LEVEL #define LOG_FORMAT I2C_LOG_FORMAT @@ -59,6 +60,7 @@ #include +#if !CONFIG_I2C_DISABLE_OLD_API /* Wait for TWINT flag set: bus is ready */ #define WAIT_TWI_READY do {} while (!(TWCR & BV(TWINT))) @@ -254,11 +256,11 @@ void i2c_builtin_init(void) MOD_INIT(i2c); } +#endif /* !CONFIG_I2C_DISABLE_OLD_API */ + /* * New Api */ - - struct I2cHardware { }; diff --git a/bertos/drv/i2c.c b/bertos/drv/i2c.c index e54c921e..44798aa9 100644 --- a/bertos/drv/i2c.c +++ b/bertos/drv/i2c.c @@ -37,6 +37,10 @@ #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. @@ -87,7 +91,7 @@ bool i2c_recv(void *_buf, size_t count) return true; } - +#endif /* !CONFIG_I2C_DISABLE_OLD_API */ void i2c_genericWrite(struct I2c *i2c, const void *_buf, size_t count) { diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index 7ce15306..d934497b 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -37,6 +37,7 @@ * $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" */ @@ -63,14 +64,14 @@ #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 @@ -107,6 +108,10 @@ bool i2c_bitbang_put(uint8_t _data); 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 @@ -129,6 +134,7 @@ int i2c_bitbang_get(bool ack); bool i2c_send(const void *_buf, size_t count); bool i2c_recv(void *_buf, size_t count); +#endif /* * I2c new api diff --git a/bertos/drv/lm75.c b/bertos/drv/lm75.c index d1ed17ac..93c6509e 100644 --- a/bertos/drv/lm75.c +++ b/bertos/drv/lm75.c @@ -58,6 +58,9 @@ #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]; @@ -93,6 +96,8 @@ void lm75_init_0(void) MOD_CHECK(i2c); LM75_HW_INIT(); } +#endif /* !CONFIG_I2C_DISABLE_OLD_API */ + /* * New API diff --git a/bertos/drv/lm75.h b/bertos/drv/lm75.h index 9c6abdfc..c1a23bcd 100644 --- a/bertos/drv/lm75.h +++ b/bertos/drv/lm75.h @@ -60,9 +60,14 @@ #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); diff --git a/bertos/drv/pcf8574.c b/bertos/drv/pcf8574.c index 908d3a0e..a94b2b7d 100644 --- a/bertos/drv/pcf8574.c +++ b/bertos/drv/pcf8574.c @@ -45,10 +45,13 @@ #include "pcf8574.h" +#include "cfg/cfg_i2c.h" + #include #include +#if !CONFIG_I2C_DISABLE_OLD_API INLINE int pcf8574_get_priv(Pcf8574 *pcf) { @@ -65,7 +68,6 @@ INLINE int pcf8574_get_priv(Pcf8574 *pcf) return data; } - /** * Read PCF8574 \a pcf bit status. * \return the pins status or EOF on errors. @@ -96,7 +98,7 @@ bool pcf8574_init_2(Pcf8574 *pcf, pcf8574_addr addr) pcf->addr = addr; return pcf8574_get_priv(pcf) != EOF; } - +#endif /* !CONFIG_I2C_DISABLE_OLD_API */ /* diff --git a/bertos/drv/pcf8574.h b/bertos/drv/pcf8574.h index fa327e28..bf2f8e5e 100644 --- a/bertos/drv/pcf8574.h +++ b/bertos/drv/pcf8574.h @@ -41,6 +41,8 @@ #ifndef DRV_PCF8574_H #define DRV_PCF8574_H +#include "cfg/cfg_i2c.h" + #include #include @@ -67,9 +69,12 @@ typedef struct Pcf8574 #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); diff --git a/bertos/drv/tas5706a.c b/bertos/drv/tas5706a.c index 641dc3e7..7719051b 100644 --- a/bertos/drv/tas5706a.c +++ b/bertos/drv/tas5706a.c @@ -34,6 +34,7 @@ * * * \author Francesco Sacchi + * \author Daniele Basile */ #include "tas5706a.h" @@ -41,6 +42,7 @@ #include "hw/hw_tas5706a.h" #include "cfg/cfg_tas5706a.h" +#include "cfg/cfg_i2c.h" #include @@ -63,6 +65,9 @@ typedef uint8_t tas_addr_t; #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); @@ -144,11 +149,11 @@ void tas5706a_setLowPower_1(bool val) 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); diff --git a/bertos/drv/tas5706a.h b/bertos/drv/tas5706a.h index e305694e..0c146ea6 100644 --- a/bertos/drv/tas5706a.h +++ b/bertos/drv/tas5706a.h @@ -44,6 +44,8 @@ #ifndef DRV_TAS5706A_H #define DRV_TAS5706A_H +#include "cfg/cfg_i2c.h" + #include #include @@ -102,9 +104,11 @@ void tas5706a_setLowPower_2(I2c *i2c, bool val); */ 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 */