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.

Committer:
mbed_official
Date:
Thu Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/uart/fsl_uart_hal_fifo_configurations.c@146:f64d43ff0c18
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #include "fsl_uart_hal.h"
mbed_official 146:f64d43ff0c18 31
mbed_official 146:f64d43ff0c18 32 /*******************************************************************************
mbed_official 146:f64d43ff0c18 33 * Definitions
mbed_official 146:f64d43ff0c18 34 ******************************************************************************/
mbed_official 146:f64d43ff0c18 35
mbed_official 146:f64d43ff0c18 36 /*******************************************************************************
mbed_official 146:f64d43ff0c18 37 * Code
mbed_official 146:f64d43ff0c18 38 ******************************************************************************/
mbed_official 146:f64d43ff0c18 39
mbed_official 146:f64d43ff0c18 40 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 146:f64d43ff0c18 41 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 42 *
mbed_official 146:f64d43ff0c18 43 * Function Name : uart_hal_enable_tx_fifo
mbed_official 146:f64d43ff0c18 44 * Description : Enable the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 45 * This function allows the user to enable the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 46 * It is required that the transmitter/receiver should be disabled before calling this function
mbed_official 146:f64d43ff0c18 47 * and when the FIFO is empty.
mbed_official 146:f64d43ff0c18 48 * Additionally, TXFLUSH and RXFLUSH commands should be issued after calling this function.
mbed_official 146:f64d43ff0c18 49 *
mbed_official 146:f64d43ff0c18 50 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 51 uart_status_t uart_hal_enable_tx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 52 {
mbed_official 146:f64d43ff0c18 53 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 54
mbed_official 146:f64d43ff0c18 55 /* before enabling the tx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 146:f64d43ff0c18 56 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 57 * if not, return an error code
mbed_official 146:f64d43ff0c18 58 */
mbed_official 146:f64d43ff0c18 59 uint8_t txEnable = HW_UART_C2(uartInstance).B.TE;
mbed_official 146:f64d43ff0c18 60 uint8_t rxEnable = HW_UART_C2(uartInstance).B.RE;
mbed_official 146:f64d43ff0c18 61
mbed_official 146:f64d43ff0c18 62 if (txEnable || rxEnable)
mbed_official 146:f64d43ff0c18 63 {
mbed_official 146:f64d43ff0c18 64 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 146:f64d43ff0c18 65 }
mbed_official 146:f64d43ff0c18 66 else
mbed_official 146:f64d43ff0c18 67 {
mbed_official 146:f64d43ff0c18 68 /* Set TXFE*/
mbed_official 146:f64d43ff0c18 69 HW_UART_PFIFO_SET(uartInstance, BM_UART_PFIFO_TXFE);
mbed_official 146:f64d43ff0c18 70 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 71 }
mbed_official 146:f64d43ff0c18 72 }
mbed_official 146:f64d43ff0c18 73
mbed_official 146:f64d43ff0c18 74 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 75 *
mbed_official 146:f64d43ff0c18 76 * Function Name : uart_hal_disable_tx_fifo
mbed_official 146:f64d43ff0c18 77 * Description : Disable the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 78 * This function allows the user to disable the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 79 * It is required that the transmitter/receiver should be disabled before calling this function
mbed_official 146:f64d43ff0c18 80 * and when the FIFO is empty.
mbed_official 146:f64d43ff0c18 81 * Additionally, TXFLUSH and RXFLUSH commands should be issued after calling this function.
mbed_official 146:f64d43ff0c18 82 *
mbed_official 146:f64d43ff0c18 83 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 84 uart_status_t uart_hal_disable_tx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 85 {
mbed_official 146:f64d43ff0c18 86 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 87
mbed_official 146:f64d43ff0c18 88 /* before enabling the tx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 146:f64d43ff0c18 89 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 90 * if not, return an error code
mbed_official 146:f64d43ff0c18 91 */
mbed_official 146:f64d43ff0c18 92 uint8_t txEnable = HW_UART_C2(uartInstance).B.TE;
mbed_official 146:f64d43ff0c18 93 uint8_t rxEnable = HW_UART_C2(uartInstance).B.RE;
mbed_official 146:f64d43ff0c18 94
mbed_official 146:f64d43ff0c18 95 if (txEnable || rxEnable)
mbed_official 146:f64d43ff0c18 96 {
mbed_official 146:f64d43ff0c18 97 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 146:f64d43ff0c18 98 }
mbed_official 146:f64d43ff0c18 99 else
mbed_official 146:f64d43ff0c18 100 {
mbed_official 146:f64d43ff0c18 101 /* Clear TXFE*/
mbed_official 146:f64d43ff0c18 102 HW_UART_PFIFO_CLR(uartInstance, BM_UART_PFIFO_TXFE);
mbed_official 146:f64d43ff0c18 103 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 104 }
mbed_official 146:f64d43ff0c18 105 }
mbed_official 146:f64d43ff0c18 106
mbed_official 146:f64d43ff0c18 107 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 108 *
mbed_official 146:f64d43ff0c18 109 * Function Name : uart_hal_enable_rx_fifo
mbed_official 146:f64d43ff0c18 110 * Description : Enable the UART receive FIFO.
mbed_official 146:f64d43ff0c18 111 * This function allows the user to enable the UART receive FIFO.
mbed_official 146:f64d43ff0c18 112 * It is required that the transmitter/receiver should be disabled before calling this function
mbed_official 146:f64d43ff0c18 113 * and when the FIFO is empty.
mbed_official 146:f64d43ff0c18 114 * Additionally, TXFLUSH and RXFLUSH commands should be issued after calling this function.
mbed_official 146:f64d43ff0c18 115 *
mbed_official 146:f64d43ff0c18 116 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 117 uart_status_t uart_hal_enable_rx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 118 {
mbed_official 146:f64d43ff0c18 119 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 120
mbed_official 146:f64d43ff0c18 121 /* before enabling the rx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 146:f64d43ff0c18 122 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 123 * if not, return an error code
mbed_official 146:f64d43ff0c18 124 */
mbed_official 146:f64d43ff0c18 125 uint8_t txEnable = HW_UART_C2(uartInstance).B.TE;
mbed_official 146:f64d43ff0c18 126 uint8_t rxEnable = HW_UART_C2(uartInstance).B.RE;
mbed_official 146:f64d43ff0c18 127
mbed_official 146:f64d43ff0c18 128 if (txEnable || rxEnable)
mbed_official 146:f64d43ff0c18 129 {
mbed_official 146:f64d43ff0c18 130 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 146:f64d43ff0c18 131 }
mbed_official 146:f64d43ff0c18 132 else
mbed_official 146:f64d43ff0c18 133 {
mbed_official 146:f64d43ff0c18 134 /* Set RXFE*/
mbed_official 146:f64d43ff0c18 135 HW_UART_PFIFO_SET(uartInstance, BM_UART_PFIFO_RXFE);
mbed_official 146:f64d43ff0c18 136 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 137 }
mbed_official 146:f64d43ff0c18 138 }
mbed_official 146:f64d43ff0c18 139
mbed_official 146:f64d43ff0c18 140 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 141 *
mbed_official 146:f64d43ff0c18 142 * Function Name : uart_hal_disable_rx_fifo
mbed_official 146:f64d43ff0c18 143 * Description : Disable the UART receive FIFO.
mbed_official 146:f64d43ff0c18 144 * This function allows the user to disable the UART receive FIFO.
mbed_official 146:f64d43ff0c18 145 * It is required that the transmitter/receiver should be disabled before calling this function
mbed_official 146:f64d43ff0c18 146 * and when the FIFO is empty.
mbed_official 146:f64d43ff0c18 147 * Additionally, TXFLUSH and RXFLUSH commands should be issued after calling this function.
mbed_official 146:f64d43ff0c18 148 *
mbed_official 146:f64d43ff0c18 149 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 150 uart_status_t uart_hal_disable_rx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 151 {
mbed_official 146:f64d43ff0c18 152 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 153
mbed_official 146:f64d43ff0c18 154 /* before disabling the rx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 146:f64d43ff0c18 155 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 156 * if not, return an error code
mbed_official 146:f64d43ff0c18 157 */
mbed_official 146:f64d43ff0c18 158 uint8_t txEnable = HW_UART_C2(uartInstance).B.TE;
mbed_official 146:f64d43ff0c18 159 uint8_t rxEnable = HW_UART_C2(uartInstance).B.RE;
mbed_official 146:f64d43ff0c18 160
mbed_official 146:f64d43ff0c18 161 if (txEnable || rxEnable)
mbed_official 146:f64d43ff0c18 162 {
mbed_official 146:f64d43ff0c18 163 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 146:f64d43ff0c18 164 }
mbed_official 146:f64d43ff0c18 165 else
mbed_official 146:f64d43ff0c18 166 {
mbed_official 146:f64d43ff0c18 167 /* Clear RXFE*/
mbed_official 146:f64d43ff0c18 168 HW_UART_PFIFO_CLR(uartInstance, BM_UART_PFIFO_RXFE);
mbed_official 146:f64d43ff0c18 169 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 170 }
mbed_official 146:f64d43ff0c18 171 }
mbed_official 146:f64d43ff0c18 172
mbed_official 146:f64d43ff0c18 173 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 174 *
mbed_official 146:f64d43ff0c18 175 * Function Name : uart_hal_get_tx_fifo_size
mbed_official 146:f64d43ff0c18 176 * Description : Get the size of the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 177 * This function returns the size (number of entries) supported in the UART transmit FIFO for
mbed_official 146:f64d43ff0c18 178 * a particular module instance.
mbed_official 146:f64d43ff0c18 179 *
mbed_official 146:f64d43ff0c18 180 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 181 uint8_t uart_hal_get_tx_fifo_size(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 182 {
mbed_official 146:f64d43ff0c18 183 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 184
mbed_official 146:f64d43ff0c18 185 return HW_UART_PFIFO(uartInstance).B.TXFIFOSIZE;
mbed_official 146:f64d43ff0c18 186 }
mbed_official 146:f64d43ff0c18 187
mbed_official 146:f64d43ff0c18 188 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 189 *
mbed_official 146:f64d43ff0c18 190 * Function Name : uart_hal_get_rx_fifo_size
mbed_official 146:f64d43ff0c18 191 * Description : Get the size of the UART receive FIFO.
mbed_official 146:f64d43ff0c18 192 * This function returns the size (number of entries) supported in the UART receive FIFO for
mbed_official 146:f64d43ff0c18 193 * a particular module instance.
mbed_official 146:f64d43ff0c18 194 *
mbed_official 146:f64d43ff0c18 195 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 196 uint8_t uart_hal_get_rx_fifo_size(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 197 {
mbed_official 146:f64d43ff0c18 198 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 199
mbed_official 146:f64d43ff0c18 200 return HW_UART_PFIFO(uartInstance).B.RXFIFOSIZE;
mbed_official 146:f64d43ff0c18 201 }
mbed_official 146:f64d43ff0c18 202
mbed_official 146:f64d43ff0c18 203 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 204 *
mbed_official 146:f64d43ff0c18 205 * Function Name : uart_hal_flush_tx_fifo
mbed_official 146:f64d43ff0c18 206 * Description : Flush the UART transmit FIFO.
mbed_official 146:f64d43ff0c18 207 * This function allows you to flush the UART transmit FIFO for a particular module instance.
mbed_official 146:f64d43ff0c18 208 * Flushing the FIFO may result in data loss.
mbed_official 146:f64d43ff0c18 209 * It is recommended that the transmitter should be disabled before calling this function.
mbed_official 146:f64d43ff0c18 210 *
mbed_official 146:f64d43ff0c18 211 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 212 uart_status_t uart_hal_flush_tx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 213 {
mbed_official 146:f64d43ff0c18 214 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 215
mbed_official 146:f64d43ff0c18 216 /* in order to flush the tx fifo, UARTx_C2[TE] (transmitter) must be disabled
mbed_official 146:f64d43ff0c18 217 * if not, return an error code
mbed_official 146:f64d43ff0c18 218 */
mbed_official 146:f64d43ff0c18 219 if (HW_UART_C2(uartInstance).B.TE != 0)
mbed_official 146:f64d43ff0c18 220 {
mbed_official 146:f64d43ff0c18 221 return kStatus_UART_TxNotDisabled;
mbed_official 146:f64d43ff0c18 222 }
mbed_official 146:f64d43ff0c18 223 else
mbed_official 146:f64d43ff0c18 224 {
mbed_official 146:f64d43ff0c18 225 /* Set the bit to flush fifo*/
mbed_official 146:f64d43ff0c18 226 HW_UART_CFIFO_SET(uartInstance, BM_UART_CFIFO_TXFLUSH);
mbed_official 146:f64d43ff0c18 227 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 228 }
mbed_official 146:f64d43ff0c18 229 }
mbed_official 146:f64d43ff0c18 230
mbed_official 146:f64d43ff0c18 231 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 232 *
mbed_official 146:f64d43ff0c18 233 * Function Name : uart_hal_flush_rx_fifo
mbed_official 146:f64d43ff0c18 234 * Description : Flush the UART receive FIFO.
mbed_official 146:f64d43ff0c18 235 * This function allows you to flush the UART receive FIFO for a particular module instance.
mbed_official 146:f64d43ff0c18 236 * Flushing the FIFO may result in data loss.
mbed_official 146:f64d43ff0c18 237 * It is recommended that the receiver should be disabled before calling this function.
mbed_official 146:f64d43ff0c18 238 *
mbed_official 146:f64d43ff0c18 239 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 240 uart_status_t uart_hal_flush_rx_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 241 {
mbed_official 146:f64d43ff0c18 242 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 243
mbed_official 146:f64d43ff0c18 244 /* in order to flush the rx fifo, UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 245 * if not, return an error code
mbed_official 146:f64d43ff0c18 246 */
mbed_official 146:f64d43ff0c18 247 if (HW_UART_C2(uartInstance).B.RE != 0)
mbed_official 146:f64d43ff0c18 248 {
mbed_official 146:f64d43ff0c18 249 return kStatus_UART_RxNotDisabled;
mbed_official 146:f64d43ff0c18 250 }
mbed_official 146:f64d43ff0c18 251 else
mbed_official 146:f64d43ff0c18 252 {
mbed_official 146:f64d43ff0c18 253 /* Set the bit to flush fifo*/
mbed_official 146:f64d43ff0c18 254 HW_UART_CFIFO_SET(uartInstance, BM_UART_CFIFO_RXFLUSH);
mbed_official 146:f64d43ff0c18 255 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 256 }
mbed_official 146:f64d43ff0c18 257 }
mbed_official 146:f64d43ff0c18 258
mbed_official 146:f64d43ff0c18 259 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 260 *
mbed_official 146:f64d43ff0c18 261 * Function Name : uart_hal_enable_tx_fifo_overflow_interrupt
mbed_official 146:f64d43ff0c18 262 * Description : Enable the UART transmit FIFO overflow interrupt.
mbed_official 146:f64d43ff0c18 263 *
mbed_official 146:f64d43ff0c18 264 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 265 void uart_hal_enable_tx_fifo_overflow_interrupt(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 266 {
mbed_official 146:f64d43ff0c18 267 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 268
mbed_official 146:f64d43ff0c18 269 /* Set to enable*/
mbed_official 146:f64d43ff0c18 270 HW_UART_CFIFO_SET(uartInstance, BM_UART_CFIFO_TXOFE);
mbed_official 146:f64d43ff0c18 271 }
mbed_official 146:f64d43ff0c18 272
mbed_official 146:f64d43ff0c18 273 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 274 *
mbed_official 146:f64d43ff0c18 275 * Function Name : uart_hal_disable_tx_fifo_overflow_interrupt
mbed_official 146:f64d43ff0c18 276 * Description : Disable the UART transmit FIFO overflow interrupt.
mbed_official 146:f64d43ff0c18 277 *
mbed_official 146:f64d43ff0c18 278 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 279 void uart_hal_disable_tx_fifo_overflow_interrupt(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 280 {
mbed_official 146:f64d43ff0c18 281 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 282
mbed_official 146:f64d43ff0c18 283 /* Clear to disable*/
mbed_official 146:f64d43ff0c18 284 HW_UART_CFIFO_CLR(uartInstance, BM_UART_CFIFO_TXOFE);
mbed_official 146:f64d43ff0c18 285 }
mbed_official 146:f64d43ff0c18 286
mbed_official 146:f64d43ff0c18 287 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 288 *
mbed_official 146:f64d43ff0c18 289 * Function Name : uart_hal_is_tx_fifo_overflow_interrupt_enabled
mbed_official 146:f64d43ff0c18 290 * Description : Get the configuration of the UART transmit FIFO overflow interrupt enable.
mbed_official 146:f64d43ff0c18 291 *
mbed_official 146:f64d43ff0c18 292 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 293 bool uart_hal_is_tx_fifo_overflow_interrupt_enabled(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 294 {
mbed_official 146:f64d43ff0c18 295 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 296
mbed_official 146:f64d43ff0c18 297 return HW_UART_CFIFO(uartInstance).B.TXOFE;
mbed_official 146:f64d43ff0c18 298 }
mbed_official 146:f64d43ff0c18 299
mbed_official 146:f64d43ff0c18 300 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 301 *
mbed_official 146:f64d43ff0c18 302 * Function Name : uart_hal_enable_rx_fifo_underflow_interrupt
mbed_official 146:f64d43ff0c18 303 * Description : Enable the UART receive FIFO underflow interrupt.
mbed_official 146:f64d43ff0c18 304 *
mbed_official 146:f64d43ff0c18 305 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 306 void uart_hal_enable_rx_fifo_underflow_interrupt(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 307 {
mbed_official 146:f64d43ff0c18 308 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 309
mbed_official 146:f64d43ff0c18 310 /* Set to enable*/
mbed_official 146:f64d43ff0c18 311 HW_UART_CFIFO_SET(uartInstance, BM_UART_CFIFO_RXUFE);
mbed_official 146:f64d43ff0c18 312 }
mbed_official 146:f64d43ff0c18 313
mbed_official 146:f64d43ff0c18 314 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 315 *
mbed_official 146:f64d43ff0c18 316 * Function Name : uart_hal_disable_rx_fifo_underflow_interrupt
mbed_official 146:f64d43ff0c18 317 * Description : Disable the UART receive FIFO underflow interrupt.
mbed_official 146:f64d43ff0c18 318 *
mbed_official 146:f64d43ff0c18 319 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 320 void uart_hal_disable_rx_fifo_underflow_interrupt(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 321 {
mbed_official 146:f64d43ff0c18 322 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 323
mbed_official 146:f64d43ff0c18 324 /* Clear to disable*/
mbed_official 146:f64d43ff0c18 325 HW_UART_CFIFO_CLR(uartInstance, BM_UART_CFIFO_RXUFE);
mbed_official 146:f64d43ff0c18 326 }
mbed_official 146:f64d43ff0c18 327
mbed_official 146:f64d43ff0c18 328 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 329 *
mbed_official 146:f64d43ff0c18 330 * Function Name : uart_hal_is_rx_fifo_underflow_interrupt_enabled
mbed_official 146:f64d43ff0c18 331 * Description : Get the configuration of the UART receive FIFO underflow interrupt enable.
mbed_official 146:f64d43ff0c18 332 *
mbed_official 146:f64d43ff0c18 333 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 334 bool uart_hal_is_rx_fifo_underflow_interrupt_enabled(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 335 {
mbed_official 146:f64d43ff0c18 336 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 337
mbed_official 146:f64d43ff0c18 338 return HW_UART_CFIFO(uartInstance).B.RXUFE;
mbed_official 146:f64d43ff0c18 339 }
mbed_official 146:f64d43ff0c18 340
mbed_official 146:f64d43ff0c18 341 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 342 *
mbed_official 146:f64d43ff0c18 343 * Function Name : uart_hal_is_tx_fifo_empty
mbed_official 146:f64d43ff0c18 344 * Description : Get the UART transmit FIFO empty status state.
mbed_official 146:f64d43ff0c18 345 * The function returns the state of the transmit FIFO empty status state but does not take into
mbed_official 146:f64d43ff0c18 346 * account data in the shift register.
mbed_official 146:f64d43ff0c18 347 *
mbed_official 146:f64d43ff0c18 348 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 349 bool uart_hal_is_tx_fifo_empty(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 350 {
mbed_official 146:f64d43ff0c18 351 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 352
mbed_official 146:f64d43ff0c18 353 return HW_UART_SFIFO(uartInstance).B.TXEMPT;
mbed_official 146:f64d43ff0c18 354 }
mbed_official 146:f64d43ff0c18 355
mbed_official 146:f64d43ff0c18 356 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 357 *
mbed_official 146:f64d43ff0c18 358 * Function Name : uart_hal_is_rx_fifo_empty
mbed_official 146:f64d43ff0c18 359 * Description : Get the UART transmit FIFO empty status state.
mbed_official 146:f64d43ff0c18 360 * The function returns the state of the receive FIFO empty status state but does not take into
mbed_official 146:f64d43ff0c18 361 * account data in the shift register.
mbed_official 146:f64d43ff0c18 362 *
mbed_official 146:f64d43ff0c18 363 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 364 bool uart_hal_is_rx_fifo_empty(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 365 {
mbed_official 146:f64d43ff0c18 366 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 367
mbed_official 146:f64d43ff0c18 368 return HW_UART_SFIFO(uartInstance).B.RXEMPT;
mbed_official 146:f64d43ff0c18 369 }
mbed_official 146:f64d43ff0c18 370
mbed_official 146:f64d43ff0c18 371 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 372 *
mbed_official 146:f64d43ff0c18 373 * Function Name : uart_hal_is_tx_fifo_overflow
mbed_official 146:f64d43ff0c18 374 * Description : Get the UART transmit FIFO overflow status state.
mbed_official 146:f64d43ff0c18 375 *
mbed_official 146:f64d43ff0c18 376 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 377 bool uart_hal_is_tx_fifo_overflow(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 378 {
mbed_official 146:f64d43ff0c18 379 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 380
mbed_official 146:f64d43ff0c18 381 return HW_UART_SFIFO(uartInstance).B.TXOF;
mbed_official 146:f64d43ff0c18 382 }
mbed_official 146:f64d43ff0c18 383
mbed_official 146:f64d43ff0c18 384 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 385 *
mbed_official 146:f64d43ff0c18 386 * Function Name : uart_hal_clear_tx_fifo_overflow
mbed_official 146:f64d43ff0c18 387 * Description : Clear the UART transmit FIFO overflow status.
mbed_official 146:f64d43ff0c18 388 *
mbed_official 146:f64d43ff0c18 389 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 390 void uart_hal_clear_tx_fifo_overflow(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 391 {
mbed_official 146:f64d43ff0c18 392 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 393
mbed_official 146:f64d43ff0c18 394 /* write one to clear status flag */
mbed_official 146:f64d43ff0c18 395 HW_UART_SFIFO_SET(uartInstance, BM_UART_SFIFO_TXOF);
mbed_official 146:f64d43ff0c18 396 }
mbed_official 146:f64d43ff0c18 397
mbed_official 146:f64d43ff0c18 398 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 399 *
mbed_official 146:f64d43ff0c18 400 * Function Name : uart_hal_is_rx_fifo_underflow
mbed_official 146:f64d43ff0c18 401 * Description : Get the UART receive FIFO underflow status state.
mbed_official 146:f64d43ff0c18 402 *
mbed_official 146:f64d43ff0c18 403 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 404 bool uart_hal_is_rx_fifo_underflow(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 405 {
mbed_official 146:f64d43ff0c18 406 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 407
mbed_official 146:f64d43ff0c18 408 return HW_UART_SFIFO(uartInstance).B.RXUF;
mbed_official 146:f64d43ff0c18 409 }
mbed_official 146:f64d43ff0c18 410
mbed_official 146:f64d43ff0c18 411 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 412 *
mbed_official 146:f64d43ff0c18 413 * Function Name : uart_hal_clear_rx_fifo_underflow
mbed_official 146:f64d43ff0c18 414 * Description : Clear the UART receive FIFO underflow status.
mbed_official 146:f64d43ff0c18 415 *
mbed_official 146:f64d43ff0c18 416 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 417 void uart_hal_clear_rx_fifo_underflow(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 418 {
mbed_official 146:f64d43ff0c18 419 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 420
mbed_official 146:f64d43ff0c18 421 /* write one to clear status flag */
mbed_official 146:f64d43ff0c18 422 HW_UART_SFIFO_SET(uartInstance, BM_UART_SFIFO_RXUF);
mbed_official 146:f64d43ff0c18 423 }
mbed_official 146:f64d43ff0c18 424
mbed_official 146:f64d43ff0c18 425 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 426 *
mbed_official 146:f64d43ff0c18 427 * Function Name : uart_hal_set_tx_fifo_watermark
mbed_official 146:f64d43ff0c18 428 * Description : Set the UART transmit FIFO watermark value.
mbed_official 146:f64d43ff0c18 429 * Programming the transmit watermark should be done when UART the transmitter is disabled
mbed_official 146:f64d43ff0c18 430 * and the value must be set less than the size obtained from uart_hal_get_tx_fifo_size.
mbed_official 146:f64d43ff0c18 431 *
mbed_official 146:f64d43ff0c18 432 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 433 uart_status_t uart_hal_set_tx_fifo_watermark(uint32_t uartInstance, uint8_t watermark)
mbed_official 146:f64d43ff0c18 434 {
mbed_official 146:f64d43ff0c18 435 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 436
mbed_official 146:f64d43ff0c18 437 /* in order to set the tx watermark, UARTx_C2[TE] (transmitter) must be disabled
mbed_official 146:f64d43ff0c18 438 * if not, return an error code
mbed_official 146:f64d43ff0c18 439 */
mbed_official 146:f64d43ff0c18 440 if (HW_UART_C2(uartInstance).B.TE != 0)
mbed_official 146:f64d43ff0c18 441 {
mbed_official 146:f64d43ff0c18 442 return kStatus_UART_TxNotDisabled;
mbed_official 146:f64d43ff0c18 443 }
mbed_official 146:f64d43ff0c18 444 else
mbed_official 146:f64d43ff0c18 445 {
mbed_official 146:f64d43ff0c18 446 /* set watermark
mbed_official 146:f64d43ff0c18 447 * Programming the transmit watermark should be done when the transmitter is disabled
mbed_official 146:f64d43ff0c18 448 * and the value must be set less than the size given in PFIFO[TXFIFOSIZE]
mbed_official 146:f64d43ff0c18 449 */
mbed_official 146:f64d43ff0c18 450 HW_UART_TWFIFO_WR(uartInstance, watermark);
mbed_official 146:f64d43ff0c18 451 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 452 }
mbed_official 146:f64d43ff0c18 453 }
mbed_official 146:f64d43ff0c18 454
mbed_official 146:f64d43ff0c18 455 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 456 *
mbed_official 146:f64d43ff0c18 457 * Function Name : uart_hal_get_tx_fifo_watermark
mbed_official 146:f64d43ff0c18 458 * Description : Get the UART transmit FIFO watermark value.
mbed_official 146:f64d43ff0c18 459 *
mbed_official 146:f64d43ff0c18 460 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 461 uint8_t uart_hal_get_tx_fifo_watermark(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 462 {
mbed_official 146:f64d43ff0c18 463 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 464
mbed_official 146:f64d43ff0c18 465 /* get watermark*/
mbed_official 146:f64d43ff0c18 466 return HW_UART_TWFIFO_RD(uartInstance);
mbed_official 146:f64d43ff0c18 467 }
mbed_official 146:f64d43ff0c18 468
mbed_official 146:f64d43ff0c18 469 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 470 *
mbed_official 146:f64d43ff0c18 471 * Function Name : uart_hal_get_tx_dataword_count_in_fifo
mbed_official 146:f64d43ff0c18 472 * Description : Get the UART transmit FIFO data word count (number of words in the
mbed_official 146:f64d43ff0c18 473 * transmit FIFO).
mbed_official 146:f64d43ff0c18 474 * The function uart_hal_get_tx_dataword_count_in_fifo excludes any data that may
mbed_official 146:f64d43ff0c18 475 * be in the UART transmit shift register
mbed_official 146:f64d43ff0c18 476 *
mbed_official 146:f64d43ff0c18 477 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 478 uint8_t uart_hal_get_tx_dataword_count_in_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 479 {
mbed_official 146:f64d43ff0c18 480 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 481
mbed_official 146:f64d43ff0c18 482 /* get the current nmber of datawords in the FIFO*/
mbed_official 146:f64d43ff0c18 483 return HW_UART_TCFIFO_RD(uartInstance);
mbed_official 146:f64d43ff0c18 484 }
mbed_official 146:f64d43ff0c18 485
mbed_official 146:f64d43ff0c18 486 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 487 *
mbed_official 146:f64d43ff0c18 488 * Function Name : uart_hal_set_rx_fifo_watermark
mbed_official 146:f64d43ff0c18 489 * Description : Set the UART receive FIFO watermark value.
mbed_official 146:f64d43ff0c18 490 * Programming the receive watermark should be done when the receiver is disabled
mbed_official 146:f64d43ff0c18 491 * and the value must be set less than the size obtained from uart_hal_get_rx_fifo_size and
mbed_official 146:f64d43ff0c18 492 * greater than zero.
mbed_official 146:f64d43ff0c18 493 *
mbed_official 146:f64d43ff0c18 494 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 495 uart_status_t uart_hal_set_rx_fifo_watermark(uint32_t uartInstance, uint8_t watermark)
mbed_official 146:f64d43ff0c18 496 {
mbed_official 146:f64d43ff0c18 497 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 498
mbed_official 146:f64d43ff0c18 499 /* in order to set the rx watermark, UARTx_C2[RE] (receiver) must be disabled
mbed_official 146:f64d43ff0c18 500 * if not, return an error code
mbed_official 146:f64d43ff0c18 501 */
mbed_official 146:f64d43ff0c18 502 if (HW_UART_C2(uartInstance).B.RE != 0)
mbed_official 146:f64d43ff0c18 503 {
mbed_official 146:f64d43ff0c18 504 return kStatus_UART_RxNotDisabled;
mbed_official 146:f64d43ff0c18 505 }
mbed_official 146:f64d43ff0c18 506 else
mbed_official 146:f64d43ff0c18 507 {
mbed_official 146:f64d43ff0c18 508 /* set watermark
mbed_official 146:f64d43ff0c18 509 * Programming the receive watermark should be done when the receiver is disabled
mbed_official 146:f64d43ff0c18 510 * and the value must be set less than the size given in PFIFO[RXFIFOSIZE]
mbed_official 146:f64d43ff0c18 511 * and greater than zero.
mbed_official 146:f64d43ff0c18 512 */
mbed_official 146:f64d43ff0c18 513 HW_UART_RWFIFO_WR(uartInstance, watermark);
mbed_official 146:f64d43ff0c18 514 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 515 }
mbed_official 146:f64d43ff0c18 516 }
mbed_official 146:f64d43ff0c18 517
mbed_official 146:f64d43ff0c18 518 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 519 *
mbed_official 146:f64d43ff0c18 520 * Function Name : uart_hal_get_rx_fifo_watermark
mbed_official 146:f64d43ff0c18 521 * Description : Get the UART receive FIFO data word count (number of words in the receive FIFO).
mbed_official 146:f64d43ff0c18 522 * The function uart_hal_get_rx_dataword_count_in_fifo excludes any data that may be
mbed_official 146:f64d43ff0c18 523 * in the receive shift register.
mbed_official 146:f64d43ff0c18 524 *
mbed_official 146:f64d43ff0c18 525 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 526 uint8_t uart_hal_get_rx_fifo_watermark(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 527 {
mbed_official 146:f64d43ff0c18 528 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 529
mbed_official 146:f64d43ff0c18 530 /* get watermark*/
mbed_official 146:f64d43ff0c18 531 return HW_UART_RWFIFO_RD(uartInstance);
mbed_official 146:f64d43ff0c18 532 }
mbed_official 146:f64d43ff0c18 533
mbed_official 146:f64d43ff0c18 534 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 535 *
mbed_official 146:f64d43ff0c18 536 * Function Name : uart_hal_get_rx_dataword_count_in_fifo
mbed_official 146:f64d43ff0c18 537 * Description : Get the UART receive FIFO watermark value.
mbed_official 146:f64d43ff0c18 538 *
mbed_official 146:f64d43ff0c18 539 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 540 uint8_t uart_hal_get_rx_dataword_count_in_fifo(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 541 {
mbed_official 146:f64d43ff0c18 542 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 543
mbed_official 146:f64d43ff0c18 544 /* get the current nmber of datawords in the FIFO*/
mbed_official 146:f64d43ff0c18 545 return HW_UART_RCFIFO_RD(uartInstance);
mbed_official 146:f64d43ff0c18 546 }
mbed_official 146:f64d43ff0c18 547 #endif /* FSL_FEATURE_UART_HAS_FIFO*/
mbed_official 146:f64d43ff0c18 548
mbed_official 146:f64d43ff0c18 549 /*******************************************************************************
mbed_official 146:f64d43ff0c18 550 * EOF
mbed_official 146:f64d43ff0c18 551 ******************************************************************************/
mbed_official 146:f64d43ff0c18 552