Skip to content

Commit b318224

Browse files
authored
Merge pull request #3715 from thread-liu/add_stm32mp1_driver
[update] add drivers for stm32mp1.
2 parents 3408c57 + a84d575 commit b318224

File tree

38 files changed

+4290
-339
lines changed

38 files changed

+4290
-339
lines changed

bsp/stm32/libraries/HAL_Drivers/SConscript

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']):
3535

3636
if GetDepend(['RT_USING_ADC']):
3737
src += Glob('drv_adc.c')
38+
39+
if GetDepend(['RT_USING_DAC']):
40+
src += Glob('drv_dac.c')
3841

3942
if GetDepend(['RT_USING_CAN']):
4043
src += ['drv_can.c']
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-06-16 thread-liu first version
9+
*/
10+
11+
#ifndef __ADC_CONFIG_H__
12+
#define __ADC_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#ifdef BSP_USING_ADC1
21+
#ifndef ADC1_CONFIG
22+
#define ADC1_CONFIG \
23+
{ \
24+
.Instance = ADC1, \
25+
.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2, \
26+
.Init.Resolution = ADC_RESOLUTION_12B, \
27+
.Init.ScanConvMode = ADC_SCAN_DISABLE, \
28+
.Init.EOCSelection = ADC_EOC_SINGLE_CONV, \
29+
.Init.LowPowerAutoWait = DISABLE, \
30+
.Init.ContinuousConvMode = DISABLE, \
31+
.Init.NbrOfConversion = 1, \
32+
.Init.DiscontinuousConvMode = DISABLE, \
33+
.Init.NbrOfDiscConversion = 1, \
34+
.Init.ExternalTrigConv = ADC_SOFTWARE_START, \
35+
.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE, \
36+
.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR, \
37+
.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN, \
38+
.Init.OversamplingMode = DISABLE, \
39+
}
40+
#endif /* ADC1_CONFIG */
41+
#endif /* BSP_USING_ADC1 */
42+
43+
#ifdef BSP_USING_ADC2
44+
#ifndef ADC2_CONFIG
45+
#define ADC2_CONFIG \
46+
{ \
47+
.Instance = ADC2, \
48+
.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2, \
49+
.Init.Resolution = ADC_RESOLUTION_12B, \
50+
.Init.ScanConvMode = ADC_SCAN_DISABLE, \
51+
.Init.EOCSelection = ADC_EOC_SINGLE_CONV, \
52+
.Init.LowPowerAutoWait = DISABLE, \
53+
.Init.ContinuousConvMode = DISABLE, \
54+
.Init.NbrOfConversion = 1, \
55+
.Init.DiscontinuousConvMode = DISABLE, \
56+
.Init.NbrOfDiscConversion = 1, \
57+
.Init.ExternalTrigConv = ADC_SOFTWARE_START, \
58+
.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE, \
59+
.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR, \
60+
.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN, \
61+
.Init.OversamplingMode = DISABLE, \
62+
}
63+
#endif /* ADC2_CONFIG */
64+
#endif /* BSP_USING_ADC2 */
65+
66+
#ifdef BSP_USING_ADC3
67+
#ifndef ADC3_CONFIG
68+
#define ADC3_CONFIG \
69+
{ \
70+
.Instance = ADC3, \
71+
.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2, \
72+
.Init.Resolution = ADC_RESOLUTION_12B, \
73+
.Init.ScanConvMode = ADC_SCAN_DISABLE, \
74+
.Init.EOCSelection = ADC_EOC_SINGLE_CONV, \
75+
.Init.LowPowerAutoWait = DISABLE, \
76+
.Init.ContinuousConvMode = DISABLE, \
77+
.Init.NbrOfConversion = 1, \
78+
.Init.DiscontinuousConvMode = DISABLE, \
79+
.Init.NbrOfDiscConversion = 1, \
80+
.Init.ExternalTrigConv = ADC_SOFTWARE_START, \
81+
.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE, \
82+
.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR, \
83+
.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN, \
84+
.Init.OversamplingMode = DISABLE, \
85+
}
86+
#endif /* ADC3_CONFIG */
87+
#endif /* BSP_USING_ADC3 */
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
93+
#endif /* __ADC_CONFIG_H__ */
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2020-06-16 thread-liu first version
9+
*/
10+
11+
#ifndef __DAC_CONFIG_H__
12+
#define __DAC_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#ifdef BSP_USING_DAC1
21+
#ifndef DAC1_CONFIG
22+
#define DAC1_CONFIG \
23+
{ \
24+
.Instance = DAC1, \
25+
}
26+
#endif /* DAC1_CONFIG */
27+
#endif /* BSP_USING_DAC1 */
28+
29+
#ifdef __cplusplus
30+
}
31+
#endif
32+
33+
#endif /* __DAC_CONFIG_H__ */

bsp/stm32/libraries/HAL_Drivers/config/mp1/dma_config.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2019-01-02 zylx first version
99
* 2019-01-08 SummerGift clean up the code
10+
* 2020-06-20 thread-liu add stm32mp1
1011
*/
1112

1213
#ifndef __DMA_CONFIG_H__
@@ -19,12 +20,12 @@ extern "C" {
1920
#endif
2021

2122
/* DMA2 stream0 */
22-
#if defined(BSP_SPI1_RX_USING_DMA) && !defined(SPI1_RX_DMA_INSTANCE)
23-
#define SPI1_DMA_RX_IRQHandler DMA2_Stream0_IRQHandler
24-
#define SPI1_RX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
25-
#define SPI1_RX_DMA_INSTANCE DMA2_Stream0
26-
#define SPI1_RX_DMA_CHANNEL DMA_REQUEST_SPI1_RX
27-
#define SPI1_RX_DMA_IRQ DMA2_Stream0_IRQn
23+
#if defined(BSP_UART3_RX_USING_DMA) && !defined(UART3_RX_DMA_INSTANCE)
24+
#define UART3_RX_DMA_IRQHandler DMA2_Stream0_IRQHandler
25+
#define UART3_RX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
26+
#define UART3_RX_DMA_INSTANCE DMA2_Stream0
27+
#define UART3_RX_DMA_CHANNEL DMA_REQUEST_USART3_RX
28+
#define UART3_RX_DMA_IRQ DMA2_Stream0_IRQn
2829
#elif defined(BSP_SPI4_RX_USING_DMA) && !defined(SPI4_RX_DMA_INSTANCE)
2930
#define SPI4_DMA_RX_IRQHandler DMA2_Stream0_IRQHandler
3031
#define SPI4_RX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
@@ -40,12 +41,12 @@ extern "C" {
4041
#endif
4142

4243
/* DMA2 stream1 */
43-
#if defined(BSP_SPI1_TX_USING_DMA) && !defined(SPI1_TX_DMA_INSTANCE)
44-
#define SPI1_DMA_TX_IRQHandler DMA2_Stream1_IRQHandler
45-
#define SPI1_TX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
46-
#define SPI1_TX_DMA_INSTANCE DMA2_Stream1
47-
#define SPI1_TX_DMA_CHANNEL DMA_REQUEST_SPI1_RX
48-
#define SPI1_TX_DMA_IRQ DMA2_Stream1_IRQn
44+
#if defined(BSP_UART3_TX_USING_DMA) && !defined(BSP_UART3_TX_USING_INSTANCE)
45+
#define UART3_TX_DMA_IRQHandler DMA2_Stream1_IRQHandler
46+
#define UART3_TX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
47+
#define UART3_TX_DMA_INSTANCE DMA2_Stream1
48+
#define UART3_TX_DMA_CHANNEL DMA_REQUEST_USART3_TX
49+
#define UART3_TX_DMA_IRQ DMA2_Stream1_IRQn
4950
#elif defined(BSP_SPI4_TX_USING_DMA) && !defined(SPI4_TX_DMA_INSTANCE)
5051
#define SPI4_DMA_TX_IRQHandler DMA2_Stream1_IRQHandler
5152
#define SPI4_TX_DMA_RCC RCC_MC_AHB2ENSETR_DMA2EN
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2006-2018, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2018-12-13 zylx first version
9+
*/
10+
11+
#ifndef __PWM_CONFIG_H__
12+
#define __PWM_CONFIG_H__
13+
14+
#include <rtthread.h>
15+
16+
#ifdef __cplusplus
17+
extern "C" {
18+
#endif
19+
20+
#ifdef BSP_USING_PWM2
21+
#ifndef PWM2_CONFIG
22+
#define PWM2_CONFIG \
23+
{ \
24+
.tim_handle.Instance = TIM2, \
25+
.name = "pwm2", \
26+
.channel = 0 \
27+
}
28+
#endif /* PWM2_CONFIG */
29+
#endif /* BSP_USING_PWM2 */
30+
31+
#ifdef BSP_USING_PWM3
32+
#ifndef PWM3_CONFIG
33+
#define PWM3_CONFIG \
34+
{ \
35+
.tim_handle.Instance = TIM3, \
36+
.name = "pwm3", \
37+
.channel = 0 \
38+
}
39+
#endif /* PWM3_CONFIG */
40+
#endif /* BSP_USING_PWM3 */
41+
42+
#ifdef BSP_USING_PWM4
43+
#ifndef PWM4_CONFIG
44+
#define PWM4_CONFIG \
45+
{ \
46+
.tim_handle.Instance = TIM4, \
47+
.name = "pwm4", \
48+
.channel = 0 \
49+
}
50+
#endif /* PWM4_CONFIG */
51+
#endif /* BSP_USING_PWM4 */
52+
53+
#ifdef BSP_USING_PWM5
54+
#ifndef PWM5_CONFIG
55+
#define PWM5_CONFIG \
56+
{ \
57+
.tim_handle.Instance = TIM5, \
58+
.name = "pwm5", \
59+
.channel = 0 \
60+
}
61+
#endif /* PWM5_CONFIG */
62+
#endif /* BSP_USING_PWM5 */
63+
64+
#ifdef __cplusplus
65+
}
66+
#endif
67+
68+
#endif /* __PWM_CONFIG_H__ */

0 commit comments

Comments
 (0)