Skip to content

Commit 0c1f9d4

Browse files
kywwilson11Alan C. Assis
authored andcommitted
Added DMA support for H5. Also added ADC DMA support.
Added logic to set hasdma to false. This is needed to enable or not enable interrupts on a per ADC basis. Made other minor formatting changes. Fixed build issues with non ADC/DMA configurations.
1 parent 156ef05 commit 0c1f9d4

File tree

9 files changed

+1589
-178
lines changed

9 files changed

+1589
-178
lines changed

arch/arm/src/stm32h5/Kconfig

Lines changed: 69 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,75 @@ config ARCH_BOARD_STM32H5_CUSTOM_CLOCKCONFIG
881881
---help---
882882
Enables special, board-specific STM32 clock configuration.
883883

884+
menu "ADC Configuration"
885+
depends on STM32H5_ADC
886+
887+
config STM32H5_ADC_MAX_SAMPLES
888+
int "The maximum number of channels that can be sampled"
889+
default 16
890+
---help---
891+
The maximum number of samples which can be handled without
892+
overrun depends on various factors. This is the user's
893+
responsibility to correctly select this value.
894+
Since the interface to update the sampling time is available
895+
for all supported devices, the user can change the default
896+
values in the board initialization logic and avoid ADC overrun.
897+
898+
config STM32H5_ADC1_DMA
899+
bool "ADC1 DMA Enable"
900+
depends on STM32H5_ADC1 && STM32H5_DMA
901+
default n
902+
---help---
903+
If DMA is selected, then the ADC may be configured to support DMA
904+
transfer, which is necessary if multiple channels are read or if
905+
very high trigger frequencies are used.
906+
907+
config STM32H5_ADC1_DMA_BATCH
908+
int "ADC1 DMA number of conversions"
909+
depends on STM32H5_ADC1 && STM32H5_ADC1_DMA
910+
default 1
911+
---help---
912+
This option allows you to select the number of regular group conversions
913+
that will trigger a DMA callback transerring data to the upper-half driver.
914+
By default, this value is 1, which means that data is transferred after
915+
each group conversion.
916+
917+
config STM32H5_ADC1_DMA_CFG
918+
bool "ADC1 DMA configuration"
919+
depends on STM32H5_ADC1 && STM32H5_ADC1_DMA
920+
default n
921+
---help---
922+
0 - ADC1 DMA in One Shot Mode, 1 - ADC1 DMA in Circular Mode
923+
924+
config STM32H5_ADC2_DMA
925+
bool "ADC2 DMA Enable"
926+
depends on STM32H5_ADC2 && STM32H5_DMA
927+
default n
928+
---help---
929+
If DMA is selected, then the ADC may be configured to support DMA
930+
transfer, which is necessary if multiple channels are read or if
931+
very high trigger frequencies are used.
932+
933+
config STM32H5_ADC2_DMA_BATCH
934+
int "ADC2 DMA number of conversions"
935+
depends on STM32H5_ADC2 && STM32H5_ADC2_DMA
936+
default 1
937+
---help---
938+
This option allows you to select the number of regular group conversions
939+
that will trigger a DMA callback transerring data to the upper-half driver.
940+
By default, this value is 1, which means that data is transferred after
941+
each group conversion.
942+
943+
config STM32H5_ADC2_DMA_CFG
944+
int "ADC2 DMA configuration"
945+
depends on STM32H5_ADC2_DMA && STM32H5_DMA
946+
range 0 1
947+
default 0
948+
---help---
949+
0 - ADC2 DMA in One Shot Mode, 1 - ADC2 DMA in Circular Mode
950+
951+
endmenu # ADC Configuration
952+
884953
menu "SPI Configuration"
885954
depends on STM32H5_SPI
886955

@@ -4550,60 +4619,6 @@ endif # STM32H5_SERIALDRIVER
45504619

45514620
endmenu # U[S]ART Configuration
45524621

4553-
menu "ADC Configuration"
4554-
depends on STM32H5_ADC
4555-
4556-
config STM32H5_ADC_MAX_SAMPLES
4557-
int "The maximum number of channels that can be sampled"
4558-
default 16
4559-
---help---
4560-
The maximum number of samples which can be handled without
4561-
overrun depends on various factors. This is the user's
4562-
responsibility to correctly select this value.
4563-
Since the interface to update the sampling time is available
4564-
for all supported devices, the user can change the default
4565-
values in the board initialization logic and avoid ADC overrun.
4566-
4567-
config STM32H5_ADC1_DMA
4568-
bool "ADC1 DMA (not supported yet)"
4569-
depends on STM32H5_ADC1 && EXPERIMENTAL
4570-
default n
4571-
---help---
4572-
If DMA is selected, then the ADC may be configured to support
4573-
DMA transfer, which is necessary if multiple channels are read
4574-
or if very high trigger frequencies are used.
4575-
4576-
config STM32H5_ADC1_DMA_BATCH
4577-
int "ADC1 DMA number of conversions"
4578-
depends on STM32H5_ADC1 && STM32H5_ADC1_DMA
4579-
default 1
4580-
---help---
4581-
This option allows you to select the number of regular group conversions
4582-
that will trigger a DMA callback transerring data to the upper-half driver.
4583-
By default, this value is 1, which means that data is transferred after
4584-
each group conversion.
4585-
4586-
config STM32H5_ADC2_DMA
4587-
bool "ADC2 DMA (not supported yet)"
4588-
depends on STM32H5_ADC2 && EXPERIMENTAL
4589-
default n
4590-
---help---
4591-
If DMA is selected, then the ADC may be configured to support
4592-
DMA transfer, which is necessary if multiple channels are read
4593-
or if very high trigger frequencies are used.
4594-
4595-
config STM32H5_ADC2_DMA_BATCH
4596-
int "ADC2 DMA number of conversions"
4597-
depends on STM32H5_ADC2 && STM32H5_ADC2_DMA
4598-
default 1
4599-
---help---
4600-
This option allows you to select the number of regular group conversions
4601-
that will trigger a DMA callback transerring data to the upper-half driver.
4602-
By default, this value is 1, which means that data is transferred after
4603-
each group conversion.
4604-
4605-
endmenu
4606-
46074622
menu "Ethernet MAC Configuration"
46084623
depends on STM32H5_ETHMAC
46094624

arch/arm/src/stm32h5/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ ifeq ($(CONFIG_STM32H5_ETHMAC),y)
8888
CHIP_CSRCS += stm32_ethernet.c
8989
endif
9090

91+
ifeq ($(CONFIG_STM32H5_DMA),y)
92+
CHIP_CSRCS += stm32_dma.c
93+
endif
94+
9195
# Required chip type specific files
9296

9397
ifeq ($(CONFIG_STM32H5_STM32H5XXXX),y)

arch/arm/src/stm32h5/hardware/stm32_gpdma.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#include <nuttx/config.h>
3131
#include "chip.h"
3232

33+
#if defined(CONFIG_STM32H5_STM32H56XXX) || defined(CONFIG_STM32H5_STM32H57XXX)
34+
# include "stm32h56x_dmasigmap.h"
35+
#else
36+
# error "Unsupported STM32 H5 DMA map"
37+
#endif
38+
3339
/****************************************************************************
3440
* Pre-processor Definitions
3541
****************************************************************************/
@@ -455,6 +461,8 @@
455461
#define GPDMA_CXCR_PRIO_SHIFT (22) /* Bits 22-23: Priority level of ch x GPDMA transfer */
456462
#define GPDMA_CXCR_PRIO_MASK (0b11 << GPDMA_CXCR_PRIO_SHIFT)
457463

464+
#define GPDMA_CXCR_ALLINTS (GPDMA_CXCR_TOIE|GPDMA_CXCR_SUSPEI|GPDMA_CXCR_USEIE|GPDMA_CXCR_ULEIE|GPDMA_CXCR_DTEIE|GPDMA_CXCR_HTIE|GPDMA_CXCR_TCIE)
465+
458466
/* Channel x transfer register 1 */
459467

460468
#define GPDMA_CXTR1_SDW_LOG2_SHIFT (0)
@@ -485,7 +493,7 @@
485493
#define GPDMA_CXTR1_DBL_1(l) ((l) - 1 << GPDMA_CXTR1_DBL_1_SHIFT)
486494

487495
#define GPDMA_CXTR1_DBX (1 << 26) /* Destination byte exchange */
488-
#define GPDMA_CXTR1_DHX (1 << 17) /* Destination half-word exchange */
496+
#define GPDMA_CXTR1_DHX (1 << 27) /* Destination half-word exchange */
489497
#define GPDMA_CXTR1_DAP (1 << 30) /* Destination allocated port */
490498
#define GPDMA_CXTR1_DSEC (1 << 31) /* Security attribute of transfer to the destination */
491499

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
/****************************************************************************
2+
* arch/arm/src/stm32h5/hardware/stm32h56x_dmasigmap.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __ARCH_ARM_SRC_STM32H5_HARDWARE_STM32H56X_DMASIGMAP_H
24+
#define __ARCH_ARM_SRC_STM32H5_HARDWARE_STM32H56X_DMASIGMAP_H
25+
26+
/* This file is valid for STM32H562/563/573 devices */
27+
28+
/****************************************************************************
29+
* Pre-processor Definitions
30+
****************************************************************************/
31+
32+
/* GPDMA Request Number */
33+
34+
#define GPDMA_REQ_ADC1 (0)
35+
#define GPDMA_REQ_ADC2 (1)
36+
#define GPDMA_REQ_DAC1_CH1 (2)
37+
#define GPDMA_REQ_DAC1_CH2 (3)
38+
#define GPDMA_REQ_TIM6_UPD (4)
39+
#define GPDMA_REQ_TIM7_UPD (5)
40+
#define GPDMA_REQ_SPI1_RX (6)
41+
#define GPDMA_REQ_SPI1_TX (7)
42+
#define GPDMA_REQ_SPI2_RX (8)
43+
#define GPDMA_REQ_SPI2_TX (9)
44+
#define GPDMA_REQ_SPI3_RX (10)
45+
#define GPDMA_REQ_SPI3_TX (11)
46+
#define GPDMA_REQ_I2C1_RX (12)
47+
#define GPDMA_REQ_I2C1_TX (13)
48+
/* (14) RESERVED */
49+
#define GPDMA_REQ_I2C2_RX (15)
50+
#define GPDMA_REQ_I2C2_TX (16)
51+
/* (17) RESERVED */
52+
#define GPDMA_REQ_I2C3_RX (18)
53+
#define GPDMA_REQ_I2C3_TX (19)
54+
/* (20) RESERVED */
55+
#define GPDMA_REQ_USART1_RX (21)
56+
#define GPDMA_REQ_USART1_TX (22)
57+
#define GPDMA_REQ_USART2_RX (23)
58+
#define GPDMA_REQ_USART2_TX (24)
59+
#define GPDMA_REQ_USART3_RX (25)
60+
#define GPDMA_REQ_USART3_TX (26)
61+
#define GPDMA_REQ_UART4_RX (27)
62+
#define GPDMA_REQ_UART4_TX (28)
63+
#define GPDMA_REQ_UART5_RX (29)
64+
#define GPDMA_REQ_UART5_TX (30)
65+
#define GPDMA_REQ_USART6_RX (31)
66+
#define GPDMA_REQ_USART6_TX (32)
67+
#define GPDMA_REQ_UART7_RX (33)
68+
#define GPDMA_REQ_UART7_TX (34)
69+
#define GPDMA_REQ_UART8_RX (35)
70+
#define GPDMA_REQ_UART8_TX (36)
71+
#define GPDMA_REQ_UART9_RX (37)
72+
#define GPDMA_REQ_UART9_TX (38)
73+
#define GPDMA_REQ_UART10_RX (39)
74+
#define GPDMA_REQ_UART10_TX (40)
75+
#define GPDMA_REQ_UART11_RX (41)
76+
#define GPDMA_REQ_UART11_TX (42)
77+
#define GPDMA_REQ_UART12_RX (43)
78+
#define GPDMA_REQ_UART12_TX (44)
79+
#define GPDMA_REQ_LPUART1_RX (45)
80+
#define GPDMA_REQ_LPUART1_TX (46)
81+
#define GPDMA_REQ_SPI4_RX (47)
82+
#define GPDMA_REQ_SPI4_TX (48)
83+
#define GPDMA_REQ_SPI5_RX (49)
84+
#define GPDMA_REQ_SPI5_TX (50)
85+
#define GPDMA_REQ_SPI6_RX (51)
86+
#define GPDMA_REQ_SPI6_TX (52)
87+
#define GPDMA_REQ_SAI1_A (53)
88+
#define GPDMA_REQ_SAI1_B (54)
89+
#define GPDMA_REQ_SAI2_A (55)
90+
#define GPDMA_REQ_SAI2_B (56)
91+
#define GPDMA_REQ_OSPI1 (57)
92+
#define GPDMA_REQ_TIM1_CC1 (58)
93+
#define GPDMA_REQ_TIM1_CC2 (59)
94+
#define GPDMA_REQ_TIM1_CC3 (60)
95+
#define GPDMA_REQ_TIM1_CC4 (61)
96+
#define GPDMA_REQ_TIM1_UPD (62)
97+
#define GPDMA_REQ_TIM1_TRG (63)
98+
#define GPDMA_REQ_TIM1_COM (64)
99+
#define GPDMA_REQ_TIM8_CC1 (65)
100+
#define GPDMA_REQ_TIM8_CC2 (66)
101+
#define GPDMA_REQ_TIM8_CC3 (67)
102+
#define GPDMA_REQ_TIM8_CC4 (68)
103+
#define GPDMA_REQ_TIM8_UPD (69)
104+
#define GPDMA_REQ_TIM8_TIG (70)
105+
#define GPDMA_REQ_TIM8_COM (71)
106+
#define GPDMA_REQ_TIM2_CC1 (72)
107+
#define GPDMA_REQ_TIM2_CC2 (73)
108+
#define GPDMA_REQ_TIM2_CC3 (74)
109+
#define GPDMA_REQ_TIM2_CC4 (75)
110+
#define GPDMA_REQ_TIM2_UPD (76)
111+
#define GPDMA_REQ_TIM3_CC1 (77)
112+
#define GPDMA_REQ_TIM3_CC2 (78)
113+
#define GPDMA_REQ_TIM3_CC3 (79)
114+
#define GPDMA_REQ_TIM3_CC4 (80)
115+
#define GPDMA_REQ_TIM3_UPD (81)
116+
#define GPDMA_REQ_TIM3_TRG (82)
117+
#define GPDMA_REQ_TIM4_CC1 (83)
118+
#define GPDMA_REQ_TIM4_CC2 (84)
119+
#define GPDMA_REQ_TIM4_CC3 (85)
120+
#define GPDMA_REQ_TIM4_CC4 (86)
121+
#define GPDMA_REQ_TIM4_UPD (87)
122+
#define GPDMA_REQ_TIM5_CC1 (88)
123+
#define GPDMA_REQ_TIM5_CC2 (89)
124+
#define GPDMA_REQ_TIM5_CC3 (90)
125+
#define GPDMA_REQ_TIM5_CC4 (91)
126+
#define GPDMA_REQ_TIM5_UPD (92)
127+
#define GPDMA_REQ_TIM5_TRG (93)
128+
#define GPDMA_REQ_TIM15_CC1 (94)
129+
#define GPDMA_REQ_TIM15_UPD (95)
130+
#define GPDMA_REQ_TIM15_TRG (96)
131+
#define GPDMA_REQ_TIM15_COM (97)
132+
#define GPDMA_REQ_TIM16_CC1 (98)
133+
#define GPDMA_REQ_TIM16_UPD (99)
134+
#define GPDMA_REQ_TIM17_CC1 (100)
135+
#define GPDMA_REQ_TIM17_UPD (101)
136+
#define GPDMA_REQ_LPTIM1_IC1 (102)
137+
#define GPDMA_REQ_LPTIM1_IC2 (103)
138+
#define GPDMA_REQ_LPTIM1_UE (104)
139+
#define GPDMA_REQ_LPTIM2_IC1 (105)
140+
#define GPDMA_REQ_LPTIM2_IC2 (106)
141+
#define GPDMA_REQ_LPTIM2_UE (107)
142+
#define GPDMA_REQ_DCMI_PSSI (108)
143+
#define GPDMA_REQ_AES_OUT (109)
144+
#define GPDMA_REQ_AES_IN (110)
145+
#define GPDMA_REQ_HASH_IN (111)
146+
#define GPDMA_REQ_UCPD1_RX (112)
147+
#define GPDMA_REQ_UCPD1_TX (113)
148+
#define GPDMA_REQ_CORDIC_R (114)
149+
#define GPDMA_REQ_CORDIC_W (115)
150+
#define GPDMA_REQ_FMAC_R (116)
151+
#define GPDMA_REQ_FMAC_W (117)
152+
#define GPDMA_REQ_SAES_OUT (118)
153+
#define GPDMA_REQ_SAES_IN (119)
154+
#define GPDMA_REQ_I3C1_RX (120)
155+
#define GPDMA_REQ_I3C1_TX (121)
156+
#define GPDMA_REQ_I3C1_TC (122)
157+
#define GPDMA_REQ_I3C1_RS (123)
158+
#define GPDMA_REQ_I2C4_RX (124)
159+
#define GPDMA_REQ_I2C4_TX (125)
160+
/* (126) RESERVED */
161+
#define GPDMA_REQ_LPTIM3_IC1 (127)
162+
#define GPDMA_REQ_LPTIM3_IC2 (128)
163+
#define GPDMA_REQ_LPTIM3_UE (129)
164+
#define GPDMA_REQ_LPTIM5_IC1 (130)
165+
#define GPDMA_REQ_LPTIM5_IC2 (131)
166+
#define GPDMA_REQ_LPTIM5_UE (132)
167+
#define GPDMA_REQ_LPTIM6_IC1 (133)
168+
#define GPDMA_REQ_LPTIM6_IC2 (134)
169+
#define GPDMA_REQ_LPTIM6_UE (135)
170+
171+
/* GPDMA Trigger Number */
172+
173+
#define GPDMA_TRIG_EXTI0 (0)
174+
#define GPDMA_TRIG_EXTI1 (1)
175+
#define GPDMA_TRIG_EXTI2 (2)
176+
#define GPDMA_TRIG_EXTI3 (3)
177+
#define GPDMA_TRIG_EXTI4 (4)
178+
#define GPDMA_TRIG_EXTI5 (5)
179+
#define GPDMA_TRIG_EXTI6 (6)
180+
#define GPDMA_TRIG_EXTI7 (7)
181+
#define GPDMA_TRIG_TAMP_TRG1 (8)
182+
#define GPDMA_TRIG_TAMP_TRG2 (9)
183+
#define GPDMA_TRIG_TAMP_TRG4 (10)
184+
#define GPDMA_TRIG_LPTIM1_CH1 (11)
185+
#define GPDMA_TRIG_LPTIM1_CH2 (12)
186+
#define GPDMA_TRIG_LPTIM2_CH1 (13)
187+
#define GPDMA_TRIG_LPTIM2_CH2 (14)
188+
#define GPDMA_TRIG_RTC_ALRA_TRG (15)
189+
#define GPDMA_TRIG_RTC_ALRB_TRG (16)
190+
#define GPDMA_TRIG_RTC_WUT_TRG (17)
191+
#define GPDMA_TRIG_GPDMA1_CH0_TC (18)
192+
#define GPDMA_TRIG_GPDMA1_CH1_TC (19)
193+
#define GPDMA_TRIG_GPDMA1_CH2_TC (20)
194+
#define GPDMA_TRIG_GPDMA1_CH3_TC (21)
195+
#define GPDMA_TRIG_GPDMA1_CH4_TC (22)
196+
#define GPDMA_TRIG_GPDMA1_CH5_TC (23)
197+
#define GPDMA_TRIG_GPDMA1_CH6_TC (24)
198+
#define GPDMA_TRIG_GPDMA1_CH7_TC (25)
199+
#define GPDMA_TRIG_GPDMA2_CH0_TC (26)
200+
#define GPDMA_TRIG_GPDMA2_CH1_TC (27)
201+
#define GPDMA_TRIG_GPDMA2_CH2_TC (28)
202+
#define GPDMA_TRIG_GPDMA2_CH3_TC (29)
203+
#define GPDMA_TRIG_GPDMA2_CH4_TC (30)
204+
#define GPDMA_TRIG_GPDMA2_CH5_TC (31)
205+
#define GPDMA_TRIG_GPDMA2_CH6_TC (32)
206+
#define GPDMA_TRIG_GPDMA2_CH7_TC (33)
207+
#define GPDMA_TRIG_TIM2_TRGO (34)
208+
#define GPDMA_TRIG_TIM15_TRG0 (35)
209+
#define GPDMA_TRIG_TIM12_TRGO (36)
210+
#define GPDMA_TRIG_LPTIM3_CH1 (37)
211+
#define GPDMA_TRIG_LPTIM3_CH2 (38)
212+
#define GPDMA_TRIG_LPTIM4_AIT (39)
213+
#define GPDMA_TRIG_LPTIM5_CH1 (40)
214+
#define GPDMA_TRIG_LPTIM5_CH2 (41)
215+
#define GPDMA_TRIG_LPTIM6_CH1 (42)
216+
#define GPDMA_TRIG_LPTIM6_CH2 (43)
217+
218+
#endif /* __ARCH_ARM_SRC_STM32H5_HARDWARE_STM32H56X_DMASIGMAP_H */

0 commit comments

Comments
 (0)