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