Naze32 clone with Frysky receiver
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

arm_math.h 239KB

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