You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/01/27 10:03:04 UTC

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

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


   This adds SPI bus driver that utilizes DMA.
   
   Code uses ST HAL drivers for all MCUs.
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-772577358


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   @@ -649,8 +649,8 @@
    
    static int
    spi_stm32_read(struct bus_dev *bdev, struct bus_node *bnode,
   -                 uint8_t *buf, uint16_t length, os_time_t timeout,
   -                 uint16_t flags)
   +               uint8_t *buf, uint16_t length, os_time_t timeout,
   +               uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   @@ -690,8 +690,8 @@
    
    static int
    spi_stm32_write(struct bus_dev *bdev, struct bus_node *bnode,
   -                  const uint8_t *buf, uint16_t length, os_time_t timeout,
   -                  uint16_t flags)
   +                const uint8_t *buf, uint16_t length, os_time_t timeout,
   +                uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,11 +22,13 @@
    #include <stm32f0xx_hal_dma.h>
    
    #define DMA_IRQn(ch) ((ch) == DMA1_CH1 ? DMA1_Ch1_IRQn : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   -                        DMA1_Channel4_5_IRQn)
   +                      ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                      ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   +                      DMA1_Channel4_5_IRQn)
    #define DMA_IRQ_HANDLER(ch) ((ch) == DMA1_CH1 ? stm32_dma1_1_irq_handler : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   -                        stm32_dma1_4_5_6_7_irq_handler)
   +                             ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                             ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   +                             stm32_dma1_4_5_6_7_irq_handler)
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, name)                    \
        const struct stm32_dma_cfg DMA ## dma ## _channel ## ch = {     \
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32l0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -21,7 +21,7 @@
    #include <stm32l0xx_hal_dma.h>
    #include <stm32_common/stm32_dma.h>
    
   -#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1 )))
   +#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1)))
    #define DMA_IRQ_HANDLER(ch) (((ch) > DMA1_CH3) ? stm32_dma1_4_5_6_7_irq_handler : stm32_dma1_2_3_irq_handler)
    
    extern DMA_HandleTypeDef *stm32_dma_ch[];
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32wbxx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,7 +22,7 @@
    #include <stm32_common/stm32_dma.h>
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_rx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _rx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   @@ -40,7 +40,7 @@
        }
    
    #define SPI_DMA_TX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_tx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _tx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
kasjer commented on a change in pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#discussion_r567636512



##########
File path: 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 <stddef.h>
+#include <stdint.h>
+#include "os/os_dev.h"
+#include "bus/drivers/spi_common.h"
+#include <mcu/stm32_hal.h>
+
+#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 node  Node device object

Review comment:
       fixed




----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-778230462


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
utzig commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-777743696


   @kasjer Please rebase.


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-773090058


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-773090058


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-772577358


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   @@ -649,8 +649,8 @@
    
    static int
    spi_stm32_read(struct bus_dev *bdev, struct bus_node *bnode,
   -                 uint8_t *buf, uint16_t length, os_time_t timeout,
   -                 uint16_t flags)
   +               uint8_t *buf, uint16_t length, os_time_t timeout,
   +               uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   @@ -690,8 +690,8 @@
    
    static int
    spi_stm32_write(struct bus_dev *bdev, struct bus_node *bnode,
   -                  const uint8_t *buf, uint16_t length, os_time_t timeout,
   -                  uint16_t flags)
   +                const uint8_t *buf, uint16_t length, os_time_t timeout,
   +                uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,11 +22,13 @@
    #include <stm32f0xx_hal_dma.h>
    
    #define DMA_IRQn(ch) ((ch) == DMA1_CH1 ? DMA1_Ch1_IRQn : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   -                        DMA1_Channel4_5_IRQn)
   +                      ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                      ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   +                      DMA1_Channel4_5_IRQn)
    #define DMA_IRQ_HANDLER(ch) ((ch) == DMA1_CH1 ? stm32_dma1_1_irq_handler : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   -                        stm32_dma1_4_5_6_7_irq_handler)
   +                             ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                             ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   +                             stm32_dma1_4_5_6_7_irq_handler)
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, name)                    \
        const struct stm32_dma_cfg DMA ## dma ## _channel ## ch = {     \
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32l0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -21,7 +21,7 @@
    #include <stm32l0xx_hal_dma.h>
    #include <stm32_common/stm32_dma.h>
    
   -#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1 )))
   +#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1)))
    #define DMA_IRQ_HANDLER(ch) (((ch) > DMA1_CH3) ? stm32_dma1_4_5_6_7_irq_handler : stm32_dma1_2_3_irq_handler)
    
    extern DMA_HandleTypeDef *stm32_dma_ch[];
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32wbxx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,7 +22,7 @@
    #include <stm32_common/stm32_dma.h>
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_rx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _rx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   @@ -40,7 +40,7 @@
        }
    
    #define SPI_DMA_TX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_tx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _tx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [mynewt-core] utzig commented on a change in pull request #2461: stm32 spi bus driver

Posted by GitBox <gi...@apache.org>.
utzig commented on a change in pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#discussion_r567512609



##########
File path: 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 <stddef.h>
+#include <stdint.h>
+#include "os/os_dev.h"
+#include "bus/drivers/spi_common.h"
+#include <mcu/stm32_hal.h>
+
+#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 node  Node device object

Review comment:
       `@param odev`




----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-772577358


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   @@ -649,8 +649,8 @@
    
    static int
    spi_stm32_read(struct bus_dev *bdev, struct bus_node *bnode,
   -                 uint8_t *buf, uint16_t length, os_time_t timeout,
   -                 uint16_t flags)
   +               uint8_t *buf, uint16_t length, os_time_t timeout,
   +               uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   @@ -690,8 +690,8 @@
    
    static int
    spi_stm32_write(struct bus_dev *bdev, struct bus_node *bnode,
   -                  const uint8_t *buf, uint16_t length, os_time_t timeout,
   -                  uint16_t flags)
   +                const uint8_t *buf, uint16_t length, os_time_t timeout,
   +                uint16_t flags)
    {
        struct bus_spi_dev *dev = (struct bus_spi_dev *)bdev;
        struct bus_spi_node *node = (struct bus_spi_node *)bnode;
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32f0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,11 +22,13 @@
    #include <stm32f0xx_hal_dma.h>
    
    #define DMA_IRQn(ch) ((ch) == DMA1_CH1 ? DMA1_Ch1_IRQn : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   -                        DMA1_Channel4_5_IRQn)
   +                      ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                      ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? DMA1_Channel2_3_IRQn : \
   +                      DMA1_Channel4_5_IRQn)
    #define DMA_IRQ_HANDLER(ch) ((ch) == DMA1_CH1 ? stm32_dma1_1_irq_handler : \
   -                        ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || ((ch) >= DMA2_CH1 && (ch) <=DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   -                        stm32_dma1_4_5_6_7_irq_handler)
   +                             ((ch) >= DMA1_CH2 && (ch) <= DMA1_CH3) || \
   +                             ((ch) >= DMA2_CH1 && (ch) <= DMA2_CH2) ? stm32_dma1_2_3_irq_handler : \
   +                             stm32_dma1_4_5_6_7_irq_handler)
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, name)                    \
        const struct stm32_dma_cfg DMA ## dma ## _channel ## ch = {     \
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32l0xx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -21,7 +21,7 @@
    #include <stm32l0xx_hal_dma.h>
    #include <stm32_common/stm32_dma.h>
    
   -#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1 )))
   +#define DMA_IRQn(ch) ((uint8_t)DMA1_Channel1_IRQn + (((DMA1_CH3) > 3) ? 2 : ((DMA1_CH3) >> 1)))
    #define DMA_IRQ_HANDLER(ch) (((ch) > DMA1_CH3) ? stm32_dma1_4_5_6_7_irq_handler : stm32_dma1_2_3_irq_handler)
    
    extern DMA_HandleTypeDef *stm32_dma_ch[];
   ```
   
   </details>
   
   #### hw/bus/drivers/spi_stm32/stm32wbxx/src/spidmacfg.c
   <details>
   
   ```diff
   @@ -22,7 +22,7 @@
    #include <stm32_common/stm32_dma.h>
    
    #define SPI_DMA_RX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_rx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _rx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   @@ -40,7 +40,7 @@
        }
    
    #define SPI_DMA_TX_CHANNEL_DEFINE(dma, ch, spi_num)                         \
   -    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ##_tx = { \
   +    const struct stm32_dma_cfg DMA ## dma ## _channel ## ch ## _spi ## spi_num ## _tx = { \
            DMA ## dma ## _CH ## ch,                                            \
            DMA ## dma ## _Channel ## ch ## _IRQn,                              \
            stm32_dma ## dma ## _ ## ch ## _irq_handler,                        \
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2461:
URL: https://github.com/apache/mynewt-core/pull/2461#issuecomment-773090058


   
   <!-- style-bot -->
   
   ## 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
   <details>
   
   ```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
    
   ```
   
   </details>


----------------------------------------------------------------
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:
users@infra.apache.org



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

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org