| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219 |
- /**
- ******************************************************************************
- * @file lsm6ds3tr_c_reg.c
- * @author Sensors Software Solution Team
- * @brief LSM6DS3TR_C driver file
- ******************************************************************************
- * @attention
- *
- * <h2><center>© Copyright (c) 2021 STMicroelectronics.
- * All rights reserved.</center></h2>
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
- #include "lsm6ds3tr-c_reg.h"
- /**
- * @defgroup LSM6DS3TR_C
- * @brief This file provides a set of functions needed to drive the
- * lsm6ds3tr_c enanced inertial module.
- * @{
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_interfaces_functions
- * @brief This section provide a set of functions used to read and
- * write a generic register of the device.
- * MANDATORY: return 0 -> no Error.
- * @{
- *
- */
- /**
- * @brief Read generic device register
- *
- * @param ctx read / write interface definitions(ptr)
- * @param reg register to read
- * @param data pointer to buffer that store the data read(ptr)
- * @param len number of consecutive register to read
- * @retval interface status (MANDATORY: return 0 -> no Error)
- *
- */
- int32_t __weak lsm6ds3tr_c_read_reg(const stmdev_ctx_t *ctx, uint8_t reg,
- uint8_t *data,
- uint16_t len)
- {
- int32_t ret;
- if (ctx == NULL)
- {
- return -1;
- }
- ret = ctx->read_reg(ctx->handle, reg, data, len);
- return ret;
- }
- /**
- * @brief Write generic device register
- *
- * @param ctx read / write interface definitions(ptr)
- * @param reg register to write
- * @param data pointer to data to write in register reg(ptr)
- * @param len number of consecutive register to write
- * @retval interface status (MANDATORY: return 0 -> no Error)
- *
- */
- int32_t __weak lsm6ds3tr_c_write_reg(const stmdev_ctx_t *ctx, uint8_t reg,
- uint8_t *data,
- uint16_t len)
- {
- int32_t ret;
- if (ctx == NULL)
- {
- return -1;
- }
- ret = ctx->write_reg(ctx->handle, reg, data, len);
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Sensitivity
- * @brief These functions convert raw-data into engineering units.
- * @{
- *
- */
- float_t lsm6ds3tr_c_from_fs2g_to_mg(int16_t lsb)
- {
- return ((float_t)lsb * 0.061f);
- }
- float_t lsm6ds3tr_c_from_fs4g_to_mg(int16_t lsb)
- {
- return ((float_t)lsb * 0.122f);
- }
- float_t lsm6ds3tr_c_from_fs8g_to_mg(int16_t lsb)
- {
- return ((float_t)lsb * 0.244f);
- }
- float_t lsm6ds3tr_c_from_fs16g_to_mg(int16_t lsb)
- {
- return ((float_t)lsb * 0.488f);
- }
- float_t lsm6ds3tr_c_from_fs125dps_to_mdps(int16_t lsb)
- {
- return ((float_t)lsb * 4.375f);
- }
- float_t lsm6ds3tr_c_from_fs250dps_to_mdps(int16_t lsb)
- {
- return ((float_t)lsb * 8.750f);
- }
- float_t lsm6ds3tr_c_from_fs500dps_to_mdps(int16_t lsb)
- {
- return ((float_t)lsb * 17.50f);
- }
- float_t lsm6ds3tr_c_from_fs1000dps_to_mdps(int16_t lsb)
- {
- return ((float_t)lsb * 35.0f);
- }
- float_t lsm6ds3tr_c_from_fs2000dps_to_mdps(int16_t lsb)
- {
- return ((float_t)lsb * 70.0f);
- }
- float_t lsm6ds3tr_c_from_lsb_to_celsius(int16_t lsb)
- {
- return (((float_t)lsb / 256.0f) + 25.0f);
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_data_generation
- * @brief This section groups all the functions concerning data
- * generation
- * @{
- *
- */
- /**
- * @brief Accelerometer full-scale selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fs_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_full_scale_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fs_xl_t val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- if (ret == 0)
- {
- ctrl1_xl.fs_xl = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- }
- return ret;
- }
- /**
- * @brief Accelerometer full-scale selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of fs_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_full_scale_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fs_xl_t *val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- switch (ctrl1_xl.fs_xl)
- {
- case LSM6DS3TR_C_2g:
- *val = LSM6DS3TR_C_2g;
- break;
- case LSM6DS3TR_C_16g:
- *val = LSM6DS3TR_C_16g;
- break;
- case LSM6DS3TR_C_4g:
- *val = LSM6DS3TR_C_4g;
- break;
- case LSM6DS3TR_C_8g:
- *val = LSM6DS3TR_C_8g;
- break;
- default:
- *val = LSM6DS3TR_C_XL_FS_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Accelerometer data rate selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of odr_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_data_rate_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_xl_t val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- if (ret == 0)
- {
- ctrl1_xl.odr_xl = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- }
- return ret;
- }
- /**
- * @brief Accelerometer data rate selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of odr_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_data_rate_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_xl_t *val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- switch (ctrl1_xl.odr_xl)
- {
- case LSM6DS3TR_C_XL_ODR_OFF:
- *val = LSM6DS3TR_C_XL_ODR_OFF;
- break;
- case LSM6DS3TR_C_XL_ODR_12Hz5:
- *val = LSM6DS3TR_C_XL_ODR_12Hz5;
- break;
- case LSM6DS3TR_C_XL_ODR_26Hz:
- *val = LSM6DS3TR_C_XL_ODR_26Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_52Hz:
- *val = LSM6DS3TR_C_XL_ODR_52Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_104Hz:
- *val = LSM6DS3TR_C_XL_ODR_104Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_208Hz:
- *val = LSM6DS3TR_C_XL_ODR_208Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_416Hz:
- *val = LSM6DS3TR_C_XL_ODR_416Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_833Hz:
- *val = LSM6DS3TR_C_XL_ODR_833Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_1k66Hz:
- *val = LSM6DS3TR_C_XL_ODR_1k66Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_3k33Hz:
- *val = LSM6DS3TR_C_XL_ODR_3k33Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_6k66Hz:
- *val = LSM6DS3TR_C_XL_ODR_6k66Hz;
- break;
- case LSM6DS3TR_C_XL_ODR_1Hz6:
- *val = LSM6DS3TR_C_XL_ODR_1Hz6;
- break;
- default:
- *val = LSM6DS3TR_C_XL_ODR_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Gyroscope chain full-scale selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fs_g in reg CTRL2_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_full_scale_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fs_g_t val)
- {
- lsm6ds3tr_c_ctrl2_g_t ctrl2_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- if (ret == 0)
- {
- ctrl2_g.fs_g = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- }
- return ret;
- }
- /**
- * @brief Gyroscope chain full-scale selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of fs_g in reg CTRL2_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_full_scale_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fs_g_t *val)
- {
- lsm6ds3tr_c_ctrl2_g_t ctrl2_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- switch (ctrl2_g.fs_g)
- {
- case LSM6DS3TR_C_250dps:
- *val = LSM6DS3TR_C_250dps;
- break;
- case LSM6DS3TR_C_125dps:
- *val = LSM6DS3TR_C_125dps;
- break;
- case LSM6DS3TR_C_500dps:
- *val = LSM6DS3TR_C_500dps;
- break;
- case LSM6DS3TR_C_1000dps:
- *val = LSM6DS3TR_C_1000dps;
- break;
- case LSM6DS3TR_C_2000dps:
- *val = LSM6DS3TR_C_2000dps;
- break;
- default:
- *val = LSM6DS3TR_C_GY_FS_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Gyroscope data rate selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of odr_g in reg CTRL2_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_data_rate_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_g_t val)
- {
- lsm6ds3tr_c_ctrl2_g_t ctrl2_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- if (ret == 0)
- {
- ctrl2_g.odr_g = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- }
- return ret;
- }
- /**
- * @brief Gyroscope data rate selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of odr_g in reg CTRL2_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_data_rate_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_g_t *val)
- {
- lsm6ds3tr_c_ctrl2_g_t ctrl2_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL2_G,
- (uint8_t *)&ctrl2_g, 1);
- switch (ctrl2_g.odr_g)
- {
- case LSM6DS3TR_C_GY_ODR_OFF:
- *val = LSM6DS3TR_C_GY_ODR_OFF;
- break;
- case LSM6DS3TR_C_GY_ODR_12Hz5:
- *val = LSM6DS3TR_C_GY_ODR_12Hz5;
- break;
- case LSM6DS3TR_C_GY_ODR_26Hz:
- *val = LSM6DS3TR_C_GY_ODR_26Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_52Hz:
- *val = LSM6DS3TR_C_GY_ODR_52Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_104Hz:
- *val = LSM6DS3TR_C_GY_ODR_104Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_208Hz:
- *val = LSM6DS3TR_C_GY_ODR_208Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_416Hz:
- *val = LSM6DS3TR_C_GY_ODR_416Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_833Hz:
- *val = LSM6DS3TR_C_GY_ODR_833Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_1k66Hz:
- *val = LSM6DS3TR_C_GY_ODR_1k66Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_3k33Hz:
- *val = LSM6DS3TR_C_GY_ODR_3k33Hz;
- break;
- case LSM6DS3TR_C_GY_ODR_6k66Hz:
- *val = LSM6DS3TR_C_GY_ODR_6k66Hz;
- break;
- default:
- *val = LSM6DS3TR_C_GY_ODR_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Block data update.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of bdu in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_block_data_update_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.bdu = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Block data update.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of bdu in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_block_data_update_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- *val = ctrl3_c.bdu;
- return ret;
- }
- /**
- * @brief Weight of XL user offset bits of registers
- * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of usr_off_w in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_offset_weight_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_usr_off_w_t val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ctrl6_c.usr_off_w = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- }
- return ret;
- }
- /**
- * @brief Weight of XL user offset bits of registers
- * X_OFS_USR(73h), Y_OFS_USR(74h), Z_OFS_USR(75h).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of usr_off_w in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_offset_weight_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_usr_off_w_t *val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- switch (ctrl6_c.usr_off_w)
- {
- case LSM6DS3TR_C_LSb_1mg:
- *val = LSM6DS3TR_C_LSb_1mg;
- break;
- case LSM6DS3TR_C_LSb_16mg:
- *val = LSM6DS3TR_C_LSb_16mg;
- break;
- default:
- *val = LSM6DS3TR_C_WEIGHT_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief High-performance operating mode for accelerometer[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of xl_hm_mode in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_power_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_xl_hm_mode_t val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ctrl6_c.xl_hm_mode = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- }
- return ret;
- }
- /**
- * @brief High-performance operating mode for accelerometer.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of xl_hm_mode in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_power_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_xl_hm_mode_t *val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- switch (ctrl6_c.xl_hm_mode)
- {
- case LSM6DS3TR_C_XL_HIGH_PERFORMANCE:
- *val = LSM6DS3TR_C_XL_HIGH_PERFORMANCE;
- break;
- case LSM6DS3TR_C_XL_NORMAL:
- *val = LSM6DS3TR_C_XL_NORMAL;
- break;
- default:
- *val = LSM6DS3TR_C_XL_PW_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Source register rounding function on WAKE_UP_SRC (1Bh),
- * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and
- * FUNC_SRC1 (53h) registers in the primary interface.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of rounding_status in reg CTRL7_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_rounding_on_status_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rounding_status_t val)
- {
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- if (ret == 0)
- {
- ctrl7_g.rounding_status = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- }
- return ret;
- }
- /**
- * @brief Source register rounding function on WAKE_UP_SRC (1Bh),
- * TAP_SRC (1Ch), D6D_SRC (1Dh), STATUS_REG (1Eh) and
- * FUNC_SRC1 (53h) registers in the primary interface.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of rounding_status in reg CTRL7_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_rounding_on_status_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rounding_status_t *val)
- {
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- switch (ctrl7_g.rounding_status)
- {
- case LSM6DS3TR_C_STAT_RND_DISABLE:
- *val = LSM6DS3TR_C_STAT_RND_DISABLE;
- break;
- case LSM6DS3TR_C_STAT_RND_ENABLE:
- *val = LSM6DS3TR_C_STAT_RND_ENABLE;
- break;
- default:
- *val = LSM6DS3TR_C_STAT_RND_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief High-performance operating mode disable for gyroscope.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of g_hm_mode in reg CTRL7_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_power_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_g_hm_mode_t val)
- {
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- if (ret == 0)
- {
- ctrl7_g.g_hm_mode = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- }
- return ret;
- }
- /**
- * @brief High-performance operating mode disable for gyroscope.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of g_hm_mode in reg CTRL7_G
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_power_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_g_hm_mode_t *val)
- {
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- switch (ctrl7_g.g_hm_mode)
- {
- case LSM6DS3TR_C_GY_HIGH_PERFORMANCE:
- *val = LSM6DS3TR_C_GY_HIGH_PERFORMANCE;
- break;
- case LSM6DS3TR_C_GY_NORMAL:
- *val = LSM6DS3TR_C_GY_NORMAL;
- break;
- default:
- *val = LSM6DS3TR_C_GY_PW_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Read all the interrupt/status flag of the device.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val WAKE_UP_SRC, TAP_SRC, D6D_SRC, STATUS_REG,
- * FUNC_SRC1, FUNC_SRC2, WRIST_TILT_IA, A_WRIST_TILT_Mask
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_all_sources_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_all_sources_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_SRC,
- (uint8_t *) & (val->wake_up_src), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_SRC,
- (uint8_t *) & (val->tap_src), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_D6D_SRC,
- (uint8_t *) & (val->d6d_src), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG,
- (uint8_t *) & (val->status_reg), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_SRC1,
- (uint8_t *) & (val->func_src1), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_SRC2,
- (uint8_t *) & (val->func_src2), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WRIST_TILT_IA,
- (uint8_t *) & (val->wrist_tilt_ia), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK,
- (uint8_t *) & (val->a_wrist_tilt_mask), 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- return ret;
- }
- /**
- * @brief The STATUS_REG register is read by the primary interface[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Registers STATUS_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_status_reg_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_status_reg_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG,
- (uint8_t *) val, 1);
- return ret;
- }
- /**
- * @brief Accelerometer new data available.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of xlda in reg STATUS_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_flag_data_ready_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_status_reg_t status_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG,
- (uint8_t *)&status_reg, 1);
- *val = status_reg.xlda;
- return ret;
- }
- /**
- * @brief Gyroscope new data available.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of gda in reg STATUS_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_flag_data_ready_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_status_reg_t status_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG,
- (uint8_t *)&status_reg, 1);
- *val = status_reg.gda;
- return ret;
- }
- /**
- * @brief Temperature new data available.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tda in reg STATUS_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_temp_flag_data_ready_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_status_reg_t status_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STATUS_REG,
- (uint8_t *)&status_reg, 1);
- *val = status_reg.tda;
- return ret;
- }
- /**
- * @brief Accelerometer axis user offset correction expressed in two’s
- * complement, weight depends on USR_OFF_W in CTRL6_C.
- * The value must be in the range [-127 127].[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_usr_offset_set(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_X_OFS_USR, buff, 3);
- return ret;
- }
- /**
- * @brief Accelerometer axis user offset correction xpressed in two’s
- * complement, weight depends on USR_OFF_W in CTRL6_C.
- * The value must be in the range [-127 127].[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_usr_offset_get(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_X_OFS_USR, buff, 3);
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Timestamp
- * @brief This section groups all the functions that manage the
- * timestamp generation.
- * @{
- *
- */
- /**
- * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h),
- * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of timer_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_timestamp_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.timer_en = val;
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- }
- return ret;
- }
- /**
- * @brief Enable timestamp count. The count is saved in TIMESTAMP0_REG (40h),
- * TIMESTAMP1_REG (41h) and TIMESTAMP2_REG (42h).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of timer_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_timestamp_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.timer_en;
- return ret;
- }
- /**
- * @brief Timestamp register resolution setting.
- * Configuration of this bit affects
- * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h),
- * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h),
- * STEP_TIMESTAMP_H(4Ah) and
- * STEP_COUNT_DELTA(15h) registers.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of timer_hr in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_timestamp_res_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_timer_hr_t val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- if (ret == 0)
- {
- wake_up_dur.timer_hr = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- }
- return ret;
- }
- /**
- * @brief Timestamp register resolution setting.
- * Configuration of this bit affects
- * TIMESTAMP0_REG(40h), TIMESTAMP1_REG(41h),
- * TIMESTAMP2_REG(42h), STEP_TIMESTAMP_L(49h),
- * STEP_TIMESTAMP_H(4Ah) and
- * STEP_COUNT_DELTA(15h) registers.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of timer_hr in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_timestamp_res_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_timer_hr_t *val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- switch (wake_up_dur.timer_hr)
- {
- case LSM6DS3TR_C_LSB_6ms4:
- *val = LSM6DS3TR_C_LSB_6ms4;
- break;
- case LSM6DS3TR_C_LSB_25us:
- *val = LSM6DS3TR_C_LSB_25us;
- break;
- default:
- *val = LSM6DS3TR_C_TS_RES_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Dataoutput
- * @brief This section groups all the data output functions.
- * @{
- *
- */
- /**
- * @brief Circular burst-mode (rounding) read from output registers
- * through the primary interface.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of rounding in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_rounding_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rounding_t val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- if (ret == 0)
- {
- ctrl5_c.rounding = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- }
- return ret;
- }
- /**
- * @brief Circular burst-mode (rounding) read from output registers
- * through the primary interface.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of rounding in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_rounding_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rounding_t *val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- switch (ctrl5_c.rounding)
- {
- case LSM6DS3TR_C_ROUND_DISABLE:
- *val = LSM6DS3TR_C_ROUND_DISABLE;
- break;
- case LSM6DS3TR_C_ROUND_XL:
- *val = LSM6DS3TR_C_ROUND_XL;
- break;
- case LSM6DS3TR_C_ROUND_GY:
- *val = LSM6DS3TR_C_ROUND_GY;
- break;
- case LSM6DS3TR_C_ROUND_GY_XL:
- *val = LSM6DS3TR_C_ROUND_GY_XL;
- break;
- case LSM6DS3TR_C_ROUND_SH1_TO_SH6:
- *val = LSM6DS3TR_C_ROUND_SH1_TO_SH6;
- break;
- case LSM6DS3TR_C_ROUND_XL_SH1_TO_SH6:
- *val = LSM6DS3TR_C_ROUND_XL_SH1_TO_SH6;
- break;
- case LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH12:
- *val = LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH12;
- break;
- case LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH6:
- *val = LSM6DS3TR_C_ROUND_GY_XL_SH1_TO_SH6;
- break;
- default:
- *val = LSM6DS3TR_C_ROUND_OUT_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Temperature data output register (r). L and H registers together
- * express a 16-bit word in two’s complement.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_temperature_raw_get(const stmdev_ctx_t *ctx,
- int16_t *val)
- {
- uint8_t buff[2];
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUT_TEMP_L, buff, 2);
- *val = (int16_t)buff[1];
- *val = (*val * 256) + (int16_t)buff[0];
- return ret;
- }
- /**
- * @brief Angular rate sensor. The value is expressed as a 16-bit word in
- * two’s complement.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_angular_rate_raw_get(const stmdev_ctx_t *ctx,
- int16_t *val)
- {
- uint8_t buff[6];
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUTX_L_G, buff, 6);
- val[0] = (int16_t)buff[1];
- val[0] = (val[0] * 256) + (int16_t)buff[0];
- val[1] = (int16_t)buff[3];
- val[1] = (val[1] * 256) + (int16_t)buff[2];
- val[2] = (int16_t)buff[5];
- val[2] = (val[2] * 256) + (int16_t)buff[4];
- return ret;
- }
- /**
- * @brief Linear acceleration output register. The value is expressed
- * as a 16-bit word in two’s complement.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_acceleration_raw_get(const stmdev_ctx_t *ctx,
- int16_t *val)
- {
- uint8_t buff[6];
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUTX_L_XL, buff, 6);
- val[0] = (int16_t)buff[1];
- val[0] = (val[0] * 256) + (int16_t)buff[0];
- val[1] = (int16_t)buff[3];
- val[1] = (val[1] * 256) + (int16_t)buff[2];
- val[2] = (int16_t)buff[5];
- val[2] = (val[2] * 256) + (int16_t)buff[4];
- return ret;
- }
- /**
- * @brief External magnetometer raw data.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_calibrated_raw_get(const stmdev_ctx_t *ctx,
- int16_t *val)
- {
- uint8_t buff[6];
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_OUT_MAG_RAW_X_L, buff, 6);
- val[0] = (int16_t)buff[1];
- val[0] = (val[0] * 256) + (int16_t)buff[0];
- val[1] = (int16_t)buff[3];
- val[1] = (val[1] * 256) + (int16_t)buff[2];
- val[2] = (int16_t)buff[5];
- val[2] = (val[2] * 256) + (int16_t)buff[4];
- return ret;
- }
- /**
- * @brief Read data in FIFO.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buffer Data buffer to store FIFO data.
- * @param len Number of data to read from FIFO.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_raw_data_get(const stmdev_ctx_t *ctx,
- uint8_t *buffer,
- uint8_t len)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_DATA_OUT_L, buffer,
- len);
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_common
- * @brief This section groups common useful functions.
- * @{
- *
- */
- /**
- * @brief Enable access to the embedded functions/sensor hub
- * configuration registers[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of func_cfg_en in reg FUNC_CFG_ACCESS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mem_bank_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_func_cfg_en_t val)
- {
- lsm6ds3tr_c_func_cfg_access_t func_cfg_access;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS,
- (uint8_t *)&func_cfg_access, 1);
- if (ret == 0)
- {
- func_cfg_access.func_cfg_en = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS,
- (uint8_t *)&func_cfg_access, 1);
- }
- return ret;
- }
- /**
- * @brief Enable access to the embedded functions/sensor hub configuration
- * registers[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of func_cfg_en in reg FUNC_CFG_ACCESS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mem_bank_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_func_cfg_en_t *val)
- {
- lsm6ds3tr_c_func_cfg_access_t func_cfg_access;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FUNC_CFG_ACCESS,
- (uint8_t *)&func_cfg_access, 1);
- switch (func_cfg_access.func_cfg_en)
- {
- case LSM6DS3TR_C_USER_BANK:
- *val = LSM6DS3TR_C_USER_BANK;
- break;
- case LSM6DS3TR_C_BANK_B:
- *val = LSM6DS3TR_C_BANK_B;
- break;
- default:
- *val = LSM6DS3TR_C_BANK_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Data-ready pulsed / letched mode[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of drdy_pulsed in reg DRDY_PULSE_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_data_ready_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_drdy_pulsed_g_t val)
- {
- lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- if (ret == 0)
- {
- drdy_pulse_cfg_g.drdy_pulsed = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- }
- return ret;
- }
- /**
- * @brief Data-ready pulsed / letched mode[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of drdy_pulsed in reg DRDY_PULSE_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_data_ready_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_drdy_pulsed_g_t *val)
- {
- lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- switch (drdy_pulse_cfg_g.drdy_pulsed)
- {
- case LSM6DS3TR_C_DRDY_LATCHED:
- *val = LSM6DS3TR_C_DRDY_LATCHED;
- break;
- case LSM6DS3TR_C_DRDY_PULSED:
- *val = LSM6DS3TR_C_DRDY_PULSED;
- break;
- default:
- *val = LSM6DS3TR_C_DRDY_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief DeviceWhoamI.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_device_id_get(const stmdev_ctx_t *ctx, uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WHO_AM_I, buff, 1);
- return ret;
- }
- /**
- * @brief Software reset. Restore the default values in user registers[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sw_reset in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_reset_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.sw_reset = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Software reset. Restore the default values in user registers[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sw_reset in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_reset_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- *val = ctrl3_c.sw_reset;
- return ret;
- }
- /**
- * @brief Big/Little Endian Data selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ble in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_data_format_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_ble_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.ble = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Big/Little Endian Data selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of ble in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_data_format_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_ble_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- switch (ctrl3_c.ble)
- {
- case LSM6DS3TR_C_LSB_AT_LOW_ADD:
- *val = LSM6DS3TR_C_LSB_AT_LOW_ADD;
- break;
- case LSM6DS3TR_C_MSB_AT_LOW_ADD:
- *val = LSM6DS3TR_C_MSB_AT_LOW_ADD;
- break;
- default:
- *val = LSM6DS3TR_C_DATA_FMT_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Register address automatically incremented during a multiple byte
- * access with a serial interface.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of if_inc in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_auto_increment_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.if_inc = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Register address automatically incremented during a multiple byte
- * access with a serial interface.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of if_inc in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_auto_increment_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- *val = ctrl3_c.if_inc;
- return ret;
- }
- /**
- * @brief Reboot memory content. Reload the calibration parameters.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of boot in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_boot_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.boot = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Reboot memory content. Reload the calibration parameters.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of boot in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_boot_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- *val = ctrl3_c.boot;
- return ret;
- }
- /**
- * @brief Linear acceleration sensor self-test enable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of st_xl in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_self_test_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_st_xl_t val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- if (ret == 0)
- {
- ctrl5_c.st_xl = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- }
- return ret;
- }
- /**
- * @brief Linear acceleration sensor self-test enable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of st_xl in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_self_test_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_st_xl_t *val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- switch (ctrl5_c.st_xl)
- {
- case LSM6DS3TR_C_XL_ST_DISABLE:
- *val = LSM6DS3TR_C_XL_ST_DISABLE;
- break;
- case LSM6DS3TR_C_XL_ST_POSITIVE:
- *val = LSM6DS3TR_C_XL_ST_POSITIVE;
- break;
- case LSM6DS3TR_C_XL_ST_NEGATIVE:
- *val = LSM6DS3TR_C_XL_ST_NEGATIVE;
- break;
- default:
- *val = LSM6DS3TR_C_XL_ST_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Angular rate sensor self-test enable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of st_g in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_self_test_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_st_g_t val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- if (ret == 0)
- {
- ctrl5_c.st_g = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- }
- return ret;
- }
- /**
- * @brief Angular rate sensor self-test enable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of st_g in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_self_test_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_st_g_t *val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- switch (ctrl5_c.st_g)
- {
- case LSM6DS3TR_C_GY_ST_DISABLE:
- *val = LSM6DS3TR_C_GY_ST_DISABLE;
- break;
- case LSM6DS3TR_C_GY_ST_POSITIVE:
- *val = LSM6DS3TR_C_GY_ST_POSITIVE;
- break;
- case LSM6DS3TR_C_GY_ST_NEGATIVE:
- *val = LSM6DS3TR_C_GY_ST_NEGATIVE;
- break;
- default:
- *val = LSM6DS3TR_C_GY_ST_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_filters
- * @brief This section group all the functions concerning the filters
- * configuration that impact both accelerometer and gyro.
- * @{
- *
- */
- /**
- * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends
- * (XL and Gyro independently masked).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of drdy_mask in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_filter_settling_mask_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.drdy_mask = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- return ret;
- }
- /**
- * @brief Mask DRDY on pin (both XL & Gyro) until filter settling ends
- * (XL and Gyro independently masked).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of drdy_mask in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_filter_settling_mask_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- *val = ctrl4_c.drdy_mask;
- return ret;
- }
- /**
- * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity
- * functions.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of slope_fds in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_hp_path_internal_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slope_fds_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.slope_fds = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief HPF or SLOPE filter selection on wake-up and Activity/Inactivity
- * functions.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of slope_fds in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_hp_path_internal_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slope_fds_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- switch (tap_cfg.slope_fds)
- {
- case LSM6DS3TR_C_USE_SLOPE:
- *val = LSM6DS3TR_C_USE_SLOPE;
- break;
- case LSM6DS3TR_C_USE_HPF:
- *val = LSM6DS3TR_C_USE_HPF;
- break;
- default:
- *val = LSM6DS3TR_C_HP_PATH_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_accelerometer_filters
- * @brief This section group all the functions concerning the filters
- * configuration that impact accelerometer in every mode.
- * @{
- *
- */
- /**
- * @brief Accelerometer analog chain bandwidth selection (only for
- * accelerometer ODR ≥ 1.67 kHz).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of bw0_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_filter_analog_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_bw0_xl_t val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- if (ret == 0)
- {
- ctrl1_xl.bw0_xl = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- }
- return ret;
- }
- /**
- * @brief Accelerometer analog chain bandwidth selection (only for
- * accelerometer ODR ≥ 1.67 kHz).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of bw0_xl in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_filter_analog_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_bw0_xl_t *val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- switch (ctrl1_xl.bw0_xl)
- {
- case LSM6DS3TR_C_XL_ANA_BW_1k5Hz:
- *val = LSM6DS3TR_C_XL_ANA_BW_1k5Hz;
- break;
- case LSM6DS3TR_C_XL_ANA_BW_400Hz:
- *val = LSM6DS3TR_C_XL_ANA_BW_400Hz;
- break;
- default:
- *val = LSM6DS3TR_C_XL_ANA_BW_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_accelerometer_filters
- * @brief This section group all the functions concerning the filters
- * configuration that impact accelerometer.
- * @{
- *
- */
- /**
- * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2 is
- * not used.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of lpf1_bw_sel in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_lp1_bandwidth_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lpf1_bw_sel_t val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- if (ret == 0)
- {
- ctrl1_xl.lpf1_bw_sel = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- ctrl8_xl.lpf2_xl_en = 0;
- ctrl8_xl.hp_slope_xl_en = 0;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Accelerometer digital LPF (LPF1) bandwidth selection LPF2
- * is not used.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of lpf1_bw_sel in reg CTRL1_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_lp1_bandwidth_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lpf1_bw_sel_t *val)
- {
- lsm6ds3tr_c_ctrl1_xl_t ctrl1_xl;
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- if ((ctrl8_xl.lpf2_xl_en != 0x00U) ||
- (ctrl8_xl.hp_slope_xl_en != 0x00U))
- {
- *val = LSM6DS3TR_C_XL_LP1_NA;
- }
- else
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL1_XL,
- (uint8_t *)&ctrl1_xl, 1);
- switch (ctrl1_xl.lpf1_bw_sel)
- {
- case LSM6DS3TR_C_XL_LP1_ODR_DIV_2:
- *val = LSM6DS3TR_C_XL_LP1_ODR_DIV_2;
- break;
- case LSM6DS3TR_C_XL_LP1_ODR_DIV_4:
- *val = LSM6DS3TR_C_XL_LP1_ODR_DIV_4;
- break;
- default:
- *val = LSM6DS3TR_C_XL_LP1_NA;
- break;
- }
- }
- }
- return ret;
- }
- /**
- * @brief LPF2 on outputs[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of input_composite in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_lp2_bandwidth_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_input_composite_t val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- ctrl8_xl.input_composite = ((uint8_t) val & 0x10U) >> 4;
- ctrl8_xl.hpcf_xl = (uint8_t) val & 0x03U;
- ctrl8_xl.lpf2_xl_en = 1;
- ctrl8_xl.hp_slope_xl_en = 0;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- }
- return ret;
- }
- /**
- * @brief LPF2 on outputs[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of input_composite in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_lp2_bandwidth_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_input_composite_t *val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- if ((ctrl8_xl.lpf2_xl_en == 0x00U) ||
- (ctrl8_xl.hp_slope_xl_en != 0x00U))
- {
- *val = LSM6DS3TR_C_XL_LP_NA;
- }
- else
- {
- switch ((ctrl8_xl.input_composite << 4) + ctrl8_xl.hpcf_xl)
- {
- case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_50:
- *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_50;
- break;
- case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_100:
- *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_100;
- break;
- case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_9:
- *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_9;
- break;
- case LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_400:
- *val = LSM6DS3TR_C_XL_LOW_LAT_LP_ODR_DIV_400;
- break;
- case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_50:
- *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_50;
- break;
- case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_100:
- *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_100;
- break;
- case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_9:
- *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_9;
- break;
- case LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_400:
- *val = LSM6DS3TR_C_XL_LOW_NOISE_LP_ODR_DIV_400;
- break;
- default:
- *val = LSM6DS3TR_C_XL_LP_NA;
- break;
- }
- }
- }
- return ret;
- }
- /**
- * @brief Enable HP filter reference mode.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of hp_ref_mode in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_reference_mode_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- ctrl8_xl.hp_ref_mode = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- }
- return ret;
- }
- /**
- * @brief Enable HP filter reference mode.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of hp_ref_mode in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_reference_mode_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- *val = ctrl8_xl.hp_ref_mode;
- return ret;
- }
- /**
- * @brief High pass/Slope on outputs.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of hpcf_xl in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_hp_bandwidth_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_hpcf_xl_t val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- ctrl8_xl.input_composite = 0;
- ctrl8_xl.hpcf_xl = (uint8_t)val & 0x03U;
- ctrl8_xl.hp_slope_xl_en = 1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- }
- return ret;
- }
- /**
- * @brief High pass/Slope on outputs.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of hpcf_xl in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_xl_hp_bandwidth_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_hpcf_xl_t *val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ctrl8_xl.hp_slope_xl_en == 0x00U)
- {
- *val = LSM6DS3TR_C_XL_HP_NA;
- }
- switch (ctrl8_xl.hpcf_xl)
- {
- case LSM6DS3TR_C_XL_HP_ODR_DIV_4:
- *val = LSM6DS3TR_C_XL_HP_ODR_DIV_4;
- break;
- case LSM6DS3TR_C_XL_HP_ODR_DIV_100:
- *val = LSM6DS3TR_C_XL_HP_ODR_DIV_100;
- break;
- case LSM6DS3TR_C_XL_HP_ODR_DIV_9:
- *val = LSM6DS3TR_C_XL_HP_ODR_DIV_9;
- break;
- case LSM6DS3TR_C_XL_HP_ODR_DIV_400:
- *val = LSM6DS3TR_C_XL_HP_ODR_DIV_400;
- break;
- default:
- *val = LSM6DS3TR_C_XL_HP_NA;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_gyroscope_filters
- * @brief This section group all the functions concerning the filters
- * configuration that impact gyroscope.
- * @{
- *
- */
- /**
- * @brief Gyroscope low pass path bandwidth.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val gyroscope filtering chain configuration.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_band_pass_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lpf1_sel_g_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- if (ret == 0)
- {
- ctrl7_g.hpm_g = ((uint8_t)val & 0x30U) >> 4;
- ctrl7_g.hp_en_g = ((uint8_t)val & 0x80U) >> 7;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ctrl6_c.ftype = (uint8_t)val & 0x03U;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.lpf1_sel_g = ((uint8_t)val & 0x08U) >> 3;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Gyroscope low pass path bandwidth.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val gyroscope filtering chain
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_band_pass_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lpf1_sel_g_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- lsm6ds3tr_c_ctrl7_g_t ctrl7_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL7_G,
- (uint8_t *)&ctrl7_g, 1);
- switch ((ctrl7_g.hp_en_g << 7) + (ctrl7_g.hpm_g << 4) +
- (ctrl4_c.lpf1_sel_g << 3) + ctrl6_c.ftype)
- {
- case LSM6DS3TR_C_HP_16mHz_LP2:
- *val = LSM6DS3TR_C_HP_16mHz_LP2;
- break;
- case LSM6DS3TR_C_HP_65mHz_LP2:
- *val = LSM6DS3TR_C_HP_65mHz_LP2;
- break;
- case LSM6DS3TR_C_HP_260mHz_LP2:
- *val = LSM6DS3TR_C_HP_260mHz_LP2;
- break;
- case LSM6DS3TR_C_HP_1Hz04_LP2:
- *val = LSM6DS3TR_C_HP_1Hz04_LP2;
- break;
- case LSM6DS3TR_C_HP_DISABLE_LP1_LIGHT:
- *val = LSM6DS3TR_C_HP_DISABLE_LP1_LIGHT;
- break;
- case LSM6DS3TR_C_HP_DISABLE_LP1_NORMAL:
- *val = LSM6DS3TR_C_HP_DISABLE_LP1_NORMAL;
- break;
- case LSM6DS3TR_C_HP_DISABLE_LP_STRONG:
- *val = LSM6DS3TR_C_HP_DISABLE_LP_STRONG;
- break;
- case LSM6DS3TR_C_HP_DISABLE_LP1_AGGRESSIVE:
- *val = LSM6DS3TR_C_HP_DISABLE_LP1_AGGRESSIVE;
- break;
- case LSM6DS3TR_C_HP_16mHz_LP1_LIGHT:
- *val = LSM6DS3TR_C_HP_16mHz_LP1_LIGHT;
- break;
- case LSM6DS3TR_C_HP_65mHz_LP1_NORMAL:
- *val = LSM6DS3TR_C_HP_65mHz_LP1_NORMAL;
- break;
- case LSM6DS3TR_C_HP_260mHz_LP1_STRONG:
- *val = LSM6DS3TR_C_HP_260mHz_LP1_STRONG;
- break;
- case LSM6DS3TR_C_HP_1Hz04_LP1_AGGRESSIVE:
- *val = LSM6DS3TR_C_HP_1Hz04_LP1_AGGRESSIVE;
- break;
- default:
- *val = LSM6DS3TR_C_HP_GY_BAND_NA;
- break;
- }
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_serial_interface
- * @brief This section groups all the functions concerning serial
- * interface management
- * @{
- *
- */
- /**
- * @brief SPI Serial Interface Mode selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sim in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_spi_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sim_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.sim = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief SPI Serial Interface Mode selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of sim in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_spi_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sim_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- switch (ctrl3_c.sim)
- {
- case LSM6DS3TR_C_SPI_4_WIRE:
- *val = LSM6DS3TR_C_SPI_4_WIRE;
- break;
- case LSM6DS3TR_C_SPI_3_WIRE:
- *val = LSM6DS3TR_C_SPI_3_WIRE;
- break;
- default:
- *val = LSM6DS3TR_C_SPI_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Disable / Enable I2C interface.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of i2c_disable in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_i2c_interface_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_i2c_disable_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.i2c_disable = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- return ret;
- }
- /**
- * @brief Disable / Enable I2C interface.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of i2c_disable in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_i2c_interface_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_i2c_disable_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- switch (ctrl4_c.i2c_disable)
- {
- case LSM6DS3TR_C_I2C_ENABLE:
- *val = LSM6DS3TR_C_I2C_ENABLE;
- break;
- case LSM6DS3TR_C_I2C_DISABLE:
- *val = LSM6DS3TR_C_I2C_DISABLE;
- break;
- default:
- *val = LSM6DS3TR_C_I2C_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_interrupt_pins
- * @brief This section groups all the functions that manage
- * interrupt pins
- * @{
- *
- */
- /**
- * @brief Select the signal that need to route on int1 pad[set]
- *
- * @param ctx Read / write interface definitions
- * @param val configure INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1),
- * MASTER_CONFIG(drdy_on_int1)
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_int1_route_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_int1_route_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- lsm6ds3tr_c_int1_ctrl_t int1_ctrl;
- lsm6ds3tr_c_md1_cfg_t md1_cfg;
- lsm6ds3tr_c_md2_cfg_t md2_cfg;
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT1_CTRL,
- (uint8_t *)&int1_ctrl, 1);
- if (ret == 0)
- {
- int1_ctrl.int1_drdy_xl = val.int1_drdy_xl;
- int1_ctrl.int1_drdy_g = val.int1_drdy_g;
- int1_ctrl.int1_boot = val.int1_boot;
- int1_ctrl.int1_fth = val.int1_fth;
- int1_ctrl.int1_fifo_ovr = val.int1_fifo_ovr;
- int1_ctrl.int1_full_flag = val.int1_full_flag;
- int1_ctrl.int1_sign_mot = val.int1_sign_mot;
- int1_ctrl.int1_step_detector = val.int1_step_detector;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT1_CTRL,
- (uint8_t *)&int1_ctrl, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG,
- (uint8_t *)&md1_cfg, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG,
- (uint8_t *)&md2_cfg, 1);
- }
- if (ret == 0)
- {
- md1_cfg.int1_timer = val.int1_timer;
- md1_cfg.int1_tilt = val.int1_tilt;
- md1_cfg.int1_6d = val.int1_6d;
- md1_cfg.int1_double_tap = val.int1_double_tap;
- md1_cfg.int1_ff = val.int1_ff;
- md1_cfg.int1_wu = val.int1_wu;
- md1_cfg.int1_single_tap = val.int1_single_tap;
- md1_cfg.int1_inact_state = val.int1_inact_state;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MD1_CFG,
- (uint8_t *)&md1_cfg, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- if (ret == 0)
- {
- ctrl4_c.den_drdy_int1 = val.den_drdy_int1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- if (ret == 0)
- {
- master_config.drdy_on_int1 = val.den_drdy_int1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if ((val.int1_6d != 0x00U) ||
- (val.int1_ff != 0x00U) ||
- (val.int1_wu != 0x00U) ||
- (val.int1_single_tap != 0x00U) ||
- (val.int1_double_tap != 0x00U) ||
- (val.int1_inact_state != 0x00U) ||
- (md2_cfg.int2_6d != 0x00U) ||
- (md2_cfg.int2_ff != 0x00U) ||
- (md2_cfg.int2_wu != 0x00U) ||
- (md2_cfg.int2_single_tap != 0x00U) ||
- (md2_cfg.int2_double_tap != 0x00U) ||
- (md2_cfg.int2_inact_state != 0x00U))
- {
- tap_cfg.interrupts_enable = PROPERTY_ENABLE;
- }
- else
- {
- tap_cfg.interrupts_enable = PROPERTY_DISABLE;
- }
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Select the signal that need to route on int1 pad[get]
- *
- * @param ctx Read / write interface definitions
- * @param val read INT1_CTRL, MD1_CFG, CTRL4_C(den_drdy_int1),
- * MASTER_CONFIG(drdy_on_int1)
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_int1_route_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_int1_route_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- lsm6ds3tr_c_int1_ctrl_t int1_ctrl;
- lsm6ds3tr_c_md1_cfg_t md1_cfg;
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT1_CTRL,
- (uint8_t *)&int1_ctrl, 1);
- if (ret == 0)
- {
- val->int1_drdy_xl = int1_ctrl.int1_drdy_xl;
- val->int1_drdy_g = int1_ctrl.int1_drdy_g;
- val->int1_boot = int1_ctrl.int1_boot;
- val->int1_fth = int1_ctrl.int1_fth;
- val->int1_fifo_ovr = int1_ctrl.int1_fifo_ovr;
- val->int1_full_flag = int1_ctrl.int1_full_flag;
- val->int1_sign_mot = int1_ctrl.int1_sign_mot;
- val->int1_step_detector = int1_ctrl.int1_step_detector ;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG,
- (uint8_t *)&md1_cfg, 1);
- if (ret == 0)
- {
- val->int1_timer = md1_cfg.int1_timer;
- val->int1_tilt = md1_cfg.int1_tilt;
- val->int1_6d = md1_cfg.int1_6d;
- val->int1_double_tap = md1_cfg.int1_double_tap;
- val->int1_ff = md1_cfg.int1_ff;
- val->int1_wu = md1_cfg.int1_wu;
- val->int1_single_tap = md1_cfg.int1_single_tap;
- val->int1_inact_state = md1_cfg.int1_inact_state;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- val->den_drdy_int1 = ctrl4_c.den_drdy_int1;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- val->den_drdy_int1 = master_config.drdy_on_int1;
- }
- }
- }
- return ret;
- }
- /**
- * @brief Select the signal that need to route on int2 pad[set]
- *
- * @param ctx Read / write interface definitions
- * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_int2_route_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_int2_route_t val)
- {
- lsm6ds3tr_c_int2_ctrl_t int2_ctrl;
- lsm6ds3tr_c_md1_cfg_t md1_cfg;
- lsm6ds3tr_c_md2_cfg_t md2_cfg;
- lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g;
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT2_CTRL,
- (uint8_t *)&int2_ctrl, 1);
- if (ret == 0)
- {
- int2_ctrl.int2_drdy_xl = val.int2_drdy_xl;
- int2_ctrl.int2_drdy_g = val.int2_drdy_g;
- int2_ctrl.int2_drdy_temp = val.int2_drdy_temp;
- int2_ctrl.int2_fth = val.int2_fth;
- int2_ctrl.int2_fifo_ovr = val.int2_fifo_ovr;
- int2_ctrl.int2_full_flag = val.int2_full_flag;
- int2_ctrl.int2_step_count_ov = val.int2_step_count_ov;
- int2_ctrl.int2_step_delta = val.int2_step_delta;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT2_CTRL,
- (uint8_t *)&int2_ctrl, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD1_CFG,
- (uint8_t *)&md1_cfg, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG,
- (uint8_t *)&md2_cfg, 1);
- }
- if (ret == 0)
- {
- md2_cfg.int2_iron = val.int2_iron;
- md2_cfg.int2_tilt = val.int2_tilt;
- md2_cfg.int2_6d = val.int2_6d;
- md2_cfg.int2_double_tap = val.int2_double_tap;
- md2_cfg.int2_ff = val.int2_ff;
- md2_cfg.int2_wu = val.int2_wu;
- md2_cfg.int2_single_tap = val.int2_single_tap;
- md2_cfg.int2_inact_state = val.int2_inact_state;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MD2_CFG,
- (uint8_t *)&md2_cfg, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- }
- if (ret == 0)
- {
- drdy_pulse_cfg_g.int2_wrist_tilt = val.int2_wrist_tilt;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if ((md1_cfg.int1_6d != 0x00U) ||
- (md1_cfg.int1_ff != 0x00U) ||
- (md1_cfg.int1_wu != 0x00U) ||
- (md1_cfg.int1_single_tap != 0x00U) ||
- (md1_cfg.int1_double_tap != 0x00U) ||
- (md1_cfg.int1_inact_state != 0x00U) ||
- (val.int2_6d != 0x00U) ||
- (val.int2_ff != 0x00U) ||
- (val.int2_wu != 0x00U) ||
- (val.int2_single_tap != 0x00U) ||
- (val.int2_double_tap != 0x00U) ||
- (val.int2_inact_state != 0x00U))
- {
- tap_cfg.interrupts_enable = PROPERTY_ENABLE;
- }
- else
- {
- tap_cfg.interrupts_enable = PROPERTY_DISABLE;
- }
- }
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Select the signal that need to route on int2 pad[get]
- *
- * @param ctx Read / write interface definitions
- * @param val INT2_CTRL, DRDY_PULSE_CFG(int2_wrist_tilt), MD2_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_int2_route_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_int2_route_t *val)
- {
- lsm6ds3tr_c_int2_ctrl_t int2_ctrl;
- lsm6ds3tr_c_md2_cfg_t md2_cfg;
- lsm6ds3tr_c_drdy_pulse_cfg_g_t drdy_pulse_cfg_g;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT2_CTRL,
- (uint8_t *)&int2_ctrl, 1);
- if (ret == 0)
- {
- val->int2_drdy_xl = int2_ctrl.int2_drdy_xl;
- val->int2_drdy_g = int2_ctrl.int2_drdy_g;
- val->int2_drdy_temp = int2_ctrl.int2_drdy_temp;
- val->int2_fth = int2_ctrl.int2_fth;
- val->int2_fifo_ovr = int2_ctrl.int2_fifo_ovr;
- val->int2_full_flag = int2_ctrl.int2_full_flag;
- val->int2_step_count_ov = int2_ctrl.int2_step_count_ov;
- val->int2_step_delta = int2_ctrl.int2_step_delta;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MD2_CFG,
- (uint8_t *)&md2_cfg, 1);
- if (ret == 0)
- {
- val->int2_iron = md2_cfg.int2_iron;
- val->int2_tilt = md2_cfg.int2_tilt;
- val->int2_6d = md2_cfg.int2_6d;
- val->int2_double_tap = md2_cfg.int2_double_tap;
- val->int2_ff = md2_cfg.int2_ff;
- val->int2_wu = md2_cfg.int2_wu;
- val->int2_single_tap = md2_cfg.int2_single_tap;
- val->int2_inact_state = md2_cfg.int2_inact_state;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_DRDY_PULSE_CFG_G,
- (uint8_t *)&drdy_pulse_cfg_g, 1);
- val->int2_wrist_tilt = drdy_pulse_cfg_g.int2_wrist_tilt;
- }
- }
- return ret;
- }
- /**
- * @brief Push-pull/open drain selection on interrupt pads.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pp_od in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pp_od_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.pp_od = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Push-pull/open drain selection on interrupt pads.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of pp_od in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pp_od_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- switch (ctrl3_c.pp_od)
- {
- case LSM6DS3TR_C_PUSH_PULL:
- *val = LSM6DS3TR_C_PUSH_PULL;
- break;
- case LSM6DS3TR_C_OPEN_DRAIN:
- *val = LSM6DS3TR_C_OPEN_DRAIN;
- break;
- default:
- *val = LSM6DS3TR_C_PIN_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Interrupt active-high/low.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of h_lactive in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_polarity_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_h_lactive_t val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- if (ret == 0)
- {
- ctrl3_c.h_lactive = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- }
- return ret;
- }
- /**
- * @brief Interrupt active-high/low.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of h_lactive in reg CTRL3_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pin_polarity_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_h_lactive_t *val)
- {
- lsm6ds3tr_c_ctrl3_c_t ctrl3_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL3_C,
- (uint8_t *)&ctrl3_c, 1);
- switch (ctrl3_c.h_lactive)
- {
- case LSM6DS3TR_C_ACTIVE_HIGH:
- *val = LSM6DS3TR_C_ACTIVE_HIGH;
- break;
- case LSM6DS3TR_C_ACTIVE_LOW:
- *val = LSM6DS3TR_C_ACTIVE_LOW;
- break;
- default:
- *val = LSM6DS3TR_C_POLARITY_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief All interrupt signals become available on INT1 pin.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of int2_on_int1 in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_all_on_int1_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.int2_on_int1 = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- return ret;
- }
- /**
- * @brief All interrupt signals become available on INT1 pin.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of int2_on_int1 in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_all_on_int1_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- *val = ctrl4_c.int2_on_int1;
- return ret;
- }
- /**
- * @brief Latched/pulsed interrupt.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of lir in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_int_notification_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lir_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.lir = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Latched/pulsed interrupt.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of lir in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_int_notification_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_lir_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- switch (tap_cfg.lir)
- {
- case LSM6DS3TR_C_INT_PULSED:
- *val = LSM6DS3TR_C_INT_PULSED;
- break;
- case LSM6DS3TR_C_INT_LATCHED:
- *val = LSM6DS3TR_C_INT_LATCHED;
- break;
- default:
- *val = LSM6DS3TR_C_INT_MODE;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Wake_Up_event
- * @brief This section groups all the functions that manage the
- * Wake Up event generation.
- * @{
- *
- */
- /**
- * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of wk_ths in reg WAKE_UP_THS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wkup_threshold_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_wake_up_ths_t wake_up_ths;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- if (ret == 0)
- {
- wake_up_ths.wk_ths = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- }
- return ret;
- }
- /**
- * @brief Threshold for wakeup.1 LSB = FS_XL / 64.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of wk_ths in reg WAKE_UP_THS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wkup_threshold_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_wake_up_ths_t wake_up_ths;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- *val = wake_up_ths.wk_ths;
- return ret;
- }
- /**
- * @brief Wake up duration event.1LSb = 1 / ODR[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of wake_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wkup_dur_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- if (ret == 0)
- {
- wake_up_dur.wake_dur = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- }
- return ret;
- }
- /**
- * @brief Wake up duration event.1LSb = 1 / ODR[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of wake_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wkup_dur_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- *val = wake_up_dur.wake_dur;
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Activity/Inactivity_detection
- * @brief This section groups all the functions concerning
- * activity/inactivity detection.
- * @{
- *
- */
- /**
- * @brief Enables gyroscope Sleep mode.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sleep in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_sleep_mode_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.sleep = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- return ret;
- }
- /**
- * @brief Enables gyroscope Sleep mode.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sleep in reg CTRL4_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_gy_sleep_mode_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- *val = ctrl4_c.sleep;
- return ret;
- }
- /**
- * @brief Enable inactivity function.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of inact_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_act_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_inact_en_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.inact_en = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Enable inactivity function.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of inact_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_act_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_inact_en_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- switch (tap_cfg.inact_en)
- {
- case LSM6DS3TR_C_PROPERTY_DISABLE:
- *val = LSM6DS3TR_C_PROPERTY_DISABLE;
- break;
- case LSM6DS3TR_C_XL_12Hz5_GY_NOT_AFFECTED:
- *val = LSM6DS3TR_C_XL_12Hz5_GY_NOT_AFFECTED;
- break;
- case LSM6DS3TR_C_XL_12Hz5_GY_SLEEP:
- *val = LSM6DS3TR_C_XL_12Hz5_GY_SLEEP;
- break;
- case LSM6DS3TR_C_XL_12Hz5_GY_PD:
- *val = LSM6DS3TR_C_XL_12Hz5_GY_PD;
- break;
- default:
- *val = LSM6DS3TR_C_ACT_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Duration to go in sleep mode.1 LSb = 512 / ODR[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sleep_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_act_sleep_dur_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- if (ret == 0)
- {
- wake_up_dur.sleep_dur = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- }
- return ret;
- }
- /**
- * @brief Duration to go in sleep mode. 1 LSb = 512 / ODR[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sleep_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_act_sleep_dur_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- *val = wake_up_dur.sleep_dur;
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_tap_generator
- * @brief This section groups all the functions that manage the
- * tap and double tap event generation.
- * @{
- *
- */
- /**
- * @brief Read the tap / double tap source register.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure of registers from TAP_SRC
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_src_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_tap_src_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_SRC, (uint8_t *) val, 1);
- return ret;
- }
- /**
- * @brief Enable Z direction in tap recognition.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_z_en in reg TAP_CFG
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_z_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.tap_z_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Enable Z direction in tap recognition.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_z_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_z_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- *val = tap_cfg.tap_z_en;
- return ret;
- }
- /**
- * @brief Enable Y direction in tap recognition.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_y_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_y_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.tap_y_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Enable Y direction in tap recognition.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_y_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_y_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- *val = tap_cfg.tap_y_en;
- return ret;
- }
- /**
- * @brief Enable X direction in tap recognition.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_x_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_x_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- if (ret == 0)
- {
- tap_cfg.tap_x_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- }
- return ret;
- }
- /**
- * @brief Enable X direction in tap recognition.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_x_en in reg TAP_CFG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_detection_on_x_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_tap_cfg_t tap_cfg;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_CFG,
- (uint8_t *)&tap_cfg, 1);
- *val = tap_cfg.tap_x_en;
- return ret;
- }
- /**
- * @brief Threshold for tap recognition.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_ths in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_threshold_x_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- if (ret == 0)
- {
- tap_ths_6d.tap_ths = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- }
- return ret;
- }
- /**
- * @brief Threshold for tap recognition.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tap_ths in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_threshold_x_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- *val = tap_ths_6d.tap_ths;
- return ret;
- }
- /**
- * @brief Maximum duration is the maximum time of an overthreshold signal
- * detection to be recognized as a tap event.
- * The default value of these bits is 00b which corresponds to
- * 4*ODR_XL time.
- * If the SHOCK[1:0] bits are set to a different
- * value, 1LSB corresponds to 8*ODR_XL time.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of shock in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_shock_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- if (ret == 0)
- {
- int_dur2.shock = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- }
- return ret;
- }
- /**
- * @brief Maximum duration is the maximum time of an overthreshold signal
- * detection to be recognized as a tap event.
- * The default value of these bits is 00b which corresponds to
- * 4*ODR_XL time.
- * If the SHOCK[1:0] bits are set to a different value, 1LSB
- * corresponds to 8*ODR_XL time.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of shock in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_shock_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- *val = int_dur2.shock;
- return ret;
- }
- /**
- * @brief Quiet time is the time after the first detected tap in which there
- * must not be any overthreshold event.
- * The default value of these bits is 00b which corresponds to
- * 2*ODR_XL time.
- * If the QUIET[1:0] bits are set to a different value, 1LSB
- * corresponds to 4*ODR_XL time.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of quiet in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_quiet_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- if (ret == 0)
- {
- int_dur2.quiet = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- }
- return ret;
- }
- /**
- * @brief Quiet time is the time after the first detected tap in which there
- * must not be any overthreshold event.
- * The default value of these bits is 00b which corresponds to
- * 2*ODR_XL time.
- * If the QUIET[1:0] bits are set to a different value, 1LSB
- * corresponds to 4*ODR_XL time.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of quiet in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_quiet_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- *val = int_dur2.quiet;
- return ret;
- }
- /**
- * @brief When double tap recognition is enabled, this register expresses the
- * maximum time between two consecutive detected taps to determine a
- * double tap event.
- * The default value of these bits is 0000b which corresponds to
- * 16*ODR_XL time.
- * If the DUR[3:0] bits are set to a different value,1LSB corresponds
- * to 32*ODR_XL time.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dur in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_dur_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- if (ret == 0)
- {
- int_dur2.dur = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- }
- return ret;
- }
- /**
- * @brief When double tap recognition is enabled, this register expresses the
- * maximum time between two consecutive detected taps to determine a
- * double tap event.
- * The default value of these bits is 0000b which corresponds to
- * 16*ODR_XL time.
- * If the DUR[3:0] bits are set to a different value,1LSB corresponds
- * to 32*ODR_XL time.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dur in reg INT_DUR2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_dur_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_int_dur2_t int_dur2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_INT_DUR2,
- (uint8_t *)&int_dur2, 1);
- *val = int_dur2.dur;
- return ret;
- }
- /**
- * @brief Single/double-tap event enable/disable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of
- * single_double_tap in reg WAKE_UP_THS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_single_double_tap_t val)
- {
- lsm6ds3tr_c_wake_up_ths_t wake_up_ths;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- if (ret == 0)
- {
- wake_up_ths.single_double_tap = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- }
- return ret;
- }
- /**
- * @brief Single/double-tap event enable/disable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of single_double_tap
- * in reg WAKE_UP_THS
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tap_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_single_double_tap_t *val)
- {
- lsm6ds3tr_c_wake_up_ths_t wake_up_ths;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_THS,
- (uint8_t *)&wake_up_ths, 1);
- switch (wake_up_ths.single_double_tap)
- {
- case LSM6DS3TR_C_ONLY_SINGLE:
- *val = LSM6DS3TR_C_ONLY_SINGLE;
- break;
- case LSM6DS3TR_C_BOTH_SINGLE_DOUBLE:
- *val = LSM6DS3TR_C_BOTH_SINGLE_DOUBLE;
- break;
- default:
- *val = LSM6DS3TR_C_TAP_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_ Six_position_detection(6D/4D)
- * @brief This section groups all the functions concerning six
- * position detection (6D).
- * @{
- *
- */
- /**
- * @brief LPF2 feed 6D function selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of low_pass_on_6d in
- * reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_6d_feed_data_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_low_pass_on_6d_t val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- if (ret == 0)
- {
- ctrl8_xl.low_pass_on_6d = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- }
- return ret;
- }
- /**
- * @brief LPF2 feed 6D function selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of low_pass_on_6d in reg CTRL8_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_6d_feed_data_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_low_pass_on_6d_t *val)
- {
- lsm6ds3tr_c_ctrl8_xl_t ctrl8_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL8_XL,
- (uint8_t *)&ctrl8_xl, 1);
- switch (ctrl8_xl.low_pass_on_6d)
- {
- case LSM6DS3TR_C_ODR_DIV_2_FEED:
- *val = LSM6DS3TR_C_ODR_DIV_2_FEED;
- break;
- case LSM6DS3TR_C_LPF2_FEED:
- *val = LSM6DS3TR_C_LPF2_FEED;
- break;
- default:
- *val = LSM6DS3TR_C_6D_FEED_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Threshold for 4D/6D function.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sixd_ths in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_6d_threshold_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sixd_ths_t val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- if (ret == 0)
- {
- tap_ths_6d.sixd_ths = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- }
- return ret;
- }
- /**
- * @brief Threshold for 4D/6D function.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of sixd_ths in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_6d_threshold_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sixd_ths_t *val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- switch (tap_ths_6d.sixd_ths)
- {
- case LSM6DS3TR_C_DEG_80:
- *val = LSM6DS3TR_C_DEG_80;
- break;
- case LSM6DS3TR_C_DEG_70:
- *val = LSM6DS3TR_C_DEG_70;
- break;
- case LSM6DS3TR_C_DEG_60:
- *val = LSM6DS3TR_C_DEG_60;
- break;
- case LSM6DS3TR_C_DEG_50:
- *val = LSM6DS3TR_C_DEG_50;
- break;
- default:
- *val = LSM6DS3TR_C_6D_TH_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief 4D orientation detection enable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of d4d_en in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_4d_mode_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- if (ret == 0)
- {
- tap_ths_6d.d4d_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- }
- return ret;
- }
- /**
- * @brief 4D orientation detection enable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of d4d_en in reg TAP_THS_6D
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_4d_mode_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_tap_ths_6d_t tap_ths_6d;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_TAP_THS_6D,
- (uint8_t *)&tap_ths_6d, 1);
- *val = tap_ths_6d.d4d_en;
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_free_fall
- * @brief This section group all the functions concerning the free
- * fall detection.
- * @{
- *
- */
- /**
- * @brief Free-fall duration event. 1LSb = 1 / ODR[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ff_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_ff_dur_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- lsm6ds3tr_c_free_fall_t free_fall;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- if (ret == 0)
- {
- free_fall.ff_dur = (val & 0x1FU);
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- if (ret == 0)
- {
- wake_up_dur.ff_dur = (val & 0x20U) >> 5;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Free-fall duration event. 1LSb = 1 / ODR[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ff_dur in reg WAKE_UP_DUR
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_ff_dur_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_wake_up_dur_t wake_up_dur;
- lsm6ds3tr_c_free_fall_t free_fall;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_WAKE_UP_DUR,
- (uint8_t *)&wake_up_dur, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- }
- *val = (wake_up_dur.ff_dur << 5) + free_fall.ff_dur;
- return ret;
- }
- /**
- * @brief Free fall threshold setting.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ff_ths in reg FREE_FALL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_ff_threshold_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_ff_ths_t val)
- {
- lsm6ds3tr_c_free_fall_t free_fall;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- if (ret == 0)
- {
- free_fall.ff_ths = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- }
- return ret;
- }
- /**
- * @brief Free fall threshold setting.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of ff_ths in reg FREE_FALL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_ff_threshold_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_ff_ths_t *val)
- {
- lsm6ds3tr_c_free_fall_t free_fall;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FREE_FALL,
- (uint8_t *)&free_fall, 1);
- switch (free_fall.ff_ths)
- {
- case LSM6DS3TR_C_FF_TSH_156mg:
- *val = LSM6DS3TR_C_FF_TSH_156mg;
- break;
- case LSM6DS3TR_C_FF_TSH_219mg:
- *val = LSM6DS3TR_C_FF_TSH_219mg;
- break;
- case LSM6DS3TR_C_FF_TSH_250mg:
- *val = LSM6DS3TR_C_FF_TSH_250mg;
- break;
- case LSM6DS3TR_C_FF_TSH_312mg:
- *val = LSM6DS3TR_C_FF_TSH_312mg;
- break;
- case LSM6DS3TR_C_FF_TSH_344mg:
- *val = LSM6DS3TR_C_FF_TSH_344mg;
- break;
- case LSM6DS3TR_C_FF_TSH_406mg:
- *val = LSM6DS3TR_C_FF_TSH_406mg;
- break;
- case LSM6DS3TR_C_FF_TSH_469mg:
- *val = LSM6DS3TR_C_FF_TSH_469mg;
- break;
- case LSM6DS3TR_C_FF_TSH_500mg:
- *val = LSM6DS3TR_C_FF_TSH_500mg;
- break;
- default:
- *val = LSM6DS3TR_C_FF_TSH_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_fifo
- * @brief This section group all the functions concerning the
- * fifo usage
- * @{
- *
- */
- /**
- * @brief FIFO watermark level selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fth in reg FIFO_CTRL1
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_watermark_set(const stmdev_ctx_t *ctx,
- uint16_t val)
- {
- lsm6ds3tr_c_fifo_ctrl1_t fifo_ctrl1;
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- fifo_ctrl1.fth = (uint8_t)(0x00FFU & val);
- fifo_ctrl2.fth = (uint8_t)((0x0700U & val) >> 8);
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL1,
- (uint8_t *)&fifo_ctrl1, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- }
- }
- return ret;
- }
- /**
- * @brief FIFO watermark level selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fth in reg FIFO_CTRL1
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_watermark_get(const stmdev_ctx_t *ctx,
- uint16_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl1_t fifo_ctrl1;
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL1,
- (uint8_t *)&fifo_ctrl1, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- }
- *val = ((uint16_t)fifo_ctrl2.fth << 8) + (uint16_t)fifo_ctrl1.fth;
- return ret;
- }
- /**
- * @brief FIFO data level.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val get the values of diff_fifo in reg FIFO_STATUS1 and
- * FIFO_STATUS2(diff_fifo), it is recommended to set the
- * BDU bit.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_data_level_get(const stmdev_ctx_t *ctx,
- uint16_t *val)
- {
- lsm6ds3tr_c_fifo_status1_t fifo_status1;
- lsm6ds3tr_c_fifo_status2_t fifo_status2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS1,
- (uint8_t *)&fifo_status1, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS2,
- (uint8_t *)&fifo_status2, 1);
- *val = ((uint16_t) fifo_status2.diff_fifo << 8) +
- (uint16_t) fifo_status1.diff_fifo;
- }
- return ret;
- }
- /**
- * @brief FIFO watermark.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val get the values of watermark in reg FIFO_STATUS2 and
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_wtm_flag_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_fifo_status2_t fifo_status2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS2,
- (uint8_t *)&fifo_status2, 1);
- *val = fifo_status2.waterm;
- return ret;
- }
- /**
- * @brief FIFO pattern.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val get the values of fifo_pattern in reg FIFO_STATUS3 and
- * FIFO_STATUS4, it is recommended to set the BDU bit
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_pattern_get(const stmdev_ctx_t *ctx, uint16_t *val)
- {
- lsm6ds3tr_c_fifo_status3_t fifo_status3;
- lsm6ds3tr_c_fifo_status4_t fifo_status4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS3,
- (uint8_t *)&fifo_status3, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_STATUS4,
- (uint8_t *)&fifo_status4, 1);
- *val = ((uint16_t)fifo_status4.fifo_pattern << 8) +
- fifo_status3.fifo_pattern;
- }
- return ret;
- }
- /**
- * @brief Batching of temperature data[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_temp_batch_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- fifo_ctrl2.fifo_temp_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- }
- return ret;
- }
- /**
- * @brief Batching of temperature data[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fifo_temp_en in reg FIFO_CTRL2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_temp_batch_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- *val = fifo_ctrl2.fifo_temp_en;
- return ret;
- }
- /**
- * @brief Trigger signal for FIFO write operation.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy)
- * and MASTER_CONFIG(data_valid_sel_fifo)
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_write_trigger_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_trigger_fifo_t val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- fifo_ctrl2.timer_pedo_fifo_drdy = (uint8_t)val & 0x01U;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.data_valid_sel_fifo = (((uint8_t)val & 0x02U) >> 1);
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Trigger signal for FIFO write operation.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val act on FIFO_CTRL2(timer_pedo_fifo_drdy)
- * and MASTER_CONFIG(data_valid_sel_fifo)
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_write_trigger_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_trigger_fifo_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- switch ((fifo_ctrl2.timer_pedo_fifo_drdy << 1) +
- fifo_ctrl2. timer_pedo_fifo_drdy)
- {
- case LSM6DS3TR_C_TRG_XL_GY_DRDY:
- *val = LSM6DS3TR_C_TRG_XL_GY_DRDY;
- break;
- case LSM6DS3TR_C_TRG_STEP_DETECT:
- *val = LSM6DS3TR_C_TRG_STEP_DETECT;
- break;
- case LSM6DS3TR_C_TRG_SH_DRDY:
- *val = LSM6DS3TR_C_TRG_SH_DRDY;
- break;
- default:
- *val = LSM6DS3TR_C_TRG_SH_ND;
- break;
- }
- }
- return ret;
- }
- /**
- * @brief Enable pedometer step counter and timestamp as 4th
- * FIFO data set.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_set(
- stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- if (ret == 0)
- {
- fifo_ctrl2.timer_pedo_fifo_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- }
- return ret;
- }
- /**
- * @brief Enable pedometer step counter and timestamp as 4th
- * FIFO data set.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of timer_pedo_fifo_en in reg FIFO_CTRL2
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_pedo_and_timestamp_batch_get(
- stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl2_t fifo_ctrl2;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL2,
- (uint8_t *)&fifo_ctrl2, 1);
- *val = fifo_ctrl2.timer_pedo_fifo_en;
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO) for
- * accelerometer data.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dec_fifo_xl in reg FIFO_CTRL3
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_xl_batch_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_fifo_xl_t val)
- {
- lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- if (ret == 0)
- {
- fifo_ctrl3.dec_fifo_xl = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO) for
- * accelerometer data.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of dec_fifo_xl in reg FIFO_CTRL3
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_xl_batch_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_fifo_xl_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- switch (fifo_ctrl3.dec_fifo_xl)
- {
- case LSM6DS3TR_C_FIFO_XL_DISABLE:
- *val = LSM6DS3TR_C_FIFO_XL_DISABLE;
- break;
- case LSM6DS3TR_C_FIFO_XL_NO_DEC:
- *val = LSM6DS3TR_C_FIFO_XL_NO_DEC;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_2:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_2;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_3:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_3;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_4:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_4;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_8:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_8;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_16:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_16;
- break;
- case LSM6DS3TR_C_FIFO_XL_DEC_32:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_32;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_XL_DEC_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO)
- * for gyroscope data.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dec_fifo_gyro in reg FIFO_CTRL3
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_gy_batch_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_fifo_gyro_t val)
- {
- lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- if (ret == 0)
- {
- fifo_ctrl3.dec_fifo_gyro = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO)
- * for gyroscope data.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of dec_fifo_gyro in reg FIFO_CTRL3
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_gy_batch_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_fifo_gyro_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl3_t fifo_ctrl3;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL3,
- (uint8_t *)&fifo_ctrl3, 1);
- switch (fifo_ctrl3.dec_fifo_gyro)
- {
- case LSM6DS3TR_C_FIFO_GY_DISABLE:
- *val = LSM6DS3TR_C_FIFO_GY_DISABLE;
- break;
- case LSM6DS3TR_C_FIFO_GY_NO_DEC:
- *val = LSM6DS3TR_C_FIFO_GY_NO_DEC;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_2:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_2;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_3:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_3;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_4:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_4;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_8:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_8;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_16:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_16;
- break;
- case LSM6DS3TR_C_FIFO_GY_DEC_32:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_32;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_GY_DEC_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO)
- * for third data set.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dec_ds3_fifo in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_dataset_3_batch_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_ds3_fifo_t val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- if (ret == 0)
- {
- fifo_ctrl4.dec_ds3_fifo = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO)
- * for third data set.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of dec_ds3_fifo in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_dataset_3_batch_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_ds3_fifo_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- switch (fifo_ctrl4.dec_ds3_fifo)
- {
- case LSM6DS3TR_C_FIFO_DS3_DISABLE:
- *val = LSM6DS3TR_C_FIFO_DS3_DISABLE;
- break;
- case LSM6DS3TR_C_FIFO_DS3_NO_DEC:
- *val = LSM6DS3TR_C_FIFO_DS3_NO_DEC;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_2:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_2;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_3:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_3;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_4:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_4;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_8:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_8;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_16:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_16;
- break;
- case LSM6DS3TR_C_FIFO_DS3_DEC_32:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_32;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_DS3_DEC_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO)
- * for fourth data set.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of dec_ds4_fifo in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_dataset_4_batch_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_ds4_fifo_t val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- if (ret == 0)
- {
- fifo_ctrl4.dec_ds4_fifo = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- }
- return ret;
- }
- /**
- * @brief Selects Batching Data Rate (writing frequency in FIFO) for
- * fourth data set.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of dec_ds4_fifo in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_dataset_4_batch_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_dec_ds4_fifo_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- switch (fifo_ctrl4.dec_ds4_fifo)
- {
- case LSM6DS3TR_C_FIFO_DS4_DISABLE:
- *val = LSM6DS3TR_C_FIFO_DS4_DISABLE;
- break;
- case LSM6DS3TR_C_FIFO_DS4_NO_DEC:
- *val = LSM6DS3TR_C_FIFO_DS4_NO_DEC;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_2:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_2;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_3:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_3;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_4:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_4;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_8:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_8;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_16:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_16;
- break;
- case LSM6DS3TR_C_FIFO_DS4_DEC_32:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_32;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_DS4_DEC_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief 8-bit data storage in FIFO.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of only_high_data in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- if (ret == 0)
- {
- fifo_ctrl4.only_high_data = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- }
- return ret;
- }
- /**
- * @brief 8-bit data storage in FIFO.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of only_high_data in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_xl_gy_8bit_format_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- *val = fifo_ctrl4.only_high_data;
- return ret;
- }
- /**
- * @brief Sensing chain FIFO stop values memorization at threshold
- * level.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of stop_on_fth in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_stop_on_wtm_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- if (ret == 0)
- {
- fifo_ctrl4.stop_on_fth = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- }
- return ret;
- }
- /**
- * @brief Sensing chain FIFO stop values memorization at threshold
- * level.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of stop_on_fth in reg FIFO_CTRL4
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_stop_on_wtm_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl4_t fifo_ctrl4;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL4,
- (uint8_t *)&fifo_ctrl4, 1);
- *val = fifo_ctrl4.stop_on_fth;
- return ret;
- }
- /**
- * @brief FIFO mode selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of fifo_mode in reg FIFO_CTRL5
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fifo_mode_t val)
- {
- lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- if (ret == 0)
- {
- fifo_ctrl5.fifo_mode = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- }
- return ret;
- }
- /**
- * @brief FIFO mode selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of fifo_mode in reg FIFO_CTRL5
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_fifo_mode_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- switch (fifo_ctrl5.fifo_mode)
- {
- case LSM6DS3TR_C_BYPASS_MODE:
- *val = LSM6DS3TR_C_BYPASS_MODE;
- break;
- case LSM6DS3TR_C_FIFO_MODE:
- *val = LSM6DS3TR_C_FIFO_MODE;
- break;
- case LSM6DS3TR_C_STREAM_TO_FIFO_MODE:
- *val = LSM6DS3TR_C_STREAM_TO_FIFO_MODE;
- break;
- case LSM6DS3TR_C_BYPASS_TO_STREAM_MODE:
- *val = LSM6DS3TR_C_BYPASS_TO_STREAM_MODE;
- break;
- case LSM6DS3TR_C_STREAM_MODE:
- *val = LSM6DS3TR_C_STREAM_MODE;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief FIFO ODR selection, setting FIFO_MODE also.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of odr_fifo in reg FIFO_CTRL5
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_data_rate_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_fifo_t val)
- {
- lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- if (ret == 0)
- {
- fifo_ctrl5.odr_fifo = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- }
- return ret;
- }
- /**
- * @brief FIFO ODR selection, setting FIFO_MODE also.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of odr_fifo in reg FIFO_CTRL5
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_fifo_data_rate_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_odr_fifo_t *val)
- {
- lsm6ds3tr_c_fifo_ctrl5_t fifo_ctrl5;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_FIFO_CTRL5,
- (uint8_t *)&fifo_ctrl5, 1);
- switch (fifo_ctrl5.odr_fifo)
- {
- case LSM6DS3TR_C_FIFO_DISABLE:
- *val = LSM6DS3TR_C_FIFO_DISABLE;
- break;
- case LSM6DS3TR_C_FIFO_12Hz5:
- *val = LSM6DS3TR_C_FIFO_12Hz5;
- break;
- case LSM6DS3TR_C_FIFO_26Hz:
- *val = LSM6DS3TR_C_FIFO_26Hz;
- break;
- case LSM6DS3TR_C_FIFO_52Hz:
- *val = LSM6DS3TR_C_FIFO_52Hz;
- break;
- case LSM6DS3TR_C_FIFO_104Hz:
- *val = LSM6DS3TR_C_FIFO_104Hz;
- break;
- case LSM6DS3TR_C_FIFO_208Hz:
- *val = LSM6DS3TR_C_FIFO_208Hz;
- break;
- case LSM6DS3TR_C_FIFO_416Hz:
- *val = LSM6DS3TR_C_FIFO_416Hz;
- break;
- case LSM6DS3TR_C_FIFO_833Hz:
- *val = LSM6DS3TR_C_FIFO_833Hz;
- break;
- case LSM6DS3TR_C_FIFO_1k66Hz:
- *val = LSM6DS3TR_C_FIFO_1k66Hz;
- break;
- case LSM6DS3TR_C_FIFO_3k33Hz:
- *val = LSM6DS3TR_C_FIFO_3k33Hz;
- break;
- case LSM6DS3TR_C_FIFO_6k66Hz:
- *val = LSM6DS3TR_C_FIFO_6k66Hz;
- break;
- default:
- *val = LSM6DS3TR_C_FIFO_RATE_ND;
- break;
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_DEN_functionality
- * @brief This section groups all the functions concerning DEN
- * functionality.
- * @{
- *
- */
- /**
- * @brief DEN active level configuration.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_lh in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_polarity_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_lh_t val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- if (ret == 0)
- {
- ctrl5_c.den_lh = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- }
- return ret;
- }
- /**
- * @brief DEN active level configuration.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of den_lh in reg CTRL5_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_polarity_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_lh_t *val)
- {
- lsm6ds3tr_c_ctrl5_c_t ctrl5_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL5_C,
- (uint8_t *)&ctrl5_c, 1);
- switch (ctrl5_c.den_lh)
- {
- case LSM6DS3TR_C_DEN_ACT_LOW:
- *val = LSM6DS3TR_C_DEN_ACT_LOW;
- break;
- case LSM6DS3TR_C_DEN_ACT_HIGH:
- *val = LSM6DS3TR_C_DEN_ACT_HIGH;
- break;
- default:
- *val = LSM6DS3TR_C_DEN_POL_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief DEN functionality marking mode[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_mode in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_mode_t val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- if (ret == 0)
- {
- ctrl6_c.den_mode = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- }
- return ret;
- }
- /**
- * @brief DEN functionality marking mode[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_mode in reg CTRL6_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_mode_t *val)
- {
- lsm6ds3tr_c_ctrl6_c_t ctrl6_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL6_C,
- (uint8_t *)&ctrl6_c, 1);
- switch (ctrl6_c.den_mode)
- {
- case LSM6DS3TR_C_DEN_DISABLE:
- *val = LSM6DS3TR_C_DEN_DISABLE;
- break;
- case LSM6DS3TR_C_LEVEL_LETCHED:
- *val = LSM6DS3TR_C_LEVEL_LETCHED;
- break;
- case LSM6DS3TR_C_LEVEL_TRIGGER:
- *val = LSM6DS3TR_C_LEVEL_TRIGGER;
- break;
- case LSM6DS3TR_C_EDGE_TRIGGER:
- *val = LSM6DS3TR_C_EDGE_TRIGGER;
- break;
- default:
- *val = LSM6DS3TR_C_DEN_MODE_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Extend DEN functionality to accelerometer sensor.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_xl_g in reg CTRL9_XL
- * and den_xl_en in CTRL4_C.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_enable_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_xl_en_t val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ctrl9_xl.den_xl_g = (uint8_t)val & 0x01U;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ctrl4_c.den_xl_en = (uint8_t)val & 0x02U;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Extend DEN functionality to accelerometer sensor. [get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of den_xl_g in reg CTRL9_XL
- * and den_xl_en in CTRL4_C.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_enable_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_den_xl_en_t *val)
- {
- lsm6ds3tr_c_ctrl4_c_t ctrl4_c;
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL4_C,
- (uint8_t *)&ctrl4_c, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- switch ((ctrl4_c.den_xl_en << 1) + ctrl9_xl.den_xl_g)
- {
- case LSM6DS3TR_C_STAMP_IN_GY_DATA:
- *val = LSM6DS3TR_C_STAMP_IN_GY_DATA;
- break;
- case LSM6DS3TR_C_STAMP_IN_XL_DATA:
- *val = LSM6DS3TR_C_STAMP_IN_XL_DATA;
- break;
- case LSM6DS3TR_C_STAMP_IN_GY_XL_DATA:
- *val = LSM6DS3TR_C_STAMP_IN_GY_XL_DATA;
- break;
- default:
- *val = LSM6DS3TR_C_DEN_STAMP_ND;
- break;
- }
- }
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of Z-axis.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_z in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_z_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ctrl9_xl.den_z = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- }
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of Z-axis.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_z in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_z_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- *val = ctrl9_xl.den_z;
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of Y-axis.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_y in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_y_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ctrl9_xl.den_y = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- }
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of Y-axis.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_y in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_y_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- *val = ctrl9_xl.den_y;
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of X-axis.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_x in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_x_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ctrl9_xl.den_x = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- }
- return ret;
- }
- /**
- * @brief DEN value stored in LSB of X-axis.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of den_x in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_den_mark_axis_x_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- *val = ctrl9_xl.den_x;
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Pedometer
- * @brief This section groups all the functions that manage pedometer.
- * @{
- *
- */
- /**
- * @brief Reset pedometer step counter.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pedo_rst_step in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_step_reset_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.pedo_rst_step = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- return ret;
- }
- /**
- * @brief Reset pedometer step counter.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pedo_rst_step in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_step_reset_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.pedo_rst_step;
- return ret;
- }
- /**
- * @brief Enable pedometer algorithm.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pedo_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_sens_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.pedo_en = val;
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- }
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- return ret;
- }
- /**
- * @brief pedo_sens: Enable pedometer algorithm.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pedo_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_sens_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.pedo_en;
- return ret;
- }
- /**
- * @brief Minimum threshold to detect a peak. Default is 10h.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ths_min in reg
- * CONFIG_PEDO_THS_MIN
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_threshold_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- config_pedo_ths_min.ths_min = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Minimum threshold to detect a peak. Default is 10h.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of ths_min in reg CONFIG_PEDO_THS_MIN
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_threshold_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- *val = config_pedo_ths_min.ths_min;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief pedo_full_scale: Pedometer data range.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pedo_fs in
- * reg CONFIG_PEDO_THS_MIN
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_full_scale_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pedo_fs_t val)
- {
- lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- config_pedo_ths_min.pedo_fs = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Pedometer data range.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of pedo_fs in
- * reg CONFIG_PEDO_THS_MIN
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_full_scale_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pedo_fs_t *val)
- {
- lsm6ds3tr_c_config_pedo_ths_min_t config_pedo_ths_min;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CONFIG_PEDO_THS_MIN,
- (uint8_t *)&config_pedo_ths_min, 1);
- if (ret == 0)
- {
- switch (config_pedo_ths_min.pedo_fs)
- {
- case LSM6DS3TR_C_PEDO_AT_2g:
- *val = LSM6DS3TR_C_PEDO_AT_2g;
- break;
- case LSM6DS3TR_C_PEDO_AT_4g:
- *val = LSM6DS3TR_C_PEDO_AT_4g;
- break;
- default:
- *val = LSM6DS3TR_C_PEDO_FS_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Pedometer debounce configuration register (r/w).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of deb_step in reg PEDO_DEB_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_debounce_steps_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- pedo_deb_reg.deb_step = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Pedometer debounce configuration register (r/w).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of deb_step in reg PEDO_DEB_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_debounce_steps_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- *val = pedo_deb_reg.deb_step;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Debounce time. If the time between two consecutive steps is
- * greater than DEB_TIME*80ms, the debouncer is reactivated.
- * Default value: 01101[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of deb_time in reg PEDO_DEB_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_timeout_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- pedo_deb_reg.deb_time = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Debounce time. If the time between two consecutive steps is
- * greater than DEB_TIME*80ms, the debouncer is reactivated.
- * Default value: 01101[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of deb_time in reg PEDO_DEB_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_timeout_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_pedo_deb_reg_t pedo_deb_reg;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_PEDO_DEB_REG,
- (uint8_t *)&pedo_deb_reg, 1);
- if (ret == 0)
- {
- *val = pedo_deb_reg.deb_time;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Time period register for step detection on delta time (r/w).[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_steps_period_set(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_STEP_COUNT_DELTA, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Time period register for step detection on delta time (r/w).[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_pedo_steps_period_get(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_STEP_COUNT_DELTA, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_significant_motion
- * @brief This section groups all the functions that manage the
- * significant motion detection.
- * @{
- *
- */
- /**
- * @brief Enable significant motion detection function.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sign_motion_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_motion_sens_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.sign_motion_en = val;
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- }
- return ret;
- }
- /**
- * @brief Enable significant motion detection function.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of sign_motion_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_motion_sens_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.sign_motion_en;
- return ret;
- }
- /**
- * @brief Significant motion threshold.[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that store significant motion threshold.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_motion_threshold_set(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SM_THS, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Significant motion threshold.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that store significant motion threshold.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_motion_threshold_get(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SM_THS, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_tilt_detection
- * @brief This section groups all the functions that manage the tilt
- * event detection.
- * @{
- *
- */
- /**
- * @brief Enable tilt calculation.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tilt_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_sens_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.tilt_en = val;
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- }
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- return ret;
- }
- /**
- * @brief Enable tilt calculation.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tilt_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_sens_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.tilt_en;
- return ret;
- }
- /**
- * @brief Enable tilt calculation.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tilt_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wrist_tilt_sens_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.wrist_tilt_en = val;
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- }
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- return ret;
- }
- /**
- * @brief Enable tilt calculation.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tilt_en in reg CTRL10_C
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_wrist_tilt_sens_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- *val = ctrl10_c.wrist_tilt_en;
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt latency register (r/w).
- * Absolute wrist tilt latency parameters.
- * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_latency_set(const stmdev_ctx_t *ctx, uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_LAT, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt latency register (r/w).
- * Absolute wrist tilt latency parameters.
- * 1 LSB = 40 ms. Default value: 0Fh (600 ms).[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_latency_get(const stmdev_ctx_t *ctx, uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_LAT, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt threshold register(r/w).
- * Absolute wrist tilt threshold parameters.
- * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_threshold_set(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_THS, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt threshold register(r/w).
- * Absolute wrist tilt threshold parameters.
- * 1 LSB = 15.625 mg.Default value: 20h (500 mg).[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_threshold_get(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_THS, buff, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt mask register (r/w).[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Registers A_WRIST_TILT_MASK
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_src_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_a_wrist_tilt_mask_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK,
- (uint8_t *) val, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Absolute Wrist Tilt mask register (r/w).[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Registers A_WRIST_TILT_MASK
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_tilt_src_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_a_wrist_tilt_mask_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_B);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_A_WRIST_TILT_MASK,
- (uint8_t *) val, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_ magnetometer_sensor
- * @brief This section groups all the functions that manage additional
- * magnetometer sensor.
- * @{
- *
- */
- /**
- * @brief Enable soft-iron correction algorithm for magnetometer.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of soft_en in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_soft_iron_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- if (ret == 0)
- {
- ctrl9_xl.soft_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- }
- return ret;
- }
- /**
- * @brief Enable soft-iron correction algorithm for magnetometer.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of soft_en in reg CTRL9_XL
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_soft_iron_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_ctrl9_xl_t ctrl9_xl;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL9_XL,
- (uint8_t *)&ctrl9_xl, 1);
- *val = ctrl9_xl.soft_en;
- return ret;
- }
- /**
- * @brief Enable hard-iron correction algorithm for magnetometer.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of iron_en in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_hard_iron_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.iron_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- if (val != 0x00U)
- {
- ctrl10_c.func_en = val;
- }
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Enable hard-iron correction algorithm for magnetometer.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of iron_en in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_hard_iron_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- *val = master_config.iron_en;
- return ret;
- }
- /**
- * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format.
- * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_soft_iron_mat_set(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MAG_SI_XX, buff, 9);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Soft iron 3x3 matrix. Value are expressed in sign-module format.
- * (Es. SVVVVVVVb where S is the sign 0/+1/- and V is the value).[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_soft_iron_mat_get(const stmdev_ctx_t *ctx,
- uint8_t *buff)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MAG_SI_XX, buff, 9);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Offset for hard-iron compensation register (r/w). The value is
- * expressed as a 16-bit word in two’s complement.[set]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that contains data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_offset_set(const stmdev_ctx_t *ctx, int16_t *val)
- {
- uint8_t buff[6];
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- buff[1] = (uint8_t)((uint16_t)val[0] / 256U);
- buff[0] = (uint8_t)((uint16_t)val[0] - (buff[1] * 256U));
- buff[3] = (uint8_t)((uint16_t)val[1] / 256U);
- buff[2] = (uint8_t)((uint16_t)val[1] - (buff[3] * 256U));
- buff[5] = (uint8_t)((uint16_t)val[2] / 256U);
- buff[4] = (uint8_t)((uint16_t)val[2] - (buff[5] * 256U));
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MAG_OFFX_L, buff, 6);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Offset for hard-iron compensation register(r/w).
- * The value is expressed as a 16-bit word in two’s complement.[get]
- *
- * @param ctx Read / write interface definitions
- * @param buff Buffer that stores data read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_mag_offset_get(const stmdev_ctx_t *ctx, int16_t *val)
- {
- uint8_t buff[6];
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MAG_OFFX_L, buff, 6);
- if (ret == 0)
- {
- val[0] = (int16_t)buff[1];
- val[0] = (val[0] * 256) + (int16_t)buff[0];
- val[1] = (int16_t)buff[3];
- val[1] = (val[1] * 256) + (int16_t)buff[2];
- val[2] = (int16_t)buff[5];
- val[2] = (val[2] * 256) + (int16_t)buff[4];
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @defgroup LSM6DS3TR_C_Sensor_hub
- * @brief This section groups all the functions that manage the sensor
- * hub functionality.
- * @{
- *
- */
- /**
- * @brief Enable function.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values func_en
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_func_en_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_ctrl10_c_t ctrl10_c;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- if (ret == 0)
- {
- ctrl10_c.func_en = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_CTRL10_C,
- (uint8_t *)&ctrl10_c, 1);
- }
- return ret;
- }
- /**
- * @brief Sensor synchronization time frame with the step of 500 ms and
- * full range of 5s. Unsigned 8-bit.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_sync_sens_frame_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_sensor_sync_time_frame_t sensor_sync_time_frame;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME,
- (uint8_t *)&sensor_sync_time_frame, 1);
- if (ret == 0)
- {
- sensor_sync_time_frame.tph = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME,
- (uint8_t *)&sensor_sync_time_frame, 1);
- }
- return ret;
- }
- /**
- * @brief Sensor synchronization time frame with the step of 500 ms and
- * full range of 5s. Unsigned 8-bit.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of tph in reg SENSOR_SYNC_TIME_FRAME
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_sync_sens_frame_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_sensor_sync_time_frame_t sensor_sync_time_frame;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_TIME_FRAME,
- (uint8_t *)&sensor_sync_time_frame, 1);
- *val = sensor_sync_time_frame.tph;
- return ret;
- }
- /**
- * @brief Resolution ratio of error code for sensor synchronization.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of rr in reg SENSOR_SYNC_RES_RATIO
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_sync_sens_ratio_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rr_t val)
- {
- lsm6ds3tr_c_sensor_sync_res_ratio_t sensor_sync_res_ratio;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO,
- (uint8_t *)&sensor_sync_res_ratio, 1);
- if (ret == 0)
- {
- sensor_sync_res_ratio.rr = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO,
- (uint8_t *)&sensor_sync_res_ratio, 1);
- }
- return ret;
- }
- /**
- * @brief Resolution ratio of error code for sensor synchronization.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of rr in reg SENSOR_SYNC_RES_RATIO
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_sync_sens_ratio_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_rr_t *val)
- {
- lsm6ds3tr_c_sensor_sync_res_ratio_t sensor_sync_res_ratio;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSOR_SYNC_RES_RATIO,
- (uint8_t *)&sensor_sync_res_ratio, 1);
- switch (sensor_sync_res_ratio.rr)
- {
- case LSM6DS3TR_C_RES_RATIO_2_11:
- *val = LSM6DS3TR_C_RES_RATIO_2_11;
- break;
- case LSM6DS3TR_C_RES_RATIO_2_12:
- *val = LSM6DS3TR_C_RES_RATIO_2_12;
- break;
- case LSM6DS3TR_C_RES_RATIO_2_13:
- *val = LSM6DS3TR_C_RES_RATIO_2_13;
- break;
- case LSM6DS3TR_C_RES_RATIO_2_14:
- *val = LSM6DS3TR_C_RES_RATIO_2_14;
- break;
- default:
- *val = LSM6DS3TR_C_RES_RATIO_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Sensor hub I2C master enable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of master_on in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_master_set(const stmdev_ctx_t *ctx, uint8_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.master_on = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- return ret;
- }
- /**
- * @brief Sensor hub I2C master enable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of master_on in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_master_get(const stmdev_ctx_t *ctx, uint8_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- *val = master_config.master_on;
- return ret;
- }
- /**
- * @brief I2C interface pass-through.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pass_through_mode in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_pass_through_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.pass_through_mode = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- return ret;
- }
- /**
- * @brief I2C interface pass-through.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pass_through_mode in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_pass_through_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- *val = master_config.pass_through_mode;
- return ret;
- }
- /**
- * @brief Master I2C pull-up enable/disable.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of pull_up_en in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_pin_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pull_up_en_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.pull_up_en = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- return ret;
- }
- /**
- * @brief Master I2C pull-up enable/disable.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of pull_up_en in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_pin_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_pull_up_en_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- switch (master_config.pull_up_en)
- {
- case LSM6DS3TR_C_EXT_PULL_UP:
- *val = LSM6DS3TR_C_EXT_PULL_UP;
- break;
- case LSM6DS3TR_C_INTERNAL_PULL_UP:
- *val = LSM6DS3TR_C_INTERNAL_PULL_UP;
- break;
- default:
- *val = LSM6DS3TR_C_SH_PIN_MODE;
- break;
- }
- return ret;
- }
- /**
- * @brief Sensor hub trigger signal selection.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of start_config in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_syncro_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_start_config_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.start_config = (uint8_t)val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- return ret;
- }
- /**
- * @brief Sensor hub trigger signal selection.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of start_config in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_syncro_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_start_config_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- switch (master_config.start_config)
- {
- case LSM6DS3TR_C_XL_GY_DRDY:
- *val = LSM6DS3TR_C_XL_GY_DRDY;
- break;
- case LSM6DS3TR_C_EXT_ON_INT2_PIN:
- *val = LSM6DS3TR_C_EXT_ON_INT2_PIN;
- break;
- default:
- *val = LSM6DS3TR_C_SH_SYNCRO_ND;
- break;
- }
- return ret;
- }
- /**
- * @brief Manage the Master DRDY signal on INT1 pad.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_drdy_on_int1_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- if (ret == 0)
- {
- master_config.drdy_on_int1 = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- }
- return ret;
- }
- /**
- * @brief Manage the Master DRDY signal on INT1 pad.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of drdy_on_int1 in reg MASTER_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_drdy_on_int1_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_master_config_t master_config;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CONFIG,
- (uint8_t *)&master_config, 1);
- *val = master_config.drdy_on_int1;
- return ret;
- }
- /**
- * @brief Sensor hub output registers.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure of registers from SENSORHUB1_REG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_read_data_raw_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_emb_sh_read_t *val)
- {
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSORHUB1_REG,
- (uint8_t *) & (val->sh_byte_1), 12);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENSORHUB13_REG,
- (uint8_t *) & (val->sh_byte_13), 6);
- }
- return ret;
- }
- /**
- * @brief Master command code used for stamping for sensor sync.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of master_cmd_code in
- * reg MASTER_CMD_CODE
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_cmd_sens_sync_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_master_cmd_code_t master_cmd_code;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE,
- (uint8_t *)&master_cmd_code, 1);
- if (ret == 0)
- {
- master_cmd_code.master_cmd_code = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE,
- (uint8_t *)&master_cmd_code, 1);
- }
- return ret;
- }
- /**
- * @brief Master command code used for stamping for sensor sync.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of master_cmd_code in
- * reg MASTER_CMD_CODE
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_cmd_sens_sync_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_master_cmd_code_t master_cmd_code;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_MASTER_CMD_CODE,
- (uint8_t *)&master_cmd_code, 1);
- *val = master_cmd_code.master_cmd_code;
- return ret;
- }
- /**
- * @brief Error code used for sensor synchronization.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of error_code in
- * reg SENS_SYNC_SPI_ERROR_CODE.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_spi_sync_error_set(const stmdev_ctx_t *ctx,
- uint8_t val)
- {
- lsm6ds3tr_c_sens_sync_spi_error_code_t sens_sync_spi_error_code;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE,
- (uint8_t *)&sens_sync_spi_error_code, 1);
- if (ret == 0)
- {
- sens_sync_spi_error_code.error_code = val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE,
- (uint8_t *)&sens_sync_spi_error_code, 1);
- }
- return ret;
- }
- /**
- * @brief Error code used for sensor synchronization.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of error_code in
- * reg SENS_SYNC_SPI_ERROR_CODE.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_spi_sync_error_get(const stmdev_ctx_t *ctx,
- uint8_t *val)
- {
- lsm6ds3tr_c_sens_sync_spi_error_code_t sens_sync_spi_error_code;
- int32_t ret;
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SENS_SYNC_SPI_ERROR_CODE,
- (uint8_t *)&sens_sync_spi_error_code, 1);
- *val = sens_sync_spi_error_code.error_code;
- return ret;
- }
- /**
- * @brief Number of external sensors to be read by the sensor hub.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of aux_sens_on in reg SLAVE0_CONFIG.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_num_of_dev_connected_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_aux_sens_on_t val)
- {
- lsm6ds3tr_c_slave0_config_t slave0_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- slave0_config.aux_sens_on = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Number of external sensors to be read by the sensor hub.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of aux_sens_on in reg SLAVE0_CONFIG.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_num_of_dev_connected_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_aux_sens_on_t *val)
- {
- lsm6ds3tr_c_slave0_config_t slave0_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- switch (slave0_config.aux_sens_on)
- {
- case LSM6DS3TR_C_SLV_0:
- *val = LSM6DS3TR_C_SLV_0;
- break;
- case LSM6DS3TR_C_SLV_0_1:
- *val = LSM6DS3TR_C_SLV_0_1;
- break;
- case LSM6DS3TR_C_SLV_0_1_2:
- *val = LSM6DS3TR_C_SLV_0_1_2;
- break;
- case LSM6DS3TR_C_SLV_0_1_2_3:
- *val = LSM6DS3TR_C_SLV_0_1_2_3;
- break;
- default:
- *val = LSM6DS3TR_C_SLV_EN_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Configure slave 0 for perform a write.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure that contain:
- * - uint8_t slv_add; 8 bit i2c device address
- * - uint8_t slv_subadd; 8 bit register device address
- * - uint8_t slv_data; 8 bit data to write
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_cfg_write(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sh_cfg_write_t *val)
- {
- lsm6ds3tr_c_slv0_add_t slv0_add;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- slv0_add.slave0_add = val->slv0_add;
- slv0_add.rw_0 = 0;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_ADD,
- (uint8_t *)&slv0_add, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_SUBADD,
- &(val->slv0_subadd), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx,
- LSM6DS3TR_C_DATAWRITE_SRC_MODE_SUB_SLV0,
- &(val->slv0_data), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Configure slave 0 for perform a read.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure that contain:
- * - uint8_t slv_add; 8 bit i2c device address
- * - uint8_t slv_subadd; 8 bit register device address
- * - uint8_t slv_len; num of bit to read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slv0_cfg_read(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sh_cfg_read_t *val)
- {
- lsm6ds3tr_c_slave0_config_t slave0_config;
- lsm6ds3tr_c_slv0_add_t slv0_add;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- slv0_add.slave0_add = val->slv_add;
- slv0_add.rw_0 = 1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_ADD,
- (uint8_t *)&slv0_add, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV0_SUBADD,
- &(val->slv_subadd), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- slave0_config.slave0_numop = val->slv_len;
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Configure slave 1 for perform a read.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure that contain:
- * - uint8_t slv_add; 8 bit i2c device address
- * - uint8_t slv_subadd; 8 bit register device address
- * - uint8_t slv_len; num of bit to read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slv1_cfg_read(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sh_cfg_read_t *val)
- {
- lsm6ds3tr_c_slave1_config_t slave1_config;
- lsm6ds3tr_c_slv1_add_t slv1_add;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- slv1_add.slave1_add = val->slv_add;
- slv1_add.r_1 = 1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV1_ADD,
- (uint8_t *)&slv1_add, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV1_SUBADD,
- &(val->slv_subadd), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- slave1_config.slave1_numop = val->slv_len;
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Configure slave 2 for perform a read.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure that contain:
- * - uint8_t slv_add; 8 bit i2c device address
- * - uint8_t slv_subadd; 8 bit register device address
- * - uint8_t slv_len; num of bit to read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slv2_cfg_read(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sh_cfg_read_t *val)
- {
- lsm6ds3tr_c_slv2_add_t slv2_add;
- lsm6ds3tr_c_slave2_config_t slave2_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- slv2_add.slave2_add = val->slv_add;
- slv2_add.r_2 = 1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV2_ADD,
- (uint8_t *)&slv2_add, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV2_SUBADD,
- &(val->slv_subadd), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG,
- (uint8_t *)&slave2_config, 1);
- if (ret == 0)
- {
- slave2_config.slave2_numop = val->slv_len;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG,
- (uint8_t *)&slave2_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Configure slave 3 for perform a read.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Structure that contain:
- * - uint8_t slv_add; 8 bit i2c device address
- * - uint8_t slv_subadd; 8 bit register device address
- * - uint8_t slv_len; num of bit to read
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slv3_cfg_read(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_sh_cfg_read_t *val)
- {
- lsm6ds3tr_c_slave3_config_t slave3_config;
- lsm6ds3tr_c_slv3_add_t slv3_add;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- slv3_add.slave3_add = val->slv_add;
- slv3_add.r_3 = 1;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV3_ADD,
- (uint8_t *)&slv3_add, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLV3_SUBADD,
- (uint8_t *) & (val->slv_subadd), 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG,
- (uint8_t *)&slave3_config, 1);
- if (ret == 0)
- {
- slave3_config.slave3_numop = val->slv_len;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG,
- (uint8_t *)&slave3_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 0 starting from the
- * sensor hub trigger.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of slave0_rate in reg SLAVE0_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_0_dec_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave0_rate_t val)
- {
- lsm6ds3tr_c_slave0_config_t slave0_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- slave0_config.slave0_rate = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 0 starting from the
- * sensor hub trigger.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of slave0_rate in reg SLAVE0_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_0_dec_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave0_rate_t *val)
- {
- lsm6ds3tr_c_slave0_config_t slave0_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE0_CONFIG,
- (uint8_t *)&slave0_config, 1);
- if (ret == 0)
- {
- switch (slave0_config.slave0_rate)
- {
- case LSM6DS3TR_C_SL0_NO_DEC:
- *val = LSM6DS3TR_C_SL0_NO_DEC;
- break;
- case LSM6DS3TR_C_SL0_DEC_2:
- *val = LSM6DS3TR_C_SL0_DEC_2;
- break;
- case LSM6DS3TR_C_SL0_DEC_4:
- *val = LSM6DS3TR_C_SL0_DEC_4;
- break;
- case LSM6DS3TR_C_SL0_DEC_8:
- *val = LSM6DS3TR_C_SL0_DEC_8;
- break;
- default:
- *val = LSM6DS3TR_C_SL0_DEC_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Slave 0 write operation is performed only at the first sensor
- * hub cycle.
- * This is effective if the Aux_sens_on[1:0] field in
- * SLAVE0_CONFIG(04h) is set to a value other than 00.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of write_once in reg SLAVE1_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_write_mode_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_write_once_t val)
- {
- lsm6ds3tr_c_slave1_config_t slave1_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- slave1_config.write_once = (uint8_t) val;
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Slave 0 write operation is performed only at the first sensor
- * hub cycle.
- * This is effective if the Aux_sens_on[1:0] field in
- * SLAVE0_CONFIG(04h) is set to a value other than 00.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of write_once in reg SLAVE1_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_write_mode_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_write_once_t *val)
- {
- lsm6ds3tr_c_slave1_config_t slave1_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- switch (slave1_config.write_once)
- {
- case LSM6DS3TR_C_EACH_SH_CYCLE:
- *val = LSM6DS3TR_C_EACH_SH_CYCLE;
- break;
- case LSM6DS3TR_C_ONLY_FIRST_CYCLE:
- *val = LSM6DS3TR_C_ONLY_FIRST_CYCLE;
- break;
- default:
- *val = LSM6DS3TR_C_SH_WR_MODE_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 1 starting from the
- * sensor hub trigger.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of slave1_rate in reg SLAVE1_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_1_dec_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave1_rate_t val)
- {
- lsm6ds3tr_c_slave1_config_t slave1_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- slave1_config.slave1_rate = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 1 starting from the
- * sensor hub trigger.[get]
- *
- * @param ctx Read / write interface definitions reg SLAVE1_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_1_dec_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave1_rate_t *val)
- {
- lsm6ds3tr_c_slave1_config_t slave1_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE1_CONFIG,
- (uint8_t *)&slave1_config, 1);
- if (ret == 0)
- {
- switch (slave1_config.slave1_rate)
- {
- case LSM6DS3TR_C_SL1_NO_DEC:
- *val = LSM6DS3TR_C_SL1_NO_DEC;
- break;
- case LSM6DS3TR_C_SL1_DEC_2:
- *val = LSM6DS3TR_C_SL1_DEC_2;
- break;
- case LSM6DS3TR_C_SL1_DEC_4:
- *val = LSM6DS3TR_C_SL1_DEC_4;
- break;
- case LSM6DS3TR_C_SL1_DEC_8:
- *val = LSM6DS3TR_C_SL1_DEC_8;
- break;
- default:
- *val = LSM6DS3TR_C_SL1_DEC_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 2 starting from the
- * sensor hub trigger.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of slave2_rate in reg SLAVE2_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_2_dec_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave2_rate_t val)
- {
- lsm6ds3tr_c_slave2_config_t slave2_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG,
- (uint8_t *)&slave2_config, 1);
- if (ret == 0)
- {
- slave2_config.slave2_rate = (uint8_t) val;
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG,
- (uint8_t *)&slave2_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 2 starting from the
- * sensor hub trigger.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of slave2_rate in reg SLAVE2_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_2_dec_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave2_rate_t *val)
- {
- lsm6ds3tr_c_slave2_config_t slave2_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE2_CONFIG,
- (uint8_t *)&slave2_config, 1);
- if (ret == 0)
- {
- switch (slave2_config.slave2_rate)
- {
- case LSM6DS3TR_C_SL2_NO_DEC:
- *val = LSM6DS3TR_C_SL2_NO_DEC;
- break;
- case LSM6DS3TR_C_SL2_DEC_2:
- *val = LSM6DS3TR_C_SL2_DEC_2;
- break;
- case LSM6DS3TR_C_SL2_DEC_4:
- *val = LSM6DS3TR_C_SL2_DEC_4;
- break;
- case LSM6DS3TR_C_SL2_DEC_8:
- *val = LSM6DS3TR_C_SL2_DEC_8;
- break;
- default:
- *val = LSM6DS3TR_C_SL2_DEC_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 3 starting from the
- * sensor hub trigger.[set]
- *
- * @param ctx Read / write interface definitions
- * @param val Change the values of slave3_rate in reg SLAVE3_CONFIG
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_3_dec_set(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave3_rate_t val)
- {
- lsm6ds3tr_c_slave3_config_t slave3_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG,
- (uint8_t *)&slave3_config, 1);
- slave3_config.slave3_rate = (uint8_t)val;
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_write_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG,
- (uint8_t *)&slave3_config, 1);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- }
- return ret;
- }
- /**
- * @brief Decimation of read operation on Slave 3 starting from the
- * sensor hub trigger.[get]
- *
- * @param ctx Read / write interface definitions
- * @param val Get the values of slave3_rate in reg SLAVE3_CONFIG.
- * @retval Interface status (MANDATORY: return 0 -> no Error).
- *
- */
- int32_t lsm6ds3tr_c_sh_slave_3_dec_get(const stmdev_ctx_t *ctx,
- lsm6ds3tr_c_slave3_rate_t *val)
- {
- lsm6ds3tr_c_slave3_config_t slave3_config;
- int32_t ret;
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_BANK_A);
- if (ret == 0)
- {
- ret = lsm6ds3tr_c_read_reg(ctx, LSM6DS3TR_C_SLAVE3_CONFIG,
- (uint8_t *)&slave3_config, 1);
- if (ret == 0)
- {
- switch (slave3_config.slave3_rate)
- {
- case LSM6DS3TR_C_SL3_NO_DEC:
- *val = LSM6DS3TR_C_SL3_NO_DEC;
- break;
- case LSM6DS3TR_C_SL3_DEC_2:
- *val = LSM6DS3TR_C_SL3_DEC_2;
- break;
- case LSM6DS3TR_C_SL3_DEC_4:
- *val = LSM6DS3TR_C_SL3_DEC_4;
- break;
- case LSM6DS3TR_C_SL3_DEC_8:
- *val = LSM6DS3TR_C_SL3_DEC_8;
- break;
- default:
- *val = LSM6DS3TR_C_SL3_DEC_ND;
- break;
- }
- ret = lsm6ds3tr_c_mem_bank_set(ctx, LSM6DS3TR_C_USER_BANK);
- }
- }
- return ret;
- }
- /**
- * @}
- *
- */
- /**
- * @}
- *
- */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|