aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
Diffstat (limited to 'testhal')
-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
*/