1
0

arm_math.h 230 KB

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