My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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