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 2020/03/27 15:46:50 UTC

[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2252: [RFC] I2S API and driver for STM32 MCUs

apache-mynewt-bot removed a comment on issue #2252: [RFC] I2S API and driver for STM32 MCUs
URL: https://github.com/apache/mynewt-core/pull/2252#issuecomment-605041342
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### hw/drivers/i2s/i2s_stm32/include/i2s_stm32/i2s_stm32.h
   <details>
   
   ```diff
   @@ -14,10 +14,10 @@
        stm32_pin_cfg_t sd_pin;
    };
    
   -#define I2S_PIN(n, port, pin) &(I2S##n##_P##port##pin)
   -#define I2S_CK_PIN(n, port, pin) &(I2S##n##_CK_P##port##pin)
   -#define I2S_WS_PIN(n, port, pin) &(I2S##n##_WS_P##port##pin)
   -#define I2S_SD_PIN(n, port, pin) &(I2S##n##_SD_P##port##pin)
   +#define I2S_PIN(n, port, pin) &(I2S ## n ## _P ## port ## pin)
   +#define I2S_CK_PIN(n, port, pin) &(I2S ## n ## _CK_P ## port ## pin)
   +#define I2S_WS_PIN(n, port, pin) &(I2S ## n ## _WS_P ## port ## pin)
   +#define I2S_SD_PIN(n, port, pin) &(I2S ## n ## _SD_P ## port ## pin)
    
    struct stm32_dma_cfg {
        uint8_t dma_num;
   @@ -38,7 +38,7 @@
        struct stm32_i2s_pins pins;
    };
    
   -#define SPI_CFG(n) &(spi##n##_cfg)
   +#define SPI_CFG(n) &(spi ## n ## _cfg)
    
    struct stm32_i2s {
        I2S_HandleTypeDef hi2s;
   @@ -48,10 +48,10 @@
        struct i2s_sample_buffer *active_buffer;
    };
    
   -#define DMA_CFG(dma, ch, st, name) &(name##_stream##st##_channel##ch)
   +#define DMA_CFG(dma, ch, st, name) &(name ## _stream ## st ## _channel ## ch)
    
    #define DMA_STREAM_DECLARE(dma, ch, st, name) \
   -extern const struct stm32_dma_cfg name##_stream##st##_channel##ch
   +    extern const struct stm32_dma_cfg name ## _stream ## st ## _channel ## ch
    
    DMA_STREAM_DECLARE(1, 0, 0, spi3_rx);
    DMA_STREAM_DECLARE(1, 0, 1, i2c1_tx);
   @@ -159,7 +159,7 @@
    DMA_STREAM_DECLARE(2, 7, 7, tim8_com);
    
    #define SPI_CFG_DECLARE(n) \
   -extern struct stm32_spi_cfg spi##n##_cfg;
   +    extern struct stm32_spi_cfg spi ## n ## _cfg;
    
    SPI_CFG_DECLARE(1);
    SPI_CFG_DECLARE(2);
   @@ -168,13 +168,13 @@
    SPI_CFG_DECLARE(5);
    
    #define I2S_PIN_DECLARE(n, port, pin) \
   -extern const struct stm32_pin_cfg I2S##n##_P##port##pin;
   +    extern const struct stm32_pin_cfg I2S ## n ## _P ## port ## pin;
    #define I2S_CK_PIN_DECLARE(n, port, pin) \
   -extern const struct stm32_pin_cfg I2S##n##_CK_P##port##pin;
   +    extern const struct stm32_pin_cfg I2S ## n ## _CK_P ## port ## pin;
    #define I2S_WS_PIN_DECLARE(n, port, pin) \
   -extern const struct stm32_pin_cfg I2S##n##_WS_P##port##pin;
   +    extern const struct stm32_pin_cfg I2S ## n ## _WS_P ## port ## pin;
    #define I2S_SD_PIN_DECLARE(n, port, pin) \
   -extern const struct stm32_pin_cfg I2S##n##_SD_P##port##pin;
   +    extern const struct stm32_pin_cfg I2S ## n ## _SD_P ## port ## pin;
    
    /* I2S1 Possible CK pins */
    I2S_CK_PIN_DECLARE(1, A, 5)
   ```
   
   </details>
   
   #### hw/drivers/i2s/i2s_stm32/src/i2s_stm32.c
   <details>
   
   ```diff
   @@ -403,52 +403,52 @@
    }
    
    #define I2S_PIN_DEFINE(n, po, pi, af)                   \
   -const struct stm32_pin_cfg I2S##n##_P##po##pi = {       \
   -    .pin = MCU_GPIO_PORT##po(pi),                       \
   -    .hal_init = {                                       \
   -        .Pin = GPIO_PIN_##pi,                           \
   -        .Mode = GPIO_MODE_AF_PP,                        \
   -        .Pull = GPIO_NOPULL,                            \
   -        .Speed = GPIO_SPEED_FREQ_LOW,                   \
   -        .Alternate = af,                                \
   -    }                                                   \
   -}
   +    const struct stm32_pin_cfg I2S ## n ## _P ## po ## pi = {       \
   +        .pin = MCU_GPIO_PORT ## po(pi),                       \
   +        .hal_init = {                                       \
   +            .Pin = GPIO_PIN_ ## pi,                           \
   +            .Mode = GPIO_MODE_AF_PP,                        \
   +            .Pull = GPIO_NOPULL,                            \
   +            .Speed = GPIO_SPEED_FREQ_LOW,                   \
   +            .Alternate = af,                                \
   +        }                                                   \
   +    }
    
    #define I2S_CK_PIN_DEFINE(n, po, pi, af)                \
   -const struct stm32_pin_cfg I2S##n##_CK_P##po##pi = {    \
   -    .pin = MCU_GPIO_PORT##po(pi),                       \
   -    .hal_init = {                                       \
   -        .Pin = GPIO_PIN_##pi,                           \
   -        .Mode = GPIO_MODE_AF_PP,                        \
   -        .Pull = GPIO_NOPULL,                            \
   -        .Speed = GPIO_SPEED_FREQ_LOW,                   \
   -        .Alternate = af,                                \
   -    }                                                   \
   -}
   +    const struct stm32_pin_cfg I2S ## n ## _CK_P ## po ## pi = {    \
   +        .pin = MCU_GPIO_PORT ## po(pi),                       \
   +        .hal_init = {                                       \
   +            .Pin = GPIO_PIN_ ## pi,                           \
   +            .Mode = GPIO_MODE_AF_PP,                        \
   +            .Pull = GPIO_NOPULL,                            \
   +            .Speed = GPIO_SPEED_FREQ_LOW,                   \
   +            .Alternate = af,                                \
   +        }                                                   \
   +    }
    
    #define I2S_WS_PIN_DEFINE(n, po, pi, af)                \
   -const struct stm32_pin_cfg I2S##n##_WS_P##po##pi = {    \
   -    .pin = MCU_GPIO_PORT##po(pi),                       \
   -    .hal_init = {                                       \
   -        .Pin = GPIO_PIN_##pi,                           \
   -        .Mode = GPIO_MODE_AF_PP,                        \
   -        .Pull = GPIO_NOPULL,                            \
   -        .Speed = GPIO_SPEED_FREQ_LOW,                   \
   -        .Alternate = af,                                \
   -    }                                                   \
   -}
   +    const struct stm32_pin_cfg I2S ## n ## _WS_P ## po ## pi = {    \
   +        .pin = MCU_GPIO_PORT ## po(pi),                       \
   +        .hal_init = {                                       \
   +            .Pin = GPIO_PIN_ ## pi,                           \
   +            .Mode = GPIO_MODE_AF_PP,                        \
   +            .Pull = GPIO_NOPULL,                            \
   +            .Speed = GPIO_SPEED_FREQ_LOW,                   \
   +            .Alternate = af,                                \
   +        }                                                   \
   +    }
    
    #define I2S_SD_PIN_DEFINE(n, po, pi, af)                \
   -const struct stm32_pin_cfg I2S##n##_SD_P##po##pi = {    \
   -    .pin = MCU_GPIO_PORT##po(pi),                       \
   -    .hal_init = {                                       \
   -        .Pin = GPIO_PIN_##pi,                           \
   -        .Mode = GPIO_MODE_AF_PP,                        \
   -        .Pull = GPIO_NOPULL,                            \
   -        .Speed = GPIO_SPEED_FREQ_LOW,                   \
   -        .Alternate = af,                                \
   -    }                                                   \
   -}
   +    const struct stm32_pin_cfg I2S ## n ## _SD_P ## po ## pi = {    \
   +        .pin = MCU_GPIO_PORT ## po(pi),                       \
   +        .hal_init = {                                       \
   +            .Pin = GPIO_PIN_ ## pi,                           \
   +            .Mode = GPIO_MODE_AF_PP,                        \
   +            .Pull = GPIO_NOPULL,                            \
   +            .Speed = GPIO_SPEED_FREQ_LOW,                   \
   +            .Alternate = af,                                \
   +        }                                                   \
   +    }
    
    /* I2S1 Possible CK pins */
    I2S_CK_PIN_DEFINE(1, A, 5, GPIO_AF5_SPI1);
   @@ -540,12 +540,12 @@
    I2S_SD_PIN_DEFINE(5, E, 14, GPIO_AF6_SPI5);
    
    #define DMA_STREAM_DEFINE(dma, ch, st, name) \
   -const struct stm32_dma_cfg name##_stream##st##_channel##ch = {  \
   -    dma,                                                        \
   -    DMA##dma##_Stream##st##_IRQn,                               \
   -    DMA##dma##_Stream##st,                                      \
   -    DMA_CHANNEL_##ch,                                           \
   -}
   +    const struct stm32_dma_cfg name ## _stream ## st ## _channel ## ch = {  \
   +        dma,                                                        \
   +        DMA ## dma ## _Stream ## st ## _IRQn,                               \
   +        DMA ## dma ## _Stream ## st,                                      \
   +        DMA_CHANNEL_ ## ch,                                           \
   +    }
    
    DMA_STREAM_DEFINE(1, 0, 0, spi3_rx);
    DMA_STREAM_DEFINE(1, 0, 1, i2c1_tx);
   @@ -664,15 +664,15 @@
    DMA_STREAM_DEFINE(2, 7, 7, tim8_com);
    
    #define SPI_CFG_DEFINE(n)                           \
   -struct stm32_spi_cfg spi##n##_cfg = {               \
   -    .spi_num = n,                                   \
   -    .spi = SPI##n,                                  \
   -    .i2s_irq = SPI##n##_IRQn,                       \
   -    .driver_data = &stm32_i2s##n,                   \
   -    .irq_handler = i2s##n##_irq_handler,            \
   -    .dma_handler = i2s##n##_dma_stream_irq_handler, \
   -    .enable_clock = i2s##n##_clock_enable,          \
   -};
   +    struct stm32_spi_cfg spi ## n ## _cfg = {               \
   +        .spi_num = n,                                   \
   +        .spi = SPI ## n,                                  \
   +        .i2s_irq = SPI ## n ## _IRQn,                       \
   +        .driver_data = &stm32_i2s ## n,                   \
   +        .irq_handler = i2s ## n ## _irq_handler,            \
   +        .dma_handler = i2s ## n ## _dma_stream_irq_handler, \
   +        .enable_clock = i2s ## n ## _clock_enable,          \
   +    };
    
    #ifdef SPI1
    SPI_CFG_DEFINE(1);
   ```
   
   </details>
   
   #### hw/drivers/i2s/include/i2s/i2s.h
   <details>
   
   ```diff
   @@ -64,12 +64,13 @@
     * @param size   single buffer size in bytes
     */
    #define I2S_BUFFER_POOL_DEF(name, count, size) \
   -static uint8_t _Alignas(struct i2s_buffer_pool) name##_buffers[(sizeof(struct i2s_sample_buffer[count])) + size * count]; \
   -struct i2s_buffer_pool name = { \
   -    .buffer_size = size, \
   -    .buffer_count = count, \
   -    .buffers = (struct i2s_sample_buffer *)name##_buffers \
   -};
   +    static uint8_t _Alignas(struct i2s_buffer_pool) name ## _buffers[(sizeof(struct i2s_sample_buffer [count])) + \
   +                                                                     size * count]; \
   +    struct i2s_buffer_pool name = { \
   +        .buffer_size = size, \
   +        .buffer_count = count, \
   +        .buffers = (struct i2s_sample_buffer *)name ## _buffers \
   +    };
    #define I2S_BUFFER_POOL(name) ((struct i2s_buffer_pool *)(&name))
    
    enum i2s_state {
   ```
   
   </details>
   
   #### hw/drivers/i2s/src/i2s.c
   <details>
   
   ```diff
   @@ -154,7 +154,8 @@
    }
    
    int
   -i2s_close(struct i2s *i2s) {
   +i2s_close(struct i2s *i2s)
   +{
        return os_dev_close(&i2s->dev);
    }
    
   ```
   
   </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


With regards,
Apache Git Services