[mynewt-core] branch master updated (461f880 -> 957010a)

2021-02-12 Thread jerzy
This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git.


from 461f880  Enable Mbed TLS self-tests which were not running
 new 5bb4570  mcu/stm: Add DMA allocation schema API
 new e755743  bus/spi_stm32: Add SPI bus driver
 new 957010a  stm32: Add SPI bus creation

The 3 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:
 .../spi_stm32/include/bus/drivers/spi_stm32.h  |  70 ++
 .../stm32wbxx => bus/drivers/spi_stm32}/pkg.yml|  42 +-
 hw/bus/drivers/spi_stm32/src/spi_stm32.c   | 881 +
 .../spi_stm32/stm32f0xx/include/spidmacfg.h|  41 +
 .../drivers/spi_stm32/stm32f0xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c |  81 ++
 .../drivers/spi_stm32/stm32f0xx/syscfg.yml}|  45 +-
 .../spi_stm32/stm32f1xx/include/spidmacfg.h|  41 +
 .../drivers/spi_stm32/stm32f1xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32f1xx/src/spidmacfg.c |  73 ++
 hw/bus/drivers/spi_stm32/stm32f1xx/syscfg.yml  |  47 ++
 .../spi_stm32/stm32f3xx/include/spidmacfg.h|  41 +
 .../drivers/spi_stm32/stm32f3xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32f3xx/src/spidmacfg.c |  80 ++
 hw/bus/drivers/spi_stm32/stm32f3xx/syscfg.yml  |  58 ++
 .../spi_stm32/stm32f4xx/include/spidmacfg.h|  62 ++
 .../drivers/spi_stm32/stm32f4xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32f4xx/src/spidmacfg.c |  96 +++
 hw/bus/drivers/spi_stm32/stm32f4xx/syscfg.yml  |  93 +++
 .../spi_stm32/stm32f7xx/include/spidmacfg.h|  62 ++
 .../drivers/spi_stm32/stm32f7xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32f7xx/src/spidmacfg.c |  96 +++
 hw/bus/drivers/spi_stm32/stm32f7xx/syscfg.yml  |  93 +++
 .../spi_stm32/stm32l0xx/include/spidmacfg.h|  41 +
 .../drivers/spi_stm32}/stm32l0xx/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32l0xx/src/spidmacfg.c |  75 ++
 .../drivers/spi_stm32/stm32l0xx/syscfg.yml}|  43 +-
 .../spi_stm32/stm32l1xx/include/spidmacfg.h|  41 +
 .../drivers/spi_stm32/stm32l1xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32l1xx/src/spidmacfg.c |  73 ++
 hw/bus/drivers/spi_stm32/stm32l1xx/syscfg.yml  |  47 ++
 .../spi_stm32/stm32l4xx/include/spidmacfg.h|  44 +
 .../drivers/spi_stm32/stm32l4xx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32l4xx/src/spidmacfg.c |  70 ++
 hw/bus/drivers/spi_stm32/stm32l4xx/syscfg.yml  |  49 ++
 .../spi_stm32/stm32wbxx/include/spidmacfg.h|  95 +++
 .../drivers/spi_stm32/stm32wbxx}/pkg.yml   |  21 +-
 hw/bus/drivers/spi_stm32/stm32wbxx/src/spidmacfg.c | 118 +++
 hw/bus/drivers/spi_stm32/stm32wbxx/syscfg.yml  |  46 ++
 .../pkg.yml => bus/drivers/spi_stm32/syscfg.yml}   |  40 +-
 .../stm32_common/include/stm32_common/stm32_dma.h  | 106 +++
 hw/mcu/stm/stm32_common/src/stm32_dma.c| 279 +++
 hw/mcu/stm/stm32_common/src/stm32_periph.c | 113 +++
 hw/mcu/stm/stm32f0xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f1xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f3xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f4xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f7xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l0xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l1xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l4xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32wbxx/pkg.yml   |   3 +
 52 files changed, 3278 insertions(+), 220 deletions(-)
 create mode 100644 hw/bus/drivers/spi_stm32/include/bus/drivers/spi_stm32.h
 copy hw/{mcu/stm/stm32wbxx => bus/drivers/spi_stm32}/pkg.yml (55%)
 create mode 100644 hw/bus/drivers/spi_stm32/src/spi_stm32.c
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f0xx/include/spidmacfg.h
 copy hw/{mcu/stm/stm32l0xx => bus/drivers/spi_stm32/stm32f0xx}/pkg.yml (77%)
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c
 copy hw/{mcu/stm/stm32f7xx/pkg.yml => 
bus/drivers/spi_stm32/stm32f0xx/syscfg.yml} (51%)
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f1xx/include/spidmacfg.h
 copy hw/{mcu/stm/stm32l0xx => bus/drivers/spi_stm32/stm32f1xx}/pkg.yml (77%)
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f1xx/src/spidmacfg.c
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f1xx/syscfg.yml
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f3xx/include/spidmacfg.h
 copy hw/{mcu/stm/stm32l0xx => bus/drivers/spi_stm32/stm32f3xx}/pkg.yml (77%)
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f3xx/src/spidmacfg.c
 create mode 100644 hw/bus/drivers/spi_stm32/stm32f3xx/syscfg.yml
 

[mynewt-core] 02/03: bus/spi_stm32: Add SPI bus driver

2021-02-12 Thread jerzy
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 e755743de14968358adadb697b2a9e8efa69af94
Author: Jerzy Kasenberg 
AuthorDate: Tue Jan 26 15:37:45 2021 +0100

bus/spi_stm32: Add SPI bus driver

This adds bus driver for STM32 MCUs.
Common code uses STM HAL functions to handle SPI
transfers using interrupts and DMA.

Separate DMA initialization structures are provided for
each supported family.

Code also takes care of pin configuration so the user
does not need to configure pins directly but just
specify some pin numbers and intended function.
---
 .../spi_stm32/include/bus/drivers/spi_stm32.h  |  70 ++
 hw/bus/drivers/spi_stm32/pkg.yml   |  55 ++
 hw/bus/drivers/spi_stm32/src/spi_stm32.c   | 881 +
 .../spi_stm32/stm32f0xx/include/spidmacfg.h|  41 +
 hw/bus/drivers/spi_stm32/stm32f0xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c |  81 ++
 hw/bus/drivers/spi_stm32/stm32f0xx/syscfg.yml  |  42 +
 .../spi_stm32/stm32f1xx/include/spidmacfg.h|  41 +
 hw/bus/drivers/spi_stm32/stm32f1xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32f1xx/src/spidmacfg.c |  73 ++
 hw/bus/drivers/spi_stm32/stm32f1xx/syscfg.yml  |  47 ++
 .../spi_stm32/stm32f3xx/include/spidmacfg.h|  41 +
 hw/bus/drivers/spi_stm32/stm32f3xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32f3xx/src/spidmacfg.c |  80 ++
 hw/bus/drivers/spi_stm32/stm32f3xx/syscfg.yml  |  58 ++
 .../spi_stm32/stm32f4xx/include/spidmacfg.h|  62 ++
 hw/bus/drivers/spi_stm32/stm32f4xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32f4xx/src/spidmacfg.c |  96 +++
 hw/bus/drivers/spi_stm32/stm32f4xx/syscfg.yml  |  93 +++
 .../spi_stm32/stm32f7xx/include/spidmacfg.h|  62 ++
 hw/bus/drivers/spi_stm32/stm32f7xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32f7xx/src/spidmacfg.c |  96 +++
 hw/bus/drivers/spi_stm32/stm32f7xx/syscfg.yml  |  93 +++
 .../spi_stm32/stm32l0xx/include/spidmacfg.h|  41 +
 hw/bus/drivers/spi_stm32/stm32l0xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32l0xx/src/spidmacfg.c |  75 ++
 hw/bus/drivers/spi_stm32/stm32l0xx/syscfg.yml  |  40 +
 .../spi_stm32/stm32l1xx/include/spidmacfg.h|  41 +
 hw/bus/drivers/spi_stm32/stm32l1xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32l1xx/src/spidmacfg.c |  73 ++
 hw/bus/drivers/spi_stm32/stm32l1xx/syscfg.yml  |  47 ++
 .../spi_stm32/stm32l4xx/include/spidmacfg.h|  44 +
 hw/bus/drivers/spi_stm32/stm32l4xx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32l4xx/src/spidmacfg.c |  70 ++
 hw/bus/drivers/spi_stm32/stm32l4xx/syscfg.yml  |  49 ++
 .../spi_stm32/stm32wbxx/include/spidmacfg.h|  95 +++
 hw/bus/drivers/spi_stm32/stm32wbxx/pkg.yml |  28 +
 hw/bus/drivers/spi_stm32/stm32wbxx/src/spidmacfg.c | 118 +++
 hw/bus/drivers/spi_stm32/stm32wbxx/syscfg.yml  |  46 ++
 hw/bus/drivers/spi_stm32/syscfg.yml|  37 +
 40 files changed, 3040 insertions(+)

diff --git a/hw/bus/drivers/spi_stm32/include/bus/drivers/spi_stm32.h 
b/hw/bus/drivers/spi_stm32/include/bus/drivers/spi_stm32.h
new file mode 100644
index 000..052fe2b
--- /dev/null
+++ b/hw/bus/drivers/spi_stm32/include/bus/drivers/spi_stm32.h
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef HW_BUS_DRIVERS_SPI_STM32_H_
+#define HW_BUS_DRIVERS_SPI_STM32_H_
+
+#include 
+#include 
+#include "os/os_dev.h"
+#include "bus/drivers/spi_common.h"
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initialize os_dev as SPI bus device using spi_hal driver
+ *
+ * This can be passed as a parameter to os_dev_create() when creating os_dev
+ * object for SPI device, however it's recommended to create devices using 
helper
+ * like bus_spi_hal_dev_create().
+ *
+ * @param odev  Node device object
+ * @param arg   Node configuration struct (struct bus_node_cfg)
+ */
+int
+bus_spi_stm32_dev_init_func(struct os_dev *odev, void *arg);
+
+/**
+ * Create SPI 

[mynewt-core] 01/03: mcu/stm: Add DMA allocation schema API

2021-02-12 Thread jerzy
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 5bb45700b36bc8ac9e52677dcf6ced4118f0e1ce
Author: Jerzy Kasenberg 
AuthorDate: Tue Jan 26 15:24:26 2021 +0100

mcu/stm: Add DMA allocation schema API

API for using ST HAL DMA functionality.
It allows to safely share DMA channels/streams.

All ST HAL uses same style functions for accessing
peripherals. This adds allocate/release functionality.
It also provides DMA interrupt handlers that will
call ST HAL handlers with currently allocated for channel
peripheral.
---
 .../stm32_common/include/stm32_common/stm32_dma.h  | 106 
 hw/mcu/stm/stm32_common/src/stm32_dma.c| 279 +
 2 files changed, 385 insertions(+)

diff --git a/hw/mcu/stm/stm32_common/include/stm32_common/stm32_dma.h 
b/hw/mcu/stm/stm32_common/include/stm32_common/stm32_dma.h
new file mode 100644
index 000..2386a9f
--- /dev/null
+++ b/hw/mcu/stm/stm32_common/include/stm32_common/stm32_dma.h
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef __STM32_DMA_H_
+#define __STM32_DMA_H_
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Enum for DMA channel.
+ * For F0, F1, F3, L0, L1, L4, WB it represents channel
+ * For F4, F7 it represents stream (because channel has other meaning).
+ */
+typedef enum {
+DMA1_CH0,
+DMA1_CH1,
+DMA1_CH2,
+DMA1_CH3,
+DMA1_CH4,
+DMA1_CH5,
+DMA1_CH6,
+DMA1_CH7,
+DMA2_CH0,
+DMA2_CH1,
+DMA2_CH2,
+DMA2_CH3,
+DMA2_CH4,
+DMA2_CH5,
+DMA2_CH6,
+DMA2_CH7,
+DMA_CH_NUM,
+} stm32_dma_ch_t;
+
+/**
+ * Allocate DMA channel for specific ST DMA handle.
+ *
+ * Function assigns DMA handle to DMA channel.
+ * This handle is later used in interrupt handlers.
+ *
+ * @param chDMA channel id
+ * @param hdma  DMA handle to assign to channel
+ * @return SYS_EBUSY - when channel is already allocated
+ * SYS_EOK - on success
+ */
+int stm32_dma_acquire_channel(stm32_dma_ch_t ch, DMA_HandleTypeDef *hdma);
+
+/**
+ * Release DMA channel.
+ *
+ * @param chDMA channel that was allocated with stm32_dma_acquire_channel()
+ *
+ * @return  SYS_EOK on success
+ *  SYS_EINVAL if channel was not previously allocated
+ */
+int stm32_dma_release_channel(stm32_dma_ch_t ch);
+
+/*
+ * Functions that can be used as interrupt handlers that redirect
+ * code execution to ST HAL drivers.
+ */
+void stm32_dma1_0_irq_handler(void);
+void stm32_dma1_1_irq_handler(void);
+void stm32_dma1_2_irq_handler(void);
+void stm32_dma1_3_irq_handler(void);
+void stm32_dma1_4_irq_handler(void);
+void stm32_dma1_5_irq_handler(void);
+void stm32_dma1_6_irq_handler(void);
+void stm32_dma1_7_irq_handler(void);
+void stm32_dma2_0_irq_handler(void);
+void stm32_dma2_1_irq_handler(void);
+void stm32_dma2_2_irq_handler(void);
+void stm32_dma2_3_irq_handler(void);
+void stm32_dma2_4_irq_handler(void);
+void stm32_dma2_5_irq_handler(void);
+void stm32_dma2_6_irq_handler(void);
+void stm32_dma2_7_irq_handler(void);
+
+/* F0 and L0 can have common vector for several DMA channels */
+void stm32_dma1_2_3_irq_handler(void);
+void stm32_dma1_4_5_6_7_irq_handler(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32_DMA_H_ */
diff --git a/hw/mcu/stm/stm32_common/src/stm32_dma.c 
b/hw/mcu/stm/stm32_common/src/stm32_dma.c
new file mode 100644
index 000..b2ab923
--- /dev/null
+++ b/hw/mcu/stm/stm32_common/src/stm32_dma.c
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed 

[GitHub] [mynewt-core] kasjer merged pull request #2461: stm32 spi bus driver

2021-02-12 Thread GitBox


kasjer merged pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461


   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[mynewt-core] 03/03: stm32: Add SPI bus creation

2021-02-12 Thread jerzy
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 957010a397c078a25f3679e62f1496f90d7601ba
Author: Jerzy Kasenberg 
AuthorDate: Tue Jan 26 15:59:23 2021 +0100

stm32: Add SPI bus creation

When SPI bus driver is present in the project,
bus devices are creating during peripheral creation
instead of hal only SPI support.
---
 hw/mcu/stm/stm32_common/src/stm32_periph.c | 113 +
 hw/mcu/stm/stm32f0xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f1xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f3xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f4xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32f7xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l0xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l1xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32l4xx/pkg.yml   |   3 +
 hw/mcu/stm/stm32wbxx/pkg.yml   |   3 +
 10 files changed, 140 insertions(+)

diff --git a/hw/mcu/stm/stm32_common/src/stm32_periph.c 
b/hw/mcu/stm/stm32_common/src/stm32_periph.c
index d8e43a3..bf687a2 100644
--- a/hw/mcu/stm/stm32_common/src/stm32_periph.c
+++ b/hw/mcu/stm/stm32_common/src/stm32_periph.c
@@ -41,6 +41,13 @@
 #include "uart/uart.h"
 #include "uart_hal/uart_hal.h"
 #endif
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+#include "bus/bus.h"
+#if MYNEWT_VAL(SPI_0_MASTER) || MYNEWT_VAL(SPI_1_MASTER) || 
MYNEWT_VAL(SPI_2_MASTER) || MYNEWT_VAL(SPI_3_MASTER) || \
+MYNEWT_VAL(SPI_4_MASTER) || MYNEWT_VAL(SPI_5_MASTER)
+#include "bus/drivers/spi_stm32.h"
+#endif
+#endif
 #if MYNEWT_VAL(PWM_0) || MYNEWT_VAL(PWM_1) || MYNEWT_VAL(PWM_2)
 #include 
 #endif
@@ -148,6 +155,69 @@ extern const struct stm32_hal_i2c_cfg os_bsp_i2c1_cfg;
 extern const struct stm32_hal_i2c_cfg os_bsp_i2c2_cfg;
 #endif
 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+static const struct bus_spi_dev_cfg spi0_cfg = {
+.spi_num = 0,
+.pin_sck = MYNEWT_VAL(SPI_0_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_0_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_0_PIN_MISO),
+};
+static struct bus_spi_dev spi0_bus;
+#endif
+
+#if MYNEWT_VAL(SPI_1_MASTER)
+static const struct bus_spi_dev_cfg spi1_cfg = {
+.spi_num = 1,
+.pin_sck = MYNEWT_VAL(SPI_1_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_1_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_1_PIN_MISO),
+};
+static struct bus_spi_dev spi1_bus;
+#endif
+
+#if MYNEWT_VAL(SPI_2_MASTER)
+static const struct bus_spi_dev_cfg spi2_cfg = {
+.spi_num = 2,
+.pin_sck = MYNEWT_VAL(SPI_2_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_2_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_2_PIN_MISO),
+};
+static struct bus_spi_dev spi2_bus;
+#endif
+
+#if MYNEWT_VAL(SPI_3_MASTER)
+static const struct bus_spi_dev_cfg spi3_cfg = {
+.spi_num = 3,
+.pin_sck = MYNEWT_VAL(SPI_3_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_3_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_3_PIN_MISO),
+};
+static struct bus_spi_dev spi3_bus;
+#endif
+
+#if MYNEWT_VAL(SPI_4_MASTER)
+static const struct bus_spi_dev_cfg spi4_cfg = {
+.spi_num = 4,
+.pin_sck = MYNEWT_VAL(SPI_4_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_4_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_4_PIN_MISO),
+};
+static struct bus_spi_dev spi4_bus;
+#endif
+
+#if MYNEWT_VAL(SPI_5_MASTER)
+static const struct bus_spi_dev_cfg spi5_cfg = {
+.spi_num = 5,
+.pin_sck = MYNEWT_VAL(SPI_5_PIN_SCK),
+.pin_mosi = MYNEWT_VAL(SPI_5_PIN_MOSI),
+.pin_miso = MYNEWT_VAL(SPI_5_PIN_MISO),
+};
+static struct bus_spi_dev spi5_bus;
+#endif
+
+#else
 #if (MYNEWT_VAL(SPI_0_MASTER) || MYNEWT_VAL(SPI_0_SLAVE))
 #if MYNEWT_VAL(SPI_0_CUSTOM_CFG)
 extern const struct stm32_hal_spi_cfg os_bsp_spi0_cfg;
@@ -200,6 +270,7 @@ static const struct stm32_hal_spi_cfg os_bsp_spi3_cfg = {
 };
 #endif
 #endif
+#endif
 
 #if MYNEWT_VAL(ETH_0)
 extern const struct stm32_eth_cfg os_bsp_eth0_cfg;
@@ -403,6 +474,47 @@ stm32_periph_create_i2c(void)
 #endif
 }
 
+#if MYNEWT_VAL(BUS_DRIVER_PRESENT)
+static void
+stm32_periph_create_spi(void)
+{
+int rc;
+
+(void)rc;
+
+#if MYNEWT_VAL(SPI_0_MASTER)
+rc = bus_spi_stm32_dev_create("spi0", _bus,
+  (struct bus_spi_dev_cfg *)_cfg);
+assert(rc == 0);
+#endif
+#if MYNEWT_VAL(SPI_1_MASTER)
+rc = bus_spi_stm32_dev_create("spi1", _bus,
+  (struct bus_spi_dev_cfg *)_cfg);
+assert(rc == 0);
+#endif
+#if MYNEWT_VAL(SPI_2_MASTER)
+rc = bus_spi_stm32_dev_create("spi2", _bus,
+  (struct bus_spi_dev_cfg *)_cfg);
+assert(rc == 0);
+#endif
+#if MYNEWT_VAL(SPI_3_MASTER)
+rc = bus_spi_stm32_dev_create("spi3", _bus,
+  (struct bus_spi_dev_cfg *)_cfg);
+assert(rc == 0);
+#endif
+#if MYNEWT_VAL(SPI_4_MASTER)
+rc = bus_spi_stm32_dev_create("spi4", _bus,
+  (struct bus_spi_dev_cfg *)_cfg);

[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2461: stm32 spi bus driver

2021-02-12 Thread GitBox


apache-mynewt-bot removed a comment on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-773090058


   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/bus/drivers/spi_stm32/src/spi_stm32.c
   
   
   ```diff
   @@ -66,15 +66,15 @@

#if MYNEWT_VAL(SPI_STM32_STAT)
STATS_SECT_START(spi_stm32_stats_section)
   -STATS_SECT_ENTRY(read_bytes)
   -STATS_SECT_ENTRY(written_bytes)
   -STATS_SECT_ENTRY(dma_transferred_bytes)
   +STATS_SECT_ENTRY(read_bytes)
   +STATS_SECT_ENTRY(written_bytes)
   +STATS_SECT_ENTRY(dma_transferred_bytes)
STATS_SECT_END

STATS_NAME_START(spi_stm32_stats_section)
   -STATS_NAME(spi_stm32_stats_section, read_bytes)
   -STATS_NAME(spi_stm32_stats_section, written_bytes)
   -STATS_NAME(spi_stm32_stats_section, dma_transferred_bytes)
   +STATS_NAME(spi_stm32_stats_section, read_bytes)
   +STATS_NAME(spi_stm32_stats_section, written_bytes)
   +STATS_NAME(spi_stm32_stats_section, dma_transferred_bytes)
STATS_NAME_END(spi_stm32_stats_section)
#endif

   ```
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2461: stm32 spi bus driver

2021-02-12 Thread GitBox


apache-mynewt-bot commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-778230462


   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/bus/drivers/spi_stm32/src/spi_stm32.c
   
   
   ```diff
   @@ -66,15 +66,15 @@

#if MYNEWT_VAL(SPI_STM32_STAT)
STATS_SECT_START(spi_stm32_stats_section)
   -STATS_SECT_ENTRY(read_bytes)
   -STATS_SECT_ENTRY(written_bytes)
   -STATS_SECT_ENTRY(dma_transferred_bytes)
   +STATS_SECT_ENTRY(read_bytes)
   +STATS_SECT_ENTRY(written_bytes)
   +STATS_SECT_ENTRY(dma_transferred_bytes)
STATS_SECT_END

STATS_NAME_START(spi_stm32_stats_section)
   -STATS_NAME(spi_stm32_stats_section, read_bytes)
   -STATS_NAME(spi_stm32_stats_section, written_bytes)
   -STATS_NAME(spi_stm32_stats_section, dma_transferred_bytes)
   +STATS_NAME(spi_stm32_stats_section, read_bytes)
   +STATS_NAME(spi_stm32_stats_section, written_bytes)
   +STATS_NAME(spi_stm32_stats_section, dma_transferred_bytes)
STATS_NAME_END(spi_stm32_stats_section)
#endif

   ```
   
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [mynewt-core] kasjer commented on pull request #2461: stm32 spi bus driver

2021-02-12 Thread GitBox


kasjer commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-778230139


   rebased as requested



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[mynewt-mcumgr] branch master updated (130ae98 -> 35d290e)

2021-02-12 Thread utzig
This is an automated email from the ASF dual-hosted git repository.

utzig pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git.


from 130ae98  Merge pull request #111 from utzig/fix-linked-list
 new c8151d8  zephyr: Rely on img_mgmt_find_best_area_id to select update 
partition
 new 35d290e  zephyr: Use flash_img_init_id instead of flash_img_init

The 2 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:
 cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)



[GitHub] [mynewt-mcumgr] utzig merged pull request #110: Use img_mgmt_find_best_area_id to select upload slot instead of FLASH_AREA_ID

2021-02-12 Thread GitBox


utzig merged pull request #110:
URL: https://github.com/apache/mynewt-mcumgr/pull/110


   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[mynewt-mcumgr] 01/02: zephyr: Rely on img_mgmt_find_best_area_id to select update partition

2021-02-12 Thread utzig
This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit c8151d8023f2f985c66a9dcecb4e741cf5306393
Author: Dominik Ermel 
AuthorDate: Thu Feb 11 12:08:22 2021 +

zephyr: Rely on img_mgmt_find_best_area_id to select update partition

The img_mgmt_find_best_area_id is supposed to figure out the best, which
also means possible, partition for software update.
Unfortunately in the code in many places the direct reference the to
FLASH_AREA_ID(image_1) is used, which may cause image_1 being
overwritten, even if other partition would be selected as the "best".

Signed-off-by: Dominik Ermel 
---
 cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c 
b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
index d6169b8..ef72c1e 100644
--- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
+++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
@@ -194,14 +194,16 @@ img_mgmt_impl_erase_slot(void)
 bool empty;
 int rc;
 
-rc = zephyr_img_mgmt_flash_check_empty(FLASH_AREA_ID(image_1),
-   );
+/* Select non-active slot */
+const int best_id = img_mgmt_find_best_area_id();
+
+rc = zephyr_img_mgmt_flash_check_empty(best_id, );
 if (rc != 0) {
 return MGMT_ERR_EUNKNOWN;
 }
 
 if (!empty) {
-rc = boot_erase_img_bank(FLASH_AREA_ID(image_1));
+rc = boot_erase_img_bank(best_id);
 if (rc != 0) {
 return MGMT_ERR_EUNKNOWN;
 }
@@ -328,7 +330,7 @@ img_mgmt_impl_erase_image_data(unsigned int off, unsigned 
int num_bytes)
 goto end;
 }
 
-rc = flash_area_open(FLASH_AREA_ID(image_1), );
+rc = flash_area_open(img_mgmt_find_best_area_id(), );
 if (rc != 0) {
 LOG_ERR("Can't bind to the flash area (err %d)", rc);
 rc = MGMT_ERR_EUNKNOWN;



[mynewt-mcumgr] 02/02: zephyr: Use flash_img_init_id instead of flash_img_init

2021-02-12 Thread utzig
This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git

commit 35d290eadf4414f4902da67e01b165a39e61080c
Author: Dominik Ermel 
AuthorDate: Thu Feb 11 12:14:41 2021 +

zephyr: Use flash_img_init_id instead of flash_img_init

Within mcumgr Zephyr port, the img_mgmt_find_best_area_id is used to
get information on the update flash ID, yet the call to the flash_img_init
selects such flash ID via value hardcoded during compilation. This may
lead to situation where the mcumgr library and flash_img_init may select
different partition for update.
This commit replaces call to flash_img_init with flash_img_init_id, which
takes flash area ID as a parameter, and uses img_mgmt_find_best_area_id
to get the ID.
This approach is better as img_mgmt_find_best_area_id, while searching for
empty image, will also check its boot status (pending, test, etc).

Signed-off-by: Dominik Ermel 
---
 cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c 
b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
index ef72c1e..777aad5 100644
--- a/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
+++ b/cmd/img_mgmt/port/zephyr/src/zephyr_img_mgmt.c
@@ -292,7 +292,7 @@ img_mgmt_impl_write_image_data(unsigned int offset, const 
void *data,
}
}
 #endif
-   rc = flash_img_init(ctx);
+   rc = flash_img_init_id(ctx, img_mgmt_find_best_area_id());
 
if (rc != 0) {
return MGMT_ERR_EUNKNOWN;