diff options
author | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-01-05 17:51:00 +0000 |
---|---|---|
committer | barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-01-05 17:51:00 +0000 |
commit | b109cacb8af5ec7f4ca9bb96b190b96ed21f1c97 (patch) | |
tree | 57f319acf9723c51faffbd3937df4eeea5ba51e5 | |
parent | 5b8b005cbdeae242145d1f88fc59a4c92ccbfc33 (diff) | |
download | ChibiOS-b109cacb8af5ec7f4ca9bb96b190b96ed21f1c97.tar.gz ChibiOS-b109cacb8af5ec7f4ca9bb96b190b96ed21f1c97.tar.bz2 ChibiOS-b109cacb8af5ec7f4ca9bb96b190b96ed21f1c97.zip |
I2C. Minor changes in testhals.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3743 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | testhal/STM32F1xx/I2C/Makefile | 2 | ||||
-rw-r--r-- | testhal/STM32F1xx/I2C/main.c | 4 | ||||
-rw-r--r-- | testhal/STM32F4xx/I2C/main.c | 14 |
3 files changed, 17 insertions, 3 deletions
diff --git a/testhal/STM32F1xx/I2C/Makefile b/testhal/STM32F1xx/I2C/Makefile index a118fb9a7..24cebda3b 100644 --- a/testhal/STM32F1xx/I2C/Makefile +++ b/testhal/STM32F1xx/I2C/Makefile @@ -31,7 +31,7 @@ endif # Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = yes
+ USE_VERBOSE_COMPILE = no
endif
#
diff --git a/testhal/STM32F1xx/I2C/main.c b/testhal/STM32F1xx/I2C/main.c index b779ae0b7..5af860e05 100644 --- a/testhal/STM32F1xx/I2C/main.c +++ b/testhal/STM32F1xx/I2C/main.c @@ -17,6 +17,10 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/*
+ Concepts and parts of this file have been contributed by Uladzimir Pylinsky
+ aka barthess.
+ */
#include <stdlib.h>
diff --git a/testhal/STM32F4xx/I2C/main.c b/testhal/STM32F4xx/I2C/main.c index 5cb616e8c..10042fee9 100644 --- a/testhal/STM32F4xx/I2C/main.c +++ b/testhal/STM32F4xx/I2C/main.c @@ -22,6 +22,10 @@ aka barthess.
*/
+/**
+ * This demo acquire data from accelerometer and prints it in shell.
+ */
+
#include <stdlib.h>
#include "ch.h"
@@ -103,6 +107,7 @@ int16_t complement2signed(uint8_t msb, uint8_t lsb){ */
int main(void) {
msg_t status = RDY_OK;
+ systime_t tmo = MS2ST(4);
/*
* System initializations.
@@ -135,18 +140,23 @@ int main(void) { txbuf[0] = ACCEL_CTRL_REG1; /* register address */
txbuf[1] = 0x1;
i2cAcquireBus(&I2CD2);
- i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 2, rxbuf, 0, TIME_INFINITE);
+ status = i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 2, rxbuf, 0, tmo);
i2cReleaseBus(&I2CD2);
+ if (status != RDY_OK){
+ errors = i2cGetErrors(&I2CD2);
+ }
+
/*
* Normal main() thread activity, nothing in this test.
*/
while (TRUE) {
+ palTogglePad(GPIOB, GPIOB_LED_B);
chThdSleepMilliseconds(100);
txbuf[0] = ACCEL_OUT_DATA; /* register address */
i2cAcquireBus(&I2CD2);
- status = i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 1, rxbuf, 6, TIME_INFINITE);
+ status = i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 1, rxbuf, 6, tmo);
i2cReleaseBus(&I2CD2);
if (status != RDY_OK){
|