| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Typedefs | Functions
Uart_driver

## Data Structures
struct | UartState
| Runtime state of the UART driver. More...
struct | UartUserConfig
| User configuration structure for UART driver. More...

## Macros
#define | UART_PEX_WRITE_EVENT_SUCCESS (1)
#define | UART_PEX_WRITE_EVENT_ERROR (UART_PEX_WRITE_EVENT_SUCCESS << 1)
#define | UART_PEX_READ_EVENT_SUCCESS (UART_PEX_WRITE_EVENT_ERROR << 1)
#define | UART_PEX_READ_EVENT_ERROR (UART_PEX_READ_EVENT_SUCCESS << 1)

## Typedefs
typedef struct UartState | uart_state_t
| Runtime state of the UART driver. More...
typedef struct UartUserConfig | uart_user_config_t
| User configuration structure for UART driver. More...

## Functions
uart_status_t | uart_init (uint32_t uartInstance, uart_state_t *uartState, const uart_user_config_t *uartUserConfig)
| This function initializes a UART instance for operation. More...
uart_status_t | uart_send_data (uart_state_t *uartState, const uint8_t *sendBuffer, uint32_t txByteCount, uint32_t timeout)
| This function sends (transmits) data out through the UART module using a blocking method. More...
uart_status_t | uart_send_data_async (uart_state_t *uartState, const uint8_t *sendBuffer, uint32_t txByteCount)
| This function sends (transmits) data through the UART module using a non-blocking method. More...
uart_status_t | uart_get_transmit_status (uart_state_t *uartState, uint32_t *bytesTransmitted)
| This function returns whether the previous UART transmit has finished. More...
uart_status_t | uart_get_receive_status (uart_state_t *uartState, uint32_t *bytesReceived)
| This function returns whether the previous UART receive is complete. More...
uart_status_t | uart_receive_data (uart_state_t *uartState, uint8_t *rxBuffer, uint32_t requestedByteCount, uint32_t timeout)
| This function gets (receives) data from the UART module using a blocking method. More...
uart_status_t | uart_receive_data_async (uart_state_t *uartState, uint8_t *rxBuffer, uint32_t requestedByteCount)
| This function gets (receives) data from the UART module using a non-blocking method. More...

## Detailed Description

## Macro Definition Documentation

#define UART_PEX_READ_EVENT_ERROR (UART_PEX_READ_EVENT_SUCCESS << 1)

Definition at line 49 of file fsl_uart_driver.h.

Referenced by uart_receive_data().

#define UART_PEX_READ_EVENT_SUCCESS (UART_PEX_WRITE_EVENT_ERROR << 1)

Definition at line 48 of file fsl_uart_driver.h.

Referenced by Serial_ISF_UART1_OnBlockReceived(), and uart_receive_data().

#define UART_PEX_WRITE_EVENT_ERROR (UART_PEX_WRITE_EVENT_SUCCESS << 1)

Definition at line 47 of file fsl_uart_driver.h.

Referenced by uart_send_data().

#define UART_PEX_WRITE_EVENT_SUCCESS (1)

Definition at line 46 of file fsl_uart_driver.h.

Referenced by Serial_ISF_UART1_OnBlockSent(), and uart_send_data().

## Typedef Documentation

typedef struct UartState uart_state_t

Runtime state of the UART driver.

This struct holds data that are used by the UART peripheral driver to communicate between the transfer function and the interrupt handler. The interrupt handler also uses this information to keep track of its progress. The user is only responsible to pass in the memory for this run-time state structure where the UART driver will take care of filling out the members.

typedef struct UartUserConfig uart_user_config_t

User configuration structure for UART driver.

Use an instance of this struct with uart_init(). This allows you to configure the most common settings of the UART peripheral with a single function call. Settings include: UART baud rate; UART parity mode: disabled (default), or even or odd; the number of stop bits; the number of bits per data word.

## Function Documentation

uart_status_t uart_get_receive_status | ( | uart_state_t * | uartState,
|  | uint32_t * | bytesReceived
| ) |  |

This function returns whether the previous UART receive is complete.

When performing an async receive, the user can call this function to ascertain the state of the current receive progress: in progress (or busy) or complete (success). In addition, if the receive is still in progress, the user can obtain the number of words that have been currently received.

Parameters

  uartState | A pointer to the UART driver state structure.
  bytesReceived | A pointer to a value that is filled in with the number of bytes which are received in the active transfer.

Return values

  kStatus_UART_Success | The receive has completed successfully.
  kStatus_UART_RxBusy | The receive is still in progress. bytesReceived is filled with the number of bytes which are received up to that point.

uart_status_t uart_get_transmit_status | ( | uart_state_t * | uartState,
|  | uint32_t * | bytesTransmitted
| ) |  |

This function returns whether the previous UART transmit has finished.

When performing an async transmit, the user can call this function to ascertain the state of the current transmission: in progress (or busy) or complete (success). In addition, if the transmission is still in progress, the user can obtain the number of words that have been currently transferred.

Parameters

  uartState | A pointer to the UART driver state structure.
  bytesTransmitted | A pointer to a value that is filled in with the number of bytes that are sent in the active transfer.

Return values

  kStatus_UART_Success | The transmit has completed successfully.
  kStatus_UART_TxBusy | The transmit is still in progress. bytesTransmitted is filled with the number of bytes which are transmitted up to that point.

uart_status_t uart_init | ( | uint32_t | uartInstance,
|  | uart_state_t * | uartState,
|  | const uart_user_config_t * | uartUserConfig
| ) |  |

This function initializes a UART instance for operation.

This function will initialize the run-time state structure to keep track of the on-going transfers, ungate the clock to the UART module, initialize the module to user defined settings and default settings, configure the IRQ state structure and enable the module-level interrupt to the core, and enable the UART module transmitter and receiver. The following is an example of how to set up the uart_state_t and the uart_user_config_t parameters and how to call the uart_init function by passing in these parameters:

1 uart_user_config_t uartConfig;
2 uartConfig.baudRate = 9600;
3 uartConfig.bitCountPerChar = kUart8BitsPerChar;
4 uartConfig.parityMode = kUartParityDisabled;
5 uartConfig.stopBitCount = kUartOneStopBit;
6 uart_state_t uartState;
7 uart_init(uartInstance, &uartState, &uartConfig);

Parameters

  uartInstance | The UART module instance number.
  uartState | A pointer to the UART driver state structure memory. The user is only responsible to pass in the memory for this run-time state structure where the UART driver will take care of filling out the members. This run-time state structure keeps track of the current transfer in progress.
  uartUserConfig | The user configuration structure of type uart_user_config_t. The user is responsbile to fill out the members of this structure and to pass the pointer of this struct into this function.

Returns
  An error code or kStatus_UART_Success.

Definition at line 41 of file fsl_uart_driver.c.

References uart_instance_PEx::fnUARTLLDInit, gSys_NumUARTBuses, UartState::instance, kStatus_UART_InvalidInstanceNumber, kStatus_UART_Success, UartState::pDeviceHandle, and UartState::uartEventHandler.

Referenced by uart_adapter_init().

Here is the caller graph for this function:

uart_status_t uart_receive_data | ( | uart_state_t * | uartState,
|  | uint8_t * | rxBuffer,
|  | uint32_t | requestedByteCount,
|  | uint32_t | timeout
| ) |  |

This function gets (receives) data from the UART module using a blocking method.

A blocking (also known as synchronous) function means that the function does not return until the receive is complete. This blocking function is used to send data through the UART port.

Parameters

  uartState | A pointer to the UART driver state structure.
  rxBuffer | A pointer to the buffer containing 8-bit read data chars received.
  requestedByteCount | The number of bytes to receive.
  timeout | A timeout value for RTOS abstraction sync control in milli-seconds (ms).

Returns
  An error code or kStatus_UART_Success.

Definition at line 102 of file fsl_uart_driver.c.

References FALSE, uart_instance_PEx::fnUARTCLLDRead, gSys_NumUARTBuses, UartState::instance, kStatus_UART_Error, kStatus_UART_InvalidInstanceNumber, kStatus_UART_Success, UartState::pDeviceHandle, UART_PEX_READ_EVENT_ERROR, UART_PEX_READ_EVENT_SUCCESS, and UartState::uartEventHandler.

Referenced by uart_adapter_read().

Here is the caller graph for this function:

uart_status_t uart_receive_data_async | ( | uart_state_t * | uartState,
|  | uint8_t * | rxBuffer,
|  | uint32_t | requestedByteCount
| ) |  |

This function gets (receives) data from the UART module using a non-blocking method.

A non-blocking (also known as synchronous) function means that the function returns immediately after initiating the receive function. The application has to get the receive status to see when the receive is complete. In other words, after calling non-blocking (asynchronous) get function, the application must get the receive status to check if receive is completed or not. The asynchronous method of transmitting and receiving allows the UART to perform a full duplex operation (simultaneously transmit and receive).

Parameters

  uartState | A pointer to the UART driver state structure.
  rxBuffer | A pointer to the buffer containing 8-bit read data chars received.
  requestedByteCount | The number of bytes to receive.

Returns
  An error code or kStatus_UART_Success.

Definition at line 127 of file fsl_uart_driver.c.

References gSys_NumUARTBuses, UartState::instance, kStatus_UART_InvalidInstanceNumber, and kStatus_UART_Success.

Referenced by uart_adapter_read().

Here is the caller graph for this function:

uart_status_t uart_send_data | ( | uart_state_t * | uartState,
|  | const uint8_t * | sendBuffer,
|  | uint32_t | txByteCount,
|  | uint32_t | timeout
| ) |  |

This function sends (transmits) data out through the UART module using a blocking method.

A blocking (also known as synchronous) function means that the function does not return until the transmit is complete. This blocking function is used to send data through the UART port.

Parameters

  uartState | The UART module internal state information.
  sendBuffer | A pointer to the source buffer containing 8-bit data chars to send.
  txByteCount | The number of bytes to send.
  timeout | A timeout value for RTOS abstraction sync control in milli-seconds (ms).

Returns
  An error code or kStatus_UART_Success.

Definition at line 61 of file fsl_uart_driver.c.

References FALSE, uart_instance_PEx::fnUARTLLDWrite, gSys_NumUARTBuses, UartState::instance, kStatus_UART_Error, kStatus_UART_InvalidInstanceNumber, kStatus_UART_Success, UartState::pDeviceHandle, UART_PEX_WRITE_EVENT_ERROR, UART_PEX_WRITE_EVENT_SUCCESS, and UartState::uartEventHandler.

Referenced by uart_adapter_write().

Here is the caller graph for this function:

uart_status_t uart_send_data_async | ( | uart_state_t * | uartState,
|  | const uint8_t * | sendBuffer,
|  | uint32_t | txByteCount
| ) |  |

This function sends (transmits) data through the UART module using a non-blocking method.

A non-blocking (also known as synchronous) function means that the function returns immediately after initiating the transmit function. The application has to get the transmit status to see when the transmit is complete. In other words, after calling non-blocking (asynchronous) send function, the application must get the transmit status to check if transmit is completed or not. The asynchronous method of transmitting and receiving allows the UART to perform a full duplex operation (simultaneously transmit and receive).

Parameters

  uartState | A pointer to the UART driver state structure.
  sendBuffer | A pointer to the source buffer containing 8-bit data chars to send.
  txByteCount | The number of bytes to send.

Returns
  An error code or kStatus_UART_Success.

Definition at line 88 of file fsl_uart_driver.c.

References gSys_NumUARTBuses, UartState::instance, kStatus_UART_InvalidInstanceNumber, and kStatus_UART_Success.

Referenced by uart_adapter_write().

Here is the caller graph for this function:
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.