raspiezo / mbed-dev

Dependents:   Nucleo_L432KC_Quadrature_Decoder_with_ADC_and_DAC

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Wed Jan 04 16:58:05 2017 +0000
Revision:
154:37f96f9d4de2
This updates the lib to the mbed lib v133

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 154:37f96f9d4de2 1 /*
<> 154:37f96f9d4de2 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
<> 154:37f96f9d4de2 3 * All rights reserved.
<> 154:37f96f9d4de2 4 *
<> 154:37f96f9d4de2 5 * Redistribution and use in source and binary forms, with or without modification,
<> 154:37f96f9d4de2 6 * are permitted provided that the following conditions are met:
<> 154:37f96f9d4de2 7 *
<> 154:37f96f9d4de2 8 * o Redistributions of source code must retain the above copyright notice, this list
<> 154:37f96f9d4de2 9 * of conditions and the following disclaimer.
<> 154:37f96f9d4de2 10 *
<> 154:37f96f9d4de2 11 * o Redistributions in binary form must reproduce the above copyright notice, this
<> 154:37f96f9d4de2 12 * list of conditions and the following disclaimer in the documentation and/or
<> 154:37f96f9d4de2 13 * other materials provided with the distribution.
<> 154:37f96f9d4de2 14 *
<> 154:37f96f9d4de2 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
<> 154:37f96f9d4de2 16 * contributors may be used to endorse or promote products derived from this
<> 154:37f96f9d4de2 17 * software without specific prior written permission.
<> 154:37f96f9d4de2 18 *
<> 154:37f96f9d4de2 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
<> 154:37f96f9d4de2 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
<> 154:37f96f9d4de2 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
<> 154:37f96f9d4de2 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
<> 154:37f96f9d4de2 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
<> 154:37f96f9d4de2 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
<> 154:37f96f9d4de2 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
<> 154:37f96f9d4de2 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<> 154:37f96f9d4de2 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
<> 154:37f96f9d4de2 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<> 154:37f96f9d4de2 29 */
<> 154:37f96f9d4de2 30 #ifndef _FSL_UART_DMA_H_
<> 154:37f96f9d4de2 31 #define _FSL_UART_DMA_H_
<> 154:37f96f9d4de2 32
<> 154:37f96f9d4de2 33 #include "fsl_uart.h"
<> 154:37f96f9d4de2 34 #include "fsl_dmamux.h"
<> 154:37f96f9d4de2 35 #include "fsl_dma.h"
<> 154:37f96f9d4de2 36
<> 154:37f96f9d4de2 37 /*!
<> 154:37f96f9d4de2 38 * @addtogroup uart_dma_driver
<> 154:37f96f9d4de2 39 * @{
<> 154:37f96f9d4de2 40 */
<> 154:37f96f9d4de2 41
<> 154:37f96f9d4de2 42 /*! @file*/
<> 154:37f96f9d4de2 43
<> 154:37f96f9d4de2 44 /*******************************************************************************
<> 154:37f96f9d4de2 45 * Definitions
<> 154:37f96f9d4de2 46 ******************************************************************************/
<> 154:37f96f9d4de2 47
<> 154:37f96f9d4de2 48 /* Forward declaration of the handle typedef. */
<> 154:37f96f9d4de2 49 typedef struct _uart_dma_handle uart_dma_handle_t;
<> 154:37f96f9d4de2 50
<> 154:37f96f9d4de2 51 /*! @brief UART transfer callback function. */
<> 154:37f96f9d4de2 52 typedef void (*uart_dma_transfer_callback_t)(UART_Type *base,
<> 154:37f96f9d4de2 53 uart_dma_handle_t *handle,
<> 154:37f96f9d4de2 54 status_t status,
<> 154:37f96f9d4de2 55 void *userData);
<> 154:37f96f9d4de2 56
<> 154:37f96f9d4de2 57 /*!
<> 154:37f96f9d4de2 58 * @brief UART DMA handle
<> 154:37f96f9d4de2 59 */
<> 154:37f96f9d4de2 60 struct _uart_dma_handle
<> 154:37f96f9d4de2 61 {
<> 154:37f96f9d4de2 62 UART_Type *base; /*!< UART peripheral base address. */
<> 154:37f96f9d4de2 63
<> 154:37f96f9d4de2 64 uart_dma_transfer_callback_t callback; /*!< Callback function. */
<> 154:37f96f9d4de2 65 void *userData; /*!< UART callback function parameter.*/
<> 154:37f96f9d4de2 66 size_t rxDataSizeAll; /*!< Size of the data to receive. */
<> 154:37f96f9d4de2 67 size_t txDataSizeAll; /*!< Size of the data to send out. */
<> 154:37f96f9d4de2 68
<> 154:37f96f9d4de2 69 dma_handle_t *txDmaHandle; /*!< The DMA TX channel used. */
<> 154:37f96f9d4de2 70 dma_handle_t *rxDmaHandle; /*!< The DMA RX channel used. */
<> 154:37f96f9d4de2 71
<> 154:37f96f9d4de2 72 volatile uint8_t txState; /*!< TX transfer state. */
<> 154:37f96f9d4de2 73 volatile uint8_t rxState; /*!< RX transfer state */
<> 154:37f96f9d4de2 74 };
<> 154:37f96f9d4de2 75
<> 154:37f96f9d4de2 76 /*******************************************************************************
<> 154:37f96f9d4de2 77 * API
<> 154:37f96f9d4de2 78 ******************************************************************************/
<> 154:37f96f9d4de2 79
<> 154:37f96f9d4de2 80 #if defined(__cplusplus)
<> 154:37f96f9d4de2 81 extern "C" {
<> 154:37f96f9d4de2 82 #endif
<> 154:37f96f9d4de2 83
<> 154:37f96f9d4de2 84 /*!
<> 154:37f96f9d4de2 85 * @name EDMA transactional
<> 154:37f96f9d4de2 86 * @{
<> 154:37f96f9d4de2 87 */
<> 154:37f96f9d4de2 88
<> 154:37f96f9d4de2 89 /*!
<> 154:37f96f9d4de2 90 * @brief Initializes the UART handle which is used in transactional functions and sets the callback.
<> 154:37f96f9d4de2 91 *
<> 154:37f96f9d4de2 92 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 93 * @param handle Pointer to uart_dma_handle_t structure.
<> 154:37f96f9d4de2 94 * @param callback UART callback, NULL means no callback.
<> 154:37f96f9d4de2 95 * @param userData User callback function data.
<> 154:37f96f9d4de2 96 * @param rxDmaHandle User requested DMA handle for RX DMA transfer.
<> 154:37f96f9d4de2 97 * @param txDmaHandle User requested DMA handle for TX DMA transfer.
<> 154:37f96f9d4de2 98 */
<> 154:37f96f9d4de2 99 void UART_TransferCreateHandleDMA(UART_Type *base,
<> 154:37f96f9d4de2 100 uart_dma_handle_t *handle,
<> 154:37f96f9d4de2 101 uart_dma_transfer_callback_t callback,
<> 154:37f96f9d4de2 102 void *userData,
<> 154:37f96f9d4de2 103 dma_handle_t *txDmaHandle,
<> 154:37f96f9d4de2 104 dma_handle_t *rxDmaHandle);
<> 154:37f96f9d4de2 105
<> 154:37f96f9d4de2 106 /*!
<> 154:37f96f9d4de2 107 * @brief Sends data using DMA.
<> 154:37f96f9d4de2 108 *
<> 154:37f96f9d4de2 109 * This function sends data using DMA. This is non-blocking function, which returns
<> 154:37f96f9d4de2 110 * right away. When all data is sent, the send callback function is called.
<> 154:37f96f9d4de2 111 *
<> 154:37f96f9d4de2 112 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 113 * @param handle UART handle pointer.
<> 154:37f96f9d4de2 114 * @param xfer UART DMA transfer structure. See #uart_transfer_t.
<> 154:37f96f9d4de2 115 * @retval kStatus_Success if succeed, others failed.
<> 154:37f96f9d4de2 116 * @retval kStatus_UART_TxBusy Previous transfer on going.
<> 154:37f96f9d4de2 117 * @retval kStatus_InvalidArgument Invalid argument.
<> 154:37f96f9d4de2 118 */
<> 154:37f96f9d4de2 119 status_t UART_TransferSendDMA(UART_Type *base, uart_dma_handle_t *handle, uart_transfer_t *xfer);
<> 154:37f96f9d4de2 120
<> 154:37f96f9d4de2 121 /*!
<> 154:37f96f9d4de2 122 * @brief Receives data using DMA.
<> 154:37f96f9d4de2 123 *
<> 154:37f96f9d4de2 124 * This function receives data using DMA. This is non-blocking function, which returns
<> 154:37f96f9d4de2 125 * right away. When all data is received, the receive callback function is called.
<> 154:37f96f9d4de2 126 *
<> 154:37f96f9d4de2 127 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 128 * @param handle Pointer to uart_dma_handle_t structure.
<> 154:37f96f9d4de2 129 * @param xfer UART DMA transfer structure. See #uart_transfer_t.
<> 154:37f96f9d4de2 130 * @retval kStatus_Success if succeed, others failed.
<> 154:37f96f9d4de2 131 * @retval kStatus_UART_RxBusy Previous transfer on going.
<> 154:37f96f9d4de2 132 * @retval kStatus_InvalidArgument Invalid argument.
<> 154:37f96f9d4de2 133 */
<> 154:37f96f9d4de2 134 status_t UART_TransferReceiveDMA(UART_Type *base, uart_dma_handle_t *handle, uart_transfer_t *xfer);
<> 154:37f96f9d4de2 135
<> 154:37f96f9d4de2 136 /*!
<> 154:37f96f9d4de2 137 * @brief Aborts the send data using DMA.
<> 154:37f96f9d4de2 138 *
<> 154:37f96f9d4de2 139 * This function aborts the sent data using DMA.
<> 154:37f96f9d4de2 140 *
<> 154:37f96f9d4de2 141 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 142 * @param handle Pointer to uart_dma_handle_t structure.
<> 154:37f96f9d4de2 143 */
<> 154:37f96f9d4de2 144 void UART_TransferAbortSendDMA(UART_Type *base, uart_dma_handle_t *handle);
<> 154:37f96f9d4de2 145
<> 154:37f96f9d4de2 146 /*!
<> 154:37f96f9d4de2 147 * @brief Aborts the received data using DMA.
<> 154:37f96f9d4de2 148 *
<> 154:37f96f9d4de2 149 * This function abort receive data which using DMA.
<> 154:37f96f9d4de2 150 *
<> 154:37f96f9d4de2 151 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 152 * @param handle Pointer to uart_dma_handle_t structure.
<> 154:37f96f9d4de2 153 */
<> 154:37f96f9d4de2 154 void UART_TransferAbortReceiveDMA(UART_Type *base, uart_dma_handle_t *handle);
<> 154:37f96f9d4de2 155
<> 154:37f96f9d4de2 156 /*!
<> 154:37f96f9d4de2 157 * @brief Get the number of bytes that have been written to UART TX register.
<> 154:37f96f9d4de2 158 *
<> 154:37f96f9d4de2 159 * This function gets the number of bytes that have been written to UART TX
<> 154:37f96f9d4de2 160 * register by DMA.
<> 154:37f96f9d4de2 161 *
<> 154:37f96f9d4de2 162 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 163 * @param handle UART handle pointer.
<> 154:37f96f9d4de2 164 * @param count Send bytes count.
<> 154:37f96f9d4de2 165 * @retval kStatus_NoTransferInProgress No send in progress.
<> 154:37f96f9d4de2 166 * @retval kStatus_InvalidArgument Parameter is invalid.
<> 154:37f96f9d4de2 167 * @retval kStatus_Success Get successfully through the parameter \p count;
<> 154:37f96f9d4de2 168 */
<> 154:37f96f9d4de2 169 status_t UART_TransferGetSendCountDMA(UART_Type *base, uart_dma_handle_t *handle, uint32_t *count);
<> 154:37f96f9d4de2 170
<> 154:37f96f9d4de2 171 /*!
<> 154:37f96f9d4de2 172 * @brief Get the number of bytes that have been received.
<> 154:37f96f9d4de2 173 *
<> 154:37f96f9d4de2 174 * This function gets the number of bytes that have been received.
<> 154:37f96f9d4de2 175 *
<> 154:37f96f9d4de2 176 * @param base UART peripheral base address.
<> 154:37f96f9d4de2 177 * @param handle UART handle pointer.
<> 154:37f96f9d4de2 178 * @param count Receive bytes count.
<> 154:37f96f9d4de2 179 * @retval kStatus_NoTransferInProgress No receive in progress.
<> 154:37f96f9d4de2 180 * @retval kStatus_InvalidArgument Parameter is invalid.
<> 154:37f96f9d4de2 181 * @retval kStatus_Success Get successfully through the parameter \p count;
<> 154:37f96f9d4de2 182 */
<> 154:37f96f9d4de2 183 status_t UART_TransferGetReceiveCountDMA(UART_Type *base, uart_dma_handle_t *handle, uint32_t *count);
<> 154:37f96f9d4de2 184
<> 154:37f96f9d4de2 185 /*@}*/
<> 154:37f96f9d4de2 186
<> 154:37f96f9d4de2 187 #if defined(__cplusplus)
<> 154:37f96f9d4de2 188 }
<> 154:37f96f9d4de2 189 #endif
<> 154:37f96f9d4de2 190
<> 154:37f96f9d4de2 191 /*! @}*/
<> 154:37f96f9d4de2 192
<> 154:37f96f9d4de2 193 #endif /* _FSL_UART_DMA_H_ */