You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/11/29 21:08:30 UTC
[mynewt-core] branch master updated (ace2d93 -> c96d592)
This is an automated email from the ASF dual-hosted git repository.
andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.
from ace2d93 Fix QSPI parameter error on erase command
new 4412d43 sys/defs: Add new error code
new 3053013 hw/mcu/nordic: Update support for 380KHz I2C
new 29f110d hw/mcu/nordic: Enable all available buses for bus driver
new f098d85 hw/mcu/nordic: Fix bus driver headers
new aee70f7 hw/bus: Make bus lock time configurable
new c8b2345 hw/bus: Allow to configure default transaction timeout
new 9fa8934 hw/bus: Add missing unlock when configuration failed
new f08bf66 hw/bus/i2c: Fix node debug poisoning
new 0480a95 hw/bus/i2c: Set I2C pins to high state on startup
new 80d434b hw/bus/i2c: Delay controller enable
new 42b4ece hw/bus/i2c: Fix operation timeouts
new 8277d29 hw/bus/i2c: Add I2C HAL errors translation
new e2261fb hw/bus/i2c: Make sure node config is set before init
new c96d592 hw/bus/spi: Make sure node config is set before init
The 14 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
hw/bus/i2c/src/i2c.c | 50 +++++++++++++++++++++----------
hw/bus/include/bus/bus.h | 25 ++++++++++++++--
hw/bus/spi/src/spi.c | 10 +++----
hw/bus/src/bus.c | 23 ++++++++++++--
hw/bus/syscfg.yml | 9 ++++++
hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 3 ++
hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c | 37 +++++++++++++++++++++--
sys/defs/include/defs/error.h | 1 +
8 files changed, 129 insertions(+), 29 deletions(-)
[mynewt-core] 11/14: hw/bus/i2c: Fix operation timeouts
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 42b4ece8c6967ac94c947f4032c67058bb845b7e
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 12:19:12 2018 +0100
hw/bus/i2c: Fix operation timeouts
These are specified in ticks in HAL already.
---
hw/bus/i2c/src/i2c.c | 6 ++----
hw/bus/syscfg.yml | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index 16827cc..10feca6 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -98,8 +98,7 @@ bus_i2c_read(struct bus_dev *bdev, struct bus_node *bnode, uint8_t *buf,
last_op = !(flags & BUS_F_NOSTOP);
- rc = hal_i2c_master_read(dev->cfg.i2c_num, &i2c_data,
- os_time_ticks_to_ms32(timeout), last_op);
+ rc = hal_i2c_master_read(dev->cfg.i2c_num, &i2c_data, timeout, last_op);
return rc;
}
@@ -123,8 +122,7 @@ bus_i2c_write(struct bus_dev *bdev, struct bus_node *bnode, const uint8_t *buf,
last_op = !(flags & BUS_F_NOSTOP);
- rc = hal_i2c_master_write(dev->cfg.i2c_num, &i2c_data,
- os_time_ticks_to_ms32(timeout), last_op);
+ rc = hal_i2c_master_write(dev->cfg.i2c_num, &i2c_data, timeout, last_op);
return rc;
}
diff --git a/hw/bus/syscfg.yml b/hw/bus/syscfg.yml
index 7a19cde..b7e03f3 100644
--- a/hw/bus/syscfg.yml
+++ b/hw/bus/syscfg.yml
@@ -30,7 +30,7 @@ syscfg.defs:
description: >
Default timeout for transaction on bus. This is used for simple
transaction APIs (i.e. without timeout set explicitly)
- value: 10
+ value: 50
BUS_DEBUG_OS_DEV:
description: >
[mynewt-core] 01/14: sys/defs: Add new error code
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 4412d434de760f98654ea842f751eba89368ab5f
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 15:35:33 2018 +0100
sys/defs: Add new error code
This is used to indicate I/O error caused by remote side. For example,
in bus driver this will indicate data NAK while existing SYS_EIO can be
used to indicate I/O errors on local side.
---
sys/defs/include/defs/error.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/sys/defs/include/defs/error.h b/sys/defs/include/defs/error.h
index 678cc19..9d7cd0e 100644
--- a/sys/defs/include/defs/error.h
+++ b/sys/defs/include/defs/error.h
@@ -38,6 +38,7 @@ extern "C" {
#define SYS_EALREADY (-11)
#define SYS_ENOTSUP (-12)
#define SYS_EUNKNOWN (-13)
+#define SYS_EREMOTEIO (-14)
#define SYS_EPERUSER (-65535)
[mynewt-core] 02/14: hw/mcu/nordic: Update support for 380KHz I2C
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 305301330612563effa7551c5481d9adaab6d6da
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Nov 23 17:43:59 2018 +0100
hw/mcu/nordic: Update support for 380KHz I2C
---
hw/mcu/nordic/nrf52xxx/src/hal_i2c.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
index 5340ee3..24a6b25 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_i2c.c
@@ -398,6 +398,9 @@ hal_i2c_config(uint8_t i2c_num, const struct hal_i2c_settings *cfg)
case 250:
freq = TWI_FREQUENCY_FREQUENCY_K250;
break;
+ case 380:
+ freq = TWI_FREQUENCY_FREQUENCY_K380;
+ break;
case 400:
freq = TWI_FREQUENCY_FREQUENCY_K400;
break;
[mynewt-core] 10/14: hw/bus/i2c: Delay controller enable
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 80d434b0de814dabdb258fdb770af40dc0eb85c3
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 11:37:45 2018 +0100
hw/bus/i2c: Delay controller enable
Controller will be enabled when used for first time.
---
hw/bus/i2c/src/i2c.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index 85a3244..16827cc 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -177,9 +177,6 @@ bus_i2c_dev_init_func(struct os_dev *odev, void *arg)
dev->cfg = *cfg;
- rc = hal_i2c_enable(dev->cfg.i2c_num);
- assert(rc == 0);
-
return 0;
}
[mynewt-core] 13/14: hw/bus/i2c: Make sure node config is set
before init
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit e2261fb26b2aa83e605f1e953a9683ee46d06ef2
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 11:40:14 2018 +0100
hw/bus/i2c: Make sure node config is set before init
---
hw/bus/i2c/src/i2c.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index afca233..df12c49 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -209,14 +209,14 @@ bus_i2c_node_init_func(struct os_dev *odev, void *arg)
BUS_DEBUG_POISON_NODE(node);
+ node->freq = cfg->freq;
+ node->addr = cfg->addr;
+ node->quirks = cfg->quirks;
+
rc = bus_node_init_func(odev, node_cfg);
if (rc) {
return rc;
}
- node->freq = cfg->freq;
- node->addr = cfg->addr;
- node->quirks = cfg->quirks;
-
return 0;
}
[mynewt-core] 06/14: hw/bus: Allow to configure default transaction
timeout
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit c8b234543d2a6c6dc1fba4475136bc7513676234
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 14:50:30 2018 +0100
hw/bus: Allow to configure default transaction timeout
This is used when using simple transaction APIs which do not specify
timeouts explicitly.
---
hw/bus/include/bus/bus.h | 11 ++++++++---
hw/bus/syscfg.yml | 5 +++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/hw/bus/include/bus/bus.h b/hw/bus/include/bus/bus.h
index dbccd7b..9158570 100644
--- a/hw/bus/include/bus/bus.h
+++ b/hw/bus/include/bus/bus.h
@@ -119,7 +119,9 @@ bus_node_write_read_transact(struct os_dev *node, const void *wbuf,
static inline int
bus_node_simple_read(struct os_dev *node, void *buf, uint16_t length)
{
- return bus_node_read(node, buf, length, OS_TIMEOUT_NEVER, BUS_F_NONE);
+ return bus_node_read(node, buf, length,
+ os_time_ms_to_ticks32(MYNEWT_VAL(BUS_DEFAULT_TRANSACTION_TIMEOUT_MS)),
+ BUS_F_NONE);
}
/**
@@ -136,7 +138,9 @@ bus_node_simple_read(struct os_dev *node, void *buf, uint16_t length)
static inline int
bus_node_simple_write(struct os_dev *node, const void *buf, uint16_t length)
{
- return bus_node_write(node, buf, length, OS_TIMEOUT_NEVER, BUS_F_NONE);
+ return bus_node_write(node, buf, length,
+ os_time_ms_to_ticks32(MYNEWT_VAL(BUS_DEFAULT_TRANSACTION_TIMEOUT_MS)),
+ BUS_F_NONE);
}
/**
@@ -159,7 +163,8 @@ bus_node_simple_write_read_transact(struct os_dev *node, const void *wbuf,
uint16_t rlength)
{
return bus_node_write_read_transact(node, wbuf, wlength, rbuf, rlength,
- OS_TIMEOUT_NEVER, BUS_F_NONE);
+ os_time_ms_to_ticks32(MYNEWT_VAL(BUS_DEFAULT_TRANSACTION_TIMEOUT_MS)),
+ BUS_F_NONE);
}
/**
diff --git a/hw/bus/syscfg.yml b/hw/bus/syscfg.yml
index be0d133..7a19cde 100644
--- a/hw/bus/syscfg.yml
+++ b/hw/bus/syscfg.yml
@@ -26,6 +26,11 @@ syscfg.defs:
description: >
Default timeout for locking the bus. This can be overriden per-node.
value: 1000
+ BUS_DEFAULT_TRANSACTION_TIMEOUT_MS:
+ description: >
+ Default timeout for transaction on bus. This is used for simple
+ transaction APIs (i.e. without timeout set explicitly)
+ value: 10
BUS_DEBUG_OS_DEV:
description: >
[mynewt-core] 14/14: hw/bus/spi: Make sure node config is set
before init
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit c96d59228b8a881767984c8a222fbb0c8635ebf8
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 11:40:30 2018 +0100
hw/bus/spi: Make sure node config is set before init
---
hw/bus/spi/src/spi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/bus/spi/src/spi.c b/hw/bus/spi/src/spi.c
index dec2926..3372233 100644
--- a/hw/bus/spi/src/spi.c
+++ b/hw/bus/spi/src/spi.c
@@ -208,11 +208,6 @@ bus_spi_node_init_func(struct os_dev *odev, void *arg)
BUS_DEBUG_POISON_NODE(node);
- rc = bus_node_init_func(odev, node_cfg);
- if (rc) {
- return rc;
- }
-
node->pin_cs = cfg->pin_cs;
node->mode = cfg->mode;
node->data_order = cfg->data_order;
@@ -221,5 +216,10 @@ bus_spi_node_init_func(struct os_dev *odev, void *arg)
hal_gpio_init_out(node->pin_cs, 1);
+ rc = bus_node_init_func(odev, node_cfg);
+ if (rc) {
+ return rc;
+ }
+
return 0;
}
[mynewt-core] 08/14: hw/bus/i2c: Fix node debug poisoning
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit f08bf6639feb01e8da83852672faf702f241c008
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 11:35:58 2018 +0100
hw/bus/i2c: Fix node debug poisoning
---
hw/bus/i2c/src/i2c.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index d9170b7..cbbe948 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -159,6 +159,8 @@ bus_i2c_dev_init_func(struct os_dev *odev, void *arg)
struct hal_i2c_hw_settings hal_cfg;
int rc;
+ BUS_DEBUG_POISON_DEV(dev);
+
hal_cfg.pin_scl = cfg->pin_scl;
hal_cfg.pin_sda = cfg->pin_sda;
rc = hal_i2c_init_hw(cfg->i2c_num, &hal_cfg);
@@ -166,8 +168,6 @@ bus_i2c_dev_init_func(struct os_dev *odev, void *arg)
return SYS_EINVAL;
}
- BUS_DEBUG_POISON_DEV(dev);
-
rc = bus_dev_init_func(odev, (void*)&bus_i2c_ops);
assert(rc == 0);
[mynewt-core] 09/14: hw/bus/i2c: Set I2C pins to high state on
startup
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 0480a955e591eed75e6cb73c17d81b80b12af1cd
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 11:37:10 2018 +0100
hw/bus/i2c: Set I2C pins to high state on startup
This is just to ensure they are in high state until controller is enabled.
---
hw/bus/i2c/src/i2c.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index cbbe948..85a3244 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -19,6 +19,7 @@
#include <assert.h>
#include "defs/error.h"
+#include "hal/hal_gpio.h"
#include "hal/hal_i2c.h"
#include "bus/bus.h"
#include "bus/bus_debug.h"
@@ -161,6 +162,9 @@ bus_i2c_dev_init_func(struct os_dev *odev, void *arg)
BUS_DEBUG_POISON_DEV(dev);
+ hal_gpio_init_out(cfg->pin_scl, 1);
+ hal_gpio_init_out(cfg->pin_sda, 1);
+
hal_cfg.pin_scl = cfg->pin_scl;
hal_cfg.pin_sda = cfg->pin_sda;
rc = hal_i2c_init_hw(cfg->i2c_num, &hal_cfg);
[mynewt-core] 12/14: hw/bus/i2c: Add I2C HAL errors translation
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 8277d29443ee046dbb5c2a9aebcba0ba8d69d05c
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 15:36:21 2018 +0100
hw/bus/i2c: Add I2C HAL errors translation
---
hw/bus/i2c/src/i2c.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/hw/bus/i2c/src/i2c.c b/hw/bus/i2c/src/i2c.c
index 10feca6..afca233 100644
--- a/hw/bus/i2c/src/i2c.c
+++ b/hw/bus/i2c/src/i2c.c
@@ -26,6 +26,27 @@
#include "bus/i2c.h"
static int
+bus_i2c_translate_hal_error(int hal_err)
+{
+ switch (hal_err) {
+ case 0:
+ return 0;
+ case HAL_I2C_ERR_UNKNOWN:
+ return SYS_EUNKNOWN;
+ case HAL_I2C_ERR_INVAL:
+ return SYS_EINVAL;
+ case HAL_I2C_ERR_TIMEOUT:
+ return SYS_ETIMEOUT;
+ case HAL_I2C_ERR_ADDR_NACK:
+ return SYS_ENOENT;
+ case HAL_I2C_ERR_DATA_NACK:
+ return SYS_EREMOTEIO;
+ }
+
+ return SYS_EUNKNOWN;
+}
+
+static int
bus_i2c_enable(struct bus_dev *bdev)
{
struct bus_i2c_dev *dev = (struct bus_i2c_dev *)bdev;
@@ -100,7 +121,7 @@ bus_i2c_read(struct bus_dev *bdev, struct bus_node *bnode, uint8_t *buf,
rc = hal_i2c_master_read(dev->cfg.i2c_num, &i2c_data, timeout, last_op);
- return rc;
+ return bus_i2c_translate_hal_error(rc);
}
static int
@@ -124,7 +145,7 @@ bus_i2c_write(struct bus_dev *bdev, struct bus_node *bnode, const uint8_t *buf,
rc = hal_i2c_master_write(dev->cfg.i2c_num, &i2c_data, timeout, last_op);
- return rc;
+ return bus_i2c_translate_hal_error(rc);
}
static int bus_i2c_disable(struct bus_dev *bdev)
[mynewt-core] 03/14: hw/mcu/nordic: Enable all available buses for
bus driver
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 29f110d58a941af5e9d7279fa3bde33d41c38fd4
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Fri Nov 23 17:20:56 2018 +0100
hw/mcu/nordic: Enable all available buses for bus driver
---
hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
index 0aaacd7..2b49c2e 100644
--- a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
+++ b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
@@ -127,6 +127,15 @@ static const struct nrf52_hal_i2c_cfg hal_i2c1_cfg = {
#endif
#if MYNEWT_VAL(SPI_0_MASTER)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+static const struct bus_spi_dev_cfg spi0_cfg = {
+ .spi_num = 0,
+ .pin_sck = MYNEWT_VAL(SPI_0_MASTER_PIN_SCK),
+ .pin_mosi = MYNEWT_VAL(SPI_0_MASTER_PIN_MOSI),
+ .pin_miso = MYNEWT_VAL(SPI_0_MASTER_PIN_MISO),
+};
+static struct bus_spi_dev spi0_bus;
+#else
static const struct nrf52_hal_spi_cfg os_bsp_spi0m_cfg = {
.sck_pin = MYNEWT_VAL(SPI_0_MASTER_PIN_SCK),
.mosi_pin = MYNEWT_VAL(SPI_0_MASTER_PIN_MOSI),
@@ -134,6 +143,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi0m_cfg = {
/* For SPI master, SS pin is controlled as regular GPIO */
};
#endif
+#endif
#if MYNEWT_VAL(SPI_0_SLAVE)
static const struct nrf52_hal_spi_cfg os_bsp_spi0s_cfg = {
.sck_pin = MYNEWT_VAL(SPI_0_SLAVE_PIN_SCK),
@@ -169,6 +179,15 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi1s_cfg = {
};
#endif
#if MYNEWT_VAL(SPI_2_MASTER)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+static const struct bus_spi_dev_cfg spi2_cfg = {
+ .spi_num = 2,
+ .pin_sck = MYNEWT_VAL(SPI_2_MASTER_PIN_SCK),
+ .pin_mosi = MYNEWT_VAL(SPI_2_MASTER_PIN_MOSI),
+ .pin_miso = MYNEWT_VAL(SPI_2_MASTER_PIN_MISO),
+};
+static struct bus_spi_dev spi2_bus;
+#else
static const struct nrf52_hal_spi_cfg os_bsp_spi2m_cfg = {
.sck_pin = MYNEWT_VAL(SPI_2_MASTER_PIN_SCK),
.mosi_pin = MYNEWT_VAL(SPI_2_MASTER_PIN_MOSI),
@@ -176,6 +195,7 @@ static const struct nrf52_hal_spi_cfg os_bsp_spi2m_cfg = {
/* For SPI master, SS pin is controlled as regular GPIO */
};
#endif
+#endif
#if MYNEWT_VAL(SPI_2_SLAVE)
static const struct nrf52_hal_spi_cfg os_bsp_spi2s_cfg = {
.sck_pin = MYNEWT_VAL(SPI_2_SLAVE_PIN_SCK),
@@ -342,9 +362,14 @@ nrf52_periph_create_spi(void)
(void)rc;
#if MYNEWT_VAL(SPI_0_MASTER)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+ rc = bus_spi_dev_create("spi0", &spi0_bus, (struct bus_spi_dev_cfg *)&spi0_cfg);
+ assert(rc == 0);
+#else
rc = hal_spi_init(0, (void *)&os_bsp_spi0m_cfg, HAL_SPI_TYPE_MASTER);
assert(rc == 0);
#endif
+#endif
#if MYNEWT_VAL(SPI_0_SLAVE)
rc = hal_spi_init(0, (void *)&os_bsp_spi0s_cfg, HAL_SPI_TYPE_SLAVE);
assert(rc == 0);
@@ -363,9 +388,14 @@ nrf52_periph_create_spi(void)
assert(rc == 0);
#endif
#if MYNEWT_VAL(SPI_2_MASTER)
+#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, (void *)&os_bsp_spi2m_cfg, HAL_SPI_TYPE_MASTER);
assert(rc == 0);
#endif
+#endif
#if MYNEWT_VAL(SPI_2_SLAVE)
rc = hal_spi_init(2, (void *)&os_bsp_spi2s_cfg, HAL_SPI_TYPE_SLAVE);
assert(rc == 0);
[mynewt-core] 05/14: hw/bus: Make bus lock time configurable
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit aee70f7530f753369a9531dfc0f249e94046ef3b
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 12:15:18 2018 +0100
hw/bus: Make bus lock time configurable
Bus lock time is now configurable. There's global default timeout but
it will be possible to configure it per-node if necessary (not yet
implemented).
Also, when locking manually caller can use predefined symbol instead of
actual timeout value and default timeout will be used.
---
hw/bus/include/bus/bus.h | 14 ++++++++++++++
hw/bus/src/bus.c | 22 +++++++++++++++++++---
hw/bus/syscfg.yml | 4 ++++
3 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/hw/bus/include/bus/bus.h b/hw/bus/include/bus/bus.h
index 11a8d07..dbccd7b 100644
--- a/hw/bus/include/bus/bus.h
+++ b/hw/bus/include/bus/bus.h
@@ -35,6 +35,9 @@ extern "C" {
#define BUS_F_NONE 0
#define BUS_F_NOSTOP 0x0001
+/* Use as default timeout to lock node */
+#define BUS_NODE_LOCK_DEFAULT_TIMEOUT ((os_time_t) -1)
+
/**
* Read data from node
*
@@ -210,6 +213,17 @@ bus_node_lock(struct os_dev *node, os_time_t timeout);
int
bus_node_unlock(struct os_dev *node);
+/**
+ * Get node configured lock timeout
+ *
+ * Returns lock timeout as configured for node. If not timeout is configured for
+ * give node or no node is specified, default timeout is returned.
+ *
+ * @param node Node to get timeout for
+ */
+os_time_t
+bus_node_get_lock_timeout(struct os_dev *node);
+
#ifdef __cplusplus
}
#endif
diff --git a/hw/bus/src/bus.c b/hw/bus/src/bus.c
index 4635969..89e2882 100644
--- a/hw/bus/src/bus.c
+++ b/hw/bus/src/bus.c
@@ -24,6 +24,8 @@
#include "bus/bus_debug.h"
#include "bus/bus_driver.h"
+static os_time_t g_bus_node_lock_timeout;
+
static int
bus_node_open_func(struct os_dev *odev, uint32_t wait, void *arg)
{
@@ -145,7 +147,7 @@ bus_node_read(struct os_dev *node, void *buf, uint16_t length,
return SYS_ENOTSUP;
}
- rc = bus_node_lock(node, timeout);
+ rc = bus_node_lock(node, g_bus_node_lock_timeout);
if (rc) {
return rc;
}
@@ -172,7 +174,7 @@ bus_node_write(struct os_dev *node, const void *buf, uint16_t length,
return SYS_ENOTSUP;
}
- rc = bus_node_lock(node, timeout);
+ rc = bus_node_lock(node, g_bus_node_lock_timeout);
if (rc) {
return rc;
}
@@ -200,7 +202,7 @@ bus_node_write_read_transact(struct os_dev *node, const void *wbuf,
return SYS_ENOTSUP;
}
- rc = bus_node_lock(node, timeout);
+ rc = bus_node_lock(node, g_bus_node_lock_timeout);
if (rc) {
return rc;
}
@@ -239,6 +241,10 @@ bus_node_lock(struct os_dev *node, os_time_t timeout)
BUS_DEBUG_VERIFY_DEV(bdev);
BUS_DEBUG_VERIFY_NODE(bnode);
+ if (timeout == BUS_NODE_LOCK_DEFAULT_TIMEOUT) {
+ timeout = g_bus_node_lock_timeout;
+ }
+
err = os_mutex_pend(&bdev->lock, timeout);
if (err == OS_TIMEOUT) {
return SYS_ETIMEOUT;
@@ -285,8 +291,18 @@ bus_node_unlock(struct os_dev *node)
return 0;
}
+os_time_t
+bus_node_get_lock_timeout(struct os_dev *node)
+{
+ return g_bus_node_lock_timeout;
+}
+
void
bus_pkg_init(void)
{
+ uint32_t lock_timeout_ms;
+
+ lock_timeout_ms = MYNEWT_VAL(BUS_DEFAULT_LOCK_TIMEOUT_MS);
+ g_bus_node_lock_timeout = os_time_ms_to_ticks32(lock_timeout_ms);
}
diff --git a/hw/bus/syscfg.yml b/hw/bus/syscfg.yml
index 62653bc..be0d133 100644
--- a/hw/bus/syscfg.yml
+++ b/hw/bus/syscfg.yml
@@ -22,6 +22,10 @@ syscfg.defs:
This indicated that hw/bus package is present in build.
Do not override this settings.
value: 1
+ BUS_DEFAULT_LOCK_TIMEOUT_MS:
+ description: >
+ Default timeout for locking the bus. This can be overriden per-node.
+ value: 1000
BUS_DEBUG_OS_DEV:
description: >
[mynewt-core] 04/14: hw/mcu/nordic: Fix bus driver headers
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit f098d8535e5d656bcad8d23bb059ab7f3feeb601
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Nov 27 15:07:23 2018 +0100
hw/mcu/nordic: Fix bus driver headers
---
hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
index 2b49c2e..8004174 100644
--- a/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
+++ b/hw/mcu/nordic/nrf52xxx/src/nrf52_periph.c
@@ -24,14 +24,15 @@
#include "hal/hal_i2c.h"
#include "hal/hal_spi.h"
#include "bsp/bsp.h"
-#if MYNEWT_VAL(I2C_0) || MYNEWT_VAL(I2C_1)
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
#include "bus/bus.h"
+#if MYNEWT_VAL(I2C_0) || MYNEWT_VAL(I2C_1)
#include "bus/i2c.h"
#endif
-#if MYNEWT_VAL(SPI_1_MASTER)
-#include "bus/bus.h"
+#if MYNEWT_VAL(SPI_0_MASTER) || MYNEWT_VAL(SPI_1_MASTER) || MYNEWT_VAL(SPI_2_MASTER)
#include "bus/spi.h"
#endif
+#endif
#include "nrfx.h"
#if MYNEWT_VAL(ADC_0)
#include "adc/adc.h"
[mynewt-core] 07/14: hw/bus: Add missing unlock when configuration
failed
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 9fa8934774ded764c5f94c4527d0a3b9820a55f6
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon Nov 26 12:18:05 2018 +0100
hw/bus: Add missing unlock when configuration failed
---
hw/bus/src/bus.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/bus/src/bus.c b/hw/bus/src/bus.c
index 89e2882..c555f17 100644
--- a/hw/bus/src/bus.c
+++ b/hw/bus/src/bus.c
@@ -260,6 +260,7 @@ bus_node_lock(struct os_dev *node, os_time_t timeout)
rc = bdev->dops->configure(bdev, bnode);
if (rc) {
bdev->configured_for = NULL;
+ (void)bus_node_unlock(node);
} else {
bdev->configured_for = bnode;
}