aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include/i2c.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/include/i2c.h')
-rw-r--r--os/hal/include/i2c.h97
1 files changed, 11 insertions, 86 deletions
diff --git a/os/hal/include/i2c.h b/os/hal/include/i2c.h
index 31dcb53d5..1053712d0 100644
--- a/os/hal/include/i2c.h
+++ b/os/hal/include/i2c.h
@@ -51,7 +51,7 @@
#define I2CD_OVERRUN 0x08 /**< @brief Overrun/Underrun. */
#define I2CD_PEC_ERROR 0x10 /**< @brief PEC Error in
reception. */
-#define I2CD_TIMEOUT 0x20 /**< @brief Timeout Error. */
+#define I2CD_TIMEOUT 0x20 /**< @brief Hardware timeout. */
#define I2CD_SMB_ALERT 0x40 /**< @brief SMBus Alert. */
/** @} */
@@ -91,85 +91,10 @@ typedef enum {
#include "i2c_lld.h"
-
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
-/**
- * @brief Waits for operation completion.
- * @details This function waits for the driver to complete the current
- * operation.
- * @pre An operation must be running while the function is invoked.
- * @note No more than one thread can wait on a I2C driver using
- * this function.
- *
- * @param[in] i2cp pointer to the @p I2CDriver object
- *
- * @notapi
- */
-#define _i2c_wait_s(i2cp, timeout, rdymsg) { \
- chDbgAssert((i2cp)->id_thread == NULL, \
- "_i2c_wait(), #1", "already waiting"); \
- chSysLock(); \
- (i2cp)->id_thread = chThdSelf(); \
- rdymsg = chSchGoSleepTimeoutS(THD_STATE_SUSPENDED, timeout); \
- chSysUnlock(); \
-}
-
-/**
- * @brief Wakes up the waiting thread.
- *
- * @param[in] i2cp pointer to the @p I2CDriver object
- *
- * @notapi
- */
-#define _i2c_wakeup_isr(i2cp) { \
- if ((i2cp)->id_thread != NULL) { \
- Thread *tp = (i2cp)->id_thread; \
- (i2cp)->id_thread = NULL; \
- chSysLockFromIsr(); \
- chSchReadyI(tp); \
- chSysUnlockFromIsr(); \
- } \
-}
-
-/**
- * @brief Common ISR code.
- * @details This code handles the portable part of the ISR code:
- * - Waiting thread wakeup.
- * - 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_code(i2cp, i2cscfg) { \
- (i2cp)->id_state = I2C_READY; \
- _i2c_wakeup_isr(i2cp); \
-}
-
-/**
- * @brief Error ISR code.
- * @details This code handles the portable part of the ISR code:
- * - Waiting thread wakeup.
- * - 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_READY; \
- _i2c_wakeup_isr(i2cp); \
-}
-
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
@@ -181,16 +106,16 @@ extern "C" {
void i2cObjectInit(I2CDriver *i2cp);
void i2cStart(I2CDriver *i2cp, const I2CConfig *config);
void i2cStop(I2CDriver *i2cp);
- msg_t i2cMasterTransmit(I2CDriver *i2cp,
- uint8_t slave_addr,
- uint8_t *txbuf, size_t txbytes,
- uint8_t *rxbuf, size_t rxbytes,
- i2cflags_t *errors, systime_t timeout);
- msg_t i2cMasterReceive(I2CDriver *i2cp,
- uint8_t slave_addr,
- uint8_t *rxbuf, size_t rxbytes,
- i2cflags_t *errors, systime_t timeout);
-
+ i2cflags_t i2cGetErrors(I2CDriver *i2cp);
+ msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp,
+ i2caddr_t addr,
+ const uint8_t *txbuf, size_t txbytes,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout);
+ msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp,
+ i2caddr_t addr,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout);
#if I2C_USE_MUTUAL_EXCLUSION
void i2cAcquireBus(I2CDriver *i2cp);
void i2cReleaseBus(I2CDriver *i2cp);