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.

Revision:
613:bc40b8d2aec4
Parent:
612:fba1c7dc54c0
Child:
614:9d86c2ae5de0
--- a/targets/hal/TARGET_Atmel/TARGET_SAM21/sercom_dma.c	Tue Aug 18 15:00:09 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* mbed Microcontroller Library
- * Copyright (c) 2006-2013 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "mbed_assert.h"
-#include "system.h"
-
-#include <math.h>
-
-#include "cmsis.h"
-#include "pinmap.h"
-#include "sercom.h"
-#include "dma_api.h"
-#include "dma_api_HAL.h"
-#include "sercom_dma.h"
-
-static struct sercom_dma sercom_channels[SERCOM_INST_NUM] = {{0}};
-
-/** Allocate a channel for TX
- *
- * @param[in] sercom_index	index of sercom instance
- * @param[out] tx_id		pointer to channel id
- * @return allocated channel id
- */
-uint8_t sercom_setup_tx_channel(uint8_t sercom_index, uint8_t *tx_id)
-{
-    if (sercom_channels[sercom_index].tx_status & DMA_ALLOCATED) {
-        *tx_id = sercom_channels[sercom_index].tx_channel_id;
-    } else {
-        /* Try to allocate a channel */
-        sercom_channels[sercom_index].tx_channel_id = dma_channel_allocate(DMA_CAP_NONE);
-        if (sercom_channels[sercom_index].tx_channel_id != (uint8_t)DMA_ERROR_OUT_OF_CHANNELS) {
-            *tx_id = sercom_channels[sercom_index].tx_channel_id;
-            sercom_channels[sercom_index].tx_status = DMA_ALLOCATED;
-        } else {
-            /* Couldn't find a channel */
-            return DMA_ERROR_OUT_OF_CHANNELS;
-        }
-    }
-    return *tx_id;
-}
-
-/** Allocate a channel for RX
- *
- * @param[in] sercom_index	index of sercom instance
- * @param[out] rx_id		pointer to channel id
- * @return allocated channel id
- */
-uint8_t sercom_setup_rx_channel(uint8_t sercom_index, uint8_t *rx_id)
-{
-    if (sercom_channels[sercom_index].rx_status & DMA_ALLOCATED) {
-        *rx_id = sercom_channels[sercom_index].rx_channel_id;
-    } else {
-        /* Try to allocate a channel */
-        sercom_channels[sercom_index].rx_channel_id = dma_channel_allocate(DMA_CAP_NONE);
-        if (sercom_channels[sercom_index].rx_channel_id != (uint8_t)DMA_ERROR_OUT_OF_CHANNELS) {
-            *rx_id = sercom_channels[sercom_index].rx_channel_id;
-            sercom_channels[sercom_index].rx_status = DMA_ALLOCATED;
-        } else {
-            /* Couldn't find a channel */
-            return DMA_ERROR_OUT_OF_CHANNELS;
-        }
-    }
-    return *rx_id;
-}
-
-/** Release DMA channels if allocated
- *
- * @param[in] sercom_index	index of sercom instance
- * @return void
- */
-void sercom_release_channel(uint8_t sercom_index)
-{
-    if (sercom_channels[sercom_index].rx_status & DMA_ALLOCATED) {
-        if (0 == dma_channel_free(sercom_channels[sercom_index].rx_channel_id)) {
-            sercom_channels[sercom_index].rx_status = DMA_NOT_USED;
-        }
-    }
-    if (sercom_channels[sercom_index].tx_status & DMA_ALLOCATED) {
-        if (0 == dma_channel_free(sercom_channels[sercom_index].tx_channel_id)) {
-            sercom_channels[sercom_index].tx_status = DMA_NOT_USED;
-        }
-    }
-}