MCUSW
Loading...
Searching...
No Matches
Cdd Uart User Guide

Introduction

This document details AUTOSAR CDD UART module implementation

  • Supported AUTOSAR Release : 4.3.1
  • Supported Configuration Variants : Pre-Compile and Post-build
  • Vendor ID : CDD_UART_VENDOR_ID (44)
  • Module ID : CDD_UART_MODULE_ID (255)

The UART complex device driver provides data read and write transfer using the module unit channels in the device board. The driver is configurable for parameters such as baud rate, word length, parity, stop bits, IO mode, clock frequency, transfer and receival buffer threshold, and operating mode. Depending upon the IO Mode selected, the driver allows for both synchronous as well as asynchronous mode of data transfer.

The UART Driver provides services for reading and writing to/from

  1. UART Channels
  2. UART Ports / Serial Device

Note: This module is not applicable for MPU devices AM62X and AM62PX


Cdd Uart Driver Architecture/Design

Please refer the Cdd Uart design document, please refer to CSP.


Functional Description

Features Supported and Not Supported

Supported Not Supported
Echoing character received in both blocking and non-blocking mode External UART Handle usage
Determine UART interrupt status MODEM control functions
Enable and disable specific interrupts in mode of operation (even for IER) IrDA and CIR features
UART handle for opened UART instance Hardware Flow Control
Closing corresponding peripheral of a UART handle
Transfer Modes: Interrupt, Polling
Receiver line error status like overrun, framing
Configuring interrupts and getting event statuses

Initialization

Cdd_Uart_Init() is the function responsible for initializing driver peripheral and opening its configured instances for transmission

States

UART driver maintains these below states as per the driver source condition:

  1. CDD_UART_UNINIT
  2. CDD_UART_INIT
  3. CDD_UART_BUSY

Main Functions

  1. Cdd_Uart_Read() - This API is used for reading data using a given channel ID upto a specified length
  2. Cdd_Uart_Write() - This API is used for writing data using a given channel ID upto a specified data count
  3. Cdd_Uart_Cancel() - This API is used for cancelling an ongoing data transfer using a given channel ID in the given direction

UART API expects Channel ID which is the index of the UART instance config from the configuration.

Example:

Cdd Uart Chanel configuartion

For the above sample configuration, Index number 0 need to be provided in place of channel ID for the UART APIs to use UART3 instance. Similarly, index number 1 and 2 need to be provided in place of channel ID for the UART APIs to use UART2 and UART0 instances.

Back To Top


File Structure

The files structure for the UART driver is silimar to other drivers. The source is divided into headers under include/ and driver source within src/ directory under Uart driver path in MCAL. Cdd_Uart.c and Cdd_Uart.h are the 2 files that contain the provided driver API’s.

Cdd_Uart.h : Shall specify the interface provided by the driver. Cdd_Uart.c, Cdd_Uart_Priv.h : Shall implement the driver functionality. Cdd_Uart_Irq.h and Cdd_Uart_Irq.c : contain interrupt service routines

Back To Top


Memory Mapping

Memory Mapping Sections CDD_UART_CODE CDD_UART_CODE_ISR CDD_UART_VAR_NO_INIT CDD_UART_VAR_ZERO_INIT CDD_UART_PBCFG CDD_UART_PBCFG_ROOT
CDD_UART_START_SEC_VAR_INIT_UNSPECIFIED(.bss) CDD_UART_STOP_SEC_VAR_INIT_UNSPECIFIED X
CDD_UART_START_SEC_CODE_APPL(.text) CDD_UART_STOP_SEC_CODE_APPL X
CDD_UART_START_SEC_VAR_UNSPECIFIED(.data) CDD_UART_STOP_SEC_VAR_UNSPECIFIED X
CDD_UART_START_SEC_CODE(.text) CDD_UART_START_SEC_CODE X
CDD_UART_START_SEC_PBCFG(.data) CDD_UART_STOP_SEC_PBCFG X
CDD_UART_START_SEC_PBCFG_ROOT(.const) CDD_UART_STOP_SEC_PBCFG_ROOT X

Back To Top


Services used by UART Driver

Cdd_Uart Callback Functions

The UART driver provides read, write and error call back functions supported for all channels targeted from UART Configurator Plugin

Dependencies on SW modules

DET

The module UART depends on the DET (by default) in order to report development errors. Detection and reporting of development errors, DET shall be enabled or disabled by the switch CDD_UART_DEV_ERROR_DETECT = STD_ON in Cdd_Uart_Cfg.h, generated by using appropriate option check within the configurator plugin. The DET can be replaced optionally by an equivalent component which is responsible to recognize development errors, if no DET component is available.

SchM (Optional)

Beside the OS the BSW Scheduler provides functions that module UART calls at begin and end of critical sections.

There is only one kind of critical sections in this driver. Within these sections all read / modify / write accesses to internal UART status variables must be performed. This is defined in the application and used to handle in the UART driver by invoking SchM_Enter_Cdd_Uart_UART_EXCLUSIVE_AREA_0() and SchM_Exit_Cdd_Uart_UART_EXCLUSIVE_AREA_0() functions

Back To Top


API Definition

Supported APIs & Service Id's

Service Service ID
Cdd_Uart_Init 0x01
Cdd_Uart_GetVersionInfo 0x02
Cdd_Uart_DeInit 0x03
Cdd_Uart_Write 0x04
Cdd_Uart_Read 0x05
Cdd_Uart_Cancel 0x06
Cdd_Uart_GetRemainingWords 0x07

Interrupt Service Routines

Following Interrupt Service Routines are present in UART:

  1. Cdd_Uart_ChannelIsr - The Channel-based Interrupt Subroutine calls handler function based on the selected channel.

Error Handling

Development error reporting. The Cdd_UartDriver will report development errors on enabling UART_DEV_ERROR_DETECT == STD_ON in Cdd_Uart_Cfg.h

Refer API documentation for list of development errors reported by UART Driver

Parameter checking AUTOSAR requires that API functions check the validity of their parameters. The checks are described in spec and are done as internal parameter checks of the API functions. These checks are for development error reporting and can be en-/disabled separately. Refer to the configuration chapter where the en-/disabling of the checks is described. En-/disabling of single checks is an addition to the AUTOSAR standard which requires to en-/disable the complete parameter checking via the parameter UART_DEV_ERROR_DETECT

Production Code Error Reporting By default, production code related errors are reported to the DEM using the service DEM_SetEventStatus().

Back To Top


Configuration

UART driver supports Pre-Compile and Post-Build variant and doesn’t support Link-Time configuration.

Configurable Parameters

Cdd_Uart_TI_AM62AX/Cdd_Uart_TI_AM62DX/Cdd_Uart_TI_AM275X configurator plugin for the driver supports below configurable parameters:

  1. uartHwUnitID - UART Hardware Unit Instance number
  2. uartClockFrequency - Clock Frequency
  3. uartBaudRate - Baud Rate for signal transfer
  4. uartIOMode - IO Mode for signal transfer
  5. uartTXTriggerLevel - Trigger level for Transmission of signal
  6. uartRXTriggerLevel - Trigger level for Receival of signal
  7. uartHwFlowControlThreshold - Trigger threshold for signal flow control
  8. uartWordLength - Word Length for packets
  9. uartParity - Parity for data
  10. uartReadReturnMode - Read return mode
  11. uartOperatingMode - Mode of Operation
  12. uartStopBits - Amount of stop bits per packet
  13. uartNotificationHandlers - Notification Callback Handles for read, write completion or in case of data transfer error detection

Back To Top


Steps to Build Applications

There are two apps for cdd uart. The MCAL example application could be built with the command

AM62AX

Cdd Uart Interrupt Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_interrupt_app BOARD=am62ax_evm SOC=am62ax BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_interrupt_app BOARD=am62ax_evm SOC=am62ax BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/(SoC)_evm/cdd_uart_interrupt_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/am62ax_evm/cdd_uart_interrupt_app_mcu0_0_release.xer5f

Cdd Uart Polling Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_polling_app BOARD=am62ax_evm SOC=am62ax BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_polling_app BOARD=am62ax_evm SOC=am62ax BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/(SoC)_evm/cdd_uart_polling_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/am62ax_evm/cdd_uart_polling_app_mcu0_0_release.xer5f

AM62DX

Cdd Uart Interrupt Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_interrupt_app BOARD=am62dx_evm SOC=am62dx BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_interrupt_app BOARD=am62dx_evm SOC=am62dx BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/(SoC)_evm/cdd_uart_interrupt_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/am62dx_evm/cdd_uart_interrupt_app_mcu0_0_release.xer5f

Cdd Uart Polling Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_polling_app BOARD=am62dx_evm SOC=am62dx BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_polling_app BOARD=am62dx_evm SOC=am62dx BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/(SoC)_evm/cdd_uart_polling_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/am62dx_evm/cdd_uart_polling_app_mcu0_0_release.xer5f

AM275X

Cdd Uart Interrupt Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_interrupt_app BOARD=am275x_evm SOC=am275x BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_interrupt_app BOARD=am275x_evm SOC=am275x BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/(SoC)_evm/cdd_uart_interrupt_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_interrupt_app/bin/am275x_evm/cdd_uart_interrupt_app_mcu0_0_release.xer5f

Cdd Uart Polling Echo App

$ cd (SDK Install Directory)/mcusw.xx.yy.zz.bb/build
$ gmake -s cdd_uart_polling_app BOARD=am275x_evm SOC=am275x BUILD_PROFILE=release CORE=mcu0_0 BUILD_OS_TYPE=baremetal
$ OR
$ gmake -s cdd_uart_polling_app BOARD=am275x_evm SOC=am275x BUILD_PROFILE=debug CORE=mcu0_0 BUILD_OS_TYPE=baremetal
  • The generated executable is available at
    • (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/(SoC)_evm/cdd_uart_polling_app_mcu0_0_(BUILD_PROFILE).xer5f
    • e.g. (SDK Install Directory)/mcusw.xx.yy.zz.bb/binary/cdd_uart_polling_app/bin/am275x_evm/cdd_uart_polling_app_mcu0_0_release.xer5f

Back To Top


Example Logs

AM62AX/AM62DX - Cdd Uart Interrupt Echo App Log

    This is Uart Echo Test in Interrupt Mode
    Please input 8 characters:
    cdd_uart
    Echo has been completed.

    All tests have passed!

AM62AX/AM62DX - Cdd Uart Polling Echo App Log

    This is Uart Echo Test in Polling Mode
    Please input 8 characters:
    cdd_uart
    Echo has been completed.

    All tests have passed!

AM275X - Cdd Uart Interrupt Echo App Log

    This is Uart Echo Test in Interrupt Mode
    Please input 8 characters:
    123asert
    Echo has been completed.

    All tests have passed!

AM275X - Cdd Uart Polling Echo App Log

    This is Uart Echo Test in Polling Mode
    Please input 8 characters:
    123sdfui
    Echo has been completed.

    All tests have passed!

Back To Top