aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-07-06 13:13:48 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-07-06 13:13:48 +0000
commit4b96f983dd6b8fbfc3876041712d7b7c6b959c20 (patch)
tree0dfeb026e9f294cfd6a59860552a8e4c001f1dd7
parent2a1dd613812badd702762913125855e8fe321f85 (diff)
downloadChibiOS-4b96f983dd6b8fbfc3876041712d7b7c6b959c20.tar.gz
ChibiOS-4b96f983dd6b8fbfc3876041712d7b7c6b959c20.tar.bz2
ChibiOS-4b96f983dd6b8fbfc3876041712d7b7c6b959c20.zip
I2C. Fixed testhal for F4x.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4410 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r--testhal/STM32F4xx/I2C/chconf.h1
-rw-r--r--testhal/STM32F4xx/I2C/halconf.h2
-rw-r--r--testhal/STM32F4xx/I2C/main.c34
3 files changed, 20 insertions, 17 deletions
diff --git a/testhal/STM32F4xx/I2C/chconf.h b/testhal/STM32F4xx/I2C/chconf.h
index d99c26773..1abb9626c 100644
--- a/testhal/STM32F4xx/I2C/chconf.h
+++ b/testhal/STM32F4xx/I2C/chconf.h
@@ -34,7 +34,6 @@
//#define CORTEX_VTOR_INIT 0x000E0000
#define CORTEX_VTOR_INIT 0x00000000
-#define CORTEX_USE_FPU TRUE
/*===========================================================================*/
/* Kernel parameters. */
diff --git a/testhal/STM32F4xx/I2C/halconf.h b/testhal/STM32F4xx/I2C/halconf.h
index e2ac49536..8aae4a995 100644
--- a/testhal/STM32F4xx/I2C/halconf.h
+++ b/testhal/STM32F4xx/I2C/halconf.h
@@ -80,7 +80,7 @@
* @brief Enables the I2C subsystem.
*/
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
+#define HAL_USE_I2C TRUE
#endif
/**
diff --git a/testhal/STM32F4xx/I2C/main.c b/testhal/STM32F4xx/I2C/main.c
index 310fe5888..e65b7e1c5 100644
--- a/testhal/STM32F4xx/I2C/main.c
+++ b/testhal/STM32F4xx/I2C/main.c
@@ -51,7 +51,7 @@ static int16_t acceleration_x, acceleration_y, acceleration_z;
static void print(char *p) {
while (*p) {
- chIOPut(&SD2, *p++);
+ sdPut(&SD2, *p++);
}
}
@@ -61,9 +61,9 @@ static void print(char *p) {
static void println(char *p) {
while (*p) {
- chIOPut(&SD2, *p++);
+ sdPut(&SD2, *p++);
}
- chIOWriteTimeout(&SD2, (uint8_t *)"\r\n", 2, TIME_INFINITE);
+ sdWriteTimeout(&SD2, (uint8_t *)"\r\n", 2, TIME_INFINITE);
}
/**
@@ -73,20 +73,20 @@ static void printn(int16_t n) {
char buf[16], *p;
if (n > 0)
- chIOPut(&SD2, '+');
+ sdPut(&SD2, '+');
else{
- chIOPut(&SD2, '-');
+ sdPut(&SD2, '-');
n = abs(n);
}
if (!n)
- chIOPut(&SD2, '0');
+ sdPut(&SD2, '0');
else {
p = buf;
while (n)
*p++ = (n % 10) + '0', n /= 10;
while (p > buf)
- chIOPut(&SD2, *--p);
+ sdPut(&SD2, *--p);
}
}
@@ -102,6 +102,13 @@ int16_t complement2signed(uint8_t msb, uint8_t lsb){
return (int16_t)word;
}
+/* I2C interface #2 */
+static const I2CConfig i2cfg2 = {
+ OPMODE_I2C,
+ 400000,
+ FAST_DUTY_CYCLE_2,
+};
+
/*
* Application entry point.
*/
@@ -120,20 +127,17 @@ int main(void) {
chSysInit();
/*
+ * Starts I2C
+ */
+ i2cStart(&I2CD2, &i2cfg2);
+
+ /*
* Prepares the Serial driver 2
*/
sdStart(&SD2, NULL); /* Default is 38400-8-N-1.*/
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
- /* I2C interface #2 */
- static const I2CConfig i2cfg2 = {
- OPMODE_I2C,
- 400000,
- FAST_DUTY_CYCLE_16_9,
- };
- i2cStart(&I2CD2, &i2cfg2);
-
/**
* Prepares the accelerometer
*/