Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs_src/docs/api_guide/doxy_samples/drivers/Uart_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define CONFIG_UART0 (0U)
#define APP_UART_MSGSIZE (8U)

UART_Handle gUartHandle;
UART_Config* gUartHandle;
/* Semaphore to indicate Write/Read completion used in callback api's */
SemaphoreP_Object gUartWriteDoneSem;
SemaphoreP_Object gUartReadDoneSem;
Expand Down Expand Up @@ -80,7 +80,7 @@ void read_transfer_blocking(void)
}

//! [write_transfer_nonblocking]
void write_callback(UART_Handle handle, UART_Transaction *trans)
void write_callback(UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesWritten = trans->count;
Expand Down Expand Up @@ -118,7 +118,7 @@ void write_transfer_nonblocking(void)
//! [write_transfer_nonblocking]

//! [read_transfer_nonblocking]
void read_callback(UART_Handle handle, UART_Transaction *trans)
void read_callback(UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesRead = trans->count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void uart_echo_callback(void *args)
return;
}

void uart_echo_write_callback(UART_Handle handle, UART_Transaction *trans)
void uart_echo_write_callback(UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesWritten = trans->count;
Expand All @@ -145,7 +145,7 @@ void uart_echo_write_callback(UART_Handle handle, UART_Transaction *trans)
return;
}

void uart_echo_read_callback(UART_Handle handle, UART_Transaction *trans)
void uart_echo_read_callback(UART_Transaction *trans)
{
DebugP_assertNoLog(UART_TRANSFER_STATUS_SUCCESS == trans->status);
gNumBytesRead = trans->count;
Expand Down
2 changes: 1 addition & 1 deletion source/drivers/bootloader/bootloader_xmodem.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
int xmodemReceive(unsigned char *dest, int destsz);
int xmodemTransmit(unsigned char *src, int srcsz);

static UART_Handle gUartHandle;
static UART_Config* gUartHandle;

int32_t _inbyte(uint16_t timeout)
{
Expand Down
10 changes: 7 additions & 3 deletions source/drivers/uart/v0/lld/dma/dummy/uart_dma_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@
#define UART_DMA_H_

#include <stdint.h>
#include <drivers/uart/v0/lld/uart_lld.h>
#include <drivers/uart/v0/uart.h>

//#include <drivers/uart/v0/lld/uart_lld.h>
#ifdef __cplusplus
extern "C"
{
#endif

typedef void* UART_DmaChConfig;
typedef void* UARTLLD_Handle;
typedef void* UART_Transaction;
/** \brief Transaction success */
#define UART_STATUS_SUCCESS ((int32_t)0)

int32_t UART_lld_dmaInit(UARTLLD_Handle hUart, UART_DmaChConfig dmaChCfg)
{
return UART_STATUS_SUCCESS;
Expand Down
10 changes: 5 additions & 5 deletions source/drivers/uart/v0/lld/dma/edma/uart_dma_edma.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void UART_edmaDoNothing(Edma_IntrHandle intrHandle, void *args);
int32_t UART_lld_dmaInit(UARTLLD_Handle hUart, UART_DmaChConfig dmaChCfg)
{
int32_t status = UART_TRANSFER_STATUS_SUCCESS;
UART_EdmaChConfig *edmaChCfg = (UART_EdmaChConfig *)dmaChCfg;
UART_EdmaChConfig *edmaChCfg = dmaChCfg;

status = UART_edmaChInit(hUart, edmaChCfg);

Expand Down Expand Up @@ -237,7 +237,7 @@ int32_t UART_lld_dmaWrite(UARTLLD_Handle hUart, const UART_Transaction *transact
isTxFifoEmpty = FALSE;
isEdmaEventPending = FALSE;

edmaChCfg = (UART_EdmaChConfig *)hUart->hUartInit->dmaChCfg;
edmaChCfg = hUart->hUartInit->dmaChCfg;

/* Fetch the EDMA paramters for UART transfer */
baseAddr = edmaChCfg->edmaBaseAddr;
Expand Down Expand Up @@ -336,7 +336,7 @@ int32_t UART_lld_dmaRead(UARTLLD_Handle hUart, const UART_Transaction *transacti
EDMACCPaRAMEntry edmaRxParam;
UART_EdmaChConfig *edmaChCfg;

edmaChCfg = (UART_EdmaChConfig *)hUart->hUartInit->dmaChCfg;
edmaChCfg = hUart->hUartInit->dmaChCfg;

/* Fetch the EDMA paramters for UART transfer */
baseAddr = edmaChCfg->edmaBaseAddr;
Expand Down Expand Up @@ -415,7 +415,7 @@ int32_t UART_lld_dmaDeInit(UARTLLD_Handle hUart)
if(UART_TRANSFER_STATUS_SUCCESS == status)
{
hUartInit = hUart->hUartInit;
edmaChCfg = (UART_EdmaChConfig *)hUartInit->dmaChCfg;
edmaChCfg = hUartInit->dmaChCfg;
uartEdmaHandle = (EDMA_Handle)hUartInit->uartDmaHandle;

/* Fetch the EDMA paramters */
Expand Down Expand Up @@ -516,7 +516,7 @@ int32_t UART_lld_dmaDisableChannel(UARTLLD_Handle hUart,

if(NULL_PTR != hUart)
{
edmaChCfg = (UART_EdmaChConfig *)hUart->hUartInit->dmaChCfg;
edmaChCfg = hUart->hUartInit->dmaChCfg;

baseAddr = edmaChCfg->edmaBaseAddr;
regionId = edmaChCfg->edmaRegionId;
Expand Down
16 changes: 16 additions & 0 deletions source/drivers/uart/v0/lld/dma/edma/uart_dma_edma.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,22 @@ typedef struct UART_EdmaChConfig_s
/**< Flag to indicate whether the DMA instance is opened already */
}UART_EdmaChConfig;

/**
* \brief UART DMA Configuration, these are filled by SysCfg based on the DMA driver that is selected
*/
typedef struct UART_DmaConfig_s
{
/** Registered callbacks for a particular DMA driver. This will be set by Sysconfig depending on the DMA driver selected */
UART_EdmaChConfig *uartDmaArgs;
/** Arguments specific to a DMA driver. This will be typecasted to the specific DMA driver args struct
* when used by the appropriate callback. This struct will be defined in the specific DMA driver header file.
* Allocation of this struct will be done statically using Sysconfig code generation in the example code
*/
} UART_DmaConfig;

typedef struct UART_EdmaChConfig_s *UART_DmaChConfig;
typedef EDMA_Config *UART_DmaHandle;

#ifdef __cplusplus
}
#endif
Expand Down
160 changes: 6 additions & 154 deletions source/drivers/uart/v0/lld/dma/uart_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,166 +40,18 @@
#define UART_DMA_H_

#include <stdint.h>
#include <drivers/uart/v0/lld/uart_lld.h>
#include <drivers/uart/v0/uart.h>

#if defined(DMA_VERSION_UART_EDMA)
#include <drivers/uart/v0/lld/dma/edma/uart_dma_edma.h>
#else
#include <drivers/uart/v0/lld/dma/udma/uart_dma_udma.h>
#endif

#ifdef __cplusplus
extern "C"
{
#endif

/**
* \brief Driver implementation to open a specific DMA driver channel - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param uartHandle [in] UART Handle
* \param uartDmaArgs [in] DMA specific arguments, obtained from the config
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*UART_dmaOpenFxn)(UART_Handle uartHandle, void *uartDmaArgs);

/**
* \brief Driver implementation to do a DMA read using a specific DMA driver - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param obj [in] Pointer to UART object
* \param attrs [in] Pointer to UART attributes.
* \param transaction [in] Pointer to #UART_Transaction. This parameter can't be NULL
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*UART_dmaTransferReadFxn)(UART_Object *obj, const UART_Attrs *attrs,
UART_Transaction *transaction);

/**
* \brief Driver implementation to do a DMA write using a specific DMA driver - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param obj [in] Pointer to UART object.
* \param attrs [in] Pointer to UART attributes.
* \param transaction [in] Pointer to #UART_Transaction. This parameter can't be NULL
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*UART_dmaTransferWriteFxn)(UART_Object *obj, const UART_Attrs *attrs,
UART_Transaction *transaction);

/**
* \brief Driver implementation to close a specific DMA driver channel - UDMA, EDMA etc
*
* Typically this callback is hidden from the end application and is implemented
* when a new DMA driver needs to be supported.
*
* \param handle [in] UART handle returned from \ref UART_open
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*UART_dmaCloseFxn)(UART_Handle handle);

/**
* \brief Driver implementation to diisable a specific DMA driver channel - UDMA, EDMA etc
*
* \param handle [in] UART handle returned from \ref UART_open
* \param isChannelTx [in] Variable to indicate if it is TX/RX Channel
*
* \return SystemP_SUCCESS on success, else failure
*/
typedef int32_t (*UART_dmaDisableChannelFxn)(UART_Handle handle, uint32_t isChannelTx);

/**
* \brief Driver implementation callbacks
*/
typedef struct UART_DmaFxns_s
{
UART_dmaOpenFxn dmaOpenFxn;
UART_dmaTransferWriteFxn dmaTransferWriteFxn;
UART_dmaTransferReadFxn dmaTransferReadFxn;
UART_dmaCloseFxn dmaCloseFxn;
UART_dmaDisableChannelFxn dmaDisableChannelFxn;
} UART_DmaFxns;

/**
* \brief UART DMA Configuration, these are filled by SysCfg based on the DMA driver that is selected
*/
typedef struct UART_DmaConfig_s
{
UART_DmaFxns *fxns;
/** Registered callbacks for a particular DMA driver. This will be set by Sysconfig depending on the DMA driver selected */
void *uartDmaArgs;
/** Arguments specific to a DMA driver. This will be typecasted to the specific DMA driver args struct
* when used by the appropriate callback. This struct will be defined in the specific DMA driver header file.
* Allocation of this struct will be done statically using Sysconfig code generation in the example code
*/
} UART_DmaConfig;

/**
* \defgroup UART_DMA_LLD APIs for UART DMA mode
* \ingroup DRV_UART_LLD_MODULE
*
* This module contains APIs to program and use DMA drivers available in the SoC with UART.
*
* @{
*/

/**
* \brief API to open an UART DMA channel
*
* This API will open a DMA Channel using the appropriate DMA driver callbacks and the registered via Sysconfig
*
* \param hUart [in] UART Handle
* \param dmaChCfg [in] UART DMA Handle
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t UART_lld_dmaInit(UARTLLD_Handle hUart, UART_DmaChConfig dmaChCfg);
/**
* \brief API to close an UART DMA channel
*
* \param hUart [in] UART handle returned from \ref UART_open
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t UART_lld_dmaDeInit(UARTLLD_Handle hUart);

/**
* \brief API to write data using an UART DMA channel
*
* \param hUart [in] Pointer to UART object
* \param transaction [in] Pointer to #UART_Transaction. This parameter can't be NULL
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t UART_lld_dmaWrite(UARTLLD_Handle hUart, const UART_Transaction *transaction);

/**
* \brief API to read data using an UART DMA channel
*
* \param hUart [in] Pointer to UART object
* \param transaction [in] Pointer to #UART_Transaction. This parameter can't be NULL
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t UART_lld_dmaRead(UARTLLD_Handle hUart, const UART_Transaction *transaction);

/**
* \brief API to disable DMA channel
*
* \param hUart [in] UART Handle
* \param isChannelTx [in] Variable to hold the Tx channel
*
* \return SystemP_SUCCESS on success, else failure
*/
int32_t UART_lld_dmaDisableChannel(UARTLLD_Handle hUart,
uint32_t isChannelTx);
/** @} */

#ifdef __cplusplus
}
#endif
Expand Down
18 changes: 9 additions & 9 deletions source/drivers/uart/v0/lld/dma/udma/uart_dma_udma.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void UART_udmaIsrTx(Udma_EventHandle eventHandle, uint32_t eventType, voi
int32_t UART_lld_dmaInit(UARTLLD_Handle hUart, UART_DmaChConfig dmaChCfg)
{
int32_t status = UART_TRANSFER_STATUS_SUCCESS;
UART_UdmaChConfig *udmaChCfg = (UART_UdmaChConfig *)dmaChCfg;
UART_UdmaChConfig *udmaChCfg = dmaChCfg;

status = UART_udmaInitRxCh(hUart, udmaChCfg);
status += UART_udmaInitTxCh(hUart, udmaChCfg);
Expand Down Expand Up @@ -202,7 +202,7 @@ int32_t UART_lld_dmaDeInit(UARTLLD_Handle hUart)
int32_t status = UART_TRANSFER_STATUS_SUCCESS;
UART_UdmaChConfig *udmaChCfg;

udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;

if (udmaChCfg->isOpen != FALSE)
{
Expand All @@ -223,7 +223,7 @@ static int32_t UART_udmaConfigPdmaTx(UARTLLD_Handle hUart, const UART_Transactio
Udma_ChHandle txChHandle;
UART_UdmaChConfig *udmaChCfg;

udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;
txChHandle = udmaChCfg->txChHandle;

/* Config PDMA channel */
Expand All @@ -241,7 +241,7 @@ static int32_t UART_udmaConfigPdmaTx(UARTLLD_Handle hUart, const UART_Transactio
DebugP_assert(UDMA_SOK == retVal);

/* Update host packet descriptor, length should be always in terms of total number of bytes */
UART_udmaHpdInit(txChHandle, (uint8_t *) udmaChCfg->txHpdMem, hUart->writeBuf, transaction->count);
UART_udmaHpdInit(txChHandle, (uint8_t *) udmaChCfg->txHpdMem, ((const void*)hUart->writeBuf), transaction->count);

retVal = Udma_ringQueueRaw(
Udma_chGetFqRingHandle(txChHandle),
Expand All @@ -258,7 +258,7 @@ static int32_t UART_udmaConfigPdmaRx(UARTLLD_Handle hUart, const UART_Transactio
Udma_ChHandle rxChHandle;
UART_UdmaChConfig *udmaChCfg;

udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;
rxChHandle = udmaChCfg->rxChHandle;

/* Config PDMA channel */
Expand All @@ -276,7 +276,7 @@ static int32_t UART_udmaConfigPdmaRx(UARTLLD_Handle hUart, const UART_Transactio
DebugP_assert(UDMA_SOK == retVal);

/* Update host packet descriptor, length should be always in terms of total number of bytes */
UART_udmaHpdInit(rxChHandle, (uint8_t *) udmaChCfg->rxHpdMem, hUart->readBuf, transaction->count);
UART_udmaHpdInit(rxChHandle, (uint8_t *) udmaChCfg->rxHpdMem, (void*) hUart->readBuf, transaction->count);

/* Submit HPD to channel */
retVal = Udma_ringQueueRaw(
Expand Down Expand Up @@ -363,7 +363,7 @@ int32_t UART_lld_dmaDisableChannel(UARTLLD_Handle hUart,
UART_UdmaChConfig *udmaChCfg;
Udma_ChHandle chHandle;

udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;

/* Disable Channel */
if (isChannelTx == TRUE)
Expand Down Expand Up @@ -409,7 +409,7 @@ static void UART_udmaIsrTx(Udma_EventHandle eventHandle,
if(NULL != args)
{
hUart = (UARTLLD_Handle)args;
udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;
txChHandle = udmaChCfg->txChHandle;

if (eventType == UDMA_EVENT_TYPE_DMA_COMPLETION)
Expand Down Expand Up @@ -455,7 +455,7 @@ static void UART_udmaIsrRx(Udma_EventHandle eventHandle,
if(NULL != args)
{
hUart = (UARTLLD_Handle)args;
udmaChCfg = (UART_UdmaChConfig *)hUart->hUartInit->dmaChCfg;
udmaChCfg = hUart->hUartInit->dmaChCfg;
rxChHandle = udmaChCfg->rxChHandle;

if (eventType == UDMA_EVENT_TYPE_DMA_COMPLETION)
Expand Down
Loading
Loading