arm_math.h 241 KB

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