|
| 1 | +/****************************************************************************** |
| 2 | + * The MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2012 LeafLabs, LLC. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person |
| 7 | + * obtaining a copy of this software and associated documentation |
| 8 | + * files (the "Software"), to deal in the Software without |
| 9 | + * restriction, including without limitation the rights to use, copy, |
| 10 | + * modify, merge, publish, distribute, sublicense, and/or sell copies |
| 11 | + * of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be |
| 15 | + * included in all copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 21 | + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | + * SOFTWARE. |
| 25 | + *****************************************************************************/ |
| 26 | + |
| 27 | +/** |
| 28 | + * @file libmaple/include/libmaple/dma_common.h |
| 29 | + * @author Marti Bolivar <mbolivar@leaflabs.com> |
| 30 | + * @brief Common DMA sub-header for <series/dma.h> and <libmaple/dma.h>. |
| 31 | + * |
| 32 | + * CONTENTS UNSTABLE. The existence of this file is an implementation |
| 33 | + * detail. Never include it directly. If you need something from |
| 34 | + * here, include <libmaple/dma.h> instead. |
| 35 | + */ |
| 36 | + |
| 37 | +/* |
| 38 | + * There's a fair amount of common DMA functionality needed by each |
| 39 | + * <series/dma.h> and <libmaple/dma.h>. This header exists in order |
| 40 | + * to provide it to both, avoiding some hacks and circular |
| 41 | + * dependencies. |
| 42 | + */ |
| 43 | + |
| 44 | +#ifndef _LIBMAPLE_DMA_COMMON_H_ |
| 45 | +#define _LIBMAPLE_DMA_COMMON_H_ |
| 46 | + |
| 47 | +#ifdef __cplusplus |
| 48 | +extern "C"{ |
| 49 | +#endif |
| 50 | + |
| 51 | +#include <libmaple/libmaple_types.h> |
| 52 | +#include <libmaple/nvic.h> |
| 53 | +#include <libmaple/rcc.h> |
| 54 | + |
| 55 | +/* |
| 56 | + * Devices |
| 57 | + */ |
| 58 | + |
| 59 | +struct dma_reg_map; |
| 60 | + |
| 61 | +/* Encapsulates state related to user interrupt handlers. You |
| 62 | + * shouldn't touch these directly; use dma_attach_interrupt() and |
| 63 | + * dma_detach_interupt() instead. */ |
| 64 | +//typedef struct dma_handler_config { |
| 65 | +// void (*handler)(void); /* User handler */ |
| 66 | +// nvic_irq_num irq_line; /* IRQ line for interrupt */ |
| 67 | +//} dma_handler_config; |
| 68 | + |
| 69 | +/** DMA device type */ |
| 70 | +//typedef struct dma_dev { |
| 71 | +// struct dma_reg_map *regs; /**< Register map */ |
| 72 | +// rcc_clk_id clk_id; /**< Clock ID */ |
| 73 | +// struct dma_handler_config handlers[]; /**< For internal use */ |
| 74 | +//} dma_dev; |
| 75 | + |
| 76 | +/** |
| 77 | + * @brief DMA channels |
| 78 | + * |
| 79 | + * Notes: |
| 80 | + * - This is also the dma_tube type for STM32F1. |
| 81 | + * - Channel 0 is not available on all STM32 series. |
| 82 | + * |
| 83 | + * @see dma_tube |
| 84 | + */ |
| 85 | +typedef enum dma_channel { |
| 86 | + DMA_CH0 = 0, /**< Channel 0 */ |
| 87 | + DMA_CH1 = 1, /**< Channel 1 */ |
| 88 | + DMA_CH2 = 2, /**< Channel 2 */ |
| 89 | + DMA_CH3 = 3, /**< Channel 3 */ |
| 90 | + DMA_CH4 = 4, /**< Channel 4 */ |
| 91 | + DMA_CH5 = 5, /**< Channel 5 */ |
| 92 | + DMA_CH6 = 6, /**< Channel 6 */ |
| 93 | + DMA_CH7 = 7, /**< Channel 7 */ |
| 94 | +} dma_channel; |
| 95 | + |
| 96 | +/** |
| 97 | + * @brief Source and destination transfer sizes. |
| 98 | + * Use these when initializing a struct dma_tube_config. |
| 99 | + * @see struct dma_tube_config |
| 100 | + * @see dma_tube_cfg |
| 101 | + */ |
| 102 | +//typedef enum dma_xfer_size { |
| 103 | +// DMA_SIZE_8BITS = 0, /**< 8-bit transfers */ |
| 104 | +// DMA_SIZE_16BITS = 1, /**< 16-bit transfers */ |
| 105 | +// DMA_SIZE_32BITS = 2, /**< 32-bit transfers */ |
| 106 | +//} dma_xfer_size; |
| 107 | + |
| 108 | +#ifdef __cplusplus |
| 109 | +} // extern "C" |
| 110 | +#endif |
| 111 | + |
| 112 | +#endif |
0 commit comments