| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466 |
- /**
- ******************************************************************************
- * @file stm32f3xx_hal_hrtim.c
- * @author MCD Application Team
- * @brief TIM HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the High Resolution Timer (HRTIM) peripheral:
- * + HRTIM Initialization
- * + DLL Calibration Start
- * + Timer Time Base Unit Configuration
- * + Simple Time Base Start/Stop
- * + Simple Time Base Start/Stop Interrupt
- * + Simple Time Base Start/Stop DMA Request
- * + Simple Output Compare/PWM Channel Configuration
- * + Simple Output Compare/PWM Channel Start/Stop Interrupt
- * + Simple Output Compare/PWM Channel Start/Stop DMA Request
- * + Simple Input Capture Channel Configuration
- * + Simple Input Capture Channel Start/Stop Interrupt
- * + Simple Input Capture Channel Start/Stop DMA Request
- * + Simple One Pulse Channel Configuration
- * + Simple One Pulse Channel Start/Stop Interrupt
- * + HRTIM External Synchronization Configuration
- * + HRTIM Burst Mode Controller Configuration
- * + HRTIM Burst Mode Controller Enabling
- * + HRTIM External Events Conditioning Configuration
- * + HRTIM Faults Conditioning Configuration
- * + HRTIM Faults Enabling
- * + HRTIM ADC trigger Configuration
- * + Waveform Timer Configuration
- * + Waveform Event Filtering Configuration
- * + Waveform Dead Time Insertion Configuration
- * + Waveform Chopper Mode Configuration
- * + Waveform Compare Unit Configuration
- * + Waveform Capture Unit Configuration
- * + Waveform Output Configuration
- * + Waveform Counter Start/Stop
- * + Waveform Counter Start/Stop Interrupt
- * + Waveform Counter Start/Stop DMA Request
- * + Waveform Output Enabling
- * + Waveform Output Level Set/Get
- * + Waveform Output State Get
- * + Waveform Burst DMA Operation Configuration
- * + Waveform Burst DMA Operation Start
- * + Waveform Timer Counter Software Reset
- * + Waveform Capture Software Trigger
- * + Waveform Burst Mode Controller Software Trigger
- * + Waveform Timer Pre-loadable Registers Update Enabling
- * + Waveform Timer Pre-loadable Registers Software Update
- * + Waveform Timer Delayed Protection Status Get
- * + Waveform Timer Burst Status Get
- * + Waveform Timer Push-Pull Status Get
- * + Peripheral State Get
- *
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- @verbatim
- ==============================================================================
- ##### Simple mode v.s. waveform mode #####
- ==============================================================================
- [..] The HRTIM HAL API is split into 2 categories:
- (#)Simple functions: these functions allow for using a HRTIM timer as a
- general purpose timer with high resolution capabilities.
- HRTIM simple modes are managed through the set of functions named
- HAL_HRTIM_Simple<Function>. These functions are similar in name and usage
- to the one defined for the TIM peripheral. When a HRTIM timer operates in
- simple mode, only a very limited set of HRTIM features are used.
- Following simple modes are proposed:
- (++)Output compare mode,
- (++)PWM output mode,
- (++)Input capture mode,
- (++)One pulse mode.
- (#)Waveform functions: These functions allow taking advantage of the HRTIM
- flexibility to produce numerous types of control signal. When a HRTIM timer
- operates in waveform mode, all the HRTIM features are accessible without
- any restriction. HRTIM waveform modes are managed through the set of
- functions named HAL_HRTIM_Waveform<Function>
- ##### How to use this driver #####
- ==============================================================================
- [..]
- (#)Initialize the HRTIM low level resources by implementing the
- HAL_HRTIM_MspInit() function:
- (##)Enable the HRTIM clock source using __HRTIMx_CLK_ENABLE()
- (##)Connect HRTIM pins to MCU I/Os
- (+++) Enable the clock for the HRTIM GPIOs using the following
- function: __HAL_RCC_GPIOx_CLK_ENABLE()
- (+++) Configure these GPIO pins in Alternate Function mode using
- HAL_GPIO_Init()
- (##)When using DMA to control data transfer (e.g HAL_HRTIM_SimpleBaseStart_DMA())
- (+++)Enable the DMAx interface clock using __DMAx_CLK_ENABLE()
- (+++)Initialize the DMA handle
- (+++)Associate the initialized DMA handle to the appropriate DMA
- handle of the HRTIM handle using __HAL_LINKDMA()
- (+++)Initialize the DMA channel using HAL_DMA_Init()
- (+++)Configure the priority and enable the NVIC for the transfer
- complete interrupt on the DMA channel using HAL_NVIC_SetPriority()
- and HAL_NVIC_EnableIRQ()
- (##)In case of using interrupt mode (e.g HAL_HRTIM_SimpleBaseStart_IT())
- (+++)Configure the priority and enable the NVIC for the concerned
- HRTIM interrupt using HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ()
- (#)Initialize the HRTIM HAL using HAL_HRTIM_Init(). The HRTIM configuration
- structure (field of the HRTIM handle) specifies which global interrupt of
- whole HRTIM must be enabled (Burst mode period, System fault, Faults).
- It also contains the HRTIM external synchronization configuration. HRTIM
- can act as a master (generating a synchronization signal) or as a slave
- (waiting for a trigger to be synchronized).
- (#)Start the high resolution unit using HAL_HRTIM_DLLCalibrationStart(). DLL
- calibration is executed periodically and compensate for potential voltage
- and temperature drifts. DLL calibration period is specified by the
- CalibrationRate argument.
- (#)HRTIM timers cannot be used until the high resolution unit is ready. This
- can be checked using HAL_HRTIM_PollForDLLCalibration(): this function returns
- HAL_OK if DLL calibration is completed or HAL_TIMEOUT if the DLL calibration
- is still going on when timeout given as argument expires. DLL calibration
- can also be started in interrupt mode using HAL_HRTIM_DLLCalibrationStart_IT().
- In that case an interrupt is generated when the DLL calibration is completed.
- Note that as DLL calibration is executed on a periodic basis an interrupt
- will be generated at the end of every DLL calibration operation
- (worst case: one interrupt every 14 micro seconds !).
- (#) Configure HRTIM resources shared by all HRTIM timers
- (##)Burst Mode Controller:
- (+++)HAL_HRTIM_BurstModeConfig(): configures the HRTIM burst mode
- controller: operating mode (continuous or one-shot mode), clock
- (source, prescaler) , trigger(s), period, idle duration.
- (##)External Events Conditioning:
- (+++)HAL_HRTIM_EventConfig(): configures the conditioning of an
- external event channel: source, polarity, edge-sensitivity.
- External event can be used as triggers (timer reset, input
- capture, burst mode, ADC triggers, delayed protection)
- They can also be used to set or reset timer outputs. Up to
- 10 event channels are available.
- (+++)HAL_HRTIM_EventPrescalerConfig(): configures the external
- event sampling clock (used for digital filtering).
- (##)Fault Conditioning:
- (+++)HAL_HRTIM_FaultConfig(): configures the conditioning of a
- fault channel: source, polarity, edge-sensitivity. Fault
- channels are used to disable the outputs in case of an
- abnormal operation. Up to 5 fault channels are available.
- (+++)HAL_HRTIM_FaultPrescalerConfig(): configures the fault
- sampling clock (used for digital filtering).
- (+++)HAL_HRTIM_FaultModeCtl(): Enables or disables fault input(s)
- circuitry. By default all fault inputs are disabled.
- (##)ADC trigger:
- (+++)HAL_HRTIM_ADCTriggerConfig(): configures the source triggering
- the update of the ADC trigger register and the ADC trigger.
- 4 independent triggers are available to start both the regular
- and the injected sequencers of the 2 ADCs
- (#) Configure HRTIM timer time base using HAL_HRTIM_TimeBaseConfig(). This
- function must be called whatever the HRTIM timer operating mode is
- (simple v.s. waveform). It configures mainly:
- (##)The HRTIM timer counter operating mode (continuous v.s. one shot)
- (##)The HRTIM timer clock prescaler
- (##)The HRTIM timer period
- (##)The HRTIM timer repetition counter
- *** If the HRTIM timer operates in simple mode ***
- ===================================================
- [..]
- (#) Start or Stop simple timers
- (++)Simple time base: HAL_HRTIM_SimpleBaseStart(),HAL_HRTIM_SimpleBaseStop(),
- HAL_HRTIM_SimpleBaseStart_IT(),HAL_HRTIM_SimpleBaseStop_IT(),
- HAL_HRTIM_SimpleBaseStart_DMA(),HAL_HRTIM_SimpleBaseStop_DMA().
- (++)Simple output compare: HAL_HRTIM_SimpleOCChannelConfig(),
- HAL_HRTIM_SimpleOCStart(),HAL_HRTIM_SimpleOCStop(),
- HAL_HRTIM_SimpleOCStart_IT(),HAL_HRTIM_SimpleOCStop_IT(),
- HAL_HRTIM_SimpleOCStart_DMA(),HAL_HRTIM_SimpleOCStop_DMA(),
- (++)Simple PWM output: HAL_HRTIM_SimplePWMChannelConfig(),
- HAL_HRTIM_SimplePWMStart(),HAL_HRTIM_SimplePWMStop(),
- HAL_HRTIM_SimplePWMStart_IT(),HAL_HRTIM_SimplePWMStop_IT(),
- HAL_HRTIM_SimplePWMStart_DMA(),HAL_HRTIM_SimplePWMStop_DMA(),
- (++)Simple input capture: HAL_HRTIM_SimpleCaptureChannelConfig(),
- HAL_HRTIM_SimpleCaptureStart(),HAL_HRTIM_SimpleCaptureStop(),
- HAL_HRTIM_SimpleCaptureStart_IT(),HAL_HRTIM_SimpleCaptureStop_IT(),
- HAL_HRTIM_SimpleCaptureStart_DMA(),HAL_HRTIM_SimpleCaptureStop_DMA().
- (++)Simple one pulse: HAL_HRTIM_SimpleOnePulseChannelConfig(),
- HAL_HRTIM_SimpleOnePulseStart(),HAL_HRTIM_SimpleOnePulseStop(),
- HAL_HRTIM_SimpleOnePulseStart_IT(),HAL_HRTIM_SimpleOnePulseStop_It().
- *** If the HRTIM timer operates in waveform mode ***
- ====================================================
- [..]
- (#) Completes waveform timer configuration
- (++)HAL_HRTIM_WaveformTimerConfig(): configuration of a HRTIM timer
- operating in wave form mode mainly consists in:
- (+++)Enabling the HRTIM timer interrupts and DMA requests.
- (+++)Enabling the half mode for the HRTIM timer.
- (+++)Defining how the HRTIM timer reacts to external synchronization input.
- (+++)Enabling the push-pull mode for the HRTIM timer.
- (+++)Enabling the fault channels for the HRTIM timer.
- (+++)Enabling the dead-time insertion for the HRTIM timer.
- (+++)Setting the delayed protection mode for the HRTIM timer (source and outputs
- on which the delayed protection are applied).
- (+++)Specifying the HRTIM timer update and reset triggers.
- (+++)Specifying the HRTIM timer registers update policy (e.g. pre-load enabling).
- (++)HAL_HRTIM_TimerEventFilteringConfig(): configures external
- event blanking and windowing circuitry of a HRTIM timer:
- (+++)Blanking: to mask external events during a defined time period a defined time period
- (+++)Windowing, to enable external events only during a defined time period
- (++)HAL_HRTIM_DeadTimeConfig(): configures the dead-time insertion
- unit for a HRTIM timer. Allows to generate a couple of
- complementary signals from a single reference waveform,
- with programmable delays between active state.
- (++)HAL_HRTIM_ChopperModeConfig(): configures the parameters of
- the high-frequency carrier signal added on top of the timing
- unit output. Chopper mode can be enabled or disabled for each
- timer output separately (see HAL_HRTIM_WaveformOutputConfig()).
- (++)HAL_HRTIM_BurstDMAConfig(): configures the burst DMA burst
- controller. Allows having multiple HRTIM registers updated
- with a single DMA request. The burst DMA operation is started
- by calling HAL_HRTIM_BurstDMATransfer().
- (++)HAL_HRTIM_WaveformCompareConfig():configures the compare unit
- of a HRTIM timer. This operation consists in setting the
- compare value and possibly specifying the auto delayed mode
- for compare units 2 and 4 (allows to have compare events
- generated relatively to capture events). Note that when auto
- delayed mode is needed, the capture unit associated to the
- compare unit must be configured separately.
- (++)HAL_HRTIM_WaveformCaptureConfig(): configures the capture unit
- of a HRTIM timer. This operation consists in specifying the
- source(s) triggering the capture (timer register update event,
- external event, timer output set/reset event, other HRTIM
- timer related events).
- (++)HAL_HRTIM_WaveformOutputConfig(): configuration of a HRTIM timer
- output mainly consists in:
- (+++)Setting the output polarity (active high or active low),
- (+++)Defining the set/reset crossbar for the output,
- (+++)Specifying the fault level (active or inactive) in IDLE and FAULT states.,
- (#) Set waveform timer output(s) level
- (++)HAL_HRTIM_WaveformSetOutputLevel(): forces the output to its
- active or inactive level. For example, when deadtime insertion
- is enabled it is necessary to force the output level by software
- to have the outputs in a complementary state as soon as the RUN mode is entered.
- (#) Enable or Disable waveform timer output(s)
- (++)HAL_HRTIM_WaveformOutputStart(),HAL_HRTIM_WaveformOutputStop().
- (#) Start or Stop waveform HRTIM timer(s).
- (++)HAL_HRTIM_WaveformCountStart(),HAL_HRTIM_WaveformCountStop(),
- (++)HAL_HRTIM_WaveformCountStart_IT(),HAL_HRTIM_WaveformCountStop_IT(),
- (++)HAL_HRTIM_WaveformCountStart_DMA(),HAL_HRTIM_WaveformCountStop_DMA(),
- (#) Burst mode controller enabling:
- (++)HAL_HRTIM_BurstModeCtl(): activates or de-activates the
- burst mode controller.
- (#) Some HRTIM operations can be triggered by software:
- (++)HAL_HRTIM_BurstModeSoftwareTrigger(): calling this function
- trigs the burst operation.
- (++)HAL_HRTIM_SoftwareCapture(): calling this function trigs the
- capture of the HRTIM timer counter.
- (++)HAL_HRTIM_SoftwareUpdate(): calling this function trigs the
- update of the pre-loadable registers of the HRTIM timer
- (++)HAL_HRTIM_SoftwareReset():calling this function resets the
- HRTIM timer counter.
- (#) Some functions can be used any time to retrieve HRTIM timer related
- information
- (++)HAL_HRTIM_GetCapturedValue(): returns actual value of the
- capture register of the designated capture unit.
- (++)HAL_HRTIM_WaveformGetOutputLevel(): returns actual level
- (ACTIVE/INACTIVE) of the designated timer output.
- (++)HAL_HRTIM_WaveformGetOutputState():returns actual state
- (IDLE/RUN/FAULT) of the designated timer output.
- (++)HAL_HRTIM_GetDelayedProtectionStatus():returns actual level
- (ACTIVE/INACTIVE) of the designated output when the delayed
- protection was triggered.
- (++)HAL_HRTIM_GetBurstStatus(): returns the actual status
- (ACTIVE/INACTIVE) of the burst mode controller.
- (++)HAL_HRTIM_GetCurrentPushPullStatus(): when the push-pull mode
- is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()),
- the push-pull status indicates on which output the signal is currently
- active (e.g signal applied on output 1 and output 2 forced
- inactive or vice versa).
- (++)HAL_HRTIM_GetIdlePushPullStatus(): when the push-pull mode
- is enabled for the HRTIM timer (see HAL_HRTIM_WaveformTimerConfig()),
- the idle push-pull status indicates during which period the
- delayed protection request occurred (e.g. protection occurred
- when the output 1 was active and output 2 forced inactive or
- vice versa).
- (#) Some functions can be used any time to retrieve actual HRTIM status
- (++)HAL_HRTIM_GetState(): returns actual HRTIM instance HAL state.
- *** Callback registration ***
- =============================
- [..]
- The compilation flag USE_HAL_HRTIM_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
- Use Functions HAL_HRTIM_RegisterCallback() or HAL_HRTIM_TIMxRegisterCallback()
- to register an interrupt callback.
- [..]
- Function HAL_HRTIM_RegisterCallback() allows to register following callbacks:
- (+) Fault1Callback : Fault 1 interrupt callback function
- (+) Fault2Callback : Fault 2 interrupt callback function
- (+) Fault3Callback : Fault 3 interrupt callback function
- (+) Fault4Callback : Fault 4 interrupt callback function
- (+) Fault5Callback : Fault 5 interrupt callback function
- (+) SystemFaultCallback : System fault interrupt callback function
- (+) DLLCalibrationReadyCallback : DLL Ready interrupt callback function
- (+) BurstModePeriodCallback : Burst mode period interrupt callback function
- (+) SynchronizationEventCallback : Sync Input interrupt callback function
- (+) ErrorCallback : DMA error callback function
- (+) MspInitCallback : HRTIM MspInit callback function
- (+) MspDeInitCallback : HRTIM MspInit callback function
- [..]
- Function HAL_HRTIM_TIMxRegisterCallback() allows to register following callbacks:
- (+) RegistersUpdateCallback : Timer x Update interrupt callback function
- (+) RepetitionEventCallback : Timer x Repetition interrupt callback function
- (+) Compare1EventCallback : Timer x Compare 1 match interrupt callback function
- (+) Compare2EventCallback : Timer x Compare 2 match interrupt callback function
- (+) Compare3EventCallback : Timer x Compare 3 match interrupt callback function
- (+) Compare4EventCallback : Timer x Compare 4 match interrupt callback function
- (+) Capture1EventCallback : Timer x Capture 1 interrupts callback function
- (+) Capture2EventCallback : Timer x Capture 2 interrupts callback function
- (+) DelayedProtectionCallback : Timer x Delayed protection interrupt callback function
- (+) CounterResetCallback : Timer x counter reset/roll-over interrupt callback function
- (+) Output1SetCallback : Timer x output 1 set interrupt callback function
- (+) Output1ResetCallback : Timer x output 1 reset interrupt callback function
- (+) Output2SetCallback : Timer x output 2 set interrupt callback function
- (+) Output2ResetCallback : Timer x output 2 reset interrupt callback function
- (+) BurstDMATransferCallback : Timer x Burst DMA completed interrupt callback function
- [..]
- Both functions take as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
- [..]
- Use function HAL_HRTIM_UnRegisterCallback or HAL_HRTIM_TIMxUnRegisterCallback
- to reset a callback to the default weak function. Both functions take as parameters
- the HAL peripheral handle and the Callback ID.
- [..]
- By default, after the HAL_HRTIM_Init() and when the state is HAL_HRTIM_STATE_RESET
- all callbacks are set to the corresponding weak functions (e.g HAL_HRTIM_Fault1Callback)
- Exception done for MspInit and MspDeInit functions that are reset to the legacy
- weak functions in the HAL_HRTIM_Init()/ HAL_HRTIM_DeInit() only when these
- callbacks are null (not registered beforehand). If MspInit or MspDeInit are
- not null, the HAL_HRTIM_Init()/ HAL_HRTIM_DeInit() keep and use the user
- MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
- [..]
- Callbacks can be registered/unregistered in HAL_HRTIM_STATE_READY state only.
- Exception done MspInit/MspDeInit functions that can be registered/unregistered
- in HAL_HRTIM_STATE_READY or HAL_HRTIM_STATE_RESET states, thus registered
- (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- Then, the user first registers the MspInit/MspDeInit user callbacks
- using HAL_HRTIM_RegisterCallback() before calling HAL_HRTIM_DeInit()
- or HAL_HRTIM_Init() function.
- [..]
- When the compilation flag USE_HAL_HRTIM_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all
- callbacks are set to the corresponding weak functions.
- @endverbatim
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f3xx_hal.h"
- /** @addtogroup STM32F3xx_HAL_Driver
- * @{
- */
- #ifdef HAL_HRTIM_MODULE_ENABLED
- #if defined(HRTIM1)
- /** @defgroup HRTIM HRTIM
- * @brief HRTIM HAL module driver
- * @{
- */
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /** @defgroup HRTIM_Private_Defines HRTIM Private Define
- * @{
- */
- #define HRTIM_FLTR_FLTxEN (HRTIM_FLTR_FLT1EN |\
- HRTIM_FLTR_FLT2EN |\
- HRTIM_FLTR_FLT3EN |\
- HRTIM_FLTR_FLT4EN | \
- HRTIM_FLTR_FLT5EN)
- #define HRTIM_TIMCR_TIMUPDATETRIGGER (HRTIM_TIMUPDATETRIGGER_MASTER |\
- HRTIM_TIMUPDATETRIGGER_TIMER_A |\
- HRTIM_TIMUPDATETRIGGER_TIMER_B |\
- HRTIM_TIMUPDATETRIGGER_TIMER_C |\
- HRTIM_TIMUPDATETRIGGER_TIMER_D |\
- HRTIM_TIMUPDATETRIGGER_TIMER_E)
- #define HRTIM_FLTINR1_FLTxLCK ((HRTIM_FAULTLOCK_READONLY) | \
- (HRTIM_FAULTLOCK_READONLY << 8U) | \
- (HRTIM_FAULTLOCK_READONLY << 16U) | \
- (HRTIM_FAULTLOCK_READONLY << 24U))
- #define HRTIM_FLTINR2_FLTxLCK ((HRTIM_FAULTLOCK_READONLY) | \
- (HRTIM_FAULTLOCK_READONLY << 8U))
- /**
- * @}
- */
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /** @defgroup HRTIM_Private_Variables HRTIM Private Variables
- * @{
- */
- static uint32_t TimerIdxToTimerId[] =
- {
- HRTIM_TIMERID_TIMER_A,
- HRTIM_TIMERID_TIMER_B,
- HRTIM_TIMERID_TIMER_C,
- HRTIM_TIMERID_TIMER_D,
- HRTIM_TIMERID_TIMER_E,
- HRTIM_TIMERID_MASTER,
- };
- /**
- * @}
- */
- /* Private function prototypes -----------------------------------------------*/
- /** @defgroup HRTIM_Private_Functions HRTIM Private Functions
- * @{
- */
- static void HRTIM_MasterBase_Config(HRTIM_HandleTypeDef * hhrtim,
- const HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg);
- static void HRTIM_TimingUnitBase_Config(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg);
- static void HRTIM_MasterWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
- const HRTIM_TimerCfgTypeDef * pTimerCfg);
- static void HRTIM_TimingUnitWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_TimerCfgTypeDef * pTimerCfg);
- static void HRTIM_CaptureUnitConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureUnit,
- uint32_t Event);
- static void HRTIM_OutputConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output,
- const HRTIM_OutputCfgTypeDef * pOutputCfg);
- static void HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Event,
- const HRTIM_EventCfgTypeDef * pEventCfg);
- static void HRTIM_TIM_ResetConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Event);
- static uint32_t HRTIM_GetITFromOCMode(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel);
- static uint32_t HRTIM_GetDMAFromOCMode(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel);
- static DMA_HandleTypeDef * HRTIM_GetDMAHandleFromTimerIdx(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx);
- static uint32_t GetTimerIdxFromDMAHandle(const HRTIM_HandleTypeDef * hhrtim,
- const DMA_HandleTypeDef * hdma);
- static void HRTIM_ForceRegistersUpdate(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx);
- static void HRTIM_HRTIM_ISR(HRTIM_HandleTypeDef * hhrtim);
- static void HRTIM_Master_ISR(HRTIM_HandleTypeDef * hhrtim);
- static void HRTIM_Timer_ISR(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx);
- static void HRTIM_DMAMasterCplt(DMA_HandleTypeDef *hdma);
- static void HRTIM_DMATimerxCplt(DMA_HandleTypeDef *hdma);
- static void HRTIM_DMAError(DMA_HandleTypeDef *hdma);
- static void HRTIM_BurstDMACplt(DMA_HandleTypeDef *hdma);
- /**
- * @}
- */
- /* Exported functions ---------------------------------------------------------*/
- /** @defgroup HRTIM_Exported_Functions HRTIM Exported Functions
- * @{
- */
- /** @defgroup HRTIM_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- @verbatim
- ===============================================================================
- ##### Initialization and Time Base Configuration functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Initialize a HRTIM instance
- (+) De-initialize a HRTIM instance
- (+) Initialize the HRTIM MSP
- (+) De-initialize the HRTIM MSP
- (+) Start the high-resolution unit (start DLL calibration)
- (+) Check that the high resolution unit is ready (DLL calibration done)
- (+) Configure the time base unit of a HRTIM timer
- @endverbatim
- * @{
- */
- /**
- * @brief Initialize a HRTIM instance
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_Init(HRTIM_HandleTypeDef * hhrtim)
- {
- uint8_t timer_idx;
- uint32_t hrtim_mcr;
- /* Check the HRTIM handle allocation */
- if(hhrtim == NULL)
- {
- return HAL_ERROR;
- }
- /* Check the parameters */
- assert_param(IS_HRTIM_ALL_INSTANCE(hhrtim->Instance));
- assert_param(IS_HRTIM_IT(hhrtim->Init.HRTIMInterruptResquests));
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- if (hhrtim->State == HAL_HRTIM_STATE_RESET)
- {
- /* Initialize callback function pointers to their default values */
- hhrtim->Fault1Callback = HAL_HRTIM_Fault1Callback;
- hhrtim->Fault2Callback = HAL_HRTIM_Fault2Callback;
- hhrtim->Fault3Callback = HAL_HRTIM_Fault3Callback;
- hhrtim->Fault4Callback = HAL_HRTIM_Fault4Callback;
- hhrtim->Fault5Callback = HAL_HRTIM_Fault5Callback;
- hhrtim->SystemFaultCallback = HAL_HRTIM_SystemFaultCallback;
- hhrtim->DLLCalibrationReadyCallback = HAL_HRTIM_DLLCalibrationReadyCallback;
- hhrtim->BurstModePeriodCallback = HAL_HRTIM_BurstModePeriodCallback;
- hhrtim->SynchronizationEventCallback = HAL_HRTIM_SynchronizationEventCallback;
- hhrtim->ErrorCallback = HAL_HRTIM_ErrorCallback;
- hhrtim->RegistersUpdateCallback = HAL_HRTIM_RegistersUpdateCallback;
- hhrtim->RepetitionEventCallback = HAL_HRTIM_RepetitionEventCallback;
- hhrtim->Compare1EventCallback = HAL_HRTIM_Compare1EventCallback;
- hhrtim->Compare2EventCallback = HAL_HRTIM_Compare2EventCallback;
- hhrtim->Compare3EventCallback = HAL_HRTIM_Compare3EventCallback;
- hhrtim->Compare4EventCallback = HAL_HRTIM_Compare4EventCallback;
- hhrtim->Capture1EventCallback = HAL_HRTIM_Capture1EventCallback;
- hhrtim->Capture2EventCallback = HAL_HRTIM_Capture2EventCallback;
- hhrtim->DelayedProtectionCallback = HAL_HRTIM_DelayedProtectionCallback;
- hhrtim->CounterResetCallback = HAL_HRTIM_CounterResetCallback;
- hhrtim->Output1SetCallback = HAL_HRTIM_Output1SetCallback;
- hhrtim->Output1ResetCallback = HAL_HRTIM_Output1ResetCallback;
- hhrtim->Output2SetCallback = HAL_HRTIM_Output2SetCallback;
- hhrtim->Output2ResetCallback = HAL_HRTIM_Output2ResetCallback;
- hhrtim->BurstDMATransferCallback = HAL_HRTIM_BurstDMATransferCallback;
- if (hhrtim->MspInitCallback == NULL)
- {
- hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
- }
- }
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- /* Set the HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Initialize the DMA handles */
- hhrtim->hdmaMaster = (DMA_HandleTypeDef *)NULL;
- hhrtim->hdmaTimerA = (DMA_HandleTypeDef *)NULL;
- hhrtim->hdmaTimerB = (DMA_HandleTypeDef *)NULL;
- hhrtim->hdmaTimerC = (DMA_HandleTypeDef *)NULL;
- hhrtim->hdmaTimerD = (DMA_HandleTypeDef *)NULL;
- hhrtim->hdmaTimerE = (DMA_HandleTypeDef *)NULL;
- /* HRTIM output synchronization configuration (if required) */
- if ((hhrtim->Init.SyncOptions & HRTIM_SYNCOPTION_MASTER) != (uint32_t)RESET)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_SYNCOUTPUTSOURCE(hhrtim->Init.SyncOutputSource));
- assert_param(IS_HRTIM_SYNCOUTPUTPOLARITY(hhrtim->Init.SyncOutputPolarity));
- /* The synchronization output initialization procedure must be done prior
- to the configuration of the MCU outputs (done within HAL_HRTIM_MspInit)
- */
- if (hhrtim->Instance == HRTIM1)
- {
- /* Enable the HRTIM peripheral clock */
- __HAL_RCC_HRTIM1_CLK_ENABLE();
- }
- hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
- /* Set the event to be sent on the synchronization output */
- hrtim_mcr &= ~(HRTIM_MCR_SYNC_SRC);
- hrtim_mcr |= (hhrtim->Init.SyncOutputSource & HRTIM_MCR_SYNC_SRC);
- /* Set the polarity of the synchronization output */
- hrtim_mcr &= ~(HRTIM_MCR_SYNC_OUT);
- hrtim_mcr |= (hhrtim->Init.SyncOutputPolarity & HRTIM_MCR_SYNC_OUT);
- /* Update the HRTIM registers */
- hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
- }
- /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->MspInitCallback(hhrtim);
- #else
- HAL_HRTIM_MspInit(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- /* HRTIM input synchronization configuration (if required) */
- if ((hhrtim->Init.SyncOptions & HRTIM_SYNCOPTION_SLAVE) != (uint32_t)RESET)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_SYNCINPUTSOURCE(hhrtim->Init.SyncInputSource));
- hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
- /* Set the synchronization input source */
- hrtim_mcr &= ~(HRTIM_MCR_SYNC_IN);
- hrtim_mcr |= (hhrtim->Init.SyncInputSource & HRTIM_MCR_SYNC_IN);
- /* Update the HRTIM registers */
- hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
- }
- /* Initialize the HRTIM state*/
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Initialize the lock status of the HRTIM HAL API */
- __HAL_UNLOCK(hhrtim);
- /* Initialize timer related parameters */
- for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
- timer_idx <= HRTIM_TIMERINDEX_MASTER ;
- timer_idx++)
- {
- hhrtim->TimerParam[timer_idx].CaptureTrigger1 = HRTIM_CAPTURETRIGGER_NONE;
- hhrtim->TimerParam[timer_idx].CaptureTrigger2 = HRTIM_CAPTURETRIGGER_NONE;
- hhrtim->TimerParam[timer_idx].InterruptRequests = HRTIM_IT_NONE;
- hhrtim->TimerParam[timer_idx].DMARequests = HRTIM_IT_NONE;
- hhrtim->TimerParam[timer_idx].DMASrcAddress = 0U;
- hhrtim->TimerParam[timer_idx].DMASize = 0U;
- }
- return HAL_OK;
- }
- /**
- * @brief De-initialize a HRTIM instance
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_DeInit (HRTIM_HandleTypeDef * hhrtim)
- {
- /* Check the HRTIM handle allocation */
- if(hhrtim == NULL)
- {
- return HAL_ERROR;
- }
- /* Check the parameters */
- assert_param(IS_HRTIM_ALL_INSTANCE(hhrtim->Instance));
- /* Set the HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* DeInit the low level hardware */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- if (hhrtim->MspDeInitCallback == NULL)
- {
- hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
- }
- hhrtim->MspDeInitCallback(hhrtim);
- #else
- HAL_HRTIM_MspDeInit(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- return HAL_OK;
- }
- /**
- * @brief MSP initialization for a HRTIM instance
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_MspInit(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_HRTIM_MspInit could be implemented in the user file
- */
- }
- /**
- * @brief MSP de-initialization of a HRTIM instance
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_MspDeInit(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_HRTIM_MspDeInit could be implemented in the user file
- */
- }
- /**
- * @brief Start the DLL calibration
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CalibrationRate DLL calibration period
- * This parameter can be one of the following values:
- * @arg HRTIM_SINGLE_CALIBRATION: One shot DLL calibration
- * @arg HRTIM_CALIBRATIONRATE_7300: Periodic DLL calibration. T=7.300 ms
- * @arg HRTIM_CALIBRATIONRATE_910: Periodic DLL calibration. T=0.910 ms
- * @arg HRTIM_CALIBRATIONRATE_114: Periodic DLL calibration. T=0.114 ms
- * @arg HRTIM_CALIBRATIONRATE_14: Periodic DLL calibration. T=0.014 ms
- * @retval HAL status
- * @note This function locks the HRTIM instance. HRTIM instance is unlocked
- * within the HAL_HRTIM_PollForDLLCalibration function, just before
- * exiting the function.
- */
- HAL_StatusTypeDef HAL_HRTIM_DLLCalibrationStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t CalibrationRate)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_CALIBRATIONRATE(CalibrationRate));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- if (CalibrationRate == HRTIM_SINGLE_CALIBRATION)
- {
- /* One shot DLL calibration */
- CLEAR_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALEN);
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CAL);
- }
- else
- {
- /* Periodic DLL calibration */
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALEN);
- MODIFY_REG(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALRTE, CalibrationRate);
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CAL);
- }
- /* Set HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- return HAL_OK;
- }
- /**
- * @brief Start the DLL calibration.
- * DLL ready interrupt is enabled
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CalibrationRate DLL calibration period
- * This parameter can be one of the following values:
- * @arg HRTIM_SINGLE_CALIBRATION: One shot DLL calibration
- * @arg HRTIM_CALIBRATIONRATE_7300: Periodic DLL calibration. T=7.300 ms
- * @arg HRTIM_CALIBRATIONRATE_910: Periodic DLL calibration. T=0.910 ms
- * @arg HRTIM_CALIBRATIONRATE_114: Periodic DLL calibration. T=0.114 ms
- * @arg HRTIM_CALIBRATIONRATE_14: Periodic DLL calibration. T=0.014 ms
- * @retval HAL status
- * @note This function locks the HRTIM instance. HRTIM instance is unlocked
- * within the IRQ processing function when processing the DLL ready
- * interrupt.
- * @note If this function is called for periodic calibration, the DLLRDY
- * interrupt is generated every time the calibration completes which
- * will significantly increases the overall interrupt rate.
- */
- HAL_StatusTypeDef HAL_HRTIM_DLLCalibrationStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t CalibrationRate)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_CALIBRATIONRATE(CalibrationRate));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable DLL Ready interrupt flag */
- __HAL_HRTIM_ENABLE_IT(hhrtim, HRTIM_IT_DLLRDY);
- if (CalibrationRate == HRTIM_SINGLE_CALIBRATION)
- {
- /* One shot DLL calibration */
- CLEAR_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALEN);
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CAL);
- }
- else
- {
- /* Periodic DLL calibration */
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALEN);
- MODIFY_REG(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CALRTE, CalibrationRate);
- SET_BIT(hhrtim->Instance->sCommonRegs.DLLCR, HRTIM_DLLCR_CAL);
- }
- /* Set HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- return HAL_OK;
- }
- /**
- * @brief Poll the DLL calibration ready flag and returns when the flag is
- * set (DLL calibration completed) or upon timeout expiration.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timeout Timeout duration in millisecond
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_PollForDLLCalibration(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timeout)
- {
- uint32_t tickstart;
- tickstart = HAL_GetTick();
- /* Check End of conversion flag */
- while(__HAL_HRTIM_GET_FLAG(hhrtim, HRTIM_IT_DLLRDY) == (uint32_t)RESET)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if(((HAL_GetTick()-tickstart) > Timeout) || (Timeout == 0U))
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- return HAL_TIMEOUT;
- }
- }
- }
- /* Set HRTIM State */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the time base unit of a timer
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param pTimeBaseCfg pointer to the time base configuration structure
- * @note This function must be called prior starting the timer
- * @note The time-base unit initialization parameters specify:
- * The timer counter operating mode (continuous, one shot),
- * The timer clock prescaler,
- * The timer period,
- * The timer repetition counter.
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_TimeBaseConfig(HRTIM_HandleTypeDef *hhrtim,
- uint32_t TimerIdx,
- const HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- assert_param(IS_HRTIM_PRESCALERRATIO(pTimeBaseCfg->PrescalerRatio));
- assert_param(IS_HRTIM_MODE(pTimeBaseCfg->Mode));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Set the HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- /* Configure master timer time base unit */
- HRTIM_MasterBase_Config(hhrtim, pTimeBaseCfg);
- }
- else
- {
- /* Configure timing unit time base unit */
- HRTIM_TimingUnitBase_Config(hhrtim, TimerIdx, pTimeBaseCfg);
- }
- /* Set HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group2 Simple time base mode functions
- * @brief Simple time base mode functions.
- @verbatim
- ===============================================================================
- ##### Simple time base mode functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Start simple time base
- (+) Stop simple time base
- (+) Start simple time base and enable interrupt
- (+) Stop simple time base and disable interrupt
- (+) Start simple time base and enable DMA transfer
- (+) Stop simple time base and disable DMA transfer
- -@- When a HRTIM timer operates in simple time base mode, the timer
- counter counts from 0 to the period value.
- @endverbatim
- * @{
- */
- /**
- * @brief Start the counter of a timer operating in simple time base mode.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the counter of a timer operating in simple time base mode.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the counter of a timer operating in simple time base mode
- * (Timer repetition interrupt is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the repetition interrupt */
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- __HAL_HRTIM_MASTER_ENABLE_IT(hhrtim, HRTIM_MASTER_IT_MREP);
- }
- else
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the counter of a timer operating in simple time base mode
- * (Timer repetition interrupt is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the repetition interrupt */
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- __HAL_HRTIM_MASTER_DISABLE_IT(hhrtim, HRTIM_MASTER_IT_MREP);
- }
- else
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the counter of a timer operating in simple time base mode
- * (Timer repetition DMA request is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param SrcAddr DMA transfer source address
- * @param DestAddr DMA transfer destination address
- * @param Length The length of data items (data size) to be transferred
- * from source to destination
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStart_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t SrcAddr,
- uint32_t DestAddr,
- uint32_t Length)
- {
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- if(hhrtim->State == HAL_HRTIM_STATE_READY)
- {
- if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
- {
- return HAL_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- }
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA transfer completed callback */
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- hdma->XferCpltCallback = HRTIM_DMAMasterCplt;
- }
- else
- {
- hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
- }
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Enable the timer repetition DMA request */
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- __HAL_HRTIM_MASTER_ENABLE_DMA(hhrtim, HRTIM_MASTER_DMA_MREP);
- }
- else
- {
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_REP);
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the counter of a timer operating in simple time base mode
- * (Timer repetition DMA request is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index.
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleBaseStop_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Disable the DMA */
- if (HAL_DMA_Abort(hhrtim->hdmaMaster) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- }
- /* Disable the timer repetition DMA request */
- __HAL_HRTIM_MASTER_DISABLE_DMA(hhrtim, HRTIM_MASTER_DMA_MREP);
- }
- else
- {
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Disable the DMA */
- if (HAL_DMA_Abort(hdma) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- }
- /* Disable the timer repetition DMA request */
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_REP);
- }
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- if (hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- else
- {
- return HAL_OK;
- }
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group3 Simple output compare mode functions
- * @brief Simple output compare functions
- @verbatim
- ===============================================================================
- ##### Simple output compare functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure simple output channel
- (+) Start simple output compare
- (+) Stop simple output compare
- (+) Start simple output compare and enable interrupt
- (+) Stop simple output compare and disable interrupt
- (+) Start simple output compare and enable DMA transfer
- (+) Stop simple output compare and disable DMA transfer
- -@- When a HRTIM timer operates in simple output compare mode
- the output level is set to a programmable value when a match
- is found between the compare register and the counter.
- Compare unit 1 is automatically associated to output 1
- Compare unit 2 is automatically associated to output 2
- @endverbatim
- * @{
- */
- /**
- * @brief Configure an output in simple output compare mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param pSimpleOCChannelCfg pointer to the simple output compare output configuration structure
- * @note When the timer operates in simple output compare mode:
- * Output 1 is implicitly controlled by the compare unit 1
- * Output 2 is implicitly controlled by the compare unit 2
- * Output Set/Reset crossbar is set according to the selected output compare mode:
- * Toggle: SETxyR = RSTxyR = CMPy
- * Active: SETxyR = CMPy, RSTxyR = 0
- * Inactive: SETxy =0, RSTxy = CMPy
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCChannelConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel,
- const HRTIM_SimpleOCChannelCfgTypeDef* pSimpleOCChannelCfg)
- {
- uint32_t CompareUnit = (uint32_t)RESET;
- HRTIM_OutputCfgTypeDef OutputCfg;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- assert_param(IS_HRTIM_BASICOCMODE(pSimpleOCChannelCfg->Mode));
- assert_param(IS_HRTIM_OUTPUTPULSE(pSimpleOCChannelCfg->Pulse));
- assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimpleOCChannelCfg->Polarity));
- assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimpleOCChannelCfg->IdleLevel));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- /* Set HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure timer compare unit */
- switch (OCChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- CompareUnit = HRTIM_COMPAREUNIT_1;
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimpleOCChannelCfg->Pulse;
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- CompareUnit = HRTIM_COMPAREUNIT_2;
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimpleOCChannelCfg->Pulse;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Configure timer output */
- OutputCfg.Polarity = (pSimpleOCChannelCfg->Polarity & HRTIM_OUTR_POL1);
- OutputCfg.IdleLevel = (pSimpleOCChannelCfg->IdleLevel & HRTIM_OUTR_IDLES1);
- OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
- OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
- OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
- OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
- switch (pSimpleOCChannelCfg->Mode)
- {
- case HRTIM_BASICOCMODE_TOGGLE:
- {
- if (CompareUnit == HRTIM_COMPAREUNIT_1)
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
- }
- else
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
- }
- OutputCfg.ResetSource = OutputCfg.SetSource;
- break;
- }
- case HRTIM_BASICOCMODE_ACTIVE:
- {
- if (CompareUnit == HRTIM_COMPAREUNIT_1)
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
- }
- else
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
- }
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
- break;
- }
- case HRTIM_BASICOCMODE_INACTIVE:
- {
- if (CompareUnit == HRTIM_COMPAREUNIT_1)
- {
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
- }
- else
- {
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP2;
- }
- OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
- break;
- }
- default:
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- HRTIM_OutputConfig(hhrtim,
- TimerIdx,
- OCChannel,
- &OutputCfg);
- /* Set HRTIM state */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the output compare signal generation on the designed timer output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the output compare signal generation on the designed timer output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the output compare signal generation on the designed timer output
- * (Interrupt is enabled (see note note below)).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @note Interrupt enabling depends on the chosen output compare mode
- * Output toggle: compare match interrupt is enabled
- * Output set active: output set interrupt is enabled
- * Output set inactive: output reset interrupt is enabled
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- uint32_t interrupt;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Get the interrupt to enable (depends on the output compare mode) */
- interrupt = HRTIM_GetITFromOCMode(hhrtim, TimerIdx, OCChannel);
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
- /* Enable the timer interrupt (depends on the output compare mode) */
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, interrupt);
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the output compare signal generation on the designed timer output
- * (Interrupt is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- uint32_t interrupt;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
- /* Get the interrupt to disable (depends on the output compare mode) */
- interrupt = HRTIM_GetITFromOCMode(hhrtim, TimerIdx, OCChannel);
- /* Disable the timer interrupt */
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, interrupt);
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the output compare signal generation on the designed timer output
- * (DMA request is enabled (see note below)).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param SrcAddr DMA transfer source address
- * @param DestAddr DMA transfer destination address
- * @param Length The length of data items (data size) to be transferred
- * from source to destination
- * @note DMA request enabling depends on the chosen output compare mode
- * Output toggle: compare match DMA request is enabled
- * Output set active: output set DMA request is enabled
- * Output set inactive: output reset DMA request is enabled
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel,
- uint32_t SrcAddr,
- uint32_t DestAddr,
- uint32_t Length)
- {
- DMA_HandleTypeDef * hdma;
- uint32_t dma_request;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- if(hhrtim->State == HAL_HRTIM_STATE_READY)
- {
- if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
- {
- return HAL_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- }
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= OCChannel;
- /* Get the DMA request to enable */
- dma_request = HRTIM_GetDMAFromOCMode(hhrtim, TimerIdx, OCChannel);
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Set the DMA transfer completed callback */
- hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Enable the timer DMA request */
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, dma_request);
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the output compare signal generation on the designed timer output
- * (DMA request is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOCStop_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- uint32_t dma_request;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= OCChannel;
- /* Get the timer DMA handler */
- /* Disable the DMA */
- if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Get the DMA request to disable */
- dma_request = HRTIM_GetDMAFromOCMode(hhrtim, TimerIdx, OCChannel);
- /* Disable the timer DMA request */
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, dma_request);
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group4 Simple PWM output mode functions
- * @brief Simple PWM output functions
- @verbatim
- ===============================================================================
- ##### Simple PWM output functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure simple PWM output channel
- (+) Start simple PWM output
- (+) Stop simple PWM output
- (+) Start simple PWM output and enable interrupt
- (+) Stop simple PWM output and disable interrupt
- (+) Start simple PWM output and enable DMA transfer
- (+) Stop simple PWM output and disable DMA transfer
- -@- When a HRTIM timer operates in simple PWM output mode
- the output level is set to a programmable value when a match is
- found between the compare register and the counter and reset when
- the timer period is reached. Duty cycle is determined by the
- comparison value.
- Compare unit 1 is automatically associated to output 1
- Compare unit 2 is automatically associated to output 2
- @endverbatim
- * @{
- */
- /**
- * @brief Configure an output in simple PWM mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param pSimplePWMChannelCfg pointer to the simple PWM output configuration structure
- * @note When the timer operates in simple PWM output mode:
- * Output 1 is implicitly controlled by the compare unit 1
- * Output 2 is implicitly controlled by the compare unit 2
- * Output Set/Reset crossbar is set as follows:
- * Output 1: SETx1R = CMP1, RSTx1R = PER
- * Output 2: SETx2R = CMP2, RST2R = PER
- * @note When Simple PWM mode is used the registers preload mechanism is
- * enabled (otherwise the behavior is not guaranteed).
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMChannelConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel,
- const HRTIM_SimplePWMChannelCfgTypeDef* pSimplePWMChannelCfg)
- {
- HRTIM_OutputCfgTypeDef OutputCfg;
- uint32_t hrtim_timcr;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimplePWMChannelCfg->Polarity));
- assert_param(IS_HRTIM_OUTPUTPULSE(pSimplePWMChannelCfg->Pulse));
- assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimplePWMChannelCfg->IdleLevel));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure timer compare unit */
- switch (PWMChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimplePWMChannelCfg->Pulse;
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimplePWMChannelCfg->Pulse;
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
- break;
- }
- default:
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Configure timer output */
- OutputCfg.Polarity = (pSimplePWMChannelCfg->Polarity & HRTIM_OUTR_POL1);
- OutputCfg.IdleLevel = (pSimplePWMChannelCfg->IdleLevel& HRTIM_OUTR_IDLES1);
- OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
- OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
- OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
- OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMPER;
- HRTIM_OutputConfig(hhrtim,
- TimerIdx,
- PWMChannel,
- &OutputCfg);
- /* Enable the registers preload mechanism */
- hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
- hrtim_timcr |= HRTIM_TIMCR_PREEN;
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the PWM output signal generation on the designed timer output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the PWM output signal generation on the designed timer output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the PWM output signal generation on the designed timer output
- * (The compare interrupt is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
- /* Enable the timer interrupt (depends on the PWM output) */
- switch (PWMChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the PWM output signal generation on the designed timer output
- * (The compare interrupt is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
- /* Disable the timer interrupt (depends on the PWM output) */
- switch (PWMChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the PWM output signal generation on the designed timer output
- * (The compare DMA request is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param SrcAddr DMA transfer source address
- * @param DestAddr DMA transfer destination address
- * @param Length The length of data items (data size) to be transferred
- * from source to destination
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel,
- uint32_t SrcAddr,
- uint32_t DestAddr,
- uint32_t Length)
- {
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- if(hhrtim->State == HAL_HRTIM_STATE_READY)
- {
- if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U))
- {
- return HAL_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- }
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= PWMChannel;
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Set the DMA transfer completed callback */
- hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Enable the timer DMA request */
- switch (PWMChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the PWM output signal generation on the designed timer output
- * (The compare DMA request is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param PWMChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimplePWMStop_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t PWMChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= PWMChannel;
- /* Get the timer DMA handler */
- /* Disable the DMA */
- if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Disable the timer DMA request */
- switch (PWMChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group5 Simple input capture functions
- * @brief Simple input capture functions
- @verbatim
- ===============================================================================
- ##### Simple input capture functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure simple input capture channel
- (+) Start simple input capture
- (+) Stop simple input capture
- (+) Start simple input capture and enable interrupt
- (+) Stop simple input capture and disable interrupt
- (+) Start simple input capture and enable DMA transfer
- (+) Stop simple input capture and disable DMA transfer
- -@- When a HRTIM timer operates in simple input capture mode
- the Capture Register (HRTIM_CPT1/2xR) is used to latch the
- value of the timer counter counter after a transition detected
- on a given external event input.
- @endverbatim
- * @{
- */
- /**
- * @brief Configure a simple capture
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Capture unit
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @param pSimpleCaptureChannelCfg pointer to the simple capture configuration structure
- * @note When the timer operates in simple capture mode the capture is triggered
- * by the designated external event and GPIO input is implicitly used as event source.
- * The cature can be triggered by a rising edge, a falling edge or both
- * edges on event channel.
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureChannelConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel,
- const HRTIM_SimpleCaptureChannelCfgTypeDef* pSimpleCaptureChannelCfg)
- {
- HRTIM_EventCfgTypeDef EventCfg;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- assert_param(IS_HRTIM_EVENT(pSimpleCaptureChannelCfg->Event));
- assert_param(IS_HRTIM_EVENTPOLARITY(pSimpleCaptureChannelCfg->EventSensitivity,
- pSimpleCaptureChannelCfg->EventPolarity));
- assert_param(IS_HRTIM_EVENTSENSITIVITY(pSimpleCaptureChannelCfg->EventSensitivity));
- assert_param(IS_HRTIM_EVENTFILTER(pSimpleCaptureChannelCfg->Event,
- pSimpleCaptureChannelCfg->EventFilter));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure external event channel */
- EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
- EventCfg.Filter = (pSimpleCaptureChannelCfg->EventFilter & HRTIM_EECR3_EE6F);
- EventCfg.Polarity = (pSimpleCaptureChannelCfg->EventPolarity & HRTIM_EECR1_EE1POL);
- EventCfg.Sensitivity = (pSimpleCaptureChannelCfg->EventSensitivity & HRTIM_EECR1_EE1SNS);
- EventCfg.Source = HRTIM_EVENTSRC_1;
- HRTIM_EventConfig(hhrtim,
- pSimpleCaptureChannelCfg->Event,
- &EventCfg);
- /* Memorize capture trigger (will be configured when the capture is started */
- HRTIM_CaptureUnitConfig(hhrtim,
- TimerIdx,
- CaptureChannel,
- pSimpleCaptureChannelCfg->Event);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable a simple capture on the designed capture unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- * @note The external event triggering the capture is available for all timing
- * units. It can be used directly and is active as soon as the timing
- * unit counter is enabled.
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the capture unit trigger */
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable a simple capture on the designed capture unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel)
- {
- uint32_t hrtim_cpt1cr;
- uint32_t hrtim_cpt2cr;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the capture unit trigger */
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
- hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
- /* Disable the timer counter */
- if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
- (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
- {
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable a simple capture on the designed capture unit
- * (Capture interrupt is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the capture unit trigger */
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
- /* Enable the capture unit 1 interrupt */
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
- /* Enable the capture unit 2 interrupt */
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable a simple capture on the designed capture unit
- * (Capture interrupt is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel)
- {
- uint32_t hrtim_cpt1cr;
- uint32_t hrtim_cpt2cr;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the capture unit trigger */
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
- /* Disable the capture unit 1 interrupt */
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
- /* Disable the capture unit 2 interrupt */
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
- hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
- /* Disable the timer counter */
- if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
- (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
- {
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable a simple capture on the designed capture unit
- * (Capture DMA request is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @param SrcAddr DMA transfer source address
- * @param DestAddr DMA transfer destination address
- * @param Length The length of data items (data size) to be transferred
- * from source to destination
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStart_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel,
- uint32_t SrcAddr,
- uint32_t DestAddr,
- uint32_t Length)
- {
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Set the DMA transfer completed callback */
- hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma, SrcAddr, DestAddr, Length) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- /* Set the capture unit trigger */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger1;
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT1);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- /* Set the capture unit trigger */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = hhrtim->TimerParam[TimerIdx].CaptureTrigger2;
- /* Enable the timer DMA request */
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable a simple capture on the designed capture unit
- * (Capture DMA request is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleCaptureStop_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureChannel)
- {
- uint32_t hrtim_cpt1cr;
- uint32_t hrtim_cpt2cr;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Get the timer DMA handler */
- /* Disable the DMA */
- if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx)) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- switch (CaptureChannel)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- /* Reset the capture unit trigger */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR = HRTIM_CAPTURETRIGGER_NONE;
- /* Disable the capture unit 1 DMA request */
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT1);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- /* Reset the capture unit trigger */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR = HRTIM_CAPTURETRIGGER_NONE;
- /* Disable the capture unit 2 DMA request */
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim, TimerIdx, HRTIM_TIM_DMA_CPT2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hrtim_cpt1cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR;
- hrtim_cpt2cr = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR;
- /* Disable the timer counter */
- if ((hrtim_cpt1cr == HRTIM_CAPTURETRIGGER_NONE) &&
- (hrtim_cpt2cr == HRTIM_CAPTURETRIGGER_NONE))
- {
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group6 Simple one pulse functions
- * @brief Simple one pulse functions
- @verbatim
- ===============================================================================
- ##### Simple one pulse functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure one pulse channel
- (+) Start one pulse generation
- (+) Stop one pulse generation
- (+) Start one pulse generation and enable interrupt
- (+) Stop one pulse generation and disable interrupt
- -@- When a HRTIM timer operates in simple one pulse mode
- the timer counter is started in response to transition detected
- on a given external event input to generate a pulse with a
- programmable length after a programmable delay.
- @endverbatim
- * @{
- */
- /**
- * @brief Configure an output simple one pulse mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OnePulseChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param pSimpleOnePulseChannelCfg pointer to the simple one pulse output configuration structure
- * @note When the timer operates in simple one pulse mode:
- * the timer counter is implicitly started by the reset event,
- * the reset of the timer counter is triggered by the designated external event
- * GPIO input is implicitly used as event source,
- * Output 1 is implicitly controlled by the compare unit 1,
- * Output 2 is implicitly controlled by the compare unit 2.
- * Output Set/Reset crossbar is set as follows:
- * Output 1: SETx1R = CMP1, RSTx1R = PER
- * Output 2: SETx2R = CMP2, RST2R = PER
- * @retval HAL status
- * @note If HAL_HRTIM_SimpleOnePulseChannelConfig is called for both timer
- * outputs, the reset event related configuration data provided in the
- * second call will override the reset event related configuration data
- * provided in the first call.
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseChannelConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OnePulseChannel,
- const HRTIM_SimpleOnePulseChannelCfgTypeDef* pSimpleOnePulseChannelCfg)
- {
- HRTIM_OutputCfgTypeDef OutputCfg;
- HRTIM_EventCfgTypeDef EventCfg;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
- assert_param(IS_HRTIM_OUTPUTPULSE(pSimpleOnePulseChannelCfg->Pulse));
- assert_param(IS_HRTIM_OUTPUTPOLARITY(pSimpleOnePulseChannelCfg->OutputPolarity));
- assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pSimpleOnePulseChannelCfg->OutputIdleLevel));
- assert_param(IS_HRTIM_EVENT(pSimpleOnePulseChannelCfg->Event));
- assert_param(IS_HRTIM_EVENTPOLARITY(pSimpleOnePulseChannelCfg->EventSensitivity,
- pSimpleOnePulseChannelCfg->EventPolarity));
- assert_param(IS_HRTIM_EVENTSENSITIVITY(pSimpleOnePulseChannelCfg->EventSensitivity));
- assert_param(IS_HRTIM_EVENTFILTER(pSimpleOnePulseChannelCfg->Event,
- pSimpleOnePulseChannelCfg->EventFilter));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure timer compare unit */
- switch (OnePulseChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pSimpleOnePulseChannelCfg->Pulse;
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP1;
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pSimpleOnePulseChannelCfg->Pulse;
- OutputCfg.SetSource = HRTIM_OUTPUTSET_TIMCMP2;
- break;
- }
- default:
- {
- OutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Configure timer output */
- OutputCfg.Polarity = (pSimpleOnePulseChannelCfg->OutputPolarity & HRTIM_OUTR_POL1);
- OutputCfg.IdleLevel = (pSimpleOnePulseChannelCfg->OutputIdleLevel & HRTIM_OUTR_IDLES1);
- OutputCfg.FaultLevel = HRTIM_OUTPUTFAULTLEVEL_NONE;
- OutputCfg.IdleMode = HRTIM_OUTPUTIDLEMODE_NONE;
- OutputCfg.ChopperModeEnable = HRTIM_OUTPUTCHOPPERMODE_DISABLED;
- OutputCfg.BurstModeEntryDelayed = HRTIM_OUTPUTBURSTMODEENTRY_REGULAR;
- OutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMPER;
- HRTIM_OutputConfig(hhrtim,
- TimerIdx,
- OnePulseChannel,
- &OutputCfg);
- /* Configure external event channel */
- EventCfg.FastMode = HRTIM_EVENTFASTMODE_DISABLE;
- EventCfg.Filter = (pSimpleOnePulseChannelCfg->EventFilter & HRTIM_EECR3_EE6F);
- EventCfg.Polarity = (pSimpleOnePulseChannelCfg->EventPolarity & HRTIM_OUTR_POL1);
- EventCfg.Sensitivity = (pSimpleOnePulseChannelCfg->EventSensitivity &HRTIM_EECR1_EE1SNS);
- EventCfg.Source = HRTIM_EVENTSRC_1;
- HRTIM_EventConfig(hhrtim,
- pSimpleOnePulseChannelCfg->Event,
- &EventCfg);
- /* Configure the timer reset register */
- HRTIM_TIM_ResetConfig(hhrtim,
- TimerIdx,
- pSimpleOnePulseChannelCfg->Event);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable the simple one pulse signal generation on the designed output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OnePulseChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OnePulseChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= OnePulseChannel;
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable the simple one pulse signal generation on the designed output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OnePulseChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OnePulseChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= OnePulseChannel;
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable the simple one pulse signal generation on the designed output
- * (The compare interrupt is enabled (pulse start)).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OnePulseChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OnePulseChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the timer output */
- hhrtim->Instance->sCommonRegs.OENR |= OnePulseChannel;
- /* Enable the timer interrupt (depends on the OnePulse output) */
- switch (OnePulseChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable the simple one pulse signal generation on the designed output
- * (The compare interrupt is disabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param OnePulseChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_SimpleOnePulseStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OnePulseChannel)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OnePulseChannel));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable the timer output */
- hhrtim->Instance->sCommonRegs.ODISR |= OnePulseChannel;
- /* Disable the timer interrupt (depends on the OnePulse output) */
- switch (OnePulseChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, TimerIdxToTimerId[TimerIdx]);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group7 Configuration functions
- * @brief HRTIM configuration functions
- @verbatim
- ===============================================================================
- ##### HRTIM configuration functions #####
- ===============================================================================
- [..] This section provides functions allowing to configure the HRTIM
- resources shared by all the HRTIM timers operating in waveform mode:
- (+) Configure the burst mode controller
- (+) Configure an external event conditioning
- (+) Configure the external events sampling clock
- (+) Configure a fault conditioning
- (+) Enable or disable fault inputs
- (+) Configure the faults sampling clock
- (+) Configure an ADC trigger
- @endverbatim
- * @{
- */
- /**
- * @brief Configure the burst mode feature of the HRTIM
- * @param hhrtim pointer to HAL HRTIM handle
- * @param pBurstModeCfg pointer to the burst mode configuration structure
- * @retval HAL status
- * @note This function must be called before starting the burst mode
- * controller
- */
- HAL_StatusTypeDef HAL_HRTIM_BurstModeConfig(HRTIM_HandleTypeDef * hhrtim,
- const HRTIM_BurstModeCfgTypeDef* pBurstModeCfg)
- {
- uint32_t hrtim_bmcr;
- /* Check parameters */
- assert_param(IS_HRTIM_BURSTMODE(pBurstModeCfg->Mode));
- assert_param(IS_HRTIM_BURSTMODECLOCKSOURCE(pBurstModeCfg->ClockSource));
- assert_param(IS_HRTIM_HRTIM_BURSTMODEPRESCALER(pBurstModeCfg->Prescaler));
- assert_param(IS_HRTIM_BURSTMODEPRELOAD(pBurstModeCfg->PreloadEnable));
- assert_param(IS_HRTIM_BURSTMODETRIGGER(pBurstModeCfg->Trigger));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
- /* Set the burst mode operating mode */
- hrtim_bmcr &= ~(HRTIM_BMCR_BMOM);
- hrtim_bmcr |= (pBurstModeCfg->Mode & HRTIM_BMCR_BMOM);
- /* Set the burst mode clock source */
- hrtim_bmcr &= ~(HRTIM_BMCR_BMCLK);
- hrtim_bmcr |= (pBurstModeCfg->ClockSource & HRTIM_BMCR_BMCLK);
- /* Set the burst mode prescaler */
- hrtim_bmcr &= ~(HRTIM_BMCR_BMPRSC);
- hrtim_bmcr |= pBurstModeCfg->Prescaler;
- /* Enable/disable burst mode registers preload */
- hrtim_bmcr &= ~(HRTIM_BMCR_BMPREN);
- hrtim_bmcr |= (pBurstModeCfg->PreloadEnable & HRTIM_BMCR_BMPREN);
- /* Set the burst mode trigger */
- hhrtim->Instance->sCommonRegs.BMTRGR = pBurstModeCfg->Trigger;
- /* Set the burst mode compare value */
- hhrtim->Instance->sCommonRegs.BMCMPR = pBurstModeCfg->IdleDuration;
- /* Set the burst mode period */
- hhrtim->Instance->sCommonRegs.BMPER = pBurstModeCfg->Period;
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the conditioning of an external event
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Event external event to configure
- * This parameter can be one of the following values:
- * @arg HRTIM_EVENT_NONE: no external Event
- * @arg HRTIM_EVENT_1: External event 1
- * @arg HRTIM_EVENT_2: External event 2
- * @arg HRTIM_EVENT_3: External event 3
- * @arg HRTIM_EVENT_4: External event 4
- * @arg HRTIM_EVENT_5: External event 5
- * @arg HRTIM_EVENT_6: External event 6
- * @arg HRTIM_EVENT_7: External event 7
- * @arg HRTIM_EVENT_8: External event 8
- * @arg HRTIM_EVENT_9: External event 9
- * @arg HRTIM_EVENT_10: External event 10
- * @param pEventCfg pointer to the event conditioning configuration structure
- * @note This function must be called before starting the timer
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Event,
- const HRTIM_EventCfgTypeDef* pEventCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_EVENT(Event));
- assert_param(IS_HRTIM_EVENTSRC(pEventCfg->Source));
- assert_param(IS_HRTIM_EVENTPOLARITY(pEventCfg->Sensitivity, pEventCfg->Polarity));
- assert_param(IS_HRTIM_EVENTSENSITIVITY(pEventCfg->Sensitivity));
- assert_param(IS_HRTIM_EVENTFASTMODE(Event, pEventCfg->FastMode));
- assert_param(IS_HRTIM_EVENTFILTER(Event, pEventCfg->Filter));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure the event channel */
- HRTIM_EventConfig(hhrtim, Event, pEventCfg);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the external event conditioning block prescaler
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Prescaler Prescaler value
- * This parameter can be one of the following values:
- * @arg HRTIM_EVENTPRESCALER_DIV1: fEEVS=fHRTIM
- * @arg HRTIM_EVENTPRESCALER_DIV2: fEEVS=fHRTIM / 2
- * @arg HRTIM_EVENTPRESCALER_DIV4: fEEVS=fHRTIM / 4
- * @arg HRTIM_EVENTPRESCALER_DIV8: fEEVS=fHRTIM / 8
- * @note This function must be called before starting the timer
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_EventPrescalerConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Prescaler)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_EVENTPRESCALER(Prescaler));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the external event prescaler */
- MODIFY_REG(hhrtim->Instance->sCommonRegs.EECR3, HRTIM_EECR3_EEVSD, (Prescaler & HRTIM_EECR3_EEVSD));
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the conditioning of fault input
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Fault fault input to configure
- * This parameter can be one of the following values:
- * @arg HRTIM_FAULT_1: Fault input 1
- * @arg HRTIM_FAULT_2: Fault input 2
- * @arg HRTIM_FAULT_3: Fault input 3
- * @arg HRTIM_FAULT_4: Fault input 4
- * @arg HRTIM_FAULT_5: Fault input 5
- * @param pFaultCfg pointer to the fault conditioning configuration structure
- * @note This function must be called before starting the timer and before
- * enabling faults inputs
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_FaultConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Fault,
- const HRTIM_FaultCfgTypeDef* pFaultCfg)
- {
- uint32_t hrtim_fltinr1;
- uint32_t hrtim_fltinr2;
- /* Check parameters */
- assert_param(IS_HRTIM_FAULT(Fault));
- assert_param(IS_HRTIM_FAULTSOURCE(pFaultCfg->Source));
- assert_param(IS_HRTIM_FAULTPOLARITY(pFaultCfg->Polarity));
- assert_param(IS_HRTIM_FAULTFILTER(pFaultCfg->Filter));
- assert_param(IS_HRTIM_FAULTLOCK(pFaultCfg->Lock));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure fault channel */
- hrtim_fltinr1 = hhrtim->Instance->sCommonRegs.FLTINR1;
- hrtim_fltinr2 = hhrtim->Instance->sCommonRegs.FLTINR2;
- switch (Fault)
- {
- case HRTIM_FAULT_1:
- {
- hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT1P | HRTIM_FLTINR1_FLT1SRC | HRTIM_FLTINR1_FLT1F | HRTIM_FLTINR1_FLT1LCK);
- hrtim_fltinr1 |= (pFaultCfg->Polarity & HRTIM_FLTINR1_FLT1P);
- hrtim_fltinr1 |= (pFaultCfg->Source & HRTIM_FLTINR1_FLT1SRC);
- hrtim_fltinr1 |= (pFaultCfg->Filter & HRTIM_FLTINR1_FLT1F);
- hrtim_fltinr1 |= (pFaultCfg->Lock & HRTIM_FLTINR1_FLT1LCK);
- break;
- }
- case HRTIM_FAULT_2:
- {
- hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT2P | HRTIM_FLTINR1_FLT2SRC | HRTIM_FLTINR1_FLT2F | HRTIM_FLTINR1_FLT2LCK);
- hrtim_fltinr1 |= ((pFaultCfg->Polarity << 8U) & HRTIM_FLTINR1_FLT2P);
- hrtim_fltinr1 |= ((pFaultCfg->Source << 8U) & HRTIM_FLTINR1_FLT2SRC);
- hrtim_fltinr1 |= ((pFaultCfg->Filter << 8U) & HRTIM_FLTINR1_FLT2F);
- hrtim_fltinr1 |= ((pFaultCfg->Lock << 8U) & HRTIM_FLTINR1_FLT2LCK);
- break;
- }
- case HRTIM_FAULT_3:
- {
- hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT3P | HRTIM_FLTINR1_FLT3SRC | HRTIM_FLTINR1_FLT3F | HRTIM_FLTINR1_FLT3LCK);
- hrtim_fltinr1 |= ((pFaultCfg->Polarity << 16U) & HRTIM_FLTINR1_FLT3P);
- hrtim_fltinr1 |= ((pFaultCfg->Source << 16U) & HRTIM_FLTINR1_FLT3SRC);
- hrtim_fltinr1 |= ((pFaultCfg->Filter << 16U) & HRTIM_FLTINR1_FLT3F);
- hrtim_fltinr1 |= ((pFaultCfg->Lock << 16U) & HRTIM_FLTINR1_FLT3LCK);
- break;
- }
- case HRTIM_FAULT_4:
- {
- hrtim_fltinr1 &= ~(HRTIM_FLTINR1_FLT4P | HRTIM_FLTINR1_FLT4SRC | HRTIM_FLTINR1_FLT4F | HRTIM_FLTINR1_FLT4LCK);
- hrtim_fltinr1 |= ((pFaultCfg->Polarity << 24U) & HRTIM_FLTINR1_FLT4P);
- hrtim_fltinr1 |= ((pFaultCfg->Source << 24U) & HRTIM_FLTINR1_FLT4SRC);
- hrtim_fltinr1 |= ((pFaultCfg->Filter << 24U) & HRTIM_FLTINR1_FLT4F);
- hrtim_fltinr1 |= ((pFaultCfg->Lock << 24U) & HRTIM_FLTINR1_FLT4LCK);
- break;
- }
- case HRTIM_FAULT_5:
- {
- hrtim_fltinr2 &= ~(HRTIM_FLTINR2_FLT5P | HRTIM_FLTINR2_FLT5SRC | HRTIM_FLTINR2_FLT5F | HRTIM_FLTINR2_FLT5LCK);
- hrtim_fltinr2 |= (pFaultCfg->Polarity & HRTIM_FLTINR2_FLT5P);
- hrtim_fltinr2 |= (pFaultCfg->Source & HRTIM_FLTINR2_FLT5SRC);
- hrtim_fltinr2 |= (pFaultCfg->Filter & HRTIM_FLTINR2_FLT5F);
- hrtim_fltinr2 |= (pFaultCfg->Lock & HRTIM_FLTINR2_FLT5LCK);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Update the HRTIM registers except LOCK bit */
- hhrtim->Instance->sCommonRegs.FLTINR1 = (hrtim_fltinr1 & (~(HRTIM_FLTINR1_FLTxLCK)));
- hhrtim->Instance->sCommonRegs.FLTINR2 = (hrtim_fltinr2 & (~(HRTIM_FLTINR2_FLTxLCK)));
- /* Update the HRTIM registers LOCK bit */
- SET_BIT(hhrtim->Instance->sCommonRegs.FLTINR1,(hrtim_fltinr1 & HRTIM_FLTINR1_FLTxLCK));
- SET_BIT(hhrtim->Instance->sCommonRegs.FLTINR2,(hrtim_fltinr2 & HRTIM_FLTINR2_FLTxLCK));
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the fault conditioning block prescaler
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Prescaler Prescaler value
- * This parameter can be one of the following values:
- * @arg HRTIM_FAULTPRESCALER_DIV1: fFLTS=fHRTIM
- * @arg HRTIM_FAULTPRESCALER_DIV2: fFLTS=fHRTIM / 2
- * @arg HRTIM_FAULTPRESCALER_DIV4: fFLTS=fHRTIM / 4
- * @arg HRTIM_FAULTPRESCALER_DIV8: fFLTS=fHRTIM / 8
- * @retval HAL status
- * @note This function must be called before starting the timer and before
- * enabling faults inputs
- */
- HAL_StatusTypeDef HAL_HRTIM_FaultPrescalerConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Prescaler)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_FAULTPRESCALER(Prescaler));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the external event prescaler */
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR2, HRTIM_FLTINR2_FLTSD, (Prescaler & HRTIM_FLTINR2_FLTSD));
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable or disables the HRTIMx Fault mode.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Faults fault input(s) to enable or disable
- * This parameter can be any combination of the following values:
- * @arg HRTIM_FAULT_1: Fault input 1
- * @arg HRTIM_FAULT_2: Fault input 2
- * @arg HRTIM_FAULT_3: Fault input 3
- * @arg HRTIM_FAULT_4: Fault input 4
- * @arg HRTIM_FAULT_5: Fault input 5
- * @param Enable Fault(s) enabling
- * This parameter can be one of the following values:
- * @arg HRTIM_FAULTMODECTL_ENABLED: Fault(s) enabled
- * @arg HRTIM_FAULTMODECTL_DISABLED: Fault(s) disabled
- * @retval None
- */
- void HAL_HRTIM_FaultModeCtl(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Faults,
- uint32_t Enable)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_FAULT(Faults));
- assert_param(IS_HRTIM_FAULTMODECTL(Enable));
- if ((Faults & HRTIM_FAULT_1) != (uint32_t)RESET)
- {
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT1E, (Enable & HRTIM_FLTINR1_FLT1E));
- }
- if ((Faults & HRTIM_FAULT_2) != (uint32_t)RESET)
- {
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT2E, ((Enable << 8U) & HRTIM_FLTINR1_FLT2E));
- }
- if ((Faults & HRTIM_FAULT_3) != (uint32_t)RESET)
- {
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT3E, ((Enable << 16U) & HRTIM_FLTINR1_FLT3E));
- }
- if ((Faults & HRTIM_FAULT_4) != (uint32_t)RESET)
- {
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR1, HRTIM_FLTINR1_FLT4E, ((Enable << 24U) & HRTIM_FLTINR1_FLT4E));
- }
- if ((Faults & HRTIM_FAULT_5) != (uint32_t)RESET)
- {
- MODIFY_REG(hhrtim->Instance->sCommonRegs.FLTINR2, HRTIM_FLTINR2_FLT5E, ((Enable) & HRTIM_FLTINR2_FLT5E));
- }
- }
- /**
- * @brief Configure both the ADC trigger register update source and the ADC
- * trigger source.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param ADCTrigger ADC trigger to configure
- * This parameter can be one of the following values:
- * @arg HRTIM_ADCTRIGGER_1: ADC trigger 1
- * @arg HRTIM_ADCTRIGGER_2: ADC trigger 2
- * @arg HRTIM_ADCTRIGGER_3: ADC trigger 3
- * @arg HRTIM_ADCTRIGGER_4: ADC trigger 4
- * @param pADCTriggerCfg pointer to the ADC trigger configuration structure
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_ADCTriggerConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t ADCTrigger,
- const HRTIM_ADCTriggerCfgTypeDef* pADCTriggerCfg)
- {
- uint32_t hrtim_cr1;
- /* Check parameters */
- assert_param(IS_HRTIM_ADCTRIGGER(ADCTrigger));
- assert_param(IS_HRTIM_ADCTRIGGERUPDATE(pADCTriggerCfg->UpdateSource));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the ADC trigger update source */
- hrtim_cr1 = hhrtim->Instance->sCommonRegs.CR1;
- switch (ADCTrigger)
- {
- case HRTIM_ADCTRIGGER_1:
- {
- hrtim_cr1 &= ~(HRTIM_CR1_ADC1USRC);
- hrtim_cr1 |= (pADCTriggerCfg->UpdateSource & HRTIM_CR1_ADC1USRC);
- /* Set the ADC trigger 1 source */
- hhrtim->Instance->sCommonRegs.ADC1R = pADCTriggerCfg->Trigger;
- break;
- }
- case HRTIM_ADCTRIGGER_2:
- {
- hrtim_cr1 &= ~(HRTIM_CR1_ADC2USRC);
- hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 3U) & HRTIM_CR1_ADC2USRC);
- /* Set the ADC trigger 2 source */
- hhrtim->Instance->sCommonRegs.ADC2R = pADCTriggerCfg->Trigger;
- break;
- }
- case HRTIM_ADCTRIGGER_3:
- {
- hrtim_cr1 &= ~(HRTIM_CR1_ADC3USRC);
- hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 6U) & HRTIM_CR1_ADC3USRC);
- /* Set the ADC trigger 3 source */
- hhrtim->Instance->sCommonRegs.ADC3R = pADCTriggerCfg->Trigger;
- break;
- }
- case HRTIM_ADCTRIGGER_4:
- {
- hrtim_cr1 &= ~(HRTIM_CR1_ADC4USRC);
- hrtim_cr1 |= ((pADCTriggerCfg->UpdateSource << 9U) & HRTIM_CR1_ADC4USRC);
- /* Set the ADC trigger 4 source */
- hhrtim->Instance->sCommonRegs.ADC4R = pADCTriggerCfg->Trigger;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.CR1 = hrtim_cr1;
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group8 Timer waveform configuration and functions
- * @brief HRTIM timer configuration and control functions
- @verbatim
- ===============================================================================
- ##### HRTIM timer configuration and control functions #####
- ===============================================================================
- [..] This section provides functions used to configure and control a
- HRTIM timer operating in waveform mode:
- (+) Configure HRTIM timer general behavior
- (+) Configure HRTIM timer event filtering
- (+) Configure HRTIM timer deadtime insertion
- (+) Configure HRTIM timer chopper mode
- (+) Configure HRTIM timer burst DMA
- (+) Configure HRTIM timer compare unit
- (+) Configure HRTIM timer capture unit
- (+) Configure HRTIM timer output
- (+) Set HRTIM timer output level
- (+) Enable HRTIM timer output
- (+) Disable HRTIM timer output
- (+) Start HRTIM timer
- (+) Stop HRTIM timer
- (+) Start HRTIM timer and enable interrupt
- (+) Stop HRTIM timer and disable interrupt
- (+) Start HRTIM timer and enable DMA transfer
- (+) Stop HRTIM timer and disable DMA transfer
- (+) Enable or disable the burst mode controller
- (+) Start the burst mode controller (by software)
- (+) Trigger a Capture (by software)
- (+) Update the HRTIM timer preloadable registers (by software)
- (+) Reset the HRTIM timer counter (by software)
- (+) Start a burst DMA transfer
- (+) Enable timer register update
- (+) Disable timer register update
- @endverbatim
- * @{
- */
- /**
- * @brief Configure the general behavior of a timer operating in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param pTimerCfg pointer to the timer configuration structure
- * @note When the timer operates in waveform mode, all the features supported by
- * the HRTIM are available without any limitation.
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformTimerConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_TimerCfgTypeDef * pTimerCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- /* Relevant for all HRTIM timers, including the master */
- assert_param(IS_HRTIM_HALFMODE(pTimerCfg->HalfModeEnable));
- assert_param(IS_HRTIM_SYNCSTART(pTimerCfg->StartOnSync));
- assert_param(IS_HRTIM_SYNCRESET(pTimerCfg->ResetOnSync));
- assert_param(IS_HRTIM_DACSYNC(pTimerCfg->DACSynchro));
- assert_param(IS_HRTIM_PRELOAD(pTimerCfg->PreloadEnable));
- assert_param(IS_HRTIM_TIMERBURSTMODE(pTimerCfg->BurstMode));
- assert_param(IS_HRTIM_UPDATEONREPETITION(pTimerCfg->RepetitionUpdate));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_UPDATEGATING_MASTER(pTimerCfg->UpdateGating));
- assert_param(IS_HRTIM_MASTER_IT(pTimerCfg->InterruptRequests));
- assert_param(IS_HRTIM_MASTER_DMA(pTimerCfg->DMARequests));
- /* Configure master timer */
- HRTIM_MasterWaveform_Config(hhrtim, pTimerCfg);
- }
- else
- {
- /* Check parameters */
- assert_param(IS_HRTIM_UPDATEGATING_TIM(pTimerCfg->UpdateGating));
- assert_param(IS_HRTIM_TIM_IT(pTimerCfg->InterruptRequests));
- assert_param(IS_HRTIM_TIM_DMA(pTimerCfg->DMARequests));
- assert_param(IS_HRTIM_TIMPUSHPULLMODE(pTimerCfg->PushPull));
- assert_param(IS_HRTIM_TIMFAULTENABLE(pTimerCfg->FaultEnable));
- assert_param(IS_HRTIM_TIMFAULTLOCK(pTimerCfg->FaultLock));
- assert_param(IS_HRTIM_TIMDEADTIMEINSERTION(pTimerCfg->PushPull,
- pTimerCfg->DeadTimeInsertion));
- assert_param(IS_HRTIM_TIMDELAYEDPROTECTION(pTimerCfg->PushPull,
- pTimerCfg->DelayedProtectionMode));
- assert_param(IS_HRTIM_TIMUPDATETRIGGER(pTimerCfg->UpdateTrigger));
- assert_param(IS_HRTIM_TIMRESETTRIGGER(pTimerCfg->ResetTrigger));
- assert_param(IS_HRTIM_TIMUPDATEONRESET(pTimerCfg->ResetUpdate));
- /* Configure timing unit */
- HRTIM_TimingUnitWaveform_Config(hhrtim, TimerIdx, pTimerCfg);
- }
- /* Update timer parameters */
- hhrtim->TimerParam[TimerIdx].InterruptRequests = pTimerCfg->InterruptRequests;
- hhrtim->TimerParam[TimerIdx].DMARequests = pTimerCfg->DMARequests;
- hhrtim->TimerParam[TimerIdx].DMASrcAddress = pTimerCfg->DMASrcAddress;
- hhrtim->TimerParam[TimerIdx].DMADstAddress = pTimerCfg->DMADstAddress;
- hhrtim->TimerParam[TimerIdx].DMASize = pTimerCfg->DMASize;
- /* Force a software update */
- HRTIM_ForceRegistersUpdate(hhrtim, TimerIdx);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the event filtering capabilities of a timer (blanking, windowing)
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Event external event for which timer event filtering must be configured
- * This parameter can be one of the following values:
- * @arg HRTIM_EVENT_1: External event 1
- * @arg HRTIM_EVENT_2: External event 2
- * @arg HRTIM_EVENT_3: External event 3
- * @arg HRTIM_EVENT_4: External event 4
- * @arg HRTIM_EVENT_5: External event 5
- * @arg HRTIM_EVENT_6: External event 6
- * @arg HRTIM_EVENT_7: External event 7
- * @arg HRTIM_EVENT_8: External event 8
- * @arg HRTIM_EVENT_9: External event 9
- * @arg HRTIM_EVENT_10: External event 10
- * @param pTimerEventFilteringCfg pointer to the timer event filtering configuration structure
- * @note This function must be called before starting the timer
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_TimerEventFilteringConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Event,
- const HRTIM_TimerEventFilteringCfgTypeDef* pTimerEventFilteringCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_EVENT(Event));
- assert_param(IS_HRTIM_TIMEVENTFILTER(pTimerEventFilteringCfg->Filter));
- assert_param(IS_HRTIM_TIMEVENTLATCH(pTimerEventFilteringCfg->Latch));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure timer event filtering capabilities */
- switch (Event)
- {
- case HRTIM_EVENT_NONE:
- {
- CLEAR_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1);
- CLEAR_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2);
- break;
- }
- case HRTIM_EVENT_1:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE1FLTR | HRTIM_EEFR1_EE1LTCH), (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch));
- break;
- }
- case HRTIM_EVENT_2:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE2FLTR | HRTIM_EEFR1_EE2LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6U) );
- break;
- }
- case HRTIM_EVENT_3:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE3FLTR | HRTIM_EEFR1_EE3LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12U) );
- break;
- }
- case HRTIM_EVENT_4:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE4FLTR | HRTIM_EEFR1_EE4LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18U) );
- break;
- }
- case HRTIM_EVENT_5:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR1, (HRTIM_EEFR1_EE5FLTR | HRTIM_EEFR1_EE5LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24U) );
- break;
- }
- case HRTIM_EVENT_6:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE6FLTR | HRTIM_EEFR2_EE6LTCH), (pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) );
- break;
- }
- case HRTIM_EVENT_7:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE7FLTR | HRTIM_EEFR2_EE7LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 6U) );
- break;
- }
- case HRTIM_EVENT_8:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE8FLTR | HRTIM_EEFR2_EE8LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 12U) );
- break;
- }
- case HRTIM_EVENT_9:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE9FLTR | HRTIM_EEFR2_EE9LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 18U) );
- break;
- }
- case HRTIM_EVENT_10:
- {
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].EEFxR2, (HRTIM_EEFR2_EE10FLTR | HRTIM_EEFR2_EE10LTCH), ((pTimerEventFilteringCfg->Filter | pTimerEventFilteringCfg->Latch) << 24U) );
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the dead-time insertion feature for a timer
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param pDeadTimeCfg pointer to the deadtime insertion configuration structure
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_DeadTimeConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_DeadTimeCfgTypeDef* pDeadTimeCfg)
- {
- uint32_t hrtim_dtr;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_TIMDEADTIME_PRESCALERRATIO(pDeadTimeCfg->Prescaler));
- assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGN(pDeadTimeCfg->RisingSign));
- assert_param(IS_HRTIM_TIMDEADTIME_RISINGLOCK(pDeadTimeCfg->RisingLock));
- assert_param(IS_HRTIM_TIMDEADTIME_RISINGSIGNLOCK(pDeadTimeCfg->RisingSignLock));
- assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGN(pDeadTimeCfg->FallingSign));
- assert_param(IS_HRTIM_TIMDEADTIME_FALLINGLOCK(pDeadTimeCfg->FallingLock));
- assert_param(IS_HRTIM_TIMDEADTIME_FALLINGSIGNLOCK(pDeadTimeCfg->FallingSignLock));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set timer deadtime configuration */
- hrtim_dtr = (pDeadTimeCfg->Prescaler & HRTIM_DTR_DTPRSC);
- hrtim_dtr |= (pDeadTimeCfg->RisingValue & HRTIM_DTR_DTR);
- hrtim_dtr |= (pDeadTimeCfg->RisingSign & HRTIM_DTR_SDTR);
- hrtim_dtr |= (pDeadTimeCfg->RisingSignLock & HRTIM_DTR_DTRSLK);
- hrtim_dtr |= (pDeadTimeCfg->RisingLock & HRTIM_DTR_DTRLK);
- hrtim_dtr |= ((pDeadTimeCfg->FallingValue << 16U) & HRTIM_DTR_DTF);
- hrtim_dtr |= (pDeadTimeCfg->FallingSign & HRTIM_DTR_SDTF);
- hrtim_dtr |= (pDeadTimeCfg->FallingSignLock & HRTIM_DTR_DTFSLK);
- hrtim_dtr |= (pDeadTimeCfg->FallingLock & HRTIM_DTR_DTFLK);
- /* Update the HRTIM registers */
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].DTxR, (
- HRTIM_DTR_DTR | HRTIM_DTR_SDTR | HRTIM_DTR_DTPRSC |
- HRTIM_DTR_DTRSLK | HRTIM_DTR_DTRLK | HRTIM_DTR_DTF |
- HRTIM_DTR_SDTF | HRTIM_DTR_DTFSLK | HRTIM_DTR_DTFLK), hrtim_dtr);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the chopper mode feature for a timer
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param pChopperModeCfg pointer to the chopper mode configuration structure
- * @retval HAL status
- * @note This function must be called before configuring the timer output(s)
- */
- HAL_StatusTypeDef HAL_HRTIM_ChopperModeConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_ChopperModeCfgTypeDef* pChopperModeCfg)
- {
- uint32_t hrtim_chpr;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CHOPPER_PRESCALERRATIO(pChopperModeCfg->CarrierFreq));
- assert_param(IS_HRTIM_CHOPPER_DUTYCYCLE(pChopperModeCfg->DutyCycle));
- assert_param(IS_HRTIM_CHOPPER_PULSEWIDTH(pChopperModeCfg->StartPulse));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set timer choppe mode configuration */
- hrtim_chpr = (pChopperModeCfg->CarrierFreq & HRTIM_CHPR_CARFRQ);
- hrtim_chpr |= (pChopperModeCfg->DutyCycle & HRTIM_CHPR_CARDTY);
- hrtim_chpr |= (pChopperModeCfg->StartPulse & HRTIM_CHPR_STRPW);
- /* Update the HRTIM registers */
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CHPxR,
- (HRTIM_CHPR_CARFRQ | HRTIM_CHPR_CARDTY | HRTIM_CHPR_STRPW),
- hrtim_chpr);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the burst DMA controller for a timer
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param RegistersToUpdate registers to be written by DMA
- * This parameter can be any combination of the following values:
- * @arg HRTIM_BURSTDMA_CR: HRTIM_MCR or HRTIM_TIMxCR
- * @arg HRTIM_BURSTDMA_ICR: HRTIM_MICR or HRTIM_TIMxICR
- * @arg HRTIM_BURSTDMA_DIER: HRTIM_MDIER or HRTIM_TIMxDIER
- * @arg HRTIM_BURSTDMA_CNT: HRTIM_MCNT or HRTIM_TIMxCNT
- * @arg HRTIM_BURSTDMA_PER: HRTIM_MPER or HRTIM_TIMxPER
- * @arg HRTIM_BURSTDMA_REP: HRTIM_MREP or HRTIM_TIMxREP
- * @arg HRTIM_BURSTDMA_CMP1: HRTIM_MCMP1 or HRTIM_TIMxCMP1
- * @arg HRTIM_BURSTDMA_CMP2: HRTIM_MCMP2 or HRTIM_TIMxCMP2
- * @arg HRTIM_BURSTDMA_CMP3: HRTIM_MCMP3 or HRTIM_TIMxCMP3
- * @arg HRTIM_BURSTDMA_CMP4: HRTIM_MCMP4 or HRTIM_TIMxCMP4
- * @arg HRTIM_BURSTDMA_DTR: HRTIM_TIMxDTR
- * @arg HRTIM_BURSTDMA_SET1R: HRTIM_TIMxSET1R
- * @arg HRTIM_BURSTDMA_RST1R: HRTIM_TIMxRST1R
- * @arg HRTIM_BURSTDMA_SET2R: HRTIM_TIMxSET2R
- * @arg HRTIM_BURSTDMA_RST2R: HRTIM_TIMxRST2R
- * @arg HRTIM_BURSTDMA_EEFR1: HRTIM_TIMxEEFR1
- * @arg HRTIM_BURSTDMA_EEFR2: HRTIM_TIMxEEFR2
- * @arg HRTIM_BURSTDMA_RSTR: HRTIM_TIMxRSTR
- * @arg HRTIM_BURSTDMA_CHPR: HRTIM_TIMxCHPR
- * @arg HRTIM_BURSTDMA_OUTR: HRTIM_TIMxOUTR
- * @arg HRTIM_BURSTDMA_FLTR: HRTIM_TIMxFLTR
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_BurstDMAConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t RegistersToUpdate)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_BURSTDMA(TimerIdx, RegistersToUpdate));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Set the burst DMA timer update register */
- switch (TimerIdx)
- {
- case HRTIM_TIMERINDEX_TIMER_A:
- {
- hhrtim->Instance->sCommonRegs.BDTAUPR = RegistersToUpdate;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_B:
- {
- hhrtim->Instance->sCommonRegs.BDTBUPR = RegistersToUpdate;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_C:
- {
- hhrtim->Instance->sCommonRegs.BDTCUPR = RegistersToUpdate;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_D:
- {
- hhrtim->Instance->sCommonRegs.BDTDUPR = RegistersToUpdate;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_E:
- {
- hhrtim->Instance->sCommonRegs.BDTEUPR = RegistersToUpdate;
- break;
- }
- case HRTIM_TIMERINDEX_MASTER:
- {
- hhrtim->Instance->sCommonRegs.BDMUPR = RegistersToUpdate;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the compare unit of a timer operating in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CompareUnit Compare unit to configure
- * This parameter can be one of the following values:
- * @arg HRTIM_COMPAREUNIT_1: Compare unit 1
- * @arg HRTIM_COMPAREUNIT_2: Compare unit 2
- * @arg HRTIM_COMPAREUNIT_3: Compare unit 3
- * @arg HRTIM_COMPAREUNIT_4: Compare unit 4
- * @param pCompareCfg pointer to the compare unit configuration structure
- * @note When auto delayed mode is required for compare unit 2 or compare unit 4,
- * application has to configure separately the capture unit. Capture unit
- * to configure in that case depends on the compare unit auto delayed mode
- * is applied to (see below):
- * Auto delayed on output compare 2: capture unit 1 must be configured
- * Auto delayed on output compare 4: capture unit 2 must be configured
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCompareConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CompareUnit,
- const HRTIM_CompareCfgTypeDef* pCompareCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure the compare unit */
- if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- switch (CompareUnit)
- {
- case HRTIM_COMPAREUNIT_1:
- {
- hhrtim->Instance->sMasterRegs.MCMP1R = pCompareCfg->CompareValue;
- break;
- }
- case HRTIM_COMPAREUNIT_2:
- {
- hhrtim->Instance->sMasterRegs.MCMP2R = pCompareCfg->CompareValue;
- break;
- }
- case HRTIM_COMPAREUNIT_3:
- {
- hhrtim->Instance->sMasterRegs.MCMP3R = pCompareCfg->CompareValue;
- break;
- }
- case HRTIM_COMPAREUNIT_4:
- {
- hhrtim->Instance->sMasterRegs.MCMP4R = pCompareCfg->CompareValue;
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- }
- else
- {
- switch (CompareUnit)
- {
- case HRTIM_COMPAREUNIT_1:
- {
- /* Set the compare value */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->CompareValue;
- break;
- }
- case HRTIM_COMPAREUNIT_2:
- {
- /* Check parameters */
- assert_param(IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE(CompareUnit, pCompareCfg->AutoDelayedMode));
- /* Set the compare value */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP2xR = pCompareCfg->CompareValue;
- if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
- {
- /* Configure auto-delayed mode */
- /* DELCMP2 bitfield must be reset when reprogrammed from one value */
- /* to the other to reinitialize properly the auto-delayed mechanism */
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~HRTIM_TIMCR_DELCMP2;
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR |= pCompareCfg->AutoDelayedMode;
- /* Set the compare value for timeout compare unit (if any) */
- if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
- }
- else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
- }
- else
- {
- /* nothing to do */
- }
- }
- else
- {
- /* Clear HRTIM_TIMxCR.DELCMP2 bitfield */
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR, HRTIM_TIMCR_DELCMP2, 0U);
- }
- break;
- }
- case HRTIM_COMPAREUNIT_3:
- {
- /* Set the compare value */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->CompareValue;
- break;
- }
- case HRTIM_COMPAREUNIT_4:
- {
- /* Check parameters */
- assert_param(IS_HRTIM_COMPAREUNIT_AUTODELAYEDMODE(CompareUnit, pCompareCfg->AutoDelayedMode));
- /* Set the compare value */
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP4xR = pCompareCfg->CompareValue;
- if (pCompareCfg->AutoDelayedMode != HRTIM_AUTODELAYEDMODE_REGULAR)
- {
- /* Configure auto-delayed mode */
- /* DELCMP4 bitfield must be reset when reprogrammed from one value */
- /* to the other to reinitialize properly the auto-delayed mechanism */
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~HRTIM_TIMCR_DELCMP4;
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR |= (pCompareCfg->AutoDelayedMode << 2U);
- /* Set the compare value for timeout compare unit (if any) */
- if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP1)
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP1xR = pCompareCfg->AutoDelayedTimeout;
- }
- else if (pCompareCfg->AutoDelayedMode == HRTIM_AUTODELAYEDMODE_AUTODELAYED_TIMEOUTCMP3)
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].CMP3xR = pCompareCfg->AutoDelayedTimeout;
- }
- else
- {
- /* nothing to do */
- }
- }
- else
- {
- /* Clear HRTIM_TIMxCR.DELCMP4 bitfield */
- MODIFY_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR, HRTIM_TIMCR_DELCMP4, 0U);
- }
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the capture unit of a timer operating in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureUnit Capture unit to configure
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @param pCaptureCfg pointer to the compare unit configuration structure
- * @retval HAL status
- * @note This function must be called before starting the timer
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCaptureConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureUnit,
- const HRTIM_CaptureCfgTypeDef* pCaptureCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_CAPTURETRIGGER(TimerIdx, pCaptureCfg->Trigger));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure the capture unit */
- switch (CaptureUnit)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- WRITE_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR, pCaptureCfg->Trigger);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- WRITE_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR, pCaptureCfg->Trigger);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Configure the output of a timer operating in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Output Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param pOutputCfg pointer to the timer output configuration structure
- * @retval HAL status
- * @note This function must be called before configuring the timer and after
- * configuring the deadtime insertion feature (if required).
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformOutputConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output,
- const HRTIM_OutputCfgTypeDef * pOutputCfg)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
- assert_param(IS_HRTIM_OUTPUTPOLARITY(pOutputCfg->Polarity));
- assert_param(IS_HRTIM_OUTPUTIDLELEVEL(pOutputCfg->IdleLevel));
- assert_param(IS_HRTIM_OUTPUTIDLEMODE(pOutputCfg->IdleMode));
- assert_param(IS_HRTIM_OUTPUTFAULTLEVEL(pOutputCfg->FaultLevel));
- assert_param(IS_HRTIM_OUTPUTCHOPPERMODE(pOutputCfg->ChopperModeEnable));
- assert_param(IS_HRTIM_OUTPUTBURSTMODEENTRY(pOutputCfg->BurstModeEntryDelayed));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Configure the timer output */
- HRTIM_OutputConfig(hhrtim,
- TimerIdx,
- Output,
- pOutputCfg);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Force the timer output to its active or inactive state
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Output Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @param OutputLevel indicates whether the output is forced to its active or inactive level
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUTLEVEL_ACTIVE: output is forced to its active level
- * @arg HRTIM_OUTPUTLEVEL_INACTIVE: output is forced to its inactive level
- * @retval HAL status
- * @note The 'software set/reset trigger' bit in the output set/reset registers
- * is automatically reset by hardware
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformSetOutputLevel(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output,
- uint32_t OutputLevel)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
- assert_param(IS_HRTIM_OUTPUTLEVEL(OutputLevel));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Force timer output level */
- switch (Output)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
- {
- /* Force output to its active state */
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R,HRTIM_SET1R_SST);
- }
- else
- {
- /* Force output to its inactive state */
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R, HRTIM_RST1R_SRT);
- }
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- if (OutputLevel == HRTIM_OUTPUTLEVEL_ACTIVE)
- {
- /* Force output to its active state */
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R, HRTIM_SET2R_SST);
- }
- else
- {
- /* Force output to its inactive state */
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R, HRTIM_RST2R_SRT);
- }
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable the generation of the waveform signal on the designated output(s)
- * Outputs can be combined (ORed) to allow for simultaneous output enabling.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param OutputsToStart Timer output(s) to enable
- * This parameter can be any combination of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t OutputsToStart)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_OUTPUT(OutputsToStart));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the HRTIM outputs */
- hhrtim->Instance->sCommonRegs.OENR |= (OutputsToStart);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable the generation of the waveform signal on the designated output(s)
- * Outputs can be combined (ORed) to allow for simultaneous output disabling.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param OutputsToStop Timer output(s) to disable
- * This parameter can be any combination of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformOutputStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t OutputsToStop)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_OUTPUT(OutputsToStop));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable the HRTIM outputs */
- hhrtim->Instance->sCommonRegs.ODISR |= (OutputsToStop);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter start.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to start
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable timer(s) counter */
- hhrtim->Instance->sMasterRegs.MCR |= (Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter stop.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to stop
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @retval HAL status
- * @note The counter of a timer is stopped only if all timer outputs are disabled
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable timer(s) counter */
- hhrtim->Instance->sMasterRegs.MCR &= ~(Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter start.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to start
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @note HRTIM interrupts (e.g. faults interrupts) and interrupts related
- * to the timers to start are enabled within this function.
- * Interrupts to enable are selected through HAL_HRTIM_WaveformTimerConfig
- * function.
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- uint8_t timer_idx;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable HRTIM interrupts (if required) */
- __HAL_HRTIM_ENABLE_IT(hhrtim, hhrtim->Init.HRTIMInterruptResquests);
- /* Enable master timer related interrupts (if required) */
- if ((Timers & HRTIM_TIMERID_MASTER) != 0U)
- {
- __HAL_HRTIM_MASTER_ENABLE_IT(hhrtim,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].InterruptRequests);
- }
- /* Enable timing unit related interrupts (if required) */
- for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
- timer_idx < HRTIM_TIMERINDEX_MASTER ;
- timer_idx++)
- {
- if ((Timers & TimerIdxToTimerId[timer_idx]) != 0U)
- {
- __HAL_HRTIM_TIMER_ENABLE_IT(hhrtim,
- timer_idx,
- hhrtim->TimerParam[timer_idx].InterruptRequests);
- }
- }
- /* Enable timer(s) counter */
- hhrtim->Instance->sMasterRegs.MCR |= (Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;}
- /**
- * @brief Stop the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter stop.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to stop
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @retval HAL status
- * @note The counter of a timer is stopped only if all timer outputs are disabled
- * @note All enabled timer related interrupts are disabled.
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop_IT(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- /* ++ WA */
- __IO uint32_t delai = (uint32_t)(0x17FU);
- /* -- WA */
- uint8_t timer_idx;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Disable HRTIM interrupts (if required) */
- __HAL_HRTIM_DISABLE_IT(hhrtim, hhrtim->Init.HRTIMInterruptResquests);
- /* Disable master timer related interrupts (if required) */
- if ((Timers & HRTIM_TIMERID_MASTER) != 0U)
- {
- /* Interrupts enable flag must be cleared one by one */
- __HAL_HRTIM_MASTER_DISABLE_IT(hhrtim, hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].InterruptRequests);
- }
- /* Disable timing unit related interrupts (if required) */
- for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
- timer_idx < HRTIM_TIMERINDEX_MASTER ;
- timer_idx++)
- {
- if ((Timers & TimerIdxToTimerId[timer_idx]) != 0U)
- {
- __HAL_HRTIM_TIMER_DISABLE_IT(hhrtim, timer_idx, hhrtim->TimerParam[timer_idx].InterruptRequests);
- }
- }
- /* ++ WA */
- do { delai--; } while (delai != 0U);
- /* -- WA */
- /* Disable timer(s) counter */
- hhrtim->Instance->sMasterRegs.MCR &= ~(Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter start.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to start
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @retval HAL status
- * @note This function enables the dma request(s) mentioned in the timer
- * configuration data structure for every timers to start.
- * @note The source memory address, the destination memory address and the
- * size of each DMA transfer are specified at timer configuration time
- * (see HAL_HRTIM_WaveformTimerConfig)
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- uint8_t timer_idx;
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- if (((Timers & HRTIM_TIMERID_MASTER) != (uint32_t)RESET) &&
- (hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests != 0U))
- {
- /* Set the DMA error callback */
- hhrtim->hdmaMaster->XferErrorCallback = HRTIM_DMAError ;
- /* Set the DMA transfer completed callback */
- hhrtim->hdmaMaster->XferCpltCallback = HRTIM_DMAMasterCplt;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hhrtim->hdmaMaster,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMASrcAddress,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMADstAddress,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMASize) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Enable the timer DMA request */
- __HAL_HRTIM_MASTER_ENABLE_DMA(hhrtim,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests);
- }
- for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
- timer_idx < HRTIM_TIMERINDEX_MASTER ;
- timer_idx++)
- {
- if (((Timers & TimerIdxToTimerId[timer_idx]) != (uint32_t)RESET) &&
- (hhrtim->TimerParam[timer_idx].DMARequests != 0U))
- {
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, timer_idx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Set the DMA transfer completed callback */
- hdma->XferCpltCallback = HRTIM_DMATimerxCplt;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma,
- hhrtim->TimerParam[timer_idx].DMASrcAddress,
- hhrtim->TimerParam[timer_idx].DMADstAddress,
- hhrtim->TimerParam[timer_idx].DMASize) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Enable the timer DMA request */
- __HAL_HRTIM_TIMER_ENABLE_DMA(hhrtim,
- timer_idx,
- hhrtim->TimerParam[timer_idx].DMARequests);
- }
- }
- /* Enable the timer counter */
- __HAL_HRTIM_ENABLE(hhrtim, Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Stop the counter of the designated timer(s) operating in waveform mode
- * Timers can be combined (ORed) to allow for simultaneous counter stop.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer counter(s) to stop
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERID_MASTER
- * @arg HRTIM_TIMERID_TIMER_A
- * @arg HRTIM_TIMERID_TIMER_B
- * @arg HRTIM_TIMERID_TIMER_C
- * @arg HRTIM_TIMERID_TIMER_D
- * @arg HRTIM_TIMERID_TIMER_E
- * @retval HAL status
- * @note The counter of a timer is stopped only if all timer outputs are disabled
- * @note All enabled timer related DMA requests are disabled.
- */
- HAL_StatusTypeDef HAL_HRTIM_WaveformCountStop_DMA(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- uint8_t timer_idx;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERID(Timers));
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- if (((Timers & HRTIM_TIMERID_MASTER) != 0U) &&
- (hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests != 0U))
- {
- /* Disable the DMA */
- if (HAL_DMA_Abort(hhrtim->hdmaMaster) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Disable the DMA request(s) */
- __HAL_HRTIM_MASTER_DISABLE_DMA(hhrtim,
- hhrtim->TimerParam[HRTIM_TIMERINDEX_MASTER].DMARequests);
- }
- }
- for (timer_idx = HRTIM_TIMERINDEX_TIMER_A ;
- timer_idx < HRTIM_TIMERINDEX_MASTER ;
- timer_idx++)
- {
- if (((Timers & TimerIdxToTimerId[timer_idx]) != 0U) &&
- (hhrtim->TimerParam[timer_idx].DMARequests != 0U))
- {
- /* Get the timer DMA handler */
- /* Disable the DMA */
- if (HAL_DMA_Abort(HRTIM_GetDMAHandleFromTimerIdx(hhrtim, timer_idx)) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Disable the DMA request(s) */
- __HAL_HRTIM_TIMER_DISABLE_DMA(hhrtim,
- timer_idx,
- hhrtim->TimerParam[timer_idx].DMARequests);
- }
- }
- }
- /* Disable the timer counter */
- __HAL_HRTIM_DISABLE(hhrtim, Timers);
- if (hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- else
- {
- return HAL_OK;
- }
- }
- /**
- * @brief Enable or disables the HRTIM burst mode controller.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Enable Burst mode controller enabling
- * This parameter can be one of the following values:
- * @arg HRTIM_BURSTMODECTL_ENABLED: Burst mode enabled
- * @arg HRTIM_BURSTMODECTL_DISABLED: Burst mode disabled
- * @retval HAL status
- * @note This function must be called after starting the timer(s)
- */
- HAL_StatusTypeDef HAL_HRTIM_BurstModeCtl(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Enable)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_BURSTMODECTL(Enable));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable/Disable the burst mode controller */
- MODIFY_REG(hhrtim->Instance->sCommonRegs.BMCR, HRTIM_BMCR_BME, Enable);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Trig the burst mode operation.
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_BurstModeSoftwareTrigger(HRTIM_HandleTypeDef *hhrtim)
- {
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Software trigger of the burst mode controller */
- SET_BIT(hhrtim->Instance->sCommonRegs.BMTRGR, HRTIM_BMTRGR_SW);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Trig a software capture on the designed capture unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureUnit Capture unit to trig
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval HAL status
- * @note The 'software capture' bit in the capure configuration register is
- * automatically reset by hardware
- */
- HAL_StatusTypeDef HAL_HRTIM_SoftwareCapture(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureUnit)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Force a software capture on concerned capture unit */
- switch (CaptureUnit)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xCR, HRTIM_CPT1CR_SWCPT);
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- SET_BIT(hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xCR, HRTIM_CPT2CR_SWCPT);
- break;
- }
- default:
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- break;
- }
- }
- if(hhrtim->State == HAL_HRTIM_STATE_ERROR)
- {
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Trig the update of the registers of one or several timers
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers timers concerned with the software register update
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERUPDATE_MASTER
- * @arg HRTIM_TIMERUPDATE_A
- * @arg HRTIM_TIMERUPDATE_B
- * @arg HRTIM_TIMERUPDATE_C
- * @arg HRTIM_TIMERUPDATE_D
- * @arg HRTIM_TIMERUPDATE_E
- * @retval HAL status
- * @note The 'software update' bits in the HRTIM control register 2 register are
- * automatically reset by hardware
- */
- HAL_StatusTypeDef HAL_HRTIM_SoftwareUpdate(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMERUPDATE(Timers));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Force timer(s) registers update */
- hhrtim->Instance->sCommonRegs.CR2 |= Timers;
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Trig the reset of one or several timers
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers timers concerned with the software counter reset
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERRESET_MASTER
- * @arg HRTIM_TIMERRESET_TIMER_A
- * @arg HRTIM_TIMERRESET_TIMER_B
- * @arg HRTIM_TIMERRESET_TIMER_C
- * @arg HRTIM_TIMERRESET_TIMER_D
- * @arg HRTIM_TIMERRESET_TIMER_E
- * @retval HAL status
- * @note The 'software reset' bits in the HRTIM control register 2 are
- * automatically reset by hardware
- */
- HAL_StatusTypeDef HAL_HRTIM_SoftwareReset(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Timers)
- {
- /* Check parameters */
- assert_param(IS_HRTIM_TIMERRESET(Timers));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Force timer(s) registers reset */
- hhrtim->Instance->sCommonRegs.CR2 = Timers;
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Start a burst DMA operation to update HRTIM control registers content
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param BurstBufferAddress address of the buffer the HRTIM control registers
- * content will be updated from.
- * @param BurstBufferLength size (in WORDS) of the burst buffer.
- * @retval HAL status
- * @note The TimerIdx parameter determines the dma channel to be used by the
- * DMA burst controller (see below)
- * HRTIM_TIMERINDEX_MASTER: DMA channel 2 is used by the DMA burst controller
- * HRTIM_TIMERINDEX_TIMER_A: DMA channel 3 is used by the DMA burst controller
- * HRTIM_TIMERINDEX_TIMER_B: DMA channel 4 is used by the DMA burst controller
- * HRTIM_TIMERINDEX_TIMER_C: DMA channel 5 is used by the DMA burst controller
- * HRTIM_TIMERINDEX_TIMER_D: DMA channel 6 is used by the DMA burst controller
- * HRTIM_TIMERINDEX_TIMER_E: DMA channel 7 is used by the DMA burst controller
- */
- HAL_StatusTypeDef HAL_HRTIM_BurstDMATransfer(HRTIM_HandleTypeDef *hhrtim,
- uint32_t TimerIdx,
- uint32_t BurstBufferAddress,
- uint32_t BurstBufferLength)
- {
- DMA_HandleTypeDef * hdma;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERINDEX(TimerIdx));
- if(hhrtim->State == HAL_HRTIM_STATE_BUSY)
- {
- return HAL_BUSY;
- }
- if(hhrtim->State == HAL_HRTIM_STATE_READY)
- {
- if((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U))
- {
- return HAL_ERROR;
- }
- else
- {
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- }
- }
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- /* Get the timer DMA handler */
- hdma = HRTIM_GetDMAHandleFromTimerIdx(hhrtim, TimerIdx);
- if (hdma == NULL)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- /* Set the DMA transfer completed callback */
- hdma->XferCpltCallback = HRTIM_BurstDMACplt;
- /* Set the DMA error callback */
- hdma->XferErrorCallback = HRTIM_DMAError ;
- /* Enable the DMA channel */
- if (HAL_DMA_Start_IT(hdma,
- BurstBufferAddress,
- (uint32_t)&(hhrtim->Instance->sCommonRegs.BDMADR),
- BurstBufferLength) != HAL_OK)
- {
- hhrtim->State = HAL_HRTIM_STATE_ERROR;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_ERROR;
- }
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Enable the transfer from preload to active registers for one
- * or several timing units (including master timer).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer(s) concerned by the register preload enabling command
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERUPDATE_MASTER
- * @arg HRTIM_TIMERUPDATE_A
- * @arg HRTIM_TIMERUPDATE_B
- * @arg HRTIM_TIMERUPDATE_C
- * @arg HRTIM_TIMERUPDATE_D
- * @arg HRTIM_TIMERUPDATE_E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_UpdateEnable(HRTIM_HandleTypeDef *hhrtim,
- uint32_t Timers)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERUPDATE(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable timer(s) registers update */
- hhrtim->Instance->sCommonRegs.CR1 &= ~(Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @brief Disable the transfer from preload to active registers for one
- * or several timing units (including master timer).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Timers Timer(s) concerned by the register preload disabling command
- * This parameter can be any combination of the following values:
- * @arg HRTIM_TIMERUPDATE_MASTER
- * @arg HRTIM_TIMERUPDATE_A
- * @arg HRTIM_TIMERUPDATE_B
- * @arg HRTIM_TIMERUPDATE_C
- * @arg HRTIM_TIMERUPDATE_D
- * @arg HRTIM_TIMERUPDATE_E
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_UpdateDisable(HRTIM_HandleTypeDef *hhrtim,
- uint32_t Timers)
- {
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMERUPDATE(Timers));
- /* Process Locked */
- __HAL_LOCK(hhrtim);
- hhrtim->State = HAL_HRTIM_STATE_BUSY;
- /* Enable timer(s) registers update */
- hhrtim->Instance->sCommonRegs.CR1 |= (Timers);
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process Unlocked */
- __HAL_UNLOCK(hhrtim);
- return HAL_OK;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group9 Peripheral state functions
- * @brief Peripheral State functions
- @verbatim
- ===============================================================================
- ##### Peripheral State functions #####
- ===============================================================================
- [..] This section provides functions used to get HRTIM or HRTIM timer
- specific information:
- (+) Get HRTIM HAL state
- (+) Get captured value
- (+) Get HRTIM timer output level
- (+) Get HRTIM timer output state
- (+) Get delayed protection status
- (+) Get burst status
- (+) Get current push-pull status
- (+) Get idle push-pull status
- @endverbatim
- * @{
- */
- /**
- * @brief Return the HRTIM HAL state
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval HAL state
- */
- HAL_HRTIM_StateTypeDef HAL_HRTIM_GetState(const HRTIM_HandleTypeDef* hhrtim)
- {
- /* Return HRTIM state */
- return hhrtim->State;
- }
- /**
- * @brief Return actual value of the capture register of the designated capture unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param CaptureUnit Capture unit to trig
- * This parameter can be one of the following values:
- * @arg HRTIM_CAPTUREUNIT_1: Capture unit 1
- * @arg HRTIM_CAPTUREUNIT_2: Capture unit 2
- * @retval Captured value
- */
- uint32_t HAL_HRTIM_GetCapturedValue(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureUnit)
- {
- uint32_t captured_value;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- assert_param(IS_HRTIM_CAPTUREUNIT(CaptureUnit));
- /* Read captured value */
- switch (CaptureUnit)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- captured_value = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT1xR;
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- captured_value = hhrtim->Instance->sTimerxRegs[TimerIdx].CPT2xR;
- break;
- }
- default:
- {
- captured_value = 0xFFFFFFFFUL;
- break;
- }
- }
- return captured_value;
- }
- /**
- * @brief Return actual level (active or inactive) of the designated output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Output Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval Output level
- * @note Returned output level is taken before the output stage (chopper,
- * polarity).
- */
- uint32_t HAL_HRTIM_WaveformGetOutputLevel(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output)
- {
- uint32_t output_level;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
- /* Read the output level */
- switch (Output)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O1CPY) != (uint32_t)RESET)
- {
- output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
- }
- else
- {
- output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
- }
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O2CPY) != (uint32_t)RESET)
- {
- output_level = HRTIM_OUTPUTLEVEL_ACTIVE;
- }
- else
- {
- output_level = HRTIM_OUTPUTLEVEL_INACTIVE;
- }
- break;
- }
- default:
- {
- output_level = 0xFFFFFFFFUL;
- break;
- }
- }
- return output_level;
- }
- /**
- * @brief Return actual state (RUN, IDLE, FAULT) of the designated output
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Output Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval Output state
- */
- uint32_t HAL_HRTIM_WaveformGetOutputState(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output)
- {
- uint32_t output_bit;
- uint32_t output_state;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
- /* Prevent unused argument(s) compilation warning */
- UNUSED(TimerIdx);
- /* Set output state according to output control status and output disable status */
- switch (Output)
- {
- case HRTIM_OUTPUT_TA1:
- {
- output_bit = HRTIM_OENR_TA1OEN;
- break;
- }
- case HRTIM_OUTPUT_TA2:
- {
- output_bit = HRTIM_OENR_TA2OEN;
- break;
- }
- case HRTIM_OUTPUT_TB1:
- {
- output_bit = HRTIM_OENR_TB1OEN;
- break;
- }
- case HRTIM_OUTPUT_TB2:
- {
- output_bit = HRTIM_OENR_TB2OEN;
- break;
- }
- case HRTIM_OUTPUT_TC1:
- {
- output_bit = HRTIM_OENR_TC1OEN;
- break;
- }
- case HRTIM_OUTPUT_TC2:
- {
- output_bit = HRTIM_OENR_TC2OEN;
- break;
- }
- case HRTIM_OUTPUT_TD1:
- {
- output_bit = HRTIM_OENR_TD1OEN;
- break;
- }
- case HRTIM_OUTPUT_TD2:
- {
- output_bit = HRTIM_OENR_TD2OEN;
- break;
- }
- case HRTIM_OUTPUT_TE1:
- {
- output_bit = HRTIM_OENR_TE1OEN;
- break;
- }
- case HRTIM_OUTPUT_TE2:
- {
- output_bit = HRTIM_OENR_TE2OEN;
- break;
- }
- default:
- {
- output_bit = 0UL;
- break;
- }
- }
- if ((hhrtim->Instance->sCommonRegs.OENR & output_bit) != (uint32_t)RESET)
- {
- /* Output is enabled: output in RUN state (whatever output disable status is)*/
- output_state = HRTIM_OUTPUTSTATE_RUN;
- }
- else
- {
- if ((hhrtim->Instance->sCommonRegs.ODSR & output_bit) != (uint32_t)RESET)
- {
- /* Output is disabled: output in FAULT state */
- output_state = HRTIM_OUTPUTSTATE_FAULT;
- }
- else
- {
- /* Output is disabled: output in IDLE state */
- output_state = HRTIM_OUTPUTSTATE_IDLE;
- }
- }
- return(output_state);
- }
- /**
- * @brief Return the level (active or inactive) of the designated output
- * when the delayed protection was triggered.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @param Output Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval Delayed protection status
- */
- uint32_t HAL_HRTIM_GetDelayedProtectionStatus(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output)
- {
- uint32_t delayed_protection_status;
- /* Check parameters */
- assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, Output));
- /* Read the delayed protection status */
- switch (Output)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O1STAT) != (uint32_t)RESET)
- {
- /* Output 1 was active when the delayed idle protection was triggered */
- delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
- }
- else
- {
- /* Output 1 was inactive when the delayed idle protection was triggered */
- delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
- }
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- if ((hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_O2STAT) != (uint32_t)RESET)
- {
- /* Output 2 was active when the delayed idle protection was triggered */
- delayed_protection_status = HRTIM_OUTPUTLEVEL_ACTIVE;
- }
- else
- {
- /* Output 2 was inactive when the delayed idle protection was triggered */
- delayed_protection_status = HRTIM_OUTPUTLEVEL_INACTIVE;
- }
- break;
- }
- default:
- {
- delayed_protection_status = 0xFFFFFFFFUL;
- break;
- }
- }
- return delayed_protection_status;
- }
- /**
- * @brief Return the actual status (active or inactive) of the burst mode controller
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval Burst mode controller status
- */
- uint32_t HAL_HRTIM_GetBurstStatus(const HRTIM_HandleTypeDef * hhrtim)
- {
- uint32_t burst_mode_status;
- /* Read burst mode status */
- burst_mode_status = (hhrtim->Instance->sCommonRegs.BMCR & HRTIM_BMCR_BMSTAT);
- return burst_mode_status;
- }
- /**
- * @brief Indicate on which output the signal is currently active (when the
- * push pull mode is enabled).
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval Burst mode controller status
- */
- uint32_t HAL_HRTIM_GetCurrentPushPullStatus(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- uint32_t current_pushpull_status;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- /* Read current push pull status */
- current_pushpull_status = (hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_CPPSTAT);
- return current_pushpull_status;
- }
- /**
- * @brief Indicate on which output the signal was applied, in push-pull mode,
- balanced fault mode or delayed idle mode, when the protection was triggered.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval Idle Push Pull Status
- */
- uint32_t HAL_HRTIM_GetIdlePushPullStatus(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- uint32_t idle_pushpull_status;
- /* Check the parameters */
- assert_param(IS_HRTIM_TIMING_UNIT(TimerIdx));
- /* Read current push pull status */
- idle_pushpull_status = (hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR & HRTIM_TIMISR_IPPSTAT);
- return idle_pushpull_status;
- }
- /**
- * @}
- */
- /** @defgroup HRTIM_Exported_Functions_Group10 Interrupts handling
- * @brief Functions called when HRTIM generates an interrupt
- * 7 interrupts can be generated by the master timer:
- * - Master timer registers update
- * - Synchronization event received
- * - Master timer repetition event
- * - Master Compare 1 to 4 event
- * 14 interrupts can be generated by each timing unit:
- * - Delayed protection triggered
- * - Counter reset or roll-over event
- * - Output 1 and output 2 reset (transition active to inactive)
- * - Output 1 and output 2 set (transition inactive to active)
- * - Capture 1 and 2 events
- * - Timing unit registers update
- * - Repetition event
- * - Compare 1 to 4 event
- * 8 global interrupts are generated for the whole HRTIM:
- * - System fault and Fault 1 to 5 (regardless of the timing unit attribution)
- * - DLL calibration done
- * - Burst mode period completed
- @verbatim
- ===============================================================================
- ##### HRTIM interrupts handling #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to manage the HRTIM
- interrupts:
- (+) HRTIM interrupt handler
- (+) Callback function called when Fault1 interrupt occurs
- (+) Callback function called when Fault2 interrupt occurs
- (+) Callback function called when Fault3 interrupt occurs
- (+) Callback function called when Fault4 interrupt occurs
- (+) Callback function called when Fault5 interrupt occurs
- (+) Callback function called when system Fault interrupt occurs
- (+) Callback function called when DLL ready interrupt occurs
- (+) Callback function called when burst mode period interrupt occurs
- (+) Callback function called when synchronization input interrupt occurs
- (+) Callback function called when a timer register update interrupt occurs
- (+) Callback function called when a timer repetition interrupt occurs
- (+) Callback function called when a compare 1 match interrupt occurs
- (+) Callback function called when a compare 2 match interrupt occurs
- (+) Callback function called when a compare 3 match interrupt occurs
- (+) Callback function called when a compare 4 match interrupt occurs
- (+) Callback function called when a capture 1 interrupt occurs
- (+) Callback function called when a capture 2 interrupt occurs
- (+) Callback function called when a delayed protection interrupt occurs
- (+) Callback function called when a timer counter reset interrupt occurs
- (+) Callback function called when a timer output 1 set interrupt occurs
- (+) Callback function called when a timer output 1 reset interrupt occurs
- (+) Callback function called when a timer output 2 set interrupt occurs
- (+) Callback function called when a timer output 2 reset interrupt occurs
- (+) Callback function called when a timer output 2 reset interrupt occurs
- (+) Callback function called upon completion of a burst DMA transfer
- (+) HRTIM callback function registration
- (+) HRTIM callback function unregistration
- (+) HRTIM Timer x callback function registration
- (+) HRTIM Timer x callback function unregistration
- @endverbatim
- * @{
- */
- /**
- * @brief This function handles HRTIM interrupt request.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be any value of HRTIM_Timer_Index
- * @retval None
- */
- void HAL_HRTIM_IRQHandler(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* HRTIM interrupts handling */
- if (TimerIdx == HRTIM_TIMERINDEX_COMMON)
- {
- HRTIM_HRTIM_ISR(hhrtim);
- }
- else if (TimerIdx == HRTIM_TIMERINDEX_MASTER)
- {
- /* Master related interrupts handling */
- HRTIM_Master_ISR(hhrtim);
- }
- else
- {
- /* Timing unit related interrupts handling */
- HRTIM_Timer_ISR(hhrtim, TimerIdx);
- }
- }
- /**
- * @brief Callback function invoked when a fault 1 interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle * @retval None
- * @retval None
- */
- __weak void HAL_HRTIM_Fault1Callback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Fault1Callback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a fault 2 interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_Fault2Callback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Fault2Callback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a fault 3 interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_Fault3Callback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Fault3Callback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a fault 4 interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_Fault4Callback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Fault4Callback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a fault 5 interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_Fault5Callback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Fault5Callback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a system fault interrupt occurred
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_SystemFaultCallback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_SystemFaultCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the DLL calibration is completed
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_DLLCalibrationReadyCallback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_DLLCalibrationCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the end of the burst mode period is reached
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_BurstModePeriodCallback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_BurstModeCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a synchronization input event is received
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_SynchronizationEventCallback(HRTIM_HandleTypeDef * hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_SynchronizationEventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when timer registers are updated
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_RegistersUpdateCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_RegistersUpdateCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when timer repetition period has elapsed
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_RepetitionEventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_RepetitionEventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer counter matches the value
- * programmed in the compare 1 register
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Compare1EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_Compare1EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer counter matches the value
- * programmed in the compare 2 register
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- */
- __weak void HAL_HRTIM_Compare2EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_Compare2EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer counter matches the value
- * programmed in the compare 3 register
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Compare3EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_Compare3EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer counter matches the value
- * programmed in the compare 4 register.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Compare4EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Master_Compare4EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x capture 1 event occurs
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Capture1EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Capture1EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x capture 2 event occurs
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Capture2EventCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Capture2EventCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the delayed idle or balanced idle mode is
- * entered.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_DelayedProtectionCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_DelayedProtectionCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x counter reset/roll-over
- * event occurs.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_CounterResetCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_CounterResetCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x output 1 is set
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Output1SetCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Output1SetCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x output 1 is reset
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Output1ResetCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Output1ResetCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x output 2 is set
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Output2SetCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Output2SetCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when the timer x output 2 is reset
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_Output2ResetCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_Timer_Output2ResetCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a DMA burst transfer is completed
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_MASTER for master timer
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- __weak void HAL_HRTIM_BurstDMATransferCallback(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- UNUSED(TimerIdx);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_BurstDMATransferCallback could be implemented in the user file
- */
- }
- /**
- * @brief Callback function invoked when a DMA error occurs
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- __weak void HAL_HRTIM_ErrorCallback(HRTIM_HandleTypeDef *hhrtim)
- {
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hhrtim);
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_HRTIM_ErrorCallback could be implemented in the user file
- */
- }
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- /**
- * @brief HRTIM callback function registration
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CallbackID ID of the HRTIM callback function to register
- * This parameter can be one of the following values:
- * @arg HAL_HRTIM_FAULT1CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT2CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT3CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT4CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT5CALLBACK_CB_ID
- * @arg HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID
- * @arg HAL_HRTIM_DLLCALBRATIONREADYCALLBACK_CB_ID
- * @arg HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID
- * @arg HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_ERRORCALLBACK_CB_ID
- * @arg HAL_HRTIM_MSPINIT_CB_ID
- * @arg HAL_HRTIM_MSPDEINIT_CB_ID
- * @param pCallback Callback function pointer
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_RegisterCallback(HRTIM_HandleTypeDef * hhrtim,
- HAL_HRTIM_CallbackIDTypeDef CallbackID,
- pHRTIM_CallbackTypeDef pCallback)
- {
- HAL_StatusTypeDef status = HAL_OK;
- if (pCallback == NULL)
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- return HAL_ERROR;
- }
- /* Process locked */
- __HAL_LOCK(hhrtim);
- if (HAL_HRTIM_STATE_READY == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_FAULT1CALLBACK_CB_ID :
- hhrtim->Fault1Callback = pCallback;
- break;
- case HAL_HRTIM_FAULT2CALLBACK_CB_ID :
- hhrtim->Fault2Callback = pCallback;
- break;
- case HAL_HRTIM_FAULT3CALLBACK_CB_ID :
- hhrtim->Fault3Callback = pCallback;
- break;
- case HAL_HRTIM_FAULT4CALLBACK_CB_ID :
- hhrtim->Fault4Callback = pCallback;
- break;
- case HAL_HRTIM_FAULT5CALLBACK_CB_ID :
- hhrtim->Fault5Callback = pCallback;
- break;
- case HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID :
- hhrtim->SystemFaultCallback = pCallback;
- break;
- case HAL_HRTIM_DLLCALBRATIONREADYCALLBACK_CB_ID :
- hhrtim->DLLCalibrationReadyCallback = pCallback;
- break;
- case HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID :
- hhrtim->BurstModePeriodCallback = pCallback;
- break;
- case HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID :
- hhrtim->SynchronizationEventCallback = pCallback;
- break;
- case HAL_HRTIM_ERRORCALLBACK_CB_ID :
- hhrtim->ErrorCallback = pCallback;
- break;
- case HAL_HRTIM_MSPINIT_CB_ID :
- hhrtim->MspInitCallback = pCallback;
- break;
- case HAL_HRTIM_MSPDEINIT_CB_ID :
- hhrtim->MspDeInitCallback = pCallback;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_HRTIM_STATE_RESET == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_MSPINIT_CB_ID :
- hhrtim->MspInitCallback = pCallback;
- break;
- case HAL_HRTIM_MSPDEINIT_CB_ID :
- hhrtim->MspDeInitCallback = pCallback;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
- /* Release Lock */
- __HAL_UNLOCK(hhrtim);
- return status;
- }
- /**
- * @brief HRTIM callback function un-registration
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CallbackID ID of the HRTIM callback function to unregister
- * This parameter can be one of the following values:
- * @arg HAL_HRTIM_FAULT1CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT2CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT3CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT4CALLBACK_CB_ID
- * @arg HAL_HRTIM_FAULT5CALLBACK_CB_ID
- * @arg HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID
- * @arg HAL_HRTIM_DLLCALBRATIONREADYCALLBACK_CB_ID
- * @arg HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID
- * @arg HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_ERRORCALLBACK_CB_ID
- * @arg HAL_HRTIM_MSPINIT_CB_ID
- * @arg HAL_HRTIM_MSPDEINIT_CB_ID
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_UnRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
- HAL_HRTIM_CallbackIDTypeDef CallbackID)
- {
- HAL_StatusTypeDef status = HAL_OK;
- /* Process locked */
- __HAL_LOCK(hhrtim);
- if (HAL_HRTIM_STATE_READY == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_FAULT1CALLBACK_CB_ID :
- hhrtim->Fault1Callback = HAL_HRTIM_Fault1Callback;
- break;
- case HAL_HRTIM_FAULT2CALLBACK_CB_ID :
- hhrtim->Fault2Callback = HAL_HRTIM_Fault2Callback;
- break;
- case HAL_HRTIM_FAULT3CALLBACK_CB_ID :
- hhrtim->Fault3Callback = HAL_HRTIM_Fault3Callback;
- break;
- case HAL_HRTIM_FAULT4CALLBACK_CB_ID :
- hhrtim->Fault4Callback = HAL_HRTIM_Fault4Callback;
- break;
- case HAL_HRTIM_FAULT5CALLBACK_CB_ID :
- hhrtim->Fault5Callback = HAL_HRTIM_Fault5Callback;
- break;
- case HAL_HRTIM_SYSTEMFAULTCALLBACK_CB_ID :
- hhrtim->SystemFaultCallback = HAL_HRTIM_SystemFaultCallback;
- break;
- case HAL_HRTIM_DLLCALBRATIONREADYCALLBACK_CB_ID :
- hhrtim->DLLCalibrationReadyCallback = HAL_HRTIM_DLLCalibrationReadyCallback;
- break;
- case HAL_HRTIM_BURSTMODEPERIODCALLBACK_CB_ID :
- hhrtim->BurstModePeriodCallback = HAL_HRTIM_BurstModePeriodCallback;
- break;
- case HAL_HRTIM_SYNCHRONIZATIONEVENTCALLBACK_CB_ID :
- hhrtim->SynchronizationEventCallback = HAL_HRTIM_SynchronizationEventCallback;
- break;
- case HAL_HRTIM_ERRORCALLBACK_CB_ID :
- hhrtim->ErrorCallback = HAL_HRTIM_ErrorCallback;
- break;
- case HAL_HRTIM_MSPINIT_CB_ID :
- hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
- break;
- case HAL_HRTIM_MSPDEINIT_CB_ID :
- hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_HRTIM_STATE_RESET == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_MSPINIT_CB_ID :
- hhrtim->MspInitCallback = HAL_HRTIM_MspInit;
- break;
- case HAL_HRTIM_MSPDEINIT_CB_ID :
- hhrtim->MspDeInitCallback = HAL_HRTIM_MspDeInit;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
- /* Release Lock */
- __HAL_UNLOCK(hhrtim);
- return status;
- }
- /**
- * @brief HRTIM Timer x callback function registration
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CallbackID ID of the HRTIM Timer x callback function to register
- * This parameter can be one of the following values:
- * @arg HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID
- * @arg HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID
- * @arg HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID
- * @param pCallback Callback function pointer
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_TIMxRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
- HAL_HRTIM_CallbackIDTypeDef CallbackID,
- pHRTIM_TIMxCallbackTypeDef pCallback)
- {
- HAL_StatusTypeDef status = HAL_OK;
- if (pCallback == NULL)
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- return HAL_ERROR;
- }
- /* Process locked */
- __HAL_LOCK(hhrtim);
- if (HAL_HRTIM_STATE_READY == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID :
- hhrtim->RegistersUpdateCallback = pCallback;
- break;
- case HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID :
- hhrtim->RepetitionEventCallback = pCallback;
- break;
- case HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID :
- hhrtim->Compare1EventCallback = pCallback;
- break;
- case HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID :
- hhrtim->Compare2EventCallback = pCallback;
- break;
- case HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID :
- hhrtim->Compare3EventCallback = pCallback;
- break;
- case HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID :
- hhrtim->Compare4EventCallback = pCallback;
- break;
- case HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID :
- hhrtim->Capture1EventCallback = pCallback;
- break;
- case HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID :
- hhrtim->Capture2EventCallback = pCallback;
- break;
- case HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID :
- hhrtim->DelayedProtectionCallback = pCallback;
- break;
- case HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID :
- hhrtim->CounterResetCallback = pCallback;
- break;
- case HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID :
- hhrtim->Output1SetCallback = pCallback;
- break;
- case HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID :
- hhrtim->Output1ResetCallback = pCallback;
- break;
- case HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID :
- hhrtim->Output2SetCallback = pCallback;
- break;
- case HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID :
- hhrtim->Output2ResetCallback = pCallback;
- break;
- case HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID :
- hhrtim->BurstDMATransferCallback = pCallback;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
- /* Release Lock */
- __HAL_UNLOCK(hhrtim);
- return status;
- }
- /**
- * @brief HRTIM Timer x callback function un-registration
- * @param hhrtim pointer to HAL HRTIM handle
- * @param CallbackID ID of the HRTIM callback Timer x function to unregister
- * This parameter can be one of the following values:
- * @arg HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID
- * @arg HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID
- * @arg HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID
- * @arg HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID
- * @arg HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID
- * @arg HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID
- * @retval HAL status
- */
- HAL_StatusTypeDef HAL_HRTIM_TIMxUnRegisterCallback(HRTIM_HandleTypeDef * hhrtim,
- HAL_HRTIM_CallbackIDTypeDef CallbackID)
- {
- HAL_StatusTypeDef status = HAL_OK;
- /* Process locked */
- __HAL_LOCK(hhrtim);
- if (HAL_HRTIM_STATE_READY == hhrtim->State)
- {
- switch (CallbackID)
- {
- case HAL_HRTIM_REGISTERSUPDATECALLBACK_CB_ID :
- hhrtim->RegistersUpdateCallback = HAL_HRTIM_RegistersUpdateCallback;
- break;
- case HAL_HRTIM_REPETITIONEVENTCALLBACK_CB_ID :
- hhrtim->RepetitionEventCallback = HAL_HRTIM_RepetitionEventCallback;
- break;
- case HAL_HRTIM_COMPARE1EVENTCALLBACK_CB_ID :
- hhrtim->Compare1EventCallback = HAL_HRTIM_Compare1EventCallback;
- break;
- case HAL_HRTIM_COMPARE2EVENTCALLBACK_CB_ID :
- hhrtim->Compare2EventCallback = HAL_HRTIM_Compare2EventCallback;
- break;
- case HAL_HRTIM_COMPARE3EVENTCALLBACK_CB_ID :
- hhrtim->Compare3EventCallback = HAL_HRTIM_Compare3EventCallback;
- break;
- case HAL_HRTIM_COMPARE4EVENTCALLBACK_CB_ID :
- hhrtim->Compare4EventCallback = HAL_HRTIM_Compare4EventCallback;
- break;
- case HAL_HRTIM_CAPTURE1EVENTCALLBACK_CB_ID :
- hhrtim->Capture1EventCallback = HAL_HRTIM_Capture1EventCallback;
- break;
- case HAL_HRTIM_CAPTURE2EVENTCALLBACK_CB_ID :
- hhrtim->Capture2EventCallback = HAL_HRTIM_Capture2EventCallback;
- break;
- case HAL_HRTIM_DELAYEDPROTECTIONCALLBACK_CB_ID :
- hhrtim->DelayedProtectionCallback = HAL_HRTIM_DelayedProtectionCallback;
- break;
- case HAL_HRTIM_COUNTERRESETCALLBACK_CB_ID :
- hhrtim->CounterResetCallback = HAL_HRTIM_CounterResetCallback;
- break;
- case HAL_HRTIM_OUTPUT1SETCALLBACK_CB_ID :
- hhrtim->Output1SetCallback = HAL_HRTIM_Output1SetCallback;
- break;
- case HAL_HRTIM_OUTPUT1RESETCALLBACK_CB_ID :
- hhrtim->Output1ResetCallback = HAL_HRTIM_Output1ResetCallback;
- break;
- case HAL_HRTIM_OUTPUT2SETCALLBACK_CB_ID :
- hhrtim->Output2SetCallback = HAL_HRTIM_Output2SetCallback;
- break;
- case HAL_HRTIM_OUTPUT2RESETCALLBACK_CB_ID :
- hhrtim->Output2ResetCallback = HAL_HRTIM_Output2ResetCallback;
- break;
- case HAL_HRTIM_BURSTDMATRANSFERCALLBACK_CB_ID :
- hhrtim->BurstDMATransferCallback = HAL_HRTIM_BurstDMATransferCallback;
- break;
- default :
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the state */
- hhrtim->State = HAL_HRTIM_STATE_INVALID_CALLBACK;
- /* Return error status */
- status = HAL_ERROR;
- }
- /* Release Lock */
- __HAL_UNLOCK(hhrtim);
- return status;
- }
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- /**
- * @}
- */
- /**
- * @}
- */
- /** @addtogroup HRTIM_Private_Functions
- * @{
- */
- /**
- * @brief Configure the master timer time base
- * @param hhrtim pointer to HAL HRTIM handle
- * @param pTimeBaseCfg pointer to the time base configuration structure
- * @retval None
- */
- static void HRTIM_MasterBase_Config(HRTIM_HandleTypeDef * hhrtim,
- const HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
- {
- uint32_t hrtim_mcr;
- /* Configure master timer */
- hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
- /* Set the prescaler ratio */
- hrtim_mcr &= (uint32_t) ~(HRTIM_MCR_CK_PSC);
- hrtim_mcr |= (uint32_t)pTimeBaseCfg->PrescalerRatio;
- /* Set the operating mode */
- hrtim_mcr &= (uint32_t) ~(HRTIM_MCR_CONT | HRTIM_MCR_RETRIG);
- hrtim_mcr |= (uint32_t)pTimeBaseCfg->Mode;
- /* Update the HRTIM registers */
- hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
- hhrtim->Instance->sMasterRegs.MPER = pTimeBaseCfg->Period;
- hhrtim->Instance->sMasterRegs.MREP = pTimeBaseCfg->RepetitionCounter;
- }
- /**
- * @brief Configure timing unit (Timer A to Timer E) time base
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param pTimeBaseCfg pointer to the time base configuration structure
- * @retval None
- */
- static void HRTIM_TimingUnitBase_Config(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx ,
- const HRTIM_TimeBaseCfgTypeDef * pTimeBaseCfg)
- {
- uint32_t hrtim_timcr;
- /* Configure master timing unit */
- hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
- /* Set the prescaler ratio */
- hrtim_timcr &= (uint32_t) ~(HRTIM_TIMCR_CK_PSC);
- hrtim_timcr |= (uint32_t)pTimeBaseCfg->PrescalerRatio;
- /* Set the operating mode */
- hrtim_timcr &= (uint32_t) ~(HRTIM_TIMCR_CONT | HRTIM_TIMCR_RETRIG);
- hrtim_timcr |= (uint32_t)pTimeBaseCfg->Mode;
- /* Update the HRTIM registers */
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
- hhrtim->Instance->sTimerxRegs[TimerIdx].PERxR = pTimeBaseCfg->Period;
- hhrtim->Instance->sTimerxRegs[TimerIdx].REPxR = pTimeBaseCfg->RepetitionCounter;
- }
- /**
- * @brief Configure the master timer in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param pTimerCfg pointer to the timer configuration data structure
- * @retval None
- */
- static void HRTIM_MasterWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
- const HRTIM_TimerCfgTypeDef * pTimerCfg)
- {
- uint32_t hrtim_mcr;
- uint32_t hrtim_bmcr;
- /* Configure master timer */
- hrtim_mcr = hhrtim->Instance->sMasterRegs.MCR;
- hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
- /* Enable/Disable the half mode */
- hrtim_mcr &= ~(HRTIM_MCR_HALF);
- hrtim_mcr |= pTimerCfg->HalfModeEnable;
- /* Enable/Disable the timer start upon synchronization event reception */
- hrtim_mcr &= ~(HRTIM_MCR_SYNCSTRTM);
- hrtim_mcr |= pTimerCfg->StartOnSync;
- /* Enable/Disable the timer reset upon synchronization event reception */
- hrtim_mcr &= ~(HRTIM_MCR_SYNCRSTM);
- hrtim_mcr |= pTimerCfg->ResetOnSync;
- /* Enable/Disable the DAC synchronization event generation */
- hrtim_mcr &= ~(HRTIM_MCR_DACSYNC);
- hrtim_mcr |= pTimerCfg->DACSynchro;
- /* Enable/Disable preload mechanism for timer registers */
- hrtim_mcr &= ~(HRTIM_MCR_PREEN);
- hrtim_mcr |= pTimerCfg->PreloadEnable;
- /* Master timer registers update handling */
- hrtim_mcr &= ~(HRTIM_MCR_BRSTDMA);
- hrtim_mcr |= (pTimerCfg->UpdateGating << 2U);
- /* Enable/Disable registers update on repetition */
- hrtim_mcr &= ~(HRTIM_MCR_MREPU);
- hrtim_mcr |= pTimerCfg->RepetitionUpdate;
- /* Set the timer burst mode */
- hrtim_bmcr &= ~(HRTIM_BMCR_MTBM);
- hrtim_bmcr |= pTimerCfg->BurstMode;
- /* Update the HRTIM registers */
- hhrtim->Instance->sMasterRegs.MCR = hrtim_mcr;
- hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
- }
- /**
- * @brief Configure timing unit (Timer A to Timer E) in waveform mode
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param pTimerCfg pointer to the timer configuration data structure
- * @retval None
- */
- static void HRTIM_TimingUnitWaveform_Config(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- const HRTIM_TimerCfgTypeDef * pTimerCfg)
- {
- uint32_t hrtim_timcr;
- uint32_t hrtim_timfltr;
- uint32_t hrtim_timoutr;
- uint32_t hrtim_timrstr;
- uint32_t hrtim_bmcr;
- /* UPDGAT bitfield must be reset before programming a new value */
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR &= ~(HRTIM_TIMCR_UPDGAT);
- /* Configure timing unit (Timer A to Timer E) */
- hrtim_timcr = hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR;
- hrtim_timfltr = hhrtim->Instance->sTimerxRegs[TimerIdx].FLTxR;
- hrtim_timoutr = hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR;
- hrtim_bmcr = hhrtim->Instance->sCommonRegs.BMCR;
- /* Enable/Disable the half mode */
- hrtim_timcr &= ~(HRTIM_TIMCR_HALF);
- hrtim_timcr |= pTimerCfg->HalfModeEnable;
- /* Enable/Disable the timer start upon synchronization event reception */
- hrtim_timcr &= ~(HRTIM_TIMCR_SYNCSTRT);
- hrtim_timcr |= pTimerCfg->StartOnSync;
- /* Enable/Disable the timer reset upon synchronization event reception */
- hrtim_timcr &= ~(HRTIM_TIMCR_SYNCRST);
- hrtim_timcr |= pTimerCfg->ResetOnSync;
- /* Enable/Disable the DAC synchronization event generation */
- hrtim_timcr &= ~(HRTIM_TIMCR_DACSYNC);
- hrtim_timcr |= pTimerCfg->DACSynchro;
- /* Enable/Disable preload mechanism for timer registers */
- hrtim_timcr &= ~(HRTIM_TIMCR_PREEN);
- hrtim_timcr |= pTimerCfg->PreloadEnable;
- /* Timing unit registers update handling */
- hrtim_timcr &= ~(HRTIM_TIMCR_UPDGAT);
- hrtim_timcr |= pTimerCfg->UpdateGating;
- /* Enable/Disable registers update on repetition */
- hrtim_timcr &= ~(HRTIM_TIMCR_TREPU);
- if (pTimerCfg->RepetitionUpdate == HRTIM_UPDATEONREPETITION_ENABLED)
- {
- hrtim_timcr |= HRTIM_TIMCR_TREPU;
- }
- /* Set the push-pull mode */
- hrtim_timcr &= ~(HRTIM_TIMCR_PSHPLL);
- hrtim_timcr |= pTimerCfg->PushPull;
- /* Enable/Disable registers update on timer counter reset */
- hrtim_timcr &= ~(HRTIM_TIMCR_TRSTU);
- hrtim_timcr |= pTimerCfg->ResetUpdate;
- /* Set the timer update trigger */
- hrtim_timcr &= ~(HRTIM_TIMCR_TIMUPDATETRIGGER);
- hrtim_timcr |= pTimerCfg->UpdateTrigger;
- /* Enable/Disable the fault channel at timer level */
- hrtim_timfltr &= ~(HRTIM_FLTR_FLTxEN);
- hrtim_timfltr |= (pTimerCfg->FaultEnable & HRTIM_FLTR_FLTxEN);
- /* Lock/Unlock fault sources at timer level */
- hrtim_timfltr &= ~(HRTIM_FLTR_FLTLCK);
- hrtim_timfltr |= pTimerCfg->FaultLock;
- /* The deadtime cannot be used simultaneously with the push-pull mode */
- if (pTimerCfg->PushPull == HRTIM_TIMPUSHPULLMODE_DISABLED)
- {
- /* Enable/Disable dead time insertion at timer level */
- hrtim_timoutr &= ~(HRTIM_OUTR_DTEN);
- hrtim_timoutr |= pTimerCfg->DeadTimeInsertion;
- }
- /* Enable/Disable delayed protection at timer level
- Delayed Idle is available whatever the timer operating mode (regular, push-pull)
- Balanced Idle is only available in push-pull mode
- */
- if ( ((pTimerCfg->DelayedProtectionMode != HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_BALANCED_EEV6)
- && (pTimerCfg->DelayedProtectionMode != HRTIM_TIMER_A_B_C_DELAYEDPROTECTION_BALANCED_EEV7))
- || (pTimerCfg->PushPull == HRTIM_TIMPUSHPULLMODE_ENABLED))
- {
- hrtim_timoutr &= ~(HRTIM_OUTR_DLYPRT| HRTIM_OUTR_DLYPRTEN);
- hrtim_timoutr |= pTimerCfg->DelayedProtectionMode;
- }
- /* Set the timer counter reset trigger */
- hrtim_timrstr = pTimerCfg->ResetTrigger;
- /* Set the timer burst mode */
- switch (TimerIdx)
- {
- case HRTIM_TIMERINDEX_TIMER_A:
- {
- hrtim_bmcr &= ~(HRTIM_BMCR_TABM);
- hrtim_bmcr |= ( pTimerCfg->BurstMode << 1U);
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_B:
- {
- hrtim_bmcr &= ~(HRTIM_BMCR_TBBM);
- hrtim_bmcr |= ( pTimerCfg->BurstMode << 2U);
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_C:
- {
- hrtim_bmcr &= ~(HRTIM_BMCR_TCBM);
- hrtim_bmcr |= ( pTimerCfg->BurstMode << 3U);
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_D:
- {
- hrtim_bmcr &= ~(HRTIM_BMCR_TDBM);
- hrtim_bmcr |= ( pTimerCfg->BurstMode << 4U);
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_E:
- {
- hrtim_bmcr &= ~(HRTIM_BMCR_TEBM);
- hrtim_bmcr |= ( pTimerCfg->BurstMode << 5U);
- break;
- }
- default:
- break;
- }
- /* Update the HRTIM registers */
- hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxCR = hrtim_timcr;
- hhrtim->Instance->sTimerxRegs[TimerIdx].FLTxR = hrtim_timfltr;
- hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR = hrtim_timoutr;
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = hrtim_timrstr;
- hhrtim->Instance->sCommonRegs.BMCR = hrtim_bmcr;
- }
- /**
- * @brief Configure a capture unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param CaptureUnit Capture unit identifier
- * @param Event Event reference
- * @retval None
- */
- static void HRTIM_CaptureUnitConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t CaptureUnit,
- uint32_t Event)
- {
- uint32_t CaptureTrigger = 0xFFFFFFFFU;
- switch (Event)
- {
- case HRTIM_EVENT_1:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_1;
- break;
- }
- case HRTIM_EVENT_2:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_2;
- break;
- }
- case HRTIM_EVENT_3:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_3;
- break;
- }
- case HRTIM_EVENT_4:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_4;
- break;
- }
- case HRTIM_EVENT_5:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_5;
- break;
- }
- case HRTIM_EVENT_6:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_6;
- break;
- }
- case HRTIM_EVENT_7:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_7;
- break;
- }
- case HRTIM_EVENT_8:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_8;
- break;
- }
- case HRTIM_EVENT_9:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_9;
- break;
- }
- case HRTIM_EVENT_10:
- {
- CaptureTrigger = HRTIM_CAPTURETRIGGER_EEV_10;
- break;
- }
- default:
- break;
- }
- switch (CaptureUnit)
- {
- case HRTIM_CAPTUREUNIT_1:
- {
- hhrtim->TimerParam[TimerIdx].CaptureTrigger1 = CaptureTrigger;
- break;
- }
- case HRTIM_CAPTUREUNIT_2:
- {
- hhrtim->TimerParam[TimerIdx].CaptureTrigger2 = CaptureTrigger;
- break;
- }
- default:
- break;
- }
- }
- /**
- * @brief Configure the output of a timing unit
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param Output timing unit output identifier
- * @param pOutputCfg pointer to the output configuration data structure
- * @retval None
- */
- static void HRTIM_OutputConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Output,
- const HRTIM_OutputCfgTypeDef * pOutputCfg)
- {
- uint32_t hrtim_outr;
- uint32_t hrtim_dtr;
- uint32_t shift = 0U;
- hrtim_outr = hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR;
- hrtim_dtr = hhrtim->Instance->sTimerxRegs[TimerIdx].DTxR;
- switch (Output)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- /* Set the output set/reset crossbar */
- hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R = pOutputCfg->SetSource;
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R = pOutputCfg->ResetSource;
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- /* Set the output set/reset crossbar */
- hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R = pOutputCfg->SetSource;
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R = pOutputCfg->ResetSource;
- shift = 16U;
- break;
- }
- default:
- break;
- }
- /* Clear output config */
- hrtim_outr &= ~((HRTIM_OUTR_POL1 |
- HRTIM_OUTR_IDLM1 |
- HRTIM_OUTR_IDLES1|
- HRTIM_OUTR_FAULT1|
- HRTIM_OUTR_CHP1 |
- HRTIM_OUTR_DIDL1) << shift);
- /* Set the polarity */
- hrtim_outr |= (pOutputCfg->Polarity << shift);
- /* Set the IDLE mode */
- hrtim_outr |= (pOutputCfg->IdleMode << shift);
- /* Set the IDLE state */
- hrtim_outr |= (pOutputCfg->IdleLevel << shift);
- /* Set the FAULT state */
- hrtim_outr |= (pOutputCfg->FaultLevel << shift);
- /* Set the chopper mode */
- hrtim_outr |= (pOutputCfg->ChopperModeEnable << shift);
- /* Set the burst mode entry mode : deadtime insertion when entering the idle
- state during a burst mode operation is allowed only under the following
- conditions:
- - the outputs is active during the burst mode (IDLES=1U)
- - positive deadtimes (SDTR/SDTF set to 0U)
- */
- if ((pOutputCfg->IdleLevel == HRTIM_OUTPUTIDLELEVEL_ACTIVE) &&
- ((hrtim_dtr & HRTIM_DTR_SDTR) == (uint32_t)RESET) &&
- ((hrtim_dtr & HRTIM_DTR_SDTF) == (uint32_t)RESET))
- {
- hrtim_outr |= (pOutputCfg->BurstModeEntryDelayed << shift);
- }
- /* Update HRTIM register */
- hhrtim->Instance->sTimerxRegs[TimerIdx].OUTxR = hrtim_outr;
- }
- /**
- * @brief Configure an external event channel
- * @param hhrtim pointer to HAL HRTIM handle
- * @param Event Event channel identifier
- * @param pEventCfg pointer to the event channel configuration data structure
- * @retval None
- */
- static void HRTIM_EventConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t Event,
- const HRTIM_EventCfgTypeDef *pEventCfg)
- {
- uint32_t hrtim_eecr1;
- uint32_t hrtim_eecr2;
- uint32_t hrtim_eecr3;
- /* Configure external event channel */
- hrtim_eecr1 = hhrtim->Instance->sCommonRegs.EECR1;
- hrtim_eecr2 = hhrtim->Instance->sCommonRegs.EECR2;
- hrtim_eecr3 = hhrtim->Instance->sCommonRegs.EECR3;
- switch (Event)
- {
- case HRTIM_EVENT_NONE:
- {
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR1 = 0U;
- hhrtim->Instance->sCommonRegs.EECR2 = 0U;
- hhrtim->Instance->sCommonRegs.EECR3 = 0U;
- break;
- }
- case HRTIM_EVENT_1:
- {
- hrtim_eecr1 &= ~(HRTIM_EECR1_EE1SRC | HRTIM_EECR1_EE1POL | HRTIM_EECR1_EE1SNS | HRTIM_EECR1_EE1FAST);
- hrtim_eecr1 |= (pEventCfg->Source & HRTIM_EECR1_EE1SRC);
- hrtim_eecr1 |= (pEventCfg->Polarity & HRTIM_EECR1_EE1POL);
- hrtim_eecr1 |= (pEventCfg->Sensitivity & HRTIM_EECR1_EE1SNS);
- /* Update the HRTIM registers (all bitfields but EE1FAST bit) */
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- /* Update the HRTIM registers (EE1FAST bit) */
- hrtim_eecr1 |= (pEventCfg->FastMode & HRTIM_EECR1_EE1FAST);
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- break;
- }
- case HRTIM_EVENT_2:
- {
- hrtim_eecr1 &= ~(HRTIM_EECR1_EE2SRC | HRTIM_EECR1_EE2POL | HRTIM_EECR1_EE2SNS | HRTIM_EECR1_EE2FAST);
- hrtim_eecr1 |= ((pEventCfg->Source << 6U) & HRTIM_EECR1_EE2SRC);
- hrtim_eecr1 |= ((pEventCfg->Polarity << 6U) & HRTIM_EECR1_EE2POL);
- hrtim_eecr1 |= ((pEventCfg->Sensitivity << 6U) & HRTIM_EECR1_EE2SNS);
- /* Update the HRTIM registers (all bitfields but EE2FAST bit) */
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- /* Update the HRTIM registers (EE2FAST bit) */
- hrtim_eecr1 |= ((pEventCfg->FastMode << 6U) & HRTIM_EECR1_EE2FAST);
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- break;
- }
- case HRTIM_EVENT_3:
- {
- hrtim_eecr1 &= ~(HRTIM_EECR1_EE3SRC | HRTIM_EECR1_EE3POL | HRTIM_EECR1_EE3SNS | HRTIM_EECR1_EE3FAST);
- hrtim_eecr1 |= ((pEventCfg->Source << 12U) & HRTIM_EECR1_EE3SRC);
- hrtim_eecr1 |= ((pEventCfg->Polarity << 12U) & HRTIM_EECR1_EE3POL);
- hrtim_eecr1 |= ((pEventCfg->Sensitivity << 12U) & HRTIM_EECR1_EE3SNS);
- /* Update the HRTIM registers (all bitfields but EE3FAST bit) */
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- /* Update the HRTIM registers (EE3FAST bit) */
- hrtim_eecr1 |= ((pEventCfg->FastMode << 12U) & HRTIM_EECR1_EE3FAST);
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- break;
- }
- case HRTIM_EVENT_4:
- {
- hrtim_eecr1 &= ~(HRTIM_EECR1_EE4SRC | HRTIM_EECR1_EE4POL | HRTIM_EECR1_EE4SNS | HRTIM_EECR1_EE4FAST);
- hrtim_eecr1 |= ((pEventCfg->Source << 18U) & HRTIM_EECR1_EE4SRC);
- hrtim_eecr1 |= ((pEventCfg->Polarity << 18U) & HRTIM_EECR1_EE4POL);
- hrtim_eecr1 |= ((pEventCfg->Sensitivity << 18U) & HRTIM_EECR1_EE4SNS);
- /* Update the HRTIM registers (all bitfields but EE4FAST bit) */
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- /* Update the HRTIM registers (EE4FAST bit) */
- hrtim_eecr1 |= ((pEventCfg->FastMode << 18U) & HRTIM_EECR1_EE4FAST);
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- break;
- }
- case HRTIM_EVENT_5:
- {
- hrtim_eecr1 &= ~(HRTIM_EECR1_EE5SRC | HRTIM_EECR1_EE5POL | HRTIM_EECR1_EE5SNS | HRTIM_EECR1_EE5FAST);
- hrtim_eecr1 |= ((pEventCfg->Source << 24U) & HRTIM_EECR1_EE5SRC);
- hrtim_eecr1 |= ((pEventCfg->Polarity << 24U) & HRTIM_EECR1_EE5POL);
- hrtim_eecr1 |= ((pEventCfg->Sensitivity << 24U) & HRTIM_EECR1_EE5SNS);
- /* Update the HRTIM registers (all bitfields but EE5FAST bit) */
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- /* Update the HRTIM registers (EE5FAST bit) */
- hrtim_eecr1 |= ((pEventCfg->FastMode << 24U) & HRTIM_EECR1_EE5FAST);
- hhrtim->Instance->sCommonRegs.EECR1 = hrtim_eecr1;
- break;
- }
- case HRTIM_EVENT_6:
- {
- hrtim_eecr2 &= ~(HRTIM_EECR2_EE6SRC | HRTIM_EECR2_EE6POL | HRTIM_EECR2_EE6SNS);
- hrtim_eecr2 |= (pEventCfg->Source & HRTIM_EECR2_EE6SRC);
- hrtim_eecr2 |= (pEventCfg->Polarity & HRTIM_EECR2_EE6POL);
- hrtim_eecr2 |= (pEventCfg->Sensitivity & HRTIM_EECR2_EE6SNS);
- hrtim_eecr3 &= ~(HRTIM_EECR3_EE6F);
- hrtim_eecr3 |= (pEventCfg->Filter & HRTIM_EECR3_EE6F);
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
- hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
- break;
- }
- case HRTIM_EVENT_7:
- {
- hrtim_eecr2 &= ~(HRTIM_EECR2_EE7SRC | HRTIM_EECR2_EE7POL | HRTIM_EECR2_EE7SNS);
- hrtim_eecr2 |= ((pEventCfg->Source << 6U) & HRTIM_EECR2_EE7SRC);
- hrtim_eecr2 |= ((pEventCfg->Polarity << 6U) & HRTIM_EECR2_EE7POL);
- hrtim_eecr2 |= ((pEventCfg->Sensitivity << 6U) & HRTIM_EECR2_EE7SNS);
- hrtim_eecr3 &= ~(HRTIM_EECR3_EE7F);
- hrtim_eecr3 |= ((pEventCfg->Filter << 6U) & HRTIM_EECR3_EE7F);
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
- hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
- break;
- }
- case HRTIM_EVENT_8:
- {
- hrtim_eecr2 &= ~(HRTIM_EECR2_EE8SRC | HRTIM_EECR2_EE8POL | HRTIM_EECR2_EE8SNS);
- hrtim_eecr2 |= ((pEventCfg->Source << 12U) & HRTIM_EECR2_EE8SRC);
- hrtim_eecr2 |= ((pEventCfg->Polarity << 12U) & HRTIM_EECR2_EE8POL);
- hrtim_eecr2 |= ((pEventCfg->Sensitivity << 12U) & HRTIM_EECR2_EE8SNS);
- hrtim_eecr3 &= ~(HRTIM_EECR3_EE8F);
- hrtim_eecr3 |= ((pEventCfg->Filter << 12U) & HRTIM_EECR3_EE8F );
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
- hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
- break;
- }
- case HRTIM_EVENT_9:
- {
- hrtim_eecr2 &= ~(HRTIM_EECR2_EE9SRC | HRTIM_EECR2_EE9POL | HRTIM_EECR2_EE9SNS);
- hrtim_eecr2 |= ((pEventCfg->Source << 18U) & HRTIM_EECR2_EE9SRC);
- hrtim_eecr2 |= ((pEventCfg->Polarity << 18U) & HRTIM_EECR2_EE9POL);
- hrtim_eecr2 |= ((pEventCfg->Sensitivity << 18U) & HRTIM_EECR2_EE9SNS);
- hrtim_eecr3 &= ~(HRTIM_EECR3_EE9F);
- hrtim_eecr3 |= ((pEventCfg->Filter << 18U) & HRTIM_EECR3_EE9F);
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
- hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
- break;
- }
- case HRTIM_EVENT_10:
- {
- hrtim_eecr2 &= ~(HRTIM_EECR2_EE10SRC | HRTIM_EECR2_EE10POL | HRTIM_EECR2_EE10SNS);
- hrtim_eecr2 |= ((pEventCfg->Source << 24U) & HRTIM_EECR2_EE10SRC);
- hrtim_eecr2 |= ((pEventCfg->Polarity << 24U) & HRTIM_EECR2_EE10POL);
- hrtim_eecr2 |= ((pEventCfg->Sensitivity << 24U) & HRTIM_EECR2_EE10SNS);
- hrtim_eecr3 &= ~(HRTIM_EECR3_EE10F);
- hrtim_eecr3 |= ((pEventCfg->Filter << 24U) & HRTIM_EECR3_EE10F);
- /* Update the HRTIM registers */
- hhrtim->Instance->sCommonRegs.EECR2 = hrtim_eecr2;
- hhrtim->Instance->sCommonRegs.EECR3 = hrtim_eecr3;
- break;
- }
- default:
- break;
- }
- }
- /**
- * @brief Configure the timer counter reset
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param Event Event channel identifier
- * @retval None
- */
- static void HRTIM_TIM_ResetConfig(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t Event)
- {
- switch (Event)
- {
- case HRTIM_EVENT_1:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_1;
- break;
- }
- case HRTIM_EVENT_2:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_2;
- break;
- }
- case HRTIM_EVENT_3:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_3;
- break;
- }
- case HRTIM_EVENT_4:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_4;
- break;
- }
- case HRTIM_EVENT_5:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_5;
- break;
- }
- case HRTIM_EVENT_6:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_6;
- break;
- }
- case HRTIM_EVENT_7:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_7;
- break;
- }
- case HRTIM_EVENT_8:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_8;
- break;
- }
- case HRTIM_EVENT_9:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_9;
- break;
- }
- case HRTIM_EVENT_10:
- {
- hhrtim->Instance->sTimerxRegs[TimerIdx].RSTxR = HRTIM_TIMRESETTRIGGER_EEV_10;
- break;
- }
- default:
- break;
- }
- }
- /**
- * @brief Return the interrupt to enable or disable according to the
- * OC mode.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval Interrupt to enable or disable
- */
- static uint32_t HRTIM_GetITFromOCMode(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- uint32_t hrtim_set;
- uint32_t hrtim_reset;
- uint32_t interrupt = 0U;
- switch (OCChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- /* Retreives actual OC mode and set interrupt accordingly */
- hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R;
- hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R;
- if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
- {
- /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
- interrupt = HRTIM_TIM_IT_CMP1;
- }
- else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
- (hrtim_reset == 0U))
- {
- /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
- interrupt = HRTIM_TIM_IT_SET1;
- }
- else if ((hrtim_set == 0U) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
- {
- /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
- interrupt = HRTIM_TIM_IT_RST1;
- }
- else
- {
- /* nothing to do */
- }
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- /* Retreives actual OC mode and set interrupt accordingly */
- hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R;
- hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R;
- if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
- {
- /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
- interrupt = HRTIM_TIM_IT_CMP2;
- }
- else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
- (hrtim_reset == 0U))
- {
- /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
- interrupt = HRTIM_TIM_IT_SET2;
- }
- else if ((hrtim_set == 0U) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
- {
- /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
- interrupt = HRTIM_TIM_IT_RST2;
- }
- else
- {
- /* nothing to do */
- }
- break;
- }
- default:
- break;
- }
- return interrupt;
- }
- /**
- * @brief Return the DMA request to enable or disable according to the
- * OC mode.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @param OCChannel Timer output
- * This parameter can be one of the following values:
- * @arg HRTIM_OUTPUT_TA1: Timer A - Output 1
- * @arg HRTIM_OUTPUT_TA2: Timer A - Output 2
- * @arg HRTIM_OUTPUT_TB1: Timer B - Output 1
- * @arg HRTIM_OUTPUT_TB2: Timer B - Output 2
- * @arg HRTIM_OUTPUT_TC1: Timer C - Output 1
- * @arg HRTIM_OUTPUT_TC2: Timer C - Output 2
- * @arg HRTIM_OUTPUT_TD1: Timer D - Output 1
- * @arg HRTIM_OUTPUT_TD2: Timer D - Output 2
- * @arg HRTIM_OUTPUT_TE1: Timer E - Output 1
- * @arg HRTIM_OUTPUT_TE2: Timer E - Output 2
- * @retval DMA request to enable or disable
- */
- static uint32_t HRTIM_GetDMAFromOCMode(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx,
- uint32_t OCChannel)
- {
- uint32_t hrtim_set;
- uint32_t hrtim_reset;
- uint32_t dma_request = 0U;
- switch (OCChannel)
- {
- case HRTIM_OUTPUT_TA1:
- case HRTIM_OUTPUT_TB1:
- case HRTIM_OUTPUT_TC1:
- case HRTIM_OUTPUT_TD1:
- case HRTIM_OUTPUT_TE1:
- {
- /* Retreives actual OC mode and set dma_request accordingly */
- hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx1R;
- hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx1R;
- if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
- {
- /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
- dma_request = HRTIM_TIM_DMA_CMP1;
- }
- else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP1) == HRTIM_OUTPUTSET_TIMCMP1) &&
- (hrtim_reset == 0U))
- {
- /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
- dma_request = HRTIM_TIM_DMA_SET1;
- }
- else if ((hrtim_set == 0U) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP1) == HRTIM_OUTPUTRESET_TIMCMP1))
- {
- /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
- dma_request = HRTIM_TIM_DMA_RST1;
- }
- else
- {
- /* nothing to do */
- }
- break;
- }
- case HRTIM_OUTPUT_TA2:
- case HRTIM_OUTPUT_TB2:
- case HRTIM_OUTPUT_TC2:
- case HRTIM_OUTPUT_TD2:
- case HRTIM_OUTPUT_TE2:
- {
- /* Retreives actual OC mode and set dma_request accordingly */
- hrtim_set = hhrtim->Instance->sTimerxRegs[TimerIdx].SETx2R;
- hrtim_reset = hhrtim->Instance->sTimerxRegs[TimerIdx].RSTx2R;
- if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
- {
- /* OC mode: HRTIM_BASICOCMODE_TOGGLE */
- dma_request = HRTIM_TIM_DMA_CMP2;
- }
- else if (((hrtim_set & HRTIM_OUTPUTSET_TIMCMP2) == HRTIM_OUTPUTSET_TIMCMP2) &&
- (hrtim_reset == 0U))
- {
- /* OC mode: HRTIM_BASICOCMODE_ACTIVE */
- dma_request = HRTIM_TIM_DMA_SET2;
- }
- else if ((hrtim_set == 0U) &&
- ((hrtim_reset & HRTIM_OUTPUTRESET_TIMCMP2) == HRTIM_OUTPUTRESET_TIMCMP2))
- {
- /* OC mode: HRTIM_BASICOCMODE_INACTIVE */
- dma_request = HRTIM_TIM_DMA_RST2;
- }
- else
- {
- /* nothing to do */
- }
- break;
- }
- default:
- break;
- }
- return dma_request;
- }
- static DMA_HandleTypeDef * HRTIM_GetDMAHandleFromTimerIdx(const HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- DMA_HandleTypeDef * hdma = (DMA_HandleTypeDef *)NULL;
- switch (TimerIdx)
- {
- case HRTIM_TIMERINDEX_MASTER:
- {
- hdma = hhrtim->hdmaMaster;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_A:
- {
- hdma = hhrtim->hdmaTimerA;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_B:
- {
- hdma = hhrtim->hdmaTimerB;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_C:
- {
- hdma = hhrtim->hdmaTimerC;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_D:
- {
- hdma = hhrtim->hdmaTimerD;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_E:
- {
- hdma = hhrtim->hdmaTimerE;
- break;
- }
- default:
- break;
- }
- return hdma;
- }
- static uint32_t GetTimerIdxFromDMAHandle(const HRTIM_HandleTypeDef * hhrtim,
- const DMA_HandleTypeDef * hdma)
- {
- uint32_t timed_idx = 0xFFFFFFFFU;
- if (hdma == hhrtim->hdmaMaster)
- {
- timed_idx = HRTIM_TIMERINDEX_MASTER;
- }
- else if (hdma == hhrtim->hdmaTimerA)
- {
- timed_idx = HRTIM_TIMERINDEX_TIMER_A;
- }
- else if (hdma == hhrtim->hdmaTimerB)
- {
- timed_idx = HRTIM_TIMERINDEX_TIMER_B;
- }
- else if (hdma == hhrtim->hdmaTimerC)
- {
- timed_idx = HRTIM_TIMERINDEX_TIMER_C;
- }
- else if (hdma == hhrtim->hdmaTimerD)
- {
- timed_idx = HRTIM_TIMERINDEX_TIMER_D;
- }
- else if (hdma == hhrtim->hdmaTimerE)
- {
- timed_idx = HRTIM_TIMERINDEX_TIMER_E;
- }
- else
- {
- /* nothing to do */
- }
- return timed_idx;
- }
- /**
- * @brief Force an immediate transfer from the preload to the active
- * registers.
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * @retval None
- */
- static void HRTIM_ForceRegistersUpdate(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- switch (TimerIdx)
- {
- case HRTIM_TIMERINDEX_MASTER:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_MSWU;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_A:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TASWU;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_B:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TBSWU;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_C:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TCSWU;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_D:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TDSWU;
- break;
- }
- case HRTIM_TIMERINDEX_TIMER_E:
- {
- hhrtim->Instance->sCommonRegs.CR2 |= HRTIM_CR2_TESWU;
- break;
- }
- default:
- break;
- }
- }
- /**
- * @brief HRTIM interrupts service routine
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- static void HRTIM_HRTIM_ISR(HRTIM_HandleTypeDef * hhrtim)
- {
- uint32_t isrflags = READ_REG(hhrtim->Instance->sCommonRegs.ISR);
- uint32_t ierits = READ_REG(hhrtim->Instance->sCommonRegs.IER);
- /* Fault 1 event */
- if((uint32_t)(isrflags & HRTIM_FLAG_FLT1) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_FLT1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT1);
- /* Invoke Fault 1 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Fault1Callback(hhrtim);
- #else
- HAL_HRTIM_Fault1Callback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Fault 2 event */
- if((uint32_t)(isrflags & HRTIM_FLAG_FLT2) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_FLT2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT2);
- /* Invoke Fault 2 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Fault2Callback(hhrtim);
- #else
- HAL_HRTIM_Fault2Callback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Fault 3 event */
- if((uint32_t)(isrflags & HRTIM_FLAG_FLT3) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_FLT3) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT3);
- /* Invoke Fault 3 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Fault3Callback(hhrtim);
- #else
- HAL_HRTIM_Fault3Callback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Fault 4 event */
- if((uint32_t)(isrflags & HRTIM_FLAG_FLT4) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_FLT4) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT4);
- /* Invoke Fault 4 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Fault4Callback(hhrtim);
- #else
- HAL_HRTIM_Fault4Callback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Fault 5 event */
- if((uint32_t)(isrflags & HRTIM_FLAG_FLT5) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_FLT5) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_FLT5);
- /* Invoke Fault 5 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Fault5Callback(hhrtim);
- #else
- HAL_HRTIM_Fault5Callback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* System fault event */
- if((uint32_t)(isrflags & HRTIM_FLAG_SYSFLT) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_SYSFLT) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_SYSFLT);
- /* Invoke System fault event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->SystemFaultCallback(hhrtim);
- #else
- HAL_HRTIM_SystemFaultCallback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- }
- /**
- * @brief Master timer interrupts service routine
- * @param hhrtim pointer to HAL HRTIM handle
- * @retval None
- */
- static void HRTIM_Master_ISR(HRTIM_HandleTypeDef * hhrtim)
- {
- uint32_t isrflags = READ_REG(hhrtim->Instance->sCommonRegs.ISR);
- uint32_t ierits = READ_REG(hhrtim->Instance->sCommonRegs.IER);
- uint32_t misrflags = READ_REG(hhrtim->Instance->sMasterRegs.MISR);
- uint32_t mdierits = READ_REG(hhrtim->Instance->sMasterRegs.MDIER);
- /* DLL calibration ready event */
- if((uint32_t)(isrflags & HRTIM_FLAG_DLLRDY) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_DLLRDY) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_DLLRDY);
- /* Set HRTIM State */
- hhrtim->State = HAL_HRTIM_STATE_READY;
- /* Process unlocked */
- __HAL_UNLOCK(hhrtim);
- /* Invoke System fault event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->DLLCalibrationReadyCallback(hhrtim);
- #else
- HAL_HRTIM_DLLCalibrationReadyCallback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Burst mode period event */
- if((uint32_t)(isrflags & HRTIM_FLAG_BMPER) != (uint32_t)RESET)
- {
- if((uint32_t)(ierits & HRTIM_IT_BMPER) != (uint32_t)RESET)
- {
- __HAL_HRTIM_CLEAR_IT(hhrtim, HRTIM_IT_BMPER);
- /* Invoke Burst mode period event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->BurstModePeriodCallback(hhrtim);
- #else
- HAL_HRTIM_BurstModePeriodCallback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer compare 1 event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP1) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP1);
- /* Invoke compare 1 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare1EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare1EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer compare 2 event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP2) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP2);
- /* Invoke compare 2 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare2EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare2EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer compare 3 event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP3) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP3) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP3);
- /* Invoke compare 3 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare3EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare3EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer compare 4 event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MCMP4) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MCMP4) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MCMP4);
- /* Invoke compare 4 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare4EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare4EventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer repetition event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MREP) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MREP) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MREP);
- /* Invoke repetition event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->RepetitionEventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_RepetitionEventCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Synchronization input event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_SYNC) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_SYNC) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_SYNC);
- /* Invoke synchronization event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->SynchronizationEventCallback(hhrtim);
- #else
- HAL_HRTIM_SynchronizationEventCallback(hhrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Master timer registers update event */
- if((uint32_t)(misrflags & HRTIM_MASTER_FLAG_MUPD) != (uint32_t)RESET)
- {
- if((uint32_t)(mdierits & HRTIM_MASTER_IT_MUPD) != (uint32_t)RESET)
- {
- __HAL_HRTIM_MASTER_CLEAR_IT(hhrtim, HRTIM_MASTER_IT_MUPD);
- /* Invoke registers update event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->RegistersUpdateCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_RegistersUpdateCallback(hhrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- }
- /**
- * @brief Timer interrupts service routine
- * @param hhrtim pointer to HAL HRTIM handle
- * @param TimerIdx Timer index
- * This parameter can be one of the following values:
- * @arg HRTIM_TIMERINDEX_TIMER_A for timer A
- * @arg HRTIM_TIMERINDEX_TIMER_B for timer B
- * @arg HRTIM_TIMERINDEX_TIMER_C for timer C
- * @arg HRTIM_TIMERINDEX_TIMER_D for timer D
- * @arg HRTIM_TIMERINDEX_TIMER_E for timer E
- * @retval None
- */
- static void HRTIM_Timer_ISR(HRTIM_HandleTypeDef * hhrtim,
- uint32_t TimerIdx)
- {
- uint32_t tisrflags = READ_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxISR);
- uint32_t tdierits = READ_REG(hhrtim->Instance->sTimerxRegs[TimerIdx].TIMxDIER);
- /* Timer compare 1 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP1) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP1);
- /* Invoke compare 1 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare1EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Compare1EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer compare 2 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP2) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP2);
- /* Invoke compare 2 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare2EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Compare2EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer compare 3 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP3) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP3) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP3);
- /* Invoke compare 3 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare3EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Compare3EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer compare 4 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CMP4) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CMP4) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CMP4);
- /* Invoke compare 4 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Compare4EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Compare4EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer repetition event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_REP) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_REP) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_REP);
- /* Invoke repetition event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->RepetitionEventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_RepetitionEventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer registers update event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_UPD) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_UPD) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_UPD);
- /* Invoke registers update event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->RegistersUpdateCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_RegistersUpdateCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer capture 1 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CPT1) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CPT1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT1);
- /* Invoke capture 1 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Capture1EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Capture1EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer capture 2 event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_CPT2) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_CPT2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_CPT2);
- /* Invoke capture 2 event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Capture2EventCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Capture2EventCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer output 1 set event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_SET1) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_SET1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_SET1);
- /* Invoke output 1 set event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Output1SetCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Output1SetCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer output 1 reset event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST1) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_RST1) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST1);
- /* Invoke output 1 reset event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Output1ResetCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Output1ResetCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer output 2 set event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_SET2) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_SET2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_SET2);
- /* Invoke output 2 set event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Output2SetCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Output2SetCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer output 2 reset event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST2) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_RST2) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST2);
- /* Invoke output 2 reset event callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->Output2ResetCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_Output2ResetCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Timer reset event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_RST) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_RST) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_RST);
- /* Invoke timer reset callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->CounterResetCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_CounterResetCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- /* Delayed protection event */
- if((uint32_t)(tisrflags & HRTIM_TIM_FLAG_DLYPRT) != (uint32_t)RESET)
- {
- if((uint32_t)(tdierits & HRTIM_TIM_IT_DLYPRT) != (uint32_t)RESET)
- {
- __HAL_HRTIM_TIMER_CLEAR_IT(hhrtim, TimerIdx, HRTIM_TIM_IT_DLYPRT);
- /* Invoke delayed protection callback */
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hhrtim->DelayedProtectionCallback(hhrtim, TimerIdx);
- #else
- HAL_HRTIM_DelayedProtectionCallback(hhrtim, TimerIdx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- }
- }
- /**
- * @brief DMA callback invoked upon master timer related DMA request completion
- * @param hdma pointer to DMA handle.
- * @retval None
- */
- static void HRTIM_DMAMasterCplt(DMA_HandleTypeDef *hdma)
- {
- HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
- if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP1) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare1EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare1EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP2) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare2EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare2EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP3) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare3EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare3EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MCMP4) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare4EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_Compare4EventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_SYNC) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->SynchronizationEventCallback(hrtim);
- #else
- HAL_HRTIM_SynchronizationEventCallback(hrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MUPD) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->RegistersUpdateCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_RegistersUpdateCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sMasterRegs.MDIER & HRTIM_MASTER_DMA_MREP) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->RepetitionEventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #else
- HAL_HRTIM_RepetitionEventCallback(hrtim, HRTIM_TIMERINDEX_MASTER);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else
- {
- /* nothing to do */
- }
- }
- /**
- * @brief DMA callback invoked upon timer A..E related DMA request completion
- * @param hdma pointer to DMA handle.
- * @retval None
- */
- static void HRTIM_DMATimerxCplt(DMA_HandleTypeDef *hdma)
- {
- uint8_t timer_idx;
- HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
- timer_idx = (uint8_t)GetTimerIdxFromDMAHandle(hrtim, hdma);
- if ( !IS_HRTIM_TIMING_UNIT(timer_idx) ) {return;}
- if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP1) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare1EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Compare1EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP2) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare2EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Compare2EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP3) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare3EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Compare3EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CMP4) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Compare4EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Compare4EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_UPD) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->RegistersUpdateCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_RegistersUpdateCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CPT1) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Capture1EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Capture1EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_CPT2) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Capture2EventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Capture2EventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_SET1) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Output1SetCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Output1SetCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST1) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Output1ResetCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Output1ResetCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_SET2) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Output2SetCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Output2SetCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST2) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->Output2ResetCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_Output2ResetCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_RST) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->CounterResetCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_CounterResetCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_DLYPRT) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->DelayedProtectionCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_DelayedProtectionCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else if ((hrtim->Instance->sTimerxRegs[timer_idx].TIMxDIER & HRTIM_TIM_DMA_REP) != (uint32_t)RESET)
- {
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->RepetitionEventCallback(hrtim, timer_idx);
- #else
- HAL_HRTIM_RepetitionEventCallback(hrtim, timer_idx);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- else
- {
- /* nothing to do */
- }
- }
- /**
- * @brief DMA error callback
- * @param hdma pointer to DMA handle.
- * @retval None
- */
- static void HRTIM_DMAError(DMA_HandleTypeDef *hdma)
- {
- HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->ErrorCallback(hrtim);
- #else
- HAL_HRTIM_ErrorCallback(hrtim);
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- /**
- * @brief DMA callback invoked upon burst DMA transfer completion
- * @param hdma pointer to DMA handle.
- * @retval None
- */
- static void HRTIM_BurstDMACplt(DMA_HandleTypeDef *hdma)
- {
- HRTIM_HandleTypeDef * hrtim = (HRTIM_HandleTypeDef *)((DMA_HandleTypeDef* )hdma)->Parent;
- #if (USE_HAL_HRTIM_REGISTER_CALLBACKS == 1)
- hrtim->BurstDMATransferCallback(hrtim, GetTimerIdxFromDMAHandle(hrtim, hdma));
- #else
- HAL_HRTIM_BurstDMATransferCallback(hrtim, GetTimerIdxFromDMAHandle(hrtim, hdma));
- #endif /* USE_HAL_HRTIM_REGISTER_CALLBACKS */
- }
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* HRTIM1 */
- #endif /* HAL_HRTIM_MODULE_ENABLED */
- /**
- * @}
- */
|