You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2018/12/06 19:42:30 UTC
[mynewt-core] 03/03: bsp/hifive1: Add bus support
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit ba162918a51cc20b0fc3c2dd63bb3f172ac54799
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Dec 6 15:50:05 2018 +0100
bsp/hifive1: Add bus support
SPI bus support is now added to bsp
---
hw/bsp/hifive1/src/hal_bsp.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/hw/bsp/hifive1/src/hal_bsp.c b/hw/bsp/hifive1/src/hal_bsp.c
index 570289d..70d6520 100644
--- a/hw/bsp/hifive1/src/hal_bsp.c
+++ b/hw/bsp/hifive1/src/hal_bsp.c
@@ -34,6 +34,12 @@
#endif
#include <bsp/bsp.h>
#include <env/freedom-e300-hifive1/platform.h>
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include "bus/bus.h"
+#if MYNEWT_VAL(SPI_0) || MYNEWT_VAL(SPI_1) || MYNEWT_VAL(SPI_2)
+#include "bus/spi.h"
+#endif
+#endif
#if MYNEWT_VAL(UART_0)
static struct uart_dev os_bsp_uart0;
@@ -53,6 +59,21 @@ extern struct fe310_hal_tmr fe310_pwm1;
extern struct fe310_hal_tmr fe310_pwm0;
#endif
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#if MYNEWT_VAL(SPI_1)
+static const struct bus_spi_dev_cfg spi1_cfg = {
+ .spi_num = 1,
+};
+static struct bus_spi_dev spi1_bus;
+#endif
+#if MYNEWT_VAL(SPI_2)
+static const struct bus_spi_dev_cfg spi2_cfg = {
+ .spi_num = 2,
+};
+static struct bus_spi_dev spi2_bus;
+#endif
+#endif
+
/*
* What memory to include in coredump.
*/
@@ -107,14 +128,23 @@ hal_bsp_init(void)
#endif
#if MYNEWT_VAL(SPI_1)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+ rc = bus_spi_dev_create("spi1", &spi1_bus, (struct bus_spi_dev_cfg *)&spi1_cfg);
+ assert(rc == 0);
+#else
rc = hal_spi_init(1, NULL, HAL_SPI_TYPE_MASTER);
assert(rc == 0);
#endif
-
+#endif
#if MYNEWT_VAL(SPI_2)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+ rc = bus_spi_dev_create("spi2", &spi2_bus, (struct bus_spi_dev_cfg *)&spi2_cfg);
+ assert(rc == 0);
+#else
rc = hal_spi_init(2, NULL, HAL_SPI_TYPE_MASTER);
assert(rc == 0);
#endif
+#endif
#if MYNEWT_VAL(UART_0)
rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",