mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

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

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

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