diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-03-31 17:20:26 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-03-31 17:20:26 +0000 |
commit | 6c8a2507a88047d8165859e787520d2cf902259d (patch) | |
tree | dcd4f342edc7ba70235ee90b802c96ad60fef5df /testhal/STM32F37x/I2C/main.c | |
parent | b0b6214a6253eedb438e003dcfd408d52ed0a6c4 (diff) | |
download | ChibiOS-6c8a2507a88047d8165859e787520d2cf902259d.tar.gz ChibiOS-6c8a2507a88047d8165859e787520d2cf902259d.tar.bz2 ChibiOS-6c8a2507a88047d8165859e787520d2cf902259d.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5523 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32F37x/I2C/main.c')
-rw-r--r-- | testhal/STM32F37x/I2C/main.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testhal/STM32F37x/I2C/main.c b/testhal/STM32F37x/I2C/main.c index 339a2bccc..52a4e889b 100644 --- a/testhal/STM32F37x/I2C/main.c +++ b/testhal/STM32F37x/I2C/main.c @@ -18,6 +18,20 @@ #include "hal.h"
/*
+ * Timing values are taken from the RM except the PRESC set to 9 because
+ * the input clock is 72MHz.
+ * The timings are critical, please always refer to the STM32 Reference
+ * Manual before attempting changes.
+ */
+static const I2CConfig i2cconfig = {
+ STM32_TIMINGR_PRESC(8U) | /* 72MHz/9 = 8MHz I2CCLK. */
+ STM32_TIMINGR_SCLDEL(3U) | STM32_TIMINGR_SDADEL(3U) |
+ STM32_TIMINGR_SCLH(3U) | STM32_TIMINGR_SCLL(9U),
+ 0,
+ 0
+};
+
+/*
* This is a periodic thread that does absolutely nothing except flashing
* a LED.
*/
@@ -50,6 +64,11 @@ int main(void) { chSysInit();
/*
+ * Starting the I2C driver 2.
+ */
+ i2cStart(&I2CD2, &i2cconfig);
+
+ /*
* Starting the blinker thread.
*/
chThdCreateStatic(blinker_wa, sizeof(blinker_wa),
|