arm_math.h 238 KB

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