EFM32 Gecko Software Documentation  efm32g-doc-5.1.2
uartdrv.h File Reference

Detailed Description

UARTDRV API definition.

Version
5.1.2

License

Copyright 2016 Silicon Laboratories, Inc, http://www.silabs.com

This file is licensed under the Silabs License Agreement. See the file "Silabs_License_Agreement.txt" for details. Before using this software for any purpose, you must agree to the terms of that agreement.

Definition in file uartdrv.h.

#include "em_device.h"
#include "em_usart.h"
#include "em_leuart.h"
#include "em_gpio.h"
#include "em_cmu.h"
#include "ecode.h"
#include "uartdrv_config.h"
#include "dmadrv.h"

Go to the source code of this file.

Data Structures

struct  UARTDRV_Buffer_FifoQueue_t
 Transfer operation FIFO queue typedef. More...
 
struct  UARTDRV_Buffer_t
 UART transfer buffer. More...
 
struct  UARTDRV_HandleData
 
struct  UARTDRV_InitLeuart_t
 
struct  UARTDRV_InitUart_t
 

Macros

#define DEFINE_BUF_QUEUE(qSize, qName)
 
#define ECODE_EMDRV_UARTDRV_ABORTED   (ECODE_EMDRV_UARTDRV_BASE | 0x00000009)
 UART transfer has been aborted.
 
#define ECODE_EMDRV_UARTDRV_BUSY   (ECODE_EMDRV_UARTDRV_BASE | 0x00000004)
 The UART port is busy.
 
#define ECODE_EMDRV_UARTDRV_CLOCK_ERROR   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000F)
 Unable to set desired baudrate.
 
#define ECODE_EMDRV_UARTDRV_DMA_ALLOC_ERROR   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000E)
 Unable to allocated DMA channels.
 
#define ECODE_EMDRV_UARTDRV_FRAME_ERROR   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000D)
 UART frame error. Data is ignored.
 
#define ECODE_EMDRV_UARTDRV_IDLE   (ECODE_EMDRV_UARTDRV_BASE | 0x00000008)
 No UART transfer in progress.
 
#define ECODE_EMDRV_UARTDRV_ILLEGAL_HANDLE   (ECODE_EMDRV_UARTDRV_BASE | 0x00000002)
 Illegal UART handle.
 
#define ECODE_EMDRV_UARTDRV_ILLEGAL_OPERATION   (ECODE_EMDRV_UARTDRV_BASE | 0x00000005)
 Illegal operation on UART port.
 
#define ECODE_EMDRV_UARTDRV_OK   (ECODE_OK)
 Success return value.
 
#define ECODE_EMDRV_UARTDRV_PARAM_ERROR   (ECODE_EMDRV_UARTDRV_BASE | 0x00000003)
 Illegal input parameter.
 
#define ECODE_EMDRV_UARTDRV_PARITY_ERROR   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000C)
 UART parity error frame. Data is ignored.
 
#define ECODE_EMDRV_UARTDRV_QUEUE_EMPTY   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000B)
 UART operation queue is empty.
 
#define ECODE_EMDRV_UARTDRV_QUEUE_FULL   (ECODE_EMDRV_UARTDRV_BASE | 0x0000000A)
 UART operation queue is full.
 
#define ECODE_EMDRV_UARTDRV_WAITING   (ECODE_EMDRV_UARTDRV_BASE | 0x00000001)
 Operation is waiting in queue.
 
#define UARTDRV_STATUS_RXBLOCK   (1 << 3)
 Receiver is blocked; incoming frames will be discarded.
 
#define UARTDRV_STATUS_RXDATAV   (1 << 7)
 Data is available in receive buffer.
 
#define UARTDRV_STATUS_RXEN   (1 << 0)
 Receiver is enabled.
 
#define UARTDRV_STATUS_RXFULL   (1 << 8)
 Receive buffer is full.
 
#define UARTDRV_STATUS_TXBL   (1 << 6)
 Transmit buffer is empty.
 
#define UARTDRV_STATUS_TXC   (1 << 5)
 Transmit operation is complete, no more data is available in the transmit buffer and shift register.
 
#define UARTDRV_STATUS_TXEN   (1 << 1)
 Transmitter is enabled.
 
#define UARTDRV_STATUS_TXIDLE   (1 << 13)
 Transmitter is idle.
 
#define UARTDRV_STATUS_TXTRI   (1 << 4)
 Transmitter is tristated.
 

Typedefs

typedef enum UARTDRV_AbortType UARTDRV_AbortType_t
 Transfer abort type.
 
typedef void(* UARTDRV_Callback_t) (struct UARTDRV_HandleData *handle, Ecode_t transferStatus, uint8_t *data, UARTDRV_Count_t transferCount)
 UARTDRV transfer completion callback function. More...
 
typedef uint32_t UARTDRV_Count_t
 UART transfer count.
 
typedef enum UARTDRV_FlowControlState UARTDRV_FlowControlState_t
 Flow Control state.
 
typedef enum UARTDRV_FlowControlType UARTDRV_FlowControlType_t
 Flow Control method.
 
typedef UARTDRV_HandleData_tUARTDRV_Handle_t
 Handle pointer.
 
typedef struct UARTDRV_HandleData UARTDRV_HandleData_t
 
typedef uint32_t UARTDRV_Status_t
 UART status return type. Bitfield of UARTDRV_STATUS_* values.
 

Enumerations

enum  UARTDRV_AbortType {
  uartdrvAbortTransmit = 1,
  uartdrvAbortReceive = 2,
  uartdrvAbortAll = 3
}
 Transfer abort type. More...
 
enum  UARTDRV_FlowControlState {
  uartdrvFlowControlOn = 0,
  uartdrvFlowControlOff = 1,
  uartdrvFlowControlAuto = 2
}
 Flow Control state. More...
 
enum  UARTDRV_FlowControlType {
  uartdrvFlowControlNone = 0,
  uartdrvFlowControlSw = 1,
  uartdrvFlowControlHw = 2,
  uartdrvFlowControlHwUart = 3
}
 Flow Control method. More...
 

Functions

Ecode_t UARTDRV_Abort (UARTDRV_Handle_t handle, UARTDRV_AbortType_t type)
 Abort ongoing UART transfers. More...
 
Ecode_t UARTDRV_DeInit (UARTDRV_Handle_t handle)
 Deinitialize a UART driver instance. More...
 
UARTDRV_FlowControlState_t UARTDRV_FlowControlGetPeerStatus (UARTDRV_Handle_t handle)
 Checks the peer's flow control status. More...
 
UARTDRV_FlowControlState_t UARTDRV_FlowControlGetSelfStatus (UARTDRV_Handle_t handle)
 Checks the self's flow control status. More...
 
Ecode_t UARTDRV_FlowControlIgnoreRestrain (UARTDRV_Handle_t handle)
 Enables transmission when restrained by flow control. More...
 
Ecode_t UARTDRV_FlowControlSet (UARTDRV_Handle_t handle, UARTDRV_FlowControlState_t state)
 Set UART flow control state. Set nRTS pin if hardware flow control is enabled. Send XON/XOFF if software flow control is enabled. More...
 
Ecode_t UARTDRV_FlowControlSetPeerStatus (UARTDRV_Handle_t handle, UARTDRV_FlowControlState_t state)
 Set peer UART flow control state. Pause/resume transmit accordingly. Only for manual software flow control. More...
 
UARTDRV_Count_t UARTDRV_ForceReceive (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t maxLength)
 Direct receive without interrupts or callback. Blocking function. More...
 
Ecode_t UARTDRV_ForceTransmit (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
 Direct transmit without interrupts or callback. Blocking function that ignores flow control if enabled. More...
 
UARTDRV_Status_t UARTDRV_GetPeripheralStatus (UARTDRV_Handle_t handle)
 Returns the status of the UART peripheral associated with a given handle. More...
 
uint8_t UARTDRV_GetReceiveDepth (UARTDRV_Handle_t handle)
 Returns the number of queued receive operations. More...
 
UARTDRV_Status_t UARTDRV_GetReceiveStatus (UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *bytesReceived, UARTDRV_Count_t *bytesRemaining)
 Check the status of the UART and gather information about any ongoing receive operations. More...
 
uint8_t UARTDRV_GetTransmitDepth (UARTDRV_Handle_t handle)
 Returns the number of queued transmit operations. More...
 
UARTDRV_Status_t UARTDRV_GetTransmitStatus (UARTDRV_Handle_t handle, uint8_t **buffer, UARTDRV_Count_t *bytesSent, UARTDRV_Count_t *bytesRemaining)
 Check the status of the UART and gather information about any ongoing transmit operations. More...
 
__STATIC_INLINE Ecode_t UARTDRV_Init (UARTDRV_Handle_t handle, UARTDRV_InitUart_t *initData)
 Initialize a U(S)ART driver instance. More...
 
Ecode_t UARTDRV_InitLeuart (UARTDRV_Handle_t handle, const UARTDRV_InitLeuart_t *initData)
 Initialize a LEUART driver instance. More...
 
Ecode_t UARTDRV_InitUart (UARTDRV_Handle_t handle, const UARTDRV_InitUart_t *initData)
 Initialize a U(S)ART driver instance. More...
 
Ecode_t UARTDRV_PauseTransmit (UARTDRV_Handle_t handle)
 Pause an ongoing transmit operation. More...
 
Ecode_t UARTDRV_Receive (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count, UARTDRV_Callback_t callback)
 Start a non-blocking receive. More...
 
Ecode_t UARTDRV_ReceiveB (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
 Start a blocking receive. More...
 
Ecode_t UARTDRV_ResumeTransmit (UARTDRV_Handle_t handle)
 Resume a paused transmit operation. More...
 
Ecode_t UARTDRV_Transmit (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count, UARTDRV_Callback_t callback)
 Start a non-blocking transmit. More...
 
Ecode_t UARTDRV_TransmitB (UARTDRV_Handle_t handle, uint8_t *data, UARTDRV_Count_t count)
 Start a blocking transmit. More...