Texas Instruments TMS320 DSP Computer Hardware User Manual


 
www.ti.com
3.1.9MultipleInterfaceSupport
InterfacesandModules
typedefstructFIR_Obj{/*FIR_Objdefinition*/
inthist[16];/*previousinputvalue*/
intframeLen;/*inputframelength*/
int*coeff;
}FIR_Obj;
FIR_HandleFIR_create(FIR_Obj*fir,constFIR_Params*params)
{
if(fir!=NULL){
if(params==NULL){/*usedefaultsifparamsisNULL*/
params=&FIR_PARAMS;
}
fir->frameLen=params->frameLen;
fir->coeff=params->coeff;
memset(fir->hist,0,sizeof(fir->hist));
}
return(fir);
}
Thedeleteentrypointshouldreleaseanyresourceheldbytheobjectbeingdeletedandshouldgracefully
handlethedeletionofpartiallyconstructedobjects;thedeleteentrypointmaybecalledbythecreate
operation.Inthiscase,thereisnothingtodo.
voidFIR_delete(FIR_Handlefir)
{
}
Finally,theFIRmodulemustprovideamethodforfilteringasignal.Thisisaccomplishedviatheapply
operationshownbelow.
voidFIR_apply(FIR_Handlefir,intin[],intout[])
{
intI;
/*filterdatausingcoefficientsfir->coeffand
historyfir->hist*/
for(I=0;I<fir->frameLen;I++){
out[i]=filter(in[i],fir->coeff,fir->hist);
}
}
Ofcourse,inarealFIRmodule,thefilteroperationwouldbeimplementedinassemblylanguage.
However,becausethestatenecessarytocomputethealgorithmisentirelycontainedintheobjectpointed
tobyfir,thisalgorithmisreentrant.Thus,itiseasytousethismoduleinmultichannelapplicationsorin
single-channelapplicationswhichrequiremorethanoneFIRfilter.
Moderncomponentprogrammingmodelssupporttheabilityofasinglecomponenttoimplementmore
thanoneinterface.Thisallowsasinglecomponenttobeusedconcurrentlybyavarietyofdifferent
applications.Forexample,inadditiontoacomponent'sconcreteinterface(definedbyitsheader)a
componentmightalsosupportadebuginterfacethatallowsdebuggerstoinquireabouttheexistenceand
extentofthecomponent'sdebugcapabilities.Ifalldebuggablecomponentsimplementacommonabstract
debuginterface,debuggerscanbewrittenthatcanuniformlydebugarbitrarycomponents.
Supportformultipleinterfacesisgenerallyincorporatedintothedevelopmentenvironment(viaCode
wizards),theprogramminglanguageitself,orboth.SincethisstandardisintendedtoonlyrequiretheC
language,theabilityofamoduletosupportmultipleinterfacesisatbestawkward.
However,severalsignificantbenefitsmakethisapproachworthwhile:
avendormaydecidenottoimplementcertaininterfacesforsomecomponents,
newinterfacescanbedefinedwithoutaffectingexistingcomponents,
multipleimplementationsofthesameinterfacemaybepresentinasinglesystem,and
partitioningalargeinterfaceintomultiplesimplerinterfacesmakesiteasiertounderstandthe
componentasawhole.
Asstatedbefore,interfacesaredefinedbyheaderfiles;eachheaderdefinesasingleinterface.A
SPRU352GJune2005RevisedFebruary2007AlgorithmComponentModel31
SubmitDocumentationFeedback