arm_math.h 239 KB

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