summaryrefslogtreecommitdiff
path: root/ucoo/hal/i2c/test
diff options
context:
space:
mode:
authorNicolas Schodet2016-07-25 15:18:40 +0200
committerNicolas Schodet2019-10-09 23:05:44 +0200
commit4695b47da68a5b2f75270bea21e15b8f1b9fd6ff (patch)
tree6e5ef4d34ee69bcd6c6627f25a0ca3aa902d47e3 /ucoo/hal/i2c/test
parentd7df91926bdb529e68eff9a215aef72072803b6e (diff)
Switch to CMSIS
Diffstat (limited to 'ucoo/hal/i2c/test')
-rw-r--r--ucoo/hal/i2c/test/Makefile2
-rw-r--r--ucoo/hal/i2c/test/test_i2c.cc28
2 files changed, 14 insertions, 16 deletions
diff --git a/ucoo/hal/i2c/test/Makefile b/ucoo/hal/i2c/test/Makefile
index ca6915e..2a3bb91 100644
--- a/ucoo/hal/i2c/test/Makefile
+++ b/ucoo/hal/i2c/test/Makefile
@@ -4,6 +4,6 @@ TARGETS = host stm32f4
PROGS = test_i2c
test_i2c_SOURCES = test_i2c.cc
-MODULES = ucoo/hal/i2c ucoo/utils ucoo/base/test ucoo/hal/usb
+MODULES = ucoo/hal/i2c ucoo/utils ucoo/base/test ucoo/hal/usb ucoo/hal/gpio
include $(BASE)/build/top.mk
diff --git a/ucoo/hal/i2c/test/test_i2c.cc b/ucoo/hal/i2c/test/test_i2c.cc
index 8b6ef9b..bef74b4 100644
--- a/ucoo/hal/i2c/test/test_i2c.cc
+++ b/ucoo/hal/i2c/test/test_i2c.cc
@@ -27,7 +27,6 @@
#include "ucoo/base/test/test.hh"
#ifdef TARGET_stm32
-# include <libopencm3/stm32/rcc.h>
# include "ucoo/hal/gpio/gpio.hh"
#endif
@@ -198,20 +197,19 @@ main (int argc, const char **argv)
// Connect I2C1 to I2C3 for the test.
// I2C1: B6: SCL, B9: SDA
// I2C3: A8: SCL, C9: SDA
- rcc_periph_clock_enable (RCC_GPIOA);
- rcc_periph_clock_enable (RCC_GPIOB);
- rcc_periph_clock_enable (RCC_GPIOC);
- gpio_mode_setup (GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO6 | GPIO9);
- gpio_mode_setup (GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO8);
- gpio_mode_setup (GPIOC, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9);
- gpio_set_output_options (GPIOB, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, GPIO6 | GPIO9);
- gpio_set_output_options (GPIOA, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, GPIO8);
- gpio_set_output_options (GPIOC, GPIO_OTYPE_OD, GPIO_OSPEED_2MHZ, GPIO9);
- gpio_set_af (GPIOB, GPIO_AF4, GPIO6 | GPIO9);
- gpio_set_af (GPIOA, GPIO_AF4, GPIO8);
- gpio_set_af (GPIOC, GPIO_AF4, GPIO9);
- ucoo::I2cHard i2c1 (0);
- ucoo::I2cHard i2c2 (2);
+ ucoo::GPIOA.enable ();
+ ucoo::GPIOB.enable ();
+ ucoo::GPIOC.enable ();
+ ucoo::GPIOB[6].af (4);
+ ucoo::GPIOB[6].type (ucoo::Gpio::Type::OPEN_DRAIN);
+ ucoo::GPIOB[9].af (4);
+ ucoo::GPIOB[9].type (ucoo::Gpio::Type::OPEN_DRAIN);
+ ucoo::GPIOA[8].af (4);
+ ucoo::GPIOA[8].type (ucoo::Gpio::Type::OPEN_DRAIN);
+ ucoo::GPIOC[9].af (4);
+ ucoo::GPIOC[9].type (ucoo::Gpio::Type::OPEN_DRAIN);
+ ucoo::I2cHard i2c1 (ucoo::I2cHard::Instance::I2C1);
+ ucoo::I2cHard i2c2 (ucoo::I2cHard::Instance::I2C2);
i2c1.enable ();
i2c2.enable ();
#endif