From: batt Date: Mon, 6 Oct 2008 17:21:48 +0000 (+0000) Subject: Merged from external project: X-Git-Tag: 2.0.0~61 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;ds=sidebyside;h=18d992e2630742a2bb49b6f9267515fd8ae6c886;p=bertos.git Merged from external project: ********** r22408 | batt | 2008-10-02 12:09:50 +0200 (Thu, 02 Oct 2008) | 1 line Add low level macros for bitbang i2c. ********** git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1873 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/i2c_bitbang.c b/bertos/drv/i2c_bitbang.c index 7067d919..ef7c9585 100644 --- a/bertos/drv/i2c_bitbang.c +++ b/bertos/drv/i2c_bitbang.c @@ -144,3 +144,16 @@ int i2c_get(bool ack) return (int)(uint8_t)data; } +MOD_DEFINE(i2c); + +/** + * Initialize i2c module. + */ +void i2c_init(void) +{ + I2C_BITBANG_HW_INIT; + SDA_HI; + SCL_HI; + MOD_INIT(i2c); +} + diff --git a/bertos/hw/hw_i2c_bitbang.h b/bertos/hw/hw_i2c_bitbang.h new file mode 100644 index 00000000..e6f0b18e --- /dev/null +++ b/bertos/hw/hw_i2c_bitbang.h @@ -0,0 +1,61 @@ +/** + * \file + * + * + * \brief Macro for I2C bitbang operation. + * + * + * \version $Id$ + * + * \author Francesco Sacchi + */ + +#ifndef HW_I2C_BITBANG_H +#define HW_I2C_BITBANG_H + +#warning TODO:This is an example implementation, you must implement it! + +#define SDA_HI /* Implement me:Set SDA High by setting SDA pin as input */ +#define SDA_LO /* Implement me:Set SDA Low by setting SDA pin as open collector output */ +#define SCL_HI /* Implement me:Set SCL High by setting SCL pin as input */ +#define SCL_LO /* Implement me:Set SCL Low by setting SCL pin as open collector output */ + + +#define SCL_IN (true) /* Implement me: read SDA pin state */ +#define SDA_IN (true) /* Implement me: read SCL pin state */ + +/** + * This macro should set SDA and SCL lines as input. + */ +#define I2C_BITBANG_HW_INIT /* Implement me! */ + +#endif /* HW_I2C_BITBANG_H */