Skyward boardcore
Loading...
Searching...
No Matches
DMADefs.h
Go to the documentation of this file.
1/* Copyright (c) 2025 Skyward Experimental Rocketry
2 * Author: Fabrizio Monti
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
25#include <interfaces/arch_registers.h>
26#include <stdint.h>
27
28#include <map>
29
30namespace Boardcore
31{
32
33// For some reason these defines are missing
34// in the CMSIS STM32F4xx file
35#if defined(STM32F407xx) || defined(STM32F429xx)
36
37#ifndef DMA_SxCR_MSIZE_Pos
38#define DMA_SxCR_MSIZE_Pos (13U)
39#endif
40
41#ifndef DMA_SxCR_PSIZE_Pos
42#define DMA_SxCR_PSIZE_Pos (11U)
43#endif
44
45#endif // STM32F407xx
46
47namespace DMADefs
48{
49
50enum class DMAStreamId : uint8_t
51{
63 DMA1_Str0 = 0,
64
65#ifndef STM32F407xx
66 // This stream is used by miosix for STM32F407xx boards
67 DMA1_Str1 = 1,
68#endif // STM32F407xx
69
70 DMA1_Str2 = 2,
71
72#ifndef STM32F407xx
73 // This stream is used by miosix for STM32F407xx boards
74 DMA1_Str3 = 3,
75#endif // STM32F407xx
76
77 DMA1_Str4 = 4,
78 DMA1_Str5 = 5,
79 DMA1_Str6 = 6,
80 DMA1_Str7 = 7,
81 DMA2_Str0 = 8,
82 DMA2_Str1 = 9,
83 DMA2_Str2 = 10,
84 // DMA2_Str3 = 11, // Always used by miosix on currently supported boards
85 DMA2_Str4 = 12,
86
87#if !defined(STM32F767xx) && !defined(STM32F429xx)
88 // This stream is used by miosix for STM32F767xx
89 // and STM32F429xx boards
90 DMA2_Str5 = 13,
91#endif // STM32F767xx & STM32F429xx
92
93 DMA2_Str6 = 14,
94
95#if !defined(STM32F767xx) && !defined(STM32F429xx)
96 // This stream is used by miosix for STM32F767xx
97 // and STM32F429xx boards
98 DMA2_Str7 = 15,
99#endif // STM32F767xx & STM32F429xx
100};
101
105enum class Channel : uint32_t
106{
107 // The first 8 channels are valid for all supported architectures
108 CHANNEL0 = 0,
109 CHANNEL1 = DMA_SxCR_CHSEL_0,
110 CHANNEL2 = DMA_SxCR_CHSEL_1,
111 CHANNEL3 = DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0,
112 CHANNEL4 = DMA_SxCR_CHSEL_2,
113 CHANNEL5 = DMA_SxCR_CHSEL_2 | DMA_SxCR_CHSEL_0,
114 CHANNEL6 = DMA_SxCR_CHSEL_2 | DMA_SxCR_CHSEL_1,
115 CHANNEL7 = DMA_SxCR_CHSEL_2 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0,
116
117// stm32f767 also has channels from 8 to 11
118#ifdef STM32F767xx
119 CHANNEL8 = DMA_SxCR_CHSEL_3,
120 CHANNEL9 = DMA_SxCR_CHSEL_3 | DMA_SxCR_CHSEL_0,
121 CHANNEL10 = DMA_SxCR_CHSEL_3 | DMA_SxCR_CHSEL_1,
122 CHANNEL11 = DMA_SxCR_CHSEL_3 | DMA_SxCR_CHSEL_1 | DMA_SxCR_CHSEL_0,
123#endif // STM32F767xx
124};
125
129enum class Peripherals : uint8_t
130{
132
211 PE_DAC1,
212 PE_DAC2,
213 PE_ADC1,
214 PE_ADC2,
215 PE_ADC3,
216 PE_SAI1_A,
217 PE_SAI2_A,
218 PE_SAI1_B,
219 PE_SAI2_B,
220 PE_DCMI,
221 PE_SDIO,
222 PE_SDMMC1,
223 PE_SDMMC2,
235};
236
242extern const IRQn_Type irqNumberMapping[];
243
252extern const std::multimap<Peripherals, std::pair<DMAStreamId, Channel>>
254
255} // namespace DMADefs
256
257} // namespace Boardcore
const IRQn_Type irqNumberMapping[]
Mapping between DMAStreamId and the corresponding irq number. This is needed because irq number value...
Definition DMADefs.cpp:60
Peripherals
All the peripherals connected to dma.
Definition DMADefs.h:130
Channel
Channels selectable for each dma stream.
Definition DMADefs.h:106
const std::multimap< Peripherals, std::pair< DMAStreamId, Channel > > mapPeripherals
Maps the peripherals to the dma streams (and the corresponding channel) that are connected with.
Driver for the VN100S IMU.