X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fi2c.h;h=2c40efde75ea0906798bb572259b83ebcb069d70;hb=HEAD;hp=193e7b2ea657a86f82ab7a06b7b0363f6a79ab03;hpb=7fda050003b7efc92c54ab6b3d9b826007d42fb5;p=bertos.git diff --git a/bertos/drv/i2c.h b/bertos/drv/i2c.h index 193e7b2e..2c40efde 100644 --- a/bertos/drv/i2c.h +++ b/bertos/drv/i2c.h @@ -30,7 +30,9 @@ * * --> * - * \addtogroup i2c_api + * \defgroup i2c_driver I2C driver + * \ingroup drivers + * \{ * \brief I2C generic driver functions. * * Some hardware requires you to declare the number of transferred @@ -103,8 +105,6 @@ #define I2C_READBIT BV(0) -/** \defgroup i2c_driver I2C driver - */ /* * The following macros are needed to maintain compatibility with older i2c API. @@ -198,88 +198,6 @@ enum I2C_BITBANG_CNT /**< Number of i2c ports */ }; -/** - * \defgroup old_i2c_api Old I2C API - * \ingroup i2c_driver - * - * This is the old and deprecated I2C API. It is maintained for backward - * compatibility only, don't use it in new projects. - * @{ - */ -#if !CONFIG_I2C_DISABLE_OLD_API - -/** - * \ingroup old_i2c_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. - * @{ - */ -#define I2C_BACKEND_BUILTIN 0 ///< Uses cpu builtin i2c driver -#define I2C_BACKEND_BITBANG 1 ///< Uses emulated bitbang driver -/**@}*/ - -/** - * \name I2c builtin prototypes. - * \ingroup old_i2c_api - * Do NOT use these function directly, instead, - * you can call the ones named without "_builtin_" - * and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) - * that you want the builtin backend. - * @{ - */ -bool i2c_builtin_start_w(uint8_t id); -bool i2c_builtin_start_r(uint8_t id); -void i2c_builtin_stop(void); -bool i2c_builtin_put(uint8_t _data); -int i2c_builtin_get(bool ack); -/**@}*/ - -/** - * \name I2c bitbang prototypes. - * \ingroup old_i2c_api - * Do NOT use these function directly, instead, - * you can call the ones named without "_bitbang_" - * and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) - * that you want the bitbang backend. - * @{ - */ -bool i2c_bitbang_start_w(uint8_t id); -bool i2c_bitbang_start_r(uint8_t id); -void i2c_bitbang_stop(void); -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_start_w_1 i2c_builtin_start_w - #define i2c_start_r_1 i2c_builtin_start_r - #define i2c_stop i2c_builtin_stop - #define i2c_put i2c_builtin_put - #define i2c_get i2c_builtin_get -#elif CONFIG_I2C_BACKEND == I2C_BACKEND_BITBANG - #define i2c_start_w_1 i2c_bitbang_start_w - #define i2c_start_r_1 i2c_bitbang_start_r - #define i2c_stop i2c_bitbang_stop - #define i2c_put i2c_bitbang_put - #define i2c_get i2c_bitbang_get -#else - #error Unsupported i2c backend. -#endif - - -bool i2c_send(const void *_buf, size_t count); -bool i2c_recv(void *_buf, size_t count); - -#endif /* !CONFIG_I2C_DISABLE_OLD_API */ -/**@}*/ - /** \defgroup i2c_api I2C driver API * \ingroup i2c_driver * \{ @@ -522,8 +440,89 @@ INLINE int i2c_error(I2c *i2c) /**@}*/ /**\}*/ // i2c_api +/** + * \defgroup old_i2c_api Old I2C API + * \ingroup i2c_driver + * + * This is the old and deprecated I2C API. It is maintained for backward + * compatibility only, don't use it in new projects. + * @{ + */ #if !CONFIG_I2C_DISABLE_OLD_API +/** + * \ingroup old_i2c_api + * \name 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. + * Set the CONFIG_I2C_BACKEND configuration variable in cfg_i2c.h + * @{ + */ +#define I2C_BACKEND_BUILTIN 0 ///< Uses cpu builtin i2c driver +#define I2C_BACKEND_BITBANG 1 ///< Uses emulated bitbang driver +/**@}*/ + +/** + * \name I2c builtin prototypes. + * \ingroup old_i2c_api + * Do NOT use these function directly, instead, + * you can call the ones named without "_builtin_" + * and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) + * that you want the builtin backend. + * @{ + */ +bool i2c_builtin_start_w(uint8_t id); +bool i2c_builtin_start_r(uint8_t id); +void i2c_builtin_stop(void); +bool i2c_builtin_put(uint8_t _data); +int i2c_builtin_get(bool ack); +/**@}*/ + +/** + * \name I2c bitbang prototypes. + * \ingroup old_i2c_api + * Do NOT use these function directly, instead, + * you can call the ones named without "_bitbang_" + * and specify in cfg_i2c.h (CONFIG_I2C_BACKEND) + * that you want the bitbang backend. + * @{ + */ +bool i2c_bitbang_start_w(uint8_t id); +bool i2c_bitbang_start_r(uint8_t id); +void i2c_bitbang_stop(void); +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_start_w_1 i2c_builtin_start_w + #define i2c_start_r_1 i2c_builtin_start_r + #define i2c_stop i2c_builtin_stop + #define i2c_put i2c_builtin_put + #define i2c_get i2c_builtin_get +#elif CONFIG_I2C_BACKEND == I2C_BACKEND_BITBANG + #define i2c_start_w_1 i2c_bitbang_start_w + #define i2c_start_r_1 i2c_bitbang_start_r + #define i2c_stop i2c_bitbang_stop + #define i2c_put i2c_bitbang_put + #define i2c_get i2c_bitbang_get +#else + #error Unsupported i2c backend. +#endif + + +bool i2c_send(const void *_buf, size_t count); +bool i2c_recv(void *_buf, size_t count); + +/**@}*/ + + extern I2c local_i2c_old_api; /** @@ -540,6 +539,6 @@ INLINE void i2c_init_0(void) } #endif /* !CONFIG_I2C_DISABLE_OLD_API */ - +/** \} */ //defgroup i2c_driver #endif