1 /* 2 * This file is part of the MicroPython project, http://micropython.org/ 3 * 4 * The MIT License (MIT) 5 * 6 * Copyright (c) 2015 Damien P. George 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a copy 9 * of this software and associated documentation files (the "Software"), to deal 10 * in the Software without restriction, including without limitation the rights 11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 * copies of the Software, and to permit persons to whom the Software is 13 * furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice shall be included in 16 * all copies or substantial portions of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * THE SOFTWARE. 25 */ 26 #ifndef MICROPY_INCLUDED_STM32_DMA_H 27 #define MICROPY_INCLUDED_STM32_DMA_H 28 29 typedef struct _dma_descr_t dma_descr_t; 30 31 #if defined(STM32F0) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7) 32 33 extern const dma_descr_t dma_I2C_1_RX; 34 extern const dma_descr_t dma_SPI_3_RX; 35 extern const dma_descr_t dma_I2C_4_RX; 36 extern const dma_descr_t dma_I2C_3_RX; 37 extern const dma_descr_t dma_I2C_2_RX; 38 extern const dma_descr_t dma_SPI_2_RX; 39 extern const dma_descr_t dma_SPI_2_TX; 40 extern const dma_descr_t dma_I2C_3_TX; 41 extern const dma_descr_t dma_I2C_4_TX; 42 extern const dma_descr_t dma_DAC_1_TX; 43 extern const dma_descr_t dma_DAC_2_TX; 44 extern const dma_descr_t dma_SPI_3_TX; 45 extern const dma_descr_t dma_I2C_1_TX; 46 extern const dma_descr_t dma_I2C_2_TX; 47 extern const dma_descr_t dma_SDMMC_2; 48 extern const dma_descr_t dma_SPI_1_RX; 49 extern const dma_descr_t dma_SPI_5_RX; 50 extern const dma_descr_t dma_SDIO_0; 51 extern const dma_descr_t dma_SPI_4_RX; 52 extern const dma_descr_t dma_SPI_5_TX; 53 extern const dma_descr_t dma_SPI_4_TX; 54 extern const dma_descr_t dma_SPI_6_TX; 55 extern const dma_descr_t dma_SPI_1_TX; 56 extern const dma_descr_t dma_SDMMC_2; 57 extern const dma_descr_t dma_SPI_6_RX; 58 extern const dma_descr_t dma_SDIO_0; 59 extern const dma_descr_t dma_DCMI_0; 60 extern const dma_descr_t dma_I2S_1_RX; 61 extern const dma_descr_t dma_I2S_1_TX; 62 extern const dma_descr_t dma_I2S_2_RX; 63 extern const dma_descr_t dma_I2S_2_TX; 64 65 #elif defined(STM32L0) 66 67 extern const dma_descr_t dma_SPI_1_RX; 68 extern const dma_descr_t dma_I2C_3_TX; 69 extern const dma_descr_t dma_SPI_1_TX; 70 extern const dma_descr_t dma_I2C_3_RX; 71 extern const dma_descr_t dma_DAC_1_TX; 72 extern const dma_descr_t dma_SPI_2_RX; 73 extern const dma_descr_t dma_I2C_2_TX; 74 extern const dma_descr_t dma_DAC_2_TX; 75 extern const dma_descr_t dma_SPI_2_TX; 76 extern const dma_descr_t dma_I2C_2_RX; 77 extern const dma_descr_t dma_I2C_1_TX; 78 extern const dma_descr_t dma_I2C_1_RX; 79 80 #elif defined(STM32L4) || defined(STM32WB) 81 82 extern const dma_descr_t dma_ADC_1_RX; 83 extern const dma_descr_t dma_ADC_2_RX; 84 extern const dma_descr_t dma_SPI_1_RX; 85 extern const dma_descr_t dma_I2C_3_TX; 86 extern const dma_descr_t dma_ADC_3_RX; 87 extern const dma_descr_t dma_SPI_1_TX; 88 extern const dma_descr_t dma_I2C_3_RX; 89 extern const dma_descr_t dma_DAC_1_TX; 90 extern const dma_descr_t dma_SPI_2_RX; 91 extern const dma_descr_t dma_I2C_2_TX; 92 extern const dma_descr_t dma_DAC_2_TX; 93 extern const dma_descr_t dma_SPI_2_TX; 94 extern const dma_descr_t dma_I2C_2_RX; 95 extern const dma_descr_t dma_I2C_1_TX; 96 extern const dma_descr_t dma_I2C_1_RX; 97 extern const dma_descr_t dma_SPI_3_RX; 98 extern const dma_descr_t dma_SPI_3_TX; 99 extern const dma_descr_t dma_SDIO_0; 100 extern const dma_descr_t dma_I2C_4_TX; 101 extern const dma_descr_t dma_I2C_4_RX; 102 103 #endif 104 105 void dma_init(DMA_HandleTypeDef *dma, const dma_descr_t *dma_descr, uint32_t dir, void *data); 106 void dma_init_handle(DMA_HandleTypeDef *dma, const dma_descr_t *dma_descr, uint32_t dir, void *data); 107 void dma_deinit(const dma_descr_t *dma_descr); 108 void dma_invalidate_channel(const dma_descr_t *dma_descr); 109 110 void dma_nohal_init(const dma_descr_t *descr, uint32_t config); 111 void dma_nohal_deinit(const dma_descr_t *descr); 112 void dma_nohal_start(const dma_descr_t *descr, uint32_t src_addr, uint32_t dst_addr, uint16_t len); 113 114 #endif // MICROPY_INCLUDED_STM32_DMA_H 115