arm_math.h 238 KB

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