diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-05 17:24:23 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-05 17:24:23 +0000 |
commit | 6ee04cf23282fff92b088ac6f408e5233eb3aa75 (patch) | |
tree | 4d1e7e5d7611dc0e26f277486adb91c00e036352 /testhal/STM32/I2C/tmp75.c | |
parent | 4bcff1c283004b10e7a39e855da996621f9eec6d (diff) | |
download | ChibiOS-6ee04cf23282fff92b088ac6f408e5233eb3aa75.tar.gz ChibiOS-6ee04cf23282fff92b088ac6f408e5233eb3aa75.tar.bz2 ChibiOS-6ee04cf23282fff92b088ac6f408e5233eb3aa75.zip |
I2C. Added template of synchronouse deriver. It does not work for a moment.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3190 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/I2C/tmp75.c')
-rw-r--r-- | testhal/STM32/I2C/tmp75.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/testhal/STM32/I2C/tmp75.c b/testhal/STM32/I2C/tmp75.c index 6276e7c8e..72e634527 100644 --- a/testhal/STM32/I2C/tmp75.c +++ b/testhal/STM32/I2C/tmp75.c @@ -14,6 +14,7 @@ /* input buffer */
static i2cblock_t tmp75_rx_data[TMP75_RX_DEPTH];
+
/* temperature value */
static int16_t temperature = 0;
@@ -30,7 +31,6 @@ static void i2c_tmp75_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ (void)*i2cp;
(void)*i2cscfg;
/* store temperature value */
- temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1];
}
/* Fill TMP75 config. */
@@ -43,12 +43,10 @@ static const I2CSlaveConfig tmp75 = { /* This is main function. */
void request_temperature(void){
-#define TXBYTES 0 /* set to zero because we need only reading */
-#define RXBYTES 2 /* we need to read 2 bytes */
-
i2cAcquireBus(&I2CD2);
- i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, RXBYTES);
+ i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, 2);
i2cReleaseBus(&I2CD2);
+ temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1];
}
|