arm_math.h 249 KB

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