arm_math.h 242 KB

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