2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
25 #include "drivers/dma.h"
26 #include "drivers/timer.h"
28 typedef uint16_t dmaCode_t
;
30 typedef struct dmaChannelSpec_s
{
33 #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32G4)
38 #define DMA_CODE(dma, stream, chanreq) ((dma << 12)|(stream << 8)|(chanreq << 0))
39 #define DMA_CODE_CONTROLLER(code) ((code >> 12) & 0xf)
40 #define DMA_CODE_STREAM(code) ((code >> 8) & 0xf)
41 #define DMA_CODE_CHANNEL(code) ((code >> 0) & 0xff)
42 #define DMA_CODE_REQUEST(code) DMA_CODE_CHANNEL(code)
54 typedef int8_t dmaoptValue_t
;
56 #define DMA_OPT_UNUSED (-1)
58 #if defined(STM32H7) || defined(STM32G4)
59 #define MAX_PERIPHERAL_DMA_OPTIONS 16
60 #define MAX_TIMER_DMA_OPTIONS 16
62 #define MAX_PERIPHERAL_DMA_OPTIONS 2
63 #define MAX_TIMER_DMA_OPTIONS 3
66 struct timerHardware_s
;
68 dmaoptValue_t
dmaoptByTag(ioTag_t ioTag
);
69 const dmaChannelSpec_t
*dmaGetChannelSpecByPeripheral(dmaPeripheral_e device
, uint8_t index
, int8_t opt
);
70 const dmaChannelSpec_t
*dmaGetChannelSpecByTimerValue(TIM_TypeDef
*tim
, uint8_t channel
, dmaoptValue_t dmaopt
);
71 const dmaChannelSpec_t
*dmaGetChannelSpecByTimer(const struct timerHardware_s
*timer
);
72 dmaoptValue_t
dmaGetOptionByTimer(const struct timerHardware_s
*timer
);
73 dmaoptValue_t
dmaGetUpOptionByTimer(const struct timerHardware_s
*timer
);