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_special_feature_configurations.c@146:f64d43ff0c18
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #include "fsl_uart_hal.h"
mbed_official 146:f64d43ff0c18 31
mbed_official 146:f64d43ff0c18 32 /*******************************************************************************
mbed_official 146:f64d43ff0c18 33 * Definitions
mbed_official 146:f64d43ff0c18 34 ******************************************************************************/
mbed_official 146:f64d43ff0c18 35
mbed_official 146:f64d43ff0c18 36 /*******************************************************************************
mbed_official 146:f64d43ff0c18 37 * Code
mbed_official 146:f64d43ff0c18 38 ******************************************************************************/
mbed_official 146:f64d43ff0c18 39
mbed_official 146:f64d43ff0c18 40 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 41 *
mbed_official 146:f64d43ff0c18 42 * Function Name : uart_hal_configure_wait_mode_operation
mbed_official 146:f64d43ff0c18 43 * Description : Configure the UART to either operate or sieze to operate in WAIT mode.
mbed_official 146:f64d43ff0c18 44 * The function configures the UART to either operate or seize to operate when WAIT mode is
mbed_official 146:f64d43ff0c18 45 * entered.
mbed_official 146:f64d43ff0c18 46 * In some UART instances it is required that the transmitter/receiver should be disabled
mbed_official 146:f64d43ff0c18 47 * before calling this function.
mbed_official 146:f64d43ff0c18 48 * Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 49 *
mbed_official 146:f64d43ff0c18 50 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 51 void uart_hal_configure_wait_mode_operation(uint32_t uartInstance, uart_operation_config_t mode)
mbed_official 146:f64d43ff0c18 52 {
mbed_official 146:f64d43ff0c18 53 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 54
mbed_official 146:f64d43ff0c18 55 /* configure uart operation in wait mode*/
mbed_official 146:f64d43ff0c18 56 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 57 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 58 {
mbed_official 146:f64d43ff0c18 59 /* In CPU wait mode: 0 - uart clocks continue to run; 1 - uart clocks freeze */
mbed_official 146:f64d43ff0c18 60 BW_UART0_C1_DOZEEN(mode);
mbed_official 146:f64d43ff0c18 61 }
mbed_official 146:f64d43ff0c18 62 else
mbed_official 146:f64d43ff0c18 63 #endif
mbed_official 146:f64d43ff0c18 64 {
mbed_official 146:f64d43ff0c18 65 /*In CPU wait mode: 0 - uart is enabled; 1 - uart is disabled */
mbed_official 146:f64d43ff0c18 66 BW_UART_C1_UARTSWAI(uartInstance, mode);
mbed_official 146:f64d43ff0c18 67 }
mbed_official 146:f64d43ff0c18 68 }
mbed_official 146:f64d43ff0c18 69
mbed_official 146:f64d43ff0c18 70 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 71 *
mbed_official 146:f64d43ff0c18 72 * Function Name : uart_hal_get_wait_mode_operation_config
mbed_official 146:f64d43ff0c18 73 * Description : Determine if the UART operates or siezes to operate in WAIT mode.
mbed_official 146:f64d43ff0c18 74 * This function returns kUartOperates if the UART has been configured to operate in WAIT mode.
mbed_official 146:f64d43ff0c18 75 * Else it returns KUartStops if the UART has been configured to seize-to-operate in WAIT mode.
mbed_official 146:f64d43ff0c18 76 *
mbed_official 146:f64d43ff0c18 77 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 78 uart_operation_config_t uart_hal_get_wait_mode_operation_config(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 79 {
mbed_official 146:f64d43ff0c18 80 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 81
mbed_official 146:f64d43ff0c18 82 /* get configuration uart operation in wait mode*/
mbed_official 146:f64d43ff0c18 83 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 84 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 85 {
mbed_official 146:f64d43ff0c18 86 /* In CPU wait mode: 0 - uart clocks continue to run; 1 - uart clocks freeze */
mbed_official 146:f64d43ff0c18 87 if (HW_UART0_C1.B.DOZEEN==0)
mbed_official 146:f64d43ff0c18 88 {
mbed_official 146:f64d43ff0c18 89 return kUartOperates;
mbed_official 146:f64d43ff0c18 90 }
mbed_official 146:f64d43ff0c18 91 else
mbed_official 146:f64d43ff0c18 92 {
mbed_official 146:f64d43ff0c18 93 return kUartStops;
mbed_official 146:f64d43ff0c18 94 }
mbed_official 146:f64d43ff0c18 95 }
mbed_official 146:f64d43ff0c18 96 else
mbed_official 146:f64d43ff0c18 97 #endif
mbed_official 146:f64d43ff0c18 98 {
mbed_official 146:f64d43ff0c18 99 /*In CPU wait mode: 0 - uart is enabled; 1 - uart is disabled */
mbed_official 146:f64d43ff0c18 100 if (HW_UART_C1(uartInstance).B.UARTSWAI == 0)
mbed_official 146:f64d43ff0c18 101 {
mbed_official 146:f64d43ff0c18 102 return kUartOperates;
mbed_official 146:f64d43ff0c18 103 }
mbed_official 146:f64d43ff0c18 104 else
mbed_official 146:f64d43ff0c18 105 {
mbed_official 146:f64d43ff0c18 106 return kUartStops;
mbed_official 146:f64d43ff0c18 107 }
mbed_official 146:f64d43ff0c18 108 }
mbed_official 146:f64d43ff0c18 109 }
mbed_official 146:f64d43ff0c18 110
mbed_official 146:f64d43ff0c18 111 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 112 *
mbed_official 146:f64d43ff0c18 113 * Function Name : uart_hal_configure_loopback_mode
mbed_official 146:f64d43ff0c18 114 * Description : Configure the UART loopback operation.
mbed_official 146:f64d43ff0c18 115 * This function enables or disables the UART loopback operation.
mbed_official 146:f64d43ff0c18 116 * In some UART instances it is required that the transmitter/receiver should be disabled
mbed_official 146:f64d43ff0c18 117 * before calling this function.
mbed_official 146:f64d43ff0c18 118 * Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 119 *
mbed_official 146:f64d43ff0c18 120 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 121 void uart_hal_configure_loopback_mode(uint32_t uartInstance, bool enable)
mbed_official 146:f64d43ff0c18 122 {
mbed_official 146:f64d43ff0c18 123 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 124
mbed_official 146:f64d43ff0c18 125 /* configure uart to enable/disable operation in loopback mode*/
mbed_official 146:f64d43ff0c18 126 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 127 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 128 {
mbed_official 146:f64d43ff0c18 129 /* configure LOOPS bit to enable(1)/disable(0) loopback mode, but also need to clear RSRC*/
mbed_official 146:f64d43ff0c18 130 BW_UART0_C1_LOOPS(enable);
mbed_official 146:f64d43ff0c18 131
mbed_official 146:f64d43ff0c18 132 /* clear RSRC for loopback mode, and if loopback disabled,
mbed_official 146:f64d43ff0c18 133 * this bit has no meaning but clear anyway
mbed_official 146:f64d43ff0c18 134 * to set it back to default value
mbed_official 146:f64d43ff0c18 135 */
mbed_official 146:f64d43ff0c18 136 HW_UART0_C1_CLR(BM_UART0_C1_RSRC);
mbed_official 146:f64d43ff0c18 137 }
mbed_official 146:f64d43ff0c18 138 else
mbed_official 146:f64d43ff0c18 139 #endif
mbed_official 146:f64d43ff0c18 140 {
mbed_official 146:f64d43ff0c18 141 /* configure LOOPS bit to enable(1)/disable(0) loopback mode, but also need to clear RSRC */
mbed_official 146:f64d43ff0c18 142 BW_UART_C1_LOOPS(uartInstance, enable);
mbed_official 146:f64d43ff0c18 143
mbed_official 146:f64d43ff0c18 144 /* clear RSRC for loopback mode, and if loopback disabled,
mbed_official 146:f64d43ff0c18 145 * this bit has no meaning but clear anyway
mbed_official 146:f64d43ff0c18 146 * to set it back to default value
mbed_official 146:f64d43ff0c18 147 */
mbed_official 146:f64d43ff0c18 148 HW_UART_C1_CLR(uartInstance, BM_UART_C1_RSRC);
mbed_official 146:f64d43ff0c18 149 }
mbed_official 146:f64d43ff0c18 150 }
mbed_official 146:f64d43ff0c18 151
mbed_official 146:f64d43ff0c18 152 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 153 *
mbed_official 146:f64d43ff0c18 154 * Function Name : uart_hal_configure_singlewire_mode
mbed_official 146:f64d43ff0c18 155 * Description : Configure the UART single-wire operation.
mbed_official 146:f64d43ff0c18 156 * This function enables or disables the UART single-wire operation.
mbed_official 146:f64d43ff0c18 157 * In some UART instances it is required that the transmitter/receiver should be disabled
mbed_official 146:f64d43ff0c18 158 * before calling this function.
mbed_official 146:f64d43ff0c18 159 * Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 160 *
mbed_official 146:f64d43ff0c18 161 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 162 void uart_hal_configure_singlewire_mode(uint32_t uartInstance, bool enable)
mbed_official 146:f64d43ff0c18 163 {
mbed_official 146:f64d43ff0c18 164 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 165
mbed_official 146:f64d43ff0c18 166 /* configure uart to enable/disable operation in single mode*/
mbed_official 146:f64d43ff0c18 167 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 168 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 169 {
mbed_official 146:f64d43ff0c18 170 /* to enable single-wire mode, need both LOOPS and RSRC set, to disable, clear both*/
mbed_official 146:f64d43ff0c18 171 BW_UART0_C1_LOOPS(enable);
mbed_official 146:f64d43ff0c18 172 BW_UART0_C1_RSRC(enable);
mbed_official 146:f64d43ff0c18 173 }
mbed_official 146:f64d43ff0c18 174 else
mbed_official 146:f64d43ff0c18 175 #endif
mbed_official 146:f64d43ff0c18 176 {
mbed_official 146:f64d43ff0c18 177 /* to enable single-wire mode, need both LOOPS and RSRC set, to disable, clear both*/
mbed_official 146:f64d43ff0c18 178 BW_UART_C1_LOOPS(uartInstance, enable);
mbed_official 146:f64d43ff0c18 179 BW_UART_C1_RSRC(uartInstance, enable);
mbed_official 146:f64d43ff0c18 180 }
mbed_official 146:f64d43ff0c18 181 }
mbed_official 146:f64d43ff0c18 182
mbed_official 146:f64d43ff0c18 183 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 184 *
mbed_official 146:f64d43ff0c18 185 * Function Name : uart_hal_configure_txdir_in_singlewire_mode
mbed_official 146:f64d43ff0c18 186 * Description : Configure the UART transmit direction while in single-wire mode.
mbed_official 146:f64d43ff0c18 187 * This function configures the transmitter direction when the UART is configured for single-wire
mbed_official 146:f64d43ff0c18 188 * operation.
mbed_official 146:f64d43ff0c18 189 *
mbed_official 146:f64d43ff0c18 190 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 191 void uart_hal_configure_txdir_in_singlewire_mode(uint32_t uartInstance,
mbed_official 146:f64d43ff0c18 192 uart_singlewire_txdir_t direction)
mbed_official 146:f64d43ff0c18 193 {
mbed_official 146:f64d43ff0c18 194 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 195
mbed_official 146:f64d43ff0c18 196 /* configure uart transmit direction (input or output) when in single-wire mode
mbed_official 146:f64d43ff0c18 197 * it is assumed uart is in single-wire mode
mbed_official 146:f64d43ff0c18 198 */
mbed_official 146:f64d43ff0c18 199 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 200 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 201 {
mbed_official 146:f64d43ff0c18 202 BW_UART0_C3_TXDIR(direction);
mbed_official 146:f64d43ff0c18 203 }
mbed_official 146:f64d43ff0c18 204 else
mbed_official 146:f64d43ff0c18 205 #endif
mbed_official 146:f64d43ff0c18 206 {
mbed_official 146:f64d43ff0c18 207 BW_UART_C3_TXDIR(uartInstance, direction);
mbed_official 146:f64d43ff0c18 208 }
mbed_official 146:f64d43ff0c18 209 }
mbed_official 146:f64d43ff0c18 210
mbed_official 146:f64d43ff0c18 211 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 212 *
mbed_official 146:f64d43ff0c18 213 * Function Name : uart_hal_put_receiver_in_standby_mode
mbed_official 146:f64d43ff0c18 214 * Description : Place the UART receiver in standby mode.
mbed_official 146:f64d43ff0c18 215 * This function, when called, will place the UART receiver into standby mode.
mbed_official 146:f64d43ff0c18 216 * In some UART instances, there is a condition that must be met before placing rx in standby mode.
mbed_official 146:f64d43ff0c18 217 * Before placing UART in standby, you need to first determine if receiver is set to
mbed_official 146:f64d43ff0c18 218 * wake on idle and if receiver is already in idle state. Per ref manual:
mbed_official 146:f64d43ff0c18 219 * NOTE: RWU should only be set with C1[WAKE] = 0 (wakeup on idle) if the channel is currently
mbed_official 146:f64d43ff0c18 220 * not idle.
mbed_official 146:f64d43ff0c18 221 * This can be determined by the S2[RAF] flag. If set to wake up FROM an IDLE event and the channel
mbed_official 146:f64d43ff0c18 222 * is already idle, it is possible that the UART will discard data since data must be received
mbed_official 146:f64d43ff0c18 223 * (or a LIN break detect) after an IDLE is detected before IDLE is allowed to reasserted.
mbed_official 146:f64d43ff0c18 224 *
mbed_official 146:f64d43ff0c18 225 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 226 uart_status_t uart_hal_put_receiver_in_standby_mode(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 227 {
mbed_official 146:f64d43ff0c18 228 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 229
mbed_official 146:f64d43ff0c18 230 /* In some uart instances, there is a condition that must be met before placing
mbed_official 146:f64d43ff0c18 231 * rx in standby mode.
mbed_official 146:f64d43ff0c18 232 * Before placing uart in standby, need to first determine if receiver is set to
mbed_official 146:f64d43ff0c18 233 * wake on idle and if receiver is already in idle state. Per ref manual:
mbed_official 146:f64d43ff0c18 234 * NOTE: RWU should only be set with C1[WAKE] = 0 (wakeup on idle) if the channel is
mbed_official 146:f64d43ff0c18 235 * currently not idle.
mbed_official 146:f64d43ff0c18 236 * This can be determined by the S2[RAF] flag. If set to wake up an IDLE event and
mbed_official 146:f64d43ff0c18 237 * the channel is already idle, it is possible that the UART will discard data since data
mbed_official 146:f64d43ff0c18 238 * must be received (or a LIN break detect) after an IDLE is detected before IDLE is
mbed_official 146:f64d43ff0c18 239 * allowed to reasserted.
mbed_official 146:f64d43ff0c18 240 */
mbed_official 146:f64d43ff0c18 241 uart_wakeup_method_t rxWakeMethod;
mbed_official 146:f64d43ff0c18 242 bool uart_current_rx_state;
mbed_official 146:f64d43ff0c18 243
mbed_official 146:f64d43ff0c18 244 /* see if wake is set for idle or */
mbed_official 146:f64d43ff0c18 245 rxWakeMethod = uart_hal_get_receiver_wakeup_method(uartInstance);
mbed_official 146:f64d43ff0c18 246 uart_current_rx_state = uart_hal_is_receiver_active(uartInstance);
mbed_official 146:f64d43ff0c18 247
mbed_official 146:f64d43ff0c18 248 /* if both rxWakeMethod is set for idle and current rx state is idle, don't put in standy*/
mbed_official 146:f64d43ff0c18 249 if ((rxWakeMethod == kUartIdleLineWake) && (uart_current_rx_state == 0))
mbed_official 146:f64d43ff0c18 250 {
mbed_official 146:f64d43ff0c18 251 return kStatus_UART_RxStandbyModeError;
mbed_official 146:f64d43ff0c18 252 }
mbed_official 146:f64d43ff0c18 253 else
mbed_official 146:f64d43ff0c18 254 {
mbed_official 146:f64d43ff0c18 255 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 256 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 257 {
mbed_official 146:f64d43ff0c18 258 /* set the RWU bit to place receiver into standby mode*/
mbed_official 146:f64d43ff0c18 259 HW_UART0_C2_SET(BM_UART0_C2_RWU);
mbed_official 146:f64d43ff0c18 260 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 261 }
mbed_official 146:f64d43ff0c18 262 else
mbed_official 146:f64d43ff0c18 263 #endif
mbed_official 146:f64d43ff0c18 264 {
mbed_official 146:f64d43ff0c18 265 /* set the RWU bit to place receiver into standby mode*/
mbed_official 146:f64d43ff0c18 266 HW_UART_C2_SET(uartInstance, BM_UART_C2_RWU);
mbed_official 146:f64d43ff0c18 267 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 268 }
mbed_official 146:f64d43ff0c18 269 }
mbed_official 146:f64d43ff0c18 270 }
mbed_official 146:f64d43ff0c18 271
mbed_official 146:f64d43ff0c18 272 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 273 *
mbed_official 146:f64d43ff0c18 274 * Function Name : uart_hal_put_receiver_in_normal_mode
mbed_official 146:f64d43ff0c18 275 * Description : Place the UART receiver in normal mode (disable standby mode operation).
mbed_official 146:f64d43ff0c18 276 * This function, when called, will place the UART receiver into normal mode and out of
mbed_official 146:f64d43ff0c18 277 * standby mode.
mbed_official 146:f64d43ff0c18 278 *
mbed_official 146:f64d43ff0c18 279 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 280 void uart_hal_put_receiver_in_normal_mode(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 281 {
mbed_official 146:f64d43ff0c18 282 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 283
mbed_official 146:f64d43ff0c18 284 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 285 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 286 {
mbed_official 146:f64d43ff0c18 287 /* clear the RWU bit to place receiver into normal mode (disable standby mode)*/
mbed_official 146:f64d43ff0c18 288 HW_UART0_C2_CLR(BM_UART0_C2_RWU);
mbed_official 146:f64d43ff0c18 289 }
mbed_official 146:f64d43ff0c18 290 else
mbed_official 146:f64d43ff0c18 291 #endif
mbed_official 146:f64d43ff0c18 292 {
mbed_official 146:f64d43ff0c18 293 /* clear the RWU bit to place receiver into normal mode (disable standby mode)*/
mbed_official 146:f64d43ff0c18 294 HW_UART_C2_CLR(uartInstance, BM_UART_C2_RWU);
mbed_official 146:f64d43ff0c18 295 }
mbed_official 146:f64d43ff0c18 296 }
mbed_official 146:f64d43ff0c18 297
mbed_official 146:f64d43ff0c18 298 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 299 *
mbed_official 146:f64d43ff0c18 300 * Function Name : uart_hal_is_receiver_in_standby
mbed_official 146:f64d43ff0c18 301 * Description : Determine if the UART receiver is currently in standby mode.
mbed_official 146:f64d43ff0c18 302 * This function determines the state of the UART receiver. If it returns true, this means
mbed_official 146:f64d43ff0c18 303 * that the UART receiver is in standby mode, otherwise if it returns false, the UART receiver
mbed_official 146:f64d43ff0c18 304 * is in normal mode.
mbed_official 146:f64d43ff0c18 305 *
mbed_official 146:f64d43ff0c18 306 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 307 bool uart_hal_is_receiver_in_standby(uint32_t uartInstance)
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 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 312 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 313 {
mbed_official 146:f64d43ff0c18 314 /* return the RWU bit setting (0 - normal more, 1 - standby)*/
mbed_official 146:f64d43ff0c18 315 return HW_UART0_C2.B.RWU;
mbed_official 146:f64d43ff0c18 316 }
mbed_official 146:f64d43ff0c18 317 else
mbed_official 146:f64d43ff0c18 318 #endif
mbed_official 146:f64d43ff0c18 319 {
mbed_official 146:f64d43ff0c18 320 /* return the RWU bit setting (0 - normal more, 1 - standby)*/
mbed_official 146:f64d43ff0c18 321 return HW_UART_C2(uartInstance).B.RWU;
mbed_official 146:f64d43ff0c18 322 }
mbed_official 146:f64d43ff0c18 323 }
mbed_official 146:f64d43ff0c18 324
mbed_official 146:f64d43ff0c18 325 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 326 *
mbed_official 146:f64d43ff0c18 327 * Function Name : uart_hal_select_receiver_wakeup_method
mbed_official 146:f64d43ff0c18 328 * Description : Select the UART receiver wakeup method (idle line or addr-mark) from standby
mbed_official 146:f64d43ff0c18 329 * mode.
mbed_official 146:f64d43ff0c18 330 * This function configured the wakeup method of the UART receiver from standby mode. The options
mbed_official 146:f64d43ff0c18 331 * are idle-line wake or address-mark wake.
mbed_official 146:f64d43ff0c18 332 *
mbed_official 146:f64d43ff0c18 333 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 334 void uart_hal_select_receiver_wakeup_method(uint32_t uartInstance, uart_wakeup_method_t method)
mbed_official 146:f64d43ff0c18 335 {
mbed_official 146:f64d43ff0c18 336 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 337
mbed_official 146:f64d43ff0c18 338 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 339 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 340 {
mbed_official 146:f64d43ff0c18 341 /* configure the WAKE bit for idle line wake or address mark wake */
mbed_official 146:f64d43ff0c18 342 BW_UART0_C1_WAKE(method);
mbed_official 146:f64d43ff0c18 343 }
mbed_official 146:f64d43ff0c18 344 else
mbed_official 146:f64d43ff0c18 345 #endif
mbed_official 146:f64d43ff0c18 346 {
mbed_official 146:f64d43ff0c18 347 /* configure the WAKE bit for idle line wake or address mark wake */
mbed_official 146:f64d43ff0c18 348 BW_UART_C1_WAKE(uartInstance, method);
mbed_official 146:f64d43ff0c18 349 }
mbed_official 146:f64d43ff0c18 350 }
mbed_official 146:f64d43ff0c18 351
mbed_official 146:f64d43ff0c18 352 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 353 *
mbed_official 146:f64d43ff0c18 354 * Function Name : uart_hal_get_receiver_wakeup_method
mbed_official 146:f64d43ff0c18 355 * Description : Get the UART receiver wakeup method (idle line or addr-mark) from standby mode.
mbed_official 146:f64d43ff0c18 356 * This function returns how the UART recevier is configured to wake from standby mode. The
mbed_official 146:f64d43ff0c18 357 * wake method options that can be returned are kUartIdleLineWake or kUartAddrMarkWake.
mbed_official 146:f64d43ff0c18 358 *
mbed_official 146:f64d43ff0c18 359 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 360 uart_wakeup_method_t uart_hal_get_receiver_wakeup_method(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 361 {
mbed_official 146:f64d43ff0c18 362 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 363
mbed_official 146:f64d43ff0c18 364 /* get configuration of the WAKE bit for idle line wake or address mark wake */
mbed_official 146:f64d43ff0c18 365 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 366 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 367 {
mbed_official 146:f64d43ff0c18 368 if(HW_UART0_C1.B.WAKE == 1)
mbed_official 146:f64d43ff0c18 369 {
mbed_official 146:f64d43ff0c18 370 return kUartAddrMarkWake;
mbed_official 146:f64d43ff0c18 371 }
mbed_official 146:f64d43ff0c18 372 else
mbed_official 146:f64d43ff0c18 373 {
mbed_official 146:f64d43ff0c18 374 return kUartIdleLineWake;
mbed_official 146:f64d43ff0c18 375 }
mbed_official 146:f64d43ff0c18 376 }
mbed_official 146:f64d43ff0c18 377 else
mbed_official 146:f64d43ff0c18 378 #endif
mbed_official 146:f64d43ff0c18 379 {
mbed_official 146:f64d43ff0c18 380 /* get configuration of the WAKE bit for idle line wake or address mark wake */
mbed_official 146:f64d43ff0c18 381 if(HW_UART_C1(uartInstance).B.WAKE == 1)
mbed_official 146:f64d43ff0c18 382 {
mbed_official 146:f64d43ff0c18 383 return kUartAddrMarkWake;
mbed_official 146:f64d43ff0c18 384 }
mbed_official 146:f64d43ff0c18 385 else
mbed_official 146:f64d43ff0c18 386 {
mbed_official 146:f64d43ff0c18 387 return kUartIdleLineWake;
mbed_official 146:f64d43ff0c18 388 }
mbed_official 146:f64d43ff0c18 389 }
mbed_official 146:f64d43ff0c18 390 }
mbed_official 146:f64d43ff0c18 391
mbed_official 146:f64d43ff0c18 392 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 393 *
mbed_official 146:f64d43ff0c18 394 * Function Name : uart_hal_configure_idle_line_detect
mbed_official 146:f64d43ff0c18 395 * Description : Configure the operation options of the UART idle line detect.
mbed_official 146:f64d43ff0c18 396 * This function allows the user to configure the UART idle-line detect operation. There are two
mbed_official 146:f64d43ff0c18 397 * separate operations for the user to configure, the idle line bit-count start and the receive
mbed_official 146:f64d43ff0c18 398 * wake up affect on IDLE status bit. The user will pass in a stucture of type
mbed_official 146:f64d43ff0c18 399 * uart_idle_line_config_t.
mbed_official 146:f64d43ff0c18 400 * In some UART instances it is required that the transmitter/receiver should be disabled
mbed_official 146:f64d43ff0c18 401 * before calling this function.
mbed_official 146:f64d43ff0c18 402 * Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 403 *
mbed_official 146:f64d43ff0c18 404 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 405 void uart_hal_configure_idle_line_detect(uint32_t uartInstance,
mbed_official 146:f64d43ff0c18 406 const uart_idle_line_config_t *config)
mbed_official 146:f64d43ff0c18 407 {
mbed_official 146:f64d43ff0c18 408 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 409
mbed_official 146:f64d43ff0c18 410 /* Configure the idle line detection configuration as follows:
mbed_official 146:f64d43ff0c18 411 * configure the ILT to bit count after start bit or stop bit
mbed_official 146:f64d43ff0c18 412 * configure RWUID to set or not set IDLE status bit upon detection of
mbed_official 146:f64d43ff0c18 413 * an idle character when recevier in standby
mbed_official 146:f64d43ff0c18 414 */
mbed_official 146:f64d43ff0c18 415 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 416 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 417 {
mbed_official 146:f64d43ff0c18 418 BW_UART0_C1_ILT(config->idleLineType);
mbed_official 146:f64d43ff0c18 419 BW_UART0_S2_RWUID(config->rxWakeIdleDetect);
mbed_official 146:f64d43ff0c18 420 }
mbed_official 146:f64d43ff0c18 421 else
mbed_official 146:f64d43ff0c18 422 #endif
mbed_official 146:f64d43ff0c18 423 {
mbed_official 146:f64d43ff0c18 424 BW_UART_C1_ILT(uartInstance, config->idleLineType);
mbed_official 146:f64d43ff0c18 425 BW_UART_S2_RWUID(uartInstance, config->rxWakeIdleDetect);
mbed_official 146:f64d43ff0c18 426 }
mbed_official 146:f64d43ff0c18 427 }
mbed_official 146:f64d43ff0c18 428
mbed_official 146:f64d43ff0c18 429 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 430 *
mbed_official 146:f64d43ff0c18 431 * Function Name : uart_hal_set_break_char_transmit_length
mbed_official 146:f64d43ff0c18 432 * Description : Configure the UART break character transmit length.
mbed_official 146:f64d43ff0c18 433 * This function allows the user to configure the UART break character transmit length. Refer to
mbed_official 146:f64d43ff0c18 434 * the typedef uart_break_char_length_t for setting options.
mbed_official 146:f64d43ff0c18 435 * In some UART instances it is required that the transmitter should be disabled before calling
mbed_official 146:f64d43ff0c18 436 * this function. Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 437 *
mbed_official 146:f64d43ff0c18 438 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 439 void uart_hal_set_break_char_transmit_length(uint32_t uartInstance,
mbed_official 146:f64d43ff0c18 440 uart_break_char_length_t length)
mbed_official 146:f64d43ff0c18 441 {
mbed_official 146:f64d43ff0c18 442 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 443
mbed_official 146:f64d43ff0c18 444 /* Configure BRK13 - Break Character transmit length configuration
mbed_official 146:f64d43ff0c18 445 * UART break character length setting:
mbed_official 146:f64d43ff0c18 446 * 0 - minimum 10-bit times (default),
mbed_official 146:f64d43ff0c18 447 * 1 - minimum 13-bit times
mbed_official 146:f64d43ff0c18 448 */
mbed_official 146:f64d43ff0c18 449 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 450 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 451 {
mbed_official 146:f64d43ff0c18 452 BW_UART0_S2_BRK13(length);
mbed_official 146:f64d43ff0c18 453 }
mbed_official 146:f64d43ff0c18 454 else
mbed_official 146:f64d43ff0c18 455 #endif
mbed_official 146:f64d43ff0c18 456 {
mbed_official 146:f64d43ff0c18 457 BW_UART_S2_BRK13(uartInstance, length);
mbed_official 146:f64d43ff0c18 458 }
mbed_official 146:f64d43ff0c18 459 }
mbed_official 146:f64d43ff0c18 460
mbed_official 146:f64d43ff0c18 461 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 462 *
mbed_official 146:f64d43ff0c18 463 * Function Name : uart_hal_set_break_char_detect_length
mbed_official 146:f64d43ff0c18 464 * Description : Configure the UART break character detect length.
mbed_official 146:f64d43ff0c18 465 * This function allows the user to configure the UART break character detect length. Refer to
mbed_official 146:f64d43ff0c18 466 * the typedef uart_break_char_length_t for setting options.
mbed_official 146:f64d43ff0c18 467 *
mbed_official 146:f64d43ff0c18 468 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 469 void uart_hal_set_break_char_detect_length(uint32_t uartInstance, uart_break_char_length_t length)
mbed_official 146:f64d43ff0c18 470 {
mbed_official 146:f64d43ff0c18 471 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 472
mbed_official 146:f64d43ff0c18 473 /* Configure LBKDE - Break Character detect length configuration
mbed_official 146:f64d43ff0c18 474 * UART break character length setting:
mbed_official 146:f64d43ff0c18 475 * 0 - minimum 10-bit times (default),
mbed_official 146:f64d43ff0c18 476 * 1 - minimum 13-bit times
mbed_official 146:f64d43ff0c18 477 */
mbed_official 146:f64d43ff0c18 478 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 479 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 480 {
mbed_official 146:f64d43ff0c18 481 BW_UART0_S2_LBKDE(length);
mbed_official 146:f64d43ff0c18 482 }
mbed_official 146:f64d43ff0c18 483 else
mbed_official 146:f64d43ff0c18 484 #endif
mbed_official 146:f64d43ff0c18 485 {
mbed_official 146:f64d43ff0c18 486 BW_UART_S2_LBKDE(uartInstance, length);
mbed_official 146:f64d43ff0c18 487 }
mbed_official 146:f64d43ff0c18 488 }
mbed_official 146:f64d43ff0c18 489
mbed_official 146:f64d43ff0c18 490 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 491 *
mbed_official 146:f64d43ff0c18 492 * Function Name : uart_hal_queue_break_char_to_send
mbed_official 146:f64d43ff0c18 493 * Description : Configure the UART transmit send break character operation.
mbed_official 146:f64d43ff0c18 494 * This function allows the user to queue a UART break character to send. If true is passed into
mbed_official 146:f64d43ff0c18 495 * the function, then a break character will be queued for transmission. A break character will
mbed_official 146:f64d43ff0c18 496 * continuously be queued until this function is called again with a false is passed into this
mbed_official 146:f64d43ff0c18 497 * function.
mbed_official 146:f64d43ff0c18 498 *
mbed_official 146:f64d43ff0c18 499 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 500 void uart_hal_queue_break_char_to_send(uint32_t uartInstance, bool enable)
mbed_official 146:f64d43ff0c18 501 {
mbed_official 146:f64d43ff0c18 502 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 503
mbed_official 146:f64d43ff0c18 504 /* Configure SBK - Send Break
mbed_official 146:f64d43ff0c18 505 * UART send break character setting:
mbed_official 146:f64d43ff0c18 506 * 0 - normal transmitter operation,
mbed_official 146:f64d43ff0c18 507 * 1 - Queue break character(s) to be sent
mbed_official 146:f64d43ff0c18 508 */
mbed_official 146:f64d43ff0c18 509 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 510 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 511 {
mbed_official 146:f64d43ff0c18 512 BW_UART0_C2_SBK(enable);
mbed_official 146:f64d43ff0c18 513 }
mbed_official 146:f64d43ff0c18 514 else
mbed_official 146:f64d43ff0c18 515 #endif
mbed_official 146:f64d43ff0c18 516 {
mbed_official 146:f64d43ff0c18 517 /* in addition to queuing a break char to send, this function also clears the
mbed_official 146:f64d43ff0c18 518 * transmit complete status flag
mbed_official 146:f64d43ff0c18 519 * for this uart instance, there is a two step process to
mbed_official 146:f64d43ff0c18 520 * clear the transmit complete status flag:
mbed_official 146:f64d43ff0c18 521 * 1. Read the status register with the status bit set
mbed_official 146:f64d43ff0c18 522 * 2. queue a break character
mbed_official 146:f64d43ff0c18 523 * first read the status register
mbed_official 146:f64d43ff0c18 524 * no need to store the read value, it's assumed the status bit is set
mbed_official 146:f64d43ff0c18 525 */
mbed_official 146:f64d43ff0c18 526 HW_UART_S1_RD(uartInstance);
mbed_official 146:f64d43ff0c18 527 /* second, queue a break character */
mbed_official 146:f64d43ff0c18 528 BW_UART_C2_SBK(uartInstance, enable);
mbed_official 146:f64d43ff0c18 529 }
mbed_official 146:f64d43ff0c18 530 }
mbed_official 146:f64d43ff0c18 531
mbed_official 146:f64d43ff0c18 532 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 533 *
mbed_official 146:f64d43ff0c18 534 * Function Name : uart_hal_configure_match_address_operation
mbed_official 146:f64d43ff0c18 535 * Description : Configure the UART match address mode control operation. (Note: Feature
mbed_official 146:f64d43ff0c18 536 * available on select UART instances)
mbed_official 146:f64d43ff0c18 537 * The function allows the user to configure the UART match address control operation. The user
mbed_official 146:f64d43ff0c18 538 * has the option to enable the match address mode and to program the match address value. There
mbed_official 146:f64d43ff0c18 539 * are two match address modes, each with it's own enable and programmable match address value.
mbed_official 146:f64d43ff0c18 540 *
mbed_official 146:f64d43ff0c18 541 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 542 uart_status_t uart_hal_configure_match_address_operation
mbed_official 146:f64d43ff0c18 543 (
mbed_official 146:f64d43ff0c18 544 uint32_t uartInstance,
mbed_official 146:f64d43ff0c18 545 bool matchAddrMode1,
mbed_official 146:f64d43ff0c18 546 bool matchAddrMode2,
mbed_official 146:f64d43ff0c18 547 uint8_t matchAddrValue1,
mbed_official 146:f64d43ff0c18 548 uint8_t matchAddrValue2)
mbed_official 146:f64d43ff0c18 549 {
mbed_official 146:f64d43ff0c18 550 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 551
mbed_official 146:f64d43ff0c18 552 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 553 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 554 {
mbed_official 146:f64d43ff0c18 555 BW_UART0_C4_MAEN1(matchAddrMode1); /* Match Address Mode Enable 1 */
mbed_official 146:f64d43ff0c18 556 BW_UART0_C4_MAEN2(matchAddrMode2); /* Match Address Mode Enable 2 */
mbed_official 146:f64d43ff0c18 557 HW_UART0_MA1_WR(matchAddrValue1); /* match address register 1 */
mbed_official 146:f64d43ff0c18 558 HW_UART0_MA2_WR(matchAddrValue2); /* match address register 2 */
mbed_official 146:f64d43ff0c18 559 }
mbed_official 146:f64d43ff0c18 560 else
mbed_official 146:f64d43ff0c18 561 {
mbed_official 146:f64d43ff0c18 562 /* unsupported feature of this instance number, return error code */
mbed_official 146:f64d43ff0c18 563 return kStatus_UART_InvalidInstanceNumber;
mbed_official 146:f64d43ff0c18 564 }
mbed_official 146:f64d43ff0c18 565 #else
mbed_official 146:f64d43ff0c18 566 BW_UART_C4_MAEN1(uartInstance, matchAddrMode1); /* Match Address Mode Enable 1 */
mbed_official 146:f64d43ff0c18 567 BW_UART_C4_MAEN2(uartInstance, matchAddrMode2); /* Match Address Mode Enable 2 */
mbed_official 146:f64d43ff0c18 568 HW_UART_MA1_WR(uartInstance, matchAddrValue1); /* match address register 1 */
mbed_official 146:f64d43ff0c18 569 HW_UART_MA2_WR(uartInstance, matchAddrValue2); /* match address register 2 */
mbed_official 146:f64d43ff0c18 570 #endif
mbed_official 146:f64d43ff0c18 571
mbed_official 146:f64d43ff0c18 572 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 573 }
mbed_official 146:f64d43ff0c18 574
mbed_official 146:f64d43ff0c18 575 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 576 *
mbed_official 146:f64d43ff0c18 577 * Function Name : uart_hal_configure_send_msb_first_operation
mbed_official 146:f64d43ff0c18 578 * Description : Configre the UART to send data MSB first
mbed_official 146:f64d43ff0c18 579 * (Note: Feature available on select UART instances)
mbed_official 146:f64d43ff0c18 580 * The function allows the user to configure the UART to send data MSB first or LSB first.
mbed_official 146:f64d43ff0c18 581 * In some UART instances it is required that the transmitter/receiver should be disabled
mbed_official 146:f64d43ff0c18 582 * before calling this function.
mbed_official 146:f64d43ff0c18 583 * Generally this may be applied to all UARTs to ensure safe operation.
mbed_official 146:f64d43ff0c18 584 *
mbed_official 146:f64d43ff0c18 585 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 586 uart_status_t uart_hal_configure_send_msb_first_operation(uint32_t uartInstance, bool enable)
mbed_official 146:f64d43ff0c18 587 {
mbed_official 146:f64d43ff0c18 588 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 589
mbed_official 146:f64d43ff0c18 590 #if FSL_FEATURE_UART_HAS_LOW_POWER_UART_SUPPORT
mbed_official 146:f64d43ff0c18 591 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 592 {
mbed_official 146:f64d43ff0c18 593 /* Setting this bit reverses the order of the bits that are
mbed_official 146:f64d43ff0c18 594 * transmitted and received on the wire.
mbed_official 146:f64d43ff0c18 595 */
mbed_official 146:f64d43ff0c18 596 BW_UART0_S2_MSBF(enable);
mbed_official 146:f64d43ff0c18 597 }
mbed_official 146:f64d43ff0c18 598 else
mbed_official 146:f64d43ff0c18 599 {
mbed_official 146:f64d43ff0c18 600 /* unsupported feature of this instance number, return error code */
mbed_official 146:f64d43ff0c18 601 return kStatus_UART_MSBFirstNotSupported;
mbed_official 146:f64d43ff0c18 602 }
mbed_official 146:f64d43ff0c18 603 #else
mbed_official 146:f64d43ff0c18 604
mbed_official 146:f64d43ff0c18 605 BW_UART_S2_MSBF(uartInstance, enable);
mbed_official 146:f64d43ff0c18 606
mbed_official 146:f64d43ff0c18 607 #endif
mbed_official 146:f64d43ff0c18 608
mbed_official 146:f64d43ff0c18 609 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 610 }
mbed_official 146:f64d43ff0c18 611
mbed_official 146:f64d43ff0c18 612 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 613 *
mbed_official 146:f64d43ff0c18 614 * Function Name : uart_hal_configure_receive_resync_disable_operation
mbed_official 146:f64d43ff0c18 615 * Description : Configuration option to disable the UART resynchronization during received data.
mbed_official 146:f64d43ff0c18 616 * (Note: Feature available on select UART instances)
mbed_official 146:f64d43ff0c18 617 * This function allows the user to disable the UART resync of received data. The default setting
mbed_official 146:f64d43ff0c18 618 * of this is false meaning that resynchronization during the received data word is supported.
mbed_official 146:f64d43ff0c18 619 * If the user passes in true, this disables resynchronization during the received data word.
mbed_official 146:f64d43ff0c18 620 *
mbed_official 146:f64d43ff0c18 621 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 622 uart_status_t uart_hal_configure_receive_resync_disable_operation(uint32_t uartInstance,
mbed_official 146:f64d43ff0c18 623 bool enable)
mbed_official 146:f64d43ff0c18 624 {
mbed_official 146:f64d43ff0c18 625 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 626
mbed_official 146:f64d43ff0c18 627 #if FSL_FEATURE_UART_HAS_RX_RESYNC_SUPPORT
mbed_official 146:f64d43ff0c18 628 if (uartInstance == 0)
mbed_official 146:f64d43ff0c18 629 {
mbed_official 146:f64d43ff0c18 630 /* When set, disables the resynchronization of the received data word when a data
mbed_official 146:f64d43ff0c18 631 * one followed by data zero transition is detected. This bit should only be changed
mbed_official 146:f64d43ff0c18 632 * when the receiver is disabled.
mbed_official 146:f64d43ff0c18 633 */
mbed_official 146:f64d43ff0c18 634 BW_UART0_C5_RESYNCDIS(enable);
mbed_official 146:f64d43ff0c18 635
mbed_official 146:f64d43ff0c18 636 return kStatus_UART_Success;
mbed_official 146:f64d43ff0c18 637 }
mbed_official 146:f64d43ff0c18 638 else
mbed_official 146:f64d43ff0c18 639 #endif
mbed_official 146:f64d43ff0c18 640 {
mbed_official 146:f64d43ff0c18 641 /* unsupported feature of this instance number, return error code */
mbed_official 146:f64d43ff0c18 642 return kStatus_UART_ResyncNotSupported;
mbed_official 146:f64d43ff0c18 643 }
mbed_official 146:f64d43ff0c18 644 }
mbed_official 146:f64d43ff0c18 645
mbed_official 146:f64d43ff0c18 646 #if FSL_FEATURE_UART_HAS_MODEM_SUPPORT
mbed_official 146:f64d43ff0c18 647 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 648 *
mbed_official 146:f64d43ff0c18 649 * Function Name : uart_hal_enable_receiver_rts
mbed_official 146:f64d43ff0c18 650 * Description : Enable the UART receiver request-to-send functionality.
mbed_official 146:f64d43ff0c18 651 * This function allows the user to enable the UART receiver request-to-send (RTS) functionality.
mbed_official 146:f64d43ff0c18 652 * By enabling, it allows the RTS output to control the CTS input of the transmitting device to
mbed_official 146:f64d43ff0c18 653 * prevent receiver overrun. RTS is deasserted if the number of characters in the receiver data
mbed_official 146:f64d43ff0c18 654 * register (FIFO) is equal to or greater than RWFIFO[RXWATER]. RTS is asserted when the
mbed_official 146:f64d43ff0c18 655 * number of characters in the receiver data register (FIFO) is less than RWFIFO[RXWATER].
mbed_official 146:f64d43ff0c18 656 * Do not set both RXRTSE and TXRTSE.
mbed_official 146:f64d43ff0c18 657 *
mbed_official 146:f64d43ff0c18 658 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 659 void uart_hal_enable_receiver_rts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 660 {
mbed_official 146:f64d43ff0c18 661 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 662
mbed_official 146:f64d43ff0c18 663 /* Set RXRTSE */
mbed_official 146:f64d43ff0c18 664 HW_UART_MODEM_SET(uartInstance, BM_UART_MODEM_RXRTSE);
mbed_official 146:f64d43ff0c18 665 }
mbed_official 146:f64d43ff0c18 666
mbed_official 146:f64d43ff0c18 667 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 668 *
mbed_official 146:f64d43ff0c18 669 * Function Name : uart_hal_disable_receiver_rts
mbed_official 146:f64d43ff0c18 670 * Description : Disable the UART receiver request-to-send functionality.
mbed_official 146:f64d43ff0c18 671 * This function allows the user to disable the UART receiver request-to-send (RTS) functionality.
mbed_official 146:f64d43ff0c18 672 *
mbed_official 146:f64d43ff0c18 673 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 674 void uart_hal_disable_receiver_rts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 675 {
mbed_official 146:f64d43ff0c18 676 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 677
mbed_official 146:f64d43ff0c18 678 /* Clear RXRTSE */
mbed_official 146:f64d43ff0c18 679 HW_UART_MODEM_CLR(uartInstance, BM_UART_MODEM_RXRTSE);
mbed_official 146:f64d43ff0c18 680 }
mbed_official 146:f64d43ff0c18 681
mbed_official 146:f64d43ff0c18 682 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 683 *
mbed_official 146:f64d43ff0c18 684 * Function Name : uart_hal_enable_transmitter_rts
mbed_official 146:f64d43ff0c18 685 * Description : Enable the UART transmitter request-to-send functionality.
mbed_official 146:f64d43ff0c18 686 * This function allows the user to enable the UART transmitter request-to-send (RTS) functionality.
mbed_official 146:f64d43ff0c18 687 * When enabled, it allows the UART to control the RTS assertion before and after a transmission
mbed_official 146:f64d43ff0c18 688 * such that when a character is placed into an empty transmitter data buffer , RTS
mbed_official 146:f64d43ff0c18 689 * asserts one bit time before the start bit is transmitted. RTS deasserts one bit time after all
mbed_official 146:f64d43ff0c18 690 * characters in the transmitter data buffer and shift register are completely sent, including
mbed_official 146:f64d43ff0c18 691 * the last stop bit.
mbed_official 146:f64d43ff0c18 692 *
mbed_official 146:f64d43ff0c18 693 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 694 void uart_hal_enable_transmitter_rts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 695 {
mbed_official 146:f64d43ff0c18 696 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 697
mbed_official 146:f64d43ff0c18 698 /* Set TXRTSE */
mbed_official 146:f64d43ff0c18 699 HW_UART_MODEM_SET(uartInstance, BM_UART_MODEM_TXRTSE);
mbed_official 146:f64d43ff0c18 700 }
mbed_official 146:f64d43ff0c18 701
mbed_official 146:f64d43ff0c18 702 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 703 *
mbed_official 146:f64d43ff0c18 704 * Function Name : uart_hal_disable_transmitter_rts
mbed_official 146:f64d43ff0c18 705 * Description : Disable the UART transmitter request-to-send functionality.
mbed_official 146:f64d43ff0c18 706 * This function allows the user to disable the UART transmitter request-to-send (RTS)
mbed_official 146:f64d43ff0c18 707 * functionality.
mbed_official 146:f64d43ff0c18 708 *
mbed_official 146:f64d43ff0c18 709 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 710 void uart_hal_disable_transmitter_rts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 711 {
mbed_official 146:f64d43ff0c18 712 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 713
mbed_official 146:f64d43ff0c18 714 /* Clear TXRTSE */
mbed_official 146:f64d43ff0c18 715 HW_UART_MODEM_CLR(uartInstance, BM_UART_MODEM_TXRTSE);
mbed_official 146:f64d43ff0c18 716 }
mbed_official 146:f64d43ff0c18 717
mbed_official 146:f64d43ff0c18 718 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 719 *
mbed_official 146:f64d43ff0c18 720 * Function Name : uart_hal_configure_transmitter_rts_polarity
mbed_official 146:f64d43ff0c18 721 * Description : Configure the UART transmitter RTS polarity.
mbed_official 146:f64d43ff0c18 722 * This function allows the user configure the transmitter RTS polarity to be either active low
mbed_official 146:f64d43ff0c18 723 * or active high.
mbed_official 146:f64d43ff0c18 724 *
mbed_official 146:f64d43ff0c18 725 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 726 void uart_hal_configure_transmitter_rts_polarity(uint32_t uartInstance, bool polarity)
mbed_official 146:f64d43ff0c18 727 {
mbed_official 146:f64d43ff0c18 728 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 729
mbed_official 146:f64d43ff0c18 730 /* Configure the transmitter rts polarity: 0=active low, 1=active high */
mbed_official 146:f64d43ff0c18 731 BW_UART_MODEM_TXRTSPOL(uartInstance, polarity);
mbed_official 146:f64d43ff0c18 732 }
mbed_official 146:f64d43ff0c18 733
mbed_official 146:f64d43ff0c18 734 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 735 *
mbed_official 146:f64d43ff0c18 736 * Function Name : uart_hal_enable_transmitter_cts
mbed_official 146:f64d43ff0c18 737 * Description : Enable the UART transmitter clear-to-send functionality.
mbed_official 146:f64d43ff0c18 738 * This function allows the user to enable the UART transmitter clear-to-send (CTS) functionality.
mbed_official 146:f64d43ff0c18 739 * When enabled, he transmitter checks the state of CTS each time it is ready to send a character.
mbed_official 146:f64d43ff0c18 740 * If CTS is asserted, the character is sent. If CTS is deasserted, the signal TXD remains in
mbed_official 146:f64d43ff0c18 741 * the mark state and transmission is delayed until CTS is asserted. Changes in CTS as a
mbed_official 146:f64d43ff0c18 742 * character is being sent do not affect its transmission.
mbed_official 146:f64d43ff0c18 743 *
mbed_official 146:f64d43ff0c18 744 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 745 void uart_hal_enable_transmitter_cts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 746 {
mbed_official 146:f64d43ff0c18 747 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 748
mbed_official 146:f64d43ff0c18 749 /* Set TXCTSE */
mbed_official 146:f64d43ff0c18 750 HW_UART_MODEM_SET(uartInstance, BM_UART_MODEM_TXCTSE);
mbed_official 146:f64d43ff0c18 751 }
mbed_official 146:f64d43ff0c18 752
mbed_official 146:f64d43ff0c18 753 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 754 *
mbed_official 146:f64d43ff0c18 755 * Function Name : uart_hal_disable_transmitter_cts
mbed_official 146:f64d43ff0c18 756 * Description : Disable the UART transmitter clear-to-send functionality.
mbed_official 146:f64d43ff0c18 757 * This function allows the user to disable the UART transmitter clear-to-send (CTS)
mbed_official 146:f64d43ff0c18 758 * functionality.
mbed_official 146:f64d43ff0c18 759 *
mbed_official 146:f64d43ff0c18 760 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 761 void uart_hal_disable_transmitter_cts(uint32_t uartInstance)
mbed_official 146:f64d43ff0c18 762 {
mbed_official 146:f64d43ff0c18 763 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 764
mbed_official 146:f64d43ff0c18 765 /* Clear TXCTSE */
mbed_official 146:f64d43ff0c18 766 HW_UART_MODEM_CLR(uartInstance, BM_UART_MODEM_TXCTSE);
mbed_official 146:f64d43ff0c18 767 }
mbed_official 146:f64d43ff0c18 768 #endif /* FSL_FEATURE_UART_HAS_MODEM_SUPPORT */
mbed_official 146:f64d43ff0c18 769
mbed_official 146:f64d43ff0c18 770 #if FSL_FEATURE_UART_HAS_IR_SUPPORT
mbed_official 146:f64d43ff0c18 771 /*FUNCTION**********************************************************************
mbed_official 146:f64d43ff0c18 772 *
mbed_official 146:f64d43ff0c18 773 * Function Name : uart_hal_configure_infrared_operation
mbed_official 146:f64d43ff0c18 774 * Description : Configure the UART infrared operation.
mbed_official 146:f64d43ff0c18 775 * The function allows the user to enable or disable the UART infrared (IR) operation
mbed_official 146:f64d43ff0c18 776 * and to configure the IR pulse width.
mbed_official 146:f64d43ff0c18 777 *
mbed_official 146:f64d43ff0c18 778 *END**************************************************************************/
mbed_official 146:f64d43ff0c18 779 void uart_hal_configure_infrared_operation(uint32_t uartInstance, bool enable,
mbed_official 146:f64d43ff0c18 780 uart_ir_tx_pulsewidth_t pulseWidth)
mbed_official 146:f64d43ff0c18 781 {
mbed_official 146:f64d43ff0c18 782 assert(uartInstance < UART_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 783
mbed_official 146:f64d43ff0c18 784 /* enable or disable infrared */
mbed_official 146:f64d43ff0c18 785 BW_UART_IR_IREN(uartInstance, enable);
mbed_official 146:f64d43ff0c18 786
mbed_official 146:f64d43ff0c18 787 /* configure the narrow pulse width of the IR pulse */
mbed_official 146:f64d43ff0c18 788 BW_UART_IR_TNP(uartInstance, pulseWidth);
mbed_official 146:f64d43ff0c18 789 }
mbed_official 146:f64d43ff0c18 790 #endif /* FSL_FEATURE_UART_HAS_IR_SUPPORT */
mbed_official 146:f64d43ff0c18 791
mbed_official 146:f64d43ff0c18 792 /*******************************************************************************
mbed_official 146:f64d43ff0c18 793 * EOF
mbed_official 146:f64d43ff0c18 794 ******************************************************************************/
mbed_official 146:f64d43ff0c18 795