Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

arm_math.h 242KB

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