arm_math.h 241 KB

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