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 Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 324:406fd2029f23 1 /*
mbed_official 324:406fd2029f23 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 324:406fd2029f23 3 * All rights reserved.
mbed_official 324:406fd2029f23 4 *
mbed_official 324:406fd2029f23 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 324:406fd2029f23 6 * are permitted provided that the following conditions are met:
mbed_official 324:406fd2029f23 7 *
mbed_official 324:406fd2029f23 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 324:406fd2029f23 9 * of conditions and the following disclaimer.
mbed_official 324:406fd2029f23 10 *
mbed_official 324:406fd2029f23 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 324:406fd2029f23 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 324:406fd2029f23 13 * other materials provided with the distribution.
mbed_official 324:406fd2029f23 14 *
mbed_official 324:406fd2029f23 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 324:406fd2029f23 16 * contributors may be used to endorse or promote products derived from this
mbed_official 324:406fd2029f23 17 * software without specific prior written permission.
mbed_official 324:406fd2029f23 18 *
mbed_official 324:406fd2029f23 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 324:406fd2029f23 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 324:406fd2029f23 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 324:406fd2029f23 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 324:406fd2029f23 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 324:406fd2029f23 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 324:406fd2029f23 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 324:406fd2029f23 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 324:406fd2029f23 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 324:406fd2029f23 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 324:406fd2029f23 29 */
mbed_official 324:406fd2029f23 30 #include "fsl_uart_hal.h"
mbed_official 324:406fd2029f23 31
mbed_official 324:406fd2029f23 32 /*******************************************************************************
mbed_official 324:406fd2029f23 33 * Code
mbed_official 324:406fd2029f23 34 ******************************************************************************/
mbed_official 324:406fd2029f23 35 /*******************************************************************************
mbed_official 324:406fd2029f23 36 * UART Common Configurations
mbed_official 324:406fd2029f23 37 ******************************************************************************/
mbed_official 324:406fd2029f23 38 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 39 *
mbed_official 324:406fd2029f23 40 * Function Name : UART_HAL_Init
mbed_official 324:406fd2029f23 41 * Description : This function initializes the module to a known state.
mbed_official 324:406fd2029f23 42 *
mbed_official 324:406fd2029f23 43 *END**************************************************************************/
mbed_official 324:406fd2029f23 44 void UART_HAL_Init(uint32_t baseAddr)
mbed_official 324:406fd2029f23 45 {
mbed_official 324:406fd2029f23 46 HW_UART_BDH_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 47 HW_UART_BDL_WR(baseAddr, 4U);
mbed_official 324:406fd2029f23 48 HW_UART_C1_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 49 HW_UART_C2_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 50 HW_UART_S2_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 51 HW_UART_C3_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 52 HW_UART_D_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 53 #if FSL_FEATURE_UART_HAS_ADDRESS_MATCHING
mbed_official 324:406fd2029f23 54 HW_UART_MA1_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 55 HW_UART_MA2_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 56 #endif
mbed_official 324:406fd2029f23 57 HW_UART_C4_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 58 #if FSL_FEATURE_UART_HAS_DMA_ENABLE
mbed_official 324:406fd2029f23 59 HW_UART_C5_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 60 #endif
mbed_official 324:406fd2029f23 61 #if FSL_FEATURE_UART_HAS_MODEM_SUPPORT
mbed_official 324:406fd2029f23 62 HW_UART_MODEM_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 63 #endif
mbed_official 324:406fd2029f23 64 #if FSL_FEATURE_UART_HAS_IR_SUPPORT
mbed_official 324:406fd2029f23 65 HW_UART_IR_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 66 #endif
mbed_official 324:406fd2029f23 67 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 68 HW_UART_PFIFO_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 69 HW_UART_CFIFO_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 70 HW_UART_SFIFO_WR(baseAddr, 0xC0U);
mbed_official 324:406fd2029f23 71 HW_UART_TWFIFO_WR(baseAddr, 0U);
mbed_official 324:406fd2029f23 72 HW_UART_RWFIFO_WR(baseAddr, 1U);
mbed_official 324:406fd2029f23 73 #endif
mbed_official 324:406fd2029f23 74 }
mbed_official 324:406fd2029f23 75
mbed_official 324:406fd2029f23 76 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 77 *
mbed_official 324:406fd2029f23 78 * Function Name : UART_HAL_SetBaudRate
mbed_official 324:406fd2029f23 79 * Description : Configure the UART baud rate.
mbed_official 324:406fd2029f23 80 * This function programs the UART baud rate to the desired value passed in by the
mbed_official 324:406fd2029f23 81 * user. The user must also pass in the module source clock so that the function can
mbed_official 324:406fd2029f23 82 * calculate the baud rate divisors to their appropriate values.
mbed_official 324:406fd2029f23 83 *
mbed_official 324:406fd2029f23 84 *END**************************************************************************/
mbed_official 324:406fd2029f23 85 uart_status_t UART_HAL_SetBaudRate(uint32_t baseAddr, uint32_t sourceClockInHz, uint32_t baudRate)
mbed_official 324:406fd2029f23 86 {
mbed_official 324:406fd2029f23 87 /* BaudRate = (SourceClkInHz)/[16 * (SBR + BRFA)]
mbed_official 324:406fd2029f23 88 * First, calculate SBR (integer part) then calculate the BRFA (fine adjust fractional field). */
mbed_official 324:406fd2029f23 89 uint16_t brfa, sbr;
mbed_official 324:406fd2029f23 90
mbed_official 324:406fd2029f23 91 /* calculate the baud rate modulo divisor, sbr*/
mbed_official 324:406fd2029f23 92 sbr = sourceClockInHz / (baudRate * 16);
mbed_official 324:406fd2029f23 93
mbed_official 324:406fd2029f23 94 /* check to see if sbr is out of range of register bits */
mbed_official 324:406fd2029f23 95 if ( (sbr > 0x1FFF) || (sbr < 1) )
mbed_official 324:406fd2029f23 96 {
mbed_official 324:406fd2029f23 97 /* unsupported baud rate for given source clock input*/
mbed_official 324:406fd2029f23 98 return kStatus_UART_BaudRateCalculationError;
mbed_official 324:406fd2029f23 99 }
mbed_official 324:406fd2029f23 100
mbed_official 324:406fd2029f23 101 /* write the sbr value to the BDH and BDL registers*/
mbed_official 324:406fd2029f23 102 BW_UART_BDH_SBR(baseAddr, (uint8_t)(sbr >> 8));
mbed_official 324:406fd2029f23 103 BW_UART_BDL_SBR(baseAddr, (uint8_t)sbr);
mbed_official 324:406fd2029f23 104
mbed_official 324:406fd2029f23 105 #if FSL_FEATURE_UART_HAS_BAUD_RATE_FINE_ADJUST_SUPPORT
mbed_official 324:406fd2029f23 106 /* determine if a fractional divider is needed to fine tune closer to the desired baud
mbed_official 324:406fd2029f23 107 * each value of brfa is in 1/32 increments, hence the multiply-by-32. */
mbed_official 324:406fd2029f23 108 brfa = (32*sourceClockInHz/(baudRate*16)) - 32*sbr;
mbed_official 324:406fd2029f23 109
mbed_official 324:406fd2029f23 110 /* write the brfa value to the register*/
mbed_official 324:406fd2029f23 111 BW_UART_C4_BRFA(baseAddr, brfa);
mbed_official 324:406fd2029f23 112 #endif
mbed_official 324:406fd2029f23 113
mbed_official 324:406fd2029f23 114 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 115 }
mbed_official 324:406fd2029f23 116
mbed_official 324:406fd2029f23 117 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 118 *
mbed_official 324:406fd2029f23 119 * Function Name : UART_HAL_SetBaudRateDivisor
mbed_official 324:406fd2029f23 120 * Description : Set the UART baud rate modulo divisor value.
mbed_official 324:406fd2029f23 121 * This function allows the user to program the baud rate divisor directly in
mbed_official 324:406fd2029f23 122 * situations where the divisor value is known. In this case, the user may not want to
mbed_official 324:406fd2029f23 123 * call the UART_HAL_SetBaudRate() function as the divisor is already known to them.
mbed_official 324:406fd2029f23 124 *
mbed_official 324:406fd2029f23 125 *END**************************************************************************/
mbed_official 324:406fd2029f23 126 void UART_HAL_SetBaudRateDivisor(uint32_t baseAddr, uint16_t baudRateDivisor)
mbed_official 324:406fd2029f23 127 {
mbed_official 324:406fd2029f23 128 /* check to see if baudRateDivisor is out of range of register bits */
mbed_official 324:406fd2029f23 129 assert( (baudRateDivisor < 0x1FFF) && (baudRateDivisor > 1) );
mbed_official 324:406fd2029f23 130
mbed_official 324:406fd2029f23 131 /* program the sbr (baudRateDivisor) value to the BDH and BDL registers*/
mbed_official 324:406fd2029f23 132 BW_UART_BDH_SBR(baseAddr, (uint8_t)(baudRateDivisor >> 8));
mbed_official 324:406fd2029f23 133 BW_UART_BDL_SBR(baseAddr, (uint8_t)baudRateDivisor);
mbed_official 324:406fd2029f23 134 }
mbed_official 324:406fd2029f23 135
mbed_official 324:406fd2029f23 136 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 137 *
mbed_official 324:406fd2029f23 138 * Function Name : UART_HAL_SetTxRxInversionCmd
mbed_official 324:406fd2029f23 139 * Description : Configure the transmit and receive inversion control in UART
mbed_official 324:406fd2029f23 140 * controller. This function allows the user to invert the transmit and receive
mbed_official 324:406fd2029f23 141 * signals, independently. This function should only be called when the UART is
mbed_official 324:406fd2029f23 142 * between transmit and receive packets.
mbed_official 324:406fd2029f23 143 *
mbed_official 324:406fd2029f23 144 *END**************************************************************************/
mbed_official 324:406fd2029f23 145 void UART_HAL_SetTxRxInversionCmd(uint32_t baseAddr, bool rxInvertEnable, bool txInvertEnable)
mbed_official 324:406fd2029f23 146 {
mbed_official 324:406fd2029f23 147 /* 0 - receive data not inverted, 1 - receive data inverted */
mbed_official 324:406fd2029f23 148 BW_UART_S2_RXINV(baseAddr, (uint8_t)rxInvertEnable);
mbed_official 324:406fd2029f23 149 /* 0 - transmit data not inverted, 1 - transmit data inverted*/
mbed_official 324:406fd2029f23 150 BW_UART_C3_TXINV(baseAddr, (uint8_t)txInvertEnable);
mbed_official 324:406fd2029f23 151 }
mbed_official 324:406fd2029f23 152
mbed_official 324:406fd2029f23 153 /*******************************************************************************
mbed_official 324:406fd2029f23 154 * UART Transfer Functions
mbed_official 324:406fd2029f23 155 ******************************************************************************/
mbed_official 324:406fd2029f23 156 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 157 *
mbed_official 324:406fd2029f23 158 * Function Name : UART_HAL_Putchar
mbed_official 324:406fd2029f23 159 * Description : This function allows the user to send an 8-bit character from the UART
mbed_official 324:406fd2029f23 160 * data register.
mbed_official 324:406fd2029f23 161 *
mbed_official 324:406fd2029f23 162 *END**************************************************************************/
mbed_official 324:406fd2029f23 163 void UART_HAL_Putchar(uint32_t baseAddr, uint8_t data)
mbed_official 324:406fd2029f23 164 {
mbed_official 324:406fd2029f23 165 /* put 8-bit data into the uart data register*/
mbed_official 324:406fd2029f23 166 /* in addition to sending a char, this function also clears the transmit status flags
mbed_official 324:406fd2029f23 167 * for this uart baseAddr, there is a two step process to clear the
mbed_official 324:406fd2029f23 168 * transmit status flags:
mbed_official 324:406fd2029f23 169 * 1. Read the status register with the status bit set
mbed_official 324:406fd2029f23 170 * 2. write to the data register */
mbed_official 324:406fd2029f23 171 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 172 HW_UART_D_WR(baseAddr, data);
mbed_official 324:406fd2029f23 173 }
mbed_official 324:406fd2029f23 174
mbed_official 324:406fd2029f23 175 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 176 *
mbed_official 324:406fd2029f23 177 * Function Name : UART_HAL_Putchar9
mbed_official 324:406fd2029f23 178 * Description : This function allows the user to send a 9-bit character from the UART
mbed_official 324:406fd2029f23 179 * data register.
mbed_official 324:406fd2029f23 180 *
mbed_official 324:406fd2029f23 181 *END**************************************************************************/
mbed_official 324:406fd2029f23 182 void UART_HAL_Putchar9(uint32_t baseAddr, uint16_t data)
mbed_official 324:406fd2029f23 183 {
mbed_official 324:406fd2029f23 184 uint8_t ninthDataBit;
mbed_official 324:406fd2029f23 185
mbed_official 324:406fd2029f23 186 ninthDataBit = (data >> 8U) & 0x1U; /* isolate the ninth data bit*/
mbed_official 324:406fd2029f23 187
mbed_official 324:406fd2029f23 188 /* put 9-bit data to transmit*/
mbed_official 324:406fd2029f23 189 /* first, write to the ninth data bit (bit position T8, where T[0:7]=8-bits, T8=9th bit)*/
mbed_official 324:406fd2029f23 190 BW_UART_C3_T8(baseAddr, ninthDataBit);
mbed_official 324:406fd2029f23 191
mbed_official 324:406fd2029f23 192 /* in addition to sending a char, this function also clears the transmit status flags
mbed_official 324:406fd2029f23 193 * for this uart baseAddr, there is a two step process to clear the
mbed_official 324:406fd2029f23 194 * transmit status flags:
mbed_official 324:406fd2029f23 195 * 1. Read the status register with the status bit set
mbed_official 324:406fd2029f23 196 * 2. write to the data register */
mbed_official 324:406fd2029f23 197 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 198 /* write to the data register last since this will trigger transmit complete status flags
mbed_official 324:406fd2029f23 199 * also typecast to uint8_t to match register type */
mbed_official 324:406fd2029f23 200 HW_UART_D_WR(baseAddr, (uint8_t)data);
mbed_official 324:406fd2029f23 201 }
mbed_official 324:406fd2029f23 202
mbed_official 324:406fd2029f23 203 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 204 *
mbed_official 324:406fd2029f23 205 * Function Name : UART_HAL_Getchar
mbed_official 324:406fd2029f23 206 * Description : This function gets a received 8-bit character from the UART data register.
mbed_official 324:406fd2029f23 207 *
mbed_official 324:406fd2029f23 208 *END**************************************************************************/
mbed_official 324:406fd2029f23 209 void UART_HAL_Getchar(uint32_t baseAddr, uint8_t *readData)
mbed_official 324:406fd2029f23 210 {
mbed_official 324:406fd2029f23 211 /* get 8-bit data from the uart data register*/
mbed_official 324:406fd2029f23 212 /* in addition to getting a char, this function also clears the receive status flag RDRF
mbed_official 324:406fd2029f23 213 * along with IDLE, OR, NF, FE, and PF (these can also be cleared in separate functions)
mbed_official 324:406fd2029f23 214 * for this uart baseAddr, there is a two step process to clear the receive
mbed_official 324:406fd2029f23 215 * status flag:
mbed_official 324:406fd2029f23 216 * 1. Read the status register with the status bit set
mbed_official 324:406fd2029f23 217 * 2. read from the data register */
mbed_official 324:406fd2029f23 218 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 219 /* second, perform a read from the data register */
mbed_official 324:406fd2029f23 220 *readData = HW_UART_D_RD(baseAddr); /* read 8-bit data from data register*/
mbed_official 324:406fd2029f23 221 }
mbed_official 324:406fd2029f23 222
mbed_official 324:406fd2029f23 223 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 224 *
mbed_official 324:406fd2029f23 225 * Function Name : UART_HAL_Getchar9
mbed_official 324:406fd2029f23 226 * Description : This function gets a received 9-bit character from the UART data register.
mbed_official 324:406fd2029f23 227 *
mbed_official 324:406fd2029f23 228 *END**************************************************************************/
mbed_official 324:406fd2029f23 229 void UART_HAL_Getchar9(uint32_t baseAddr, uint16_t *readData)
mbed_official 324:406fd2029f23 230 {
mbed_official 324:406fd2029f23 231 uint16_t temp;
mbed_official 324:406fd2029f23 232
mbed_official 324:406fd2029f23 233 /* get 9-bit data from the uart data register*/
mbed_official 324:406fd2029f23 234 /* read ninth data bit and left shift to bit position R8 before reading
mbed_official 324:406fd2029f23 235 * the 8 other data bits R[7:0]
mbed_official 324:406fd2029f23 236 * *readData = (HW_UART_C3(baseAddr).B.R8) << 8; */
mbed_official 324:406fd2029f23 237 temp = (HW_UART_C3(baseAddr).B.R8);
mbed_official 324:406fd2029f23 238 *readData = temp << 8;
mbed_official 324:406fd2029f23 239
mbed_official 324:406fd2029f23 240 /* in addition to getting a char, this function also clears the receive status flag RDRF
mbed_official 324:406fd2029f23 241 * along with IDLE, OR, NF, FE, and PF (these can also be cleared in separate functions)
mbed_official 324:406fd2029f23 242 * for this uart baseAddr, there is a two step process to clear the receive
mbed_official 324:406fd2029f23 243 * status flag:
mbed_official 324:406fd2029f23 244 * 1. Read the status register with the status bit set
mbed_official 324:406fd2029f23 245 * 2. read from the data register */
mbed_official 324:406fd2029f23 246 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 247 /* do last: get 8-bit data from the uart data register,
mbed_official 324:406fd2029f23 248 * will clear certain receive status bits once completed
mbed_official 324:406fd2029f23 249 * need to OR these 8-bits with the ninth bit value above. */
mbed_official 324:406fd2029f23 250 *readData |= HW_UART_D_RD(baseAddr); /* read 8-bit data from data register*/
mbed_official 324:406fd2029f23 251 }
mbed_official 324:406fd2029f23 252
mbed_official 324:406fd2029f23 253 /*******************************************************************************
mbed_official 324:406fd2029f23 254 * UART Interrupts and DMA
mbed_official 324:406fd2029f23 255 ******************************************************************************/
mbed_official 324:406fd2029f23 256 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 257 *
mbed_official 324:406fd2029f23 258 * Function Name : UART_HAL_ConfigureInterrupts
mbed_official 324:406fd2029f23 259 * Description : Configure the UART module interrupts to enable/disable various
mbed_official 324:406fd2029f23 260 * interrupt sources.
mbed_official 324:406fd2029f23 261 *
mbed_official 324:406fd2029f23 262 *END**************************************************************************/
mbed_official 324:406fd2029f23 263 void UART_HAL_SetIntMode(uint32_t baseAddr, uart_interrupt_t interrupt, bool enable)
mbed_official 324:406fd2029f23 264 {
mbed_official 324:406fd2029f23 265 uint8_t reg = (uint32_t)interrupt >> UART_SHIFT;
mbed_official 324:406fd2029f23 266 uint32_t temp = 1U << (uint8_t)interrupt;
mbed_official 324:406fd2029f23 267
mbed_official 324:406fd2029f23 268 switch ( reg )
mbed_official 324:406fd2029f23 269 {
mbed_official 324:406fd2029f23 270 case 0 :
mbed_official 324:406fd2029f23 271 enable ? HW_UART_BDH_SET(baseAddr, temp) : HW_UART_BDH_CLR(baseAddr, temp);
mbed_official 324:406fd2029f23 272 break;
mbed_official 324:406fd2029f23 273 case 1 :
mbed_official 324:406fd2029f23 274 enable ? HW_UART_C2_SET(baseAddr, temp) : HW_UART_C2_CLR(baseAddr, temp);
mbed_official 324:406fd2029f23 275 break;
mbed_official 324:406fd2029f23 276 case 2 :
mbed_official 324:406fd2029f23 277 enable ? HW_UART_C3_SET(baseAddr, temp) : HW_UART_C3_CLR(baseAddr, temp);
mbed_official 324:406fd2029f23 278 break;
mbed_official 324:406fd2029f23 279 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 280 case 3 :
mbed_official 324:406fd2029f23 281 enable ? HW_UART_CFIFO_SET(baseAddr, temp) : HW_UART_CFIFO_CLR(baseAddr, temp);
mbed_official 324:406fd2029f23 282 break;
mbed_official 324:406fd2029f23 283 #endif
mbed_official 324:406fd2029f23 284 default :
mbed_official 324:406fd2029f23 285 break;
mbed_official 324:406fd2029f23 286 }
mbed_official 324:406fd2029f23 287 }
mbed_official 324:406fd2029f23 288
mbed_official 324:406fd2029f23 289 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 290 *
mbed_official 324:406fd2029f23 291 * Function Name : UART_HAL_GetIntMode
mbed_official 324:406fd2029f23 292 * Description : Return whether the UART module interrupts is enabled/disabled.
mbed_official 324:406fd2029f23 293 *
mbed_official 324:406fd2029f23 294 *END**************************************************************************/
mbed_official 324:406fd2029f23 295 bool UART_HAL_GetIntMode(uint32_t baseAddr, uart_interrupt_t interrupt)
mbed_official 324:406fd2029f23 296 {
mbed_official 324:406fd2029f23 297 uint8_t reg = (uint32_t)interrupt >> UART_SHIFT;
mbed_official 324:406fd2029f23 298 uint8_t temp = 0;
mbed_official 324:406fd2029f23 299
mbed_official 324:406fd2029f23 300 switch ( reg )
mbed_official 324:406fd2029f23 301 {
mbed_official 324:406fd2029f23 302 case 0 :
mbed_official 324:406fd2029f23 303 temp = HW_UART_BDH_RD(baseAddr) >> (uint8_t)(interrupt) & 1U;
mbed_official 324:406fd2029f23 304 break;
mbed_official 324:406fd2029f23 305 case 1 :
mbed_official 324:406fd2029f23 306 temp = HW_UART_C2_RD(baseAddr) >> (uint8_t)(interrupt) & 1U;
mbed_official 324:406fd2029f23 307 break;
mbed_official 324:406fd2029f23 308 case 2 :
mbed_official 324:406fd2029f23 309 temp = HW_UART_C3_RD(baseAddr) >> (uint8_t)(interrupt) & 1U;
mbed_official 324:406fd2029f23 310 break;
mbed_official 324:406fd2029f23 311 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 312 case 3 :
mbed_official 324:406fd2029f23 313 temp = HW_UART_CFIFO_RD(baseAddr) >> (uint8_t)(interrupt) & 1U;
mbed_official 324:406fd2029f23 314 break;
mbed_official 324:406fd2029f23 315 #endif
mbed_official 324:406fd2029f23 316 default :
mbed_official 324:406fd2029f23 317 break;
mbed_official 324:406fd2029f23 318 }
mbed_official 324:406fd2029f23 319 return (bool)temp;
mbed_official 324:406fd2029f23 320 }
mbed_official 324:406fd2029f23 321 #if FSL_FEATURE_UART_HAS_DMA_SELECT
mbed_official 324:406fd2029f23 322 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 323 *
mbed_official 324:406fd2029f23 324 * Function Name : UART_HAL_ConfigureDma
mbed_official 324:406fd2029f23 325 * Description : Configure the UART DMA requests for the Transmitter and Receiver.
mbed_official 324:406fd2029f23 326 * This function allows the user to configure the transmit data register empty flag to
mbed_official 324:406fd2029f23 327 * generate an interrupt request (default) or a DMA request. Similarly, this function
mbed_official 324:406fd2029f23 328 * allows the user to conigure the receive data register full flag to generate an interrupt
mbed_official 324:406fd2029f23 329 * request (default) or a DMA request.
mbed_official 324:406fd2029f23 330 *
mbed_official 324:406fd2029f23 331 *END**************************************************************************/
mbed_official 324:406fd2029f23 332 void UART_HAL_ConfigureDma(uint32_t baseAddr, bool txDmaConfig, bool rxDmaConfig)
mbed_official 324:406fd2029f23 333 {
mbed_official 324:406fd2029f23 334
mbed_official 324:406fd2029f23 335 /* TDMAS configures the transmit data register empty flag, TDRE, to generate interrupt
mbed_official 324:406fd2029f23 336 * or DMA requests if TIE is set.
mbed_official 324:406fd2029f23 337 * NOTE: If UART_C2[TIE] is cleared, TDRE DMA and TDRE interrupt request signals are
mbed_official 324:406fd2029f23 338 * not asserted when the TDRE flag is set, regardless of the state of TDMAS.
mbed_official 324:406fd2029f23 339 * If UART_C2[TIE] and TDMAS are both set, then UART_C2[TCIE] must be cleared, and UART_D
mbed_official 324:406fd2029f23 340 * must not be written outside of servicing of a DMA request.
mbed_official 324:406fd2029f23 341 * 0 If TIE is set and the TDRE flag is set, the TDRE interrupt request signal is asserted
mbed_official 324:406fd2029f23 342 * to request interrupt service.
mbed_official 324:406fd2029f23 343 * 1 If TIE is set and the TDRE flag is set, the TDRE DMA request signal is asserted
mbed_official 324:406fd2029f23 344 * to request a DMA transfer.
mbed_official 324:406fd2029f23 345 */
mbed_official 324:406fd2029f23 346 if (txDmaConfig == 1)
mbed_official 324:406fd2029f23 347 {
mbed_official 324:406fd2029f23 348 /* enable uart to generate transmit DMA request*/
mbed_official 324:406fd2029f23 349 BW_UART_C5_TDMAS(baseAddr, 1U); /* set TDMAS */
mbed_official 324:406fd2029f23 350 BW_UART_C2_TCIE(baseAddr, 0U); /* clear TCIE */
mbed_official 324:406fd2029f23 351 BW_UART_C2_TIE(baseAddr, 1U); /* set TIE */
mbed_official 324:406fd2029f23 352 }
mbed_official 324:406fd2029f23 353 else
mbed_official 324:406fd2029f23 354 {
mbed_official 324:406fd2029f23 355 /* disable uart transmit DMA request*/
mbed_official 324:406fd2029f23 356 BW_UART_C2_TIE(baseAddr, 0U); /* clear TIE to disable */
mbed_official 324:406fd2029f23 357 BW_UART_C5_TDMAS(baseAddr, 0U); /* clear TDMAS to disable */
mbed_official 324:406fd2029f23 358 }
mbed_official 324:406fd2029f23 359
mbed_official 324:406fd2029f23 360 /* RDMAS configures the receiver data register full flag, RDRF, to generate interrupt or
mbed_official 324:406fd2029f23 361 * DMA requests if RIEis set.
mbed_official 324:406fd2029f23 362 * NOTE: If RIE is cleared, the RDRF DMA and RDRF interrupt request signals are not
mbed_official 324:406fd2029f23 363 * asserted when the RDRF flag is set, regardless of the state of RDMAS.
mbed_official 324:406fd2029f23 364 * 0 If RIE is set and the RDRF flag is set, the RDRF interrupt request signal is
mbed_official 324:406fd2029f23 365 * asserted to request interrupt service.
mbed_official 324:406fd2029f23 366 * 1 If RIE is set and the RDRF flag is set, the RDRF DMA request signal is asserted
mbed_official 324:406fd2029f23 367 * to request a DMA transfer.
mbed_official 324:406fd2029f23 368 */
mbed_official 324:406fd2029f23 369 if (rxDmaConfig == 1)
mbed_official 324:406fd2029f23 370 {
mbed_official 324:406fd2029f23 371 /* enable uart to generate receive DMA request*/
mbed_official 324:406fd2029f23 372 BW_UART_C5_RDMAS(baseAddr, 1U); /* set RDMAS */
mbed_official 324:406fd2029f23 373 BW_UART_C2_RIE(baseAddr, 1U); /* set RIE */
mbed_official 324:406fd2029f23 374 }
mbed_official 324:406fd2029f23 375 else
mbed_official 324:406fd2029f23 376 {
mbed_official 324:406fd2029f23 377 /* disable uart receive DMA request*/
mbed_official 324:406fd2029f23 378 BW_UART_C2_RIE(baseAddr, 0U); /* clear RIE to disable */
mbed_official 324:406fd2029f23 379 BW_UART_C5_RDMAS(baseAddr, 0U); /* clear RDMAS to disable */
mbed_official 324:406fd2029f23 380 }
mbed_official 324:406fd2029f23 381 }
mbed_official 324:406fd2029f23 382
mbed_official 324:406fd2029f23 383 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 384 *
mbed_official 324:406fd2029f23 385 * Function Name : UART_HAL_IsTxdmaEnabled
mbed_official 324:406fd2029f23 386 * Description : Get the UART Transmit DMA request configuration setting.
mbed_official 324:406fd2029f23 387 * This function returns to the user the configuration setting of the Transmit DMA request.
mbed_official 324:406fd2029f23 388 *
mbed_official 324:406fd2029f23 389 *END**************************************************************************/
mbed_official 324:406fd2029f23 390 bool UART_HAL_IsTxdmaEnabled(uint32_t baseAddr)
mbed_official 324:406fd2029f23 391 {
mbed_official 324:406fd2029f23 392 /* create variable for this to work around MISRA rule 12.4 since this is a volatile value*/
mbed_official 324:406fd2029f23 393 uint32_t tcieBitStatus;
mbed_official 324:406fd2029f23 394 tcieBitStatus = HW_UART_C2(baseAddr).B.TCIE;
mbed_official 324:406fd2029f23 395
mbed_official 324:406fd2029f23 396 /* TDMAS configures the transmit data register empty flag, TDRE, to generate interrupt or
mbed_official 324:406fd2029f23 397 * DMA requests if TIE is set.
mbed_official 324:406fd2029f23 398 * NOTE: If UART_C2[TIE] is cleared, TDRE DMA and TDRE interrupt request signals are
mbed_official 324:406fd2029f23 399 * not asserted when the TDRE flag is set, regardless of the state of TDMAS.
mbed_official 324:406fd2029f23 400 * If UART_C2[TIE] and TDMAS are both set, then UART_C2[TCIE] must be cleared, and UART_D
mbed_official 324:406fd2029f23 401 * must not be written outside of servicing of a DMA request.
mbed_official 324:406fd2029f23 402 * 0 If TIE is set and the TDRE flag is set, the TDRE interrupt request signal is asserted
mbed_official 324:406fd2029f23 403 * to request interrupt service.
mbed_official 324:406fd2029f23 404 * 1 If TIE is set and the TDRE flag is set, the TDRE DMA request signal is asserted to
mbed_official 324:406fd2029f23 405 * request a DMA transfer.
mbed_official 324:406fd2029f23 406 */
mbed_official 324:406fd2029f23 407 if (BR_UART_C5_TDMAS(baseAddr) == 1)
mbed_official 324:406fd2029f23 408 {
mbed_official 324:406fd2029f23 409 /* in order to enable transmit DMA request, TIE must be set and TCIE must be cleared*/
mbed_official 324:406fd2029f23 410 if ((BR_UART_C2_TIE(baseAddr) == 1) && (tcieBitStatus == 0))
mbed_official 324:406fd2029f23 411 {
mbed_official 324:406fd2029f23 412 /* UART module is configured to generate TxDMA request*/
mbed_official 324:406fd2029f23 413 return 1;
mbed_official 324:406fd2029f23 414 }
mbed_official 324:406fd2029f23 415 else
mbed_official 324:406fd2029f23 416 {
mbed_official 324:406fd2029f23 417 /* UART module is NOT configured to generate TxDMA request*/
mbed_official 324:406fd2029f23 418 return 0;
mbed_official 324:406fd2029f23 419 }
mbed_official 324:406fd2029f23 420 }
mbed_official 324:406fd2029f23 421 else
mbed_official 324:406fd2029f23 422 {
mbed_official 324:406fd2029f23 423 /* UART module is NOT configured to generate TxDMA request*/
mbed_official 324:406fd2029f23 424 return 0;
mbed_official 324:406fd2029f23 425 }
mbed_official 324:406fd2029f23 426 }
mbed_official 324:406fd2029f23 427
mbed_official 324:406fd2029f23 428 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 429 *
mbed_official 324:406fd2029f23 430 * Function Name : UART_HAL_IsRxdmaEnabled
mbed_official 324:406fd2029f23 431 * Description : Get the UART Receive DMA request configuration setting.
mbed_official 324:406fd2029f23 432 * This function returns to the user the configuration setting of the Receive DMA request.
mbed_official 324:406fd2029f23 433 *
mbed_official 324:406fd2029f23 434 *END**************************************************************************/
mbed_official 324:406fd2029f23 435 bool UART_HAL_IsRxdmaEnabled(uint32_t baseAddr)
mbed_official 324:406fd2029f23 436 {
mbed_official 324:406fd2029f23 437 /* RDMAS configures the receiver data register full flag, RDRF, to generate interrupt or
mbed_official 324:406fd2029f23 438 * DMA requests if RIE is set.
mbed_official 324:406fd2029f23 439 * NOTE: If RIE is cleared, the RDRF DMA and RDRF interrupt request signals are not
mbed_official 324:406fd2029f23 440 * asserted when the RDRF flag is set, regardless of the state of RDMAS.
mbed_official 324:406fd2029f23 441 * 0 If RIE is set and the RDRF flag is set, the RDRF interrupt request signal is asserted
mbed_official 324:406fd2029f23 442 * to requestinterrupt service.
mbed_official 324:406fd2029f23 443 * 1 If RIE is set and the RDRF flag is set, the RDRF DMA request signal is asserted to
mbed_official 324:406fd2029f23 444 * request a DMA transfer.
mbed_official 324:406fd2029f23 445 */
mbed_official 324:406fd2029f23 446 if (BR_UART_C5_RDMAS(baseAddr) == 1)
mbed_official 324:406fd2029f23 447 {
mbed_official 324:406fd2029f23 448 /* enable uart to generate receive DMA request*/
mbed_official 324:406fd2029f23 449 if (BR_UART_C2_RIE(baseAddr) == 1)
mbed_official 324:406fd2029f23 450 {
mbed_official 324:406fd2029f23 451 /* UART module is configured to generate RxDMA request*/
mbed_official 324:406fd2029f23 452 return 1;
mbed_official 324:406fd2029f23 453 }
mbed_official 324:406fd2029f23 454 else
mbed_official 324:406fd2029f23 455 {
mbed_official 324:406fd2029f23 456 /* UART module is NOT configured to generate RxDMA request*/
mbed_official 324:406fd2029f23 457 return 0;
mbed_official 324:406fd2029f23 458 }
mbed_official 324:406fd2029f23 459 }
mbed_official 324:406fd2029f23 460 else
mbed_official 324:406fd2029f23 461 {
mbed_official 324:406fd2029f23 462 /* UART module is NOT configured to generate RxDMA request*/
mbed_official 324:406fd2029f23 463 return 0;
mbed_official 324:406fd2029f23 464 }
mbed_official 324:406fd2029f23 465 }
mbed_official 324:406fd2029f23 466 #endif
mbed_official 324:406fd2029f23 467 /*******************************************************************************
mbed_official 324:406fd2029f23 468 * UART UART Status Flags
mbed_official 324:406fd2029f23 469 ******************************************************************************/
mbed_official 324:406fd2029f23 470 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 471 *
mbed_official 324:406fd2029f23 472 * Function Name : UART_HAL_GetStatusFlag
mbed_official 324:406fd2029f23 473 * Description : Get UART status flag states.
mbed_official 324:406fd2029f23 474 *
mbed_official 324:406fd2029f23 475 *END**************************************************************************/
mbed_official 324:406fd2029f23 476 bool UART_HAL_GetStatusFlag(uint32_t baseAddr, uart_status_flag_t statusFlag)
mbed_official 324:406fd2029f23 477 {
mbed_official 324:406fd2029f23 478 uint8_t reg = (uint32_t)statusFlag >> UART_SHIFT;
mbed_official 324:406fd2029f23 479 uint8_t temp = 0;
mbed_official 324:406fd2029f23 480
mbed_official 324:406fd2029f23 481 switch ( reg )
mbed_official 324:406fd2029f23 482 {
mbed_official 324:406fd2029f23 483 case 0 :
mbed_official 324:406fd2029f23 484 temp = HW_UART_S1_RD(baseAddr) >> (uint8_t)(statusFlag) & 1U;
mbed_official 324:406fd2029f23 485 break;
mbed_official 324:406fd2029f23 486 case 1 :
mbed_official 324:406fd2029f23 487 temp = HW_UART_S2_RD(baseAddr) >> (uint8_t)(statusFlag) & 1U;
mbed_official 324:406fd2029f23 488 break;
mbed_official 324:406fd2029f23 489 #if FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS
mbed_official 324:406fd2029f23 490 case 2 :
mbed_official 324:406fd2029f23 491 temp = HW_UART_ED_RD(baseAddr) >> (uint8_t)(statusFlag) & 1U;
mbed_official 324:406fd2029f23 492 break;
mbed_official 324:406fd2029f23 493 #endif
mbed_official 324:406fd2029f23 494 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 495 case 3 :
mbed_official 324:406fd2029f23 496 temp = HW_UART_SFIFO_RD(baseAddr) >> (uint8_t)(statusFlag) & 1U;
mbed_official 324:406fd2029f23 497 break;
mbed_official 324:406fd2029f23 498 #endif
mbed_official 324:406fd2029f23 499 default :
mbed_official 324:406fd2029f23 500 break;
mbed_official 324:406fd2029f23 501 }
mbed_official 324:406fd2029f23 502 return (bool)temp;
mbed_official 324:406fd2029f23 503 }
mbed_official 324:406fd2029f23 504
mbed_official 324:406fd2029f23 505 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 506 *
mbed_official 324:406fd2029f23 507 * Function Name : UART_HAL_ClearStatusFlag
mbed_official 324:406fd2029f23 508 * Description : Clear an individual and specific UART status flag.
mbed_official 324:406fd2029f23 509 * This function allows the user to clear an individual and specific UART status flag. Refer to
mbed_official 324:406fd2029f23 510 * structure definition uart_status_flag_t for list of status bits.
mbed_official 324:406fd2029f23 511 *
mbed_official 324:406fd2029f23 512 *END**************************************************************************/
mbed_official 324:406fd2029f23 513 uart_status_t UART_HAL_ClearStatusFlag(uint32_t baseAddr, uart_status_flag_t statusFlag)
mbed_official 324:406fd2029f23 514 {
mbed_official 324:406fd2029f23 515 uart_status_t returnCode; /* return code variable */
mbed_official 324:406fd2029f23 516 returnCode = kStatus_UART_Success; /* default return code, unless changed by error condition*/
mbed_official 324:406fd2029f23 517
mbed_official 324:406fd2029f23 518 /* clear the desired, individual status flag as passed in through statusFlag */
mbed_official 324:406fd2029f23 519 switch(statusFlag)
mbed_official 324:406fd2029f23 520 {
mbed_official 324:406fd2029f23 521 case kUartTxDataRegEmpty:
mbed_official 324:406fd2029f23 522 /* This flag is cleared automatically by other uart operations and
mbed_official 324:406fd2029f23 523 * cannot be manually cleared, return error code
mbed_official 324:406fd2029f23 524 */
mbed_official 324:406fd2029f23 525 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 526 break;
mbed_official 324:406fd2029f23 527
mbed_official 324:406fd2029f23 528 case kUartTxComplete:
mbed_official 324:406fd2029f23 529 /* This flag is cleared automatically by other uart operations and
mbed_official 324:406fd2029f23 530 * cannot be manually cleared, return error code
mbed_official 324:406fd2029f23 531 */
mbed_official 324:406fd2029f23 532 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 533 break;
mbed_official 324:406fd2029f23 534
mbed_official 324:406fd2029f23 535 case kUartRxDataRegFull:
mbed_official 324:406fd2029f23 536 /* This flag is cleared automatically by other uart operations and
mbed_official 324:406fd2029f23 537 * cannot be manually cleared, return error code
mbed_official 324:406fd2029f23 538 */
mbed_official 324:406fd2029f23 539 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 540 break;
mbed_official 324:406fd2029f23 541
mbed_official 324:406fd2029f23 542 case kUartIdleLineDetect:
mbed_official 324:406fd2029f23 543 /* to clear the status is a two-step process:
mbed_official 324:406fd2029f23 544 * first, read S1 register with the status flag set
mbed_official 324:406fd2029f23 545 */
mbed_official 324:406fd2029f23 546 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 547 /* second, read the data register*/
mbed_official 324:406fd2029f23 548 HW_UART_D_RD(baseAddr);
mbed_official 324:406fd2029f23 549 break;
mbed_official 324:406fd2029f23 550
mbed_official 324:406fd2029f23 551 case kUartRxOverrun:
mbed_official 324:406fd2029f23 552 /* to clear the status is a two-step process:
mbed_official 324:406fd2029f23 553 * first, read S1 register with the status flag set
mbed_official 324:406fd2029f23 554 */
mbed_official 324:406fd2029f23 555 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 556 /* second, read the data register*/
mbed_official 324:406fd2029f23 557 HW_UART_D_RD(baseAddr);
mbed_official 324:406fd2029f23 558 break;
mbed_official 324:406fd2029f23 559
mbed_official 324:406fd2029f23 560 case kUartNoiseDetect:
mbed_official 324:406fd2029f23 561 /* to clear the status is a two-step process:
mbed_official 324:406fd2029f23 562 * first, read S1 register with the status flag set
mbed_official 324:406fd2029f23 563 */
mbed_official 324:406fd2029f23 564 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 565 /* second, read the data register*/
mbed_official 324:406fd2029f23 566 HW_UART_D_RD(baseAddr);
mbed_official 324:406fd2029f23 567 break;
mbed_official 324:406fd2029f23 568
mbed_official 324:406fd2029f23 569 case kUartFrameErr:
mbed_official 324:406fd2029f23 570 /* to clear the status is a two-step process:
mbed_official 324:406fd2029f23 571 * first, read S1 register with the status flag set
mbed_official 324:406fd2029f23 572 */
mbed_official 324:406fd2029f23 573 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 574 /* second, read the data register*/
mbed_official 324:406fd2029f23 575 HW_UART_D_RD(baseAddr);
mbed_official 324:406fd2029f23 576 break;
mbed_official 324:406fd2029f23 577
mbed_official 324:406fd2029f23 578 case kUartParityErr:
mbed_official 324:406fd2029f23 579 /* to clear the status is a two-step process:
mbed_official 324:406fd2029f23 580 * first, read S1 register with the status flag set
mbed_official 324:406fd2029f23 581 */
mbed_official 324:406fd2029f23 582 HW_UART_S1_RD(baseAddr);
mbed_official 324:406fd2029f23 583 /* second, read the data register*/
mbed_official 324:406fd2029f23 584 HW_UART_D_RD(baseAddr);
mbed_official 324:406fd2029f23 585 break;
mbed_official 324:406fd2029f23 586
mbed_official 324:406fd2029f23 587 case kUartLineBreakDetect:
mbed_official 324:406fd2029f23 588 /* write one to clear status flag */
mbed_official 324:406fd2029f23 589 HW_UART_S2_SET(baseAddr, BM_UART_S2_LBKDIF);
mbed_official 324:406fd2029f23 590 break;
mbed_official 324:406fd2029f23 591
mbed_official 324:406fd2029f23 592 case kUartRxActiveEdgeDetect:
mbed_official 324:406fd2029f23 593 /* write one to clear status flag */
mbed_official 324:406fd2029f23 594 HW_UART_S2_SET(baseAddr, BM_UART_S2_RXEDGIF);
mbed_official 324:406fd2029f23 595 break;
mbed_official 324:406fd2029f23 596
mbed_official 324:406fd2029f23 597 case kUartRxActive:
mbed_official 324:406fd2029f23 598 /* This flag is cleared automatically by other uart operations and
mbed_official 324:406fd2029f23 599 * cannot be manually cleared, return error code
mbed_official 324:406fd2029f23 600 */
mbed_official 324:406fd2029f23 601 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 602 break;
mbed_official 324:406fd2029f23 603
mbed_official 324:406fd2029f23 604 #if FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS
mbed_official 324:406fd2029f23 605 case kUartNoiseInCurrentWord:
mbed_official 324:406fd2029f23 606 /* This flag is not clearable, it simply reflects the status in the
mbed_official 324:406fd2029f23 607 * current data word and changes with each new data word
mbed_official 324:406fd2029f23 608 */
mbed_official 324:406fd2029f23 609 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 610 break;
mbed_official 324:406fd2029f23 611
mbed_official 324:406fd2029f23 612 case kUartParityErrInCurrentWord:
mbed_official 324:406fd2029f23 613 /* This flag is not clearable, it simply reflects the status in the
mbed_official 324:406fd2029f23 614 * current data word and changes with each new data word
mbed_official 324:406fd2029f23 615 */
mbed_official 324:406fd2029f23 616 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 617 break;
mbed_official 324:406fd2029f23 618 #endif
mbed_official 324:406fd2029f23 619 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 620 case kUartTxBuffEmpty:
mbed_official 324:406fd2029f23 621 /* This flag is not clearable, it simply reflects the current
mbed_official 324:406fd2029f23 622 * status of the buffer/FIFO
mbed_official 324:406fd2029f23 623 */
mbed_official 324:406fd2029f23 624 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 625 break;
mbed_official 324:406fd2029f23 626
mbed_official 324:406fd2029f23 627 case kUartRxBuffEmpty:
mbed_official 324:406fd2029f23 628 /* This flag is not clearable, it simply reflects the current
mbed_official 324:406fd2029f23 629 * status of the buffer/FIFO
mbed_official 324:406fd2029f23 630 */
mbed_official 324:406fd2029f23 631 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 632 break;
mbed_official 324:406fd2029f23 633
mbed_official 324:406fd2029f23 634 case kUartTxBuffOverflow:
mbed_official 324:406fd2029f23 635 /* write one to clear status flag */
mbed_official 324:406fd2029f23 636 HW_UART_SFIFO_SET(baseAddr, BM_UART_SFIFO_TXOF);
mbed_official 324:406fd2029f23 637 break;
mbed_official 324:406fd2029f23 638
mbed_official 324:406fd2029f23 639 case kUartRxBuffUnderflow:
mbed_official 324:406fd2029f23 640 /* write one to clear status flag */
mbed_official 324:406fd2029f23 641 HW_UART_SFIFO_SET(baseAddr, BM_UART_SFIFO_RXUF);
mbed_official 324:406fd2029f23 642 break;
mbed_official 324:406fd2029f23 643 #endif
mbed_official 324:406fd2029f23 644 default: /* catch inputs that are not recognized*/
mbed_official 324:406fd2029f23 645 returnCode = kStatus_UART_ClearStatusFlagError;
mbed_official 324:406fd2029f23 646 break;
mbed_official 324:406fd2029f23 647 }
mbed_official 324:406fd2029f23 648
mbed_official 324:406fd2029f23 649 return (returnCode);
mbed_official 324:406fd2029f23 650 }
mbed_official 324:406fd2029f23 651
mbed_official 324:406fd2029f23 652 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 653 *
mbed_official 324:406fd2029f23 654 * Function Name : UART_HAL_ClearAllNonAutoclearStatusFlags
mbed_official 324:406fd2029f23 655 * Description : Clear ALL of the UART status flags.
mbed_official 324:406fd2029f23 656 * This function tries to clear all of the UART status flags. In some cases, some of the status
mbed_official 324:406fd2029f23 657 * flags may not get cleared because of the condition that set the flag may still exist.
mbed_official 324:406fd2029f23 658 *
mbed_official 324:406fd2029f23 659 *END**************************************************************************/
mbed_official 324:406fd2029f23 660 void UART_HAL_ClearAllNonAutoclearStatusFlags(uint32_t baseAddr)
mbed_official 324:406fd2029f23 661 {
mbed_official 324:406fd2029f23 662 /* clear the status flags that can be manually cleared
mbed_official 324:406fd2029f23 663 * note, some flags are automatically cleared and cannot be cleared automatically
mbed_official 324:406fd2029f23 664 */
mbed_official 324:406fd2029f23 665 UART_HAL_ClearStatusFlag(baseAddr, kUartIdleLineDetect);
mbed_official 324:406fd2029f23 666 UART_HAL_ClearStatusFlag(baseAddr, kUartRxOverrun);
mbed_official 324:406fd2029f23 667 UART_HAL_ClearStatusFlag(baseAddr, kUartNoiseDetect);
mbed_official 324:406fd2029f23 668 UART_HAL_ClearStatusFlag(baseAddr, kUartFrameErr);
mbed_official 324:406fd2029f23 669 UART_HAL_ClearStatusFlag(baseAddr, kUartParityErr);
mbed_official 324:406fd2029f23 670 UART_HAL_ClearStatusFlag(baseAddr, kUartLineBreakDetect);
mbed_official 324:406fd2029f23 671 UART_HAL_ClearStatusFlag(baseAddr, kUartRxActiveEdgeDetect);
mbed_official 324:406fd2029f23 672 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 673 UART_HAL_ClearStatusFlag(baseAddr, kUartTxBuffOverflow);
mbed_official 324:406fd2029f23 674 UART_HAL_ClearStatusFlag(baseAddr, kUartRxBuffUnderflow);
mbed_official 324:406fd2029f23 675 #endif
mbed_official 324:406fd2029f23 676 }
mbed_official 324:406fd2029f23 677
mbed_official 324:406fd2029f23 678 /*******************************************************************************
mbed_official 324:406fd2029f23 679 * UART FIFO Configurations
mbed_official 324:406fd2029f23 680 ******************************************************************************/
mbed_official 324:406fd2029f23 681 #if FSL_FEATURE_UART_HAS_FIFO
mbed_official 324:406fd2029f23 682 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 683 *
mbed_official 324:406fd2029f23 684 * Function Name : UART_HAL_SetTxFifo
mbed_official 324:406fd2029f23 685 * Description : Enable or disable the UART transmit FIFO.
mbed_official 324:406fd2029f23 686 * This function allows the user to enable or disable the UART transmit FIFO.
mbed_official 324:406fd2029f23 687 * It is required that the transmitter/receiver should be disabled before calling this
mbed_official 324:406fd2029f23 688 * function and when the FIFO is empty. Additionally, TXFLUSH and RXFLUSH commands
mbed_official 324:406fd2029f23 689 * should be issued after calling this function.
mbed_official 324:406fd2029f23 690 *
mbed_official 324:406fd2029f23 691 *END**************************************************************************/
mbed_official 324:406fd2029f23 692 uart_status_t UART_HAL_SetTxFifoCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 693 {
mbed_official 324:406fd2029f23 694 /* before enabling the tx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 324:406fd2029f23 695 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 324:406fd2029f23 696 * if not, return an error code */
mbed_official 324:406fd2029f23 697 uint8_t txEnable = BR_UART_C2_TE(baseAddr);
mbed_official 324:406fd2029f23 698 uint8_t rxEnable = BR_UART_C2_RE(baseAddr);
mbed_official 324:406fd2029f23 699
mbed_official 324:406fd2029f23 700 if (txEnable || rxEnable)
mbed_official 324:406fd2029f23 701 {
mbed_official 324:406fd2029f23 702 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 324:406fd2029f23 703 }
mbed_official 324:406fd2029f23 704 else
mbed_official 324:406fd2029f23 705 {
mbed_official 324:406fd2029f23 706 BW_UART_PFIFO_TXFE(baseAddr, enable);
mbed_official 324:406fd2029f23 707 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 708 }
mbed_official 324:406fd2029f23 709 }
mbed_official 324:406fd2029f23 710
mbed_official 324:406fd2029f23 711 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 712 *
mbed_official 324:406fd2029f23 713 * Function Name : UART_HAL_SetRxFifoCmd
mbed_official 324:406fd2029f23 714 * Description : Enable or disable the UART receive FIFO.
mbed_official 324:406fd2029f23 715 * This function allows the user to enable or disable the UART receive FIFO.
mbed_official 324:406fd2029f23 716 * It is required that the transmitter/receiver should be disabled before calling
mbed_official 324:406fd2029f23 717 * this function and when the FIFO is empty. Additionally, TXFLUSH and RXFLUSH
mbed_official 324:406fd2029f23 718 * commands should be issued after calling this function.
mbed_official 324:406fd2029f23 719 *
mbed_official 324:406fd2029f23 720 *END**************************************************************************/
mbed_official 324:406fd2029f23 721 uart_status_t UART_HAL_SetRxFifoCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 722 {
mbed_official 324:406fd2029f23 723 /* before enabling the rx fifo, UARTx_C2[TE] (transmitter) and
mbed_official 324:406fd2029f23 724 * UARTx_C2[RE] (receiver) must be disabled
mbed_official 324:406fd2029f23 725 * if not, return an error code */
mbed_official 324:406fd2029f23 726 uint8_t txEnable = BR_UART_C2_TE(baseAddr);
mbed_official 324:406fd2029f23 727 uint8_t rxEnable = BR_UART_C2_RE(baseAddr);
mbed_official 324:406fd2029f23 728
mbed_official 324:406fd2029f23 729 if (txEnable || rxEnable)
mbed_official 324:406fd2029f23 730 {
mbed_official 324:406fd2029f23 731 return kStatus_UART_TxOrRxNotDisabled;
mbed_official 324:406fd2029f23 732 }
mbed_official 324:406fd2029f23 733 else
mbed_official 324:406fd2029f23 734 {
mbed_official 324:406fd2029f23 735 BW_UART_PFIFO_RXFE(baseAddr, enable);
mbed_official 324:406fd2029f23 736 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 737 }
mbed_official 324:406fd2029f23 738 }
mbed_official 324:406fd2029f23 739
mbed_official 324:406fd2029f23 740 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 741 *
mbed_official 324:406fd2029f23 742 * Function Name : UART_HAL_FlushTxFifo
mbed_official 324:406fd2029f23 743 * Description : Flush the UART transmit FIFO.
mbed_official 324:406fd2029f23 744 * This function allows you to flush the UART transmit FIFO for a particular modulei
mbed_official 324:406fd2029f23 745 * baseAddr. Flushing the FIFO may result in data loss. It is recommended that the
mbed_official 324:406fd2029f23 746 * transmitter should be disabled before calling this function.
mbed_official 324:406fd2029f23 747 *
mbed_official 324:406fd2029f23 748 *END**************************************************************************/
mbed_official 324:406fd2029f23 749 uart_status_t UART_HAL_FlushTxFifo(uint32_t baseAddr)
mbed_official 324:406fd2029f23 750 {
mbed_official 324:406fd2029f23 751 /* in order to flush the tx fifo, UARTx_C2[TE] (transmitter) must be disabled
mbed_official 324:406fd2029f23 752 * if not, return an error code */
mbed_official 324:406fd2029f23 753 if (BR_UART_C2_TE(baseAddr) != 0)
mbed_official 324:406fd2029f23 754 {
mbed_official 324:406fd2029f23 755 return kStatus_UART_TxNotDisabled;
mbed_official 324:406fd2029f23 756 }
mbed_official 324:406fd2029f23 757 else
mbed_official 324:406fd2029f23 758 {
mbed_official 324:406fd2029f23 759 /* Set the bit to flush fifo*/
mbed_official 324:406fd2029f23 760 BW_UART_CFIFO_TXFLUSH(baseAddr, 1U);
mbed_official 324:406fd2029f23 761 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 762 }
mbed_official 324:406fd2029f23 763 }
mbed_official 324:406fd2029f23 764
mbed_official 324:406fd2029f23 765 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 766 *
mbed_official 324:406fd2029f23 767 * Function Name : UART_HAL_FlushRxFifo
mbed_official 324:406fd2029f23 768 * Description : Flush the UART receive FIFO.
mbed_official 324:406fd2029f23 769 * This function allows you to flush the UART receive FIFO for a particular module
mbed_official 324:406fd2029f23 770 * baseAddr. Flushing the FIFO may result in data loss. It is recommended that the
mbed_official 324:406fd2029f23 771 * receiver should be disabled before calling this function.
mbed_official 324:406fd2029f23 772 *
mbed_official 324:406fd2029f23 773 *END**************************************************************************/
mbed_official 324:406fd2029f23 774 uart_status_t UART_HAL_FlushRxFifo(uint32_t baseAddr)
mbed_official 324:406fd2029f23 775 {
mbed_official 324:406fd2029f23 776 /* in order to flush the rx fifo, UARTx_C2[RE] (receiver) must be disabled
mbed_official 324:406fd2029f23 777 * if not, return an error code. */
mbed_official 324:406fd2029f23 778 if (BR_UART_C2_RE(baseAddr) != 0)
mbed_official 324:406fd2029f23 779 {
mbed_official 324:406fd2029f23 780 return kStatus_UART_RxNotDisabled;
mbed_official 324:406fd2029f23 781 }
mbed_official 324:406fd2029f23 782 else
mbed_official 324:406fd2029f23 783 {
mbed_official 324:406fd2029f23 784 /* Set the bit to flush fifo*/
mbed_official 324:406fd2029f23 785 BW_UART_CFIFO_RXFLUSH(baseAddr, 1U);
mbed_official 324:406fd2029f23 786 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 787 }
mbed_official 324:406fd2029f23 788 }
mbed_official 324:406fd2029f23 789
mbed_official 324:406fd2029f23 790 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 791 *
mbed_official 324:406fd2029f23 792 * Function Name : UART_HAL_SetTxFifoWatermark
mbed_official 324:406fd2029f23 793 * Description : Set the UART transmit FIFO watermark value.
mbed_official 324:406fd2029f23 794 * Programming the transmit watermark should be done when UART the transmitter is
mbed_official 324:406fd2029f23 795 * disabled and the value must be set less than the size obtained from
mbed_official 324:406fd2029f23 796 * UART_HAL_GetTxFifoSize.
mbed_official 324:406fd2029f23 797 *
mbed_official 324:406fd2029f23 798 *END**************************************************************************/
mbed_official 324:406fd2029f23 799 uart_status_t UART_HAL_SetTxFifoWatermark(uint32_t baseAddr, uint8_t watermark)
mbed_official 324:406fd2029f23 800 {
mbed_official 324:406fd2029f23 801 /* in order to set the tx watermark, UARTx_C2[TE] (transmitter) must be disabled
mbed_official 324:406fd2029f23 802 * if not, return an error code
mbed_official 324:406fd2029f23 803 */
mbed_official 324:406fd2029f23 804 if (BR_UART_C2_TE(baseAddr) != 0)
mbed_official 324:406fd2029f23 805 {
mbed_official 324:406fd2029f23 806 return kStatus_UART_TxNotDisabled;
mbed_official 324:406fd2029f23 807 }
mbed_official 324:406fd2029f23 808 else
mbed_official 324:406fd2029f23 809 {
mbed_official 324:406fd2029f23 810 /* Programming the transmit watermark should be done when the transmitter is
mbed_official 324:406fd2029f23 811 * disabled and the value must be set less than the size given in
mbed_official 324:406fd2029f23 812 * PFIFO[TXFIFOSIZE] */
mbed_official 324:406fd2029f23 813 HW_UART_TWFIFO_WR(baseAddr, watermark);
mbed_official 324:406fd2029f23 814 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 815 }
mbed_official 324:406fd2029f23 816 }
mbed_official 324:406fd2029f23 817
mbed_official 324:406fd2029f23 818 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 819 *
mbed_official 324:406fd2029f23 820 * Function Name : UART_HAL_SetRxFifoWatermark
mbed_official 324:406fd2029f23 821 * Description : Set the UART receive FIFO watermark value.
mbed_official 324:406fd2029f23 822 * Programming the receive watermark should be done when the receiver is disabled
mbed_official 324:406fd2029f23 823 * and the value must be set less than the size obtained from UART_HAL_GetRxFifoSize
mbed_official 324:406fd2029f23 824 * and greater than zero.
mbed_official 324:406fd2029f23 825 *
mbed_official 324:406fd2029f23 826 *END**************************************************************************/
mbed_official 324:406fd2029f23 827 uart_status_t UART_HAL_SetRxFifoWatermark(uint32_t baseAddr, uint8_t watermark)
mbed_official 324:406fd2029f23 828 {
mbed_official 324:406fd2029f23 829 /* in order to set the rx watermark, UARTx_C2[RE] (receiver) must be disabled
mbed_official 324:406fd2029f23 830 * if not, return an error code. */
mbed_official 324:406fd2029f23 831 if (BR_UART_C2_RE(baseAddr) != 0)
mbed_official 324:406fd2029f23 832 {
mbed_official 324:406fd2029f23 833 return kStatus_UART_RxNotDisabled;
mbed_official 324:406fd2029f23 834 }
mbed_official 324:406fd2029f23 835 else
mbed_official 324:406fd2029f23 836 {
mbed_official 324:406fd2029f23 837 /* Programming the receive watermark should be done when the receiver is
mbed_official 324:406fd2029f23 838 * disabled and the value must be set less than the size given in
mbed_official 324:406fd2029f23 839 * PFIFO[RXFIFOSIZE] and greater than zero. */
mbed_official 324:406fd2029f23 840 HW_UART_RWFIFO_WR(baseAddr, watermark);
mbed_official 324:406fd2029f23 841 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 842 }
mbed_official 324:406fd2029f23 843 }
mbed_official 324:406fd2029f23 844 #endif /* FSL_FEATURE_UART_HAS_FIFO*/
mbed_official 324:406fd2029f23 845
mbed_official 324:406fd2029f23 846 /*******************************************************************************
mbed_official 324:406fd2029f23 847 * UART Special Feature Configurations
mbed_official 324:406fd2029f23 848 ******************************************************************************/
mbed_official 324:406fd2029f23 849
mbed_official 324:406fd2029f23 850 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 851 *
mbed_official 324:406fd2029f23 852 * Function Name : UART_HAL_PutReceiverInStandbyMode
mbed_official 324:406fd2029f23 853 * Description : Place the UART receiver in standby mode.
mbed_official 324:406fd2029f23 854 * This function, when called, will place the UART receiver into standby mode.
mbed_official 324:406fd2029f23 855 * In some UART baseAddrs, there is a condition that must be met before placing rx in standby mode.
mbed_official 324:406fd2029f23 856 * Before placing UART in standby, you need to first determine if receiver is set to
mbed_official 324:406fd2029f23 857 * wake on idle and if receiver is already in idle state. Per ref manual:
mbed_official 324:406fd2029f23 858 * NOTE: RWU should only be set with C1[WAKE] = 0 (wakeup on idle) if the channel is currently
mbed_official 324:406fd2029f23 859 * not idle.
mbed_official 324:406fd2029f23 860 * This can be determined by the S2[RAF] flag. If set to wake up FROM an IDLE event and the channel
mbed_official 324:406fd2029f23 861 * is already idle, it is possible that the UART will discard data since data must be received
mbed_official 324:406fd2029f23 862 * (or a LIN break detect) after an IDLE is detected before IDLE is allowed to reasserted.
mbed_official 324:406fd2029f23 863 *
mbed_official 324:406fd2029f23 864 *END**************************************************************************/
mbed_official 324:406fd2029f23 865 uart_status_t UART_HAL_PutReceiverInStandbyMode(uint32_t baseAddr)
mbed_official 324:406fd2029f23 866 {
mbed_official 324:406fd2029f23 867 /* In some uart baseAddrs, there is a condition that must be met before placing
mbed_official 324:406fd2029f23 868 * rx in standby mode.
mbed_official 324:406fd2029f23 869 * Before placing uart in standby, need to first determine if receiver is set to
mbed_official 324:406fd2029f23 870 * wake on idle and if receiver is already in idle state. Per ref manual:
mbed_official 324:406fd2029f23 871 * NOTE: RWU should only be set with C1[WAKE] = 0 (wakeup on idle) if the channel is
mbed_official 324:406fd2029f23 872 * currently not idle.
mbed_official 324:406fd2029f23 873 * This can be determined by the S2[RAF] flag. If set to wake up an IDLE event and
mbed_official 324:406fd2029f23 874 * the channel is already idle, it is possible that the UART will discard data since data
mbed_official 324:406fd2029f23 875 * must be received (or a LIN break detect) after an IDLE is detected before IDLE is
mbed_official 324:406fd2029f23 876 * allowed to reasserted.
mbed_official 324:406fd2029f23 877 */
mbed_official 324:406fd2029f23 878 uart_wakeup_method_t rxWakeMethod;
mbed_official 324:406fd2029f23 879 bool uart_current_rx_state;
mbed_official 324:406fd2029f23 880
mbed_official 324:406fd2029f23 881 /* see if wake is set for idle or */
mbed_official 324:406fd2029f23 882 rxWakeMethod = UART_HAL_GetReceiverWakeupMethod(baseAddr);
mbed_official 324:406fd2029f23 883 uart_current_rx_state = UART_HAL_GetStatusFlag(baseAddr, kUartRxActive);
mbed_official 324:406fd2029f23 884
mbed_official 324:406fd2029f23 885 /* if both rxWakeMethod is set for idle and current rx state is idle, don't put in standy*/
mbed_official 324:406fd2029f23 886 if ((rxWakeMethod == kUartIdleLineWake) && (uart_current_rx_state == 0))
mbed_official 324:406fd2029f23 887 {
mbed_official 324:406fd2029f23 888 return kStatus_UART_RxStandbyModeError;
mbed_official 324:406fd2029f23 889 }
mbed_official 324:406fd2029f23 890 else
mbed_official 324:406fd2029f23 891 {
mbed_official 324:406fd2029f23 892 /* set the RWU bit to place receiver into standby mode*/
mbed_official 324:406fd2029f23 893 HW_UART_C2_SET(baseAddr, BM_UART_C2_RWU);
mbed_official 324:406fd2029f23 894 return kStatus_UART_Success;
mbed_official 324:406fd2029f23 895 }
mbed_official 324:406fd2029f23 896 }
mbed_official 324:406fd2029f23 897
mbed_official 324:406fd2029f23 898 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 899 *
mbed_official 324:406fd2029f23 900 * Function Name : UART_HAL_ConfigIdleLineDetect
mbed_official 324:406fd2029f23 901 * Description : Configure the operation options of the UART idle line detect.
mbed_official 324:406fd2029f23 902 * This function allows the user to configure the UART idle-line detect operation. There are two
mbed_official 324:406fd2029f23 903 * separate operations for the user to configure, the idle line bit-count start and the receive
mbed_official 324:406fd2029f23 904 * wake up affect on IDLE status bit. The user will pass in a stucture of type
mbed_official 324:406fd2029f23 905 * uart_idle_line_config_t.
mbed_official 324:406fd2029f23 906 *
mbed_official 324:406fd2029f23 907 *END**************************************************************************/
mbed_official 324:406fd2029f23 908 void UART_HAL_ConfigIdleLineDetect(uint32_t baseAddr, uint8_t idleLine, uint8_t rxWakeIdleDetect)
mbed_official 324:406fd2029f23 909 {
mbed_official 324:406fd2029f23 910 /* Configure the idle line detection configuration as follows:
mbed_official 324:406fd2029f23 911 * configure the ILT to bit count after start bit or stop bit
mbed_official 324:406fd2029f23 912 * configure RWUID to set or not set IDLE status bit upon detection of
mbed_official 324:406fd2029f23 913 * an idle character when recevier in standby */
mbed_official 324:406fd2029f23 914 BW_UART_C1_ILT(baseAddr, idleLine);
mbed_official 324:406fd2029f23 915 BW_UART_S2_RWUID(baseAddr, rxWakeIdleDetect);
mbed_official 324:406fd2029f23 916 }
mbed_official 324:406fd2029f23 917 #if FSL_FEATURE_UART_HAS_ADDRESS_MATCHING
mbed_official 324:406fd2029f23 918 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 919 *
mbed_official 324:406fd2029f23 920 * Function Name : UART_HAL_SetMatchAddress
mbed_official 324:406fd2029f23 921 * Description : Configure the UART match address mode control operation. (Note: Feature
mbed_official 324:406fd2029f23 922 * available on select UART baseAddrs)
mbed_official 324:406fd2029f23 923 * The function allows the user to configure the UART match address control operation. The user
mbed_official 324:406fd2029f23 924 * has the option to enable the match address mode and to program the match address value. There
mbed_official 324:406fd2029f23 925 * are two match address modes, each with it's own enable and programmable match address value.
mbed_official 324:406fd2029f23 926 *
mbed_official 324:406fd2029f23 927 *END**************************************************************************/
mbed_official 324:406fd2029f23 928 void UART_HAL_SetMatchAddress( uint32_t baseAddr, bool matchAddrMode1, bool matchAddrMode2,
mbed_official 324:406fd2029f23 929 uint8_t matchAddrValue1, uint8_t matchAddrValue2)
mbed_official 324:406fd2029f23 930 {
mbed_official 324:406fd2029f23 931 BW_UART_C4_MAEN1(baseAddr, matchAddrMode1); /* Match Address Mode Enable 1 */
mbed_official 324:406fd2029f23 932 BW_UART_C4_MAEN2(baseAddr, matchAddrMode2); /* Match Address Mode Enable 2 */
mbed_official 324:406fd2029f23 933 HW_UART_MA1_WR(baseAddr, matchAddrValue1); /* match address register 1 */
mbed_official 324:406fd2029f23 934 HW_UART_MA2_WR(baseAddr, matchAddrValue2); /* match address register 2 */
mbed_official 324:406fd2029f23 935 }
mbed_official 324:406fd2029f23 936 #endif
mbed_official 324:406fd2029f23 937
mbed_official 324:406fd2029f23 938 #if FSL_FEATURE_UART_HAS_IR_SUPPORT
mbed_official 324:406fd2029f23 939 /*FUNCTION**********************************************************************
mbed_official 324:406fd2029f23 940 *
mbed_official 324:406fd2029f23 941 * Function Name : UART_HAL_SetInfraredOperation
mbed_official 324:406fd2029f23 942 * Description : Configure the UART infrared operation.
mbed_official 324:406fd2029f23 943 * The function allows the user to enable or disable the UART infrared (IR) operation
mbed_official 324:406fd2029f23 944 * and to configure the IR pulse width.
mbed_official 324:406fd2029f23 945 *
mbed_official 324:406fd2029f23 946 *END**************************************************************************/
mbed_official 324:406fd2029f23 947 void UART_HAL_SetInfraredOperation(uint32_t baseAddr, bool enable,
mbed_official 324:406fd2029f23 948 uart_ir_tx_pulsewidth_t pulseWidth)
mbed_official 324:406fd2029f23 949 {
mbed_official 324:406fd2029f23 950 /* enable or disable infrared */
mbed_official 324:406fd2029f23 951 BW_UART_IR_IREN(baseAddr, enable);
mbed_official 324:406fd2029f23 952 /* configure the narrow pulse width of the IR pulse */
mbed_official 324:406fd2029f23 953 BW_UART_IR_TNP(baseAddr, pulseWidth);
mbed_official 324:406fd2029f23 954 }
mbed_official 324:406fd2029f23 955 #endif /* FSL_FEATURE_UART_HAS_IR_SUPPORT */
mbed_official 324:406fd2029f23 956
mbed_official 324:406fd2029f23 957
mbed_official 324:406fd2029f23 958 /*******************************************************************************
mbed_official 324:406fd2029f23 959 * EOF
mbed_official 324:406fd2029f23 960 ******************************************************************************/
mbed_official 324:406fd2029f23 961