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:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 148:fd96258d940d 1 /*
Kojto 148:fd96258d940d 2 * Copyright (c) 2016, Freescale Semiconductor, Inc.
Kojto 148:fd96258d940d 3 * All rights reserved.
Kojto 148:fd96258d940d 4 *
Kojto 148:fd96258d940d 5 * Redistribution and use in source and binary forms, with or without modification,
Kojto 148:fd96258d940d 6 * are permitted provided that the following conditions are met:
Kojto 148:fd96258d940d 7 *
Kojto 148:fd96258d940d 8 * o Redistributions of source code must retain the above copyright notice, this list
Kojto 148:fd96258d940d 9 * of conditions and the following disclaimer.
Kojto 148:fd96258d940d 10 *
Kojto 148:fd96258d940d 11 * o Redistributions in binary form must reproduce the above copyright notice, this
Kojto 148:fd96258d940d 12 * list of conditions and the following disclaimer in the documentation and/or
Kojto 148:fd96258d940d 13 * other materials provided with the distribution.
Kojto 148:fd96258d940d 14 *
Kojto 148:fd96258d940d 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
Kojto 148:fd96258d940d 16 * contributors may be used to endorse or promote products derived from this
Kojto 148:fd96258d940d 17 * software without specific prior written permission.
Kojto 148:fd96258d940d 18 *
Kojto 148:fd96258d940d 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Kojto 148:fd96258d940d 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Kojto 148:fd96258d940d 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 148:fd96258d940d 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Kojto 148:fd96258d940d 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Kojto 148:fd96258d940d 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Kojto 148:fd96258d940d 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Kojto 148:fd96258d940d 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Kojto 148:fd96258d940d 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Kojto 148:fd96258d940d 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 148:fd96258d940d 29 */
Kojto 148:fd96258d940d 30 #ifndef _FSL_DMIC_DMA_H_
Kojto 148:fd96258d940d 31 #define _FSL_DMIC_DMA_H_
Kojto 148:fd96258d940d 32
Kojto 148:fd96258d940d 33 #include "fsl_common.h"
Kojto 148:fd96258d940d 34 #include "fsl_dma.h"
Kojto 148:fd96258d940d 35
Kojto 148:fd96258d940d 36 /*!
Kojto 148:fd96258d940d 37 * @addtogroup dmic_dma_driver
Kojto 148:fd96258d940d 38 * @{
Kojto 148:fd96258d940d 39 */
Kojto 148:fd96258d940d 40
Kojto 148:fd96258d940d 41 /*! @file */
Kojto 148:fd96258d940d 42
Kojto 148:fd96258d940d 43 /*******************************************************************************
Kojto 148:fd96258d940d 44 * Definitions
Kojto 148:fd96258d940d 45 ******************************************************************************/
Kojto 148:fd96258d940d 46
Kojto 148:fd96258d940d 47 /*! @brief DMIC transfer structure. */
Kojto 148:fd96258d940d 48 typedef struct _dmic_transfer
Kojto 148:fd96258d940d 49 {
Kojto 148:fd96258d940d 50 uint16_t *data; /*!< The buffer of data to be transfer.*/
Kojto 148:fd96258d940d 51 size_t dataSize; /*!< The byte count to be transfer. */
Kojto 148:fd96258d940d 52 } dmic_transfer_t;
Kojto 148:fd96258d940d 53
Kojto 148:fd96258d940d 54 /* Forward declaration of the handle typedef. */
Kojto 148:fd96258d940d 55 typedef struct _dmic_dma_handle dmic_dma_handle_t;
Kojto 148:fd96258d940d 56
Kojto 148:fd96258d940d 57 /*! @brief DMIC transfer callback function. */
Kojto 148:fd96258d940d 58 typedef void (*dmic_dma_transfer_callback_t)(DMIC_Type *base,
Kojto 148:fd96258d940d 59 dmic_dma_handle_t *handle,
Kojto 148:fd96258d940d 60 status_t status,
Kojto 148:fd96258d940d 61 void *userData);
Kojto 148:fd96258d940d 62
Kojto 148:fd96258d940d 63 /*!
Kojto 148:fd96258d940d 64 * @brief DMIC DMA handle
Kojto 148:fd96258d940d 65 */
Kojto 148:fd96258d940d 66 struct _dmic_dma_handle
Kojto 148:fd96258d940d 67 {
Kojto 148:fd96258d940d 68 DMIC_Type *base; /*!< DMIC peripheral base address. */
Kojto 148:fd96258d940d 69 dma_handle_t *rxDmaHandle; /*!< The DMA RX channel used. */
Kojto 148:fd96258d940d 70 dmic_dma_transfer_callback_t callback; /*!< Callback function. */
Kojto 148:fd96258d940d 71 void *userData; /*!< DMIC callback function parameter.*/
Kojto 148:fd96258d940d 72 size_t transferSize; /*!< Size of the data to receive. */
Kojto 148:fd96258d940d 73 volatile uint8_t state; /*!< Internal state of DMIC DMA transfer */
Kojto 148:fd96258d940d 74 };
Kojto 148:fd96258d940d 75
Kojto 148:fd96258d940d 76 /*******************************************************************************
Kojto 148:fd96258d940d 77 * API
Kojto 148:fd96258d940d 78 ******************************************************************************/
Kojto 148:fd96258d940d 79
Kojto 148:fd96258d940d 80 #ifdef __cplusplus
Kojto 148:fd96258d940d 81 extern "C" {
Kojto 148:fd96258d940d 82 #endif /* _cplusplus */
Kojto 148:fd96258d940d 83
Kojto 148:fd96258d940d 84 /*!
Kojto 148:fd96258d940d 85 * @name DMA transactional
Kojto 148:fd96258d940d 86 * @{
Kojto 148:fd96258d940d 87 */
Kojto 148:fd96258d940d 88
Kojto 148:fd96258d940d 89 /*!
Kojto 148:fd96258d940d 90 * @brief Initializes the DMIC handle which is used in transactional functions.
Kojto 148:fd96258d940d 91 * @param base DMIC peripheral base address.
Kojto 148:fd96258d940d 92 * @param handle Pointer to dmic_dma_handle_t structure.
Kojto 148:fd96258d940d 93 * @param callback Callback function.
Kojto 148:fd96258d940d 94 * @param userData User data.
Kojto 148:fd96258d940d 95 * @param rxDmaHandle User-requested DMA handle for RX DMA transfer.
Kojto 148:fd96258d940d 96 */
Kojto 148:fd96258d940d 97 status_t DMIC_TransferCreateHandleDMA(DMIC_Type *base,
Kojto 148:fd96258d940d 98 dmic_dma_handle_t *handle,
Kojto 148:fd96258d940d 99 dmic_dma_transfer_callback_t callback,
Kojto 148:fd96258d940d 100 void *userData,
Kojto 148:fd96258d940d 101 dma_handle_t *rxDmaHandle);
Kojto 148:fd96258d940d 102
Kojto 148:fd96258d940d 103 /*!
Kojto 148:fd96258d940d 104 * @brief Receives data using DMA.
Kojto 148:fd96258d940d 105 *
Kojto 148:fd96258d940d 106 * This function receives data using DMA. This is a non-blocking function, which returns
Kojto 148:fd96258d940d 107 * right away. When all data is received, the receive callback function is called.
Kojto 148:fd96258d940d 108 *
Kojto 148:fd96258d940d 109 * @param base USART peripheral base address.
Kojto 148:fd96258d940d 110 * @param handle Pointer to usart_dma_handle_t structure.
Kojto 148:fd96258d940d 111 * @param xfer DMIC DMA transfer structure. See #dmic_transfer_t.
Kojto 148:fd96258d940d 112 * @param dmic_channel DMIC channel
Kojto 148:fd96258d940d 113 * @retval kStatus_Success
Kojto 148:fd96258d940d 114 */
Kojto 148:fd96258d940d 115 status_t DMIC_TransferReceiveDMA(DMIC_Type *base,
Kojto 148:fd96258d940d 116 dmic_dma_handle_t *handle,
Kojto 148:fd96258d940d 117 dmic_transfer_t *xfer,
Kojto 148:fd96258d940d 118 uint32_t dmic_channel);
Kojto 148:fd96258d940d 119
Kojto 148:fd96258d940d 120 /*!
Kojto 148:fd96258d940d 121 * @brief Aborts the received data using DMA.
Kojto 148:fd96258d940d 122 *
Kojto 148:fd96258d940d 123 * This function aborts the received data using DMA.
Kojto 148:fd96258d940d 124 *
Kojto 148:fd96258d940d 125 * @param base DMIC peripheral base address
Kojto 148:fd96258d940d 126 * @param handle Pointer to dmic_dma_handle_t structure
Kojto 148:fd96258d940d 127 */
Kojto 148:fd96258d940d 128 void DMIC_TransferAbortReceiveDMA(DMIC_Type *base, dmic_dma_handle_t *handle);
Kojto 148:fd96258d940d 129
Kojto 148:fd96258d940d 130 /*!
Kojto 148:fd96258d940d 131 * @brief Get the number of bytes that have been received.
Kojto 148:fd96258d940d 132 *
Kojto 148:fd96258d940d 133 * This function gets the number of bytes that have been received.
Kojto 148:fd96258d940d 134 *
Kojto 148:fd96258d940d 135 * @param base DMIC peripheral base address.
Kojto 148:fd96258d940d 136 * @param handle DMIC handle pointer.
Kojto 148:fd96258d940d 137 * @param count Receive bytes count.
Kojto 148:fd96258d940d 138 * @retval kStatus_NoTransferInProgress No receive in progress.
Kojto 148:fd96258d940d 139 * @retval kStatus_InvalidArgument Parameter is invalid.
Kojto 148:fd96258d940d 140 * @retval kStatus_Success Get successfully through the parameter count;
Kojto 148:fd96258d940d 141 */
Kojto 148:fd96258d940d 142 status_t DMIC_TransferGetReceiveCountDMA(DMIC_Type *base, dmic_dma_handle_t *handle, uint32_t *count);
Kojto 148:fd96258d940d 143
Kojto 148:fd96258d940d 144 /* @} */
Kojto 148:fd96258d940d 145
Kojto 148:fd96258d940d 146 #if defined(__cplusplus)
Kojto 148:fd96258d940d 147 }
Kojto 148:fd96258d940d 148 #endif
Kojto 148:fd96258d940d 149
Kojto 148:fd96258d940d 150 /*! @}*/
Kojto 148:fd96258d940d 151
Kojto 148:fd96258d940d 152 #endif /* _FSL_DMIC_DMA_H_ */