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_transfer_functions.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 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 41 *
mbed_official 146:f64d43ff0c18 42 * Function Name : uart_hal_putchar
mbed_official 146:f64d43ff0c18 43 * Description : This function allows the user to send an 8-bit character from the UART
mbed_official 146:f64d43ff0c18 44 * data register.
mbed_official 146:f64d43ff0c18 45 *
mbed_official 146:f64d43ff0c18 46 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 47 void uart_hal_putchar(uint32_t uartInstance, uint8_t data)
mbed_official 146:f64d43ff0c18 48 {
mbed_official 146:f64d43ff0c18 49 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 50
mbed_official 146:f64d43ff0c18 51 /* put 8-bit data into the uart data register*/
mbed_official 146:f64d43ff0c18 52 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 53 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 54 {
mbed_official 146:f64d43ff0c18 55 HW_UART0_D_WR(data);
mbed_official 146:f64d43ff0c18 56 }
mbed_official 146:f64d43ff0c18 57 else
mbed_official 146:f64d43ff0c18 58 #endif
mbed_official 146:f64d43ff0c18 59 {
mbed_official 146:f64d43ff0c18 60 /* in addition to sending a char, this function also clears the transmit status flags
mbed_official 146:f64d43ff0c18 61 * for this uart instance, there is a two step process to clear the transmit status flags:
mbed_official 146:f64d43ff0c18 62 * 1. Read the status register with the status bit set
mbed_official 146:f64d43ff0c18 63 * 2. write to the data register
mbed_official 146:f64d43ff0c18 64 * first read the status register
mbed_official 146:f64d43ff0c18 65 * no need to store the read value, it's assumed the status bit is set
mbed_official 146:f64d43ff0c18 66 */
mbed_official 146:f64d43ff0c18 67 HW_UART_S1_RD(uartInstance);
mbed_official 146:f64d43ff0c18 68 /* second, perform a write to the data register */
mbed_official 146:f64d43ff0c18 69 HW_UART_D_WR(uartInstance, data);
mbed_official 146:f64d43ff0c18 70 }
mbed_official 146:f64d43ff0c18 71 }
mbed_official 146:f64d43ff0c18 72
mbed_official 146:f64d43ff0c18 73 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 74 *
mbed_official 146:f64d43ff0c18 75 * Function Name : uart_hal_putchar9
mbed_official 146:f64d43ff0c18 76 * Description : This function allows the user to send a 9-bit character from the UART
mbed_official 146:f64d43ff0c18 77 * data register.
mbed_official 146:f64d43ff0c18 78 *
mbed_official 146:f64d43ff0c18 79 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 80
mbed_official 146:f64d43ff0c18 81 void uart_hal_putchar9(uint32_t uartInstance, uint16_t data)
mbed_official 146:f64d43ff0c18 82 {
mbed_official 146:f64d43ff0c18 83 uint8_t ninthDataBit;
mbed_official 146:f64d43ff0c18 84
mbed_official 146:f64d43ff0c18 85 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 86
mbed_official 146:f64d43ff0c18 87 ninthDataBit = (data >> 8U) & 0x1U; /* isolate the ninth data bit*/
mbed_official 146:f64d43ff0c18 88
mbed_official 146:f64d43ff0c18 89 /* put 9-bit data to transmit*/
mbed_official 146:f64d43ff0c18 90 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 91 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 92 {
mbed_official 146:f64d43ff0c18 93 /* first, write to the ninth data bit (bit position T8, where T[0:7]=8-bits, T8=9th bit)*/
mbed_official 146:f64d43ff0c18 94 BW_UART0_C3_R9T8(ninthDataBit);
mbed_official 146:f64d43ff0c18 95
mbed_official 146:f64d43ff0c18 96 /* write to the data register last since this will trigger transmit complete status flag
mbed_official 146:f64d43ff0c18 97 * also typecast to uint8_t to match register type
mbed_official 146:f64d43ff0c18 98 */
mbed_official 146:f64d43ff0c18 99 HW_UART0_D_WR((uint8_t)data);
mbed_official 146:f64d43ff0c18 100 }
mbed_official 146:f64d43ff0c18 101 else
mbed_official 146:f64d43ff0c18 102 #endif
mbed_official 146:f64d43ff0c18 103 {
mbed_official 146:f64d43ff0c18 104 /* first, write to the ninth data bit (bit position T8, where T[0:7]=8-bits, T8=9th bit)*/
mbed_official 146:f64d43ff0c18 105 BW_UART_C3_T8(uartInstance, ninthDataBit);
mbed_official 146:f64d43ff0c18 106
mbed_official 146:f64d43ff0c18 107 /* in addition to sending a char, this function also clears the transmit status flags
mbed_official 146:f64d43ff0c18 108 * for this uart instance, there is a two step process to clear the transmit status flags:
mbed_official 146:f64d43ff0c18 109 * 1. Read the status register with the status bit set
mbed_official 146:f64d43ff0c18 110 * 2. write to the data register
mbed_official 146:f64d43ff0c18 111 * first read the status register
mbed_official 146:f64d43ff0c18 112 * no need to store the read value, it's assumed the status bit is set
mbed_official 146:f64d43ff0c18 113 */
mbed_official 146:f64d43ff0c18 114 HW_UART_S1_RD(uartInstance);
mbed_official 146:f64d43ff0c18 115 /* write to the data register last since this will trigger transmit complete status flags
mbed_official 146:f64d43ff0c18 116 * also typecast to uint8_t to match register type
mbed_official 146:f64d43ff0c18 117 */
mbed_official 146:f64d43ff0c18 118 HW_UART_D_WR(uartInstance, (uint8_t)data);
mbed_official 146:f64d43ff0c18 119 }
mbed_official 146:f64d43ff0c18 120 }
mbed_official 146:f64d43ff0c18 121
mbed_official 146:f64d43ff0c18 122 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 123 *
mbed_official 146:f64d43ff0c18 124 * Function Name : uart_hal_putchar10
mbed_official 146:f64d43ff0c18 125 * Description : This function allows the user to send a 10-bit character from the UART
mbed_official 146:f64d43ff0c18 126 * data register. (Note: Feature available on select UART instances)
mbed_official 146:f64d43ff0c18 127 *
mbed_official 146:f64d43ff0c18 128 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 129 uart_status_t uart_hal_putchar10(uint32_t uartInstance, uint16_t data)
mbed_official 146:f64d43ff0c18 130 {
mbed_official 146:f64d43ff0c18 131 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 132
mbed_official 146:f64d43ff0c18 133 /* put 10-bit data to transmit*/
mbed_official 146:f64d43ff0c18 134 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 135 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 136 {
mbed_official 146:f64d43ff0c18 137 uint8_t ninthDataBit;
mbed_official 146:f64d43ff0c18 138 uint8_t tenthDataBit;
mbed_official 146:f64d43ff0c18 139 ninthDataBit = (data >> 8U) & 0x1U; /* isolate the ninth data bit*/
mbed_official 146:f64d43ff0c18 140 tenthDataBit = (data >> 9U) & 0x1U; /* isolate the tenth data bit*/
mbed_official 146:f64d43ff0c18 141
mbed_official 146:f64d43ff0c18 142 /* first, write to the tenth data bit (bit position T9, where T[0:7]=8-bits,
mbed_official 146:f64d43ff0c18 143 * T9=10th bit, T8=9th bit)
mbed_official 146:f64d43ff0c18 144 */
mbed_official 146:f64d43ff0c18 145 BW_UART0_C3_R8T9(tenthDataBit);
mbed_official 146:f64d43ff0c18 146
mbed_official 146:f64d43ff0c18 147 /* next, write to the ninth data bit (bit position T8, where T[0:7]=8-bits,
mbed_official 146:f64d43ff0c18 148 * T9=10th bit, T8=9th bit)
mbed_official 146:f64d43ff0c18 149 */
mbed_official 146:f64d43ff0c18 150 BW_UART0_C3_R9T8(ninthDataBit);
mbed_official 146:f64d43ff0c18 151
mbed_official 146:f64d43ff0c18 152 /* write to the data register last since this will trigger transmit complete status flag
mbed_official 146:f64d43ff0c18 153 * also typecast to uint8_t to match register type
mbed_official 146:f64d43ff0c18 154 */
mbed_official 146:f64d43ff0c18 155 HW_UART0_D_WR((uint8_t)data);
mbed_official 146:f64d43ff0c18 156
mbed_official 146:f64d43ff0c18 157 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 158 }
mbed_official 146:f64d43ff0c18 159 else
mbed_official 146:f64d43ff0c18 160 #endif
mbed_official 146:f64d43ff0c18 161 {
mbed_official 146:f64d43ff0c18 162 /* unsupported feature of this instance number, return error code*/
mbed_official 146:f64d43ff0c18 163 return kStatus_UART_BitCountNotSupported;
mbed_official 146:f64d43ff0c18 164 }
mbed_official 146:f64d43ff0c18 165 }
mbed_official 146:f64d43ff0c18 166
mbed_official 146:f64d43ff0c18 167 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 168 *
mbed_official 146:f64d43ff0c18 169 * Function Name : uart_hal_getchar
mbed_official 146:f64d43ff0c18 170 * Description : This function gets a received 8-bit character from the UART data register.
mbed_official 146:f64d43ff0c18 171 *
mbed_official 146:f64d43ff0c18 172 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 173 void uart_hal_getchar(uint32_t uartInstance, uint8_t *readData)
mbed_official 146:f64d43ff0c18 174 {
mbed_official 146:f64d43ff0c18 175 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 176
mbed_official 146:f64d43ff0c18 177 /* get 8-bit data from the uart data register*/
mbed_official 146:f64d43ff0c18 178 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 179 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 180 {
mbed_official 146:f64d43ff0c18 181 *readData = HW_UART0_D_RD(); /* read 8-bit data from data register*/
mbed_official 146:f64d43ff0c18 182 }
mbed_official 146:f64d43ff0c18 183 else
mbed_official 146:f64d43ff0c18 184 #endif
mbed_official 146:f64d43ff0c18 185 {
mbed_official 146:f64d43ff0c18 186 /* in addition to getting a char, this function also clears the receive status flag RDRF
mbed_official 146:f64d43ff0c18 187 * along with IDLE, OR, NF, FE, and PF (these can also be cleared in separate functions)
mbed_official 146:f64d43ff0c18 188 * for this uart instance, there is a two step process to clear the receive status flag:
mbed_official 146:f64d43ff0c18 189 * 1. Read the status register with the status bit set
mbed_official 146:f64d43ff0c18 190 * 2. read from the data register
mbed_official 146:f64d43ff0c18 191 * first read the status register
mbed_official 146:f64d43ff0c18 192 * no need to store the read value, it's assumed the status bit is set
mbed_official 146:f64d43ff0c18 193 */
mbed_official 146:f64d43ff0c18 194 HW_UART_S1_RD(uartInstance);
mbed_official 146:f64d43ff0c18 195 /* second, perform a read from the data register */
mbed_official 146:f64d43ff0c18 196 *readData = HW_UART_D_RD(uartInstance); /* read 8-bit data from data register*/
mbed_official 146:f64d43ff0c18 197 }
mbed_official 146:f64d43ff0c18 198 }
mbed_official 146:f64d43ff0c18 199
mbed_official 146:f64d43ff0c18 200 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 201 *
mbed_official 146:f64d43ff0c18 202 * Function Name : uart_hal_getchar9
mbed_official 146:f64d43ff0c18 203 * Description : This function gets a received 9-bit character from the UART data register.
mbed_official 146:f64d43ff0c18 204 *
mbed_official 146:f64d43ff0c18 205 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 206 void uart_hal_getchar9(uint32_t uartInstance, uint16_t *readData)
mbed_official 146:f64d43ff0c18 207 {
mbed_official 146:f64d43ff0c18 208 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 209
mbed_official 146:f64d43ff0c18 210 uint16_t temp;
mbed_official 146:f64d43ff0c18 211
mbed_official 146:f64d43ff0c18 212 /* get 9-bit data from the uart data register*/
mbed_official 146:f64d43ff0c18 213 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 214 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 215 {
mbed_official 146:f64d43ff0c18 216 /* read ninth data bit and left shift to bit position R8 before reading
mbed_official 146:f64d43ff0c18 217 * the 8 other data bits R[7:0]
mbed_official 146:f64d43ff0c18 218 * *readData = (HW_UART0_C3.B.R8T9) << 8;
mbed_official 146:f64d43ff0c18 219 */
mbed_official 146:f64d43ff0c18 220 temp = HW_UART0_C3.B.R8T9; /* need this two step process to work around mishra rule*/
mbed_official 146:f64d43ff0c18 221 *readData = temp << 8;
mbed_official 146:f64d43ff0c18 222
mbed_official 146:f64d43ff0c18 223 /* do last: get 8-bit data from the uart data register, will clear certain
mbed_official 146:f64d43ff0c18 224 * receive status bits once completed
mbed_official 146:f64d43ff0c18 225 * need to OR these 8-bits with the ninth bit value above
mbed_official 146:f64d43ff0c18 226 */
mbed_official 146:f64d43ff0c18 227 *readData |= HW_UART0_D_RD(); /* read 8-bit data from data register*/
mbed_official 146:f64d43ff0c18 228 }
mbed_official 146:f64d43ff0c18 229 else
mbed_official 146:f64d43ff0c18 230 #endif
mbed_official 146:f64d43ff0c18 231 {
mbed_official 146:f64d43ff0c18 232 /* read ninth data bit and left shift to bit position R8 before reading
mbed_official 146:f64d43ff0c18 233 * the 8 other data bits R[7:0]
mbed_official 146:f64d43ff0c18 234 * *readData = (HW_UART_C3(uartInstance).B.R8) << 8;
mbed_official 146:f64d43ff0c18 235 */
mbed_official 146:f64d43ff0c18 236 temp = (HW_UART_C3(uartInstance).B.R8);
mbed_official 146:f64d43ff0c18 237 *readData = temp << 8;
mbed_official 146:f64d43ff0c18 238
mbed_official 146:f64d43ff0c18 239 /* in addition to getting a char, this function also clears the receive status flag RDRF
mbed_official 146:f64d43ff0c18 240 * along with IDLE, OR, NF, FE, and PF (these can also be cleared in separate functions)
mbed_official 146:f64d43ff0c18 241 * for this uart instance, there is a two step process to clear the receive status flag:
mbed_official 146:f64d43ff0c18 242 * 1. Read the status register with the status bit set
mbed_official 146:f64d43ff0c18 243 * 2. read from the data register
mbed_official 146:f64d43ff0c18 244 * first read the status register
mbed_official 146:f64d43ff0c18 245 * no need to store the read value, it's assumed the status bit is set
mbed_official 146:f64d43ff0c18 246 */
mbed_official 146:f64d43ff0c18 247 HW_UART_S1_RD(uartInstance);
mbed_official 146:f64d43ff0c18 248 /* do last: get 8-bit data from the uart data register,
mbed_official 146:f64d43ff0c18 249 * will clear certain receive status bits once completed
mbed_official 146:f64d43ff0c18 250 * need to OR these 8-bits with the ninth bit value above
mbed_official 146:f64d43ff0c18 251 */
mbed_official 146:f64d43ff0c18 252 *readData |= HW_UART_D_RD(uartInstance); /* read 8-bit data from data register*/
mbed_official 146:f64d43ff0c18 253 }
mbed_official 146:f64d43ff0c18 254 }
mbed_official 146:f64d43ff0c18 255
mbed_official 146:f64d43ff0c18 256 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 257 *
mbed_official 146:f64d43ff0c18 258 * Function Name : uart_hal_getchar10
mbed_official 146:f64d43ff0c18 259 * Description : This function gets a received 10-bit character from the UART data register.
mbed_official 146:f64d43ff0c18 260 * (Note: Feature available on select UART instances)
mbed_official 146:f64d43ff0c18 261 *
mbed_official 146:f64d43ff0c18 262 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 263 uart_status_t uart_hal_getchar10(uint32_t uartInstance, uint16_t *readData)
mbed_official 146:f64d43ff0c18 264 {
mbed_official 146:f64d43ff0c18 265 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 266
mbed_official 146:f64d43ff0c18 267 /* get 10-bit data from the uart data register, available only on supported uarts*/
mbed_official 146:f64d43ff0c18 268 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 269 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 270 {
mbed_official 146:f64d43ff0c18 271 /* read tenth data bit and left shift to bit position R9 before reading the 9 other
mbed_official 146:f64d43ff0c18 272 * data bits: R8 and R[7:0]
mbed_official 146:f64d43ff0c18 273 */
mbed_official 146:f64d43ff0c18 274 *readData = (uint16_t)((uint32_t)(HW_UART0_C3.B.R9T8) << 9U);
mbed_official 146:f64d43ff0c18 275
mbed_official 146:f64d43ff0c18 276 /* read ninth data bit and left shift to bit position R8 before reading the 8 other
mbed_official 146:f64d43ff0c18 277 * data bits R[7:0]
mbed_official 146:f64d43ff0c18 278 */
mbed_official 146:f64d43ff0c18 279 *readData |= (uint16_t)((uint32_t)(HW_UART0_C3.B.R8T9) << 8U);
mbed_official 146:f64d43ff0c18 280
mbed_official 146:f64d43ff0c18 281 /* do last: get 8-bit data from the uart data register, will clear certain receive
mbed_official 146:f64d43ff0c18 282 * status bits once completed
mbed_official 146:f64d43ff0c18 283 * need to OR these 8-bits with the ninth bit value above
mbed_official 146:f64d43ff0c18 284 */
mbed_official 146:f64d43ff0c18 285 *readData |= HW_UART0_D_RD(); /* read 8-bit data from data register*/
mbed_official 146:f64d43ff0c18 286
mbed_official 146:f64d43ff0c18 287 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 288 }
mbed_official 146:f64d43ff0c18 289 else
mbed_official 146:f64d43ff0c18 290 #endif
mbed_official 146:f64d43ff0c18 291 {
mbed_official 146:f64d43ff0c18 292 /* unsupported feature of this instance number, return error code*/
mbed_official 146:f64d43ff0c18 293 return kStatus_UART_BitCountNotSupported;
mbed_official 146:f64d43ff0c18 294 }
mbed_official 146:f64d43ff0c18 295 }
mbed_official 146:f64d43ff0c18 296
mbed_official 146:f64d43ff0c18 297 #if FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS
mbed_official 146:f64d43ff0c18 298 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 299 *
mbed_official 146:f64d43ff0c18 300 * Function Name : uart_hal_configure_bit10_as_paritybit_operation
mbed_official 146:f64d43ff0c18 301 * Description : Configure the UART bit 10 (if enabled) or bit 9 (if disabled) as the
mbed_official 146:f64d43ff0c18 302 * parity bit in the serial transmission.
mbed_official 146:f64d43ff0c18 303 * This function configures bit 10 or bit 9 to be the parity bit. To configure bit 10 as the parity
mbed_official 146:f64d43ff0c18 304 * bit, the function sets UARTx_C4[M10]; it also sets UARTx_C1[M] and UARTx_C1[PE] as required.
mbed_official 146:f64d43ff0c18 305 *
mbed_official 146:f64d43ff0c18 306 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 307 void uart_hal_configure_bit10_as_paritybit_operation(uint32_t uartInstance, bool enable)
mbed_official 146:f64d43ff0c18 308 {
mbed_official 146:f64d43ff0c18 309 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 310
mbed_official 146:f64d43ff0c18 311 /* to enable the parity bit as the tenth data bit, along with enabling UARTx_C4[M10]
mbed_official 146:f64d43ff0c18 312 * need to also enable parity and set UARTx_C1[M] bit
mbed_official 146:f64d43ff0c18 313 * assumed that the user has already set the appropriate bits
mbed_official 146:f64d43ff0c18 314 */
mbed_official 146:f64d43ff0c18 315 BW_UART_C4_M10(uartInstance, enable);
mbed_official 146:f64d43ff0c18 316 }
mbed_official 146:f64d43ff0c18 317
mbed_official 146:f64d43ff0c18 318 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 319 *
mbed_official 146:f64d43ff0c18 320 * Function Name : uart_hal_is_bit10_set_as_paritybit
mbed_official 146:f64d43ff0c18 321 * Description : Get the configuration of the UART bit 10 (if enabled) or bit 9 (if disabled)
mbed_official 146:f64d43ff0c18 322 * as the parity bit in the serial transmission
mbed_official 146:f64d43ff0c18 323 * This function returns true if bit 10 is configured as the parity bit, otherwise it returns
mbed_official 146:f64d43ff0c18 324 * false if bit 9 is configured as the parity bit.
mbed_official 146:f64d43ff0c18 325 *
mbed_official 146:f64d43ff0c18 326 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 327 bool uart_hal_is_bit10_set_as_paritybit(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 328 {
mbed_official 146:f64d43ff0c18 329 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 330
mbed_official 146:f64d43ff0c18 331 /* to see if the parity bit is set as the tenth data bit,
mbed_official 146:f64d43ff0c18 332 * return value of UARTx_C4[M10]
mbed_official 146:f64d43ff0c18 333 */
mbed_official 146:f64d43ff0c18 334 return HW_UART_C4(uartInstance).B.M10;
mbed_official 146:f64d43ff0c18 335 }
mbed_official 146:f64d43ff0c18 336
mbed_official 146:f64d43ff0c18 337 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 338 *
mbed_official 146:f64d43ff0c18 339 * Function Name : uart_hal_is_current_dataword_received_with_noise
mbed_official 146:f64d43ff0c18 340 * Description : Determine if the UART received data word was received with noise.
mbed_official 146:f64d43ff0c18 341 * This function will return true if the received data word was received with noise. Otherwise,
mbed_official 146:f64d43ff0c18 342 * it will return false indicating no noise was detected.
mbed_official 146:f64d43ff0c18 343 *
mbed_official 146:f64d43ff0c18 344 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 345 bool uart_hal_is_current_dataword_received_with_noise(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 346 {
mbed_official 146:f64d43ff0c18 347 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 348
mbed_official 146:f64d43ff0c18 349 /* to see if the current dataword was received with noise,
mbed_official 146:f64d43ff0c18 350 * return value of UARTx_ED[NOISY]
mbed_official 146:f64d43ff0c18 351 */
mbed_official 146:f64d43ff0c18 352 return HW_UART_ED(uartInstance).B.NOISY;
mbed_official 146:f64d43ff0c18 353 }
mbed_official 146:f64d43ff0c18 354
mbed_official 146:f64d43ff0c18 355 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 356 *
mbed_official 146:f64d43ff0c18 357 * Function Name : uart_hal_is_current_dataword_received_with_parityerror
mbed_official 146:f64d43ff0c18 358 * Description : Determine if the UART received data word was received with a parity error.
mbed_official 146:f64d43ff0c18 359 * This function will return true if the received data word was received with a parity error.
mbed_official 146:f64d43ff0c18 360 * Otherwise, it will return false indicating no parity error was detected.
mbed_official 146:f64d43ff0c18 361 *
mbed_official 146:f64d43ff0c18 362 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 363 bool uart_hal_is_current_dataword_received_with_parityerror(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 364 {
mbed_official 146:f64d43ff0c18 365 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 366
mbed_official 146:f64d43ff0c18 367 /* to see if the current dataword was received with parity error,
mbed_official 146:f64d43ff0c18 368 * return value of UARTx_ED[PARITYE]
mbed_official 146:f64d43ff0c18 369 */
mbed_official 146:f64d43ff0c18 370 return HW_UART_ED(uartInstance).B.PARITYE;
mbed_official 146:f64d43ff0c18 371 }
mbed_official 146:f64d43ff0c18 372 #endif /* FSL_FEATURE_UART_HAS_EXTENDED_DATA_REGISTER_FLAGS*/
mbed_official 146:f64d43ff0c18 373
mbed_official 146:f64d43ff0c18 374 /*******************************************************************************
mbed_official 146:f64d43ff0c18 375 * EOF
mbed_official 146:f64d43ff0c18 376 ******************************************************************************/
mbed_official 146:f64d43ff0c18 377