arm_math.h 241 KB

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