2018-11-29 17:00:22 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
2019-01-09 10:10:39 +08:00
|
|
|
* 2018-11-06 SummerGift first version
|
2018-11-29 17:00:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SPI_CONFIG_H__
|
|
|
|
#define __SPI_CONFIG_H__
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
|
|
|
2019-01-09 10:10:39 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 17:00:22 +08:00
|
|
|
#ifdef BSP_USING_SPI1
|
2019-01-08 11:58:57 +08:00
|
|
|
#ifndef SPI1_BUS_CONFIG
|
|
|
|
#define SPI1_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.Instance = SPI1, \
|
|
|
|
.bus_name = "spi1", \
|
2018-11-29 17:00:22 +08:00
|
|
|
}
|
2019-01-08 11:58:57 +08:00
|
|
|
#endif /* SPI1_BUS_CONFIG */
|
|
|
|
#endif /* BSP_USING_SPI1 */
|
|
|
|
|
|
|
|
#ifdef BSP_SPI1_TX_USING_DMA
|
|
|
|
#ifndef SPI1_TX_DMA_CONFIG
|
|
|
|
#define SPI1_TX_DMA_CONFIG \
|
|
|
|
{ \
|
|
|
|
.dma_rcc = SPI1_TX_DMA_RCC, \
|
|
|
|
.Instance = SPI1_TX_DMA_INSTANCE, \
|
|
|
|
.request = SPI1_TX_DMA_REQUEST, \
|
|
|
|
.dma_irq = SPI1_TX_DMA_IRQ, \
|
|
|
|
}
|
|
|
|
#endif /* SPI1_TX_DMA_CONFIG */
|
|
|
|
#endif /* BSP_SPI1_TX_USING_DMA */
|
|
|
|
|
|
|
|
#ifdef BSP_SPI1_RX_USING_DMA
|
|
|
|
#ifndef SPI1_RX_DMA_CONFIG
|
|
|
|
#define SPI1_RX_DMA_CONFIG \
|
|
|
|
{ \
|
|
|
|
.dma_rcc = SPI1_RX_DMA_RCC, \
|
|
|
|
.Instance = SPI1_RX_DMA_INSTANCE, \
|
|
|
|
.request = SPI1_RX_DMA_REQUEST, \
|
|
|
|
.dma_irq = SPI1_RX_DMA_IRQ, \
|
|
|
|
}
|
|
|
|
#endif /* SPI1_RX_DMA_CONFIG */
|
|
|
|
#endif /* BSP_SPI1_RX_USING_DMA */
|
2018-11-29 17:00:22 +08:00
|
|
|
|
|
|
|
#ifdef BSP_USING_SPI2
|
|
|
|
#define SPI2_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.Instance = SPI2, \
|
|
|
|
.bus_name = "spi2", \
|
|
|
|
.dma_rx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
|
|
|
|
.dma_tx.dma_rcc = RCC_AHB1ENR_DMA1EN, \
|
|
|
|
.dma_rx.Instance = DMA1_Channel4, \
|
|
|
|
.dma_rx.request = DMA_REQUEST_1, \
|
|
|
|
.dma_rx.dma_irq = DMA1_Channel4_IRQn, \
|
|
|
|
.dma_tx.Instance = DMA1_Channel5, \
|
|
|
|
.dma_tx.request = DMA_REQUEST_1, \
|
|
|
|
.dma_tx.dma_irq = DMA1_Channel5_IRQn, \
|
|
|
|
}
|
2019-01-08 11:58:57 +08:00
|
|
|
|
2018-11-29 17:00:22 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BSP_USING_SPI3
|
|
|
|
#define SPI3_BUS_CONFIG \
|
|
|
|
{ \
|
|
|
|
.Instance = SPI3, \
|
|
|
|
.bus_name = "spi3", \
|
|
|
|
.dma_rx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
|
|
|
|
.dma_tx.dma_rcc = RCC_AHB1ENR_DMA2EN, \
|
|
|
|
.dma_rx.Instance = DMA2_Channel1, \
|
|
|
|
.dma_rx.request = DMA_REQUEST_3, \
|
|
|
|
.dma_rx.dma_irq = DMA2_Channel1_IRQn, \
|
|
|
|
.dma_tx.Instance = DMA2_Channel2, \
|
|
|
|
.dma_tx.request = DMA_REQUEST_3, \
|
|
|
|
.dma_tx.dma_irq = DMA2_Channel2_IRQn, \
|
|
|
|
}
|
2019-01-08 11:58:57 +08:00
|
|
|
|
2018-11-29 17:00:22 +08:00
|
|
|
#endif
|
|
|
|
|
2019-01-09 10:10:39 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-29 17:00:22 +08:00
|
|
|
#endif /*__SPI_CONFIG_H__ */
|