![](/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_K82F/drivers/fsl_lpuart_edma.h@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
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_EDMA_H_ |
kadonotakashi | 0:8fdf9a60065b | 31 | #define _FSL_LPUART_EDMA_H_ |
kadonotakashi | 0:8fdf9a60065b | 32 | |
kadonotakashi | 0:8fdf9a60065b | 33 | #include "fsl_lpuart.h" |
kadonotakashi | 0:8fdf9a60065b | 34 | #include "fsl_dmamux.h" |
kadonotakashi | 0:8fdf9a60065b | 35 | #include "fsl_edma.h" |
kadonotakashi | 0:8fdf9a60065b | 36 | |
kadonotakashi | 0:8fdf9a60065b | 37 | /*! |
kadonotakashi | 0:8fdf9a60065b | 38 | * @addtogroup lpuart_edma_driver |
kadonotakashi | 0:8fdf9a60065b | 39 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 40 | */ |
kadonotakashi | 0:8fdf9a60065b | 41 | |
kadonotakashi | 0:8fdf9a60065b | 42 | /******************************************************************************* |
kadonotakashi | 0:8fdf9a60065b | 43 | * Definitions |
kadonotakashi | 0:8fdf9a60065b | 44 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 45 | |
kadonotakashi | 0:8fdf9a60065b | 46 | /* Forward declaration of the handle typedef. */ |
kadonotakashi | 0:8fdf9a60065b | 47 | typedef struct _lpuart_edma_handle lpuart_edma_handle_t; |
kadonotakashi | 0:8fdf9a60065b | 48 | |
kadonotakashi | 0:8fdf9a60065b | 49 | /*! @brief LPUART transfer callback function. */ |
kadonotakashi | 0:8fdf9a60065b | 50 | typedef void (*lpuart_edma_transfer_callback_t)(LPUART_Type *base, |
kadonotakashi | 0:8fdf9a60065b | 51 | lpuart_edma_handle_t *handle, |
kadonotakashi | 0:8fdf9a60065b | 52 | status_t status, |
kadonotakashi | 0:8fdf9a60065b | 53 | void *userData); |
kadonotakashi | 0:8fdf9a60065b | 54 | |
kadonotakashi | 0:8fdf9a60065b | 55 | /*! |
kadonotakashi | 0:8fdf9a60065b | 56 | * @brief LPUART eDMA handle |
kadonotakashi | 0:8fdf9a60065b | 57 | */ |
kadonotakashi | 0:8fdf9a60065b | 58 | struct _lpuart_edma_handle |
kadonotakashi | 0:8fdf9a60065b | 59 | { |
kadonotakashi | 0:8fdf9a60065b | 60 | lpuart_edma_transfer_callback_t callback; /*!< Callback function. */ |
kadonotakashi | 0:8fdf9a60065b | 61 | void *userData; /*!< LPUART callback function parameter.*/ |
kadonotakashi | 0:8fdf9a60065b | 62 | size_t rxDataSizeAll; /*!< Size of the data to receive. */ |
kadonotakashi | 0:8fdf9a60065b | 63 | size_t txDataSizeAll; /*!< Size of the data to send out. */ |
kadonotakashi | 0:8fdf9a60065b | 64 | |
kadonotakashi | 0:8fdf9a60065b | 65 | edma_handle_t *txEdmaHandle; /*!< The eDMA TX channel used. */ |
kadonotakashi | 0:8fdf9a60065b | 66 | edma_handle_t *rxEdmaHandle; /*!< The eDMA RX channel used. */ |
kadonotakashi | 0:8fdf9a60065b | 67 | |
kadonotakashi | 0:8fdf9a60065b | 68 | uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */ |
kadonotakashi | 0:8fdf9a60065b | 69 | |
kadonotakashi | 0:8fdf9a60065b | 70 | volatile uint8_t txState; /*!< TX transfer state. */ |
kadonotakashi | 0:8fdf9a60065b | 71 | volatile uint8_t rxState; /*!< RX transfer state */ |
kadonotakashi | 0:8fdf9a60065b | 72 | }; |
kadonotakashi | 0:8fdf9a60065b | 73 | |
kadonotakashi | 0:8fdf9a60065b | 74 | /******************************************************************************* |
kadonotakashi | 0:8fdf9a60065b | 75 | * API |
kadonotakashi | 0:8fdf9a60065b | 76 | ******************************************************************************/ |
kadonotakashi | 0:8fdf9a60065b | 77 | |
kadonotakashi | 0:8fdf9a60065b | 78 | #if defined(__cplusplus) |
kadonotakashi | 0:8fdf9a60065b | 79 | extern "C" { |
kadonotakashi | 0:8fdf9a60065b | 80 | #endif |
kadonotakashi | 0:8fdf9a60065b | 81 | |
kadonotakashi | 0:8fdf9a60065b | 82 | /*! |
kadonotakashi | 0:8fdf9a60065b | 83 | * @name eDMA transactional |
kadonotakashi | 0:8fdf9a60065b | 84 | * @{ |
kadonotakashi | 0:8fdf9a60065b | 85 | */ |
kadonotakashi | 0:8fdf9a60065b | 86 | |
kadonotakashi | 0:8fdf9a60065b | 87 | /*! |
kadonotakashi | 0:8fdf9a60065b | 88 | * @brief Initializes the LPUART handle which is used in transactional functions. |
kadonotakashi | 0:8fdf9a60065b | 89 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 90 | * @param handle Pointer to lpuart_edma_handle_t structure. |
kadonotakashi | 0:8fdf9a60065b | 91 | * @param callback Callback function. |
kadonotakashi | 0:8fdf9a60065b | 92 | * @param userData User data. |
kadonotakashi | 0:8fdf9a60065b | 93 | * @param txEdmaHandle User requested DMA handle for TX DMA transfer. |
kadonotakashi | 0:8fdf9a60065b | 94 | * @param rxEdmaHandle User requested DMA handle for RX DMA transfer. |
kadonotakashi | 0:8fdf9a60065b | 95 | */ |
kadonotakashi | 0:8fdf9a60065b | 96 | void LPUART_TransferCreateHandleEDMA(LPUART_Type *base, |
kadonotakashi | 0:8fdf9a60065b | 97 | lpuart_edma_handle_t *handle, |
kadonotakashi | 0:8fdf9a60065b | 98 | lpuart_edma_transfer_callback_t callback, |
kadonotakashi | 0:8fdf9a60065b | 99 | void *userData, |
kadonotakashi | 0:8fdf9a60065b | 100 | edma_handle_t *txEdmaHandle, |
kadonotakashi | 0:8fdf9a60065b | 101 | edma_handle_t *rxEdmaHandle); |
kadonotakashi | 0:8fdf9a60065b | 102 | |
kadonotakashi | 0:8fdf9a60065b | 103 | /*! |
kadonotakashi | 0:8fdf9a60065b | 104 | * @brief Sends data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 105 | * |
kadonotakashi | 0:8fdf9a60065b | 106 | * This function sends data using eDMA. This is a non-blocking function, which returns |
kadonotakashi | 0:8fdf9a60065b | 107 | * right away. When all data is sent, the send callback function is called. |
kadonotakashi | 0:8fdf9a60065b | 108 | * |
kadonotakashi | 0:8fdf9a60065b | 109 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 110 | * @param handle LPUART handle pointer. |
kadonotakashi | 0:8fdf9a60065b | 111 | * @param xfer LPUART eDMA transfer structure. See #lpuart_transfer_t. |
kadonotakashi | 0:8fdf9a60065b | 112 | * @retval kStatus_Success if succeed, others failed. |
kadonotakashi | 0:8fdf9a60065b | 113 | * @retval kStatus_LPUART_TxBusy Previous transfer on going. |
kadonotakashi | 0:8fdf9a60065b | 114 | * @retval kStatus_InvalidArgument Invalid argument. |
kadonotakashi | 0:8fdf9a60065b | 115 | */ |
kadonotakashi | 0:8fdf9a60065b | 116 | status_t LPUART_SendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer); |
kadonotakashi | 0:8fdf9a60065b | 117 | |
kadonotakashi | 0:8fdf9a60065b | 118 | /*! |
kadonotakashi | 0:8fdf9a60065b | 119 | * @brief Receives data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 120 | * |
kadonotakashi | 0:8fdf9a60065b | 121 | * This function receives data using eDMA. This is non-blocking function, which returns |
kadonotakashi | 0:8fdf9a60065b | 122 | * right away. When all data is received, the receive callback function is called. |
kadonotakashi | 0:8fdf9a60065b | 123 | * |
kadonotakashi | 0:8fdf9a60065b | 124 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 125 | * @param handle Pointer to lpuart_edma_handle_t structure. |
kadonotakashi | 0:8fdf9a60065b | 126 | * @param xfer LPUART eDMA transfer structure, see #lpuart_transfer_t. |
kadonotakashi | 0:8fdf9a60065b | 127 | * @retval kStatus_Success if succeed, others fail. |
kadonotakashi | 0:8fdf9a60065b | 128 | * @retval kStatus_LPUART_RxBusy Previous transfer ongoing. |
kadonotakashi | 0:8fdf9a60065b | 129 | * @retval kStatus_InvalidArgument Invalid argument. |
kadonotakashi | 0:8fdf9a60065b | 130 | */ |
kadonotakashi | 0:8fdf9a60065b | 131 | status_t LPUART_ReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, lpuart_transfer_t *xfer); |
kadonotakashi | 0:8fdf9a60065b | 132 | |
kadonotakashi | 0:8fdf9a60065b | 133 | /*! |
kadonotakashi | 0:8fdf9a60065b | 134 | * @brief Aborts the sent data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 135 | * |
kadonotakashi | 0:8fdf9a60065b | 136 | * This function aborts the sent data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 137 | * |
kadonotakashi | 0:8fdf9a60065b | 138 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 139 | * @param handle Pointer to lpuart_edma_handle_t structure. |
kadonotakashi | 0:8fdf9a60065b | 140 | */ |
kadonotakashi | 0:8fdf9a60065b | 141 | void LPUART_TransferAbortSendEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle); |
kadonotakashi | 0:8fdf9a60065b | 142 | |
kadonotakashi | 0:8fdf9a60065b | 143 | /*! |
kadonotakashi | 0:8fdf9a60065b | 144 | * @brief Aborts the received data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 145 | * |
kadonotakashi | 0:8fdf9a60065b | 146 | * This function aborts the received data using eDMA. |
kadonotakashi | 0:8fdf9a60065b | 147 | * |
kadonotakashi | 0:8fdf9a60065b | 148 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 149 | * @param handle Pointer to lpuart_edma_handle_t structure. |
kadonotakashi | 0:8fdf9a60065b | 150 | */ |
kadonotakashi | 0:8fdf9a60065b | 151 | void LPUART_TransferAbortReceiveEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle); |
kadonotakashi | 0:8fdf9a60065b | 152 | |
kadonotakashi | 0:8fdf9a60065b | 153 | /*! |
kadonotakashi | 0:8fdf9a60065b | 154 | * @brief Gets the number of bytes written to the LPUART TX register. |
kadonotakashi | 0:8fdf9a60065b | 155 | * |
kadonotakashi | 0:8fdf9a60065b | 156 | * This function gets the number of bytes written to the LPUART TX |
kadonotakashi | 0:8fdf9a60065b | 157 | * register by DMA. |
kadonotakashi | 0:8fdf9a60065b | 158 | * |
kadonotakashi | 0:8fdf9a60065b | 159 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 160 | * @param handle LPUART handle pointer. |
kadonotakashi | 0:8fdf9a60065b | 161 | * @param count Send bytes count. |
kadonotakashi | 0:8fdf9a60065b | 162 | * @retval kStatus_NoTransferInProgress No send in progress. |
kadonotakashi | 0:8fdf9a60065b | 163 | * @retval kStatus_InvalidArgument Parameter is invalid. |
kadonotakashi | 0:8fdf9a60065b | 164 | * @retval kStatus_Success Get successfully through the parameter \p count; |
kadonotakashi | 0:8fdf9a60065b | 165 | */ |
kadonotakashi | 0:8fdf9a60065b | 166 | status_t LPUART_TransferGetSendCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count); |
kadonotakashi | 0:8fdf9a60065b | 167 | |
kadonotakashi | 0:8fdf9a60065b | 168 | /*! |
kadonotakashi | 0:8fdf9a60065b | 169 | * @brief Gets the number of received bytes. |
kadonotakashi | 0:8fdf9a60065b | 170 | * |
kadonotakashi | 0:8fdf9a60065b | 171 | * This function gets the number of received bytes. |
kadonotakashi | 0:8fdf9a60065b | 172 | * |
kadonotakashi | 0:8fdf9a60065b | 173 | * @param base LPUART peripheral base address. |
kadonotakashi | 0:8fdf9a60065b | 174 | * @param handle LPUART handle pointer. |
kadonotakashi | 0:8fdf9a60065b | 175 | * @param count Receive bytes count. |
kadonotakashi | 0:8fdf9a60065b | 176 | * @retval kStatus_NoTransferInProgress No receive in progress. |
kadonotakashi | 0:8fdf9a60065b | 177 | * @retval kStatus_InvalidArgument Parameter is invalid. |
kadonotakashi | 0:8fdf9a60065b | 178 | * @retval kStatus_Success Get successfully through the parameter \p count; |
kadonotakashi | 0:8fdf9a60065b | 179 | */ |
kadonotakashi | 0:8fdf9a60065b | 180 | status_t LPUART_TransferGetReceiveCountEDMA(LPUART_Type *base, lpuart_edma_handle_t *handle, uint32_t *count); |
kadonotakashi | 0:8fdf9a60065b | 181 | |
kadonotakashi | 0:8fdf9a60065b | 182 | /*@}*/ |
kadonotakashi | 0:8fdf9a60065b | 183 | |
kadonotakashi | 0:8fdf9a60065b | 184 | #if defined(__cplusplus) |
kadonotakashi | 0:8fdf9a60065b | 185 | } |
kadonotakashi | 0:8fdf9a60065b | 186 | #endif |
kadonotakashi | 0:8fdf9a60065b | 187 | |
kadonotakashi | 0:8fdf9a60065b | 188 | /*! @}*/ |
kadonotakashi | 0:8fdf9a60065b | 189 | |
kadonotakashi | 0:8fdf9a60065b | 190 | #endif /* _FSL_LPUART_EDMA_H_ */ |