200 lines
6.8 KiB
C
200 lines
6.8 KiB
C
/******************************************************************************/
|
|
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
|
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
|
/******************************************************************************/
|
|
/* CONTEXT:USER_APP */
|
|
/* PACKAGE TITLE: Setup */
|
|
/* DESCRIPTION: This code assist with the setup of kernel managed */
|
|
/* resources */
|
|
/* */
|
|
/* FILE NAME: SETUP.c */
|
|
/* REVISION HISTORY: 14-04-2016 | 1.0 | Initial revision */
|
|
/* */
|
|
/******************************************************************************/
|
|
#define _SETUP_C
|
|
|
|
/******************************************************************************/
|
|
/* HEADER FILES */
|
|
/******************************************************************************/
|
|
#include "build.h"
|
|
|
|
#ifdef BUILD_USER
|
|
|
|
#include "SETUP.h"
|
|
#include "diag.h"
|
|
|
|
|
|
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
|
|
|
|
|
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
|
|
|
|
|
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
|
bool SETUP_boSetupADSE(IOAPI_tenEHIOResource enEHIOResource, IOAPI_tenEHIOType enEHIOType, ADCAPI_tenSamplesAv enSamplesAv, ADCAPI_tpfResultCB pfResultCB, ADCAPI_tenTrigger enTrigger, puint32 pu32Arg)
|
|
{
|
|
bool boRetVal = FALSE;
|
|
ADCAPI_tstADCCB stADCCB;
|
|
|
|
stADCCB.enSamplesAv = enSamplesAv;
|
|
stADCCB.enDiffGain = ADCAPI_enDiffGain1;
|
|
stADCCB.pfResultCB = pfResultCB;
|
|
stADCCB.enTrigger = enTrigger;
|
|
|
|
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);
|
|
|
|
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
|
{
|
|
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
|
(void*)&enEHIOType, (void*)&stADCCB);
|
|
|
|
if (SYSAPI_enOK != pstSVCDataStruct->enSVCResult)
|
|
{
|
|
*pu32Arg |= (uint32)SYSAPI_enResourceRequestFailed;/*CR1_13*/
|
|
}
|
|
else
|
|
{
|
|
boRetVal = TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
*pu32Arg |= (uint32)SYSAPI_enResourceInitFailed;/*CR1_13*/
|
|
}
|
|
|
|
return boRetVal;
|
|
}
|
|
|
|
TABLEAPI_ttTableIDX SETUP_tSetupTable(void* pvTableData, void* pvOutputData, TYPE_tenDataType enDataType, sint16 s16TableSize, SPREADAPI_ttSpreadIDX tSpreadIDX, TABLEAPI_pfPIDResultCB pfResultCB)
|
|
{
|
|
TABLEAPI_tstTableCB stTableCB;
|
|
TABLEAPI_ttTableIDX tTableIDX;
|
|
|
|
/* Request and initialise required Kernel managed tables */
|
|
stTableCB.pvTableData = pvTableData;
|
|
stTableCB.pvOutputData = pvOutputData;
|
|
stTableCB.enDataType = enDataType;
|
|
stTableCB.i16TableSize = s16TableSize;
|
|
stTableCB.tSpreadIDX = tSpreadIDX;
|
|
stTableCB.pfResultCB = NULL;
|
|
|
|
USER_vSVC(SYSAPI_enInitialiseTableResource, (void*)&stTableCB, NULL, NULL);
|
|
tTableIDX = (SYSAPI_enOK == pstSVCDataStruct->enSVCResult) ?
|
|
(TABLEAPI_ttTableIDX)pstSVCDataStruct->tClientHandle : -1;
|
|
|
|
return tTableIDX;
|
|
}
|
|
|
|
MAPSAPI_ttMapIDX SETUP_tSetupMap(void* pvMapData, void* pvOutputData, TYPE_tenDataType enDataType, sint16 s16MapSizeX, sint16 s16MapSizeY, SPREADAPI_ttSpreadIDX tSpreadIDXX, SPREADAPI_ttSpreadIDX tSpreadIDXY,TABLEAPI_pfPIDResultCB pfResultCB)
|
|
{
|
|
MAPSAPI_tstMapCB stMapCB;
|
|
MAPSAPI_ttMapIDX tMapIDX;
|
|
|
|
/* Request and initialise required Kernel managed tables */
|
|
stMapCB.pvMapData = pvMapData;
|
|
stMapCB.pvOutputData = pvOutputData;
|
|
stMapCB.enDataType = enDataType;
|
|
stMapCB.i16MapSizeX = s16MapSizeX;
|
|
stMapCB.i16MapSizeY = s16MapSizeY;
|
|
stMapCB.tSpreadIDXX = tSpreadIDXX;
|
|
stMapCB.tSpreadIDXY = tSpreadIDXY;
|
|
stMapCB.pfResultCB = NULL;
|
|
|
|
USER_vSVC(SYSAPI_enInitialiseMapResource, (void*)&stMapCB, NULL, NULL);
|
|
tMapIDX = (SYSAPI_enOK == pstSVCDataStruct->enSVCResult) ?
|
|
(MAPSAPI_ttMapIDX)pstSVCDataStruct->tClientHandle : -1;
|
|
|
|
return tMapIDX;
|
|
}
|
|
|
|
SPREADAPI_ttSpreadIDX SETUP_tSetupSpread(void* pvSourceData, void* pvSpreadData, TYPE_tenDataType enDataType, sint16 s16SpreadSize, SPREADAPI_tenSpreadRate enSpreadRate, SPREADAPI_pfPIDResultCB pfResultCB)
|
|
{
|
|
SPREADAPI_tstSpreadCB stSpreadCB;
|
|
SPREADAPI_ttSpreadIDX tSpreadIDX;
|
|
USERDIAG_tstSpreadIDXAddressPair stSpreadIDXAddressPair;
|
|
|
|
stSpreadCB.pvSourceData = pvSourceData;
|
|
stSpreadCB.pvSpreadData = pvSpreadData;
|
|
stSpreadCB.enDataType = enDataType;
|
|
stSpreadCB.s16SpreadSize = s16SpreadSize;
|
|
stSpreadCB.enSpreadRate = enSpreadRate;
|
|
stSpreadCB.pfResultCB = pfResultCB;
|
|
|
|
USER_vSVC(SYSAPI_enInitialiseSpreadResource, (void*)&stSpreadCB, NULL, NULL);
|
|
tSpreadIDX = (SYSAPI_enOK == pstSVCDataStruct->enSVCResult) ?
|
|
(SPREADAPI_ttSpreadIDX)pstSVCDataStruct->tClientHandle : -1;
|
|
|
|
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
|
{
|
|
stSpreadIDXAddressPair.pData = pvSpreadData;
|
|
stSpreadIDXAddressPair.tSpreadIDX = tSpreadIDX;
|
|
USERDIAG_vAddIDXAddressPair(&stSpreadIDXAddressPair);
|
|
}
|
|
|
|
return tSpreadIDX;
|
|
}
|
|
|
|
void SETUP_vSetupDigitalIO(IOAPI_tenEHIOResource enEHIOResource, IOAPI_tenEHIOType enEHIOType, IOAPI_tenDriveStrength enDriveStrength, puint32 pu32Arg)
|
|
{
|
|
if (EH_IO_Invalid != enEHIOResource)
|
|
{
|
|
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);
|
|
|
|
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
|
{
|
|
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
|
(void*)&enEHIOType, (void*)&enDriveStrength);
|
|
|
|
if (SYSAPI_enOK != pstSVCDataStruct->enSVCResult)
|
|
{
|
|
*pu32Arg |= (uint32)SYSAPI_enResourceRequestFailed;/*CR1_13*/
|
|
}
|
|
}
|
|
else
|
|
{
|
|
*pu32Arg |= (uint32)SYSAPI_enResourceInitFailed;/*CR1_13*/
|
|
}
|
|
}
|
|
else
|
|
{
|
|
*pu32Arg |= (uint32)SYSAPI_enResourceInitFailed;/*CR1_13*/
|
|
}
|
|
}
|
|
|
|
|
|
void SETUP_vSetDigitalIOHigh(IOAPI_tenEHIOResource enEHIOResource)
|
|
{
|
|
IOAPI_tenTriState enTriState = IOAPI_enHigh;
|
|
|
|
USER_vSVC(SYSAPI_enAssertDIOResource, (void*)&enEHIOResource,
|
|
(void*)&enTriState, (void*)NULL);
|
|
}
|
|
|
|
void SETUP_vSetDigitalIOLow(IOAPI_tenEHIOResource enEHIOResource)
|
|
{
|
|
IOAPI_tenTriState enTriState = IOAPI_enLow;
|
|
|
|
USER_vSVC(SYSAPI_enAssertDIOResource, (void*)&enEHIOResource,
|
|
(void*)&enTriState, (void*)NULL);
|
|
}
|
|
|
|
bool SETUP_vGetDigitalIO(IOAPI_tenEHIOResource enEHIOResource)
|
|
{
|
|
bool boResult;
|
|
|
|
USER_vSVC(SYSAPI_enGetDIOResource, (void*)&enEHIOResource,
|
|
(void*)NULL, (void*)NULL);
|
|
|
|
boResult = *(bool*)pstSVCDataStruct->pvArg1;
|
|
|
|
return boResult;
|
|
}
|
|
|
|
void SETUP_vSetupSimpleCamSync(IOAPI_tenEHIOResource enEHIOResource, bool boCamSyncHighLate, uint32 u32CamSyncSampleToothCount)
|
|
{
|
|
USER_vSVC(SYSAPI_enSetupSimpleCamSync, (void*)&enEHIOResource,
|
|
(void*)&boCamSyncHighLate, (void*)&u32CamSyncSampleToothCount);
|
|
}
|
|
|
|
#endif //BUILD_USER
|