aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-07-03 18:02:55 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-07-03 18:02:55 +0000
commitccb28114da9485c5e3f950fd31dfb67be1b8a173 (patch)
treea9645e52236f59fb69d4995ee9c121acaeb50808 /os/hal/include
parentaf0e40079ded13b8842e8d129fa6ed2f37fdf678 (diff)
downloadChibiOS-ccb28114da9485c5e3f950fd31dfb67be1b8a173.tar.gz
ChibiOS-ccb28114da9485c5e3f950fd31dfb67be1b8a173.tar.bz2
ChibiOS-ccb28114da9485c5e3f950fd31dfb67be1b8a173.zip
I2C. Driver looks working, but sometimes hangs up. I don't know, my big project cause troubles in it, or driver cause troubles in my project.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3116 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/i2c.h35
1 files changed, 30 insertions, 5 deletions
diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h
index 0a4ba8b53..774c0cf22 100644
--- a/os/hal/include/i2c.h
+++ b/os/hal/include/i2c.h
@@ -165,9 +165,9 @@ struct I2CSlaveConfig{
* @notapi
*/
#define _i2c_wait_s(i2cp) { \
- chDbgAssert((i2cp)->id_thread == NULL, \
+ chDbgAssert((i2cp)->id_thread == NULL, \
"_i2c_wait(), #1", "already waiting"); \
- (i2cp)->id_thread = chThdSelf(); \
+ (i2cp)->id_thread = chThdSelf(); \
chSchGoSleepS(THD_STATE_SUSPENDED); \
}
@@ -179,9 +179,9 @@ struct I2CSlaveConfig{
* @notapi
*/
#define _i2c_wakeup_isr(i2cp) { \
- if ((i2cp)->id_thread != NULL) { \
- Thread *tp = (i2cp)->id_thread; \
- (i2cp)->id_thread = NULL; \
+ if ((i2cp)->id_thread != NULL) { \
+ Thread *tp = (i2cp)->id_thread; \
+ (i2cp)->id_thread = NULL; \
chSysLockFromIsr(); \
chSchReadyI(tp); \
chSysUnlockFromIsr(); \
@@ -218,6 +218,31 @@ struct I2CSlaveConfig{
_i2c_wakeup_isr(i2cp); \
}
+/**
+ * @brief Error ISR code.
+ * @details This code handles the portable part of the ISR code:
+ * - Error callback invocation.
+ * - Waiting thread wakeup, if any.
+ * - Driver state transitions.
+ *
+ * @note This macro is meant to be used in the low level drivers
+ * implementation only.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ *
+ * @notapi
+ */
+#define _i2c_isr_err_code(i2cp, i2cscfg) { \
+ (i2cp)->id_state = I2C_COMPLETE; \
+ if(((i2cp)->id_slave_config)->id_err_callback) { \
+ ((i2cp)->id_slave_config)->id_err_callback(i2cp, i2cscfg); \
+ if((i2cp)->id_state == I2C_COMPLETE) \
+ (i2cp)->id_state = I2C_READY; \
+ } \
+ else \
+ (i2cp)->id_state = I2C_READY; \
+ _i2c_wakeup_isr(i2cp); \
+}
/*===========================================================================*/
/* External declarations. */