arm_math.h 241 KB

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