aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/i2c.c
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-23 08:11:23 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-23 08:11:23 +0000
commit4ec82f62c18894d92bafc6c6f98784650106373d (patch)
treea0cec5585dff0434608241c373b9ad30af5ae869 /os/hal/src/i2c.c
parentc877f5bfcc5301b441c9b13e8c32d83e9df04f37 (diff)
parent2a494cb534dbe3535a9bf4c61dfbc8b6c9e750be (diff)
downloadChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.tar.gz
ChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.tar.bz2
ChibiOS-4ec82f62c18894d92bafc6c6f98784650106373d.zip
I2C. 1 - Merge code from trunk. 2 - Fix driver problems detected by the CH_DBG_SYSTEM_STATE_CHECK
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3249 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/i2c.c')
-rw-r--r--os/hal/src/i2c.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/os/hal/src/i2c.c b/os/hal/src/i2c.c
index 9676a3250..974f65a08 100644
--- a/os/hal/src/i2c.c
+++ b/os/hal/src/i2c.c
@@ -103,11 +103,15 @@ void i2cObjectInit(I2CDriver *i2cp) {
void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
chDbgCheck((i2cp != NULL) && (config != NULL), "i2cStart");
-
- chSysLock();
chDbgAssert((i2cp->id_state == I2C_STOP) || (i2cp->id_state == I2C_READY),
"i2cStart(), #1",
"invalid state");
+
+#if (!(STM32_I2C_I2C2_USE_POLLING_WAIT) && I2C_SUPPORTS_CALLBACKS)
+ gptStart(i2cp->timer, i2cp->timer_cfg);
+#endif /* !(STM32_I2C_I2C2_USE_POLLING_WAIT) */
+
+ chSysLock();
i2cp->id_config = config;
i2c_lld_start(i2cp);
i2cp->id_state = I2C_READY;
@@ -124,11 +128,15 @@ void i2cStart(I2CDriver *i2cp, const I2CConfig *config) {
void i2cStop(I2CDriver *i2cp) {
chDbgCheck(i2cp != NULL, "i2cStop");
-
- chSysLock();
chDbgAssert((i2cp->id_state == I2C_STOP) || (i2cp->id_state == I2C_READY),
"i2cStop(), #1",
"invalid state");
+
+#if (!(STM32_I2C_I2C2_USE_POLLING_WAIT) && I2C_SUPPORTS_CALLBACKS)
+ gptStop(i2cp->timer);
+#endif /* !(STM32_I2C_I2C2_USE_POLLING_WAIT) */
+
+ chSysLock();
i2c_lld_stop(i2cp);
i2cp->id_state = I2C_STOP;
chSysUnlock();