The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
114:252557024ec3
Release 147 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 111:4336505e4b1c 1 /* mbed Microcontroller Library
Kojto 111:4336505e4b1c 2 * Copyright (c) 2006-2015 ARM Limited
Kojto 111:4336505e4b1c 3 *
Kojto 111:4336505e4b1c 4 * Licensed under the Apache License, Version 2.0 (the "License");
Kojto 111:4336505e4b1c 5 * you may not use this file except in compliance with the License.
Kojto 111:4336505e4b1c 6 * You may obtain a copy of the License at
Kojto 111:4336505e4b1c 7 *
Kojto 111:4336505e4b1c 8 * http://www.apache.org/licenses/LICENSE-2.0
Kojto 111:4336505e4b1c 9 *
Kojto 111:4336505e4b1c 10 * Unless required by applicable law or agreed to in writing, software
Kojto 111:4336505e4b1c 11 * distributed under the License is distributed on an "AS IS" BASIS,
Kojto 111:4336505e4b1c 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Kojto 111:4336505e4b1c 13 * See the License for the specific language governing permissions and
Kojto 111:4336505e4b1c 14 * limitations under the License.
Kojto 111:4336505e4b1c 15 */
Kojto 111:4336505e4b1c 16
Kojto 111:4336505e4b1c 17 #ifndef _DMA_API_HAL_H
Kojto 111:4336505e4b1c 18 #define _DMA_API_HAL_H
Kojto 111:4336505e4b1c 19
Kojto 111:4336505e4b1c 20 #ifdef __cplusplus
Kojto 111:4336505e4b1c 21 extern "C" {
Kojto 111:4336505e4b1c 22 #endif
Kojto 111:4336505e4b1c 23
Kojto 111:4336505e4b1c 24 #include <compiler.h>
Kojto 111:4336505e4b1c 25 #include "dma.h"
Kojto 111:4336505e4b1c 26
Kojto 111:4336505e4b1c 27 enum dma_status_flags {
Kojto 111:4336505e4b1c 28 DMA_NOT_USED = (uint32_t)1,
Kojto 111:4336505e4b1c 29 DMA_ALLOCATED = (DMA_NOT_USED << 1),
Kojto 111:4336505e4b1c 30 DMA_TEMPORARY = (DMA_NOT_USED << 2),
Kojto 111:4336505e4b1c 31 DMA_ERROR = (DMA_NOT_USED << 3),
Kojto 111:4336505e4b1c 32 };
Kojto 111:4336505e4b1c 33
Kojto 111:4336505e4b1c 34 /* No other capabilities supported now */
Kojto 111:4336505e4b1c 35 #define DMA_CAP_NONE 0
Kojto 111:4336505e4b1c 36
Kojto 111:4336505e4b1c 37 #define DMA_ADDRESS_INC_DISABLE 0
Kojto 111:4336505e4b1c 38 #define DMA_ADDRESS_INC_ENABLE 1
Kojto 111:4336505e4b1c 39
Kojto 111:4336505e4b1c 40 #define DMA_TRANSFER_ERROR ((uint32_t)1 << 1)
Kojto 111:4336505e4b1c 41 #define DMA_TRANSFER_COMPLETE ((uint32_t)1 << 2)
Kojto 111:4336505e4b1c 42
Kojto 111:4336505e4b1c 43 #define DMA_EVENT_ALL (DMA_TRANSFER_ERROR | DMA_TRANSFER_COMPLETE)
Kojto 111:4336505e4b1c 44
Kojto 111:4336505e4b1c 45
Kojto 111:4336505e4b1c 46 COMPILER_ALIGNED(16)
Kojto 111:4336505e4b1c 47 struct dma_instance_s {
Kojto 111:4336505e4b1c 48 struct dma_resource resource;
Kojto 111:4336505e4b1c 49 DmacDescriptor descriptor;
Kojto 111:4336505e4b1c 50 uint8_t status;
Kojto 111:4336505e4b1c 51 uint32_t events;
Kojto 111:4336505e4b1c 52 uint32_t handler;
Kojto 111:4336505e4b1c 53 };
Kojto 111:4336505e4b1c 54
Kojto 111:4336505e4b1c 55 /** Setup a DMA descriptor for specified resource
Kojto 111:4336505e4b1c 56 *
Kojto 111:4336505e4b1c 57 * @param[in] channel_index DMA channel id
Kojto 111:4336505e4b1c 58 * @param[in] src source address
Kojto 111:4336505e4b1c 59 * @param[in] src_inc_enable source address auto increment enable flag
Kojto 111:4336505e4b1c 60 * @param[in] desc destination address
Kojto 111:4336505e4b1c 61 * @param[in] desc_inc_enable destination address auto increment enable flag
Kojto 111:4336505e4b1c 62 * @param[in] length length of data to be transferred
Kojto 111:4336505e4b1c 63 * @param[in] beat_size beat size to be set
Kojto 111:4336505e4b1c 64 * @return void
Kojto 111:4336505e4b1c 65 */
Kojto 111:4336505e4b1c 66 void dma_setup_transfer(uint8_t channelid, uint32_t src, bool src_inc_enable, uint32_t desc, bool desc_inc_enable, uint32_t length, uint8_t beat_size);
Kojto 111:4336505e4b1c 67
Kojto 111:4336505e4b1c 68 /** Start DMA transfer
Kojto 111:4336505e4b1c 69 *
Kojto 111:4336505e4b1c 70 * Kick starts transfer in DMA channel with specified channel id
Kojto 111:4336505e4b1c 71 * @param[in] channelid Channel id of DMA channel
Kojto 111:4336505e4b1c 72 * @return non zero if success otherwise zero
Kojto 111:4336505e4b1c 73 */
Kojto 111:4336505e4b1c 74 bool dma_start_transfer(int channelid);
Kojto 111:4336505e4b1c 75
Kojto 111:4336505e4b1c 76 /** DMA channel busy check
Kojto 111:4336505e4b1c 77 *
Kojto 111:4336505e4b1c 78 * To check whether DMA channel is busy with a job or not
Kojto 111:4336505e4b1c 79 * @param[in] channelid Channel id of DMA channel
Kojto 111:4336505e4b1c 80 * @return non zero if busy otherwise zero
Kojto 111:4336505e4b1c 81 */
Kojto 111:4336505e4b1c 82 bool dma_busy(int channelid);
Kojto 111:4336505e4b1c 83
Kojto 111:4336505e4b1c 84 /** DMA channel transfer completion check
Kojto 111:4336505e4b1c 85 *
Kojto 111:4336505e4b1c 86 * To check whether DMA channel job is completed or not
Kojto 111:4336505e4b1c 87 * @param[in] channelid Channel id of DMA channel
Kojto 111:4336505e4b1c 88 * @return non zero if busy otherwise zero
Kojto 111:4336505e4b1c 89 */
Kojto 111:4336505e4b1c 90 bool dma_is_transfer_complete(int channelid);
Kojto 111:4336505e4b1c 91
Kojto 111:4336505e4b1c 92 /** Registers callback function for DMA
Kojto 111:4336505e4b1c 93 *
Kojto 111:4336505e4b1c 94 * Registers callback function for DMA for specified events
Kojto 111:4336505e4b1c 95 * @param[in] channelid Channel id of DMA channel
Kojto 111:4336505e4b1c 96 * @param[in] handler Callback function pointer
Kojto 111:4336505e4b1c 97 * @param[in] event Events mask
Kojto 111:4336505e4b1c 98 * @return void
Kojto 111:4336505e4b1c 99 */
Kojto 111:4336505e4b1c 100 void dma_set_handler(int channelid, uint32_t handler, uint32_t event);
Kojto 111:4336505e4b1c 101
Kojto 111:4336505e4b1c 102 #ifdef __cplusplus
Kojto 111:4336505e4b1c 103 }
Kojto 111:4336505e4b1c 104 #endif
Kojto 111:4336505e4b1c 105
Kojto 114:252557024ec3 106 #endif /* _DMA_API_HAL_H */