📄 edma3.c
字号:
(const void *)(&drvObj[phyCtrllerInstId].gblCfgParams),
sizeof (EDMA3_RM_GblConfigParams));
result = EDMA3_RM_create(phyCtrllerInstId, (EDMA3_RM_GblConfigParams *)&rmGblCfgParams, miscParam);
}
else
{
/* User has not passed any global info. */
result = EDMA3_RM_create(phyCtrllerInstId, NULL, miscParam);
if (EDMA3_RM_SOK == result)
{
/**
* Copy the global config info from the RM object to the
* driver object for future use.
*/
/* Fill the RM global info struct with the DRV global info */
edma3MemCpy((void *)(&drvObj[phyCtrllerInstId].gblCfgParams),
(const void *)(&resMgrObj[phyCtrllerInstId].gblCfgParams),
sizeof (EDMA3_RM_GblConfigParams));
}
}
if (EDMA3_RM_SOK == result)
{
drvObj[phyCtrllerInstId].state = EDMA3_DRV_CREATED;
drvObj[phyCtrllerInstId].numOpens = 0;
drvObj[phyCtrllerInstId].phyCtrllerInstId = phyCtrllerInstId;
/* Make all the Driver instances for this EDMA3 HW NULL */
for (count = 0; count < drvObj[phyCtrllerInstId].gblCfgParams.numRegions; count++)
{
edma3MemSet((void *)&(drvInstance[phyCtrllerInstId][count]) , 0x00u,
sizeof(EDMA3_DRV_Instance));
}
/* Reset edma3DrvChBoundRes Array*/
for (count = 0; count < EDMA3_MAX_LOGICAL_CH; count++)
{
edma3DrvChBoundRes[phyCtrllerInstId][count].paRAMId = -1;
edma3DrvChBoundRes[phyCtrllerInstId][count].tcc = EDMA3_MAX_TCC;
edma3DrvChBoundRes[phyCtrllerInstId][count].trigMode =
EDMA3_DRV_TRIG_MODE_NONE;
}
}
}
}
return result;
}
/**
* \brief Delete EDMA3 Driver Object
*
* Use this API to delete the EDMA3 Driver Object. It should be called only
* ONCE for each EDMA3 hardware instance. It should be called ONLY after
* closing all the EDMA3 Driver Instances.
*
* This API is used to delete the EDMA3 Driver Object. It should be called
* once for each EDMA3 hardware instance, ONLY after closing all the
* previously opened EDMA3 Driver Instances.
*
* After successful completion of this API, Driver Object's state
* changes to EDMA3_DRV_DELETED.
*
* \param phyCtrllerInstId [IN] EDMA3 Phy Controller Instance Id (Hardware
* instance id, starting from 0).
* \param param [IN] For possible future use.
*
* \return EDMA3_DRV_SOK or EDMA3_DRV Error code
*/
EDMA3_DRV_Result EDMA3_DRV_delete(unsigned int phyCtrllerInstId,
const void *param)
{
EDMA3_DRV_Result result = EDMA3_DRV_SOK;
if (phyCtrllerInstId >= EDMA3_MAX_EDMA3_INSTANCES)
{
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
/*to remove CCS remark: parameter "param" was never referenced */
(void)param;
/**
* If number of Driver Instances is 0, then state should be
* EDMA3_DRV_CLOSED OR EDMA3_DRV_CREATED.
*/
if ((NULL == drvObj[phyCtrllerInstId].numOpens)
&& ((drvObj[phyCtrllerInstId].state != EDMA3_DRV_CLOSED)
&& (drvObj[phyCtrllerInstId].state != EDMA3_DRV_CREATED)))
{
result = EDMA3_DRV_E_OBJ_NOT_CLOSED;
}
else
{
/**
* If number of Driver Instances is NOT 0, then this function
* SHOULD NOT be called by anybody.
*/
if (NULL != drvObj[phyCtrllerInstId].numOpens)
{
result = EDMA3_DRV_E_INVALID_STATE;
}
else
{
/**
* State is correct. Delete the RM Object.
*/
result = EDMA3_RM_delete (phyCtrllerInstId, NULL);
if (EDMA3_RM_SOK == result)
{
/** Change state to EDMA3_DRV_DELETED */
drvObj[phyCtrllerInstId].state = EDMA3_DRV_DELETED;
/* Also, reset the Driver Object Global Config Info */
edma3MemSet((void *)&(drvObj[phyCtrllerInstId].gblCfgParams) , 0x00u,
sizeof(EDMA3_DRV_GblConfigParams));
}
}
}
}
return result;
}
/**
* \brief Open EDMA3 Driver Instance
*
* This API is used to open an EDMA3 Driver Instance. It could be
* called multiple times, for each possible EDMA3 shadow region. Maximum
* EDMA3_MAX_REGIONS instances are allowed for each EDMA3 hardware
* instance. Multiple instances on the same shadow region are NOT allowed.
*
* Also, only ONE Master Driver Instance is permitted. This master
* instance (and hence the region to which it belongs) will only receive the
* EDMA3 interrupts, if enabled.
*
* User could pass the instance specific configuration structure
* (initCfg.drvInstInitConfig) as a part of the 'initCfg' structure,
* during init-time. In case user doesn't provide it, this information could
* be taken from the SoC specific configuration file edma3_<SOC_NAME>_cfg.c,
* in case it is available.
*
* \param phyCtrllerInstId [IN] EDMA3 Controller Instance Id (Hardware
* instance id, starting from 0).
* \param initCfg [IN] Used to Initialize the EDMA3 Driver
* Instance (Master or Slave).
* \param errorCode [OUT] Error code while opening DRV instance.
*
* \return EDMA3_DRV_Handle : If successfully opened, the API will return the
* associated driver's instance handle.
*
* \note This function disables the global interrupts (by calling API
* edma3OsProtectEntry with protection level
* EDMA3_OS_PROTECT_INTERRUPT) while modifying the global data
* structures, to make it re-entrant.
*/
EDMA3_DRV_Handle EDMA3_DRV_open (unsigned int phyCtrllerInstId,
const EDMA3_DRV_InitConfig *initCfg,
EDMA3_DRV_Result *errorCode)
{
EDMA3_DRV_Result result = EDMA3_DRV_SOK;
EDMA3_DRV_Object *drvObject = NULL;
EDMA3_DRV_Instance *drvInstanceHandle = NULL;
unsigned int intState = 0;
volatile EDMA3_CCRL_Regs *globalRegs = NULL;
unsigned short flag = 0;
if (((initCfg == NULL) || (phyCtrllerInstId >= EDMA3_MAX_EDMA3_INSTANCES))
|| (errorCode == NULL))
{
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
/* Check whether the semaphore handle is null or not */
if (NULL== initCfg->drvSemHandle)
{
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
drvObject = &drvObj[phyCtrllerInstId];
if (NULL == drvObject)
{
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
if (initCfg->regionId >= drvObject->gblCfgParams.numRegions)
{
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
/* if no instance is opened and this is the first one,
* then state should be created/closed.
*/
if (((drvObject->numOpens == NULL) && (drvObject->state != EDMA3_DRV_CREATED))
&& (drvObject->state != EDMA3_DRV_CLOSED))
{
result = EDMA3_DRV_E_INVALID_STATE;
}
else
{
/* if num of instances opened is more than 0 and less than no of regions,
* then state should be opened.
*/
if (((drvObject->numOpens > 0) && (drvObject->numOpens < drvObject->gblCfgParams.numRegions))
&& (drvObject->state != EDMA3_DRV_OPENED))
{
result = EDMA3_DRV_E_INVALID_STATE;
}
else
{
/* if a driver instance is already there for a specific region,
* it should return an error.
*/
drvInstanceHandle = &drvInstance[phyCtrllerInstId][initCfg->regionId];
if (drvInstanceHandle->pDrvObjectHandle != NULL)
{
drvInstanceHandle = NULL;
result = EDMA3_DRV_E_INST_ALREADY_EXISTS;
}
}
}
}
}
}
}
if (EDMA3_DRV_SOK == result)
{
/* Save the region specific information in the region specific drv instance*/
drvInstanceHandle->regionId = initCfg->regionId;
drvInstanceHandle->isMaster = initCfg->isMaster;
drvInstanceHandle->drvSemHandle = initCfg->drvSemHandle;
drvInstanceHandle->gblerrCbParams.gblerrCb = initCfg->gblerrCb;
drvInstanceHandle->gblerrCbParams.gblerrData = initCfg->gblerrData;
if (NULL != initCfg->drvInstInitConfig)
{
edma3MemCpy((void *)(&drvInstanceHandle->drvInstInitConfig),
(const void *)(initCfg->drvInstInitConfig),
sizeof (EDMA3_DRV_InstanceInitConfig));
/* Flag to remember that driver has passed config info to RM*/
flag = 1u;
}
if (NULL == drvObject->gblCfgParams.globalRegs)
{
drvInstanceHandle = NULL;
result = EDMA3_DRV_E_INVALID_PARAM;
}
else
{
globalRegs = (volatile EDMA3_CCRL_Regs *)drvObject->gblCfgParams.globalRegs;
/* Update shadowRegs */
drvInstanceHandle->shadowRegs = (EDMA3_CCRL_ShadowRegs *)
(&(globalRegs->SHADOW[initCfg->regionId]));
result = edma3OpenResMgr (phyCtrllerInstId, initCfg->regionId, flag);
if (EDMA3_DRV_SOK != result)
{
drvInstanceHandle = NULL;
}
else
{
drvObject->state = EDMA3_DRV_OPENED;
edma3OsProtectEntry (EDMA3_OS_PROTECT_INTERRUPT, &intState);
drvObject->numOpens++;
edma3OsProtectExit (EDMA3_OS_PROTECT_INTERRUPT, intState);
}
}
}
*errorCode = result;
return (EDMA3_DRV_Handle)drvInstanceHandle;
}
/**
* \brief Close the EDMA3 Driver Instance.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -