summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsundm75 <[email protected]>2018-03-17 19:04:23 +0800
committersundm75 <[email protected]>2018-03-17 19:04:23 +0800
commitaf743afb019c47d524bef28956cf316a4442d5ab (patch)
tree00e2ac2270f61c112d881f4e5fe60247d9abf728
parent4a8076e4b8635a38e266754a8e7df95c0a9f8ca5 (diff)
[bsp][ls1c] add ls1c_hw_i2c_init
-rw-r--r--bsp/ls1cdev/drivers/hw_i2c.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/bsp/ls1cdev/drivers/hw_i2c.c b/bsp/ls1cdev/drivers/hw_i2c.c
index 15d84997c6..6d427701ed 100644
--- a/bsp/ls1cdev/drivers/hw_i2c.c
+++ b/bsp/ls1cdev/drivers/hw_i2c.c
@@ -25,6 +25,9 @@
#include <rtthread.h>
#include <rtdevice.h>
#include "ls1c_i2c.h"
+#include "../libraries/ls1c_pin.h"
+
+#ifdef RT_USING_I2C
struct ls1c_i2c_bus
{
@@ -119,11 +122,33 @@ static struct ls1c_i2c_bus ls1c_i2c_bus_2 =
};
#endif
-int rt_i2c_init(void)
+int ls1c_hw_i2c_init(void)
{
struct ls1c_i2c_bus* ls1c_i2c;
#ifdef RT_USING_I2C0
+/*
+ pin_set_purpose(2, PIN_PURPOSE_OTHER);
+ pin_set_purpose(3, PIN_PURPOSE_OTHER);
+ pin_set_remap(2, PIN_REMAP_SECOND);
+ pin_set_remap(3, PIN_REMAP_SECOND);
+ */
+#endif
+#ifdef RT_USING_I2C1
+ pin_set_purpose(2, PIN_PURPOSE_OTHER);
+ pin_set_purpose(3, PIN_PURPOSE_OTHER);
+ pin_set_remap(2, PIN_REMAP_SECOND);
+ pin_set_remap(3, PIN_REMAP_SECOND);
+#endif
+#ifdef RT_USING_I2C2
+ pin_set_purpose(51, PIN_PURPOSE_OTHER);
+ pin_set_purpose(50, PIN_PURPOSE_OTHER);
+ pin_set_remap(51, PIN_REMAP_FOURTH);
+ pin_set_remap(50, PIN_REMAP_FOURTH);
+#endif
+
+
+#ifdef RT_USING_I2C0
ls1c_i2c = &ls1c_i2c_bus_0;
ls1c_i2c->parent.ops = &ls1c_i2c_ops;
rt_i2c_bus_device_register(&ls1c_i2c->parent, "i2c0");
@@ -145,3 +170,7 @@ int rt_i2c_init(void)
return RT_EOK;
}
+
+INIT_BOARD_EXPORT(ls1c_hw_i2c_init);
+
+#endif