From: asterix Date: Tue, 29 Jun 2010 10:51:17 +0000 (+0000) Subject: First implementation of i2c module for stm32. X-Git-Tag: 2.6.0~338 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=d3ad5e296866cfe84c5b2d26143b3261aa7ed654;p=bertos.git First implementation of i2c module for stm32. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3969 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/drv/i2c_stm32.c b/bertos/cpu/cortex-m3/drv/i2c_stm32.c new file mode 100644 index 00000000..ee3a60e0 --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/i2c_stm32.c @@ -0,0 +1,132 @@ +/** + * \file + * + * + * \brief STM32F103xx I2C driver. + * + * \author Daniele Basile + */ + +#include "cfg/cfg_i2c.h" + +#define LOG_LEVEL I2C_LOG_LEVEL +#define LOG_FORMAT I2C_LOG_FORMAT +#include + +#include +#include // BV() +#include + +#include + +/** + * Send START condition on the bus. + * + * \return true on success, false otherwise. + */ +static bool i2c_builtin_start(void) +{ + + return false; +} + + +/** + * Send START condition and select slave for write. + * \c id is the device id comprehensive of address left shifted by 1. + * The LSB of \c id is ignored and reset to 0 for write operation. + * + * \return true on success, false otherwise. + */ +bool i2c_builtin_start_w(uint8_t id) +{ + return false; +} + + +/** + * Send START condition and select slave for read. + * \c id is the device id comprehensive of address left shifted by 1. + * The LSB of \c id is ignored and set to 1 for read operation. + * + * \return true on success, false otherwise. + */ +bool i2c_builtin_start_r(uint8_t id) +{ + + return false; +} + + +/** + * Send STOP condition. + */ +void i2c_builtin_stop(void) +{ + +} + + +/** + * Put a single byte in master transmitter mode + * to the selected slave device through the TWI bus. + * + * \return true on success, false on error. + */ +bool i2c_builtin_put(const uint8_t data) +{ + + return true; +} + +/** + * Get 1 byte from slave in master transmitter mode + * to the selected slave device through the TWI bus. + * If \a ack is true issue a ACK after getting the byte, + * otherwise a NACK is issued. + * + * \return the byte read if ok, EOF on errors. + */ +int i2c_builtin_get(bool ack) +{ + + return 0; +} + +MOD_DEFINE(i2c); + +/** + * Initialize TWI module. + */ +void i2c_builtin_init(void) +{ + MOD_INIT(i2c); +}