Keyboard firmwares for Atmel AVR and Cortex-M
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.

arm_math.h 230KB

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