arm_math.h 241 KB

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