mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 08:45:36 +03:00
Converting the universal target as well. Simplified timer management some. Added F722 support for good measuer. Fixed SITL, tests. Cleanup after rebase. Added support for all timer consumers and F7. Fixed 'USE_DMA_SPEC' for F3, some cleanups.
59 lines
1.8 KiB
C
59 lines
1.8 KiB
C
/*
|
|
* This file is part of Cleanflight and Betaflight.
|
|
*
|
|
* Cleanflight and Betaflight are free software. You can redistribute
|
|
* this software and/or modify this software under the terms of the
|
|
* GNU General Public License as published by the Free Software
|
|
* Foundation, either version 3 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* Cleanflight and Betaflight are distributed in the hope that they
|
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software.
|
|
*
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
//#pragma once
|
|
|
|
#include "platform.h"
|
|
|
|
#include "drivers/timer.h"
|
|
|
|
typedef uint16_t dmaCode_t;
|
|
|
|
typedef struct dmaChannelSpec_s {
|
|
dmaCode_t code;
|
|
#if defined(STM32F4) || defined(STM32F7)
|
|
DMA_Stream_TypeDef *ref;
|
|
uint32_t channel;
|
|
#else
|
|
DMA_Channel_TypeDef *ref;
|
|
#endif
|
|
} dmaChannelSpec_t;
|
|
|
|
#define DMA_CODE(dma, stream, chanreq) ((dma << 12)|(stream << 8)|(chanreq << 0))
|
|
#define DMA_CODE_CONTROLLER(code) ((code >> 12) & 0xf)
|
|
#define DMA_CODE_STREAM(code) ((code >> 8) & 0xf)
|
|
#define DMA_CODE_CHANNEL(code) ((code >> 0) & 0xff)
|
|
#define DMA_CODE_REQUEST(code) DMA_CODE_CHANNEL(code)
|
|
|
|
typedef enum {
|
|
DMA_PERIPH_SPI_TX,
|
|
DMA_PERIPH_SPI_RX,
|
|
DMA_PERIPH_ADC,
|
|
DMA_PERIPH_SDIO,
|
|
DMA_PERIPH_UART_TX,
|
|
DMA_PERIPH_UART_RX,
|
|
} dmaPeripheral_e;
|
|
|
|
typedef int8_t dmaoptValue_t;
|
|
#define DMA_OPT_UNUSED (-1)
|
|
|
|
const dmaChannelSpec_t *dmaGetChannelSpecByPeripheral(dmaPeripheral_e device, uint8_t index, int8_t opt);
|
|
const dmaChannelSpec_t *dmaGetChannelSpecByTimer(const timerHardware_t *timer);
|
|
int8_t dmaGetOptionByTimer(const timerHardware_t *timer);
|