arm_math.h 237 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307
  1. /* ----------------------------------------------------------------------
  2. * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
  3. *
  4. * $Date: 17. January 2013
  5. * $Revision: V1.4.1
  6. *
  7. * Project: CMSIS DSP Library
  8. * Title: arm_math.h
  9. *
  10. * Description: Public header file for CMSIS DSP Library
  11. *
  12. * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions
  16. * are met:
  17. * - Redistributions of source code must retain the above copyright
  18. * notice, this list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in
  21. * the documentation and/or other materials provided with the
  22. * distribution.
  23. * - Neither the name of ARM LIMITED nor the names of its contributors
  24. * may be used to endorse or promote products derived from this
  25. * software without specific prior written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  30. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  31. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  33. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  34. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  35. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  37. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGE.
  39. * -------------------------------------------------------------------- */
  40. /**
  41. \mainpage CMSIS DSP Software Library
  42. *
  43. * <b>Introduction</b>
  44. *
  45. * This user manual describes the CMSIS DSP software library,
  46. * a suite of common signal processing functions for use on Cortex-M processor based devices.
  47. *
  48. * The library is divided into a number of functions each covering a specific category:
  49. * - Basic math functions
  50. * - Fast math functions
  51. * - Complex math functions
  52. * - Filters
  53. * - Matrix functions
  54. * - Transforms
  55. * - Motor control functions
  56. * - Statistical functions
  57. * - Support functions
  58. * - Interpolation functions
  59. *
  60. * The library has separate functions for operating on 8-bit integers, 16-bit integers,
  61. * 32-bit integer and 32-bit floating-point values.
  62. *
  63. * <b>Using the Library</b>
  64. *
  65. * The library installer contains prebuilt versions of the libraries in the <code>Lib</code> folder.
  66. * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4)
  67. * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4)
  68. * - arm_cortexM4l_math.lib (Little endian on Cortex-M4)
  69. * - arm_cortexM4b_math.lib (Big endian on Cortex-M4)
  70. * - arm_cortexM3l_math.lib (Little endian on Cortex-M3)
  71. * - arm_cortexM3b_math.lib (Big endian on Cortex-M3)
  72. * - arm_cortexM0l_math.lib (Little endian on Cortex-M0)
  73. * - arm_cortexM0b_math.lib (Big endian on Cortex-M3)
  74. *
  75. * The library functions are declared in the public file <code>arm_math.h</code> which is placed in the <code>Include</code> folder.
  76. * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single
  77. * public header file <code> arm_math.h</code> for Cortex-M4/M3/M0 with little endian and big endian. Same header file will be used for floating point unit(FPU) variants.
  78. * Define the appropriate pre processor MACRO ARM_MATH_CM4 or ARM_MATH_CM3 or
  79. * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
  80. *
  81. * <b>Examples</b>
  82. *
  83. * The library ships with a number of examples which demonstrate how to use the library functions.
  84. *
  85. * <b>Toolchain Support</b>
  86. *
  87. * The library has been developed and tested with MDK-ARM version 4.60.
  88. * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly.
  89. *
  90. * <b>Building the Library</b>
  91. *
  92. * The library installer contains project files to re build libraries on MDK Tool chain in the <code>CMSIS\\DSP_Lib\\Source\\ARM</code> folder.
  93. * - arm_cortexM0b_math.uvproj
  94. * - arm_cortexM0l_math.uvproj
  95. * - arm_cortexM3b_math.uvproj
  96. * - arm_cortexM3l_math.uvproj
  97. * - arm_cortexM4b_math.uvproj
  98. * - arm_cortexM4l_math.uvproj
  99. * - arm_cortexM4bf_math.uvproj
  100. * - arm_cortexM4lf_math.uvproj
  101. *
  102. *
  103. * The project can be built by opening the appropriate project in MDK-ARM 4.60 chain and defining the optional pre processor MACROs detailed above.
  104. *
  105. * <b>Pre-processor Macros</b>
  106. *
  107. * Each library project have differant pre-processor macros.
  108. *
  109. * - UNALIGNED_SUPPORT_DISABLE:
  110. *
  111. * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access
  112. *
  113. * - ARM_MATH_BIG_ENDIAN:
  114. *
  115. * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets.
  116. *
  117. * - ARM_MATH_MATRIX_CHECK:
  118. *
  119. * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices
  120. *
  121. * - ARM_MATH_ROUNDING:
  122. *
  123. * Define macro ARM_MATH_ROUNDING for rounding on support functions
  124. *
  125. * - ARM_MATH_CMx:
  126. *
  127. * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target
  128. * and ARM_MATH_CM0 for building library on cortex-M0 target, ARM_MATH_CM0PLUS for building library on cortex-M0+ target.
  129. *
  130. * - __FPU_PRESENT:
  131. *
  132. * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries
  133. *
  134. * <b>Copyright Notice</b>
  135. *
  136. * Copyright (C) 2010-2013 ARM Limited. All rights reserved.
  137. */
  138. /**
  139. * @defgroup groupMath Basic Math Functions
  140. */
  141. /**
  142. * @defgroup groupFastMath Fast Math Functions
  143. * This set of functions provides a fast approximation to sine, cosine, and square root.
  144. * As compared to most of the other functions in the CMSIS math library, the fast math functions
  145. * operate on individual values and not arrays.
  146. * There are separate functions for Q15, Q31, and floating-point data.
  147. *
  148. */
  149. /**
  150. * @defgroup groupCmplxMath Complex Math Functions
  151. * This set of functions operates on complex data vectors.
  152. * The data in the complex arrays is stored in an interleaved fashion
  153. * (real, imag, real, imag, ...).
  154. * In the API functions, the number of samples in a complex array refers
  155. * to the number of complex values; the array contains twice this number of
  156. * real values.
  157. */
  158. /**
  159. * @defgroup groupFilters Filtering Functions
  160. */
  161. /**
  162. * @defgroup groupMatrix Matrix Functions
  163. *
  164. * This set of functions provides basic matrix math operations.
  165. * The functions operate on matrix data structures. For example,
  166. * the type
  167. * definition for the floating-point matrix structure is shown
  168. * below:
  169. * <pre>
  170. * typedef struct
  171. * {
  172. * uint16_t numRows; // number of rows of the matrix.
  173. * uint16_t numCols; // number of columns of the matrix.
  174. * float32_t *pData; // points to the data of the matrix.
  175. * } arm_matrix_instance_f32;
  176. * </pre>
  177. * There are similar definitions for Q15 and Q31 data types.
  178. *
  179. * The structure specifies the size of the matrix and then points to
  180. * an array of data. The array is of size <code>numRows X numCols</code>
  181. * and the values are arranged in row order. That is, the
  182. * matrix element (i, j) is stored at:
  183. * <pre>
  184. * pData[i*numCols + j]
  185. * </pre>
  186. *
  187. * \par Init Functions
  188. * There is an associated initialization function for each type of matrix
  189. * data structure.
  190. * The initialization function sets the values of the internal structure fields.
  191. * Refer to the function <code>arm_mat_init_f32()</code>, <code>arm_mat_init_q31()</code>
  192. * and <code>arm_mat_init_q15()</code> for floating-point, Q31 and Q15 types, respectively.
  193. *
  194. * \par
  195. * Use of the initialization function is optional. However, if initialization function is used
  196. * then the instance structure cannot be placed into a const data section.
  197. * To place the instance structure in a const data
  198. * section, manually initialize the data structure. For example:
  199. * <pre>
  200. * <code>arm_matrix_instance_f32 S = {nRows, nColumns, pData};</code>
  201. * <code>arm_matrix_instance_q31 S = {nRows, nColumns, pData};</code>
  202. * <code>arm_matrix_instance_q15 S = {nRows, nColumns, pData};</code>
  203. * </pre>
  204. * where <code>nRows</code> specifies the number of rows, <code>nColumns</code>
  205. * specifies the number of columns, and <code>pData</code> points to the
  206. * data array.
  207. *
  208. * \par Size Checking
  209. * By default all of the matrix functions perform size checking on the input and
  210. * output matrices. For example, the matrix addition function verifies that the
  211. * two input matrices and the output matrix all have the same number of rows and
  212. * columns. If the size check fails the functions return:
  213. * <pre>
  214. * ARM_MATH_SIZE_MISMATCH
  215. * </pre>
  216. * Otherwise the functions return
  217. * <pre>
  218. * ARM_MATH_SUCCESS
  219. * </pre>
  220. * There is some overhead associated with this matrix size checking.
  221. * The matrix size checking is enabled via the \#define
  222. * <pre>
  223. * ARM_MATH_MATRIX_CHECK
  224. * </pre>
  225. * within the library project settings. By default this macro is defined
  226. * and size checking is enabled. By changing the project settings and
  227. * undefining this macro size checking is eliminated and the functions
  228. * run a bit faster. With size checking disabled the functions always
  229. * return <code>ARM_MATH_SUCCESS</code>.
  230. */
  231. /**
  232. * @defgroup groupTransforms Transform Functions
  233. */
  234. /**
  235. * @defgroup groupController Controller Functions
  236. */
  237. /**
  238. * @defgroup groupStats Statistics Functions
  239. */
  240. /**
  241. * @defgroup groupSupport Support Functions
  242. */
  243. /**
  244. * @defgroup groupInterpolation Interpolation Functions
  245. * These functions perform 1- and 2-dimensional interpolation of data.
  246. * Linear interpolation is used for 1-dimensional data and
  247. * bilinear interpolation is used for 2-dimensional data.
  248. */
  249. /**
  250. * @defgroup groupExamples Examples
  251. */
  252. #ifndef _ARM_MATH_H
  253. #define _ARM_MATH_H
  254. #define __CMSIS_GENERIC /* disable NVIC and Systick functions */
  255. #if defined (ARM_MATH_CM4)
  256. #include "core_cm4.h"
  257. #elif defined (ARM_MATH_CM3)
  258. #include "core_cm3.h"
  259. #elif defined (ARM_MATH_CM0)
  260. #include "core_cm0.h"
  261. #define ARM_MATH_CM0_FAMILY
  262. #elif defined (ARM_MATH_CM0PLUS)
  263. #include "core_cm0plus.h"
  264. #define ARM_MATH_CM0_FAMILY
  265. #else
  266. #include "ARMCM4.h"
  267. #warning "Define either ARM_MATH_CM4 OR ARM_MATH_CM3...By Default building on ARM_MATH_CM4....."
  268. #endif
  269. #undef __CMSIS_GENERIC /* enable NVIC and Systick functions */
  270. #include "string.h"
  271. #include "math.h"
  272. #ifdef __cplusplus
  273. extern "C"
  274. {
  275. #endif
  276. /**
  277. * @brief Macros required for reciprocal calculation in Normalized LMS
  278. */
  279. #define DELTA_Q31 (0x100)
  280. #define DELTA_Q15 0x5
  281. #define INDEX_MASK 0x0000003F
  282. #ifndef PI
  283. #define PI 3.14159265358979f
  284. #endif
  285. /**
  286. * @brief Macros required for SINE and COSINE Fast math approximations
  287. */
  288. #define TABLE_SIZE 256
  289. #define TABLE_SPACING_Q31 0x800000
  290. #define TABLE_SPACING_Q15 0x80
  291. /**
  292. * @brief Macros required for SINE and COSINE Controller functions
  293. */
  294. /* 1.31(q31) Fixed value of 2/360 */
  295. /* -1 to +1 is divided into 360 values so total spacing is (2/360) */
  296. #define INPUT_SPACING 0xB60B61
  297. /**
  298. * @brief Macro for Unaligned Support
  299. */
  300. #ifndef UNALIGNED_SUPPORT_DISABLE
  301. #define ALIGN4
  302. #else
  303. #if defined (__GNUC__)
  304. #define ALIGN4 __attribute__((aligned(4)))
  305. #else
  306. #define ALIGN4 __align(4)
  307. #endif
  308. #endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */
  309. /**
  310. * @brief Error status returned by some functions in the library.
  311. */
  312. typedef enum
  313. {
  314. ARM_MATH_SUCCESS = 0, /**< No error */
  315. ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */
  316. ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */
  317. ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation. */
  318. ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */
  319. ARM_MATH_SINGULAR = -5, /**< Generated by matrix inversion if the input matrix is singular and cannot be inverted. */
  320. ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */
  321. } arm_status;
  322. /**
  323. * @brief 8-bit fractional data type in 1.7 format.
  324. */
  325. typedef int8_t q7_t;
  326. /**
  327. * @brief 16-bit fractional data type in 1.15 format.
  328. */
  329. typedef int16_t q15_t;
  330. /**
  331. * @brief 32-bit fractional data type in 1.31 format.
  332. */
  333. typedef int32_t q31_t;
  334. /**
  335. * @brief 64-bit fractional data type in 1.63 format.
  336. */
  337. typedef int64_t q63_t;
  338. /**
  339. * @brief 32-bit floating-point type definition.
  340. */
  341. typedef float float32_t;
  342. /**
  343. * @brief 64-bit floating-point type definition.
  344. */
  345. typedef double float64_t;
  346. /**
  347. * @brief definition to read/write two 16 bit values.
  348. */
  349. #if defined __CC_ARM
  350. #define __SIMD32_TYPE int32_t __packed
  351. #define CMSIS_UNUSED __attribute__((unused))
  352. #elif defined __ICCARM__
  353. #define CMSIS_UNUSED
  354. #define __SIMD32_TYPE int32_t __packed
  355. #elif defined __GNUC__
  356. #define __SIMD32_TYPE int32_t
  357. #define CMSIS_UNUSED __attribute__((unused))
  358. #else
  359. #error Unknown compiler
  360. #endif
  361. #define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))
  362. #define __SIMD32_CONST(addr) ((__SIMD32_TYPE *)(addr))
  363. #define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE *) (addr))
  364. #define __SIMD64(addr) (*(int64_t **) & (addr))
  365. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  366. /**
  367. * @brief definition to pack two 16 bit values.
  368. */
  369. #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \
  370. (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) )
  371. #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \
  372. (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) )
  373. #endif
  374. /**
  375. * @brief definition to pack four 8 bit values.
  376. */
  377. #ifndef ARM_MATH_BIG_ENDIAN
  378. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \
  379. (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \
  380. (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
  381. (((int32_t)(v3) << 24) & (int32_t)0xFF000000) )
  382. #else
  383. #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \
  384. (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \
  385. (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \
  386. (((int32_t)(v0) << 24) & (int32_t)0xFF000000) )
  387. #endif
  388. /**
  389. * @brief Clips Q63 to Q31 values.
  390. */
  391. static __INLINE q31_t clip_q63_to_q31(
  392. q63_t x)
  393. {
  394. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  395. ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x;
  396. }
  397. /**
  398. * @brief Clips Q63 to Q15 values.
  399. */
  400. static __INLINE q15_t clip_q63_to_q15(
  401. q63_t x)
  402. {
  403. return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ?
  404. ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15);
  405. }
  406. /**
  407. * @brief Clips Q31 to Q7 values.
  408. */
  409. static __INLINE q7_t clip_q31_to_q7(
  410. q31_t x)
  411. {
  412. return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ?
  413. ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x;
  414. }
  415. /**
  416. * @brief Clips Q31 to Q15 values.
  417. */
  418. static __INLINE q15_t clip_q31_to_q15(
  419. q31_t x)
  420. {
  421. return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ?
  422. ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x;
  423. }
  424. /**
  425. * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format.
  426. */
  427. static __INLINE q63_t mult32x64(
  428. q63_t x,
  429. q31_t y)
  430. {
  431. return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) +
  432. (((q63_t) (x >> 32) * y)));
  433. }
  434. #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM )
  435. #define __CLZ __clz
  436. #endif
  437. #if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ||(defined (__GNUC__)) || defined (__TASKING__) )
  438. static __INLINE uint32_t __CLZ(
  439. q31_t data);
  440. static __INLINE uint32_t __CLZ(
  441. q31_t data)
  442. {
  443. uint32_t count = 0;
  444. uint32_t mask = 0x80000000;
  445. while((data & mask) == 0)
  446. {
  447. count += 1u;
  448. mask = mask >> 1u;
  449. }
  450. return (count);
  451. }
  452. #endif
  453. /**
  454. * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type.
  455. */
  456. static __INLINE uint32_t arm_recip_q31(
  457. q31_t in,
  458. q31_t * dst,
  459. q31_t * pRecipTable)
  460. {
  461. uint32_t out, tempVal;
  462. uint32_t index, i;
  463. uint32_t signBits;
  464. if(in > 0)
  465. {
  466. signBits = __CLZ(in) - 1;
  467. }
  468. else
  469. {
  470. signBits = __CLZ(-in) - 1;
  471. }
  472. /* Convert input sample to 1.31 format */
  473. in = in << signBits;
  474. /* calculation of index for initial approximated Val */
  475. index = (uint32_t) (in >> 24u);
  476. index = (index & INDEX_MASK);
  477. /* 1.31 with exp 1 */
  478. out = pRecipTable[index];
  479. /* calculation of reciprocal value */
  480. /* running approximation for two iterations */
  481. for (i = 0u; i < 2u; i++)
  482. {
  483. tempVal = (q31_t) (((q63_t) in * out) >> 31u);
  484. tempVal = 0x7FFFFFFF - tempVal;
  485. /* 1.31 with exp 1 */
  486. //out = (q31_t) (((q63_t) out * tempVal) >> 30u);
  487. out = (q31_t) clip_q63_to_q31(((q63_t) out * tempVal) >> 30u);
  488. }
  489. /* write output */
  490. *dst = out;
  491. /* return num of signbits of out = 1/in value */
  492. return (signBits + 1u);
  493. }
  494. /**
  495. * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type.
  496. */
  497. static __INLINE uint32_t arm_recip_q15(
  498. q15_t in,
  499. q15_t * dst,
  500. q15_t * pRecipTable)
  501. {
  502. uint32_t out = 0, tempVal = 0;
  503. uint32_t index = 0, i = 0;
  504. uint32_t signBits = 0;
  505. if(in > 0)
  506. {
  507. signBits = __CLZ(in) - 17;
  508. }
  509. else
  510. {
  511. signBits = __CLZ(-in) - 17;
  512. }
  513. /* Convert input sample to 1.15 format */
  514. in = in << signBits;
  515. /* calculation of index for initial approximated Val */
  516. index = in >> 8;
  517. index = (index & INDEX_MASK);
  518. /* 1.15 with exp 1 */
  519. out = pRecipTable[index];
  520. /* calculation of reciprocal value */
  521. /* running approximation for two iterations */
  522. for (i = 0; i < 2; i++)
  523. {
  524. tempVal = (q15_t) (((q31_t) in * out) >> 15);
  525. tempVal = 0x7FFF - tempVal;
  526. /* 1.15 with exp 1 */
  527. out = (q15_t) (((q31_t) out * tempVal) >> 14);
  528. }
  529. /* write output */
  530. *dst = out;
  531. /* return num of signbits of out = 1/in value */
  532. return (signBits + 1);
  533. }
  534. /*
  535. * @brief C custom defined intrinisic function for only M0 processors
  536. */
  537. #if defined(ARM_MATH_CM0_FAMILY)
  538. static __INLINE q31_t __SSAT(
  539. q31_t x,
  540. uint32_t y)
  541. {
  542. int32_t posMax, negMin;
  543. uint32_t i;
  544. posMax = 1;
  545. for (i = 0; i < (y - 1); i++)
  546. {
  547. posMax = posMax * 2;
  548. }
  549. if(x > 0)
  550. {
  551. posMax = (posMax - 1);
  552. if(x > posMax)
  553. {
  554. x = posMax;
  555. }
  556. }
  557. else
  558. {
  559. negMin = -posMax;
  560. if(x < negMin)
  561. {
  562. x = negMin;
  563. }
  564. }
  565. return (x);
  566. }
  567. #endif /* end of ARM_MATH_CM0_FAMILY */
  568. /*
  569. * @brief C custom defined intrinsic function for M3 and M0 processors
  570. */
  571. #if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY)
  572. /*
  573. * @brief C custom defined QADD8 for M3 and M0 processors
  574. */
  575. static __INLINE q31_t __QADD8(
  576. q31_t x,
  577. q31_t y)
  578. {
  579. q31_t sum;
  580. q7_t r, s, t, u;
  581. r = (q7_t) x;
  582. s = (q7_t) y;
  583. r = __SSAT((q31_t) (r + s), 8);
  584. s = __SSAT(((q31_t) (((x << 16) >> 24) + ((y << 16) >> 24))), 8);
  585. t = __SSAT(((q31_t) (((x << 8) >> 24) + ((y << 8) >> 24))), 8);
  586. u = __SSAT(((q31_t) ((x >> 24) + (y >> 24))), 8);
  587. sum =
  588. (((q31_t) u << 24) & 0xFF000000) | (((q31_t) t << 16) & 0x00FF0000) |
  589. (((q31_t) s << 8) & 0x0000FF00) | (r & 0x000000FF);
  590. return sum;
  591. }
  592. /*
  593. * @brief C custom defined QSUB8 for M3 and M0 processors
  594. */
  595. static __INLINE q31_t __QSUB8(
  596. q31_t x,
  597. q31_t y)
  598. {
  599. q31_t sum;
  600. q31_t r, s, t, u;
  601. r = (q7_t) x;
  602. s = (q7_t) y;
  603. r = __SSAT((r - s), 8);
  604. s = __SSAT(((q31_t) (((x << 16) >> 24) - ((y << 16) >> 24))), 8) << 8;
  605. t = __SSAT(((q31_t) (((x << 8) >> 24) - ((y << 8) >> 24))), 8) << 16;
  606. u = __SSAT(((q31_t) ((x >> 24) - (y >> 24))), 8) << 24;
  607. sum =
  608. (u & 0xFF000000) | (t & 0x00FF0000) | (s & 0x0000FF00) | (r &
  609. 0x000000FF);
  610. return sum;
  611. }
  612. /*
  613. * @brief C custom defined QADD16 for M3 and M0 processors
  614. */
  615. /*
  616. * @brief C custom defined QADD16 for M3 and M0 processors
  617. */
  618. static __INLINE q31_t __QADD16(
  619. q31_t x,
  620. q31_t y)
  621. {
  622. q31_t sum;
  623. q31_t r, s;
  624. r = (short) x;
  625. s = (short) y;
  626. r = __SSAT(r + s, 16);
  627. s = __SSAT(((q31_t) ((x >> 16) + (y >> 16))), 16) << 16;
  628. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  629. return sum;
  630. }
  631. /*
  632. * @brief C custom defined SHADD16 for M3 and M0 processors
  633. */
  634. static __INLINE q31_t __SHADD16(
  635. q31_t x,
  636. q31_t y)
  637. {
  638. q31_t sum;
  639. q31_t r, s;
  640. r = (short) x;
  641. s = (short) y;
  642. r = ((r >> 1) + (s >> 1));
  643. s = ((q31_t) ((x >> 17) + (y >> 17))) << 16;
  644. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  645. return sum;
  646. }
  647. /*
  648. * @brief C custom defined QSUB16 for M3 and M0 processors
  649. */
  650. static __INLINE q31_t __QSUB16(
  651. q31_t x,
  652. q31_t y)
  653. {
  654. q31_t sum;
  655. q31_t r, s;
  656. r = (short) x;
  657. s = (short) y;
  658. r = __SSAT(r - s, 16);
  659. s = __SSAT(((q31_t) ((x >> 16) - (y >> 16))), 16) << 16;
  660. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  661. return sum;
  662. }
  663. /*
  664. * @brief C custom defined SHSUB16 for M3 and M0 processors
  665. */
  666. static __INLINE q31_t __SHSUB16(
  667. q31_t x,
  668. q31_t y)
  669. {
  670. q31_t diff;
  671. q31_t r, s;
  672. r = (short) x;
  673. s = (short) y;
  674. r = ((r >> 1) - (s >> 1));
  675. s = (((x >> 17) - (y >> 17)) << 16);
  676. diff = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  677. return diff;
  678. }
  679. /*
  680. * @brief C custom defined QASX for M3 and M0 processors
  681. */
  682. static __INLINE q31_t __QASX(
  683. q31_t x,
  684. q31_t y)
  685. {
  686. q31_t sum = 0;
  687. sum =
  688. ((sum +
  689. clip_q31_to_q15((q31_t) ((short) (x >> 16) + (short) y))) << 16) +
  690. clip_q31_to_q15((q31_t) ((short) x - (short) (y >> 16)));
  691. return sum;
  692. }
  693. /*
  694. * @brief C custom defined SHASX for M3 and M0 processors
  695. */
  696. static __INLINE q31_t __SHASX(
  697. q31_t x,
  698. q31_t y)
  699. {
  700. q31_t sum;
  701. q31_t r, s;
  702. r = (short) x;
  703. s = (short) y;
  704. r = ((r >> 1) - (y >> 17));
  705. s = (((x >> 17) + (s >> 1)) << 16);
  706. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  707. return sum;
  708. }
  709. /*
  710. * @brief C custom defined QSAX for M3 and M0 processors
  711. */
  712. static __INLINE q31_t __QSAX(
  713. q31_t x,
  714. q31_t y)
  715. {
  716. q31_t sum = 0;
  717. sum =
  718. ((sum +
  719. clip_q31_to_q15((q31_t) ((short) (x >> 16) - (short) y))) << 16) +
  720. clip_q31_to_q15((q31_t) ((short) x + (short) (y >> 16)));
  721. return sum;
  722. }
  723. /*
  724. * @brief C custom defined SHSAX for M3 and M0 processors
  725. */
  726. static __INLINE q31_t __SHSAX(
  727. q31_t x,
  728. q31_t y)
  729. {
  730. q31_t sum;
  731. q31_t r, s;
  732. r = (short) x;
  733. s = (short) y;
  734. r = ((r >> 1) + (y >> 17));
  735. s = (((x >> 17) - (s >> 1)) << 16);
  736. sum = (s & 0xFFFF0000) | (r & 0x0000FFFF);
  737. return sum;
  738. }
  739. /*
  740. * @brief C custom defined SMUSDX for M3 and M0 processors
  741. */
  742. static __INLINE q31_t __SMUSDX(
  743. q31_t x,
  744. q31_t y)
  745. {
  746. return ((q31_t) (((short) x * (short) (y >> 16)) -
  747. ((short) (x >> 16) * (short) y)));
  748. }
  749. /*
  750. * @brief C custom defined SMUADX for M3 and M0 processors
  751. */
  752. static __INLINE q31_t __SMUADX(
  753. q31_t x,
  754. q31_t y)
  755. {
  756. return ((q31_t) (((short) x * (short) (y >> 16)) +
  757. ((short) (x >> 16) * (short) y)));
  758. }
  759. /*
  760. * @brief C custom defined QADD for M3 and M0 processors
  761. */
  762. static __INLINE q31_t __QADD(
  763. q31_t x,
  764. q31_t y)
  765. {
  766. return clip_q63_to_q31((q63_t) x + y);
  767. }
  768. /*
  769. * @brief C custom defined QSUB for M3 and M0 processors
  770. */
  771. static __INLINE q31_t __QSUB(
  772. q31_t x,
  773. q31_t y)
  774. {
  775. return clip_q63_to_q31((q63_t) x - y);
  776. }
  777. /*
  778. * @brief C custom defined SMLAD for M3 and M0 processors
  779. */
  780. static __INLINE q31_t __SMLAD(
  781. q31_t x,
  782. q31_t y,
  783. q31_t sum)
  784. {
  785. return (sum + ((short) (x >> 16) * (short) (y >> 16)) +
  786. ((short) x * (short) y));
  787. }
  788. /*
  789. * @brief C custom defined SMLADX for M3 and M0 processors
  790. */
  791. static __INLINE q31_t __SMLADX(
  792. q31_t x,
  793. q31_t y,
  794. q31_t sum)
  795. {
  796. return (sum + ((short) (x >> 16) * (short) (y)) +
  797. ((short) x * (short) (y >> 16)));
  798. }
  799. /*
  800. * @brief C custom defined SMLSDX for M3 and M0 processors
  801. */
  802. static __INLINE q31_t __SMLSDX(
  803. q31_t x,
  804. q31_t y,
  805. q31_t sum)
  806. {
  807. return (sum - ((short) (x >> 16) * (short) (y)) +
  808. ((short) x * (short) (y >> 16)));
  809. }
  810. /*
  811. * @brief C custom defined SMLALD for M3 and M0 processors
  812. */
  813. static __INLINE q63_t __SMLALD(
  814. q31_t x,
  815. q31_t y,
  816. q63_t sum)
  817. {
  818. return (sum + ((short) (x >> 16) * (short) (y >> 16)) +
  819. ((short) x * (short) y));
  820. }
  821. /*
  822. * @brief C custom defined SMLALDX for M3 and M0 processors
  823. */
  824. static __INLINE q63_t __SMLALDX(
  825. q31_t x,
  826. q31_t y,
  827. q63_t sum)
  828. {
  829. return (sum + ((short) (x >> 16) * (short) y)) +
  830. ((short) x * (short) (y >> 16));
  831. }
  832. /*
  833. * @brief C custom defined SMUAD for M3 and M0 processors
  834. */
  835. static __INLINE q31_t __SMUAD(
  836. q31_t x,
  837. q31_t y)
  838. {
  839. return (((x >> 16) * (y >> 16)) +
  840. (((x << 16) >> 16) * ((y << 16) >> 16)));
  841. }
  842. /*
  843. * @brief C custom defined SMUSD for M3 and M0 processors
  844. */
  845. static __INLINE q31_t __SMUSD(
  846. q31_t x,
  847. q31_t y)
  848. {
  849. return (-((x >> 16) * (y >> 16)) +
  850. (((x << 16) >> 16) * ((y << 16) >> 16)));
  851. }
  852. /*
  853. * @brief C custom defined SXTB16 for M3 and M0 processors
  854. */
  855. static __INLINE q31_t __SXTB16(
  856. q31_t x)
  857. {
  858. return ((((x << 24) >> 24) & 0x0000FFFF) |
  859. (((x << 8) >> 8) & 0xFFFF0000));
  860. }
  861. #endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */
  862. /**
  863. * @brief Instance structure for the Q7 FIR filter.
  864. */
  865. typedef struct
  866. {
  867. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  868. q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  869. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  870. } arm_fir_instance_q7;
  871. /**
  872. * @brief Instance structure for the Q15 FIR filter.
  873. */
  874. typedef struct
  875. {
  876. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  877. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  878. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  879. } arm_fir_instance_q15;
  880. /**
  881. * @brief Instance structure for the Q31 FIR filter.
  882. */
  883. typedef struct
  884. {
  885. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  886. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  887. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  888. } arm_fir_instance_q31;
  889. /**
  890. * @brief Instance structure for the floating-point FIR filter.
  891. */
  892. typedef struct
  893. {
  894. uint16_t numTaps; /**< number of filter coefficients in the filter. */
  895. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  896. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  897. } arm_fir_instance_f32;
  898. /**
  899. * @brief Processing function for the Q7 FIR filter.
  900. * @param[in] *S points to an instance of the Q7 FIR filter structure.
  901. * @param[in] *pSrc points to the block of input data.
  902. * @param[out] *pDst points to the block of output data.
  903. * @param[in] blockSize number of samples to process.
  904. * @return none.
  905. */
  906. void arm_fir_q7(
  907. const arm_fir_instance_q7 * S,
  908. q7_t * pSrc,
  909. q7_t * pDst,
  910. uint32_t blockSize);
  911. /**
  912. * @brief Initialization function for the Q7 FIR filter.
  913. * @param[in,out] *S points to an instance of the Q7 FIR structure.
  914. * @param[in] numTaps Number of filter coefficients in the filter.
  915. * @param[in] *pCoeffs points to the filter coefficients.
  916. * @param[in] *pState points to the state buffer.
  917. * @param[in] blockSize number of samples that are processed.
  918. * @return none
  919. */
  920. void arm_fir_init_q7(
  921. arm_fir_instance_q7 * S,
  922. uint16_t numTaps,
  923. q7_t * pCoeffs,
  924. q7_t * pState,
  925. uint32_t blockSize);
  926. /**
  927. * @brief Processing function for the Q15 FIR filter.
  928. * @param[in] *S points to an instance of the Q15 FIR structure.
  929. * @param[in] *pSrc points to the block of input data.
  930. * @param[out] *pDst points to the block of output data.
  931. * @param[in] blockSize number of samples to process.
  932. * @return none.
  933. */
  934. void arm_fir_q15(
  935. const arm_fir_instance_q15 * S,
  936. q15_t * pSrc,
  937. q15_t * pDst,
  938. uint32_t blockSize);
  939. /**
  940. * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4.
  941. * @param[in] *S points to an instance of the Q15 FIR filter structure.
  942. * @param[in] *pSrc points to the block of input data.
  943. * @param[out] *pDst points to the block of output data.
  944. * @param[in] blockSize number of samples to process.
  945. * @return none.
  946. */
  947. void arm_fir_fast_q15(
  948. const arm_fir_instance_q15 * S,
  949. q15_t * pSrc,
  950. q15_t * pDst,
  951. uint32_t blockSize);
  952. /**
  953. * @brief Initialization function for the Q15 FIR filter.
  954. * @param[in,out] *S points to an instance of the Q15 FIR filter structure.
  955. * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4.
  956. * @param[in] *pCoeffs points to the filter coefficients.
  957. * @param[in] *pState points to the state buffer.
  958. * @param[in] blockSize number of samples that are processed at a time.
  959. * @return The function returns ARM_MATH_SUCCESS if initialization was successful or ARM_MATH_ARGUMENT_ERROR if
  960. * <code>numTaps</code> is not a supported value.
  961. */
  962. arm_status arm_fir_init_q15(
  963. arm_fir_instance_q15 * S,
  964. uint16_t numTaps,
  965. q15_t * pCoeffs,
  966. q15_t * pState,
  967. uint32_t blockSize);
  968. /**
  969. * @brief Processing function for the Q31 FIR filter.
  970. * @param[in] *S points to an instance of the Q31 FIR filter structure.
  971. * @param[in] *pSrc points to the block of input data.
  972. * @param[out] *pDst points to the block of output data.
  973. * @param[in] blockSize number of samples to process.
  974. * @return none.
  975. */
  976. void arm_fir_q31(
  977. const arm_fir_instance_q31 * S,
  978. q31_t * pSrc,
  979. q31_t * pDst,
  980. uint32_t blockSize);
  981. /**
  982. * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4.
  983. * @param[in] *S points to an instance of the Q31 FIR structure.
  984. * @param[in] *pSrc points to the block of input data.
  985. * @param[out] *pDst points to the block of output data.
  986. * @param[in] blockSize number of samples to process.
  987. * @return none.
  988. */
  989. void arm_fir_fast_q31(
  990. const arm_fir_instance_q31 * S,
  991. q31_t * pSrc,
  992. q31_t * pDst,
  993. uint32_t blockSize);
  994. /**
  995. * @brief Initialization function for the Q31 FIR filter.
  996. * @param[in,out] *S points to an instance of the Q31 FIR structure.
  997. * @param[in] numTaps Number of filter coefficients in the filter.
  998. * @param[in] *pCoeffs points to the filter coefficients.
  999. * @param[in] *pState points to the state buffer.
  1000. * @param[in] blockSize number of samples that are processed at a time.
  1001. * @return none.
  1002. */
  1003. void arm_fir_init_q31(
  1004. arm_fir_instance_q31 * S,
  1005. uint16_t numTaps,
  1006. q31_t * pCoeffs,
  1007. q31_t * pState,
  1008. uint32_t blockSize);
  1009. /**
  1010. * @brief Processing function for the floating-point FIR filter.
  1011. * @param[in] *S points to an instance of the floating-point FIR structure.
  1012. * @param[in] *pSrc points to the block of input data.
  1013. * @param[out] *pDst points to the block of output data.
  1014. * @param[in] blockSize number of samples to process.
  1015. * @return none.
  1016. */
  1017. void arm_fir_f32(
  1018. const arm_fir_instance_f32 * S,
  1019. float32_t * pSrc,
  1020. float32_t * pDst,
  1021. uint32_t blockSize);
  1022. /**
  1023. * @brief Initialization function for the floating-point FIR filter.
  1024. * @param[in,out] *S points to an instance of the floating-point FIR filter structure.
  1025. * @param[in] numTaps Number of filter coefficients in the filter.
  1026. * @param[in] *pCoeffs points to the filter coefficients.
  1027. * @param[in] *pState points to the state buffer.
  1028. * @param[in] blockSize number of samples that are processed at a time.
  1029. * @return none.
  1030. */
  1031. void arm_fir_init_f32(
  1032. arm_fir_instance_f32 * S,
  1033. uint16_t numTaps,
  1034. float32_t * pCoeffs,
  1035. float32_t * pState,
  1036. uint32_t blockSize);
  1037. /**
  1038. * @brief Instance structure for the Q15 Biquad cascade filter.
  1039. */
  1040. typedef struct
  1041. {
  1042. int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1043. q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1044. q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1045. int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1046. } arm_biquad_casd_df1_inst_q15;
  1047. /**
  1048. * @brief Instance structure for the Q31 Biquad cascade filter.
  1049. */
  1050. typedef struct
  1051. {
  1052. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1053. q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1054. q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1055. uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */
  1056. } arm_biquad_casd_df1_inst_q31;
  1057. /**
  1058. * @brief Instance structure for the floating-point Biquad cascade filter.
  1059. */
  1060. typedef struct
  1061. {
  1062. uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  1063. float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */
  1064. float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */
  1065. } arm_biquad_casd_df1_inst_f32;
  1066. /**
  1067. * @brief Processing function for the Q15 Biquad cascade filter.
  1068. * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
  1069. * @param[in] *pSrc points to the block of input data.
  1070. * @param[out] *pDst points to the block of output data.
  1071. * @param[in] blockSize number of samples to process.
  1072. * @return none.
  1073. */
  1074. void arm_biquad_cascade_df1_q15(
  1075. const arm_biquad_casd_df1_inst_q15 * S,
  1076. q15_t * pSrc,
  1077. q15_t * pDst,
  1078. uint32_t blockSize);
  1079. /**
  1080. * @brief Initialization function for the Q15 Biquad cascade filter.
  1081. * @param[in,out] *S points to an instance of the Q15 Biquad cascade structure.
  1082. * @param[in] numStages number of 2nd order stages in the filter.
  1083. * @param[in] *pCoeffs points to the filter coefficients.
  1084. * @param[in] *pState points to the state buffer.
  1085. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1086. * @return none
  1087. */
  1088. void arm_biquad_cascade_df1_init_q15(
  1089. arm_biquad_casd_df1_inst_q15 * S,
  1090. uint8_t numStages,
  1091. q15_t * pCoeffs,
  1092. q15_t * pState,
  1093. int8_t postShift);
  1094. /**
  1095. * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1096. * @param[in] *S points to an instance of the Q15 Biquad cascade structure.
  1097. * @param[in] *pSrc points to the block of input data.
  1098. * @param[out] *pDst points to the block of output data.
  1099. * @param[in] blockSize number of samples to process.
  1100. * @return none.
  1101. */
  1102. void arm_biquad_cascade_df1_fast_q15(
  1103. const arm_biquad_casd_df1_inst_q15 * S,
  1104. q15_t * pSrc,
  1105. q15_t * pDst,
  1106. uint32_t blockSize);
  1107. /**
  1108. * @brief Processing function for the Q31 Biquad cascade filter
  1109. * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
  1110. * @param[in] *pSrc points to the block of input data.
  1111. * @param[out] *pDst points to the block of output data.
  1112. * @param[in] blockSize number of samples to process.
  1113. * @return none.
  1114. */
  1115. void arm_biquad_cascade_df1_q31(
  1116. const arm_biquad_casd_df1_inst_q31 * S,
  1117. q31_t * pSrc,
  1118. q31_t * pDst,
  1119. uint32_t blockSize);
  1120. /**
  1121. * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4.
  1122. * @param[in] *S points to an instance of the Q31 Biquad cascade structure.
  1123. * @param[in] *pSrc points to the block of input data.
  1124. * @param[out] *pDst points to the block of output data.
  1125. * @param[in] blockSize number of samples to process.
  1126. * @return none.
  1127. */
  1128. void arm_biquad_cascade_df1_fast_q31(
  1129. const arm_biquad_casd_df1_inst_q31 * S,
  1130. q31_t * pSrc,
  1131. q31_t * pDst,
  1132. uint32_t blockSize);
  1133. /**
  1134. * @brief Initialization function for the Q31 Biquad cascade filter.
  1135. * @param[in,out] *S points to an instance of the Q31 Biquad cascade structure.
  1136. * @param[in] numStages number of 2nd order stages in the filter.
  1137. * @param[in] *pCoeffs points to the filter coefficients.
  1138. * @param[in] *pState points to the state buffer.
  1139. * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format
  1140. * @return none
  1141. */
  1142. void arm_biquad_cascade_df1_init_q31(
  1143. arm_biquad_casd_df1_inst_q31 * S,
  1144. uint8_t numStages,
  1145. q31_t * pCoeffs,
  1146. q31_t * pState,
  1147. int8_t postShift);
  1148. /**
  1149. * @brief Processing function for the floating-point Biquad cascade filter.
  1150. * @param[in] *S points to an instance of the floating-point Biquad cascade structure.
  1151. * @param[in] *pSrc points to the block of input data.
  1152. * @param[out] *pDst points to the block of output data.
  1153. * @param[in] blockSize number of samples to process.
  1154. * @return none.
  1155. */
  1156. void arm_biquad_cascade_df1_f32(
  1157. const arm_biquad_casd_df1_inst_f32 * S,
  1158. float32_t * pSrc,
  1159. float32_t * pDst,
  1160. uint32_t blockSize);
  1161. /**
  1162. * @brief Initialization function for the floating-point Biquad cascade filter.
  1163. * @param[in,out] *S points to an instance of the floating-point Biquad cascade structure.
  1164. * @param[in] numStages number of 2nd order stages in the filter.
  1165. * @param[in] *pCoeffs points to the filter coefficients.
  1166. * @param[in] *pState points to the state buffer.
  1167. * @return none
  1168. */
  1169. void arm_biquad_cascade_df1_init_f32(
  1170. arm_biquad_casd_df1_inst_f32 * S,
  1171. uint8_t numStages,
  1172. float32_t * pCoeffs,
  1173. float32_t * pState);
  1174. /**
  1175. * @brief Instance structure for the floating-point matrix structure.
  1176. */
  1177. typedef struct
  1178. {
  1179. uint16_t numRows; /**< number of rows of the matrix. */
  1180. uint16_t numCols; /**< number of columns of the matrix. */
  1181. float32_t *pData; /**< points to the data of the matrix. */
  1182. } arm_matrix_instance_f32;
  1183. /**
  1184. * @brief Instance structure for the Q15 matrix structure.
  1185. */
  1186. typedef struct
  1187. {
  1188. uint16_t numRows; /**< number of rows of the matrix. */
  1189. uint16_t numCols; /**< number of columns of the matrix. */
  1190. q15_t *pData; /**< points to the data of the matrix. */
  1191. } arm_matrix_instance_q15;
  1192. /**
  1193. * @brief Instance structure for the Q31 matrix structure.
  1194. */
  1195. typedef struct
  1196. {
  1197. uint16_t numRows; /**< number of rows of the matrix. */
  1198. uint16_t numCols; /**< number of columns of the matrix. */
  1199. q31_t *pData; /**< points to the data of the matrix. */
  1200. } arm_matrix_instance_q31;
  1201. /**
  1202. * @brief Floating-point matrix addition.
  1203. * @param[in] *pSrcA points to the first input matrix structure
  1204. * @param[in] *pSrcB points to the second input matrix structure
  1205. * @param[out] *pDst points to output matrix structure
  1206. * @return The function returns either
  1207. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1208. */
  1209. arm_status arm_mat_add_f32(
  1210. const arm_matrix_instance_f32 * pSrcA,
  1211. const arm_matrix_instance_f32 * pSrcB,
  1212. arm_matrix_instance_f32 * pDst);
  1213. /**
  1214. * @brief Q15 matrix addition.
  1215. * @param[in] *pSrcA points to the first input matrix structure
  1216. * @param[in] *pSrcB points to the second input matrix structure
  1217. * @param[out] *pDst points to output matrix structure
  1218. * @return The function returns either
  1219. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1220. */
  1221. arm_status arm_mat_add_q15(
  1222. const arm_matrix_instance_q15 * pSrcA,
  1223. const arm_matrix_instance_q15 * pSrcB,
  1224. arm_matrix_instance_q15 * pDst);
  1225. /**
  1226. * @brief Q31 matrix addition.
  1227. * @param[in] *pSrcA points to the first input matrix structure
  1228. * @param[in] *pSrcB points to the second input matrix structure
  1229. * @param[out] *pDst points to output matrix structure
  1230. * @return The function returns either
  1231. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1232. */
  1233. arm_status arm_mat_add_q31(
  1234. const arm_matrix_instance_q31 * pSrcA,
  1235. const arm_matrix_instance_q31 * pSrcB,
  1236. arm_matrix_instance_q31 * pDst);
  1237. /**
  1238. * @brief Floating-point matrix transpose.
  1239. * @param[in] *pSrc points to the input matrix
  1240. * @param[out] *pDst points to the output matrix
  1241. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1242. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1243. */
  1244. arm_status arm_mat_trans_f32(
  1245. const arm_matrix_instance_f32 * pSrc,
  1246. arm_matrix_instance_f32 * pDst);
  1247. /**
  1248. * @brief Q15 matrix transpose.
  1249. * @param[in] *pSrc points to the input matrix
  1250. * @param[out] *pDst points to the output matrix
  1251. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1252. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1253. */
  1254. arm_status arm_mat_trans_q15(
  1255. const arm_matrix_instance_q15 * pSrc,
  1256. arm_matrix_instance_q15 * pDst);
  1257. /**
  1258. * @brief Q31 matrix transpose.
  1259. * @param[in] *pSrc points to the input matrix
  1260. * @param[out] *pDst points to the output matrix
  1261. * @return The function returns either <code>ARM_MATH_SIZE_MISMATCH</code>
  1262. * or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1263. */
  1264. arm_status arm_mat_trans_q31(
  1265. const arm_matrix_instance_q31 * pSrc,
  1266. arm_matrix_instance_q31 * pDst);
  1267. /**
  1268. * @brief Floating-point matrix multiplication
  1269. * @param[in] *pSrcA points to the first input matrix structure
  1270. * @param[in] *pSrcB points to the second input matrix structure
  1271. * @param[out] *pDst points to output matrix structure
  1272. * @return The function returns either
  1273. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1274. */
  1275. arm_status arm_mat_mult_f32(
  1276. const arm_matrix_instance_f32 * pSrcA,
  1277. const arm_matrix_instance_f32 * pSrcB,
  1278. arm_matrix_instance_f32 * pDst);
  1279. /**
  1280. * @brief Q15 matrix multiplication
  1281. * @param[in] *pSrcA points to the first input matrix structure
  1282. * @param[in] *pSrcB points to the second input matrix structure
  1283. * @param[out] *pDst points to output matrix structure
  1284. * @param[in] *pState points to the array for storing intermediate results
  1285. * @return The function returns either
  1286. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1287. */
  1288. arm_status arm_mat_mult_q15(
  1289. const arm_matrix_instance_q15 * pSrcA,
  1290. const arm_matrix_instance_q15 * pSrcB,
  1291. arm_matrix_instance_q15 * pDst,
  1292. q15_t * pState);
  1293. /**
  1294. * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1295. * @param[in] *pSrcA points to the first input matrix structure
  1296. * @param[in] *pSrcB points to the second input matrix structure
  1297. * @param[out] *pDst points to output matrix structure
  1298. * @param[in] *pState points to the array for storing intermediate results
  1299. * @return The function returns either
  1300. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1301. */
  1302. arm_status arm_mat_mult_fast_q15(
  1303. const arm_matrix_instance_q15 * pSrcA,
  1304. const arm_matrix_instance_q15 * pSrcB,
  1305. arm_matrix_instance_q15 * pDst,
  1306. q15_t * pState);
  1307. /**
  1308. * @brief Q31 matrix multiplication
  1309. * @param[in] *pSrcA points to the first input matrix structure
  1310. * @param[in] *pSrcB points to the second input matrix structure
  1311. * @param[out] *pDst points to output matrix structure
  1312. * @return The function returns either
  1313. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1314. */
  1315. arm_status arm_mat_mult_q31(
  1316. const arm_matrix_instance_q31 * pSrcA,
  1317. const arm_matrix_instance_q31 * pSrcB,
  1318. arm_matrix_instance_q31 * pDst);
  1319. /**
  1320. * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4
  1321. * @param[in] *pSrcA points to the first input matrix structure
  1322. * @param[in] *pSrcB points to the second input matrix structure
  1323. * @param[out] *pDst points to output matrix structure
  1324. * @return The function returns either
  1325. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1326. */
  1327. arm_status arm_mat_mult_fast_q31(
  1328. const arm_matrix_instance_q31 * pSrcA,
  1329. const arm_matrix_instance_q31 * pSrcB,
  1330. arm_matrix_instance_q31 * pDst);
  1331. /**
  1332. * @brief Floating-point matrix subtraction
  1333. * @param[in] *pSrcA points to the first input matrix structure
  1334. * @param[in] *pSrcB points to the second input matrix structure
  1335. * @param[out] *pDst points to output matrix structure
  1336. * @return The function returns either
  1337. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1338. */
  1339. arm_status arm_mat_sub_f32(
  1340. const arm_matrix_instance_f32 * pSrcA,
  1341. const arm_matrix_instance_f32 * pSrcB,
  1342. arm_matrix_instance_f32 * pDst);
  1343. /**
  1344. * @brief Q15 matrix subtraction
  1345. * @param[in] *pSrcA points to the first input matrix structure
  1346. * @param[in] *pSrcB points to the second input matrix structure
  1347. * @param[out] *pDst points to output matrix structure
  1348. * @return The function returns either
  1349. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1350. */
  1351. arm_status arm_mat_sub_q15(
  1352. const arm_matrix_instance_q15 * pSrcA,
  1353. const arm_matrix_instance_q15 * pSrcB,
  1354. arm_matrix_instance_q15 * pDst);
  1355. /**
  1356. * @brief Q31 matrix subtraction
  1357. * @param[in] *pSrcA points to the first input matrix structure
  1358. * @param[in] *pSrcB points to the second input matrix structure
  1359. * @param[out] *pDst points to output matrix structure
  1360. * @return The function returns either
  1361. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1362. */
  1363. arm_status arm_mat_sub_q31(
  1364. const arm_matrix_instance_q31 * pSrcA,
  1365. const arm_matrix_instance_q31 * pSrcB,
  1366. arm_matrix_instance_q31 * pDst);
  1367. /**
  1368. * @brief Floating-point matrix scaling.
  1369. * @param[in] *pSrc points to the input matrix
  1370. * @param[in] scale scale factor
  1371. * @param[out] *pDst points to the output matrix
  1372. * @return The function returns either
  1373. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1374. */
  1375. arm_status arm_mat_scale_f32(
  1376. const arm_matrix_instance_f32 * pSrc,
  1377. float32_t scale,
  1378. arm_matrix_instance_f32 * pDst);
  1379. /**
  1380. * @brief Q15 matrix scaling.
  1381. * @param[in] *pSrc points to input matrix
  1382. * @param[in] scaleFract fractional portion of the scale factor
  1383. * @param[in] shift number of bits to shift the result by
  1384. * @param[out] *pDst points to output matrix
  1385. * @return The function returns either
  1386. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1387. */
  1388. arm_status arm_mat_scale_q15(
  1389. const arm_matrix_instance_q15 * pSrc,
  1390. q15_t scaleFract,
  1391. int32_t shift,
  1392. arm_matrix_instance_q15 * pDst);
  1393. /**
  1394. * @brief Q31 matrix scaling.
  1395. * @param[in] *pSrc points to input matrix
  1396. * @param[in] scaleFract fractional portion of the scale factor
  1397. * @param[in] shift number of bits to shift the result by
  1398. * @param[out] *pDst points to output matrix structure
  1399. * @return The function returns either
  1400. * <code>ARM_MATH_SIZE_MISMATCH</code> or <code>ARM_MATH_SUCCESS</code> based on the outcome of size checking.
  1401. */
  1402. arm_status arm_mat_scale_q31(
  1403. const arm_matrix_instance_q31 * pSrc,
  1404. q31_t scaleFract,
  1405. int32_t shift,
  1406. arm_matrix_instance_q31 * pDst);
  1407. /**
  1408. * @brief Q31 matrix initialization.
  1409. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1410. * @param[in] nRows number of rows in the matrix.
  1411. * @param[in] nColumns number of columns in the matrix.
  1412. * @param[in] *pData points to the matrix data array.
  1413. * @return none
  1414. */
  1415. void arm_mat_init_q31(
  1416. arm_matrix_instance_q31 * S,
  1417. uint16_t nRows,
  1418. uint16_t nColumns,
  1419. q31_t * pData);
  1420. /**
  1421. * @brief Q15 matrix initialization.
  1422. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1423. * @param[in] nRows number of rows in the matrix.
  1424. * @param[in] nColumns number of columns in the matrix.
  1425. * @param[in] *pData points to the matrix data array.
  1426. * @return none
  1427. */
  1428. void arm_mat_init_q15(
  1429. arm_matrix_instance_q15 * S,
  1430. uint16_t nRows,
  1431. uint16_t nColumns,
  1432. q15_t * pData);
  1433. /**
  1434. * @brief Floating-point matrix initialization.
  1435. * @param[in,out] *S points to an instance of the floating-point matrix structure.
  1436. * @param[in] nRows number of rows in the matrix.
  1437. * @param[in] nColumns number of columns in the matrix.
  1438. * @param[in] *pData points to the matrix data array.
  1439. * @return none
  1440. */
  1441. void arm_mat_init_f32(
  1442. arm_matrix_instance_f32 * S,
  1443. uint16_t nRows,
  1444. uint16_t nColumns,
  1445. float32_t * pData);
  1446. /**
  1447. * @brief Instance structure for the Q15 PID Control.
  1448. */
  1449. typedef struct
  1450. {
  1451. q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1452. #ifdef ARM_MATH_CM0_FAMILY
  1453. q15_t A1;
  1454. q15_t A2;
  1455. #else
  1456. q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
  1457. #endif
  1458. q15_t state[3]; /**< The state array of length 3. */
  1459. q15_t Kp; /**< The proportional gain. */
  1460. q15_t Ki; /**< The integral gain. */
  1461. q15_t Kd; /**< The derivative gain. */
  1462. } arm_pid_instance_q15;
  1463. /**
  1464. * @brief Instance structure for the Q31 PID Control.
  1465. */
  1466. typedef struct
  1467. {
  1468. q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1469. q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1470. q31_t A2; /**< The derived gain, A2 = Kd . */
  1471. q31_t state[3]; /**< The state array of length 3. */
  1472. q31_t Kp; /**< The proportional gain. */
  1473. q31_t Ki; /**< The integral gain. */
  1474. q31_t Kd; /**< The derivative gain. */
  1475. } arm_pid_instance_q31;
  1476. /**
  1477. * @brief Instance structure for the floating-point PID Control.
  1478. */
  1479. typedef struct
  1480. {
  1481. float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */
  1482. float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */
  1483. float32_t A2; /**< The derived gain, A2 = Kd . */
  1484. float32_t state[3]; /**< The state array of length 3. */
  1485. float32_t Kp; /**< The proportional gain. */
  1486. float32_t Ki; /**< The integral gain. */
  1487. float32_t Kd; /**< The derivative gain. */
  1488. } arm_pid_instance_f32;
  1489. /**
  1490. * @brief Initialization function for the floating-point PID Control.
  1491. * @param[in,out] *S points to an instance of the PID structure.
  1492. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1493. * @return none.
  1494. */
  1495. void arm_pid_init_f32(
  1496. arm_pid_instance_f32 * S,
  1497. int32_t resetStateFlag);
  1498. /**
  1499. * @brief Reset function for the floating-point PID Control.
  1500. * @param[in,out] *S is an instance of the floating-point PID Control structure
  1501. * @return none
  1502. */
  1503. void arm_pid_reset_f32(
  1504. arm_pid_instance_f32 * S);
  1505. /**
  1506. * @brief Initialization function for the Q31 PID Control.
  1507. * @param[in,out] *S points to an instance of the Q15 PID structure.
  1508. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1509. * @return none.
  1510. */
  1511. void arm_pid_init_q31(
  1512. arm_pid_instance_q31 * S,
  1513. int32_t resetStateFlag);
  1514. /**
  1515. * @brief Reset function for the Q31 PID Control.
  1516. * @param[in,out] *S points to an instance of the Q31 PID Control structure
  1517. * @return none
  1518. */
  1519. void arm_pid_reset_q31(
  1520. arm_pid_instance_q31 * S);
  1521. /**
  1522. * @brief Initialization function for the Q15 PID Control.
  1523. * @param[in,out] *S points to an instance of the Q15 PID structure.
  1524. * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state.
  1525. * @return none.
  1526. */
  1527. void arm_pid_init_q15(
  1528. arm_pid_instance_q15 * S,
  1529. int32_t resetStateFlag);
  1530. /**
  1531. * @brief Reset function for the Q15 PID Control.
  1532. * @param[in,out] *S points to an instance of the q15 PID Control structure
  1533. * @return none
  1534. */
  1535. void arm_pid_reset_q15(
  1536. arm_pid_instance_q15 * S);
  1537. /**
  1538. * @brief Instance structure for the floating-point Linear Interpolate function.
  1539. */
  1540. typedef struct
  1541. {
  1542. uint32_t nValues; /**< nValues */
  1543. float32_t x1; /**< x1 */
  1544. float32_t xSpacing; /**< xSpacing */
  1545. float32_t *pYData; /**< pointer to the table of Y values */
  1546. } arm_linear_interp_instance_f32;
  1547. /**
  1548. * @brief Instance structure for the floating-point bilinear interpolation function.
  1549. */
  1550. typedef struct
  1551. {
  1552. uint16_t numRows; /**< number of rows in the data table. */
  1553. uint16_t numCols; /**< number of columns in the data table. */
  1554. float32_t *pData; /**< points to the data table. */
  1555. } arm_bilinear_interp_instance_f32;
  1556. /**
  1557. * @brief Instance structure for the Q31 bilinear interpolation function.
  1558. */
  1559. typedef struct
  1560. {
  1561. uint16_t numRows; /**< number of rows in the data table. */
  1562. uint16_t numCols; /**< number of columns in the data table. */
  1563. q31_t *pData; /**< points to the data table. */
  1564. } arm_bilinear_interp_instance_q31;
  1565. /**
  1566. * @brief Instance structure for the Q15 bilinear interpolation function.
  1567. */
  1568. typedef struct
  1569. {
  1570. uint16_t numRows; /**< number of rows in the data table. */
  1571. uint16_t numCols; /**< number of columns in the data table. */
  1572. q15_t *pData; /**< points to the data table. */
  1573. } arm_bilinear_interp_instance_q15;
  1574. /**
  1575. * @brief Instance structure for the Q15 bilinear interpolation function.
  1576. */
  1577. typedef struct
  1578. {
  1579. uint16_t numRows; /**< number of rows in the data table. */
  1580. uint16_t numCols; /**< number of columns in the data table. */
  1581. q7_t *pData; /**< points to the data table. */
  1582. } arm_bilinear_interp_instance_q7;
  1583. /**
  1584. * @brief Q7 vector multiplication.
  1585. * @param[in] *pSrcA points to the first input vector
  1586. * @param[in] *pSrcB points to the second input vector
  1587. * @param[out] *pDst points to the output vector
  1588. * @param[in] blockSize number of samples in each vector
  1589. * @return none.
  1590. */
  1591. void arm_mult_q7(
  1592. q7_t * pSrcA,
  1593. q7_t * pSrcB,
  1594. q7_t * pDst,
  1595. uint32_t blockSize);
  1596. /**
  1597. * @brief Q15 vector multiplication.
  1598. * @param[in] *pSrcA points to the first input vector
  1599. * @param[in] *pSrcB points to the second input vector
  1600. * @param[out] *pDst points to the output vector
  1601. * @param[in] blockSize number of samples in each vector
  1602. * @return none.
  1603. */
  1604. void arm_mult_q15(
  1605. q15_t * pSrcA,
  1606. q15_t * pSrcB,
  1607. q15_t * pDst,
  1608. uint32_t blockSize);
  1609. /**
  1610. * @brief Q31 vector multiplication.
  1611. * @param[in] *pSrcA points to the first input vector
  1612. * @param[in] *pSrcB points to the second input vector
  1613. * @param[out] *pDst points to the output vector
  1614. * @param[in] blockSize number of samples in each vector
  1615. * @return none.
  1616. */
  1617. void arm_mult_q31(
  1618. q31_t * pSrcA,
  1619. q31_t * pSrcB,
  1620. q31_t * pDst,
  1621. uint32_t blockSize);
  1622. /**
  1623. * @brief Floating-point vector multiplication.
  1624. * @param[in] *pSrcA points to the first input vector
  1625. * @param[in] *pSrcB points to the second input vector
  1626. * @param[out] *pDst points to the output vector
  1627. * @param[in] blockSize number of samples in each vector
  1628. * @return none.
  1629. */
  1630. void arm_mult_f32(
  1631. float32_t * pSrcA,
  1632. float32_t * pSrcB,
  1633. float32_t * pDst,
  1634. uint32_t blockSize);
  1635. /**
  1636. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1637. */
  1638. typedef struct
  1639. {
  1640. uint16_t fftLen; /**< length of the FFT. */
  1641. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1642. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1643. q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */
  1644. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1645. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1646. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1647. } arm_cfft_radix2_instance_q15;
  1648. arm_status arm_cfft_radix2_init_q15(
  1649. arm_cfft_radix2_instance_q15 * S,
  1650. uint16_t fftLen,
  1651. uint8_t ifftFlag,
  1652. uint8_t bitReverseFlag);
  1653. void arm_cfft_radix2_q15(
  1654. const arm_cfft_radix2_instance_q15 * S,
  1655. q15_t * pSrc);
  1656. /**
  1657. * @brief Instance structure for the Q15 CFFT/CIFFT function.
  1658. */
  1659. typedef struct
  1660. {
  1661. uint16_t fftLen; /**< length of the FFT. */
  1662. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1663. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1664. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1665. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1666. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1667. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1668. } arm_cfft_radix4_instance_q15;
  1669. arm_status arm_cfft_radix4_init_q15(
  1670. arm_cfft_radix4_instance_q15 * S,
  1671. uint16_t fftLen,
  1672. uint8_t ifftFlag,
  1673. uint8_t bitReverseFlag);
  1674. void arm_cfft_radix4_q15(
  1675. const arm_cfft_radix4_instance_q15 * S,
  1676. q15_t * pSrc);
  1677. /**
  1678. * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function.
  1679. */
  1680. typedef struct
  1681. {
  1682. uint16_t fftLen; /**< length of the FFT. */
  1683. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1684. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1685. q31_t *pTwiddle; /**< points to the Twiddle factor table. */
  1686. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1687. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1688. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1689. } arm_cfft_radix2_instance_q31;
  1690. arm_status arm_cfft_radix2_init_q31(
  1691. arm_cfft_radix2_instance_q31 * S,
  1692. uint16_t fftLen,
  1693. uint8_t ifftFlag,
  1694. uint8_t bitReverseFlag);
  1695. void arm_cfft_radix2_q31(
  1696. const arm_cfft_radix2_instance_q31 * S,
  1697. q31_t * pSrc);
  1698. /**
  1699. * @brief Instance structure for the Q31 CFFT/CIFFT function.
  1700. */
  1701. typedef struct
  1702. {
  1703. uint16_t fftLen; /**< length of the FFT. */
  1704. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1705. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1706. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1707. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1708. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1709. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1710. } arm_cfft_radix4_instance_q31;
  1711. void arm_cfft_radix4_q31(
  1712. const arm_cfft_radix4_instance_q31 * S,
  1713. q31_t * pSrc);
  1714. arm_status arm_cfft_radix4_init_q31(
  1715. arm_cfft_radix4_instance_q31 * S,
  1716. uint16_t fftLen,
  1717. uint8_t ifftFlag,
  1718. uint8_t bitReverseFlag);
  1719. /**
  1720. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1721. */
  1722. typedef struct
  1723. {
  1724. uint16_t fftLen; /**< length of the FFT. */
  1725. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1726. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1727. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1728. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1729. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1730. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1731. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1732. } arm_cfft_radix2_instance_f32;
  1733. /* Deprecated */
  1734. arm_status arm_cfft_radix2_init_f32(
  1735. arm_cfft_radix2_instance_f32 * S,
  1736. uint16_t fftLen,
  1737. uint8_t ifftFlag,
  1738. uint8_t bitReverseFlag);
  1739. /* Deprecated */
  1740. void arm_cfft_radix2_f32(
  1741. const arm_cfft_radix2_instance_f32 * S,
  1742. float32_t * pSrc);
  1743. /**
  1744. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1745. */
  1746. typedef struct
  1747. {
  1748. uint16_t fftLen; /**< length of the FFT. */
  1749. uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */
  1750. uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */
  1751. float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1752. uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1753. uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1754. uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */
  1755. float32_t onebyfftLen; /**< value of 1/fftLen. */
  1756. } arm_cfft_radix4_instance_f32;
  1757. /* Deprecated */
  1758. arm_status arm_cfft_radix4_init_f32(
  1759. arm_cfft_radix4_instance_f32 * S,
  1760. uint16_t fftLen,
  1761. uint8_t ifftFlag,
  1762. uint8_t bitReverseFlag);
  1763. /* Deprecated */
  1764. void arm_cfft_radix4_f32(
  1765. const arm_cfft_radix4_instance_f32 * S,
  1766. float32_t * pSrc);
  1767. /**
  1768. * @brief Instance structure for the floating-point CFFT/CIFFT function.
  1769. */
  1770. typedef struct
  1771. {
  1772. uint16_t fftLen; /**< length of the FFT. */
  1773. const float32_t *pTwiddle; /**< points to the Twiddle factor table. */
  1774. const uint16_t *pBitRevTable; /**< points to the bit reversal table. */
  1775. uint16_t bitRevLength; /**< bit reversal table length. */
  1776. } arm_cfft_instance_f32;
  1777. void arm_cfft_f32(
  1778. const arm_cfft_instance_f32 * S,
  1779. float32_t * p1,
  1780. uint8_t ifftFlag,
  1781. uint8_t bitReverseFlag);
  1782. /**
  1783. * @brief Instance structure for the Q15 RFFT/RIFFT function.
  1784. */
  1785. typedef struct
  1786. {
  1787. uint32_t fftLenReal; /**< length of the real FFT. */
  1788. uint32_t fftLenBy2; /**< length of the complex FFT. */
  1789. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1790. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1791. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1792. q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1793. q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1794. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1795. } arm_rfft_instance_q15;
  1796. arm_status arm_rfft_init_q15(
  1797. arm_rfft_instance_q15 * S,
  1798. arm_cfft_radix4_instance_q15 * S_CFFT,
  1799. uint32_t fftLenReal,
  1800. uint32_t ifftFlagR,
  1801. uint32_t bitReverseFlag);
  1802. void arm_rfft_q15(
  1803. const arm_rfft_instance_q15 * S,
  1804. q15_t * pSrc,
  1805. q15_t * pDst);
  1806. /**
  1807. * @brief Instance structure for the Q31 RFFT/RIFFT function.
  1808. */
  1809. typedef struct
  1810. {
  1811. uint32_t fftLenReal; /**< length of the real FFT. */
  1812. uint32_t fftLenBy2; /**< length of the complex FFT. */
  1813. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1814. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1815. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1816. q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1817. q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1818. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1819. } arm_rfft_instance_q31;
  1820. arm_status arm_rfft_init_q31(
  1821. arm_rfft_instance_q31 * S,
  1822. arm_cfft_radix4_instance_q31 * S_CFFT,
  1823. uint32_t fftLenReal,
  1824. uint32_t ifftFlagR,
  1825. uint32_t bitReverseFlag);
  1826. void arm_rfft_q31(
  1827. const arm_rfft_instance_q31 * S,
  1828. q31_t * pSrc,
  1829. q31_t * pDst);
  1830. /**
  1831. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1832. */
  1833. typedef struct
  1834. {
  1835. uint32_t fftLenReal; /**< length of the real FFT. */
  1836. uint16_t fftLenBy2; /**< length of the complex FFT. */
  1837. uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */
  1838. uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */
  1839. uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */
  1840. float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */
  1841. float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */
  1842. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1843. } arm_rfft_instance_f32;
  1844. arm_status arm_rfft_init_f32(
  1845. arm_rfft_instance_f32 * S,
  1846. arm_cfft_radix4_instance_f32 * S_CFFT,
  1847. uint32_t fftLenReal,
  1848. uint32_t ifftFlagR,
  1849. uint32_t bitReverseFlag);
  1850. void arm_rfft_f32(
  1851. const arm_rfft_instance_f32 * S,
  1852. float32_t * pSrc,
  1853. float32_t * pDst);
  1854. /**
  1855. * @brief Instance structure for the floating-point RFFT/RIFFT function.
  1856. */
  1857. typedef struct
  1858. {
  1859. arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */
  1860. uint16_t fftLenRFFT; /**< length of the real sequence */
  1861. float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */
  1862. } arm_rfft_fast_instance_f32 ;
  1863. arm_status arm_rfft_fast_init_f32 (
  1864. arm_rfft_fast_instance_f32 * S,
  1865. uint16_t fftLen);
  1866. void arm_rfft_fast_f32(
  1867. arm_rfft_fast_instance_f32 * S,
  1868. float32_t * p, float32_t * pOut,
  1869. uint8_t ifftFlag);
  1870. /**
  1871. * @brief Instance structure for the floating-point DCT4/IDCT4 function.
  1872. */
  1873. typedef struct
  1874. {
  1875. uint16_t N; /**< length of the DCT4. */
  1876. uint16_t Nby2; /**< half of the length of the DCT4. */
  1877. float32_t normalize; /**< normalizing factor. */
  1878. float32_t *pTwiddle; /**< points to the twiddle factor table. */
  1879. float32_t *pCosFactor; /**< points to the cosFactor table. */
  1880. arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */
  1881. arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */
  1882. } arm_dct4_instance_f32;
  1883. /**
  1884. * @brief Initialization function for the floating-point DCT4/IDCT4.
  1885. * @param[in,out] *S points to an instance of floating-point DCT4/IDCT4 structure.
  1886. * @param[in] *S_RFFT points to an instance of floating-point RFFT/RIFFT structure.
  1887. * @param[in] *S_CFFT points to an instance of floating-point CFFT/CIFFT structure.
  1888. * @param[in] N length of the DCT4.
  1889. * @param[in] Nby2 half of the length of the DCT4.
  1890. * @param[in] normalize normalizing factor.
  1891. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>fftLenReal</code> is not a supported transform length.
  1892. */
  1893. arm_status arm_dct4_init_f32(
  1894. arm_dct4_instance_f32 * S,
  1895. arm_rfft_instance_f32 * S_RFFT,
  1896. arm_cfft_radix4_instance_f32 * S_CFFT,
  1897. uint16_t N,
  1898. uint16_t Nby2,
  1899. float32_t normalize);
  1900. /**
  1901. * @brief Processing function for the floating-point DCT4/IDCT4.
  1902. * @param[in] *S points to an instance of the floating-point DCT4/IDCT4 structure.
  1903. * @param[in] *pState points to state buffer.
  1904. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  1905. * @return none.
  1906. */
  1907. void arm_dct4_f32(
  1908. const arm_dct4_instance_f32 * S,
  1909. float32_t * pState,
  1910. float32_t * pInlineBuffer);
  1911. /**
  1912. * @brief Instance structure for the Q31 DCT4/IDCT4 function.
  1913. */
  1914. typedef struct
  1915. {
  1916. uint16_t N; /**< length of the DCT4. */
  1917. uint16_t Nby2; /**< half of the length of the DCT4. */
  1918. q31_t normalize; /**< normalizing factor. */
  1919. q31_t *pTwiddle; /**< points to the twiddle factor table. */
  1920. q31_t *pCosFactor; /**< points to the cosFactor table. */
  1921. arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */
  1922. arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */
  1923. } arm_dct4_instance_q31;
  1924. /**
  1925. * @brief Initialization function for the Q31 DCT4/IDCT4.
  1926. * @param[in,out] *S points to an instance of Q31 DCT4/IDCT4 structure.
  1927. * @param[in] *S_RFFT points to an instance of Q31 RFFT/RIFFT structure
  1928. * @param[in] *S_CFFT points to an instance of Q31 CFFT/CIFFT structure
  1929. * @param[in] N length of the DCT4.
  1930. * @param[in] Nby2 half of the length of the DCT4.
  1931. * @param[in] normalize normalizing factor.
  1932. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  1933. */
  1934. arm_status arm_dct4_init_q31(
  1935. arm_dct4_instance_q31 * S,
  1936. arm_rfft_instance_q31 * S_RFFT,
  1937. arm_cfft_radix4_instance_q31 * S_CFFT,
  1938. uint16_t N,
  1939. uint16_t Nby2,
  1940. q31_t normalize);
  1941. /**
  1942. * @brief Processing function for the Q31 DCT4/IDCT4.
  1943. * @param[in] *S points to an instance of the Q31 DCT4 structure.
  1944. * @param[in] *pState points to state buffer.
  1945. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  1946. * @return none.
  1947. */
  1948. void arm_dct4_q31(
  1949. const arm_dct4_instance_q31 * S,
  1950. q31_t * pState,
  1951. q31_t * pInlineBuffer);
  1952. /**
  1953. * @brief Instance structure for the Q15 DCT4/IDCT4 function.
  1954. */
  1955. typedef struct
  1956. {
  1957. uint16_t N; /**< length of the DCT4. */
  1958. uint16_t Nby2; /**< half of the length of the DCT4. */
  1959. q15_t normalize; /**< normalizing factor. */
  1960. q15_t *pTwiddle; /**< points to the twiddle factor table. */
  1961. q15_t *pCosFactor; /**< points to the cosFactor table. */
  1962. arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */
  1963. arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */
  1964. } arm_dct4_instance_q15;
  1965. /**
  1966. * @brief Initialization function for the Q15 DCT4/IDCT4.
  1967. * @param[in,out] *S points to an instance of Q15 DCT4/IDCT4 structure.
  1968. * @param[in] *S_RFFT points to an instance of Q15 RFFT/RIFFT structure.
  1969. * @param[in] *S_CFFT points to an instance of Q15 CFFT/CIFFT structure.
  1970. * @param[in] N length of the DCT4.
  1971. * @param[in] Nby2 half of the length of the DCT4.
  1972. * @param[in] normalize normalizing factor.
  1973. * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if <code>N</code> is not a supported transform length.
  1974. */
  1975. arm_status arm_dct4_init_q15(
  1976. arm_dct4_instance_q15 * S,
  1977. arm_rfft_instance_q15 * S_RFFT,
  1978. arm_cfft_radix4_instance_q15 * S_CFFT,
  1979. uint16_t N,
  1980. uint16_t Nby2,
  1981. q15_t normalize);
  1982. /**
  1983. * @brief Processing function for the Q15 DCT4/IDCT4.
  1984. * @param[in] *S points to an instance of the Q15 DCT4 structure.
  1985. * @param[in] *pState points to state buffer.
  1986. * @param[in,out] *pInlineBuffer points to the in-place input and output buffer.
  1987. * @return none.
  1988. */
  1989. void arm_dct4_q15(
  1990. const arm_dct4_instance_q15 * S,
  1991. q15_t * pState,
  1992. q15_t * pInlineBuffer);
  1993. /**
  1994. * @brief Floating-point vector addition.
  1995. * @param[in] *pSrcA points to the first input vector
  1996. * @param[in] *pSrcB points to the second input vector
  1997. * @param[out] *pDst points to the output vector
  1998. * @param[in] blockSize number of samples in each vector
  1999. * @return none.
  2000. */
  2001. void arm_add_f32(
  2002. float32_t * pSrcA,
  2003. float32_t * pSrcB,
  2004. float32_t * pDst,
  2005. uint32_t blockSize);
  2006. /**
  2007. * @brief Q7 vector addition.
  2008. * @param[in] *pSrcA points to the first input vector
  2009. * @param[in] *pSrcB points to the second input vector
  2010. * @param[out] *pDst points to the output vector
  2011. * @param[in] blockSize number of samples in each vector
  2012. * @return none.
  2013. */
  2014. void arm_add_q7(
  2015. q7_t * pSrcA,
  2016. q7_t * pSrcB,
  2017. q7_t * pDst,
  2018. uint32_t blockSize);
  2019. /**
  2020. * @brief Q15 vector addition.
  2021. * @param[in] *pSrcA points to the first input vector
  2022. * @param[in] *pSrcB points to the second input vector
  2023. * @param[out] *pDst points to the output vector
  2024. * @param[in] blockSize number of samples in each vector
  2025. * @return none.
  2026. */
  2027. void arm_add_q15(
  2028. q15_t * pSrcA,
  2029. q15_t * pSrcB,
  2030. q15_t * pDst,
  2031. uint32_t blockSize);
  2032. /**
  2033. * @brief Q31 vector addition.
  2034. * @param[in] *pSrcA points to the first input vector
  2035. * @param[in] *pSrcB points to the second input vector
  2036. * @param[out] *pDst points to the output vector
  2037. * @param[in] blockSize number of samples in each vector
  2038. * @return none.
  2039. */
  2040. void arm_add_q31(
  2041. q31_t * pSrcA,
  2042. q31_t * pSrcB,
  2043. q31_t * pDst,
  2044. uint32_t blockSize);
  2045. /**
  2046. * @brief Floating-point vector subtraction.
  2047. * @param[in] *pSrcA points to the first input vector
  2048. * @param[in] *pSrcB points to the second input vector
  2049. * @param[out] *pDst points to the output vector
  2050. * @param[in] blockSize number of samples in each vector
  2051. * @return none.
  2052. */
  2053. void arm_sub_f32(
  2054. float32_t * pSrcA,
  2055. float32_t * pSrcB,
  2056. float32_t * pDst,
  2057. uint32_t blockSize);
  2058. /**
  2059. * @brief Q7 vector subtraction.
  2060. * @param[in] *pSrcA points to the first input vector
  2061. * @param[in] *pSrcB points to the second input vector
  2062. * @param[out] *pDst points to the output vector
  2063. * @param[in] blockSize number of samples in each vector
  2064. * @return none.
  2065. */
  2066. void arm_sub_q7(
  2067. q7_t * pSrcA,
  2068. q7_t * pSrcB,
  2069. q7_t * pDst,
  2070. uint32_t blockSize);
  2071. /**
  2072. * @brief Q15 vector subtraction.
  2073. * @param[in] *pSrcA points to the first input vector
  2074. * @param[in] *pSrcB points to the second input vector
  2075. * @param[out] *pDst points to the output vector
  2076. * @param[in] blockSize number of samples in each vector
  2077. * @return none.
  2078. */
  2079. void arm_sub_q15(
  2080. q15_t * pSrcA,
  2081. q15_t * pSrcB,
  2082. q15_t * pDst,
  2083. uint32_t blockSize);
  2084. /**
  2085. * @brief Q31 vector subtraction.
  2086. * @param[in] *pSrcA points to the first input vector
  2087. * @param[in] *pSrcB points to the second input vector
  2088. * @param[out] *pDst points to the output vector
  2089. * @param[in] blockSize number of samples in each vector
  2090. * @return none.
  2091. */
  2092. void arm_sub_q31(
  2093. q31_t * pSrcA,
  2094. q31_t * pSrcB,
  2095. q31_t * pDst,
  2096. uint32_t blockSize);
  2097. /**
  2098. * @brief Multiplies a floating-point vector by a scalar.
  2099. * @param[in] *pSrc points to the input vector
  2100. * @param[in] scale scale factor to be applied
  2101. * @param[out] *pDst points to the output vector
  2102. * @param[in] blockSize number of samples in the vector
  2103. * @return none.
  2104. */
  2105. void arm_scale_f32(
  2106. float32_t * pSrc,
  2107. float32_t scale,
  2108. float32_t * pDst,
  2109. uint32_t blockSize);
  2110. /**
  2111. * @brief Multiplies a Q7 vector by a scalar.
  2112. * @param[in] *pSrc points to the input vector
  2113. * @param[in] scaleFract fractional portion of the scale value
  2114. * @param[in] shift number of bits to shift the result by
  2115. * @param[out] *pDst points to the output vector
  2116. * @param[in] blockSize number of samples in the vector
  2117. * @return none.
  2118. */
  2119. void arm_scale_q7(
  2120. q7_t * pSrc,
  2121. q7_t scaleFract,
  2122. int8_t shift,
  2123. q7_t * pDst,
  2124. uint32_t blockSize);
  2125. /**
  2126. * @brief Multiplies a Q15 vector by a scalar.
  2127. * @param[in] *pSrc points to the input vector
  2128. * @param[in] scaleFract fractional portion of the scale value
  2129. * @param[in] shift number of bits to shift the result by
  2130. * @param[out] *pDst points to the output vector
  2131. * @param[in] blockSize number of samples in the vector
  2132. * @return none.
  2133. */
  2134. void arm_scale_q15(
  2135. q15_t * pSrc,
  2136. q15_t scaleFract,
  2137. int8_t shift,
  2138. q15_t * pDst,
  2139. uint32_t blockSize);
  2140. /**
  2141. * @brief Multiplies a Q31 vector by a scalar.
  2142. * @param[in] *pSrc points to the input vector
  2143. * @param[in] scaleFract fractional portion of the scale value
  2144. * @param[in] shift number of bits to shift the result by
  2145. * @param[out] *pDst points to the output vector
  2146. * @param[in] blockSize number of samples in the vector
  2147. * @return none.
  2148. */
  2149. void arm_scale_q31(
  2150. q31_t * pSrc,
  2151. q31_t scaleFract,
  2152. int8_t shift,
  2153. q31_t * pDst,
  2154. uint32_t blockSize);
  2155. /**
  2156. * @brief Q7 vector absolute value.
  2157. * @param[in] *pSrc points to the input buffer
  2158. * @param[out] *pDst points to the output buffer
  2159. * @param[in] blockSize number of samples in each vector
  2160. * @return none.
  2161. */
  2162. void arm_abs_q7(
  2163. q7_t * pSrc,
  2164. q7_t * pDst,
  2165. uint32_t blockSize);
  2166. /**
  2167. * @brief Floating-point vector absolute value.
  2168. * @param[in] *pSrc points to the input buffer
  2169. * @param[out] *pDst points to the output buffer
  2170. * @param[in] blockSize number of samples in each vector
  2171. * @return none.
  2172. */
  2173. void arm_abs_f32(
  2174. float32_t * pSrc,
  2175. float32_t * pDst,
  2176. uint32_t blockSize);
  2177. /**
  2178. * @brief Q15 vector absolute value.
  2179. * @param[in] *pSrc points to the input buffer
  2180. * @param[out] *pDst points to the output buffer
  2181. * @param[in] blockSize number of samples in each vector
  2182. * @return none.
  2183. */
  2184. void arm_abs_q15(
  2185. q15_t * pSrc,
  2186. q15_t * pDst,
  2187. uint32_t blockSize);
  2188. /**
  2189. * @brief Q31 vector absolute value.
  2190. * @param[in] *pSrc points to the input buffer
  2191. * @param[out] *pDst points to the output buffer
  2192. * @param[in] blockSize number of samples in each vector
  2193. * @return none.
  2194. */
  2195. void arm_abs_q31(
  2196. q31_t * pSrc,
  2197. q31_t * pDst,
  2198. uint32_t blockSize);
  2199. /**
  2200. * @brief Dot product of floating-point vectors.
  2201. * @param[in] *pSrcA points to the first input vector
  2202. * @param[in] *pSrcB points to the second input vector
  2203. * @param[in] blockSize number of samples in each vector
  2204. * @param[out] *result output result returned here
  2205. * @return none.
  2206. */
  2207. void arm_dot_prod_f32(
  2208. float32_t * pSrcA,
  2209. float32_t * pSrcB,
  2210. uint32_t blockSize,
  2211. float32_t * result);
  2212. /**
  2213. * @brief Dot product of Q7 vectors.
  2214. * @param[in] *pSrcA points to the first input vector
  2215. * @param[in] *pSrcB points to the second input vector
  2216. * @param[in] blockSize number of samples in each vector
  2217. * @param[out] *result output result returned here
  2218. * @return none.
  2219. */
  2220. void arm_dot_prod_q7(
  2221. q7_t * pSrcA,
  2222. q7_t * pSrcB,
  2223. uint32_t blockSize,
  2224. q31_t * result);
  2225. /**
  2226. * @brief Dot product of Q15 vectors.
  2227. * @param[in] *pSrcA points to the first input vector
  2228. * @param[in] *pSrcB points to the second input vector
  2229. * @param[in] blockSize number of samples in each vector
  2230. * @param[out] *result output result returned here
  2231. * @return none.
  2232. */
  2233. void arm_dot_prod_q15(
  2234. q15_t * pSrcA,
  2235. q15_t * pSrcB,
  2236. uint32_t blockSize,
  2237. q63_t * result);
  2238. /**
  2239. * @brief Dot product of Q31 vectors.
  2240. * @param[in] *pSrcA points to the first input vector
  2241. * @param[in] *pSrcB points to the second input vector
  2242. * @param[in] blockSize number of samples in each vector
  2243. * @param[out] *result output result returned here
  2244. * @return none.
  2245. */
  2246. void arm_dot_prod_q31(
  2247. q31_t * pSrcA,
  2248. q31_t * pSrcB,
  2249. uint32_t blockSize,
  2250. q63_t * result);
  2251. /**
  2252. * @brief Shifts the elements of a Q7 vector a specified number of bits.
  2253. * @param[in] *pSrc points to the input vector
  2254. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2255. * @param[out] *pDst points to the output vector
  2256. * @param[in] blockSize number of samples in the vector
  2257. * @return none.
  2258. */
  2259. void arm_shift_q7(
  2260. q7_t * pSrc,
  2261. int8_t shiftBits,
  2262. q7_t * pDst,
  2263. uint32_t blockSize);
  2264. /**
  2265. * @brief Shifts the elements of a Q15 vector a specified number of bits.
  2266. * @param[in] *pSrc points to the input vector
  2267. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2268. * @param[out] *pDst points to the output vector
  2269. * @param[in] blockSize number of samples in the vector
  2270. * @return none.
  2271. */
  2272. void arm_shift_q15(
  2273. q15_t * pSrc,
  2274. int8_t shiftBits,
  2275. q15_t * pDst,
  2276. uint32_t blockSize);
  2277. /**
  2278. * @brief Shifts the elements of a Q31 vector a specified number of bits.
  2279. * @param[in] *pSrc points to the input vector
  2280. * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right.
  2281. * @param[out] *pDst points to the output vector
  2282. * @param[in] blockSize number of samples in the vector
  2283. * @return none.
  2284. */
  2285. void arm_shift_q31(
  2286. q31_t * pSrc,
  2287. int8_t shiftBits,
  2288. q31_t * pDst,
  2289. uint32_t blockSize);
  2290. /**
  2291. * @brief Adds a constant offset to a floating-point vector.
  2292. * @param[in] *pSrc points to the input vector
  2293. * @param[in] offset is the offset to be added
  2294. * @param[out] *pDst points to the output vector
  2295. * @param[in] blockSize number of samples in the vector
  2296. * @return none.
  2297. */
  2298. void arm_offset_f32(
  2299. float32_t * pSrc,
  2300. float32_t offset,
  2301. float32_t * pDst,
  2302. uint32_t blockSize);
  2303. /**
  2304. * @brief Adds a constant offset to a Q7 vector.
  2305. * @param[in] *pSrc points to the input vector
  2306. * @param[in] offset is the offset to be added
  2307. * @param[out] *pDst points to the output vector
  2308. * @param[in] blockSize number of samples in the vector
  2309. * @return none.
  2310. */
  2311. void arm_offset_q7(
  2312. q7_t * pSrc,
  2313. q7_t offset,
  2314. q7_t * pDst,
  2315. uint32_t blockSize);
  2316. /**
  2317. * @brief Adds a constant offset to a Q15 vector.
  2318. * @param[in] *pSrc points to the input vector
  2319. * @param[in] offset is the offset to be added
  2320. * @param[out] *pDst points to the output vector
  2321. * @param[in] blockSize number of samples in the vector
  2322. * @return none.
  2323. */
  2324. void arm_offset_q15(
  2325. q15_t * pSrc,
  2326. q15_t offset,
  2327. q15_t * pDst,
  2328. uint32_t blockSize);
  2329. /**
  2330. * @brief Adds a constant offset to a Q31 vector.
  2331. * @param[in] *pSrc points to the input vector
  2332. * @param[in] offset is the offset to be added
  2333. * @param[out] *pDst points to the output vector
  2334. * @param[in] blockSize number of samples in the vector
  2335. * @return none.
  2336. */
  2337. void arm_offset_q31(
  2338. q31_t * pSrc,
  2339. q31_t offset,
  2340. q31_t * pDst,
  2341. uint32_t blockSize);
  2342. /**
  2343. * @brief Negates the elements of a floating-point vector.
  2344. * @param[in] *pSrc points to the input vector
  2345. * @param[out] *pDst points to the output vector
  2346. * @param[in] blockSize number of samples in the vector
  2347. * @return none.
  2348. */
  2349. void arm_negate_f32(
  2350. float32_t * pSrc,
  2351. float32_t * pDst,
  2352. uint32_t blockSize);
  2353. /**
  2354. * @brief Negates the elements of a Q7 vector.
  2355. * @param[in] *pSrc points to the input vector
  2356. * @param[out] *pDst points to the output vector
  2357. * @param[in] blockSize number of samples in the vector
  2358. * @return none.
  2359. */
  2360. void arm_negate_q7(
  2361. q7_t * pSrc,
  2362. q7_t * pDst,
  2363. uint32_t blockSize);
  2364. /**
  2365. * @brief Negates the elements of a Q15 vector.
  2366. * @param[in] *pSrc points to the input vector
  2367. * @param[out] *pDst points to the output vector
  2368. * @param[in] blockSize number of samples in the vector
  2369. * @return none.
  2370. */
  2371. void arm_negate_q15(
  2372. q15_t * pSrc,
  2373. q15_t * pDst,
  2374. uint32_t blockSize);
  2375. /**
  2376. * @brief Negates the elements of a Q31 vector.
  2377. * @param[in] *pSrc points to the input vector
  2378. * @param[out] *pDst points to the output vector
  2379. * @param[in] blockSize number of samples in the vector
  2380. * @return none.
  2381. */
  2382. void arm_negate_q31(
  2383. q31_t * pSrc,
  2384. q31_t * pDst,
  2385. uint32_t blockSize);
  2386. /**
  2387. * @brief Copies the elements of a floating-point vector.
  2388. * @param[in] *pSrc input pointer
  2389. * @param[out] *pDst output pointer
  2390. * @param[in] blockSize number of samples to process
  2391. * @return none.
  2392. */
  2393. void arm_copy_f32(
  2394. float32_t * pSrc,
  2395. float32_t * pDst,
  2396. uint32_t blockSize);
  2397. /**
  2398. * @brief Copies the elements of a Q7 vector.
  2399. * @param[in] *pSrc input pointer
  2400. * @param[out] *pDst output pointer
  2401. * @param[in] blockSize number of samples to process
  2402. * @return none.
  2403. */
  2404. void arm_copy_q7(
  2405. q7_t * pSrc,
  2406. q7_t * pDst,
  2407. uint32_t blockSize);
  2408. /**
  2409. * @brief Copies the elements of a Q15 vector.
  2410. * @param[in] *pSrc input pointer
  2411. * @param[out] *pDst output pointer
  2412. * @param[in] blockSize number of samples to process
  2413. * @return none.
  2414. */
  2415. void arm_copy_q15(
  2416. q15_t * pSrc,
  2417. q15_t * pDst,
  2418. uint32_t blockSize);
  2419. /**
  2420. * @brief Copies the elements of a Q31 vector.
  2421. * @param[in] *pSrc input pointer
  2422. * @param[out] *pDst output pointer
  2423. * @param[in] blockSize number of samples to process
  2424. * @return none.
  2425. */
  2426. void arm_copy_q31(
  2427. q31_t * pSrc,
  2428. q31_t * pDst,
  2429. uint32_t blockSize);
  2430. /**
  2431. * @brief Fills a constant value into a floating-point vector.
  2432. * @param[in] value input value to be filled
  2433. * @param[out] *pDst output pointer
  2434. * @param[in] blockSize number of samples to process
  2435. * @return none.
  2436. */
  2437. void arm_fill_f32(
  2438. float32_t value,
  2439. float32_t * pDst,
  2440. uint32_t blockSize);
  2441. /**
  2442. * @brief Fills a constant value into a Q7 vector.
  2443. * @param[in] value input value to be filled
  2444. * @param[out] *pDst output pointer
  2445. * @param[in] blockSize number of samples to process
  2446. * @return none.
  2447. */
  2448. void arm_fill_q7(
  2449. q7_t value,
  2450. q7_t * pDst,
  2451. uint32_t blockSize);
  2452. /**
  2453. * @brief Fills a constant value into a Q15 vector.
  2454. * @param[in] value input value to be filled
  2455. * @param[out] *pDst output pointer
  2456. * @param[in] blockSize number of samples to process
  2457. * @return none.
  2458. */
  2459. void arm_fill_q15(
  2460. q15_t value,
  2461. q15_t * pDst,
  2462. uint32_t blockSize);
  2463. /**
  2464. * @brief Fills a constant value into a Q31 vector.
  2465. * @param[in] value input value to be filled
  2466. * @param[out] *pDst output pointer
  2467. * @param[in] blockSize number of samples to process
  2468. * @return none.
  2469. */
  2470. void arm_fill_q31(
  2471. q31_t value,
  2472. q31_t * pDst,
  2473. uint32_t blockSize);
  2474. /**
  2475. * @brief Convolution of floating-point sequences.
  2476. * @param[in] *pSrcA points to the first input sequence.
  2477. * @param[in] srcALen length of the first input sequence.
  2478. * @param[in] *pSrcB points to the second input sequence.
  2479. * @param[in] srcBLen length of the second input sequence.
  2480. * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2481. * @return none.
  2482. */
  2483. void arm_conv_f32(
  2484. float32_t * pSrcA,
  2485. uint32_t srcALen,
  2486. float32_t * pSrcB,
  2487. uint32_t srcBLen,
  2488. float32_t * pDst);
  2489. /**
  2490. * @brief Convolution of Q15 sequences.
  2491. * @param[in] *pSrcA points to the first input sequence.
  2492. * @param[in] srcALen length of the first input sequence.
  2493. * @param[in] *pSrcB points to the second input sequence.
  2494. * @param[in] srcBLen length of the second input sequence.
  2495. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2496. * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2497. * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2498. * @return none.
  2499. */
  2500. void arm_conv_opt_q15(
  2501. q15_t * pSrcA,
  2502. uint32_t srcALen,
  2503. q15_t * pSrcB,
  2504. uint32_t srcBLen,
  2505. q15_t * pDst,
  2506. q15_t * pScratch1,
  2507. q15_t * pScratch2);
  2508. /**
  2509. * @brief Convolution of Q15 sequences.
  2510. * @param[in] *pSrcA points to the first input sequence.
  2511. * @param[in] srcALen length of the first input sequence.
  2512. * @param[in] *pSrcB points to the second input sequence.
  2513. * @param[in] srcBLen length of the second input sequence.
  2514. * @param[out] *pDst points to the location where the output result is written. Length srcALen+srcBLen-1.
  2515. * @return none.
  2516. */
  2517. void arm_conv_q15(
  2518. q15_t * pSrcA,
  2519. uint32_t srcALen,
  2520. q15_t * pSrcB,
  2521. uint32_t srcBLen,
  2522. q15_t * pDst);
  2523. /**
  2524. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2525. * @param[in] *pSrcA points to the first input sequence.
  2526. * @param[in] srcALen length of the first input sequence.
  2527. * @param[in] *pSrcB points to the second input sequence.
  2528. * @param[in] srcBLen length of the second input sequence.
  2529. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2530. * @return none.
  2531. */
  2532. void arm_conv_fast_q15(
  2533. q15_t * pSrcA,
  2534. uint32_t srcALen,
  2535. q15_t * pSrcB,
  2536. uint32_t srcBLen,
  2537. q15_t * pDst);
  2538. /**
  2539. * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2540. * @param[in] *pSrcA points to the first input sequence.
  2541. * @param[in] srcALen length of the first input sequence.
  2542. * @param[in] *pSrcB points to the second input sequence.
  2543. * @param[in] srcBLen length of the second input sequence.
  2544. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2545. * @param[in] *pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2546. * @param[in] *pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2547. * @return none.
  2548. */
  2549. void arm_conv_fast_opt_q15(
  2550. q15_t * pSrcA,
  2551. uint32_t srcALen,
  2552. q15_t * pSrcB,
  2553. uint32_t srcBLen,
  2554. q15_t * pDst,
  2555. q15_t * pScratch1,
  2556. q15_t * pScratch2);
  2557. /**
  2558. * @brief Convolution of Q31 sequences.
  2559. * @param[in] *pSrcA points to the first input sequence.
  2560. * @param[in] srcALen length of the first input sequence.
  2561. * @param[in] *pSrcB points to the second input sequence.
  2562. * @param[in] srcBLen length of the second input sequence.
  2563. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2564. * @return none.
  2565. */
  2566. void arm_conv_q31(
  2567. q31_t * pSrcA,
  2568. uint32_t srcALen,
  2569. q31_t * pSrcB,
  2570. uint32_t srcBLen,
  2571. q31_t * pDst);
  2572. /**
  2573. * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2574. * @param[in] *pSrcA points to the first input sequence.
  2575. * @param[in] srcALen length of the first input sequence.
  2576. * @param[in] *pSrcB points to the second input sequence.
  2577. * @param[in] srcBLen length of the second input sequence.
  2578. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2579. * @return none.
  2580. */
  2581. void arm_conv_fast_q31(
  2582. q31_t * pSrcA,
  2583. uint32_t srcALen,
  2584. q31_t * pSrcB,
  2585. uint32_t srcBLen,
  2586. q31_t * pDst);
  2587. /**
  2588. * @brief Convolution of Q7 sequences.
  2589. * @param[in] *pSrcA points to the first input sequence.
  2590. * @param[in] srcALen length of the first input sequence.
  2591. * @param[in] *pSrcB points to the second input sequence.
  2592. * @param[in] srcBLen length of the second input sequence.
  2593. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2594. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2595. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2596. * @return none.
  2597. */
  2598. void arm_conv_opt_q7(
  2599. q7_t * pSrcA,
  2600. uint32_t srcALen,
  2601. q7_t * pSrcB,
  2602. uint32_t srcBLen,
  2603. q7_t * pDst,
  2604. q15_t * pScratch1,
  2605. q15_t * pScratch2);
  2606. /**
  2607. * @brief Convolution of Q7 sequences.
  2608. * @param[in] *pSrcA points to the first input sequence.
  2609. * @param[in] srcALen length of the first input sequence.
  2610. * @param[in] *pSrcB points to the second input sequence.
  2611. * @param[in] srcBLen length of the second input sequence.
  2612. * @param[out] *pDst points to the block of output data Length srcALen+srcBLen-1.
  2613. * @return none.
  2614. */
  2615. void arm_conv_q7(
  2616. q7_t * pSrcA,
  2617. uint32_t srcALen,
  2618. q7_t * pSrcB,
  2619. uint32_t srcBLen,
  2620. q7_t * pDst);
  2621. /**
  2622. * @brief Partial convolution of floating-point sequences.
  2623. * @param[in] *pSrcA points to the first input sequence.
  2624. * @param[in] srcALen length of the first input sequence.
  2625. * @param[in] *pSrcB points to the second input sequence.
  2626. * @param[in] srcBLen length of the second input sequence.
  2627. * @param[out] *pDst points to the block of output data
  2628. * @param[in] firstIndex is the first output sample to start with.
  2629. * @param[in] numPoints is the number of output points to be computed.
  2630. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2631. */
  2632. arm_status arm_conv_partial_f32(
  2633. float32_t * pSrcA,
  2634. uint32_t srcALen,
  2635. float32_t * pSrcB,
  2636. uint32_t srcBLen,
  2637. float32_t * pDst,
  2638. uint32_t firstIndex,
  2639. uint32_t numPoints);
  2640. /**
  2641. * @brief Partial convolution of Q15 sequences.
  2642. * @param[in] *pSrcA points to the first input sequence.
  2643. * @param[in] srcALen length of the first input sequence.
  2644. * @param[in] *pSrcB points to the second input sequence.
  2645. * @param[in] srcBLen length of the second input sequence.
  2646. * @param[out] *pDst points to the block of output data
  2647. * @param[in] firstIndex is the first output sample to start with.
  2648. * @param[in] numPoints is the number of output points to be computed.
  2649. * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2650. * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2651. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2652. */
  2653. arm_status arm_conv_partial_opt_q15(
  2654. q15_t * pSrcA,
  2655. uint32_t srcALen,
  2656. q15_t * pSrcB,
  2657. uint32_t srcBLen,
  2658. q15_t * pDst,
  2659. uint32_t firstIndex,
  2660. uint32_t numPoints,
  2661. q15_t * pScratch1,
  2662. q15_t * pScratch2);
  2663. /**
  2664. * @brief Partial convolution of Q15 sequences.
  2665. * @param[in] *pSrcA points to the first input sequence.
  2666. * @param[in] srcALen length of the first input sequence.
  2667. * @param[in] *pSrcB points to the second input sequence.
  2668. * @param[in] srcBLen length of the second input sequence.
  2669. * @param[out] *pDst points to the block of output data
  2670. * @param[in] firstIndex is the first output sample to start with.
  2671. * @param[in] numPoints is the number of output points to be computed.
  2672. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2673. */
  2674. arm_status arm_conv_partial_q15(
  2675. q15_t * pSrcA,
  2676. uint32_t srcALen,
  2677. q15_t * pSrcB,
  2678. uint32_t srcBLen,
  2679. q15_t * pDst,
  2680. uint32_t firstIndex,
  2681. uint32_t numPoints);
  2682. /**
  2683. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2684. * @param[in] *pSrcA points to the first input sequence.
  2685. * @param[in] srcALen length of the first input sequence.
  2686. * @param[in] *pSrcB points to the second input sequence.
  2687. * @param[in] srcBLen length of the second input sequence.
  2688. * @param[out] *pDst points to the block of output data
  2689. * @param[in] firstIndex is the first output sample to start with.
  2690. * @param[in] numPoints is the number of output points to be computed.
  2691. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2692. */
  2693. arm_status arm_conv_partial_fast_q15(
  2694. q15_t * pSrcA,
  2695. uint32_t srcALen,
  2696. q15_t * pSrcB,
  2697. uint32_t srcBLen,
  2698. q15_t * pDst,
  2699. uint32_t firstIndex,
  2700. uint32_t numPoints);
  2701. /**
  2702. * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4
  2703. * @param[in] *pSrcA points to the first input sequence.
  2704. * @param[in] srcALen length of the first input sequence.
  2705. * @param[in] *pSrcB points to the second input sequence.
  2706. * @param[in] srcBLen length of the second input sequence.
  2707. * @param[out] *pDst points to the block of output data
  2708. * @param[in] firstIndex is the first output sample to start with.
  2709. * @param[in] numPoints is the number of output points to be computed.
  2710. * @param[in] * pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2711. * @param[in] * pScratch2 points to scratch buffer of size min(srcALen, srcBLen).
  2712. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2713. */
  2714. arm_status arm_conv_partial_fast_opt_q15(
  2715. q15_t * pSrcA,
  2716. uint32_t srcALen,
  2717. q15_t * pSrcB,
  2718. uint32_t srcBLen,
  2719. q15_t * pDst,
  2720. uint32_t firstIndex,
  2721. uint32_t numPoints,
  2722. q15_t * pScratch1,
  2723. q15_t * pScratch2);
  2724. /**
  2725. * @brief Partial convolution of Q31 sequences.
  2726. * @param[in] *pSrcA points to the first input sequence.
  2727. * @param[in] srcALen length of the first input sequence.
  2728. * @param[in] *pSrcB points to the second input sequence.
  2729. * @param[in] srcBLen length of the second input sequence.
  2730. * @param[out] *pDst points to the block of output data
  2731. * @param[in] firstIndex is the first output sample to start with.
  2732. * @param[in] numPoints is the number of output points to be computed.
  2733. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2734. */
  2735. arm_status arm_conv_partial_q31(
  2736. q31_t * pSrcA,
  2737. uint32_t srcALen,
  2738. q31_t * pSrcB,
  2739. uint32_t srcBLen,
  2740. q31_t * pDst,
  2741. uint32_t firstIndex,
  2742. uint32_t numPoints);
  2743. /**
  2744. * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  2745. * @param[in] *pSrcA points to the first input sequence.
  2746. * @param[in] srcALen length of the first input sequence.
  2747. * @param[in] *pSrcB points to the second input sequence.
  2748. * @param[in] srcBLen length of the second input sequence.
  2749. * @param[out] *pDst points to the block of output data
  2750. * @param[in] firstIndex is the first output sample to start with.
  2751. * @param[in] numPoints is the number of output points to be computed.
  2752. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2753. */
  2754. arm_status arm_conv_partial_fast_q31(
  2755. q31_t * pSrcA,
  2756. uint32_t srcALen,
  2757. q31_t * pSrcB,
  2758. uint32_t srcBLen,
  2759. q31_t * pDst,
  2760. uint32_t firstIndex,
  2761. uint32_t numPoints);
  2762. /**
  2763. * @brief Partial convolution of Q7 sequences
  2764. * @param[in] *pSrcA points to the first input sequence.
  2765. * @param[in] srcALen length of the first input sequence.
  2766. * @param[in] *pSrcB points to the second input sequence.
  2767. * @param[in] srcBLen length of the second input sequence.
  2768. * @param[out] *pDst points to the block of output data
  2769. * @param[in] firstIndex is the first output sample to start with.
  2770. * @param[in] numPoints is the number of output points to be computed.
  2771. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  2772. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  2773. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2774. */
  2775. arm_status arm_conv_partial_opt_q7(
  2776. q7_t * pSrcA,
  2777. uint32_t srcALen,
  2778. q7_t * pSrcB,
  2779. uint32_t srcBLen,
  2780. q7_t * pDst,
  2781. uint32_t firstIndex,
  2782. uint32_t numPoints,
  2783. q15_t * pScratch1,
  2784. q15_t * pScratch2);
  2785. /**
  2786. * @brief Partial convolution of Q7 sequences.
  2787. * @param[in] *pSrcA points to the first input sequence.
  2788. * @param[in] srcALen length of the first input sequence.
  2789. * @param[in] *pSrcB points to the second input sequence.
  2790. * @param[in] srcBLen length of the second input sequence.
  2791. * @param[out] *pDst points to the block of output data
  2792. * @param[in] firstIndex is the first output sample to start with.
  2793. * @param[in] numPoints is the number of output points to be computed.
  2794. * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2].
  2795. */
  2796. arm_status arm_conv_partial_q7(
  2797. q7_t * pSrcA,
  2798. uint32_t srcALen,
  2799. q7_t * pSrcB,
  2800. uint32_t srcBLen,
  2801. q7_t * pDst,
  2802. uint32_t firstIndex,
  2803. uint32_t numPoints);
  2804. /**
  2805. * @brief Instance structure for the Q15 FIR decimator.
  2806. */
  2807. typedef struct
  2808. {
  2809. uint8_t M; /**< decimation factor. */
  2810. uint16_t numTaps; /**< number of coefficients in the filter. */
  2811. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2812. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2813. } arm_fir_decimate_instance_q15;
  2814. /**
  2815. * @brief Instance structure for the Q31 FIR decimator.
  2816. */
  2817. typedef struct
  2818. {
  2819. uint8_t M; /**< decimation factor. */
  2820. uint16_t numTaps; /**< number of coefficients in the filter. */
  2821. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2822. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2823. } arm_fir_decimate_instance_q31;
  2824. /**
  2825. * @brief Instance structure for the floating-point FIR decimator.
  2826. */
  2827. typedef struct
  2828. {
  2829. uint8_t M; /**< decimation factor. */
  2830. uint16_t numTaps; /**< number of coefficients in the filter. */
  2831. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  2832. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  2833. } arm_fir_decimate_instance_f32;
  2834. /**
  2835. * @brief Processing function for the floating-point FIR decimator.
  2836. * @param[in] *S points to an instance of the floating-point FIR decimator structure.
  2837. * @param[in] *pSrc points to the block of input data.
  2838. * @param[out] *pDst points to the block of output data
  2839. * @param[in] blockSize number of input samples to process per call.
  2840. * @return none
  2841. */
  2842. void arm_fir_decimate_f32(
  2843. const arm_fir_decimate_instance_f32 * S,
  2844. float32_t * pSrc,
  2845. float32_t * pDst,
  2846. uint32_t blockSize);
  2847. /**
  2848. * @brief Initialization function for the floating-point FIR decimator.
  2849. * @param[in,out] *S points to an instance of the floating-point FIR decimator structure.
  2850. * @param[in] numTaps number of coefficients in the filter.
  2851. * @param[in] M decimation factor.
  2852. * @param[in] *pCoeffs points to the filter coefficients.
  2853. * @param[in] *pState points to the state buffer.
  2854. * @param[in] blockSize number of input samples to process per call.
  2855. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2856. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2857. */
  2858. arm_status arm_fir_decimate_init_f32(
  2859. arm_fir_decimate_instance_f32 * S,
  2860. uint16_t numTaps,
  2861. uint8_t M,
  2862. float32_t * pCoeffs,
  2863. float32_t * pState,
  2864. uint32_t blockSize);
  2865. /**
  2866. * @brief Processing function for the Q15 FIR decimator.
  2867. * @param[in] *S points to an instance of the Q15 FIR decimator structure.
  2868. * @param[in] *pSrc points to the block of input data.
  2869. * @param[out] *pDst points to the block of output data
  2870. * @param[in] blockSize number of input samples to process per call.
  2871. * @return none
  2872. */
  2873. void arm_fir_decimate_q15(
  2874. const arm_fir_decimate_instance_q15 * S,
  2875. q15_t * pSrc,
  2876. q15_t * pDst,
  2877. uint32_t blockSize);
  2878. /**
  2879. * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2880. * @param[in] *S points to an instance of the Q15 FIR decimator structure.
  2881. * @param[in] *pSrc points to the block of input data.
  2882. * @param[out] *pDst points to the block of output data
  2883. * @param[in] blockSize number of input samples to process per call.
  2884. * @return none
  2885. */
  2886. void arm_fir_decimate_fast_q15(
  2887. const arm_fir_decimate_instance_q15 * S,
  2888. q15_t * pSrc,
  2889. q15_t * pDst,
  2890. uint32_t blockSize);
  2891. /**
  2892. * @brief Initialization function for the Q15 FIR decimator.
  2893. * @param[in,out] *S points to an instance of the Q15 FIR decimator structure.
  2894. * @param[in] numTaps number of coefficients in the filter.
  2895. * @param[in] M decimation factor.
  2896. * @param[in] *pCoeffs points to the filter coefficients.
  2897. * @param[in] *pState points to the state buffer.
  2898. * @param[in] blockSize number of input samples to process per call.
  2899. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2900. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2901. */
  2902. arm_status arm_fir_decimate_init_q15(
  2903. arm_fir_decimate_instance_q15 * S,
  2904. uint16_t numTaps,
  2905. uint8_t M,
  2906. q15_t * pCoeffs,
  2907. q15_t * pState,
  2908. uint32_t blockSize);
  2909. /**
  2910. * @brief Processing function for the Q31 FIR decimator.
  2911. * @param[in] *S points to an instance of the Q31 FIR decimator structure.
  2912. * @param[in] *pSrc points to the block of input data.
  2913. * @param[out] *pDst points to the block of output data
  2914. * @param[in] blockSize number of input samples to process per call.
  2915. * @return none
  2916. */
  2917. void arm_fir_decimate_q31(
  2918. const arm_fir_decimate_instance_q31 * S,
  2919. q31_t * pSrc,
  2920. q31_t * pDst,
  2921. uint32_t blockSize);
  2922. /**
  2923. * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4.
  2924. * @param[in] *S points to an instance of the Q31 FIR decimator structure.
  2925. * @param[in] *pSrc points to the block of input data.
  2926. * @param[out] *pDst points to the block of output data
  2927. * @param[in] blockSize number of input samples to process per call.
  2928. * @return none
  2929. */
  2930. void arm_fir_decimate_fast_q31(
  2931. arm_fir_decimate_instance_q31 * S,
  2932. q31_t * pSrc,
  2933. q31_t * pDst,
  2934. uint32_t blockSize);
  2935. /**
  2936. * @brief Initialization function for the Q31 FIR decimator.
  2937. * @param[in,out] *S points to an instance of the Q31 FIR decimator structure.
  2938. * @param[in] numTaps number of coefficients in the filter.
  2939. * @param[in] M decimation factor.
  2940. * @param[in] *pCoeffs points to the filter coefficients.
  2941. * @param[in] *pState points to the state buffer.
  2942. * @param[in] blockSize number of input samples to process per call.
  2943. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  2944. * <code>blockSize</code> is not a multiple of <code>M</code>.
  2945. */
  2946. arm_status arm_fir_decimate_init_q31(
  2947. arm_fir_decimate_instance_q31 * S,
  2948. uint16_t numTaps,
  2949. uint8_t M,
  2950. q31_t * pCoeffs,
  2951. q31_t * pState,
  2952. uint32_t blockSize);
  2953. /**
  2954. * @brief Instance structure for the Q15 FIR interpolator.
  2955. */
  2956. typedef struct
  2957. {
  2958. uint8_t L; /**< upsample factor. */
  2959. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2960. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2961. q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2962. } arm_fir_interpolate_instance_q15;
  2963. /**
  2964. * @brief Instance structure for the Q31 FIR interpolator.
  2965. */
  2966. typedef struct
  2967. {
  2968. uint8_t L; /**< upsample factor. */
  2969. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2970. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2971. q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */
  2972. } arm_fir_interpolate_instance_q31;
  2973. /**
  2974. * @brief Instance structure for the floating-point FIR interpolator.
  2975. */
  2976. typedef struct
  2977. {
  2978. uint8_t L; /**< upsample factor. */
  2979. uint16_t phaseLength; /**< length of each polyphase filter component. */
  2980. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */
  2981. float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */
  2982. } arm_fir_interpolate_instance_f32;
  2983. /**
  2984. * @brief Processing function for the Q15 FIR interpolator.
  2985. * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
  2986. * @param[in] *pSrc points to the block of input data.
  2987. * @param[out] *pDst points to the block of output data.
  2988. * @param[in] blockSize number of input samples to process per call.
  2989. * @return none.
  2990. */
  2991. void arm_fir_interpolate_q15(
  2992. const arm_fir_interpolate_instance_q15 * S,
  2993. q15_t * pSrc,
  2994. q15_t * pDst,
  2995. uint32_t blockSize);
  2996. /**
  2997. * @brief Initialization function for the Q15 FIR interpolator.
  2998. * @param[in,out] *S points to an instance of the Q15 FIR interpolator structure.
  2999. * @param[in] L upsample factor.
  3000. * @param[in] numTaps number of filter coefficients in the filter.
  3001. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3002. * @param[in] *pState points to the state buffer.
  3003. * @param[in] blockSize number of input samples to process per call.
  3004. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3005. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3006. */
  3007. arm_status arm_fir_interpolate_init_q15(
  3008. arm_fir_interpolate_instance_q15 * S,
  3009. uint8_t L,
  3010. uint16_t numTaps,
  3011. q15_t * pCoeffs,
  3012. q15_t * pState,
  3013. uint32_t blockSize);
  3014. /**
  3015. * @brief Processing function for the Q31 FIR interpolator.
  3016. * @param[in] *S points to an instance of the Q15 FIR interpolator structure.
  3017. * @param[in] *pSrc points to the block of input data.
  3018. * @param[out] *pDst points to the block of output data.
  3019. * @param[in] blockSize number of input samples to process per call.
  3020. * @return none.
  3021. */
  3022. void arm_fir_interpolate_q31(
  3023. const arm_fir_interpolate_instance_q31 * S,
  3024. q31_t * pSrc,
  3025. q31_t * pDst,
  3026. uint32_t blockSize);
  3027. /**
  3028. * @brief Initialization function for the Q31 FIR interpolator.
  3029. * @param[in,out] *S points to an instance of the Q31 FIR interpolator structure.
  3030. * @param[in] L upsample factor.
  3031. * @param[in] numTaps number of filter coefficients in the filter.
  3032. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3033. * @param[in] *pState points to the state buffer.
  3034. * @param[in] blockSize number of input samples to process per call.
  3035. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3036. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3037. */
  3038. arm_status arm_fir_interpolate_init_q31(
  3039. arm_fir_interpolate_instance_q31 * S,
  3040. uint8_t L,
  3041. uint16_t numTaps,
  3042. q31_t * pCoeffs,
  3043. q31_t * pState,
  3044. uint32_t blockSize);
  3045. /**
  3046. * @brief Processing function for the floating-point FIR interpolator.
  3047. * @param[in] *S points to an instance of the floating-point FIR interpolator structure.
  3048. * @param[in] *pSrc points to the block of input data.
  3049. * @param[out] *pDst points to the block of output data.
  3050. * @param[in] blockSize number of input samples to process per call.
  3051. * @return none.
  3052. */
  3053. void arm_fir_interpolate_f32(
  3054. const arm_fir_interpolate_instance_f32 * S,
  3055. float32_t * pSrc,
  3056. float32_t * pDst,
  3057. uint32_t blockSize);
  3058. /**
  3059. * @brief Initialization function for the floating-point FIR interpolator.
  3060. * @param[in,out] *S points to an instance of the floating-point FIR interpolator structure.
  3061. * @param[in] L upsample factor.
  3062. * @param[in] numTaps number of filter coefficients in the filter.
  3063. * @param[in] *pCoeffs points to the filter coefficient buffer.
  3064. * @param[in] *pState points to the state buffer.
  3065. * @param[in] blockSize number of input samples to process per call.
  3066. * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if
  3067. * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>.
  3068. */
  3069. arm_status arm_fir_interpolate_init_f32(
  3070. arm_fir_interpolate_instance_f32 * S,
  3071. uint8_t L,
  3072. uint16_t numTaps,
  3073. float32_t * pCoeffs,
  3074. float32_t * pState,
  3075. uint32_t blockSize);
  3076. /**
  3077. * @brief Instance structure for the high precision Q31 Biquad cascade filter.
  3078. */
  3079. typedef struct
  3080. {
  3081. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3082. q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */
  3083. q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3084. uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */
  3085. } arm_biquad_cas_df1_32x64_ins_q31;
  3086. /**
  3087. * @param[in] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3088. * @param[in] *pSrc points to the block of input data.
  3089. * @param[out] *pDst points to the block of output data
  3090. * @param[in] blockSize number of samples to process.
  3091. * @return none.
  3092. */
  3093. void arm_biquad_cas_df1_32x64_q31(
  3094. const arm_biquad_cas_df1_32x64_ins_q31 * S,
  3095. q31_t * pSrc,
  3096. q31_t * pDst,
  3097. uint32_t blockSize);
  3098. /**
  3099. * @param[in,out] *S points to an instance of the high precision Q31 Biquad cascade filter structure.
  3100. * @param[in] numStages number of 2nd order stages in the filter.
  3101. * @param[in] *pCoeffs points to the filter coefficients.
  3102. * @param[in] *pState points to the state buffer.
  3103. * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format
  3104. * @return none
  3105. */
  3106. void arm_biquad_cas_df1_32x64_init_q31(
  3107. arm_biquad_cas_df1_32x64_ins_q31 * S,
  3108. uint8_t numStages,
  3109. q31_t * pCoeffs,
  3110. q63_t * pState,
  3111. uint8_t postShift);
  3112. /**
  3113. * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter.
  3114. */
  3115. typedef struct
  3116. {
  3117. uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */
  3118. float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */
  3119. float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */
  3120. } arm_biquad_cascade_df2T_instance_f32;
  3121. /**
  3122. * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
  3123. * @param[in] *S points to an instance of the filter data structure.
  3124. * @param[in] *pSrc points to the block of input data.
  3125. * @param[out] *pDst points to the block of output data
  3126. * @param[in] blockSize number of samples to process.
  3127. * @return none.
  3128. */
  3129. void arm_biquad_cascade_df2T_f32(
  3130. const arm_biquad_cascade_df2T_instance_f32 * S,
  3131. float32_t * pSrc,
  3132. float32_t * pDst,
  3133. uint32_t blockSize);
  3134. /**
  3135. * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter.
  3136. * @param[in,out] *S points to an instance of the filter data structure.
  3137. * @param[in] numStages number of 2nd order stages in the filter.
  3138. * @param[in] *pCoeffs points to the filter coefficients.
  3139. * @param[in] *pState points to the state buffer.
  3140. * @return none
  3141. */
  3142. void arm_biquad_cascade_df2T_init_f32(
  3143. arm_biquad_cascade_df2T_instance_f32 * S,
  3144. uint8_t numStages,
  3145. float32_t * pCoeffs,
  3146. float32_t * pState);
  3147. /**
  3148. * @brief Instance structure for the Q15 FIR lattice filter.
  3149. */
  3150. typedef struct
  3151. {
  3152. uint16_t numStages; /**< number of filter stages. */
  3153. q15_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3154. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3155. } arm_fir_lattice_instance_q15;
  3156. /**
  3157. * @brief Instance structure for the Q31 FIR lattice filter.
  3158. */
  3159. typedef struct
  3160. {
  3161. uint16_t numStages; /**< number of filter stages. */
  3162. q31_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3163. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3164. } arm_fir_lattice_instance_q31;
  3165. /**
  3166. * @brief Instance structure for the floating-point FIR lattice filter.
  3167. */
  3168. typedef struct
  3169. {
  3170. uint16_t numStages; /**< number of filter stages. */
  3171. float32_t *pState; /**< points to the state variable array. The array is of length numStages. */
  3172. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */
  3173. } arm_fir_lattice_instance_f32;
  3174. /**
  3175. * @brief Initialization function for the Q15 FIR lattice filter.
  3176. * @param[in] *S points to an instance of the Q15 FIR lattice structure.
  3177. * @param[in] numStages number of filter stages.
  3178. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3179. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3180. * @return none.
  3181. */
  3182. void arm_fir_lattice_init_q15(
  3183. arm_fir_lattice_instance_q15 * S,
  3184. uint16_t numStages,
  3185. q15_t * pCoeffs,
  3186. q15_t * pState);
  3187. /**
  3188. * @brief Processing function for the Q15 FIR lattice filter.
  3189. * @param[in] *S points to an instance of the Q15 FIR lattice structure.
  3190. * @param[in] *pSrc points to the block of input data.
  3191. * @param[out] *pDst points to the block of output data.
  3192. * @param[in] blockSize number of samples to process.
  3193. * @return none.
  3194. */
  3195. void arm_fir_lattice_q15(
  3196. const arm_fir_lattice_instance_q15 * S,
  3197. q15_t * pSrc,
  3198. q15_t * pDst,
  3199. uint32_t blockSize);
  3200. /**
  3201. * @brief Initialization function for the Q31 FIR lattice filter.
  3202. * @param[in] *S points to an instance of the Q31 FIR lattice structure.
  3203. * @param[in] numStages number of filter stages.
  3204. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3205. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3206. * @return none.
  3207. */
  3208. void arm_fir_lattice_init_q31(
  3209. arm_fir_lattice_instance_q31 * S,
  3210. uint16_t numStages,
  3211. q31_t * pCoeffs,
  3212. q31_t * pState);
  3213. /**
  3214. * @brief Processing function for the Q31 FIR lattice filter.
  3215. * @param[in] *S points to an instance of the Q31 FIR lattice structure.
  3216. * @param[in] *pSrc points to the block of input data.
  3217. * @param[out] *pDst points to the block of output data
  3218. * @param[in] blockSize number of samples to process.
  3219. * @return none.
  3220. */
  3221. void arm_fir_lattice_q31(
  3222. const arm_fir_lattice_instance_q31 * S,
  3223. q31_t * pSrc,
  3224. q31_t * pDst,
  3225. uint32_t blockSize);
  3226. /**
  3227. * @brief Initialization function for the floating-point FIR lattice filter.
  3228. * @param[in] *S points to an instance of the floating-point FIR lattice structure.
  3229. * @param[in] numStages number of filter stages.
  3230. * @param[in] *pCoeffs points to the coefficient buffer. The array is of length numStages.
  3231. * @param[in] *pState points to the state buffer. The array is of length numStages.
  3232. * @return none.
  3233. */
  3234. void arm_fir_lattice_init_f32(
  3235. arm_fir_lattice_instance_f32 * S,
  3236. uint16_t numStages,
  3237. float32_t * pCoeffs,
  3238. float32_t * pState);
  3239. /**
  3240. * @brief Processing function for the floating-point FIR lattice filter.
  3241. * @param[in] *S points to an instance of the floating-point FIR lattice structure.
  3242. * @param[in] *pSrc points to the block of input data.
  3243. * @param[out] *pDst points to the block of output data
  3244. * @param[in] blockSize number of samples to process.
  3245. * @return none.
  3246. */
  3247. void arm_fir_lattice_f32(
  3248. const arm_fir_lattice_instance_f32 * S,
  3249. float32_t * pSrc,
  3250. float32_t * pDst,
  3251. uint32_t blockSize);
  3252. /**
  3253. * @brief Instance structure for the Q15 IIR lattice filter.
  3254. */
  3255. typedef struct
  3256. {
  3257. uint16_t numStages; /**< number of stages in the filter. */
  3258. q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3259. q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3260. q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3261. } arm_iir_lattice_instance_q15;
  3262. /**
  3263. * @brief Instance structure for the Q31 IIR lattice filter.
  3264. */
  3265. typedef struct
  3266. {
  3267. uint16_t numStages; /**< number of stages in the filter. */
  3268. q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3269. q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3270. q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3271. } arm_iir_lattice_instance_q31;
  3272. /**
  3273. * @brief Instance structure for the floating-point IIR lattice filter.
  3274. */
  3275. typedef struct
  3276. {
  3277. uint16_t numStages; /**< number of stages in the filter. */
  3278. float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */
  3279. float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */
  3280. float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */
  3281. } arm_iir_lattice_instance_f32;
  3282. /**
  3283. * @brief Processing function for the floating-point IIR lattice filter.
  3284. * @param[in] *S points to an instance of the floating-point IIR lattice structure.
  3285. * @param[in] *pSrc points to the block of input data.
  3286. * @param[out] *pDst points to the block of output data.
  3287. * @param[in] blockSize number of samples to process.
  3288. * @return none.
  3289. */
  3290. void arm_iir_lattice_f32(
  3291. const arm_iir_lattice_instance_f32 * S,
  3292. float32_t * pSrc,
  3293. float32_t * pDst,
  3294. uint32_t blockSize);
  3295. /**
  3296. * @brief Initialization function for the floating-point IIR lattice filter.
  3297. * @param[in] *S points to an instance of the floating-point IIR lattice structure.
  3298. * @param[in] numStages number of stages in the filter.
  3299. * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3300. * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3301. * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize-1.
  3302. * @param[in] blockSize number of samples to process.
  3303. * @return none.
  3304. */
  3305. void arm_iir_lattice_init_f32(
  3306. arm_iir_lattice_instance_f32 * S,
  3307. uint16_t numStages,
  3308. float32_t * pkCoeffs,
  3309. float32_t * pvCoeffs,
  3310. float32_t * pState,
  3311. uint32_t blockSize);
  3312. /**
  3313. * @brief Processing function for the Q31 IIR lattice filter.
  3314. * @param[in] *S points to an instance of the Q31 IIR lattice structure.
  3315. * @param[in] *pSrc points to the block of input data.
  3316. * @param[out] *pDst points to the block of output data.
  3317. * @param[in] blockSize number of samples to process.
  3318. * @return none.
  3319. */
  3320. void arm_iir_lattice_q31(
  3321. const arm_iir_lattice_instance_q31 * S,
  3322. q31_t * pSrc,
  3323. q31_t * pDst,
  3324. uint32_t blockSize);
  3325. /**
  3326. * @brief Initialization function for the Q31 IIR lattice filter.
  3327. * @param[in] *S points to an instance of the Q31 IIR lattice structure.
  3328. * @param[in] numStages number of stages in the filter.
  3329. * @param[in] *pkCoeffs points to the reflection coefficient buffer. The array is of length numStages.
  3330. * @param[in] *pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1.
  3331. * @param[in] *pState points to the state buffer. The array is of length numStages+blockSize.
  3332. * @param[in] blockSize number of samples to process.
  3333. * @return none.
  3334. */
  3335. void arm_iir_lattice_init_q31(
  3336. arm_iir_lattice_instance_q31 * S,
  3337. uint16_t numStages,
  3338. q31_t * pkCoeffs,
  3339. q31_t * pvCoeffs,
  3340. q31_t * pState,
  3341. uint32_t blockSize);
  3342. /**
  3343. * @brief Processing function for the Q15 IIR lattice filter.
  3344. * @param[in] *S points to an instance of the Q15 IIR lattice structure.
  3345. * @param[in] *pSrc points to the block of input data.
  3346. * @param[out] *pDst points to the block of output data.
  3347. * @param[in] blockSize number of samples to process.
  3348. * @return none.
  3349. */
  3350. void arm_iir_lattice_q15(
  3351. const arm_iir_lattice_instance_q15 * S,
  3352. q15_t * pSrc,
  3353. q15_t * pDst,
  3354. uint32_t blockSize);
  3355. /**
  3356. * @brief Initialization function for the Q15 IIR lattice filter.
  3357. * @param[in] *S points to an instance of the fixed-point Q15 IIR lattice structure.
  3358. * @param[in] numStages number of stages in the filter.
  3359. * @param[in] *pkCoeffs points to reflection coefficient buffer. The array is of length numStages.
  3360. * @param[in] *pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1.
  3361. * @param[in] *pState points to state buffer. The array is of length numStages+blockSize.
  3362. * @param[in] blockSize number of samples to process per call.
  3363. * @return none.
  3364. */
  3365. void arm_iir_lattice_init_q15(
  3366. arm_iir_lattice_instance_q15 * S,
  3367. uint16_t numStages,
  3368. q15_t * pkCoeffs,
  3369. q15_t * pvCoeffs,
  3370. q15_t * pState,
  3371. uint32_t blockSize);
  3372. /**
  3373. * @brief Instance structure for the floating-point LMS filter.
  3374. */
  3375. typedef struct
  3376. {
  3377. uint16_t numTaps; /**< number of coefficients in the filter. */
  3378. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3379. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3380. float32_t mu; /**< step size that controls filter coefficient updates. */
  3381. } arm_lms_instance_f32;
  3382. /**
  3383. * @brief Processing function for floating-point LMS filter.
  3384. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3385. * @param[in] *pSrc points to the block of input data.
  3386. * @param[in] *pRef points to the block of reference data.
  3387. * @param[out] *pOut points to the block of output data.
  3388. * @param[out] *pErr points to the block of error data.
  3389. * @param[in] blockSize number of samples to process.
  3390. * @return none.
  3391. */
  3392. void arm_lms_f32(
  3393. const arm_lms_instance_f32 * S,
  3394. float32_t * pSrc,
  3395. float32_t * pRef,
  3396. float32_t * pOut,
  3397. float32_t * pErr,
  3398. uint32_t blockSize);
  3399. /**
  3400. * @brief Initialization function for floating-point LMS filter.
  3401. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3402. * @param[in] numTaps number of filter coefficients.
  3403. * @param[in] *pCoeffs points to the coefficient buffer.
  3404. * @param[in] *pState points to state buffer.
  3405. * @param[in] mu step size that controls filter coefficient updates.
  3406. * @param[in] blockSize number of samples to process.
  3407. * @return none.
  3408. */
  3409. void arm_lms_init_f32(
  3410. arm_lms_instance_f32 * S,
  3411. uint16_t numTaps,
  3412. float32_t * pCoeffs,
  3413. float32_t * pState,
  3414. float32_t mu,
  3415. uint32_t blockSize);
  3416. /**
  3417. * @brief Instance structure for the Q15 LMS filter.
  3418. */
  3419. typedef struct
  3420. {
  3421. uint16_t numTaps; /**< number of coefficients in the filter. */
  3422. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3423. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3424. q15_t mu; /**< step size that controls filter coefficient updates. */
  3425. uint32_t postShift; /**< bit shift applied to coefficients. */
  3426. } arm_lms_instance_q15;
  3427. /**
  3428. * @brief Initialization function for the Q15 LMS filter.
  3429. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3430. * @param[in] numTaps number of filter coefficients.
  3431. * @param[in] *pCoeffs points to the coefficient buffer.
  3432. * @param[in] *pState points to the state buffer.
  3433. * @param[in] mu step size that controls filter coefficient updates.
  3434. * @param[in] blockSize number of samples to process.
  3435. * @param[in] postShift bit shift applied to coefficients.
  3436. * @return none.
  3437. */
  3438. void arm_lms_init_q15(
  3439. arm_lms_instance_q15 * S,
  3440. uint16_t numTaps,
  3441. q15_t * pCoeffs,
  3442. q15_t * pState,
  3443. q15_t mu,
  3444. uint32_t blockSize,
  3445. uint32_t postShift);
  3446. /**
  3447. * @brief Processing function for Q15 LMS filter.
  3448. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3449. * @param[in] *pSrc points to the block of input data.
  3450. * @param[in] *pRef points to the block of reference data.
  3451. * @param[out] *pOut points to the block of output data.
  3452. * @param[out] *pErr points to the block of error data.
  3453. * @param[in] blockSize number of samples to process.
  3454. * @return none.
  3455. */
  3456. void arm_lms_q15(
  3457. const arm_lms_instance_q15 * S,
  3458. q15_t * pSrc,
  3459. q15_t * pRef,
  3460. q15_t * pOut,
  3461. q15_t * pErr,
  3462. uint32_t blockSize);
  3463. /**
  3464. * @brief Instance structure for the Q31 LMS filter.
  3465. */
  3466. typedef struct
  3467. {
  3468. uint16_t numTaps; /**< number of coefficients in the filter. */
  3469. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3470. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3471. q31_t mu; /**< step size that controls filter coefficient updates. */
  3472. uint32_t postShift; /**< bit shift applied to coefficients. */
  3473. } arm_lms_instance_q31;
  3474. /**
  3475. * @brief Processing function for Q31 LMS filter.
  3476. * @param[in] *S points to an instance of the Q15 LMS filter structure.
  3477. * @param[in] *pSrc points to the block of input data.
  3478. * @param[in] *pRef points to the block of reference data.
  3479. * @param[out] *pOut points to the block of output data.
  3480. * @param[out] *pErr points to the block of error data.
  3481. * @param[in] blockSize number of samples to process.
  3482. * @return none.
  3483. */
  3484. void arm_lms_q31(
  3485. const arm_lms_instance_q31 * S,
  3486. q31_t * pSrc,
  3487. q31_t * pRef,
  3488. q31_t * pOut,
  3489. q31_t * pErr,
  3490. uint32_t blockSize);
  3491. /**
  3492. * @brief Initialization function for Q31 LMS filter.
  3493. * @param[in] *S points to an instance of the Q31 LMS filter structure.
  3494. * @param[in] numTaps number of filter coefficients.
  3495. * @param[in] *pCoeffs points to coefficient buffer.
  3496. * @param[in] *pState points to state buffer.
  3497. * @param[in] mu step size that controls filter coefficient updates.
  3498. * @param[in] blockSize number of samples to process.
  3499. * @param[in] postShift bit shift applied to coefficients.
  3500. * @return none.
  3501. */
  3502. void arm_lms_init_q31(
  3503. arm_lms_instance_q31 * S,
  3504. uint16_t numTaps,
  3505. q31_t * pCoeffs,
  3506. q31_t * pState,
  3507. q31_t mu,
  3508. uint32_t blockSize,
  3509. uint32_t postShift);
  3510. /**
  3511. * @brief Instance structure for the floating-point normalized LMS filter.
  3512. */
  3513. typedef struct
  3514. {
  3515. uint16_t numTaps; /**< number of coefficients in the filter. */
  3516. float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3517. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3518. float32_t mu; /**< step size that control filter coefficient updates. */
  3519. float32_t energy; /**< saves previous frame energy. */
  3520. float32_t x0; /**< saves previous input sample. */
  3521. } arm_lms_norm_instance_f32;
  3522. /**
  3523. * @brief Processing function for floating-point normalized LMS filter.
  3524. * @param[in] *S points to an instance of the floating-point normalized LMS filter structure.
  3525. * @param[in] *pSrc points to the block of input data.
  3526. * @param[in] *pRef points to the block of reference data.
  3527. * @param[out] *pOut points to the block of output data.
  3528. * @param[out] *pErr points to the block of error data.
  3529. * @param[in] blockSize number of samples to process.
  3530. * @return none.
  3531. */
  3532. void arm_lms_norm_f32(
  3533. arm_lms_norm_instance_f32 * S,
  3534. float32_t * pSrc,
  3535. float32_t * pRef,
  3536. float32_t * pOut,
  3537. float32_t * pErr,
  3538. uint32_t blockSize);
  3539. /**
  3540. * @brief Initialization function for floating-point normalized LMS filter.
  3541. * @param[in] *S points to an instance of the floating-point LMS filter structure.
  3542. * @param[in] numTaps number of filter coefficients.
  3543. * @param[in] *pCoeffs points to coefficient buffer.
  3544. * @param[in] *pState points to state buffer.
  3545. * @param[in] mu step size that controls filter coefficient updates.
  3546. * @param[in] blockSize number of samples to process.
  3547. * @return none.
  3548. */
  3549. void arm_lms_norm_init_f32(
  3550. arm_lms_norm_instance_f32 * S,
  3551. uint16_t numTaps,
  3552. float32_t * pCoeffs,
  3553. float32_t * pState,
  3554. float32_t mu,
  3555. uint32_t blockSize);
  3556. /**
  3557. * @brief Instance structure for the Q31 normalized LMS filter.
  3558. */
  3559. typedef struct
  3560. {
  3561. uint16_t numTaps; /**< number of coefficients in the filter. */
  3562. q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3563. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3564. q31_t mu; /**< step size that controls filter coefficient updates. */
  3565. uint8_t postShift; /**< bit shift applied to coefficients. */
  3566. q31_t *recipTable; /**< points to the reciprocal initial value table. */
  3567. q31_t energy; /**< saves previous frame energy. */
  3568. q31_t x0; /**< saves previous input sample. */
  3569. } arm_lms_norm_instance_q31;
  3570. /**
  3571. * @brief Processing function for Q31 normalized LMS filter.
  3572. * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
  3573. * @param[in] *pSrc points to the block of input data.
  3574. * @param[in] *pRef points to the block of reference data.
  3575. * @param[out] *pOut points to the block of output data.
  3576. * @param[out] *pErr points to the block of error data.
  3577. * @param[in] blockSize number of samples to process.
  3578. * @return none.
  3579. */
  3580. void arm_lms_norm_q31(
  3581. arm_lms_norm_instance_q31 * S,
  3582. q31_t * pSrc,
  3583. q31_t * pRef,
  3584. q31_t * pOut,
  3585. q31_t * pErr,
  3586. uint32_t blockSize);
  3587. /**
  3588. * @brief Initialization function for Q31 normalized LMS filter.
  3589. * @param[in] *S points to an instance of the Q31 normalized LMS filter structure.
  3590. * @param[in] numTaps number of filter coefficients.
  3591. * @param[in] *pCoeffs points to coefficient buffer.
  3592. * @param[in] *pState points to state buffer.
  3593. * @param[in] mu step size that controls filter coefficient updates.
  3594. * @param[in] blockSize number of samples to process.
  3595. * @param[in] postShift bit shift applied to coefficients.
  3596. * @return none.
  3597. */
  3598. void arm_lms_norm_init_q31(
  3599. arm_lms_norm_instance_q31 * S,
  3600. uint16_t numTaps,
  3601. q31_t * pCoeffs,
  3602. q31_t * pState,
  3603. q31_t mu,
  3604. uint32_t blockSize,
  3605. uint8_t postShift);
  3606. /**
  3607. * @brief Instance structure for the Q15 normalized LMS filter.
  3608. */
  3609. typedef struct
  3610. {
  3611. uint16_t numTaps; /**< Number of coefficients in the filter. */
  3612. q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */
  3613. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */
  3614. q15_t mu; /**< step size that controls filter coefficient updates. */
  3615. uint8_t postShift; /**< bit shift applied to coefficients. */
  3616. q15_t *recipTable; /**< Points to the reciprocal initial value table. */
  3617. q15_t energy; /**< saves previous frame energy. */
  3618. q15_t x0; /**< saves previous input sample. */
  3619. } arm_lms_norm_instance_q15;
  3620. /**
  3621. * @brief Processing function for Q15 normalized LMS filter.
  3622. * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
  3623. * @param[in] *pSrc points to the block of input data.
  3624. * @param[in] *pRef points to the block of reference data.
  3625. * @param[out] *pOut points to the block of output data.
  3626. * @param[out] *pErr points to the block of error data.
  3627. * @param[in] blockSize number of samples to process.
  3628. * @return none.
  3629. */
  3630. void arm_lms_norm_q15(
  3631. arm_lms_norm_instance_q15 * S,
  3632. q15_t * pSrc,
  3633. q15_t * pRef,
  3634. q15_t * pOut,
  3635. q15_t * pErr,
  3636. uint32_t blockSize);
  3637. /**
  3638. * @brief Initialization function for Q15 normalized LMS filter.
  3639. * @param[in] *S points to an instance of the Q15 normalized LMS filter structure.
  3640. * @param[in] numTaps number of filter coefficients.
  3641. * @param[in] *pCoeffs points to coefficient buffer.
  3642. * @param[in] *pState points to state buffer.
  3643. * @param[in] mu step size that controls filter coefficient updates.
  3644. * @param[in] blockSize number of samples to process.
  3645. * @param[in] postShift bit shift applied to coefficients.
  3646. * @return none.
  3647. */
  3648. void arm_lms_norm_init_q15(
  3649. arm_lms_norm_instance_q15 * S,
  3650. uint16_t numTaps,
  3651. q15_t * pCoeffs,
  3652. q15_t * pState,
  3653. q15_t mu,
  3654. uint32_t blockSize,
  3655. uint8_t postShift);
  3656. /**
  3657. * @brief Correlation of floating-point sequences.
  3658. * @param[in] *pSrcA points to the first input sequence.
  3659. * @param[in] srcALen length of the first input sequence.
  3660. * @param[in] *pSrcB points to the second input sequence.
  3661. * @param[in] srcBLen length of the second input sequence.
  3662. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3663. * @return none.
  3664. */
  3665. void arm_correlate_f32(
  3666. float32_t * pSrcA,
  3667. uint32_t srcALen,
  3668. float32_t * pSrcB,
  3669. uint32_t srcBLen,
  3670. float32_t * pDst);
  3671. /**
  3672. * @brief Correlation of Q15 sequences
  3673. * @param[in] *pSrcA points to the first input sequence.
  3674. * @param[in] srcALen length of the first input sequence.
  3675. * @param[in] *pSrcB points to the second input sequence.
  3676. * @param[in] srcBLen length of the second input sequence.
  3677. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3678. * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3679. * @return none.
  3680. */
  3681. void arm_correlate_opt_q15(
  3682. q15_t * pSrcA,
  3683. uint32_t srcALen,
  3684. q15_t * pSrcB,
  3685. uint32_t srcBLen,
  3686. q15_t * pDst,
  3687. q15_t * pScratch);
  3688. /**
  3689. * @brief Correlation of Q15 sequences.
  3690. * @param[in] *pSrcA points to the first input sequence.
  3691. * @param[in] srcALen length of the first input sequence.
  3692. * @param[in] *pSrcB points to the second input sequence.
  3693. * @param[in] srcBLen length of the second input sequence.
  3694. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3695. * @return none.
  3696. */
  3697. void arm_correlate_q15(
  3698. q15_t * pSrcA,
  3699. uint32_t srcALen,
  3700. q15_t * pSrcB,
  3701. uint32_t srcBLen,
  3702. q15_t * pDst);
  3703. /**
  3704. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3705. * @param[in] *pSrcA points to the first input sequence.
  3706. * @param[in] srcALen length of the first input sequence.
  3707. * @param[in] *pSrcB points to the second input sequence.
  3708. * @param[in] srcBLen length of the second input sequence.
  3709. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3710. * @return none.
  3711. */
  3712. void arm_correlate_fast_q15(
  3713. q15_t * pSrcA,
  3714. uint32_t srcALen,
  3715. q15_t * pSrcB,
  3716. uint32_t srcBLen,
  3717. q15_t * pDst);
  3718. /**
  3719. * @brief Correlation of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4.
  3720. * @param[in] *pSrcA points to the first input sequence.
  3721. * @param[in] srcALen length of the first input sequence.
  3722. * @param[in] *pSrcB points to the second input sequence.
  3723. * @param[in] srcBLen length of the second input sequence.
  3724. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3725. * @param[in] *pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3726. * @return none.
  3727. */
  3728. void arm_correlate_fast_opt_q15(
  3729. q15_t * pSrcA,
  3730. uint32_t srcALen,
  3731. q15_t * pSrcB,
  3732. uint32_t srcBLen,
  3733. q15_t * pDst,
  3734. q15_t * pScratch);
  3735. /**
  3736. * @brief Correlation of Q31 sequences.
  3737. * @param[in] *pSrcA points to the first input sequence.
  3738. * @param[in] srcALen length of the first input sequence.
  3739. * @param[in] *pSrcB points to the second input sequence.
  3740. * @param[in] srcBLen length of the second input sequence.
  3741. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3742. * @return none.
  3743. */
  3744. void arm_correlate_q31(
  3745. q31_t * pSrcA,
  3746. uint32_t srcALen,
  3747. q31_t * pSrcB,
  3748. uint32_t srcBLen,
  3749. q31_t * pDst);
  3750. /**
  3751. * @brief Correlation of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4
  3752. * @param[in] *pSrcA points to the first input sequence.
  3753. * @param[in] srcALen length of the first input sequence.
  3754. * @param[in] *pSrcB points to the second input sequence.
  3755. * @param[in] srcBLen length of the second input sequence.
  3756. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3757. * @return none.
  3758. */
  3759. void arm_correlate_fast_q31(
  3760. q31_t * pSrcA,
  3761. uint32_t srcALen,
  3762. q31_t * pSrcB,
  3763. uint32_t srcBLen,
  3764. q31_t * pDst);
  3765. /**
  3766. * @brief Correlation of Q7 sequences.
  3767. * @param[in] *pSrcA points to the first input sequence.
  3768. * @param[in] srcALen length of the first input sequence.
  3769. * @param[in] *pSrcB points to the second input sequence.
  3770. * @param[in] srcBLen length of the second input sequence.
  3771. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3772. * @param[in] *pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2.
  3773. * @param[in] *pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen).
  3774. * @return none.
  3775. */
  3776. void arm_correlate_opt_q7(
  3777. q7_t * pSrcA,
  3778. uint32_t srcALen,
  3779. q7_t * pSrcB,
  3780. uint32_t srcBLen,
  3781. q7_t * pDst,
  3782. q15_t * pScratch1,
  3783. q15_t * pScratch2);
  3784. /**
  3785. * @brief Correlation of Q7 sequences.
  3786. * @param[in] *pSrcA points to the first input sequence.
  3787. * @param[in] srcALen length of the first input sequence.
  3788. * @param[in] *pSrcB points to the second input sequence.
  3789. * @param[in] srcBLen length of the second input sequence.
  3790. * @param[out] *pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1.
  3791. * @return none.
  3792. */
  3793. void arm_correlate_q7(
  3794. q7_t * pSrcA,
  3795. uint32_t srcALen,
  3796. q7_t * pSrcB,
  3797. uint32_t srcBLen,
  3798. q7_t * pDst);
  3799. /**
  3800. * @brief Instance structure for the floating-point sparse FIR filter.
  3801. */
  3802. typedef struct
  3803. {
  3804. uint16_t numTaps; /**< number of coefficients in the filter. */
  3805. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3806. float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3807. float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3808. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3809. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3810. } arm_fir_sparse_instance_f32;
  3811. /**
  3812. * @brief Instance structure for the Q31 sparse FIR filter.
  3813. */
  3814. typedef struct
  3815. {
  3816. uint16_t numTaps; /**< number of coefficients in the filter. */
  3817. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3818. q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3819. q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3820. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3821. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3822. } arm_fir_sparse_instance_q31;
  3823. /**
  3824. * @brief Instance structure for the Q15 sparse FIR filter.
  3825. */
  3826. typedef struct
  3827. {
  3828. uint16_t numTaps; /**< number of coefficients in the filter. */
  3829. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3830. q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3831. q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3832. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3833. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3834. } arm_fir_sparse_instance_q15;
  3835. /**
  3836. * @brief Instance structure for the Q7 sparse FIR filter.
  3837. */
  3838. typedef struct
  3839. {
  3840. uint16_t numTaps; /**< number of coefficients in the filter. */
  3841. uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */
  3842. q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */
  3843. q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/
  3844. uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */
  3845. int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */
  3846. } arm_fir_sparse_instance_q7;
  3847. /**
  3848. * @brief Processing function for the floating-point sparse FIR filter.
  3849. * @param[in] *S points to an instance of the floating-point sparse FIR structure.
  3850. * @param[in] *pSrc points to the block of input data.
  3851. * @param[out] *pDst points to the block of output data
  3852. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  3853. * @param[in] blockSize number of input samples to process per call.
  3854. * @return none.
  3855. */
  3856. void arm_fir_sparse_f32(
  3857. arm_fir_sparse_instance_f32 * S,
  3858. float32_t * pSrc,
  3859. float32_t * pDst,
  3860. float32_t * pScratchIn,
  3861. uint32_t blockSize);
  3862. /**
  3863. * @brief Initialization function for the floating-point sparse FIR filter.
  3864. * @param[in,out] *S points to an instance of the floating-point sparse FIR structure.
  3865. * @param[in] numTaps number of nonzero coefficients in the filter.
  3866. * @param[in] *pCoeffs points to the array of filter coefficients.
  3867. * @param[in] *pState points to the state buffer.
  3868. * @param[in] *pTapDelay points to the array of offset times.
  3869. * @param[in] maxDelay maximum offset time supported.
  3870. * @param[in] blockSize number of samples that will be processed per block.
  3871. * @return none
  3872. */
  3873. void arm_fir_sparse_init_f32(
  3874. arm_fir_sparse_instance_f32 * S,
  3875. uint16_t numTaps,
  3876. float32_t * pCoeffs,
  3877. float32_t * pState,
  3878. int32_t * pTapDelay,
  3879. uint16_t maxDelay,
  3880. uint32_t blockSize);
  3881. /**
  3882. * @brief Processing function for the Q31 sparse FIR filter.
  3883. * @param[in] *S points to an instance of the Q31 sparse FIR structure.
  3884. * @param[in] *pSrc points to the block of input data.
  3885. * @param[out] *pDst points to the block of output data
  3886. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  3887. * @param[in] blockSize number of input samples to process per call.
  3888. * @return none.
  3889. */
  3890. void arm_fir_sparse_q31(
  3891. arm_fir_sparse_instance_q31 * S,
  3892. q31_t * pSrc,
  3893. q31_t * pDst,
  3894. q31_t * pScratchIn,
  3895. uint32_t blockSize);
  3896. /**
  3897. * @brief Initialization function for the Q31 sparse FIR filter.
  3898. * @param[in,out] *S points to an instance of the Q31 sparse FIR structure.
  3899. * @param[in] numTaps number of nonzero coefficients in the filter.
  3900. * @param[in] *pCoeffs points to the array of filter coefficients.
  3901. * @param[in] *pState points to the state buffer.
  3902. * @param[in] *pTapDelay points to the array of offset times.
  3903. * @param[in] maxDelay maximum offset time supported.
  3904. * @param[in] blockSize number of samples that will be processed per block.
  3905. * @return none
  3906. */
  3907. void arm_fir_sparse_init_q31(
  3908. arm_fir_sparse_instance_q31 * S,
  3909. uint16_t numTaps,
  3910. q31_t * pCoeffs,
  3911. q31_t * pState,
  3912. int32_t * pTapDelay,
  3913. uint16_t maxDelay,
  3914. uint32_t blockSize);
  3915. /**
  3916. * @brief Processing function for the Q15 sparse FIR filter.
  3917. * @param[in] *S points to an instance of the Q15 sparse FIR structure.
  3918. * @param[in] *pSrc points to the block of input data.
  3919. * @param[out] *pDst points to the block of output data
  3920. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  3921. * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
  3922. * @param[in] blockSize number of input samples to process per call.
  3923. * @return none.
  3924. */
  3925. void arm_fir_sparse_q15(
  3926. arm_fir_sparse_instance_q15 * S,
  3927. q15_t * pSrc,
  3928. q15_t * pDst,
  3929. q15_t * pScratchIn,
  3930. q31_t * pScratchOut,
  3931. uint32_t blockSize);
  3932. /**
  3933. * @brief Initialization function for the Q15 sparse FIR filter.
  3934. * @param[in,out] *S points to an instance of the Q15 sparse FIR structure.
  3935. * @param[in] numTaps number of nonzero coefficients in the filter.
  3936. * @param[in] *pCoeffs points to the array of filter coefficients.
  3937. * @param[in] *pState points to the state buffer.
  3938. * @param[in] *pTapDelay points to the array of offset times.
  3939. * @param[in] maxDelay maximum offset time supported.
  3940. * @param[in] blockSize number of samples that will be processed per block.
  3941. * @return none
  3942. */
  3943. void arm_fir_sparse_init_q15(
  3944. arm_fir_sparse_instance_q15 * S,
  3945. uint16_t numTaps,
  3946. q15_t * pCoeffs,
  3947. q15_t * pState,
  3948. int32_t * pTapDelay,
  3949. uint16_t maxDelay,
  3950. uint32_t blockSize);
  3951. /**
  3952. * @brief Processing function for the Q7 sparse FIR filter.
  3953. * @param[in] *S points to an instance of the Q7 sparse FIR structure.
  3954. * @param[in] *pSrc points to the block of input data.
  3955. * @param[out] *pDst points to the block of output data
  3956. * @param[in] *pScratchIn points to a temporary buffer of size blockSize.
  3957. * @param[in] *pScratchOut points to a temporary buffer of size blockSize.
  3958. * @param[in] blockSize number of input samples to process per call.
  3959. * @return none.
  3960. */
  3961. void arm_fir_sparse_q7(
  3962. arm_fir_sparse_instance_q7 * S,
  3963. q7_t * pSrc,
  3964. q7_t * pDst,
  3965. q7_t * pScratchIn,
  3966. q31_t * pScratchOut,
  3967. uint32_t blockSize);
  3968. /**
  3969. * @brief Initialization function for the Q7 sparse FIR filter.
  3970. * @param[in,out] *S points to an instance of the Q7 sparse FIR structure.
  3971. * @param[in] numTaps number of nonzero coefficients in the filter.
  3972. * @param[in] *pCoeffs points to the array of filter coefficients.
  3973. * @param[in] *pState points to the state buffer.
  3974. * @param[in] *pTapDelay points to the array of offset times.
  3975. * @param[in] maxDelay maximum offset time supported.
  3976. * @param[in] blockSize number of samples that will be processed per block.
  3977. * @return none
  3978. */
  3979. void arm_fir_sparse_init_q7(
  3980. arm_fir_sparse_instance_q7 * S,
  3981. uint16_t numTaps,
  3982. q7_t * pCoeffs,
  3983. q7_t * pState,
  3984. int32_t * pTapDelay,
  3985. uint16_t maxDelay,
  3986. uint32_t blockSize);
  3987. /*
  3988. * @brief Floating-point sin_cos function.
  3989. * @param[in] theta input value in degrees
  3990. * @param[out] *pSinVal points to the processed sine output.
  3991. * @param[out] *pCosVal points to the processed cos output.
  3992. * @return none.
  3993. */
  3994. void arm_sin_cos_f32(
  3995. float32_t theta,
  3996. float32_t * pSinVal,
  3997. float32_t * pCcosVal);
  3998. /*
  3999. * @brief Q31 sin_cos function.
  4000. * @param[in] theta scaled input value in degrees
  4001. * @param[out] *pSinVal points to the processed sine output.
  4002. * @param[out] *pCosVal points to the processed cosine output.
  4003. * @return none.
  4004. */
  4005. void arm_sin_cos_q31(
  4006. q31_t theta,
  4007. q31_t * pSinVal,
  4008. q31_t * pCosVal);
  4009. /**
  4010. * @brief Floating-point complex conjugate.
  4011. * @param[in] *pSrc points to the input vector
  4012. * @param[out] *pDst points to the output vector
  4013. * @param[in] numSamples number of complex samples in each vector
  4014. * @return none.
  4015. */
  4016. void arm_cmplx_conj_f32(
  4017. float32_t * pSrc,
  4018. float32_t * pDst,
  4019. uint32_t numSamples);
  4020. /**
  4021. * @brief Q31 complex conjugate.
  4022. * @param[in] *pSrc points to the input vector
  4023. * @param[out] *pDst points to the output vector
  4024. * @param[in] numSamples number of complex samples in each vector
  4025. * @return none.
  4026. */
  4027. void arm_cmplx_conj_q31(
  4028. q31_t * pSrc,
  4029. q31_t * pDst,
  4030. uint32_t numSamples);
  4031. /**
  4032. * @brief Q15 complex conjugate.
  4033. * @param[in] *pSrc points to the input vector
  4034. * @param[out] *pDst points to the output vector
  4035. * @param[in] numSamples number of complex samples in each vector
  4036. * @return none.
  4037. */
  4038. void arm_cmplx_conj_q15(
  4039. q15_t * pSrc,
  4040. q15_t * pDst,
  4041. uint32_t numSamples);
  4042. /**
  4043. * @brief Floating-point complex magnitude squared
  4044. * @param[in] *pSrc points to the complex input vector
  4045. * @param[out] *pDst points to the real output vector
  4046. * @param[in] numSamples number of complex samples in the input vector
  4047. * @return none.
  4048. */
  4049. void arm_cmplx_mag_squared_f32(
  4050. float32_t * pSrc,
  4051. float32_t * pDst,
  4052. uint32_t numSamples);
  4053. /**
  4054. * @brief Q31 complex magnitude squared
  4055. * @param[in] *pSrc points to the complex input vector
  4056. * @param[out] *pDst points to the real output vector
  4057. * @param[in] numSamples number of complex samples in the input vector
  4058. * @return none.
  4059. */
  4060. void arm_cmplx_mag_squared_q31(
  4061. q31_t * pSrc,
  4062. q31_t * pDst,
  4063. uint32_t numSamples);
  4064. /**
  4065. * @brief Q15 complex magnitude squared
  4066. * @param[in] *pSrc points to the complex input vector
  4067. * @param[out] *pDst points to the real output vector
  4068. * @param[in] numSamples number of complex samples in the input vector
  4069. * @return none.
  4070. */
  4071. void arm_cmplx_mag_squared_q15(
  4072. q15_t * pSrc,
  4073. q15_t * pDst,
  4074. uint32_t numSamples);
  4075. /**
  4076. * @ingroup groupController
  4077. */
  4078. /**
  4079. * @defgroup PID PID Motor Control
  4080. *
  4081. * A Proportional Integral Derivative (PID) controller is a generic feedback control
  4082. * loop mechanism widely used in industrial control systems.
  4083. * A PID controller is the most commonly used type of feedback controller.
  4084. *
  4085. * This set of functions implements (PID) controllers
  4086. * for Q15, Q31, and floating-point data types. The functions operate on a single sample
  4087. * of data and each call to the function returns a single processed value.
  4088. * <code>S</code> points to an instance of the PID control data structure. <code>in</code>
  4089. * is the input sample value. The functions return the output value.
  4090. *
  4091. * \par Algorithm:
  4092. * <pre>
  4093. * y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
  4094. * A0 = Kp + Ki + Kd
  4095. * A1 = (-Kp ) - (2 * Kd )
  4096. * A2 = Kd </pre>
  4097. *
  4098. * \par
  4099. * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant
  4100. *
  4101. * \par
  4102. * \image html PID.gif "Proportional Integral Derivative Controller"
  4103. *
  4104. * \par
  4105. * The PID controller calculates an "error" value as the difference between
  4106. * the measured output and the reference input.
  4107. * The controller attempts to minimize the error by adjusting the process control inputs.
  4108. * The proportional value determines the reaction to the current error,
  4109. * the integral value determines the reaction based on the sum of recent errors,
  4110. * and the derivative value determines the reaction based on the rate at which the error has been changing.
  4111. *
  4112. * \par Instance Structure
  4113. * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure.
  4114. * A separate instance structure must be defined for each PID Controller.
  4115. * There are separate instance structure declarations for each of the 3 supported data types.
  4116. *
  4117. * \par Reset Functions
  4118. * There is also an associated reset function for each data type which clears the state array.
  4119. *
  4120. * \par Initialization Functions
  4121. * There is also an associated initialization function for each data type.
  4122. * The initialization function performs the following operations:
  4123. * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains.
  4124. * - Zeros out the values in the state buffer.
  4125. *
  4126. * \par
  4127. * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function.
  4128. *
  4129. * \par Fixed-Point Behavior
  4130. * Care must be taken when using the fixed-point versions of the PID Controller functions.
  4131. * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered.
  4132. * Refer to the function specific documentation below for usage guidelines.
  4133. */
  4134. /**
  4135. * @addtogroup PID
  4136. * @{
  4137. */
  4138. /**
  4139. * @brief Process function for the floating-point PID Control.
  4140. * @param[in,out] *S is an instance of the floating-point PID Control structure
  4141. * @param[in] in input sample to process
  4142. * @return out processed output sample.
  4143. */
  4144. static __INLINE float32_t arm_pid_f32(
  4145. arm_pid_instance_f32 * S,
  4146. float32_t in)
  4147. {
  4148. float32_t out;
  4149. /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */
  4150. out = (S->A0 * in) +
  4151. (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]);
  4152. /* Update state */
  4153. S->state[1] = S->state[0];
  4154. S->state[0] = in;
  4155. S->state[2] = out;
  4156. /* return to application */
  4157. return (out);
  4158. }
  4159. /**
  4160. * @brief Process function for the Q31 PID Control.
  4161. * @param[in,out] *S points to an instance of the Q31 PID Control structure
  4162. * @param[in] in input sample to process
  4163. * @return out processed output sample.
  4164. *
  4165. * <b>Scaling and Overflow Behavior:</b>
  4166. * \par
  4167. * The function is implemented using an internal 64-bit accumulator.
  4168. * The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit.
  4169. * Thus, if the accumulator result overflows it wraps around rather than clip.
  4170. * In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions.
  4171. * After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format.
  4172. */
  4173. static __INLINE q31_t arm_pid_q31(
  4174. arm_pid_instance_q31 * S,
  4175. q31_t in)
  4176. {
  4177. q63_t acc;
  4178. q31_t out;
  4179. /* acc = A0 * x[n] */
  4180. acc = (q63_t) S->A0 * in;
  4181. /* acc += A1 * x[n-1] */
  4182. acc += (q63_t) S->A1 * S->state[0];
  4183. /* acc += A2 * x[n-2] */
  4184. acc += (q63_t) S->A2 * S->state[1];
  4185. /* convert output to 1.31 format to add y[n-1] */
  4186. out = (q31_t) (acc >> 31u);
  4187. /* out += y[n-1] */
  4188. out += S->state[2];
  4189. /* Update state */
  4190. S->state[1] = S->state[0];
  4191. S->state[0] = in;
  4192. S->state[2] = out;
  4193. /* return to application */
  4194. return (out);
  4195. }
  4196. /**
  4197. * @brief Process function for the Q15 PID Control.
  4198. * @param[in,out] *S points to an instance of the Q15 PID Control structure
  4199. * @param[in] in input sample to process
  4200. * @return out processed output sample.
  4201. *
  4202. * <b>Scaling and Overflow Behavior:</b>
  4203. * \par
  4204. * The function is implemented using a 64-bit internal accumulator.
  4205. * Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result.
  4206. * The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format.
  4207. * There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved.
  4208. * After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits.
  4209. * Lastly, the accumulator is saturated to yield a result in 1.15 format.
  4210. */
  4211. static __INLINE q15_t arm_pid_q15(
  4212. arm_pid_instance_q15 * S,
  4213. q15_t in)
  4214. {
  4215. q63_t acc;
  4216. q15_t out;
  4217. #ifndef ARM_MATH_CM0_FAMILY
  4218. __SIMD32_TYPE *vstate;
  4219. /* Implementation of PID controller */
  4220. /* acc = A0 * x[n] */
  4221. acc = (q31_t) __SMUAD(S->A0, in);
  4222. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4223. vstate = __SIMD32_CONST(S->state);
  4224. acc = __SMLALD(S->A1, (q31_t) *vstate, acc);
  4225. #else
  4226. /* acc = A0 * x[n] */
  4227. acc = ((q31_t) S->A0) * in;
  4228. /* acc += A1 * x[n-1] + A2 * x[n-2] */
  4229. acc += (q31_t) S->A1 * S->state[0];
  4230. acc += (q31_t) S->A2 * S->state[1];
  4231. #endif
  4232. /* acc += y[n-1] */
  4233. acc += (q31_t) S->state[2] << 15;
  4234. /* saturate the output */
  4235. out = (q15_t) (__SSAT((acc >> 15), 16));
  4236. /* Update state */
  4237. S->state[1] = S->state[0];
  4238. S->state[0] = in;
  4239. S->state[2] = out;
  4240. /* return to application */
  4241. return (out);
  4242. }
  4243. /**
  4244. * @} end of PID group
  4245. */
  4246. /**
  4247. * @brief Floating-point matrix inverse.
  4248. * @param[in] *src points to the instance of the input floating-point matrix structure.
  4249. * @param[out] *dst points to the instance of the output floating-point matrix structure.
  4250. * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match.
  4251. * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR.
  4252. */
  4253. arm_status arm_mat_inverse_f32(
  4254. const arm_matrix_instance_f32 * src,
  4255. arm_matrix_instance_f32 * dst);
  4256. /**
  4257. * @ingroup groupController
  4258. */
  4259. /**
  4260. * @defgroup clarke Vector Clarke Transform
  4261. * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector.
  4262. * Generally the Clarke transform uses three-phase currents <code>Ia, Ib and Ic</code> to calculate currents
  4263. * in the two-phase orthogonal stator axis <code>Ialpha</code> and <code>Ibeta</code>.
  4264. * When <code>Ialpha</code> is superposed with <code>Ia</code> as shown in the figure below
  4265. * \image html clarke.gif Stator current space vector and its components in (a,b).
  4266. * and <code>Ia + Ib + Ic = 0</code>, in this condition <code>Ialpha</code> and <code>Ibeta</code>
  4267. * can be calculated using only <code>Ia</code> and <code>Ib</code>.
  4268. *
  4269. * The function operates on a single sample of data and each call to the function returns the processed output.
  4270. * The library provides separate functions for Q31 and floating-point data types.
  4271. * \par Algorithm
  4272. * \image html clarkeFormula.gif
  4273. * where <code>Ia</code> and <code>Ib</code> are the instantaneous stator phases and
  4274. * <code>pIalpha</code> and <code>pIbeta</code> are the two coordinates of time invariant vector.
  4275. * \par Fixed-Point Behavior
  4276. * Care must be taken when using the Q31 version of the Clarke transform.
  4277. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4278. * Refer to the function specific documentation below for usage guidelines.
  4279. */
  4280. /**
  4281. * @addtogroup clarke
  4282. * @{
  4283. */
  4284. /**
  4285. *
  4286. * @brief Floating-point Clarke transform
  4287. * @param[in] Ia input three-phase coordinate <code>a</code>
  4288. * @param[in] Ib input three-phase coordinate <code>b</code>
  4289. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4290. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4291. * @return none.
  4292. */
  4293. static __INLINE void arm_clarke_f32(
  4294. float32_t Ia,
  4295. float32_t Ib,
  4296. float32_t * pIalpha,
  4297. float32_t * pIbeta)
  4298. {
  4299. /* Calculate pIalpha using the equation, pIalpha = Ia */
  4300. *pIalpha = Ia;
  4301. /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */
  4302. *pIbeta =
  4303. ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib);
  4304. }
  4305. /**
  4306. * @brief Clarke transform for Q31 version
  4307. * @param[in] Ia input three-phase coordinate <code>a</code>
  4308. * @param[in] Ib input three-phase coordinate <code>b</code>
  4309. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4310. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4311. * @return none.
  4312. *
  4313. * <b>Scaling and Overflow Behavior:</b>
  4314. * \par
  4315. * The function is implemented using an internal 32-bit accumulator.
  4316. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4317. * There is saturation on the addition, hence there is no risk of overflow.
  4318. */
  4319. static __INLINE void arm_clarke_q31(
  4320. q31_t Ia,
  4321. q31_t Ib,
  4322. q31_t * pIalpha,
  4323. q31_t * pIbeta)
  4324. {
  4325. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4326. /* Calculating pIalpha from Ia by equation pIalpha = Ia */
  4327. *pIalpha = Ia;
  4328. /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */
  4329. product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30);
  4330. /* Intermediate product is calculated by (2/sqrt(3) * Ib) */
  4331. product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30);
  4332. /* pIbeta is calculated by adding the intermediate products */
  4333. *pIbeta = __QADD(product1, product2);
  4334. }
  4335. /**
  4336. * @} end of clarke group
  4337. */
  4338. /**
  4339. * @brief Converts the elements of the Q7 vector to Q31 vector.
  4340. * @param[in] *pSrc input pointer
  4341. * @param[out] *pDst output pointer
  4342. * @param[in] blockSize number of samples to process
  4343. * @return none.
  4344. */
  4345. void arm_q7_to_q31(
  4346. q7_t * pSrc,
  4347. q31_t * pDst,
  4348. uint32_t blockSize);
  4349. /**
  4350. * @ingroup groupController
  4351. */
  4352. /**
  4353. * @defgroup inv_clarke Vector Inverse Clarke Transform
  4354. * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases.
  4355. *
  4356. * The function operates on a single sample of data and each call to the function returns the processed output.
  4357. * The library provides separate functions for Q31 and floating-point data types.
  4358. * \par Algorithm
  4359. * \image html clarkeInvFormula.gif
  4360. * where <code>pIa</code> and <code>pIb</code> are the instantaneous stator phases and
  4361. * <code>Ialpha</code> and <code>Ibeta</code> are the two coordinates of time invariant vector.
  4362. * \par Fixed-Point Behavior
  4363. * Care must be taken when using the Q31 version of the Clarke transform.
  4364. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4365. * Refer to the function specific documentation below for usage guidelines.
  4366. */
  4367. /**
  4368. * @addtogroup inv_clarke
  4369. * @{
  4370. */
  4371. /**
  4372. * @brief Floating-point Inverse Clarke transform
  4373. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4374. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4375. * @param[out] *pIa points to output three-phase coordinate <code>a</code>
  4376. * @param[out] *pIb points to output three-phase coordinate <code>b</code>
  4377. * @return none.
  4378. */
  4379. static __INLINE void arm_inv_clarke_f32(
  4380. float32_t Ialpha,
  4381. float32_t Ibeta,
  4382. float32_t * pIa,
  4383. float32_t * pIb)
  4384. {
  4385. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4386. *pIa = Ialpha;
  4387. /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */
  4388. *pIb = -0.5 * Ialpha + (float32_t) 0.8660254039 *Ibeta;
  4389. }
  4390. /**
  4391. * @brief Inverse Clarke transform for Q31 version
  4392. * @param[in] Ialpha input two-phase orthogonal vector axis alpha
  4393. * @param[in] Ibeta input two-phase orthogonal vector axis beta
  4394. * @param[out] *pIa points to output three-phase coordinate <code>a</code>
  4395. * @param[out] *pIb points to output three-phase coordinate <code>b</code>
  4396. * @return none.
  4397. *
  4398. * <b>Scaling and Overflow Behavior:</b>
  4399. * \par
  4400. * The function is implemented using an internal 32-bit accumulator.
  4401. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4402. * There is saturation on the subtraction, hence there is no risk of overflow.
  4403. */
  4404. static __INLINE void arm_inv_clarke_q31(
  4405. q31_t Ialpha,
  4406. q31_t Ibeta,
  4407. q31_t * pIa,
  4408. q31_t * pIb)
  4409. {
  4410. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4411. /* Calculating pIa from Ialpha by equation pIa = Ialpha */
  4412. *pIa = Ialpha;
  4413. /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */
  4414. product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31);
  4415. /* Intermediate product is calculated by (1/sqrt(3) * pIb) */
  4416. product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31);
  4417. /* pIb is calculated by subtracting the products */
  4418. *pIb = __QSUB(product2, product1);
  4419. }
  4420. /**
  4421. * @} end of inv_clarke group
  4422. */
  4423. /**
  4424. * @brief Converts the elements of the Q7 vector to Q15 vector.
  4425. * @param[in] *pSrc input pointer
  4426. * @param[out] *pDst output pointer
  4427. * @param[in] blockSize number of samples to process
  4428. * @return none.
  4429. */
  4430. void arm_q7_to_q15(
  4431. q7_t * pSrc,
  4432. q15_t * pDst,
  4433. uint32_t blockSize);
  4434. /**
  4435. * @ingroup groupController
  4436. */
  4437. /**
  4438. * @defgroup park Vector Park Transform
  4439. *
  4440. * Forward Park transform converts the input two-coordinate vector to flux and torque components.
  4441. * The Park transform can be used to realize the transformation of the <code>Ialpha</code> and the <code>Ibeta</code> currents
  4442. * from the stationary to the moving reference frame and control the spatial relationship between
  4443. * the stator vector current and rotor flux vector.
  4444. * If we consider the d axis aligned with the rotor flux, the diagram below shows the
  4445. * current vector and the relationship from the two reference frames:
  4446. * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame"
  4447. *
  4448. * The function operates on a single sample of data and each call to the function returns the processed output.
  4449. * The library provides separate functions for Q31 and floating-point data types.
  4450. * \par Algorithm
  4451. * \image html parkFormula.gif
  4452. * where <code>Ialpha</code> and <code>Ibeta</code> are the stator vector components,
  4453. * <code>pId</code> and <code>pIq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4454. * cosine and sine values of theta (rotor flux position).
  4455. * \par Fixed-Point Behavior
  4456. * Care must be taken when using the Q31 version of the Park transform.
  4457. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4458. * Refer to the function specific documentation below for usage guidelines.
  4459. */
  4460. /**
  4461. * @addtogroup park
  4462. * @{
  4463. */
  4464. /**
  4465. * @brief Floating-point Park transform
  4466. * @param[in] Ialpha input two-phase vector coordinate alpha
  4467. * @param[in] Ibeta input two-phase vector coordinate beta
  4468. * @param[out] *pId points to output rotor reference frame d
  4469. * @param[out] *pIq points to output rotor reference frame q
  4470. * @param[in] sinVal sine value of rotation angle theta
  4471. * @param[in] cosVal cosine value of rotation angle theta
  4472. * @return none.
  4473. *
  4474. * The function implements the forward Park transform.
  4475. *
  4476. */
  4477. static __INLINE void arm_park_f32(
  4478. float32_t Ialpha,
  4479. float32_t Ibeta,
  4480. float32_t * pId,
  4481. float32_t * pIq,
  4482. float32_t sinVal,
  4483. float32_t cosVal)
  4484. {
  4485. /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */
  4486. *pId = Ialpha * cosVal + Ibeta * sinVal;
  4487. /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */
  4488. *pIq = -Ialpha * sinVal + Ibeta * cosVal;
  4489. }
  4490. /**
  4491. * @brief Park transform for Q31 version
  4492. * @param[in] Ialpha input two-phase vector coordinate alpha
  4493. * @param[in] Ibeta input two-phase vector coordinate beta
  4494. * @param[out] *pId points to output rotor reference frame d
  4495. * @param[out] *pIq points to output rotor reference frame q
  4496. * @param[in] sinVal sine value of rotation angle theta
  4497. * @param[in] cosVal cosine value of rotation angle theta
  4498. * @return none.
  4499. *
  4500. * <b>Scaling and Overflow Behavior:</b>
  4501. * \par
  4502. * The function is implemented using an internal 32-bit accumulator.
  4503. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4504. * There is saturation on the addition and subtraction, hence there is no risk of overflow.
  4505. */
  4506. static __INLINE void arm_park_q31(
  4507. q31_t Ialpha,
  4508. q31_t Ibeta,
  4509. q31_t * pId,
  4510. q31_t * pIq,
  4511. q31_t sinVal,
  4512. q31_t cosVal)
  4513. {
  4514. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4515. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4516. /* Intermediate product is calculated by (Ialpha * cosVal) */
  4517. product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31);
  4518. /* Intermediate product is calculated by (Ibeta * sinVal) */
  4519. product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31);
  4520. /* Intermediate product is calculated by (Ialpha * sinVal) */
  4521. product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31);
  4522. /* Intermediate product is calculated by (Ibeta * cosVal) */
  4523. product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31);
  4524. /* Calculate pId by adding the two intermediate products 1 and 2 */
  4525. *pId = __QADD(product1, product2);
  4526. /* Calculate pIq by subtracting the two intermediate products 3 from 4 */
  4527. *pIq = __QSUB(product4, product3);
  4528. }
  4529. /**
  4530. * @} end of park group
  4531. */
  4532. /**
  4533. * @brief Converts the elements of the Q7 vector to floating-point vector.
  4534. * @param[in] *pSrc is input pointer
  4535. * @param[out] *pDst is output pointer
  4536. * @param[in] blockSize is the number of samples to process
  4537. * @return none.
  4538. */
  4539. void arm_q7_to_float(
  4540. q7_t * pSrc,
  4541. float32_t * pDst,
  4542. uint32_t blockSize);
  4543. /**
  4544. * @ingroup groupController
  4545. */
  4546. /**
  4547. * @defgroup inv_park Vector Inverse Park transform
  4548. * Inverse Park transform converts the input flux and torque components to two-coordinate vector.
  4549. *
  4550. * The function operates on a single sample of data and each call to the function returns the processed output.
  4551. * The library provides separate functions for Q31 and floating-point data types.
  4552. * \par Algorithm
  4553. * \image html parkInvFormula.gif
  4554. * where <code>pIalpha</code> and <code>pIbeta</code> are the stator vector components,
  4555. * <code>Id</code> and <code>Iq</code> are rotor vector components and <code>cosVal</code> and <code>sinVal</code> are the
  4556. * cosine and sine values of theta (rotor flux position).
  4557. * \par Fixed-Point Behavior
  4558. * Care must be taken when using the Q31 version of the Park transform.
  4559. * In particular, the overflow and saturation behavior of the accumulator used must be considered.
  4560. * Refer to the function specific documentation below for usage guidelines.
  4561. */
  4562. /**
  4563. * @addtogroup inv_park
  4564. * @{
  4565. */
  4566. /**
  4567. * @brief Floating-point Inverse Park transform
  4568. * @param[in] Id input coordinate of rotor reference frame d
  4569. * @param[in] Iq input coordinate of rotor reference frame q
  4570. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4571. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4572. * @param[in] sinVal sine value of rotation angle theta
  4573. * @param[in] cosVal cosine value of rotation angle theta
  4574. * @return none.
  4575. */
  4576. static __INLINE void arm_inv_park_f32(
  4577. float32_t Id,
  4578. float32_t Iq,
  4579. float32_t * pIalpha,
  4580. float32_t * pIbeta,
  4581. float32_t sinVal,
  4582. float32_t cosVal)
  4583. {
  4584. /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */
  4585. *pIalpha = Id * cosVal - Iq * sinVal;
  4586. /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */
  4587. *pIbeta = Id * sinVal + Iq * cosVal;
  4588. }
  4589. /**
  4590. * @brief Inverse Park transform for Q31 version
  4591. * @param[in] Id input coordinate of rotor reference frame d
  4592. * @param[in] Iq input coordinate of rotor reference frame q
  4593. * @param[out] *pIalpha points to output two-phase orthogonal vector axis alpha
  4594. * @param[out] *pIbeta points to output two-phase orthogonal vector axis beta
  4595. * @param[in] sinVal sine value of rotation angle theta
  4596. * @param[in] cosVal cosine value of rotation angle theta
  4597. * @return none.
  4598. *
  4599. * <b>Scaling and Overflow Behavior:</b>
  4600. * \par
  4601. * The function is implemented using an internal 32-bit accumulator.
  4602. * The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format.
  4603. * There is saturation on the addition, hence there is no risk of overflow.
  4604. */
  4605. static __INLINE void arm_inv_park_q31(
  4606. q31_t Id,
  4607. q31_t Iq,
  4608. q31_t * pIalpha,
  4609. q31_t * pIbeta,
  4610. q31_t sinVal,
  4611. q31_t cosVal)
  4612. {
  4613. q31_t product1, product2; /* Temporary variables used to store intermediate results */
  4614. q31_t product3, product4; /* Temporary variables used to store intermediate results */
  4615. /* Intermediate product is calculated by (Id * cosVal) */
  4616. product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31);
  4617. /* Intermediate product is calculated by (Iq * sinVal) */
  4618. product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31);
  4619. /* Intermediate product is calculated by (Id * sinVal) */
  4620. product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31);
  4621. /* Intermediate product is calculated by (Iq * cosVal) */
  4622. product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31);
  4623. /* Calculate pIalpha by using the two intermediate products 1 and 2 */
  4624. *pIalpha = __QSUB(product1, product2);
  4625. /* Calculate pIbeta by using the two intermediate products 3 and 4 */
  4626. *pIbeta = __QADD(product4, product3);
  4627. }
  4628. /**
  4629. * @} end of Inverse park group
  4630. */
  4631. /**
  4632. * @brief Converts the elements of the Q31 vector to floating-point vector.
  4633. * @param[in] *pSrc is input pointer
  4634. * @param[out] *pDst is output pointer
  4635. * @param[in] blockSize is the number of samples to process
  4636. * @return none.
  4637. */
  4638. void arm_q31_to_float(
  4639. q31_t * pSrc,
  4640. float32_t * pDst,
  4641. uint32_t blockSize);
  4642. /**
  4643. * @ingroup groupInterpolation
  4644. */
  4645. /**
  4646. * @defgroup LinearInterpolate Linear Interpolation
  4647. *
  4648. * Linear interpolation is a method of curve fitting using linear polynomials.
  4649. * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line
  4650. *
  4651. * \par
  4652. * \image html LinearInterp.gif "Linear interpolation"
  4653. *
  4654. * \par
  4655. * A Linear Interpolate function calculates an output value(y), for the input(x)
  4656. * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values)
  4657. *
  4658. * \par Algorithm:
  4659. * <pre>
  4660. * y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
  4661. * where x0, x1 are nearest values of input x
  4662. * y0, y1 are nearest values to output y
  4663. * </pre>
  4664. *
  4665. * \par
  4666. * This set of functions implements Linear interpolation process
  4667. * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single
  4668. * sample of data and each call to the function returns a single processed value.
  4669. * <code>S</code> points to an instance of the Linear Interpolate function data structure.
  4670. * <code>x</code> is the input sample value. The functions returns the output value.
  4671. *
  4672. * \par
  4673. * if x is outside of the table boundary, Linear interpolation returns first value of the table
  4674. * if x is below input range and returns last value of table if x is above range.
  4675. */
  4676. /**
  4677. * @addtogroup LinearInterpolate
  4678. * @{
  4679. */
  4680. /**
  4681. * @brief Process function for the floating-point Linear Interpolation Function.
  4682. * @param[in,out] *S is an instance of the floating-point Linear Interpolation structure
  4683. * @param[in] x input sample to process
  4684. * @return y processed output sample.
  4685. *
  4686. */
  4687. static __INLINE float32_t arm_linear_interp_f32(
  4688. arm_linear_interp_instance_f32 * S,
  4689. float32_t x)
  4690. {
  4691. float32_t y;
  4692. float32_t x0, x1; /* Nearest input values */
  4693. float32_t y0, y1; /* Nearest output values */
  4694. float32_t xSpacing = S->xSpacing; /* spacing between input values */
  4695. int32_t i; /* Index variable */
  4696. float32_t *pYData = S->pYData; /* pointer to output table */
  4697. /* Calculation of index */
  4698. i = (int32_t) ((x - S->x1) / xSpacing);
  4699. if(i < 0)
  4700. {
  4701. /* Iniatilize output for below specified range as least output value of table */
  4702. y = pYData[0];
  4703. }
  4704. else if((uint32_t)i >= S->nValues)
  4705. {
  4706. /* Iniatilize output for above specified range as last output value of table */
  4707. y = pYData[S->nValues - 1];
  4708. }
  4709. else
  4710. {
  4711. /* Calculation of nearest input values */
  4712. x0 = S->x1 + i * xSpacing;
  4713. x1 = S->x1 + (i + 1) * xSpacing;
  4714. /* Read of nearest output values */
  4715. y0 = pYData[i];
  4716. y1 = pYData[i + 1];
  4717. /* Calculation of output */
  4718. y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));
  4719. }
  4720. /* returns output value */
  4721. return (y);
  4722. }
  4723. /**
  4724. *
  4725. * @brief Process function for the Q31 Linear Interpolation Function.
  4726. * @param[in] *pYData pointer to Q31 Linear Interpolation table
  4727. * @param[in] x input sample to process
  4728. * @param[in] nValues number of table values
  4729. * @return y processed output sample.
  4730. *
  4731. * \par
  4732. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4733. * This function can support maximum of table size 2^12.
  4734. *
  4735. */
  4736. static __INLINE q31_t arm_linear_interp_q31(
  4737. q31_t * pYData,
  4738. q31_t x,
  4739. uint32_t nValues)
  4740. {
  4741. q31_t y; /* output */
  4742. q31_t y0, y1; /* Nearest output values */
  4743. q31_t fract; /* fractional part */
  4744. int32_t index; /* Index to read nearest output values */
  4745. /* Input is in 12.20 format */
  4746. /* 12 bits for the table index */
  4747. /* Index value calculation */
  4748. index = ((x & 0xFFF00000) >> 20);
  4749. if(index >= (int32_t)(nValues - 1))
  4750. {
  4751. return (pYData[nValues - 1]);
  4752. }
  4753. else if(index < 0)
  4754. {
  4755. return (pYData[0]);
  4756. }
  4757. else
  4758. {
  4759. /* 20 bits for the fractional part */
  4760. /* shift left by 11 to keep fract in 1.31 format */
  4761. fract = (x & 0x000FFFFF) << 11;
  4762. /* Read two nearest output values from the index in 1.31(q31) format */
  4763. y0 = pYData[index];
  4764. y1 = pYData[index + 1u];
  4765. /* Calculation of y0 * (1-fract) and y is in 2.30 format */
  4766. y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32));
  4767. /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */
  4768. y += ((q31_t) (((q63_t) y1 * fract) >> 32));
  4769. /* Convert y to 1.31 format */
  4770. return (y << 1u);
  4771. }
  4772. }
  4773. /**
  4774. *
  4775. * @brief Process function for the Q15 Linear Interpolation Function.
  4776. * @param[in] *pYData pointer to Q15 Linear Interpolation table
  4777. * @param[in] x input sample to process
  4778. * @param[in] nValues number of table values
  4779. * @return y processed output sample.
  4780. *
  4781. * \par
  4782. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4783. * This function can support maximum of table size 2^12.
  4784. *
  4785. */
  4786. static __INLINE q15_t arm_linear_interp_q15(
  4787. q15_t * pYData,
  4788. q31_t x,
  4789. uint32_t nValues)
  4790. {
  4791. q63_t y; /* output */
  4792. q15_t y0, y1; /* Nearest output values */
  4793. q31_t fract; /* fractional part */
  4794. int32_t index; /* Index to read nearest output values */
  4795. /* Input is in 12.20 format */
  4796. /* 12 bits for the table index */
  4797. /* Index value calculation */
  4798. index = ((x & 0xFFF00000) >> 20u);
  4799. if(index >= (int32_t)(nValues - 1))
  4800. {
  4801. return (pYData[nValues - 1]);
  4802. }
  4803. else if(index < 0)
  4804. {
  4805. return (pYData[0]);
  4806. }
  4807. else
  4808. {
  4809. /* 20 bits for the fractional part */
  4810. /* fract is in 12.20 format */
  4811. fract = (x & 0x000FFFFF);
  4812. /* Read two nearest output values from the index */
  4813. y0 = pYData[index];
  4814. y1 = pYData[index + 1u];
  4815. /* Calculation of y0 * (1-fract) and y is in 13.35 format */
  4816. y = ((q63_t) y0 * (0xFFFFF - fract));
  4817. /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */
  4818. y += ((q63_t) y1 * (fract));
  4819. /* convert y to 1.15 format */
  4820. return (y >> 20);
  4821. }
  4822. }
  4823. /**
  4824. *
  4825. * @brief Process function for the Q7 Linear Interpolation Function.
  4826. * @param[in] *pYData pointer to Q7 Linear Interpolation table
  4827. * @param[in] x input sample to process
  4828. * @param[in] nValues number of table values
  4829. * @return y processed output sample.
  4830. *
  4831. * \par
  4832. * Input sample <code>x</code> is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part.
  4833. * This function can support maximum of table size 2^12.
  4834. */
  4835. static __INLINE q7_t arm_linear_interp_q7(
  4836. q7_t * pYData,
  4837. q31_t x,
  4838. uint32_t nValues)
  4839. {
  4840. q31_t y; /* output */
  4841. q7_t y0, y1; /* Nearest output values */
  4842. q31_t fract; /* fractional part */
  4843. uint32_t index; /* Index to read nearest output values */
  4844. /* Input is in 12.20 format */
  4845. /* 12 bits for the table index */
  4846. /* Index value calculation */
  4847. if (x < 0)
  4848. {
  4849. return (pYData[0]);
  4850. }
  4851. index = (x >> 20) & 0xfff;
  4852. if(index >= (nValues - 1))
  4853. {
  4854. return (pYData[nValues - 1]);
  4855. }
  4856. else
  4857. {
  4858. /* 20 bits for the fractional part */
  4859. /* fract is in 12.20 format */
  4860. fract = (x & 0x000FFFFF);
  4861. /* Read two nearest output values from the index and are in 1.7(q7) format */
  4862. y0 = pYData[index];
  4863. y1 = pYData[index + 1u];
  4864. /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */
  4865. y = ((y0 * (0xFFFFF - fract)));
  4866. /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */
  4867. y += (y1 * fract);
  4868. /* convert y to 1.7(q7) format */
  4869. return (y >> 20u);
  4870. }
  4871. }
  4872. /**
  4873. * @} end of LinearInterpolate group
  4874. */
  4875. /**
  4876. * @brief Fast approximation to the trigonometric sine function for floating-point data.
  4877. * @param[in] x input value in radians.
  4878. * @return sin(x).
  4879. */
  4880. float32_t arm_sin_f32(
  4881. float32_t x);
  4882. /**
  4883. * @brief Fast approximation to the trigonometric sine function for Q31 data.
  4884. * @param[in] x Scaled input value in radians.
  4885. * @return sin(x).
  4886. */
  4887. q31_t arm_sin_q31(
  4888. q31_t x);
  4889. /**
  4890. * @brief Fast approximation to the trigonometric sine function for Q15 data.
  4891. * @param[in] x Scaled input value in radians.
  4892. * @return sin(x).
  4893. */
  4894. q15_t arm_sin_q15(
  4895. q15_t x);
  4896. /**
  4897. * @brief Fast approximation to the trigonometric cosine function for floating-point data.
  4898. * @param[in] x input value in radians.
  4899. * @return cos(x).
  4900. */
  4901. float32_t arm_cos_f32(
  4902. float32_t x);
  4903. /**
  4904. * @brief Fast approximation to the trigonometric cosine function for Q31 data.
  4905. * @param[in] x Scaled input value in radians.
  4906. * @return cos(x).
  4907. */
  4908. q31_t arm_cos_q31(
  4909. q31_t x);
  4910. /**
  4911. * @brief Fast approximation to the trigonometric cosine function for Q15 data.
  4912. * @param[in] x Scaled input value in radians.
  4913. * @return cos(x).
  4914. */
  4915. q15_t arm_cos_q15(
  4916. q15_t x);
  4917. /**
  4918. * @ingroup groupFastMath
  4919. */
  4920. /**
  4921. * @defgroup SQRT Square Root
  4922. *
  4923. * Computes the square root of a number.
  4924. * There are separate functions for Q15, Q31, and floating-point data types.
  4925. * The square root function is computed using the Newton-Raphson algorithm.
  4926. * This is an iterative algorithm of the form:
  4927. * <pre>
  4928. * x1 = x0 - f(x0)/f'(x0)
  4929. * </pre>
  4930. * where <code>x1</code> is the current estimate,
  4931. * <code>x0</code> is the previous estimate, and
  4932. * <code>f'(x0)</code> is the derivative of <code>f()</code> evaluated at <code>x0</code>.
  4933. * For the square root function, the algorithm reduces to:
  4934. * <pre>
  4935. * x0 = in/2 [initial guess]
  4936. * x1 = 1/2 * ( x0 + in / x0) [each iteration]
  4937. * </pre>
  4938. */
  4939. /**
  4940. * @addtogroup SQRT
  4941. * @{
  4942. */
  4943. /**
  4944. * @brief Floating-point square root function.
  4945. * @param[in] in input value.
  4946. * @param[out] *pOut square root of input value.
  4947. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4948. * <code>in</code> is negative value and returns zero output for negative values.
  4949. */
  4950. static __INLINE arm_status arm_sqrt_f32(
  4951. float32_t in,
  4952. float32_t * pOut)
  4953. {
  4954. if(in > 0)
  4955. {
  4956. // #if __FPU_USED
  4957. #if (__FPU_USED == 1) && defined ( __CC_ARM )
  4958. *pOut = __sqrtf(in);
  4959. #else
  4960. *pOut = sqrtf(in);
  4961. #endif
  4962. return (ARM_MATH_SUCCESS);
  4963. }
  4964. else
  4965. {
  4966. *pOut = 0.0f;
  4967. return (ARM_MATH_ARGUMENT_ERROR);
  4968. }
  4969. }
  4970. /**
  4971. * @brief Q31 square root function.
  4972. * @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF.
  4973. * @param[out] *pOut square root of input value.
  4974. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4975. * <code>in</code> is negative value and returns zero output for negative values.
  4976. */
  4977. arm_status arm_sqrt_q31(
  4978. q31_t in,
  4979. q31_t * pOut);
  4980. /**
  4981. * @brief Q15 square root function.
  4982. * @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF.
  4983. * @param[out] *pOut square root of input value.
  4984. * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if
  4985. * <code>in</code> is negative value and returns zero output for negative values.
  4986. */
  4987. arm_status arm_sqrt_q15(
  4988. q15_t in,
  4989. q15_t * pOut);
  4990. /**
  4991. * @} end of SQRT group
  4992. */
  4993. /**
  4994. * @brief floating-point Circular write function.
  4995. */
  4996. static __INLINE void arm_circularWrite_f32(
  4997. int32_t * circBuffer,
  4998. int32_t L,
  4999. uint16_t * writeOffset,
  5000. int32_t bufferInc,
  5001. const int32_t * src,
  5002. int32_t srcInc,
  5003. uint32_t blockSize)
  5004. {
  5005. uint32_t i = 0u;
  5006. int32_t wOffset;
  5007. /* Copy the value of Index pointer that points
  5008. * to the current location where the input samples to be copied */
  5009. wOffset = *writeOffset;
  5010. /* Loop over the blockSize */
  5011. i = blockSize;
  5012. while(i > 0u)
  5013. {
  5014. /* copy the input sample to the circular buffer */
  5015. circBuffer[wOffset] = *src;
  5016. /* Update the input pointer */
  5017. src += srcInc;
  5018. /* Circularly update wOffset. Watch out for positive and negative value */
  5019. wOffset += bufferInc;
  5020. if(wOffset >= L)
  5021. wOffset -= L;
  5022. /* Decrement the loop counter */
  5023. i--;
  5024. }
  5025. /* Update the index pointer */
  5026. *writeOffset = wOffset;
  5027. }
  5028. /**
  5029. * @brief floating-point Circular Read function.
  5030. */
  5031. static __INLINE void arm_circularRead_f32(
  5032. int32_t * circBuffer,
  5033. int32_t L,
  5034. int32_t * readOffset,
  5035. int32_t bufferInc,
  5036. int32_t * dst,
  5037. int32_t * dst_base,
  5038. int32_t dst_length,
  5039. int32_t dstInc,
  5040. uint32_t blockSize)
  5041. {
  5042. uint32_t i = 0u;
  5043. int32_t rOffset, dst_end;
  5044. /* Copy the value of Index pointer that points
  5045. * to the current location from where the input samples to be read */
  5046. rOffset = *readOffset;
  5047. dst_end = (int32_t) (dst_base + dst_length);
  5048. /* Loop over the blockSize */
  5049. i = blockSize;
  5050. while(i > 0u)
  5051. {
  5052. /* copy the sample from the circular buffer to the destination buffer */
  5053. *dst = circBuffer[rOffset];
  5054. /* Update the input pointer */
  5055. dst += dstInc;
  5056. if(dst == (int32_t *) dst_end)
  5057. {
  5058. dst = dst_base;
  5059. }
  5060. /* Circularly update rOffset. Watch out for positive and negative value */
  5061. rOffset += bufferInc;
  5062. if(rOffset >= L)
  5063. {
  5064. rOffset -= L;
  5065. }
  5066. /* Decrement the loop counter */
  5067. i--;
  5068. }
  5069. /* Update the index pointer */
  5070. *readOffset = rOffset;
  5071. }
  5072. /**
  5073. * @brief Q15 Circular write function.
  5074. */
  5075. static __INLINE void arm_circularWrite_q15(
  5076. q15_t * circBuffer,
  5077. int32_t L,
  5078. uint16_t * writeOffset,
  5079. int32_t bufferInc,
  5080. const q15_t * src,
  5081. int32_t srcInc,
  5082. uint32_t blockSize)
  5083. {
  5084. uint32_t i = 0u;
  5085. int32_t wOffset;
  5086. /* Copy the value of Index pointer that points
  5087. * to the current location where the input samples to be copied */
  5088. wOffset = *writeOffset;
  5089. /* Loop over the blockSize */
  5090. i = blockSize;
  5091. while(i > 0u)
  5092. {
  5093. /* copy the input sample to the circular buffer */
  5094. circBuffer[wOffset] = *src;
  5095. /* Update the input pointer */
  5096. src += srcInc;
  5097. /* Circularly update wOffset. Watch out for positive and negative value */
  5098. wOffset += bufferInc;
  5099. if(wOffset >= L)
  5100. wOffset -= L;
  5101. /* Decrement the loop counter */
  5102. i--;
  5103. }
  5104. /* Update the index pointer */
  5105. *writeOffset = wOffset;
  5106. }
  5107. /**
  5108. * @brief Q15 Circular Read function.
  5109. */
  5110. static __INLINE void arm_circularRead_q15(
  5111. q15_t * circBuffer,
  5112. int32_t L,
  5113. int32_t * readOffset,
  5114. int32_t bufferInc,
  5115. q15_t * dst,
  5116. q15_t * dst_base,
  5117. int32_t dst_length,
  5118. int32_t dstInc,
  5119. uint32_t blockSize)
  5120. {
  5121. uint32_t i = 0;
  5122. int32_t rOffset, dst_end;
  5123. /* Copy the value of Index pointer that points
  5124. * to the current location from where the input samples to be read */
  5125. rOffset = *readOffset;
  5126. dst_end = (int32_t) (dst_base + dst_length);
  5127. /* Loop over the blockSize */
  5128. i = blockSize;
  5129. while(i > 0u)
  5130. {
  5131. /* copy the sample from the circular buffer to the destination buffer */
  5132. *dst = circBuffer[rOffset];
  5133. /* Update the input pointer */
  5134. dst += dstInc;
  5135. if(dst == (q15_t *) dst_end)
  5136. {
  5137. dst = dst_base;
  5138. }
  5139. /* Circularly update wOffset. Watch out for positive and negative value */
  5140. rOffset += bufferInc;
  5141. if(rOffset >= L)
  5142. {
  5143. rOffset -= L;
  5144. }
  5145. /* Decrement the loop counter */
  5146. i--;
  5147. }
  5148. /* Update the index pointer */
  5149. *readOffset = rOffset;
  5150. }
  5151. /**
  5152. * @brief Q7 Circular write function.
  5153. */
  5154. static __INLINE void arm_circularWrite_q7(
  5155. q7_t * circBuffer,
  5156. int32_t L,
  5157. uint16_t * writeOffset,
  5158. int32_t bufferInc,
  5159. const q7_t * src,
  5160. int32_t srcInc,
  5161. uint32_t blockSize)
  5162. {
  5163. uint32_t i = 0u;
  5164. int32_t wOffset;
  5165. /* Copy the value of Index pointer that points
  5166. * to the current location where the input samples to be copied */
  5167. wOffset = *writeOffset;
  5168. /* Loop over the blockSize */
  5169. i = blockSize;
  5170. while(i > 0u)
  5171. {
  5172. /* copy the input sample to the circular buffer */
  5173. circBuffer[wOffset] = *src;
  5174. /* Update the input pointer */
  5175. src += srcInc;
  5176. /* Circularly update wOffset. Watch out for positive and negative value */
  5177. wOffset += bufferInc;
  5178. if(wOffset >= L)
  5179. wOffset -= L;
  5180. /* Decrement the loop counter */
  5181. i--;
  5182. }
  5183. /* Update the index pointer */
  5184. *writeOffset = wOffset;
  5185. }
  5186. /**
  5187. * @brief Q7 Circular Read function.
  5188. */
  5189. static __INLINE void arm_circularRead_q7(
  5190. q7_t * circBuffer,
  5191. int32_t L,
  5192. int32_t * readOffset,
  5193. int32_t bufferInc,
  5194. q7_t * dst,
  5195. q7_t * dst_base,
  5196. int32_t dst_length,
  5197. int32_t dstInc,
  5198. uint32_t blockSize)
  5199. {
  5200. uint32_t i = 0;
  5201. int32_t rOffset, dst_end;
  5202. /* Copy the value of Index pointer that points
  5203. * to the current location from where the input samples to be read */
  5204. rOffset = *readOffset;
  5205. dst_end = (int32_t) (dst_base + dst_length);
  5206. /* Loop over the blockSize */
  5207. i = blockSize;
  5208. while(i > 0u)
  5209. {
  5210. /* copy the sample from the circular buffer to the destination buffer */
  5211. *dst = circBuffer[rOffset];
  5212. /* Update the input pointer */
  5213. dst += dstInc;
  5214. if(dst == (q7_t *) dst_end)
  5215. {
  5216. dst = dst_base;
  5217. }
  5218. /* Circularly update rOffset. Watch out for positive and negative value */
  5219. rOffset += bufferInc;
  5220. if(rOffset >= L)
  5221. {
  5222. rOffset -= L;
  5223. }
  5224. /* Decrement the loop counter */
  5225. i--;
  5226. }
  5227. /* Update the index pointer */
  5228. *readOffset = rOffset;
  5229. }
  5230. /**
  5231. * @brief Sum of the squares of the elements of a Q31 vector.
  5232. * @param[in] *pSrc is input pointer
  5233. * @param[in] blockSize is the number of samples to process
  5234. * @param[out] *pResult is output value.
  5235. * @return none.
  5236. */
  5237. void arm_power_q31(
  5238. q31_t * pSrc,
  5239. uint32_t blockSize,
  5240. q63_t * pResult);
  5241. /**
  5242. * @brief Sum of the squares of the elements of a floating-point vector.
  5243. * @param[in] *pSrc is input pointer
  5244. * @param[in] blockSize is the number of samples to process
  5245. * @param[out] *pResult is output value.
  5246. * @return none.
  5247. */
  5248. void arm_power_f32(
  5249. float32_t * pSrc,
  5250. uint32_t blockSize,
  5251. float32_t * pResult);
  5252. /**
  5253. * @brief Sum of the squares of the elements of a Q15 vector.
  5254. * @param[in] *pSrc is input pointer
  5255. * @param[in] blockSize is the number of samples to process
  5256. * @param[out] *pResult is output value.
  5257. * @return none.
  5258. */
  5259. void arm_power_q15(
  5260. q15_t * pSrc,
  5261. uint32_t blockSize,
  5262. q63_t * pResult);
  5263. /**
  5264. * @brief Sum of the squares of the elements of a Q7 vector.
  5265. * @param[in] *pSrc is input pointer
  5266. * @param[in] blockSize is the number of samples to process
  5267. * @param[out] *pResult is output value.
  5268. * @return none.
  5269. */
  5270. void arm_power_q7(
  5271. q7_t * pSrc,
  5272. uint32_t blockSize,
  5273. q31_t * pResult);
  5274. /**
  5275. * @brief Mean value of a Q7 vector.
  5276. * @param[in] *pSrc is input pointer
  5277. * @param[in] blockSize is the number of samples to process
  5278. * @param[out] *pResult is output value.
  5279. * @return none.
  5280. */
  5281. void arm_mean_q7(
  5282. q7_t * pSrc,
  5283. uint32_t blockSize,
  5284. q7_t * pResult);
  5285. /**
  5286. * @brief Mean value of a Q15 vector.
  5287. * @param[in] *pSrc is input pointer
  5288. * @param[in] blockSize is the number of samples to process
  5289. * @param[out] *pResult is output value.
  5290. * @return none.
  5291. */
  5292. void arm_mean_q15(
  5293. q15_t * pSrc,
  5294. uint32_t blockSize,
  5295. q15_t * pResult);
  5296. /**
  5297. * @brief Mean value of a Q31 vector.
  5298. * @param[in] *pSrc is input pointer
  5299. * @param[in] blockSize is the number of samples to process
  5300. * @param[out] *pResult is output value.
  5301. * @return none.
  5302. */
  5303. void arm_mean_q31(
  5304. q31_t * pSrc,
  5305. uint32_t blockSize,
  5306. q31_t * pResult);
  5307. /**
  5308. * @brief Mean value of a floating-point vector.
  5309. * @param[in] *pSrc is input pointer
  5310. * @param[in] blockSize is the number of samples to process
  5311. * @param[out] *pResult is output value.
  5312. * @return none.
  5313. */
  5314. void arm_mean_f32(
  5315. float32_t * pSrc,
  5316. uint32_t blockSize,
  5317. float32_t * pResult);
  5318. /**
  5319. * @brief Variance of the elements of a floating-point vector.
  5320. * @param[in] *pSrc is input pointer
  5321. * @param[in] blockSize is the number of samples to process
  5322. * @param[out] *pResult is output value.
  5323. * @return none.
  5324. */
  5325. void arm_var_f32(
  5326. float32_t * pSrc,
  5327. uint32_t blockSize,
  5328. float32_t * pResult);
  5329. /**
  5330. * @brief Variance of the elements of a Q31 vector.
  5331. * @param[in] *pSrc is input pointer
  5332. * @param[in] blockSize is the number of samples to process
  5333. * @param[out] *pResult is output value.
  5334. * @return none.
  5335. */
  5336. void arm_var_q31(
  5337. q31_t * pSrc,
  5338. uint32_t blockSize,
  5339. q63_t * pResult);
  5340. /**
  5341. * @brief Variance of the elements of a Q15 vector.
  5342. * @param[in] *pSrc is input pointer
  5343. * @param[in] blockSize is the number of samples to process
  5344. * @param[out] *pResult is output value.
  5345. * @return none.
  5346. */
  5347. void arm_var_q15(
  5348. q15_t * pSrc,
  5349. uint32_t blockSize,
  5350. q31_t * pResult);
  5351. /**
  5352. * @brief Root Mean Square of the elements of a floating-point vector.
  5353. * @param[in] *pSrc is input pointer
  5354. * @param[in] blockSize is the number of samples to process
  5355. * @param[out] *pResult is output value.
  5356. * @return none.
  5357. */
  5358. void arm_rms_f32(
  5359. float32_t * pSrc,
  5360. uint32_t blockSize,
  5361. float32_t * pResult);
  5362. /**
  5363. * @brief Root Mean Square of the elements of a Q31 vector.
  5364. * @param[in] *pSrc is input pointer
  5365. * @param[in] blockSize is the number of samples to process
  5366. * @param[out] *pResult is output value.
  5367. * @return none.
  5368. */
  5369. void arm_rms_q31(
  5370. q31_t * pSrc,
  5371. uint32_t blockSize,
  5372. q31_t * pResult);
  5373. /**
  5374. * @brief Root Mean Square of the elements of a Q15 vector.
  5375. * @param[in] *pSrc is input pointer
  5376. * @param[in] blockSize is the number of samples to process
  5377. * @param[out] *pResult is output value.
  5378. * @return none.
  5379. */
  5380. void arm_rms_q15(
  5381. q15_t * pSrc,
  5382. uint32_t blockSize,
  5383. q15_t * pResult);
  5384. /**
  5385. * @brief Standard deviation of the elements of a floating-point vector.
  5386. * @param[in] *pSrc is input pointer
  5387. * @param[in] blockSize is the number of samples to process
  5388. * @param[out] *pResult is output value.
  5389. * @return none.
  5390. */
  5391. void arm_std_f32(
  5392. float32_t * pSrc,
  5393. uint32_t blockSize,
  5394. float32_t * pResult);
  5395. /**
  5396. * @brief Standard deviation of the elements of a Q31 vector.
  5397. * @param[in] *pSrc is input pointer
  5398. * @param[in] blockSize is the number of samples to process
  5399. * @param[out] *pResult is output value.
  5400. * @return none.
  5401. */
  5402. void arm_std_q31(
  5403. q31_t * pSrc,
  5404. uint32_t blockSize,
  5405. q31_t * pResult);
  5406. /**
  5407. * @brief Standard deviation of the elements of a Q15 vector.
  5408. * @param[in] *pSrc is input pointer
  5409. * @param[in] blockSize is the number of samples to process
  5410. * @param[out] *pResult is output value.
  5411. * @return none.
  5412. */
  5413. void arm_std_q15(
  5414. q15_t * pSrc,
  5415. uint32_t blockSize,
  5416. q15_t * pResult);
  5417. /**
  5418. * @brief Floating-point complex magnitude
  5419. * @param[in] *pSrc points to the complex input vector
  5420. * @param[out] *pDst points to the real output vector
  5421. * @param[in] numSamples number of complex samples in the input vector
  5422. * @return none.
  5423. */
  5424. void arm_cmplx_mag_f32(
  5425. float32_t * pSrc,
  5426. float32_t * pDst,
  5427. uint32_t numSamples);
  5428. /**
  5429. * @brief Q31 complex magnitude
  5430. * @param[in] *pSrc points to the complex input vector
  5431. * @param[out] *pDst points to the real output vector
  5432. * @param[in] numSamples number of complex samples in the input vector
  5433. * @return none.
  5434. */
  5435. void arm_cmplx_mag_q31(
  5436. q31_t * pSrc,
  5437. q31_t * pDst,
  5438. uint32_t numSamples);
  5439. /**
  5440. * @brief Q15 complex magnitude
  5441. * @param[in] *pSrc points to the complex input vector
  5442. * @param[out] *pDst points to the real output vector
  5443. * @param[in] numSamples number of complex samples in the input vector
  5444. * @return none.
  5445. */
  5446. void arm_cmplx_mag_q15(
  5447. q15_t * pSrc,
  5448. q15_t * pDst,
  5449. uint32_t numSamples);
  5450. /**
  5451. * @brief Q15 complex dot product
  5452. * @param[in] *pSrcA points to the first input vector
  5453. * @param[in] *pSrcB points to the second input vector
  5454. * @param[in] numSamples number of complex samples in each vector
  5455. * @param[out] *realResult real part of the result returned here
  5456. * @param[out] *imagResult imaginary part of the result returned here
  5457. * @return none.
  5458. */
  5459. void arm_cmplx_dot_prod_q15(
  5460. q15_t * pSrcA,
  5461. q15_t * pSrcB,
  5462. uint32_t numSamples,
  5463. q31_t * realResult,
  5464. q31_t * imagResult);
  5465. /**
  5466. * @brief Q31 complex dot product
  5467. * @param[in] *pSrcA points to the first input vector
  5468. * @param[in] *pSrcB points to the second input vector
  5469. * @param[in] numSamples number of complex samples in each vector
  5470. * @param[out] *realResult real part of the result returned here
  5471. * @param[out] *imagResult imaginary part of the result returned here
  5472. * @return none.
  5473. */
  5474. void arm_cmplx_dot_prod_q31(
  5475. q31_t * pSrcA,
  5476. q31_t * pSrcB,
  5477. uint32_t numSamples,
  5478. q63_t * realResult,
  5479. q63_t * imagResult);
  5480. /**
  5481. * @brief Floating-point complex dot product
  5482. * @param[in] *pSrcA points to the first input vector
  5483. * @param[in] *pSrcB points to the second input vector
  5484. * @param[in] numSamples number of complex samples in each vector
  5485. * @param[out] *realResult real part of the result returned here
  5486. * @param[out] *imagResult imaginary part of the result returned here
  5487. * @return none.
  5488. */
  5489. void arm_cmplx_dot_prod_f32(
  5490. float32_t * pSrcA,
  5491. float32_t * pSrcB,
  5492. uint32_t numSamples,
  5493. float32_t * realResult,
  5494. float32_t * imagResult);
  5495. /**
  5496. * @brief Q15 complex-by-real multiplication
  5497. * @param[in] *pSrcCmplx points to the complex input vector
  5498. * @param[in] *pSrcReal points to the real input vector
  5499. * @param[out] *pCmplxDst points to the complex output vector
  5500. * @param[in] numSamples number of samples in each vector
  5501. * @return none.
  5502. */
  5503. void arm_cmplx_mult_real_q15(
  5504. q15_t * pSrcCmplx,
  5505. q15_t * pSrcReal,
  5506. q15_t * pCmplxDst,
  5507. uint32_t numSamples);
  5508. /**
  5509. * @brief Q31 complex-by-real multiplication
  5510. * @param[in] *pSrcCmplx points to the complex input vector
  5511. * @param[in] *pSrcReal points to the real input vector
  5512. * @param[out] *pCmplxDst points to the complex output vector
  5513. * @param[in] numSamples number of samples in each vector
  5514. * @return none.
  5515. */
  5516. void arm_cmplx_mult_real_q31(
  5517. q31_t * pSrcCmplx,
  5518. q31_t * pSrcReal,
  5519. q31_t * pCmplxDst,
  5520. uint32_t numSamples);
  5521. /**
  5522. * @brief Floating-point complex-by-real multiplication
  5523. * @param[in] *pSrcCmplx points to the complex input vector
  5524. * @param[in] *pSrcReal points to the real input vector
  5525. * @param[out] *pCmplxDst points to the complex output vector
  5526. * @param[in] numSamples number of samples in each vector
  5527. * @return none.
  5528. */
  5529. void arm_cmplx_mult_real_f32(
  5530. float32_t * pSrcCmplx,
  5531. float32_t * pSrcReal,
  5532. float32_t * pCmplxDst,
  5533. uint32_t numSamples);
  5534. /**
  5535. * @brief Minimum value of a Q7 vector.
  5536. * @param[in] *pSrc is input pointer
  5537. * @param[in] blockSize is the number of samples to process
  5538. * @param[out] *result is output pointer
  5539. * @param[in] index is the array index of the minimum value in the input buffer.
  5540. * @return none.
  5541. */
  5542. void arm_min_q7(
  5543. q7_t * pSrc,
  5544. uint32_t blockSize,
  5545. q7_t * result,
  5546. uint32_t * index);
  5547. /**
  5548. * @brief Minimum value of a Q15 vector.
  5549. * @param[in] *pSrc is input pointer
  5550. * @param[in] blockSize is the number of samples to process
  5551. * @param[out] *pResult is output pointer
  5552. * @param[in] *pIndex is the array index of the minimum value in the input buffer.
  5553. * @return none.
  5554. */
  5555. void arm_min_q15(
  5556. q15_t * pSrc,
  5557. uint32_t blockSize,
  5558. q15_t * pResult,
  5559. uint32_t * pIndex);
  5560. /**
  5561. * @brief Minimum value of a Q31 vector.
  5562. * @param[in] *pSrc is input pointer
  5563. * @param[in] blockSize is the number of samples to process
  5564. * @param[out] *pResult is output pointer
  5565. * @param[out] *pIndex is the array index of the minimum value in the input buffer.
  5566. * @return none.
  5567. */
  5568. void arm_min_q31(
  5569. q31_t * pSrc,
  5570. uint32_t blockSize,
  5571. q31_t * pResult,
  5572. uint32_t * pIndex);
  5573. /**
  5574. * @brief Minimum value of a floating-point vector.
  5575. * @param[in] *pSrc is input pointer
  5576. * @param[in] blockSize is the number of samples to process
  5577. * @param[out] *pResult is output pointer
  5578. * @param[out] *pIndex is the array index of the minimum value in the input buffer.
  5579. * @return none.
  5580. */
  5581. void arm_min_f32(
  5582. float32_t * pSrc,
  5583. uint32_t blockSize,
  5584. float32_t * pResult,
  5585. uint32_t * pIndex);
  5586. /**
  5587. * @brief Maximum value of a Q7 vector.
  5588. * @param[in] *pSrc points to the input buffer
  5589. * @param[in] blockSize length of the input vector
  5590. * @param[out] *pResult maximum value returned here
  5591. * @param[out] *pIndex index of maximum value returned here
  5592. * @return none.
  5593. */
  5594. void arm_max_q7(
  5595. q7_t * pSrc,
  5596. uint32_t blockSize,
  5597. q7_t * pResult,
  5598. uint32_t * pIndex);
  5599. /**
  5600. * @brief Maximum value of a Q15 vector.
  5601. * @param[in] *pSrc points to the input buffer
  5602. * @param[in] blockSize length of the input vector
  5603. * @param[out] *pResult maximum value returned here
  5604. * @param[out] *pIndex index of maximum value returned here
  5605. * @return none.
  5606. */
  5607. void arm_max_q15(
  5608. q15_t * pSrc,
  5609. uint32_t blockSize,
  5610. q15_t * pResult,
  5611. uint32_t * pIndex);
  5612. /**
  5613. * @brief Maximum value of a Q31 vector.
  5614. * @param[in] *pSrc points to the input buffer
  5615. * @param[in] blockSize length of the input vector
  5616. * @param[out] *pResult maximum value returned here
  5617. * @param[out] *pIndex index of maximum value returned here
  5618. * @return none.
  5619. */
  5620. void arm_max_q31(
  5621. q31_t * pSrc,
  5622. uint32_t blockSize,
  5623. q31_t * pResult,
  5624. uint32_t * pIndex);
  5625. /**
  5626. * @brief Maximum value of a floating-point vector.
  5627. * @param[in] *pSrc points to the input buffer
  5628. * @param[in] blockSize length of the input vector
  5629. * @param[out] *pResult maximum value returned here
  5630. * @param[out] *pIndex index of maximum value returned here
  5631. * @return none.
  5632. */
  5633. void arm_max_f32(
  5634. float32_t * pSrc,
  5635. uint32_t blockSize,
  5636. float32_t * pResult,
  5637. uint32_t * pIndex);
  5638. /**
  5639. * @brief Q15 complex-by-complex multiplication
  5640. * @param[in] *pSrcA points to the first input vector
  5641. * @param[in] *pSrcB points to the second input vector
  5642. * @param[out] *pDst points to the output vector
  5643. * @param[in] numSamples number of complex samples in each vector
  5644. * @return none.
  5645. */
  5646. void arm_cmplx_mult_cmplx_q15(
  5647. q15_t * pSrcA,
  5648. q15_t * pSrcB,
  5649. q15_t * pDst,
  5650. uint32_t numSamples);
  5651. /**
  5652. * @brief Q31 complex-by-complex multiplication
  5653. * @param[in] *pSrcA points to the first input vector
  5654. * @param[in] *pSrcB points to the second input vector
  5655. * @param[out] *pDst points to the output vector
  5656. * @param[in] numSamples number of complex samples in each vector
  5657. * @return none.
  5658. */
  5659. void arm_cmplx_mult_cmplx_q31(
  5660. q31_t * pSrcA,
  5661. q31_t * pSrcB,
  5662. q31_t * pDst,
  5663. uint32_t numSamples);
  5664. /**
  5665. * @brief Floating-point complex-by-complex multiplication
  5666. * @param[in] *pSrcA points to the first input vector
  5667. * @param[in] *pSrcB points to the second input vector
  5668. * @param[out] *pDst points to the output vector
  5669. * @param[in] numSamples number of complex samples in each vector
  5670. * @return none.
  5671. */
  5672. void arm_cmplx_mult_cmplx_f32(
  5673. float32_t * pSrcA,
  5674. float32_t * pSrcB,
  5675. float32_t * pDst,
  5676. uint32_t numSamples);
  5677. /**
  5678. * @brief Converts the elements of the floating-point vector to Q31 vector.
  5679. * @param[in] *pSrc points to the floating-point input vector
  5680. * @param[out] *pDst points to the Q31 output vector
  5681. * @param[in] blockSize length of the input vector
  5682. * @return none.
  5683. */
  5684. void arm_float_to_q31(
  5685. float32_t * pSrc,
  5686. q31_t * pDst,
  5687. uint32_t blockSize);
  5688. /**
  5689. * @brief Converts the elements of the floating-point vector to Q15 vector.
  5690. * @param[in] *pSrc points to the floating-point input vector
  5691. * @param[out] *pDst points to the Q15 output vector
  5692. * @param[in] blockSize length of the input vector
  5693. * @return none
  5694. */
  5695. void arm_float_to_q15(
  5696. float32_t * pSrc,
  5697. q15_t * pDst,
  5698. uint32_t blockSize);
  5699. /**
  5700. * @brief Converts the elements of the floating-point vector to Q7 vector.
  5701. * @param[in] *pSrc points to the floating-point input vector
  5702. * @param[out] *pDst points to the Q7 output vector
  5703. * @param[in] blockSize length of the input vector
  5704. * @return none
  5705. */
  5706. void arm_float_to_q7(
  5707. float32_t * pSrc,
  5708. q7_t * pDst,
  5709. uint32_t blockSize);
  5710. /**
  5711. * @brief Converts the elements of the Q31 vector to Q15 vector.
  5712. * @param[in] *pSrc is input pointer
  5713. * @param[out] *pDst is output pointer
  5714. * @param[in] blockSize is the number of samples to process
  5715. * @return none.
  5716. */
  5717. void arm_q31_to_q15(
  5718. q31_t * pSrc,
  5719. q15_t * pDst,
  5720. uint32_t blockSize);
  5721. /**
  5722. * @brief Converts the elements of the Q31 vector to Q7 vector.
  5723. * @param[in] *pSrc is input pointer
  5724. * @param[out] *pDst is output pointer
  5725. * @param[in] blockSize is the number of samples to process
  5726. * @return none.
  5727. */
  5728. void arm_q31_to_q7(
  5729. q31_t * pSrc,
  5730. q7_t * pDst,
  5731. uint32_t blockSize);
  5732. /**
  5733. * @brief Converts the elements of the Q15 vector to floating-point vector.
  5734. * @param[in] *pSrc is input pointer
  5735. * @param[out] *pDst is output pointer
  5736. * @param[in] blockSize is the number of samples to process
  5737. * @return none.
  5738. */
  5739. void arm_q15_to_float(
  5740. q15_t * pSrc,
  5741. float32_t * pDst,
  5742. uint32_t blockSize);
  5743. /**
  5744. * @brief Converts the elements of the Q15 vector to Q31 vector.
  5745. * @param[in] *pSrc is input pointer
  5746. * @param[out] *pDst is output pointer
  5747. * @param[in] blockSize is the number of samples to process
  5748. * @return none.
  5749. */
  5750. void arm_q15_to_q31(
  5751. q15_t * pSrc,
  5752. q31_t * pDst,
  5753. uint32_t blockSize);
  5754. /**
  5755. * @brief Converts the elements of the Q15 vector to Q7 vector.
  5756. * @param[in] *pSrc is input pointer
  5757. * @param[out] *pDst is output pointer
  5758. * @param[in] blockSize is the number of samples to process
  5759. * @return none.
  5760. */
  5761. void arm_q15_to_q7(
  5762. q15_t * pSrc,
  5763. q7_t * pDst,
  5764. uint32_t blockSize);
  5765. /**
  5766. * @ingroup groupInterpolation
  5767. */
  5768. /**
  5769. * @defgroup BilinearInterpolate Bilinear Interpolation
  5770. *
  5771. * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid.
  5772. * The underlying function <code>f(x, y)</code> is sampled on a regular grid and the interpolation process
  5773. * determines values between the grid points.
  5774. * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension.
  5775. * Bilinear interpolation is often used in image processing to rescale images.
  5776. * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types.
  5777. *
  5778. * <b>Algorithm</b>
  5779. * \par
  5780. * The instance structure used by the bilinear interpolation functions describes a two dimensional data table.
  5781. * For floating-point, the instance structure is defined as:
  5782. * <pre>
  5783. * typedef struct
  5784. * {
  5785. * uint16_t numRows;
  5786. * uint16_t numCols;
  5787. * float32_t *pData;
  5788. * } arm_bilinear_interp_instance_f32;
  5789. * </pre>
  5790. *
  5791. * \par
  5792. * where <code>numRows</code> specifies the number of rows in the table;
  5793. * <code>numCols</code> specifies the number of columns in the table;
  5794. * and <code>pData</code> points to an array of size <code>numRows*numCols</code> values.
  5795. * The data table <code>pTable</code> is organized in row order and the supplied data values fall on integer indexes.
  5796. * That is, table element (x,y) is located at <code>pTable[x + y*numCols]</code> where x and y are integers.
  5797. *
  5798. * \par
  5799. * Let <code>(x, y)</code> specify the desired interpolation point. Then define:
  5800. * <pre>
  5801. * XF = floor(x)
  5802. * YF = floor(y)
  5803. * </pre>
  5804. * \par
  5805. * The interpolated output point is computed as:
  5806. * <pre>
  5807. * f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
  5808. * + f(XF+1, YF) * (x-XF)*(1-(y-YF))
  5809. * + f(XF, YF+1) * (1-(x-XF))*(y-YF)
  5810. * + f(XF+1, YF+1) * (x-XF)*(y-YF)
  5811. * </pre>
  5812. * Note that the coordinates (x, y) contain integer and fractional components.
  5813. * The integer components specify which portion of the table to use while the
  5814. * fractional components control the interpolation processor.
  5815. *
  5816. * \par
  5817. * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output.
  5818. */
  5819. /**
  5820. * @addtogroup BilinearInterpolate
  5821. * @{
  5822. */
  5823. /**
  5824. *
  5825. * @brief Floating-point bilinear interpolation.
  5826. * @param[in,out] *S points to an instance of the interpolation structure.
  5827. * @param[in] X interpolation coordinate.
  5828. * @param[in] Y interpolation coordinate.
  5829. * @return out interpolated value.
  5830. */
  5831. static __INLINE float32_t arm_bilinear_interp_f32(
  5832. const arm_bilinear_interp_instance_f32 * S,
  5833. float32_t X,
  5834. float32_t Y)
  5835. {
  5836. float32_t out;
  5837. float32_t f00, f01, f10, f11;
  5838. float32_t *pData = S->pData;
  5839. int32_t xIndex, yIndex, index;
  5840. float32_t xdiff, ydiff;
  5841. float32_t b1, b2, b3, b4;
  5842. xIndex = (int32_t) X;
  5843. yIndex = (int32_t) Y;
  5844. /* Care taken for table outside boundary */
  5845. /* Returns zero output when values are outside table boundary */
  5846. if(xIndex < 0 || xIndex > (S->numRows - 1) || yIndex < 0
  5847. || yIndex > (S->numCols - 1))
  5848. {
  5849. return (0);
  5850. }
  5851. /* Calculation of index for two nearest points in X-direction */
  5852. index = (xIndex - 1) + (yIndex - 1) * S->numCols;
  5853. /* Read two nearest points in X-direction */
  5854. f00 = pData[index];
  5855. f01 = pData[index + 1];
  5856. /* Calculation of index for two nearest points in Y-direction */
  5857. index = (xIndex - 1) + (yIndex) * S->numCols;
  5858. /* Read two nearest points in Y-direction */
  5859. f10 = pData[index];
  5860. f11 = pData[index + 1];
  5861. /* Calculation of intermediate values */
  5862. b1 = f00;
  5863. b2 = f01 - f00;
  5864. b3 = f10 - f00;
  5865. b4 = f00 - f01 - f10 + f11;
  5866. /* Calculation of fractional part in X */
  5867. xdiff = X - xIndex;
  5868. /* Calculation of fractional part in Y */
  5869. ydiff = Y - yIndex;
  5870. /* Calculation of bi-linear interpolated output */
  5871. out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff;
  5872. /* return to application */
  5873. return (out);
  5874. }
  5875. /**
  5876. *
  5877. * @brief Q31 bilinear interpolation.
  5878. * @param[in,out] *S points to an instance of the interpolation structure.
  5879. * @param[in] X interpolation coordinate in 12.20 format.
  5880. * @param[in] Y interpolation coordinate in 12.20 format.
  5881. * @return out interpolated value.
  5882. */
  5883. static __INLINE q31_t arm_bilinear_interp_q31(
  5884. arm_bilinear_interp_instance_q31 * S,
  5885. q31_t X,
  5886. q31_t Y)
  5887. {
  5888. q31_t out; /* Temporary output */
  5889. q31_t acc = 0; /* output */
  5890. q31_t xfract, yfract; /* X, Y fractional parts */
  5891. q31_t x1, x2, y1, y2; /* Nearest output values */
  5892. int32_t rI, cI; /* Row and column indices */
  5893. q31_t *pYData = S->pData; /* pointer to output table values */
  5894. uint32_t nCols = S->numCols; /* num of rows */
  5895. /* Input is in 12.20 format */
  5896. /* 12 bits for the table index */
  5897. /* Index value calculation */
  5898. rI = ((X & 0xFFF00000) >> 20u);
  5899. /* Input is in 12.20 format */
  5900. /* 12 bits for the table index */
  5901. /* Index value calculation */
  5902. cI = ((Y & 0xFFF00000) >> 20u);
  5903. /* Care taken for table outside boundary */
  5904. /* Returns zero output when values are outside table boundary */
  5905. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5906. {
  5907. return (0);
  5908. }
  5909. /* 20 bits for the fractional part */
  5910. /* shift left xfract by 11 to keep 1.31 format */
  5911. xfract = (X & 0x000FFFFF) << 11u;
  5912. /* Read two nearest output values from the index */
  5913. x1 = pYData[(rI) + nCols * (cI)];
  5914. x2 = pYData[(rI) + nCols * (cI) + 1u];
  5915. /* 20 bits for the fractional part */
  5916. /* shift left yfract by 11 to keep 1.31 format */
  5917. yfract = (Y & 0x000FFFFF) << 11u;
  5918. /* Read two nearest output values from the index */
  5919. y1 = pYData[(rI) + nCols * (cI + 1)];
  5920. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  5921. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */
  5922. out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32));
  5923. acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32));
  5924. /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */
  5925. out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32));
  5926. acc += ((q31_t) ((q63_t) out * (xfract) >> 32));
  5927. /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */
  5928. out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32));
  5929. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  5930. /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */
  5931. out = ((q31_t) ((q63_t) y2 * (xfract) >> 32));
  5932. acc += ((q31_t) ((q63_t) out * (yfract) >> 32));
  5933. /* Convert acc to 1.31(q31) format */
  5934. return (acc << 2u);
  5935. }
  5936. /**
  5937. * @brief Q15 bilinear interpolation.
  5938. * @param[in,out] *S points to an instance of the interpolation structure.
  5939. * @param[in] X interpolation coordinate in 12.20 format.
  5940. * @param[in] Y interpolation coordinate in 12.20 format.
  5941. * @return out interpolated value.
  5942. */
  5943. static __INLINE q15_t arm_bilinear_interp_q15(
  5944. arm_bilinear_interp_instance_q15 * S,
  5945. q31_t X,
  5946. q31_t Y)
  5947. {
  5948. q63_t acc = 0; /* output */
  5949. q31_t out; /* Temporary output */
  5950. q15_t x1, x2, y1, y2; /* Nearest output values */
  5951. q31_t xfract, yfract; /* X, Y fractional parts */
  5952. int32_t rI, cI; /* Row and column indices */
  5953. q15_t *pYData = S->pData; /* pointer to output table values */
  5954. uint32_t nCols = S->numCols; /* num of rows */
  5955. /* Input is in 12.20 format */
  5956. /* 12 bits for the table index */
  5957. /* Index value calculation */
  5958. rI = ((X & 0xFFF00000) >> 20);
  5959. /* Input is in 12.20 format */
  5960. /* 12 bits for the table index */
  5961. /* Index value calculation */
  5962. cI = ((Y & 0xFFF00000) >> 20);
  5963. /* Care taken for table outside boundary */
  5964. /* Returns zero output when values are outside table boundary */
  5965. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  5966. {
  5967. return (0);
  5968. }
  5969. /* 20 bits for the fractional part */
  5970. /* xfract should be in 12.20 format */
  5971. xfract = (X & 0x000FFFFF);
  5972. /* Read two nearest output values from the index */
  5973. x1 = pYData[(rI) + nCols * (cI)];
  5974. x2 = pYData[(rI) + nCols * (cI) + 1u];
  5975. /* 20 bits for the fractional part */
  5976. /* yfract should be in 12.20 format */
  5977. yfract = (Y & 0x000FFFFF);
  5978. /* Read two nearest output values from the index */
  5979. y1 = pYData[(rI) + nCols * (cI + 1)];
  5980. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  5981. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */
  5982. /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */
  5983. /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */
  5984. out = (q31_t) (((q63_t) x1 * (0xFFFFF - xfract)) >> 4u);
  5985. acc = ((q63_t) out * (0xFFFFF - yfract));
  5986. /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */
  5987. out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u);
  5988. acc += ((q63_t) out * (xfract));
  5989. /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */
  5990. out = (q31_t) (((q63_t) y1 * (0xFFFFF - xfract)) >> 4u);
  5991. acc += ((q63_t) out * (yfract));
  5992. /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */
  5993. out = (q31_t) (((q63_t) y2 * (xfract)) >> 4u);
  5994. acc += ((q63_t) out * (yfract));
  5995. /* acc is in 13.51 format and down shift acc by 36 times */
  5996. /* Convert out to 1.15 format */
  5997. return (acc >> 36);
  5998. }
  5999. /**
  6000. * @brief Q7 bilinear interpolation.
  6001. * @param[in,out] *S points to an instance of the interpolation structure.
  6002. * @param[in] X interpolation coordinate in 12.20 format.
  6003. * @param[in] Y interpolation coordinate in 12.20 format.
  6004. * @return out interpolated value.
  6005. */
  6006. static __INLINE q7_t arm_bilinear_interp_q7(
  6007. arm_bilinear_interp_instance_q7 * S,
  6008. q31_t X,
  6009. q31_t Y)
  6010. {
  6011. q63_t acc = 0; /* output */
  6012. q31_t out; /* Temporary output */
  6013. q31_t xfract, yfract; /* X, Y fractional parts */
  6014. q7_t x1, x2, y1, y2; /* Nearest output values */
  6015. int32_t rI, cI; /* Row and column indices */
  6016. q7_t *pYData = S->pData; /* pointer to output table values */
  6017. uint32_t nCols = S->numCols; /* num of rows */
  6018. /* Input is in 12.20 format */
  6019. /* 12 bits for the table index */
  6020. /* Index value calculation */
  6021. rI = ((X & 0xFFF00000) >> 20);
  6022. /* Input is in 12.20 format */
  6023. /* 12 bits for the table index */
  6024. /* Index value calculation */
  6025. cI = ((Y & 0xFFF00000) >> 20);
  6026. /* Care taken for table outside boundary */
  6027. /* Returns zero output when values are outside table boundary */
  6028. if(rI < 0 || rI > (S->numRows - 1) || cI < 0 || cI > (S->numCols - 1))
  6029. {
  6030. return (0);
  6031. }
  6032. /* 20 bits for the fractional part */
  6033. /* xfract should be in 12.20 format */
  6034. xfract = (X & 0x000FFFFF);
  6035. /* Read two nearest output values from the index */
  6036. x1 = pYData[(rI) + nCols * (cI)];
  6037. x2 = pYData[(rI) + nCols * (cI) + 1u];
  6038. /* 20 bits for the fractional part */
  6039. /* yfract should be in 12.20 format */
  6040. yfract = (Y & 0x000FFFFF);
  6041. /* Read two nearest output values from the index */
  6042. y1 = pYData[(rI) + nCols * (cI + 1)];
  6043. y2 = pYData[(rI) + nCols * (cI + 1) + 1u];
  6044. /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */
  6045. out = ((x1 * (0xFFFFF - xfract)));
  6046. acc = (((q63_t) out * (0xFFFFF - yfract)));
  6047. /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */
  6048. out = ((x2 * (0xFFFFF - yfract)));
  6049. acc += (((q63_t) out * (xfract)));
  6050. /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */
  6051. out = ((y1 * (0xFFFFF - xfract)));
  6052. acc += (((q63_t) out * (yfract)));
  6053. /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */
  6054. out = ((y2 * (yfract)));
  6055. acc += (((q63_t) out * (xfract)));
  6056. /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */
  6057. return (acc >> 40);
  6058. }
  6059. /**
  6060. * @} end of BilinearInterpolate group
  6061. */
  6062. #if defined ( __CC_ARM ) //Keil
  6063. //SMMLAR
  6064. #define multAcc_32x32_keep32_R(a, x, y) \
  6065. a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6066. //SMMLSR
  6067. #define multSub_32x32_keep32_R(a, x, y) \
  6068. a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32)
  6069. //SMMULR
  6070. #define mult_32x32_keep32_R(a, x, y) \
  6071. a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32)
  6072. //Enter low optimization region - place directly above function definition
  6073. #define LOW_OPTIMIZATION_ENTER \
  6074. _Pragma ("push") \
  6075. _Pragma ("O1")
  6076. //Exit low optimization region - place directly after end of function definition
  6077. #define LOW_OPTIMIZATION_EXIT \
  6078. _Pragma ("pop")
  6079. //Enter low optimization region - place directly above function definition
  6080. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6081. //Exit low optimization region - place directly after end of function definition
  6082. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6083. #elif defined(__ICCARM__) //IAR
  6084. //SMMLA
  6085. #define multAcc_32x32_keep32_R(a, x, y) \
  6086. a += (q31_t) (((q63_t) x * y) >> 32)
  6087. //SMMLS
  6088. #define multSub_32x32_keep32_R(a, x, y) \
  6089. a -= (q31_t) (((q63_t) x * y) >> 32)
  6090. //SMMUL
  6091. #define mult_32x32_keep32_R(a, x, y) \
  6092. a = (q31_t) (((q63_t) x * y ) >> 32)
  6093. //Enter low optimization region - place directly above function definition
  6094. #define LOW_OPTIMIZATION_ENTER \
  6095. _Pragma ("optimize=low")
  6096. //Exit low optimization region - place directly after end of function definition
  6097. #define LOW_OPTIMIZATION_EXIT
  6098. //Enter low optimization region - place directly above function definition
  6099. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \
  6100. _Pragma ("optimize=low")
  6101. //Exit low optimization region - place directly after end of function definition
  6102. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6103. #elif defined(__GNUC__)
  6104. //SMMLA
  6105. #define multAcc_32x32_keep32_R(a, x, y) \
  6106. a += (q31_t) (((q63_t) x * y) >> 32)
  6107. //SMMLS
  6108. #define multSub_32x32_keep32_R(a, x, y) \
  6109. a -= (q31_t) (((q63_t) x * y) >> 32)
  6110. //SMMUL
  6111. #define mult_32x32_keep32_R(a, x, y) \
  6112. a = (q31_t) (((q63_t) x * y ) >> 32)
  6113. #define LOW_OPTIMIZATION_ENTER __attribute__(( optimize("-O1") ))
  6114. #define LOW_OPTIMIZATION_EXIT
  6115. #define IAR_ONLY_LOW_OPTIMIZATION_ENTER
  6116. #define IAR_ONLY_LOW_OPTIMIZATION_EXIT
  6117. #endif
  6118. #ifdef __cplusplus
  6119. }
  6120. #endif
  6121. #endif /* _ARM_MATH_H */
  6122. /**
  6123. *
  6124. * End of file.
  6125. */