arm_math.h 250 KB

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