ch32v20x.h 346 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : ch32v20x.h
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2024/07/04
  6. * Description : CH32V20x Device Peripheral Access Layer Header File.
  7. *********************************************************************************
  8. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  9. * Attention: This software (modified or not) and binary are used for
  10. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  11. *******************************************************************************/
  12. #ifndef __CH32V20x_H
  13. #define __CH32V20x_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if !defined(CH32V20x_D8W) && !defined(CH32V20x_D8) && !defined(CH32V20x_D6)
  18. #define CH32V20x_D6 /* CH32V203F6-CH32V203F8-CH32V203G6-CH32V203G8-CH32V203K8-CH32V203C6-CH32V203C8-CH32V203G8*/
  19. //#define CH32V20x_D8 /* CH32V203RBT6 */
  20. //#define CH32V20x_D8W /* CH32V208 */
  21. #endif
  22. #define __MPU_PRESENT 0 /* Other CH32 devices does not provide an MPU */
  23. #define __Vendor_SysTickConfig 0 /* Set to 1 if different SysTick Config is used */
  24. #ifndef HSE_VALUE
  25. #if defined(CH32V20x_D8) || defined(CH32V20x_D8W)
  26. #define HSE_VALUE ((uint32_t)32000000) /* Value of the External oscillator in Hz */
  27. #else
  28. #define HSE_VALUE ((uint32_t)8000000) /* Value of the External oscillator in Hz */
  29. #endif
  30. #endif
  31. /* In the following line adjust the External High Speed oscillator (HSE) Startup Timeout value */
  32. #define HSE_STARTUP_TIMEOUT ((uint16_t)0x1000) /* Time out for HSE start up */
  33. #define HSI_VALUE ((uint32_t)8000000) /* Value of the Internal oscillator in Hz */
  34. /* CH32V20x Standard Peripheral Library version number */
  35. #define __CH32V20x_STDPERIPH_VERSION_MAIN (0x02) /* [15:8] main version */
  36. #define __CH32V20x_STDPERIPH_VERSION_SUB (0x02) /* [7:0] sub version */
  37. #define __CH32V20x_STDPERIPH_VERSION ( (__CH32V20x_STDPERIPH_VERSION_MAIN << 8)\
  38. |(__CH32V20x_STDPERIPH_VERSION_SUB << 0))
  39. /* Interrupt Number Definition, according to the selected device */
  40. typedef enum IRQn
  41. {
  42. /****** RISC-V Processor Exceptions Numbers *******************************************************/
  43. NonMaskableInt_IRQn = 2, /* 2 Non Maskable Interrupt */
  44. EXC_IRQn = 3, /* 3 Exception Interrupt */
  45. Ecall_M_Mode_IRQn = 5, /* 5 Ecall M Mode Interrupt */
  46. Ecall_U_Mode_IRQn = 8, /* 8 Ecall U Mode Interrupt */
  47. Break_Point_IRQn = 9, /* 9 Break Point Interrupt */
  48. SysTick_IRQn = 12, /* 12 System timer Interrupt */
  49. Software_IRQn = 14, /* 14 software Interrupt */
  50. /****** RISC-V specific Interrupt Numbers *********************************************************/
  51. WWDG_IRQn = 16, /* Window WatchDog Interrupt */
  52. PVD_IRQn = 17, /* PVD through EXTI Line detection Interrupt */
  53. TAMPER_IRQn = 18, /* Tamper Interrupt */
  54. RTC_IRQn = 19, /* RTC global Interrupt */
  55. FLASH_IRQn = 20, /* FLASH global Interrupt */
  56. RCC_IRQn = 21, /* RCC global Interrupt */
  57. EXTI0_IRQn = 22, /* EXTI Line0 Interrupt */
  58. EXTI1_IRQn = 23, /* EXTI Line1 Interrupt */
  59. EXTI2_IRQn = 24, /* EXTI Line2 Interrupt */
  60. EXTI3_IRQn = 25, /* EXTI Line3 Interrupt */
  61. EXTI4_IRQn = 26, /* EXTI Line4 Interrupt */
  62. DMA1_Channel1_IRQn = 27, /* DMA1 Channel 1 global Interrupt */
  63. DMA1_Channel2_IRQn = 28, /* DMA1 Channel 2 global Interrupt */
  64. DMA1_Channel3_IRQn = 29, /* DMA1 Channel 3 global Interrupt */
  65. DMA1_Channel4_IRQn = 30, /* DMA1 Channel 4 global Interrupt */
  66. DMA1_Channel5_IRQn = 31, /* DMA1 Channel 5 global Interrupt */
  67. DMA1_Channel6_IRQn = 32, /* DMA1 Channel 6 global Interrupt */
  68. DMA1_Channel7_IRQn = 33, /* DMA1 Channel 7 global Interrupt */
  69. ADC_IRQn = 34, /* ADC1 and ADC2 global Interrupt */
  70. USB_HP_CAN1_TX_IRQn = 35, /* USB Device High Priority or CAN1 TX Interrupts */
  71. USB_LP_CAN1_RX0_IRQn = 36, /* USB Device Low Priority or CAN1 RX0 Interrupts */
  72. CAN1_RX1_IRQn = 37, /* CAN1 RX1 Interrupt */
  73. CAN1_SCE_IRQn = 38, /* CAN1 SCE Interrupt */
  74. EXTI9_5_IRQn = 39, /* External Line[9:5] Interrupts */
  75. TIM1_BRK_IRQn = 40, /* TIM1 Break Interrupt */
  76. TIM1_UP_IRQn = 41, /* TIM1 Update Interrupt */
  77. TIM1_TRG_COM_IRQn = 42, /* TIM1 Trigger and Commutation Interrupt */
  78. TIM1_CC_IRQn = 43, /* TIM1 Capture Compare Interrupt */
  79. TIM2_IRQn = 44, /* TIM2 global Interrupt */
  80. TIM3_IRQn = 45, /* TIM3 global Interrupt */
  81. TIM4_IRQn = 46, /* TIM4 global Interrupt */
  82. I2C1_EV_IRQn = 47, /* I2C1 Event Interrupt */
  83. I2C1_ER_IRQn = 48, /* I2C1 Error Interrupt */
  84. I2C2_EV_IRQn = 49, /* I2C2 Event Interrupt */
  85. I2C2_ER_IRQn = 50, /* I2C2 Error Interrupt */
  86. SPI1_IRQn = 51, /* SPI1 global Interrupt */
  87. SPI2_IRQn = 52, /* SPI2 global Interrupt */
  88. USART1_IRQn = 53, /* USART1 global Interrupt */
  89. USART2_IRQn = 54, /* USART2 global Interrupt */
  90. USART3_IRQn = 55, /* USART3 global Interrupt */
  91. EXTI15_10_IRQn = 56, /* External Line[15:10] Interrupts */
  92. RTCAlarm_IRQn = 57, /* RTC Alarm through EXTI Line Interrupt */
  93. USBWakeUp_IRQn = 58, /* USB Device WakeUp from suspend through EXTI Line Interrupt */
  94. USBFS_IRQn = 59, /* USBFS global Interrupt */
  95. USBFSWakeUp_IRQn = 60, /* USB Host/Device WakeUp Interrupt */
  96. #ifdef CH32V20x_D6
  97. UART4_IRQn = 61, /* UART4 global Interrupt */
  98. DMA1_Channel8_IRQn = 62, /* DMA1 Channel 8 global Interrupt */
  99. #elif defined(CH32V20x_D8)
  100. ETH_IRQn = 61, /* ETH global Interrupt */
  101. ETHWakeUp_IRQn = 62, /* ETH WakeUp Interrupt */
  102. TIM5_IRQn = 65, /* TIM5 global Interrupt */
  103. UART4_IRQn = 66, /* UART4 global Interrupt */
  104. DMA1_Channel8_IRQn = 67, /* DMA1 Channel 8 global Interrupt */
  105. OSC32KCal_IRQn = 68, /* OSC32K global Interrupt */
  106. OSCWakeUp_IRQn = 69, /* OSC32K WakeUp Interrupt */
  107. #elif defined(CH32V20x_D8W)
  108. ETH_IRQn = 61, /* ETH global Interrupt */
  109. ETHWakeUp_IRQn = 62, /* ETH WakeUp Interrupt */
  110. BB_IRQn = 63, /* BLE BB global Interrupt */
  111. LLE_IRQn = 64, /* BLE LLE global Interrupt */
  112. TIM5_IRQn = 65, /* TIM5 global Interrupt */
  113. UART4_IRQn = 66, /* UART4 global Interrupt */
  114. DMA1_Channel8_IRQn = 67, /* DMA1 Channel 8 global Interrupt */
  115. OSC32KCal_IRQn = 68, /* OSC32K global Interrupt */
  116. OSCWakeUp_IRQn = 69, /* OSC32K WakeUp Interrupt */
  117. #endif
  118. } IRQn_Type;
  119. #define HardFault_IRQn EXC_IRQn
  120. #define ADC1_2_IRQn ADC_IRQn
  121. #define SysTicK_IRQn SysTick_IRQn
  122. #define USBHD_IRQn USBFS_IRQn
  123. #define USBHDWakeUp_IRQn USBFSWakeUp_IRQn
  124. #define USBHD_IRQHandler USBFS_IRQHandler
  125. #define USBHDWakeUp_IRQHandler USBFSWakeUp_IRQHandler
  126. #define USBOTG_FS USBFSD
  127. #define USBOTG_H_FS USBFSH
  128. #include <stdint.h>
  129. #include "core_riscv.h"
  130. #include "system_ch32v20x.h"
  131. /* Standard Peripheral Library old definitions (maintained for legacy purpose) */
  132. #define HSI_Value HSI_VALUE
  133. #define HSE_Value HSE_VALUE
  134. #define HSEStartUp_TimeOut HSE_STARTUP_TIMEOUT
  135. /* Analog to Digital Converter */
  136. typedef struct
  137. {
  138. __IO uint32_t STATR;
  139. __IO uint32_t CTLR1;
  140. __IO uint32_t CTLR2;
  141. __IO uint32_t SAMPTR1;
  142. __IO uint32_t SAMPTR2;
  143. __IO uint32_t IOFR1;
  144. __IO uint32_t IOFR2;
  145. __IO uint32_t IOFR3;
  146. __IO uint32_t IOFR4;
  147. __IO uint32_t WDHTR;
  148. __IO uint32_t WDLTR;
  149. __IO uint32_t RSQR1;
  150. __IO uint32_t RSQR2;
  151. __IO uint32_t RSQR3;
  152. __IO uint32_t ISQR;
  153. __IO uint32_t IDATAR1;
  154. __IO uint32_t IDATAR2;
  155. __IO uint32_t IDATAR3;
  156. __IO uint32_t IDATAR4;
  157. __IO uint32_t RDATAR;
  158. } ADC_TypeDef;
  159. /* Backup Registers */
  160. typedef struct
  161. {
  162. uint32_t RESERVED0;
  163. __IO uint16_t DATAR1;
  164. uint16_t RESERVED1;
  165. __IO uint16_t DATAR2;
  166. uint16_t RESERVED2;
  167. __IO uint16_t DATAR3;
  168. uint16_t RESERVED3;
  169. __IO uint16_t DATAR4;
  170. uint16_t RESERVED4;
  171. __IO uint16_t DATAR5;
  172. uint16_t RESERVED5;
  173. __IO uint16_t DATAR6;
  174. uint16_t RESERVED6;
  175. __IO uint16_t DATAR7;
  176. uint16_t RESERVED7;
  177. __IO uint16_t DATAR8;
  178. uint16_t RESERVED8;
  179. __IO uint16_t DATAR9;
  180. uint16_t RESERVED9;
  181. __IO uint16_t DATAR10;
  182. uint16_t RESERVED10;
  183. __IO uint16_t OCTLR;
  184. uint16_t RESERVED11;
  185. __IO uint16_t TPCTLR;
  186. uint16_t RESERVED12;
  187. __IO uint16_t TPCSR;
  188. uint16_t RESERVED13[5];
  189. __IO uint16_t DATAR11;
  190. uint16_t RESERVED14;
  191. __IO uint16_t DATAR12;
  192. uint16_t RESERVED15;
  193. __IO uint16_t DATAR13;
  194. uint16_t RESERVED16;
  195. __IO uint16_t DATAR14;
  196. uint16_t RESERVED17;
  197. __IO uint16_t DATAR15;
  198. uint16_t RESERVED18;
  199. __IO uint16_t DATAR16;
  200. uint16_t RESERVED19;
  201. __IO uint16_t DATAR17;
  202. uint16_t RESERVED20;
  203. __IO uint16_t DATAR18;
  204. uint16_t RESERVED21;
  205. __IO uint16_t DATAR19;
  206. uint16_t RESERVED22;
  207. __IO uint16_t DATAR20;
  208. uint16_t RESERVED23;
  209. __IO uint16_t DATAR21;
  210. uint16_t RESERVED24;
  211. __IO uint16_t DATAR22;
  212. uint16_t RESERVED25;
  213. __IO uint16_t DATAR23;
  214. uint16_t RESERVED26;
  215. __IO uint16_t DATAR24;
  216. uint16_t RESERVED27;
  217. __IO uint16_t DATAR25;
  218. uint16_t RESERVED28;
  219. __IO uint16_t DATAR26;
  220. uint16_t RESERVED29;
  221. __IO uint16_t DATAR27;
  222. uint16_t RESERVED30;
  223. __IO uint16_t DATAR28;
  224. uint16_t RESERVED31;
  225. __IO uint16_t DATAR29;
  226. uint16_t RESERVED32;
  227. __IO uint16_t DATAR30;
  228. uint16_t RESERVED33;
  229. __IO uint16_t DATAR31;
  230. uint16_t RESERVED34;
  231. __IO uint16_t DATAR32;
  232. uint16_t RESERVED35;
  233. __IO uint16_t DATAR33;
  234. uint16_t RESERVED36;
  235. __IO uint16_t DATAR34;
  236. uint16_t RESERVED37;
  237. __IO uint16_t DATAR35;
  238. uint16_t RESERVED38;
  239. __IO uint16_t DATAR36;
  240. uint16_t RESERVED39;
  241. __IO uint16_t DATAR37;
  242. uint16_t RESERVED40;
  243. __IO uint16_t DATAR38;
  244. uint16_t RESERVED41;
  245. __IO uint16_t DATAR39;
  246. uint16_t RESERVED42;
  247. __IO uint16_t DATAR40;
  248. uint16_t RESERVED43;
  249. __IO uint16_t DATAR41;
  250. uint16_t RESERVED44;
  251. __IO uint16_t DATAR42;
  252. uint16_t RESERVED45;
  253. } BKP_TypeDef;
  254. /* Controller Area Network TxMailBox */
  255. typedef struct
  256. {
  257. __IO uint32_t TXMIR;
  258. __IO uint32_t TXMDTR;
  259. __IO uint32_t TXMDLR;
  260. __IO uint32_t TXMDHR;
  261. } CAN_TxMailBox_TypeDef;
  262. /* Controller Area Network FIFOMailBox */
  263. typedef struct
  264. {
  265. __IO uint32_t RXMIR;
  266. __IO uint32_t RXMDTR;
  267. __IO uint32_t RXMDLR;
  268. __IO uint32_t RXMDHR;
  269. } CAN_FIFOMailBox_TypeDef;
  270. /* Controller Area Network FilterRegister */
  271. typedef struct
  272. {
  273. __IO uint32_t FR1;
  274. __IO uint32_t FR2;
  275. } CAN_FilterRegister_TypeDef;
  276. /* Controller Area Network */
  277. typedef struct
  278. {
  279. __IO uint32_t CTLR;
  280. __IO uint32_t STATR;
  281. __IO uint32_t TSTATR;
  282. __IO uint32_t RFIFO0;
  283. __IO uint32_t RFIFO1;
  284. __IO uint32_t INTENR;
  285. __IO uint32_t ERRSR;
  286. __IO uint32_t BTIMR;
  287. uint32_t RESERVED0[88];
  288. CAN_TxMailBox_TypeDef sTxMailBox[3];
  289. CAN_FIFOMailBox_TypeDef sFIFOMailBox[2];
  290. uint32_t RESERVED1[12];
  291. __IO uint32_t FCTLR;
  292. __IO uint32_t FMCFGR;
  293. uint32_t RESERVED2;
  294. __IO uint32_t FSCFGR;
  295. uint32_t RESERVED3;
  296. __IO uint32_t FAFIFOR;
  297. uint32_t RESERVED4;
  298. __IO uint32_t FWR;
  299. uint32_t RESERVED5[8];
  300. CAN_FilterRegister_TypeDef sFilterRegister[28];
  301. } CAN_TypeDef;
  302. /* CRC Calculation Unit */
  303. typedef struct
  304. {
  305. __IO uint32_t DATAR;
  306. __IO uint8_t IDATAR;
  307. uint8_t RESERVED0;
  308. uint16_t RESERVED1;
  309. __IO uint32_t CTLR;
  310. } CRC_TypeDef;
  311. /* DMA Channel Controller */
  312. typedef struct
  313. {
  314. __IO uint32_t CFGR;
  315. __IO uint32_t CNTR;
  316. __IO uint32_t PADDR;
  317. __IO uint32_t MADDR;
  318. } DMA_Channel_TypeDef;
  319. /* DMA Controller */
  320. typedef struct
  321. {
  322. __IO uint32_t INTFR;
  323. __IO uint32_t INTFCR;
  324. } DMA_TypeDef;
  325. /* External Interrupt/Event Controller */
  326. typedef struct
  327. {
  328. __IO uint32_t INTENR;
  329. __IO uint32_t EVENR;
  330. __IO uint32_t RTENR;
  331. __IO uint32_t FTENR;
  332. __IO uint32_t SWIEVR;
  333. __IO uint32_t INTFR;
  334. } EXTI_TypeDef;
  335. /* FLASH Registers */
  336. typedef struct
  337. {
  338. __IO uint32_t ACTLR;
  339. __IO uint32_t KEYR;
  340. __IO uint32_t OBKEYR;
  341. __IO uint32_t STATR;
  342. __IO uint32_t CTLR;
  343. __IO uint32_t ADDR;
  344. __IO uint32_t RESERVED;
  345. __IO uint32_t OBR;
  346. __IO uint32_t WPR;
  347. __IO uint32_t MODEKEYR;
  348. } FLASH_TypeDef;
  349. /* Option Bytes Registers */
  350. typedef struct
  351. {
  352. __IO uint16_t RDPR;
  353. __IO uint16_t USER;
  354. __IO uint16_t Data0;
  355. __IO uint16_t Data1;
  356. __IO uint16_t WRPR0;
  357. __IO uint16_t WRPR1;
  358. __IO uint16_t WRPR2;
  359. __IO uint16_t WRPR3;
  360. } OB_TypeDef;
  361. /* General Purpose I/O */
  362. typedef struct
  363. {
  364. __IO uint32_t CFGLR;
  365. __IO uint32_t CFGHR;
  366. __IO uint32_t INDR;
  367. __IO uint32_t OUTDR;
  368. __IO uint32_t BSHR;
  369. __IO uint32_t BCR;
  370. __IO uint32_t LCKR;
  371. } GPIO_TypeDef;
  372. /* Alternate Function I/O */
  373. typedef struct
  374. {
  375. __IO uint32_t ECR;
  376. __IO uint32_t PCFR1;
  377. __IO uint32_t EXTICR[4];
  378. uint32_t RESERVED0;
  379. __IO uint32_t PCFR2;
  380. } AFIO_TypeDef;
  381. /* Inter Integrated Circuit Interface */
  382. typedef struct
  383. {
  384. __IO uint16_t CTLR1;
  385. uint16_t RESERVED0;
  386. __IO uint16_t CTLR2;
  387. uint16_t RESERVED1;
  388. __IO uint16_t OADDR1;
  389. uint16_t RESERVED2;
  390. __IO uint16_t OADDR2;
  391. uint16_t RESERVED3;
  392. __IO uint16_t DATAR;
  393. uint16_t RESERVED4;
  394. __IO uint16_t STAR1;
  395. uint16_t RESERVED5;
  396. __IO uint16_t STAR2;
  397. uint16_t RESERVED6;
  398. __IO uint16_t CKCFGR;
  399. uint16_t RESERVED7;
  400. __IO uint16_t RTR;
  401. uint16_t RESERVED8;
  402. } I2C_TypeDef;
  403. /* Independent WatchDog */
  404. typedef struct
  405. {
  406. __IO uint32_t CTLR;
  407. __IO uint32_t PSCR;
  408. __IO uint32_t RLDR;
  409. __IO uint32_t STATR;
  410. } IWDG_TypeDef;
  411. /* Power Control */
  412. typedef struct
  413. {
  414. __IO uint32_t CTLR;
  415. __IO uint32_t CSR;
  416. } PWR_TypeDef;
  417. /* Reset and Clock Control */
  418. typedef struct
  419. {
  420. __IO uint32_t CTLR;
  421. __IO uint32_t CFGR0;
  422. __IO uint32_t INTR;
  423. __IO uint32_t APB2PRSTR;
  424. __IO uint32_t APB1PRSTR;
  425. __IO uint32_t AHBPCENR;
  426. __IO uint32_t APB2PCENR;
  427. __IO uint32_t APB1PCENR;
  428. __IO uint32_t BDCTLR;
  429. __IO uint32_t RSTSCKR;
  430. __IO uint32_t AHBRSTR;
  431. __IO uint32_t CFGR2;
  432. } RCC_TypeDef;
  433. /* Real-Time Clock */
  434. typedef struct
  435. {
  436. __IO uint16_t CTLRH;
  437. uint16_t RESERVED0;
  438. __IO uint16_t CTLRL;
  439. uint16_t RESERVED1;
  440. __IO uint16_t PSCRH;
  441. uint16_t RESERVED2;
  442. __IO uint16_t PSCRL;
  443. uint16_t RESERVED3;
  444. __IO uint16_t DIVH;
  445. uint16_t RESERVED4;
  446. __IO uint16_t DIVL;
  447. uint16_t RESERVED5;
  448. __IO uint16_t CNTH;
  449. uint16_t RESERVED6;
  450. __IO uint16_t CNTL;
  451. uint16_t RESERVED7;
  452. __IO uint16_t ALRMH;
  453. uint16_t RESERVED8;
  454. __IO uint16_t ALRML;
  455. uint16_t RESERVED9;
  456. } RTC_TypeDef;
  457. /* Serial Peripheral Interface */
  458. typedef struct
  459. {
  460. __IO uint16_t CTLR1;
  461. uint16_t RESERVED0;
  462. __IO uint16_t CTLR2;
  463. uint16_t RESERVED1;
  464. __IO uint16_t STATR;
  465. uint16_t RESERVED2;
  466. __IO uint16_t DATAR;
  467. uint16_t RESERVED3;
  468. __IO uint16_t CRCR;
  469. uint16_t RESERVED4;
  470. __IO uint16_t RCRCR;
  471. uint16_t RESERVED5;
  472. __IO uint16_t TCRCR;
  473. uint16_t RESERVED6;
  474. __IO uint16_t I2SCFGR;
  475. uint16_t RESERVED7;
  476. __IO uint16_t I2SPR;
  477. uint16_t RESERVED8;
  478. __IO uint16_t HSCR;
  479. uint16_t RESERVED9;
  480. } SPI_TypeDef;
  481. /* TIM */
  482. typedef struct
  483. {
  484. __IO uint16_t CTLR1;
  485. uint16_t RESERVED0;
  486. __IO uint16_t CTLR2;
  487. uint16_t RESERVED1;
  488. __IO uint16_t SMCFGR;
  489. uint16_t RESERVED2;
  490. __IO uint16_t DMAINTENR;
  491. uint16_t RESERVED3;
  492. __IO uint16_t INTFR;
  493. uint16_t RESERVED4;
  494. __IO uint16_t SWEVGR;
  495. uint16_t RESERVED5;
  496. __IO uint16_t CHCTLR1;
  497. uint16_t RESERVED6;
  498. __IO uint16_t CHCTLR2;
  499. uint16_t RESERVED7;
  500. __IO uint16_t CCER;
  501. uint16_t RESERVED8;
  502. union
  503. {
  504. __IO uint32_t CNT_R32;
  505. struct
  506. {
  507. __IO uint16_t CNT;
  508. uint16_t RESERVED9;
  509. };
  510. };
  511. __IO uint16_t PSC;
  512. uint16_t RESERVED10;
  513. union
  514. {
  515. __IO uint32_t ATRLR_R32;
  516. struct
  517. {
  518. __IO uint16_t ATRLR;
  519. uint16_t RESERVED11;
  520. };
  521. };
  522. __IO uint16_t RPTCR;
  523. uint16_t RESERVED12;
  524. union
  525. {
  526. __IO uint32_t CH1CVR_R32;
  527. struct
  528. {
  529. __IO uint16_t CH1CVR;
  530. uint16_t RESERVED13;
  531. };
  532. };
  533. union
  534. {
  535. __IO uint32_t CH2CVR_R32;
  536. struct
  537. {
  538. __IO uint16_t CH2CVR;
  539. uint16_t RESERVED14;
  540. };
  541. };
  542. union
  543. {
  544. __IO uint32_t CH3CVR_R32;
  545. struct
  546. {
  547. __IO uint16_t CH3CVR;
  548. uint16_t RESERVED15;
  549. };
  550. };
  551. union
  552. {
  553. __IO uint32_t CH4CVR_R32;
  554. struct
  555. {
  556. __IO uint16_t CH4CVR;
  557. uint16_t RESERVED16;
  558. };
  559. };
  560. __IO uint16_t BDTR;
  561. uint16_t RESERVED17;
  562. __IO uint16_t DMACFGR;
  563. uint16_t RESERVED18;
  564. __IO uint16_t DMAADR;
  565. uint16_t RESERVED19;
  566. } TIM_TypeDef;
  567. /* Universal Synchronous Asynchronous Receiver Transmitter */
  568. typedef struct
  569. {
  570. __IO uint16_t STATR;
  571. uint16_t RESERVED0;
  572. __IO uint16_t DATAR;
  573. uint16_t RESERVED1;
  574. __IO uint16_t BRR;
  575. uint16_t RESERVED2;
  576. __IO uint16_t CTLR1;
  577. uint16_t RESERVED3;
  578. __IO uint16_t CTLR2;
  579. uint16_t RESERVED4;
  580. __IO uint16_t CTLR3;
  581. uint16_t RESERVED5;
  582. __IO uint16_t GPR;
  583. uint16_t RESERVED6;
  584. } USART_TypeDef;
  585. /* Window WatchDog */
  586. typedef struct
  587. {
  588. __IO uint32_t CTLR;
  589. __IO uint32_t CFGR;
  590. __IO uint32_t STATR;
  591. } WWDG_TypeDef;
  592. /* Enhanced Registers */
  593. typedef struct
  594. {
  595. __IO uint32_t EXTEN_CTR;
  596. } EXTEN_TypeDef;
  597. /* OPA Registers */
  598. typedef struct
  599. {
  600. __IO uint32_t CR;
  601. } OPA_TypeDef;
  602. /* USBFS Registers */
  603. typedef struct
  604. {
  605. __IO uint8_t BASE_CTRL;
  606. __IO uint8_t UDEV_CTRL;
  607. __IO uint8_t INT_EN;
  608. __IO uint8_t DEV_ADDR;
  609. __IO uint8_t Reserve0;
  610. __IO uint8_t MIS_ST;
  611. __IO uint8_t INT_FG;
  612. __IO uint8_t INT_ST;
  613. __IO uint32_t RX_LEN;
  614. __IO uint8_t UEP4_1_MOD;
  615. __IO uint8_t UEP2_3_MOD;
  616. __IO uint8_t UEP5_6_MOD;
  617. __IO uint8_t UEP7_MOD;
  618. __IO uint32_t UEP0_DMA;
  619. __IO uint32_t UEP1_DMA;
  620. __IO uint32_t UEP2_DMA;
  621. __IO uint32_t UEP3_DMA;
  622. __IO uint32_t UEP4_DMA;
  623. __IO uint32_t UEP5_DMA;
  624. __IO uint32_t UEP6_DMA;
  625. __IO uint32_t UEP7_DMA;
  626. __IO uint16_t UEP0_TX_LEN;
  627. __IO uint8_t UEP0_TX_CTRL;
  628. __IO uint8_t UEP0_RX_CTRL;
  629. __IO uint16_t UEP1_TX_LEN;
  630. __IO uint8_t UEP1_TX_CTRL;
  631. __IO uint8_t UEP1_RX_CTRL;
  632. __IO uint16_t UEP2_TX_LEN;
  633. __IO uint8_t UEP2_TX_CTRL;
  634. __IO uint8_t UEP2_RX_CTRL;
  635. __IO uint16_t UEP3_TX_LEN;
  636. __IO uint8_t UEP3_TX_CTRL;
  637. __IO uint8_t UEP3_RX_CTRL;
  638. __IO uint16_t UEP4_TX_LEN;
  639. __IO uint8_t UEP4_TX_CTRL;
  640. __IO uint8_t UEP4_RX_CTRL;
  641. __IO uint16_t UEP5_TX_LEN;
  642. __IO uint8_t UEP5_TX_CTRL;
  643. __IO uint8_t UEP5_RX_CTRL;
  644. __IO uint16_t UEP6_TX_LEN;
  645. __IO uint8_t UEP6_TX_CTRL;
  646. __IO uint8_t UEP6_RX_CTRL;
  647. __IO uint16_t UEP7_TX_LEN;
  648. __IO uint8_t UEP7_TX_CTRL;
  649. __IO uint8_t UEP7_RX_CTRL;
  650. __IO uint32_t Reserve1;
  651. __IO uint32_t OTG_CR;
  652. __IO uint32_t OTG_SR;
  653. } USBFSD_TypeDef;
  654. typedef struct
  655. {
  656. __IO uint8_t BASE_CTRL;
  657. __IO uint8_t HOST_CTRL;
  658. __IO uint8_t INT_EN;
  659. __IO uint8_t DEV_ADDR;
  660. __IO uint8_t Reserve0;
  661. __IO uint8_t MIS_ST;
  662. __IO uint8_t INT_FG;
  663. __IO uint8_t INT_ST;
  664. __IO uint16_t RX_LEN;
  665. __IO uint16_t Reserve1;
  666. __IO uint8_t Reserve2;
  667. __IO uint8_t HOST_EP_MOD;
  668. __IO uint16_t Reserve3;
  669. __IO uint32_t Reserve4;
  670. __IO uint32_t Reserve5;
  671. __IO uint32_t HOST_RX_DMA;
  672. __IO uint32_t HOST_TX_DMA;
  673. __IO uint32_t Reserve6;
  674. __IO uint32_t Reserve7;
  675. __IO uint32_t Reserve8;
  676. __IO uint32_t Reserve9;
  677. __IO uint32_t Reserve10;
  678. __IO uint16_t Reserve11;
  679. __IO uint16_t HOST_SETUP;
  680. __IO uint8_t HOST_EP_PID;
  681. __IO uint8_t Reserve12;
  682. __IO uint8_t Reserve13;
  683. __IO uint8_t HOST_RX_CTRL;
  684. __IO uint16_t HOST_TX_LEN;
  685. __IO uint8_t HOST_TX_CTRL;
  686. __IO uint8_t Reserve14;
  687. __IO uint32_t Reserve15;
  688. __IO uint32_t Reserve16;
  689. __IO uint32_t Reserve17;
  690. __IO uint32_t Reserve18;
  691. __IO uint32_t Reserve19;
  692. __IO uint32_t OTG_CR;
  693. __IO uint32_t OTG_SR;
  694. } USBFSH_TypeDef;
  695. #if defined(CH32V20x_D8) || defined(CH32V20x_D8W)
  696. /* ETH10M Registers */
  697. typedef struct
  698. {
  699. __IO uint8_t reserved1;
  700. __IO uint8_t reserved2;
  701. __IO uint8_t reserved3;
  702. __IO uint8_t EIE;
  703. __IO uint8_t EIR;
  704. __IO uint8_t ESTAT;
  705. __IO uint8_t ECON2;
  706. __IO uint8_t ECON1;
  707. __IO uint16_t ETXST;
  708. __IO uint16_t ETXLN;
  709. __IO uint16_t ERXST;
  710. __IO uint16_t ERXLN;
  711. __IO uint32_t HTL;
  712. __IO uint32_t HTH;
  713. __IO uint8_t ERXFON;
  714. __IO uint8_t MACON1;
  715. __IO uint8_t MACON2;
  716. __IO uint8_t MABBIPG;
  717. __IO uint16_t EPAUS;
  718. __IO uint16_t MAMXFL;
  719. __IO uint16_t MIRD;
  720. __IO uint16_t reserved4;
  721. __IO uint8_t MIERGADR;
  722. __IO uint8_t MISTAT;
  723. __IO uint16_t MIWR;
  724. __IO uint32_t MAADRL;
  725. __IO uint16_t MAADRH;
  726. __IO uint16_t reserved5;
  727. } ETH10M_TypeDef;
  728. #endif
  729. #if defined(CH32V20x_D8) || defined(CH32V20x_D8W)
  730. /* OSC Registers */
  731. typedef struct
  732. {
  733. __IO uint32_t HSE_CAL_CTRL;
  734. __IO uint32_t Reserve0;
  735. __IO uint16_t Reserve1;
  736. __IO uint16_t LSI32K_TUNE;
  737. __IO uint32_t Reserve2;
  738. __IO uint32_t Reserve3;
  739. __IO uint32_t Reserve4;
  740. __IO uint32_t Reserve5;
  741. __IO uint8_t Reserve6;
  742. __IO uint8_t LSI32K_CAL_CFG;
  743. __IO uint16_t Reserve7;
  744. __IO uint16_t LSI32K_CAL_STATR;
  745. __IO uint8_t LSI32K_CAL_OV_CNT;
  746. __IO uint8_t LSI32K_CAL_CTRL;
  747. } OSC_TypeDef;
  748. #endif
  749. /* Peripheral memory map */
  750. #define FLASH_BASE ((uint32_t)0x08000000) /* FLASH base address in the alias region */
  751. #define SRAM_BASE ((uint32_t)0x20000000) /* SRAM base address in the alias region */
  752. #define PERIPH_BASE ((uint32_t)0x40000000) /* Peripheral base address in the alias region */
  753. #define APB1PERIPH_BASE (PERIPH_BASE)
  754. #define APB2PERIPH_BASE (PERIPH_BASE + 0x10000)
  755. #define AHBPERIPH_BASE (PERIPH_BASE + 0x20000)
  756. #define TIM2_BASE (APB1PERIPH_BASE + 0x0000)
  757. #define TIM3_BASE (APB1PERIPH_BASE + 0x0400)
  758. #define TIM4_BASE (APB1PERIPH_BASE + 0x0800)
  759. #define TIM5_BASE (APB1PERIPH_BASE + 0x0C00)
  760. #define RTC_BASE (APB1PERIPH_BASE + 0x2800)
  761. #define WWDG_BASE (APB1PERIPH_BASE + 0x2C00)
  762. #define IWDG_BASE (APB1PERIPH_BASE + 0x3000)
  763. #define SPI2_BASE (APB1PERIPH_BASE + 0x3800)
  764. #define USART2_BASE (APB1PERIPH_BASE + 0x4400)
  765. #define USART3_BASE (APB1PERIPH_BASE + 0x4800)
  766. #define UART4_BASE (APB1PERIPH_BASE + 0x4C00)
  767. #define I2C1_BASE (APB1PERIPH_BASE + 0x5400)
  768. #define I2C2_BASE (APB1PERIPH_BASE + 0x5800)
  769. #define CAN1_BASE (APB1PERIPH_BASE + 0x6400)
  770. #define BKP_BASE (APB1PERIPH_BASE + 0x6C00)
  771. #define PWR_BASE (APB1PERIPH_BASE + 0x7000)
  772. #define AFIO_BASE (APB2PERIPH_BASE + 0x0000)
  773. #define EXTI_BASE (APB2PERIPH_BASE + 0x0400)
  774. #define GPIOA_BASE (APB2PERIPH_BASE + 0x0800)
  775. #define GPIOB_BASE (APB2PERIPH_BASE + 0x0C00)
  776. #define GPIOC_BASE (APB2PERIPH_BASE + 0x1000)
  777. #define GPIOD_BASE (APB2PERIPH_BASE + 0x1400)
  778. #define GPIOE_BASE (APB2PERIPH_BASE + 0x1800)
  779. #define GPIOF_BASE (APB2PERIPH_BASE + 0x1C00)
  780. #define GPIOG_BASE (APB2PERIPH_BASE + 0x2000)
  781. #define ADC1_BASE (APB2PERIPH_BASE + 0x2400)
  782. #define ADC2_BASE (APB2PERIPH_BASE + 0x2800)
  783. #define TIM1_BASE (APB2PERIPH_BASE + 0x2C00)
  784. #define SPI1_BASE (APB2PERIPH_BASE + 0x3000)
  785. #define USART1_BASE (APB2PERIPH_BASE + 0x3800)
  786. #define DMA1_BASE (AHBPERIPH_BASE + 0x0000)
  787. #define DMA1_Channel1_BASE (AHBPERIPH_BASE + 0x0008)
  788. #define DMA1_Channel2_BASE (AHBPERIPH_BASE + 0x001C)
  789. #define DMA1_Channel3_BASE (AHBPERIPH_BASE + 0x0030)
  790. #define DMA1_Channel4_BASE (AHBPERIPH_BASE + 0x0044)
  791. #define DMA1_Channel5_BASE (AHBPERIPH_BASE + 0x0058)
  792. #define DMA1_Channel6_BASE (AHBPERIPH_BASE + 0x006C)
  793. #define DMA1_Channel7_BASE (AHBPERIPH_BASE + 0x0080)
  794. #define DMA1_Channel8_BASE (AHBPERIPH_BASE + 0x0094)
  795. #define RCC_BASE (AHBPERIPH_BASE + 0x1000)
  796. #define FLASH_R_BASE (AHBPERIPH_BASE + 0x2000)
  797. #define CRC_BASE (AHBPERIPH_BASE + 0x3000)
  798. #define EXTEN_BASE (AHBPERIPH_BASE + 0x3800)
  799. #define OPA_BASE (AHBPERIPH_BASE + 0x3804)
  800. #define ETH10M_BASE (AHBPERIPH_BASE + 0x8000)
  801. #define USBFS_BASE ((uint32_t)0x50000000)
  802. #define OB_BASE ((uint32_t)0x1FFFF800)
  803. #if defined(CH32V20x_D8) || defined(CH32V20x_D8W)
  804. #define OSC_BASE (AHBPERIPH_BASE + 0x202C)
  805. #endif
  806. /* Peripheral declaration */
  807. #define TIM2 ((TIM_TypeDef *)TIM2_BASE)
  808. #define TIM3 ((TIM_TypeDef *)TIM3_BASE)
  809. #define TIM4 ((TIM_TypeDef *)TIM4_BASE)
  810. #define TIM5 ((TIM_TypeDef *)TIM5_BASE)
  811. #define RTC ((RTC_TypeDef *)RTC_BASE)
  812. #define WWDG ((WWDG_TypeDef *)WWDG_BASE)
  813. #define IWDG ((IWDG_TypeDef *)IWDG_BASE)
  814. #define SPI2 ((SPI_TypeDef *)SPI2_BASE)
  815. #define USART2 ((USART_TypeDef *)USART2_BASE)
  816. #define USART3 ((USART_TypeDef *)USART3_BASE)
  817. #define UART4 ((USART_TypeDef *)UART4_BASE)
  818. #define I2C1 ((I2C_TypeDef *)I2C1_BASE)
  819. #define I2C2 ((I2C_TypeDef *)I2C2_BASE)
  820. #define CAN1 ((CAN_TypeDef *)CAN1_BASE)
  821. #define BKP ((BKP_TypeDef *)BKP_BASE)
  822. #define PWR ((PWR_TypeDef *)PWR_BASE)
  823. #define AFIO ((AFIO_TypeDef *)AFIO_BASE)
  824. #define EXTI ((EXTI_TypeDef *)EXTI_BASE)
  825. #define GPIOA ((GPIO_TypeDef *)GPIOA_BASE)
  826. #define GPIOB ((GPIO_TypeDef *)GPIOB_BASE)
  827. #define GPIOC ((GPIO_TypeDef *)GPIOC_BASE)
  828. #define GPIOD ((GPIO_TypeDef *)GPIOD_BASE)
  829. #define GPIOE ((GPIO_TypeDef *)GPIOE_BASE)
  830. #define GPIOF ((GPIO_TypeDef *)GPIOF_BASE)
  831. #define GPIOG ((GPIO_TypeDef *)GPIOG_BASE)
  832. #define ADC1 ((ADC_TypeDef *)ADC1_BASE)
  833. #define ADC2 ((ADC_TypeDef *)ADC2_BASE)
  834. #define TKey1 ((ADC_TypeDef *)ADC1_BASE)
  835. #define TKey2 ((ADC_TypeDef *)ADC2_BASE)
  836. #define TIM1 ((TIM_TypeDef *)TIM1_BASE)
  837. #define SPI1 ((SPI_TypeDef *)SPI1_BASE)
  838. #define USART1 ((USART_TypeDef *)USART1_BASE)
  839. #define DMA1 ((DMA_TypeDef *)DMA1_BASE)
  840. #define DMA1_Channel1 ((DMA_Channel_TypeDef *)DMA1_Channel1_BASE)
  841. #define DMA1_Channel2 ((DMA_Channel_TypeDef *)DMA1_Channel2_BASE)
  842. #define DMA1_Channel3 ((DMA_Channel_TypeDef *)DMA1_Channel3_BASE)
  843. #define DMA1_Channel4 ((DMA_Channel_TypeDef *)DMA1_Channel4_BASE)
  844. #define DMA1_Channel5 ((DMA_Channel_TypeDef *)DMA1_Channel5_BASE)
  845. #define DMA1_Channel6 ((DMA_Channel_TypeDef *)DMA1_Channel6_BASE)
  846. #define DMA1_Channel7 ((DMA_Channel_TypeDef *)DMA1_Channel7_BASE)
  847. #define DMA1_Channel8 ((DMA_Channel_TypeDef *)DMA1_Channel8_BASE)
  848. #define RCC ((RCC_TypeDef *)RCC_BASE)
  849. #define FLASH ((FLASH_TypeDef *)FLASH_R_BASE)
  850. #define CRC ((CRC_TypeDef *)CRC_BASE)
  851. #define USBFSD ((USBFSD_TypeDef *)USBFS_BASE)
  852. #define USBFSH ((USBFSH_TypeDef *)USBFS_BASE)
  853. #define EXTEN ((EXTEN_TypeDef *)EXTEN_BASE)
  854. #define OPA ((OPA_TypeDef *)OPA_BASE)
  855. #define ETH10M ((ETH10M_TypeDef *)ETH10M_BASE)
  856. #define OB ((OB_TypeDef *)OB_BASE)
  857. #if defined(CH32V20x_D8) || defined(CH32V20x_D8W)
  858. #define OSC ((OSC_TypeDef *)OSC_BASE)
  859. #endif
  860. /******************************************************************************/
  861. /* Peripheral Registers Bits Definition */
  862. /******************************************************************************/
  863. /******************************************************************************/
  864. /* Analog to Digital Converter */
  865. /******************************************************************************/
  866. /******************** Bit definition for ADC_STATR register ********************/
  867. #define ADC_AWD ((uint8_t)0x01) /* Analog watchdog flag */
  868. #define ADC_EOC ((uint8_t)0x02) /* End of conversion */
  869. #define ADC_JEOC ((uint8_t)0x04) /* Injected channel end of conversion */
  870. #define ADC_JSTRT ((uint8_t)0x08) /* Injected channel Start flag */
  871. #define ADC_STRT ((uint8_t)0x10) /* Regular channel Start flag */
  872. /******************* Bit definition for ADC_CTLR1 register ********************/
  873. #define ADC_AWDCH ((uint32_t)0x0000001F) /* AWDCH[4:0] bits (Analog watchdog channel select bits) */
  874. #define ADC_AWDCH_0 ((uint32_t)0x00000001) /* Bit 0 */
  875. #define ADC_AWDCH_1 ((uint32_t)0x00000002) /* Bit 1 */
  876. #define ADC_AWDCH_2 ((uint32_t)0x00000004) /* Bit 2 */
  877. #define ADC_AWDCH_3 ((uint32_t)0x00000008) /* Bit 3 */
  878. #define ADC_AWDCH_4 ((uint32_t)0x00000010) /* Bit 4 */
  879. #define ADC_EOCIE ((uint32_t)0x00000020) /* Interrupt enable for EOC */
  880. #define ADC_AWDIE ((uint32_t)0x00000040) /* Analog Watchdog interrupt enable */
  881. #define ADC_JEOCIE ((uint32_t)0x00000080) /* Interrupt enable for injected channels */
  882. #define ADC_SCAN ((uint32_t)0x00000100) /* Scan mode */
  883. #define ADC_AWDSGL ((uint32_t)0x00000200) /* Enable the watchdog on a single channel in scan mode */
  884. #define ADC_JAUTO ((uint32_t)0x00000400) /* Automatic injected group conversion */
  885. #define ADC_DISCEN ((uint32_t)0x00000800) /* Discontinuous mode on regular channels */
  886. #define ADC_JDISCEN ((uint32_t)0x00001000) /* Discontinuous mode on injected channels */
  887. #define ADC_DISCNUM ((uint32_t)0x0000E000) /* DISCNUM[2:0] bits (Discontinuous mode channel count) */
  888. #define ADC_DISCNUM_0 ((uint32_t)0x00002000) /* Bit 0 */
  889. #define ADC_DISCNUM_1 ((uint32_t)0x00004000) /* Bit 1 */
  890. #define ADC_DISCNUM_2 ((uint32_t)0x00008000) /* Bit 2 */
  891. #define ADC_DUALMOD ((uint32_t)0x000F0000) /* DUALMOD[3:0] bits (Dual mode selection) */
  892. #define ADC_DUALMOD_0 ((uint32_t)0x00010000) /* Bit 0 */
  893. #define ADC_DUALMOD_1 ((uint32_t)0x00020000) /* Bit 1 */
  894. #define ADC_DUALMOD_2 ((uint32_t)0x00040000) /* Bit 2 */
  895. #define ADC_DUALMOD_3 ((uint32_t)0x00080000) /* Bit 3 */
  896. #define ADC_JAWDEN ((uint32_t)0x00400000) /* Analog watchdog enable on injected channels */
  897. #define ADC_AWDEN ((uint32_t)0x00800000) /* Analog watchdog enable on regular channels */
  898. /******************* Bit definition for ADC_CTLR2 register ********************/
  899. #define ADC_ADON ((uint32_t)0x00000001) /* A/D Converter ON / OFF */
  900. #define ADC_CONT ((uint32_t)0x00000002) /* Continuous Conversion */
  901. #define ADC_CAL ((uint32_t)0x00000004) /* A/D Calibration */
  902. #define ADC_RSTCAL ((uint32_t)0x00000008) /* Reset Calibration */
  903. #define ADC_DMA ((uint32_t)0x00000100) /* Direct Memory access mode */
  904. #define ADC_ALIGN ((uint32_t)0x00000800) /* Data Alignment */
  905. #define ADC_JEXTSEL ((uint32_t)0x00007000) /* JEXTSEL[2:0] bits (External event select for injected group) */
  906. #define ADC_JEXTSEL_0 ((uint32_t)0x00001000) /* Bit 0 */
  907. #define ADC_JEXTSEL_1 ((uint32_t)0x00002000) /* Bit 1 */
  908. #define ADC_JEXTSEL_2 ((uint32_t)0x00004000) /* Bit 2 */
  909. #define ADC_JEXTTRIG ((uint32_t)0x00008000) /* External Trigger Conversion mode for injected channels */
  910. #define ADC_EXTSEL ((uint32_t)0x000E0000) /* EXTSEL[2:0] bits (External Event Select for regular group) */
  911. #define ADC_EXTSEL_0 ((uint32_t)0x00020000) /* Bit 0 */
  912. #define ADC_EXTSEL_1 ((uint32_t)0x00040000) /* Bit 1 */
  913. #define ADC_EXTSEL_2 ((uint32_t)0x00080000) /* Bit 2 */
  914. #define ADC_EXTTRIG ((uint32_t)0x00100000) /* External Trigger Conversion mode for regular channels */
  915. #define ADC_JSWSTART ((uint32_t)0x00200000) /* Start Conversion of injected channels */
  916. #define ADC_SWSTART ((uint32_t)0x00400000) /* Start Conversion of regular channels */
  917. #define ADC_TSVREFE ((uint32_t)0x00800000) /* Temperature Sensor and VREFINT Enable */
  918. /****************** Bit definition for ADC_SAMPTR1 register *******************/
  919. #define ADC_SMP10 ((uint32_t)0x00000007) /* SMP10[2:0] bits (Channel 10 Sample time selection) */
  920. #define ADC_SMP10_0 ((uint32_t)0x00000001) /* Bit 0 */
  921. #define ADC_SMP10_1 ((uint32_t)0x00000002) /* Bit 1 */
  922. #define ADC_SMP10_2 ((uint32_t)0x00000004) /* Bit 2 */
  923. #define ADC_SMP11 ((uint32_t)0x00000038) /* SMP11[2:0] bits (Channel 11 Sample time selection) */
  924. #define ADC_SMP11_0 ((uint32_t)0x00000008) /* Bit 0 */
  925. #define ADC_SMP11_1 ((uint32_t)0x00000010) /* Bit 1 */
  926. #define ADC_SMP11_2 ((uint32_t)0x00000020) /* Bit 2 */
  927. #define ADC_SMP12 ((uint32_t)0x000001C0) /* SMP12[2:0] bits (Channel 12 Sample time selection) */
  928. #define ADC_SMP12_0 ((uint32_t)0x00000040) /* Bit 0 */
  929. #define ADC_SMP12_1 ((uint32_t)0x00000080) /* Bit 1 */
  930. #define ADC_SMP12_2 ((uint32_t)0x00000100) /* Bit 2 */
  931. #define ADC_SMP13 ((uint32_t)0x00000E00) /* SMP13[2:0] bits (Channel 13 Sample time selection) */
  932. #define ADC_SMP13_0 ((uint32_t)0x00000200) /* Bit 0 */
  933. #define ADC_SMP13_1 ((uint32_t)0x00000400) /* Bit 1 */
  934. #define ADC_SMP13_2 ((uint32_t)0x00000800) /* Bit 2 */
  935. #define ADC_SMP14 ((uint32_t)0x00007000) /* SMP14[2:0] bits (Channel 14 Sample time selection) */
  936. #define ADC_SMP14_0 ((uint32_t)0x00001000) /* Bit 0 */
  937. #define ADC_SMP14_1 ((uint32_t)0x00002000) /* Bit 1 */
  938. #define ADC_SMP14_2 ((uint32_t)0x00004000) /* Bit 2 */
  939. #define ADC_SMP15 ((uint32_t)0x00038000) /* SMP15[2:0] bits (Channel 15 Sample time selection) */
  940. #define ADC_SMP15_0 ((uint32_t)0x00008000) /* Bit 0 */
  941. #define ADC_SMP15_1 ((uint32_t)0x00010000) /* Bit 1 */
  942. #define ADC_SMP15_2 ((uint32_t)0x00020000) /* Bit 2 */
  943. #define ADC_SMP16 ((uint32_t)0x001C0000) /* SMP16[2:0] bits (Channel 16 Sample time selection) */
  944. #define ADC_SMP16_0 ((uint32_t)0x00040000) /* Bit 0 */
  945. #define ADC_SMP16_1 ((uint32_t)0x00080000) /* Bit 1 */
  946. #define ADC_SMP16_2 ((uint32_t)0x00100000) /* Bit 2 */
  947. #define ADC_SMP17 ((uint32_t)0x00E00000) /* SMP17[2:0] bits (Channel 17 Sample time selection) */
  948. #define ADC_SMP17_0 ((uint32_t)0x00200000) /* Bit 0 */
  949. #define ADC_SMP17_1 ((uint32_t)0x00400000) /* Bit 1 */
  950. #define ADC_SMP17_2 ((uint32_t)0x00800000) /* Bit 2 */
  951. /****************** Bit definition for ADC_SAMPTR2 register *******************/
  952. #define ADC_SMP0 ((uint32_t)0x00000007) /* SMP0[2:0] bits (Channel 0 Sample time selection) */
  953. #define ADC_SMP0_0 ((uint32_t)0x00000001) /* Bit 0 */
  954. #define ADC_SMP0_1 ((uint32_t)0x00000002) /* Bit 1 */
  955. #define ADC_SMP0_2 ((uint32_t)0x00000004) /* Bit 2 */
  956. #define ADC_SMP1 ((uint32_t)0x00000038) /* SMP1[2:0] bits (Channel 1 Sample time selection) */
  957. #define ADC_SMP1_0 ((uint32_t)0x00000008) /* Bit 0 */
  958. #define ADC_SMP1_1 ((uint32_t)0x00000010) /* Bit 1 */
  959. #define ADC_SMP1_2 ((uint32_t)0x00000020) /* Bit 2 */
  960. #define ADC_SMP2 ((uint32_t)0x000001C0) /* SMP2[2:0] bits (Channel 2 Sample time selection) */
  961. #define ADC_SMP2_0 ((uint32_t)0x00000040) /* Bit 0 */
  962. #define ADC_SMP2_1 ((uint32_t)0x00000080) /* Bit 1 */
  963. #define ADC_SMP2_2 ((uint32_t)0x00000100) /* Bit 2 */
  964. #define ADC_SMP3 ((uint32_t)0x00000E00) /* SMP3[2:0] bits (Channel 3 Sample time selection) */
  965. #define ADC_SMP3_0 ((uint32_t)0x00000200) /* Bit 0 */
  966. #define ADC_SMP3_1 ((uint32_t)0x00000400) /* Bit 1 */
  967. #define ADC_SMP3_2 ((uint32_t)0x00000800) /* Bit 2 */
  968. #define ADC_SMP4 ((uint32_t)0x00007000) /* SMP4[2:0] bits (Channel 4 Sample time selection) */
  969. #define ADC_SMP4_0 ((uint32_t)0x00001000) /* Bit 0 */
  970. #define ADC_SMP4_1 ((uint32_t)0x00002000) /* Bit 1 */
  971. #define ADC_SMP4_2 ((uint32_t)0x00004000) /* Bit 2 */
  972. #define ADC_SMP5 ((uint32_t)0x00038000) /* SMP5[2:0] bits (Channel 5 Sample time selection) */
  973. #define ADC_SMP5_0 ((uint32_t)0x00008000) /* Bit 0 */
  974. #define ADC_SMP5_1 ((uint32_t)0x00010000) /* Bit 1 */
  975. #define ADC_SMP5_2 ((uint32_t)0x00020000) /* Bit 2 */
  976. #define ADC_SMP6 ((uint32_t)0x001C0000) /* SMP6[2:0] bits (Channel 6 Sample time selection) */
  977. #define ADC_SMP6_0 ((uint32_t)0x00040000) /* Bit 0 */
  978. #define ADC_SMP6_1 ((uint32_t)0x00080000) /* Bit 1 */
  979. #define ADC_SMP6_2 ((uint32_t)0x00100000) /* Bit 2 */
  980. #define ADC_SMP7 ((uint32_t)0x00E00000) /* SMP7[2:0] bits (Channel 7 Sample time selection) */
  981. #define ADC_SMP7_0 ((uint32_t)0x00200000) /* Bit 0 */
  982. #define ADC_SMP7_1 ((uint32_t)0x00400000) /* Bit 1 */
  983. #define ADC_SMP7_2 ((uint32_t)0x00800000) /* Bit 2 */
  984. #define ADC_SMP8 ((uint32_t)0x07000000) /* SMP8[2:0] bits (Channel 8 Sample time selection) */
  985. #define ADC_SMP8_0 ((uint32_t)0x01000000) /* Bit 0 */
  986. #define ADC_SMP8_1 ((uint32_t)0x02000000) /* Bit 1 */
  987. #define ADC_SMP8_2 ((uint32_t)0x04000000) /* Bit 2 */
  988. #define ADC_SMP9 ((uint32_t)0x38000000) /* SMP9[2:0] bits (Channel 9 Sample time selection) */
  989. #define ADC_SMP9_0 ((uint32_t)0x08000000) /* Bit 0 */
  990. #define ADC_SMP9_1 ((uint32_t)0x10000000) /* Bit 1 */
  991. #define ADC_SMP9_2 ((uint32_t)0x20000000) /* Bit 2 */
  992. /****************** Bit definition for ADC_IOFR1 register *******************/
  993. #define ADC_JOFFSET1 ((uint16_t)0x0FFF) /* Data offset for injected channel 1 */
  994. /****************** Bit definition for ADC_IOFR2 register *******************/
  995. #define ADC_JOFFSET2 ((uint16_t)0x0FFF) /* Data offset for injected channel 2 */
  996. /****************** Bit definition for ADC_IOFR3 register *******************/
  997. #define ADC_JOFFSET3 ((uint16_t)0x0FFF) /* Data offset for injected channel 3 */
  998. /****************** Bit definition for ADC_IOFR4 register *******************/
  999. #define ADC_JOFFSET4 ((uint16_t)0x0FFF) /* Data offset for injected channel 4 */
  1000. /******************* Bit definition for ADC_WDHTR register ********************/
  1001. #define ADC_HT ((uint16_t)0x0FFF) /* Analog watchdog high threshold */
  1002. /******************* Bit definition for ADC_WDLTR register ********************/
  1003. #define ADC_LT ((uint16_t)0x0FFF) /* Analog watchdog low threshold */
  1004. /******************* Bit definition for ADC_RSQR1 register *******************/
  1005. #define ADC_SQ13 ((uint32_t)0x0000001F) /* SQ13[4:0] bits (13th conversion in regular sequence) */
  1006. #define ADC_SQ13_0 ((uint32_t)0x00000001) /* Bit 0 */
  1007. #define ADC_SQ13_1 ((uint32_t)0x00000002) /* Bit 1 */
  1008. #define ADC_SQ13_2 ((uint32_t)0x00000004) /* Bit 2 */
  1009. #define ADC_SQ13_3 ((uint32_t)0x00000008) /* Bit 3 */
  1010. #define ADC_SQ13_4 ((uint32_t)0x00000010) /* Bit 4 */
  1011. #define ADC_SQ14 ((uint32_t)0x000003E0) /* SQ14[4:0] bits (14th conversion in regular sequence) */
  1012. #define ADC_SQ14_0 ((uint32_t)0x00000020) /* Bit 0 */
  1013. #define ADC_SQ14_1 ((uint32_t)0x00000040) /* Bit 1 */
  1014. #define ADC_SQ14_2 ((uint32_t)0x00000080) /* Bit 2 */
  1015. #define ADC_SQ14_3 ((uint32_t)0x00000100) /* Bit 3 */
  1016. #define ADC_SQ14_4 ((uint32_t)0x00000200) /* Bit 4 */
  1017. #define ADC_SQ15 ((uint32_t)0x00007C00) /* SQ15[4:0] bits (15th conversion in regular sequence) */
  1018. #define ADC_SQ15_0 ((uint32_t)0x00000400) /* Bit 0 */
  1019. #define ADC_SQ15_1 ((uint32_t)0x00000800) /* Bit 1 */
  1020. #define ADC_SQ15_2 ((uint32_t)0x00001000) /* Bit 2 */
  1021. #define ADC_SQ15_3 ((uint32_t)0x00002000) /* Bit 3 */
  1022. #define ADC_SQ15_4 ((uint32_t)0x00004000) /* Bit 4 */
  1023. #define ADC_SQ16 ((uint32_t)0x000F8000) /* SQ16[4:0] bits (16th conversion in regular sequence) */
  1024. #define ADC_SQ16_0 ((uint32_t)0x00008000) /* Bit 0 */
  1025. #define ADC_SQ16_1 ((uint32_t)0x00010000) /* Bit 1 */
  1026. #define ADC_SQ16_2 ((uint32_t)0x00020000) /* Bit 2 */
  1027. #define ADC_SQ16_3 ((uint32_t)0x00040000) /* Bit 3 */
  1028. #define ADC_SQ16_4 ((uint32_t)0x00080000) /* Bit 4 */
  1029. #define ADC_L ((uint32_t)0x00F00000) /* L[3:0] bits (Regular channel sequence length) */
  1030. #define ADC_L_0 ((uint32_t)0x00100000) /* Bit 0 */
  1031. #define ADC_L_1 ((uint32_t)0x00200000) /* Bit 1 */
  1032. #define ADC_L_2 ((uint32_t)0x00400000) /* Bit 2 */
  1033. #define ADC_L_3 ((uint32_t)0x00800000) /* Bit 3 */
  1034. /******************* Bit definition for ADC_RSQR2 register *******************/
  1035. #define ADC_SQ7 ((uint32_t)0x0000001F) /* SQ7[4:0] bits (7th conversion in regular sequence) */
  1036. #define ADC_SQ7_0 ((uint32_t)0x00000001) /* Bit 0 */
  1037. #define ADC_SQ7_1 ((uint32_t)0x00000002) /* Bit 1 */
  1038. #define ADC_SQ7_2 ((uint32_t)0x00000004) /* Bit 2 */
  1039. #define ADC_SQ7_3 ((uint32_t)0x00000008) /* Bit 3 */
  1040. #define ADC_SQ7_4 ((uint32_t)0x00000010) /* Bit 4 */
  1041. #define ADC_SQ8 ((uint32_t)0x000003E0) /* SQ8[4:0] bits (8th conversion in regular sequence) */
  1042. #define ADC_SQ8_0 ((uint32_t)0x00000020) /* Bit 0 */
  1043. #define ADC_SQ8_1 ((uint32_t)0x00000040) /* Bit 1 */
  1044. #define ADC_SQ8_2 ((uint32_t)0x00000080) /* Bit 2 */
  1045. #define ADC_SQ8_3 ((uint32_t)0x00000100) /* Bit 3 */
  1046. #define ADC_SQ8_4 ((uint32_t)0x00000200) /* Bit 4 */
  1047. #define ADC_SQ9 ((uint32_t)0x00007C00) /* SQ9[4:0] bits (9th conversion in regular sequence) */
  1048. #define ADC_SQ9_0 ((uint32_t)0x00000400) /* Bit 0 */
  1049. #define ADC_SQ9_1 ((uint32_t)0x00000800) /* Bit 1 */
  1050. #define ADC_SQ9_2 ((uint32_t)0x00001000) /* Bit 2 */
  1051. #define ADC_SQ9_3 ((uint32_t)0x00002000) /* Bit 3 */
  1052. #define ADC_SQ9_4 ((uint32_t)0x00004000) /* Bit 4 */
  1053. #define ADC_SQ10 ((uint32_t)0x000F8000) /* SQ10[4:0] bits (10th conversion in regular sequence) */
  1054. #define ADC_SQ10_0 ((uint32_t)0x00008000) /* Bit 0 */
  1055. #define ADC_SQ10_1 ((uint32_t)0x00010000) /* Bit 1 */
  1056. #define ADC_SQ10_2 ((uint32_t)0x00020000) /* Bit 2 */
  1057. #define ADC_SQ10_3 ((uint32_t)0x00040000) /* Bit 3 */
  1058. #define ADC_SQ10_4 ((uint32_t)0x00080000) /* Bit 4 */
  1059. #define ADC_SQ11 ((uint32_t)0x01F00000) /* SQ11[4:0] bits (11th conversion in regular sequence) */
  1060. #define ADC_SQ11_0 ((uint32_t)0x00100000) /* Bit 0 */
  1061. #define ADC_SQ11_1 ((uint32_t)0x00200000) /* Bit 1 */
  1062. #define ADC_SQ11_2 ((uint32_t)0x00400000) /* Bit 2 */
  1063. #define ADC_SQ11_3 ((uint32_t)0x00800000) /* Bit 3 */
  1064. #define ADC_SQ11_4 ((uint32_t)0x01000000) /* Bit 4 */
  1065. #define ADC_SQ12 ((uint32_t)0x3E000000) /* SQ12[4:0] bits (12th conversion in regular sequence) */
  1066. #define ADC_SQ12_0 ((uint32_t)0x02000000) /* Bit 0 */
  1067. #define ADC_SQ12_1 ((uint32_t)0x04000000) /* Bit 1 */
  1068. #define ADC_SQ12_2 ((uint32_t)0x08000000) /* Bit 2 */
  1069. #define ADC_SQ12_3 ((uint32_t)0x10000000) /* Bit 3 */
  1070. #define ADC_SQ12_4 ((uint32_t)0x20000000) /* Bit 4 */
  1071. /******************* Bit definition for ADC_RSQR3 register *******************/
  1072. #define ADC_SQ1 ((uint32_t)0x0000001F) /* SQ1[4:0] bits (1st conversion in regular sequence) */
  1073. #define ADC_SQ1_0 ((uint32_t)0x00000001) /* Bit 0 */
  1074. #define ADC_SQ1_1 ((uint32_t)0x00000002) /* Bit 1 */
  1075. #define ADC_SQ1_2 ((uint32_t)0x00000004) /* Bit 2 */
  1076. #define ADC_SQ1_3 ((uint32_t)0x00000008) /* Bit 3 */
  1077. #define ADC_SQ1_4 ((uint32_t)0x00000010) /* Bit 4 */
  1078. #define ADC_SQ2 ((uint32_t)0x000003E0) /* SQ2[4:0] bits (2nd conversion in regular sequence) */
  1079. #define ADC_SQ2_0 ((uint32_t)0x00000020) /* Bit 0 */
  1080. #define ADC_SQ2_1 ((uint32_t)0x00000040) /* Bit 1 */
  1081. #define ADC_SQ2_2 ((uint32_t)0x00000080) /* Bit 2 */
  1082. #define ADC_SQ2_3 ((uint32_t)0x00000100) /* Bit 3 */
  1083. #define ADC_SQ2_4 ((uint32_t)0x00000200) /* Bit 4 */
  1084. #define ADC_SQ3 ((uint32_t)0x00007C00) /* SQ3[4:0] bits (3rd conversion in regular sequence) */
  1085. #define ADC_SQ3_0 ((uint32_t)0x00000400) /* Bit 0 */
  1086. #define ADC_SQ3_1 ((uint32_t)0x00000800) /* Bit 1 */
  1087. #define ADC_SQ3_2 ((uint32_t)0x00001000) /* Bit 2 */
  1088. #define ADC_SQ3_3 ((uint32_t)0x00002000) /* Bit 3 */
  1089. #define ADC_SQ3_4 ((uint32_t)0x00004000) /* Bit 4 */
  1090. #define ADC_SQ4 ((uint32_t)0x000F8000) /* SQ4[4:0] bits (4th conversion in regular sequence) */
  1091. #define ADC_SQ4_0 ((uint32_t)0x00008000) /* Bit 0 */
  1092. #define ADC_SQ4_1 ((uint32_t)0x00010000) /* Bit 1 */
  1093. #define ADC_SQ4_2 ((uint32_t)0x00020000) /* Bit 2 */
  1094. #define ADC_SQ4_3 ((uint32_t)0x00040000) /* Bit 3 */
  1095. #define ADC_SQ4_4 ((uint32_t)0x00080000) /* Bit 4 */
  1096. #define ADC_SQ5 ((uint32_t)0x01F00000) /* SQ5[4:0] bits (5th conversion in regular sequence) */
  1097. #define ADC_SQ5_0 ((uint32_t)0x00100000) /* Bit 0 */
  1098. #define ADC_SQ5_1 ((uint32_t)0x00200000) /* Bit 1 */
  1099. #define ADC_SQ5_2 ((uint32_t)0x00400000) /* Bit 2 */
  1100. #define ADC_SQ5_3 ((uint32_t)0x00800000) /* Bit 3 */
  1101. #define ADC_SQ5_4 ((uint32_t)0x01000000) /* Bit 4 */
  1102. #define ADC_SQ6 ((uint32_t)0x3E000000) /* SQ6[4:0] bits (6th conversion in regular sequence) */
  1103. #define ADC_SQ6_0 ((uint32_t)0x02000000) /* Bit 0 */
  1104. #define ADC_SQ6_1 ((uint32_t)0x04000000) /* Bit 1 */
  1105. #define ADC_SQ6_2 ((uint32_t)0x08000000) /* Bit 2 */
  1106. #define ADC_SQ6_3 ((uint32_t)0x10000000) /* Bit 3 */
  1107. #define ADC_SQ6_4 ((uint32_t)0x20000000) /* Bit 4 */
  1108. /******************* Bit definition for ADC_ISQR register *******************/
  1109. #define ADC_JSQ1 ((uint32_t)0x0000001F) /* JSQ1[4:0] bits (1st conversion in injected sequence) */
  1110. #define ADC_JSQ1_0 ((uint32_t)0x00000001) /* Bit 0 */
  1111. #define ADC_JSQ1_1 ((uint32_t)0x00000002) /* Bit 1 */
  1112. #define ADC_JSQ1_2 ((uint32_t)0x00000004) /* Bit 2 */
  1113. #define ADC_JSQ1_3 ((uint32_t)0x00000008) /* Bit 3 */
  1114. #define ADC_JSQ1_4 ((uint32_t)0x00000010) /* Bit 4 */
  1115. #define ADC_JSQ2 ((uint32_t)0x000003E0) /* JSQ2[4:0] bits (2nd conversion in injected sequence) */
  1116. #define ADC_JSQ2_0 ((uint32_t)0x00000020) /* Bit 0 */
  1117. #define ADC_JSQ2_1 ((uint32_t)0x00000040) /* Bit 1 */
  1118. #define ADC_JSQ2_2 ((uint32_t)0x00000080) /* Bit 2 */
  1119. #define ADC_JSQ2_3 ((uint32_t)0x00000100) /* Bit 3 */
  1120. #define ADC_JSQ2_4 ((uint32_t)0x00000200) /* Bit 4 */
  1121. #define ADC_JSQ3 ((uint32_t)0x00007C00) /* JSQ3[4:0] bits (3rd conversion in injected sequence) */
  1122. #define ADC_JSQ3_0 ((uint32_t)0x00000400) /* Bit 0 */
  1123. #define ADC_JSQ3_1 ((uint32_t)0x00000800) /* Bit 1 */
  1124. #define ADC_JSQ3_2 ((uint32_t)0x00001000) /* Bit 2 */
  1125. #define ADC_JSQ3_3 ((uint32_t)0x00002000) /* Bit 3 */
  1126. #define ADC_JSQ3_4 ((uint32_t)0x00004000) /* Bit 4 */
  1127. #define ADC_JSQ4 ((uint32_t)0x000F8000) /* JSQ4[4:0] bits (4th conversion in injected sequence) */
  1128. #define ADC_JSQ4_0 ((uint32_t)0x00008000) /* Bit 0 */
  1129. #define ADC_JSQ4_1 ((uint32_t)0x00010000) /* Bit 1 */
  1130. #define ADC_JSQ4_2 ((uint32_t)0x00020000) /* Bit 2 */
  1131. #define ADC_JSQ4_3 ((uint32_t)0x00040000) /* Bit 3 */
  1132. #define ADC_JSQ4_4 ((uint32_t)0x00080000) /* Bit 4 */
  1133. #define ADC_JL ((uint32_t)0x00300000) /* JL[1:0] bits (Injected Sequence length) */
  1134. #define ADC_JL_0 ((uint32_t)0x00100000) /* Bit 0 */
  1135. #define ADC_JL_1 ((uint32_t)0x00200000) /* Bit 1 */
  1136. /******************* Bit definition for ADC_IDATAR1 register *******************/
  1137. #define ADC_IDATAR1_JDATA ((uint16_t)0xFFFF) /* Injected data */
  1138. /******************* Bit definition for ADC_IDATAR2 register *******************/
  1139. #define ADC_IDATAR2_JDATA ((uint16_t)0xFFFF) /* Injected data */
  1140. /******************* Bit definition for ADC_IDATAR3 register *******************/
  1141. #define ADC_IDATAR3_JDATA ((uint16_t)0xFFFF) /* Injected data */
  1142. /******************* Bit definition for ADC_IDATAR4 register *******************/
  1143. #define ADC_IDATAR4_JDATA ((uint16_t)0xFFFF) /* Injected data */
  1144. /******************** Bit definition for ADC_RDATAR register ********************/
  1145. #define ADC_RDATAR_DATA ((uint32_t)0x0000FFFF) /* Regular data */
  1146. #define ADC_RDATAR_ADC2DATA ((uint32_t)0xFFFF0000) /* ADC2 data */
  1147. /******************************************************************************/
  1148. /* Backup registers */
  1149. /******************************************************************************/
  1150. /******************* Bit definition for BKP_DATAR1 register ********************/
  1151. #define BKP_DATAR1_D ((uint16_t)0xFFFF) /* Backup data */
  1152. /******************* Bit definition for BKP_DATAR2 register ********************/
  1153. #define BKP_DATAR2_D ((uint16_t)0xFFFF) /* Backup data */
  1154. /******************* Bit definition for BKP_DATAR3 register ********************/
  1155. #define BKP_DATAR3_D ((uint16_t)0xFFFF) /* Backup data */
  1156. /******************* Bit definition for BKP_DATAR4 register ********************/
  1157. #define BKP_DATAR4_D ((uint16_t)0xFFFF) /* Backup data */
  1158. /******************* Bit definition for BKP_DATAR5 register ********************/
  1159. #define BKP_DATAR5_D ((uint16_t)0xFFFF) /* Backup data */
  1160. /******************* Bit definition for BKP_DATAR6 register ********************/
  1161. #define BKP_DATAR6_D ((uint16_t)0xFFFF) /* Backup data */
  1162. /******************* Bit definition for BKP_DATAR7 register ********************/
  1163. #define BKP_DATAR7_D ((uint16_t)0xFFFF) /* Backup data */
  1164. /******************* Bit definition for BKP_DATAR8 register ********************/
  1165. #define BKP_DATAR8_D ((uint16_t)0xFFFF) /* Backup data */
  1166. /******************* Bit definition for BKP_DATAR9 register ********************/
  1167. #define BKP_DATAR9_D ((uint16_t)0xFFFF) /* Backup data */
  1168. /******************* Bit definition for BKP_DATAR10 register *******************/
  1169. #define BKP_DATAR10_D ((uint16_t)0xFFFF) /* Backup data */
  1170. /******************* Bit definition for BKP_DATAR11 register *******************/
  1171. #define BKP_DATAR11_D ((uint16_t)0xFFFF) /* Backup data */
  1172. /******************* Bit definition for BKP_DATAR12 register *******************/
  1173. #define BKP_DATAR12_D ((uint16_t)0xFFFF) /* Backup data */
  1174. /******************* Bit definition for BKP_DATAR13 register *******************/
  1175. #define BKP_DATAR13_D ((uint16_t)0xFFFF) /* Backup data */
  1176. /******************* Bit definition for BKP_DATAR14 register *******************/
  1177. #define BKP_DATAR14_D ((uint16_t)0xFFFF) /* Backup data */
  1178. /******************* Bit definition for BKP_DATAR15 register *******************/
  1179. #define BKP_DATAR15_D ((uint16_t)0xFFFF) /* Backup data */
  1180. /******************* Bit definition for BKP_DATAR16 register *******************/
  1181. #define BKP_DATAR16_D ((uint16_t)0xFFFF) /* Backup data */
  1182. /******************* Bit definition for BKP_DATAR17 register *******************/
  1183. #define BKP_DATAR17_D ((uint16_t)0xFFFF) /* Backup data */
  1184. /****************** Bit definition for BKP_DATAR18 register ********************/
  1185. #define BKP_DATAR18_D ((uint16_t)0xFFFF) /* Backup data */
  1186. /******************* Bit definition for BKP_DATAR19 register *******************/
  1187. #define BKP_DATAR19_D ((uint16_t)0xFFFF) /* Backup data */
  1188. /******************* Bit definition for BKP_DATAR20 register *******************/
  1189. #define BKP_DATAR20_D ((uint16_t)0xFFFF) /* Backup data */
  1190. /******************* Bit definition for BKP_DATAR21 register *******************/
  1191. #define BKP_DATAR21_D ((uint16_t)0xFFFF) /* Backup data */
  1192. /******************* Bit definition for BKP_DATAR22 register *******************/
  1193. #define BKP_DATAR22_D ((uint16_t)0xFFFF) /* Backup data */
  1194. /******************* Bit definition for BKP_DATAR23 register *******************/
  1195. #define BKP_DATAR23_D ((uint16_t)0xFFFF) /* Backup data */
  1196. /******************* Bit definition for BKP_DATAR24 register *******************/
  1197. #define BKP_DATAR24_D ((uint16_t)0xFFFF) /* Backup data */
  1198. /******************* Bit definition for BKP_DATAR25 register *******************/
  1199. #define BKP_DATAR25_D ((uint16_t)0xFFFF) /* Backup data */
  1200. /******************* Bit definition for BKP_DATAR26 register *******************/
  1201. #define BKP_DATAR26_D ((uint16_t)0xFFFF) /* Backup data */
  1202. /******************* Bit definition for BKP_DATAR27 register *******************/
  1203. #define BKP_DATAR27_D ((uint16_t)0xFFFF) /* Backup data */
  1204. /******************* Bit definition for BKP_DATAR28 register *******************/
  1205. #define BKP_DATAR28_D ((uint16_t)0xFFFF) /* Backup data */
  1206. /******************* Bit definition for BKP_DATAR29 register *******************/
  1207. #define BKP_DATAR29_D ((uint16_t)0xFFFF) /* Backup data */
  1208. /******************* Bit definition for BKP_DATAR30 register *******************/
  1209. #define BKP_DATAR30_D ((uint16_t)0xFFFF) /* Backup data */
  1210. /******************* Bit definition for BKP_DATAR31 register *******************/
  1211. #define BKP_DATAR31_D ((uint16_t)0xFFFF) /* Backup data */
  1212. /******************* Bit definition for BKP_DATAR32 register *******************/
  1213. #define BKP_DATAR32_D ((uint16_t)0xFFFF) /* Backup data */
  1214. /******************* Bit definition for BKP_DATAR33 register *******************/
  1215. #define BKP_DATAR33_D ((uint16_t)0xFFFF) /* Backup data */
  1216. /******************* Bit definition for BKP_DATAR34 register *******************/
  1217. #define BKP_DATAR34_D ((uint16_t)0xFFFF) /* Backup data */
  1218. /******************* Bit definition for BKP_DATAR35 register *******************/
  1219. #define BKP_DATAR35_D ((uint16_t)0xFFFF) /* Backup data */
  1220. /******************* Bit definition for BKP_DATAR36 register *******************/
  1221. #define BKP_DATAR36_D ((uint16_t)0xFFFF) /* Backup data */
  1222. /******************* Bit definition for BKP_DATAR37 register *******************/
  1223. #define BKP_DATAR37_D ((uint16_t)0xFFFF) /* Backup data */
  1224. /******************* Bit definition for BKP_DATAR38 register *******************/
  1225. #define BKP_DATAR38_D ((uint16_t)0xFFFF) /* Backup data */
  1226. /******************* Bit definition for BKP_DATAR39 register *******************/
  1227. #define BKP_DATAR39_D ((uint16_t)0xFFFF) /* Backup data */
  1228. /******************* Bit definition for BKP_DATAR40 register *******************/
  1229. #define BKP_DATAR40_D ((uint16_t)0xFFFF) /* Backup data */
  1230. /******************* Bit definition for BKP_DATAR41 register *******************/
  1231. #define BKP_DATAR41_D ((uint16_t)0xFFFF) /* Backup data */
  1232. /******************* Bit definition for BKP_DATAR42 register *******************/
  1233. #define BKP_DATAR42_D ((uint16_t)0xFFFF) /* Backup data */
  1234. /****************** Bit definition for BKP_OCTLR register *******************/
  1235. #define BKP_CAL ((uint16_t)0x007F) /* Calibration value */
  1236. #define BKP_CCO ((uint16_t)0x0080) /* Calibration Clock Output */
  1237. #define BKP_ASOE ((uint16_t)0x0100) /* Alarm or Second Output Enable */
  1238. #define BKP_ASOS ((uint16_t)0x0200) /* Alarm or Second Output Selection */
  1239. /******************** Bit definition for BKP_TPCTLR register ********************/
  1240. #define BKP_TPE ((uint8_t)0x01) /* TAMPER pin enable */
  1241. #define BKP_TPAL ((uint8_t)0x02) /* TAMPER pin active level */
  1242. /******************* Bit definition for BKP_TPCSR register ********************/
  1243. #define BKP_CTE ((uint16_t)0x0001) /* Clear Tamper event */
  1244. #define BKP_CTI ((uint16_t)0x0002) /* Clear Tamper Interrupt */
  1245. #define BKP_TPIE ((uint16_t)0x0004) /* TAMPER Pin interrupt enable */
  1246. #define BKP_TEF ((uint16_t)0x0100) /* Tamper Event Flag */
  1247. #define BKP_TIF ((uint16_t)0x0200) /* Tamper Interrupt Flag */
  1248. /******************************************************************************/
  1249. /* Controller Area Network */
  1250. /******************************************************************************/
  1251. /******************* Bit definition for CAN_CTLR register ********************/
  1252. #define CAN_CTLR_INRQ ((uint16_t)0x0001) /* Initialization Request */
  1253. #define CAN_CTLR_SLEEP ((uint16_t)0x0002) /* Sleep Mode Request */
  1254. #define CAN_CTLR_TXFP ((uint16_t)0x0004) /* Transmit FIFO Priority */
  1255. #define CAN_CTLR_RFLM ((uint16_t)0x0008) /* Receive FIFO Locked Mode */
  1256. #define CAN_CTLR_NART ((uint16_t)0x0010) /* No Automatic Retransmission */
  1257. #define CAN_CTLR_AWUM ((uint16_t)0x0020) /* Automatic Wakeup Mode */
  1258. #define CAN_CTLR_ABOM ((uint16_t)0x0040) /* Automatic Bus-Off Management */
  1259. #define CAN_CTLR_TTCM ((uint16_t)0x0080) /* Time Triggered Communication Mode */
  1260. #define CAN_CTLR_RESET ((uint16_t)0x8000) /* CAN software master reset */
  1261. /******************* Bit definition for CAN_STATR register ********************/
  1262. #define CAN_STATR_INAK ((uint16_t)0x0001) /* Initialization Acknowledge */
  1263. #define CAN_STATR_SLAK ((uint16_t)0x0002) /* Sleep Acknowledge */
  1264. #define CAN_STATR_ERRI ((uint16_t)0x0004) /* Error Interrupt */
  1265. #define CAN_STATR_WKUI ((uint16_t)0x0008) /* Wakeup Interrupt */
  1266. #define CAN_STATR_SLAKI ((uint16_t)0x0010) /* Sleep Acknowledge Interrupt */
  1267. #define CAN_STATR_TXM ((uint16_t)0x0100) /* Transmit Mode */
  1268. #define CAN_STATR_RXM ((uint16_t)0x0200) /* Receive Mode */
  1269. #define CAN_STATR_SAMP ((uint16_t)0x0400) /* Last Sample Point */
  1270. #define CAN_STATR_RX ((uint16_t)0x0800) /* CAN Rx Signal */
  1271. /******************* Bit definition for CAN_TSTATR register ********************/
  1272. #define CAN_TSTATR_RQCP0 ((uint32_t)0x00000001) /* Request Completed Mailbox0 */
  1273. #define CAN_TSTATR_TXOK0 ((uint32_t)0x00000002) /* Transmission OK of Mailbox0 */
  1274. #define CAN_TSTATR_ALST0 ((uint32_t)0x00000004) /* Arbitration Lost for Mailbox0 */
  1275. #define CAN_TSTATR_TERR0 ((uint32_t)0x00000008) /* Transmission Error of Mailbox0 */
  1276. #define CAN_TSTATR_ABRQ0 ((uint32_t)0x00000080) /* Abort Request for Mailbox0 */
  1277. #define CAN_TSTATR_RQCP1 ((uint32_t)0x00000100) /* Request Completed Mailbox1 */
  1278. #define CAN_TSTATR_TXOK1 ((uint32_t)0x00000200) /* Transmission OK of Mailbox1 */
  1279. #define CAN_TSTATR_ALST1 ((uint32_t)0x00000400) /* Arbitration Lost for Mailbox1 */
  1280. #define CAN_TSTATR_TERR1 ((uint32_t)0x00000800) /* Transmission Error of Mailbox1 */
  1281. #define CAN_TSTATR_ABRQ1 ((uint32_t)0x00008000) /* Abort Request for Mailbox 1 */
  1282. #define CAN_TSTATR_RQCP2 ((uint32_t)0x00010000) /* Request Completed Mailbox2 */
  1283. #define CAN_TSTATR_TXOK2 ((uint32_t)0x00020000) /* Transmission OK of Mailbox 2 */
  1284. #define CAN_TSTATR_ALST2 ((uint32_t)0x00040000) /* Arbitration Lost for mailbox 2 */
  1285. #define CAN_TSTATR_TERR2 ((uint32_t)0x00080000) /* Transmission Error of Mailbox 2 */
  1286. #define CAN_TSTATR_ABRQ2 ((uint32_t)0x00800000) /* Abort Request for Mailbox 2 */
  1287. #define CAN_TSTATR_CODE ((uint32_t)0x03000000) /* Mailbox Code */
  1288. #define CAN_TSTATR_TME ((uint32_t)0x1C000000) /* TME[2:0] bits */
  1289. #define CAN_TSTATR_TME0 ((uint32_t)0x04000000) /* Transmit Mailbox 0 Empty */
  1290. #define CAN_TSTATR_TME1 ((uint32_t)0x08000000) /* Transmit Mailbox 1 Empty */
  1291. #define CAN_TSTATR_TME2 ((uint32_t)0x10000000) /* Transmit Mailbox 2 Empty */
  1292. #define CAN_TSTATR_LOW ((uint32_t)0xE0000000) /* LOW[2:0] bits */
  1293. #define CAN_TSTATR_LOW0 ((uint32_t)0x20000000) /* Lowest Priority Flag for Mailbox 0 */
  1294. #define CAN_TSTATR_LOW1 ((uint32_t)0x40000000) /* Lowest Priority Flag for Mailbox 1 */
  1295. #define CAN_TSTATR_LOW2 ((uint32_t)0x80000000) /* Lowest Priority Flag for Mailbox 2 */
  1296. /******************* Bit definition for CAN_RFIFO0 register *******************/
  1297. #define CAN_RFIFO0_FMP0 ((uint8_t)0x03) /* FIFO 0 Message Pending */
  1298. #define CAN_RFIFO0_FULL0 ((uint8_t)0x08) /* FIFO 0 Full */
  1299. #define CAN_RFIFO0_FOVR0 ((uint8_t)0x10) /* FIFO 0 Overrun */
  1300. #define CAN_RFIFO0_RFOM0 ((uint8_t)0x20) /* Release FIFO 0 Output Mailbox */
  1301. /******************* Bit definition for CAN_RFIFO1 register *******************/
  1302. #define CAN_RFIFO1_FMP1 ((uint8_t)0x03) /* FIFO 1 Message Pending */
  1303. #define CAN_RFIFO1_FULL1 ((uint8_t)0x08) /* FIFO 1 Full */
  1304. #define CAN_RFIFO1_FOVR1 ((uint8_t)0x10) /* FIFO 1 Overrun */
  1305. #define CAN_RFIFO1_RFOM1 ((uint8_t)0x20) /* Release FIFO 1 Output Mailbox */
  1306. /******************** Bit definition for CAN_INTENR register *******************/
  1307. #define CAN_INTENR_TMEIE ((uint32_t)0x00000001) /* Transmit Mailbox Empty Interrupt Enable */
  1308. #define CAN_INTENR_FMPIE0 ((uint32_t)0x00000002) /* FIFO Message Pending Interrupt Enable */
  1309. #define CAN_INTENR_FFIE0 ((uint32_t)0x00000004) /* FIFO Full Interrupt Enable */
  1310. #define CAN_INTENR_FOVIE0 ((uint32_t)0x00000008) /* FIFO Overrun Interrupt Enable */
  1311. #define CAN_INTENR_FMPIE1 ((uint32_t)0x00000010) /* FIFO Message Pending Interrupt Enable */
  1312. #define CAN_INTENR_FFIE1 ((uint32_t)0x00000020) /* FIFO Full Interrupt Enable */
  1313. #define CAN_INTENR_FOVIE1 ((uint32_t)0x00000040) /* FIFO Overrun Interrupt Enable */
  1314. #define CAN_INTENR_EWGIE ((uint32_t)0x00000100) /* Error Warning Interrupt Enable */
  1315. #define CAN_INTENR_EPVIE ((uint32_t)0x00000200) /* Error Passive Interrupt Enable */
  1316. #define CAN_INTENR_BOFIE ((uint32_t)0x00000400) /* Bus-Off Interrupt Enable */
  1317. #define CAN_INTENR_LECIE ((uint32_t)0x00000800) /* Last Error Code Interrupt Enable */
  1318. #define CAN_INTENR_ERRIE ((uint32_t)0x00008000) /* Error Interrupt Enable */
  1319. #define CAN_INTENR_WKUIE ((uint32_t)0x00010000) /* Wakeup Interrupt Enable */
  1320. #define CAN_INTENR_SLKIE ((uint32_t)0x00020000) /* Sleep Interrupt Enable */
  1321. /******************** Bit definition for CAN_ERRSR register *******************/
  1322. #define CAN_ERRSR_EWGF ((uint32_t)0x00000001) /* Error Warning Flag */
  1323. #define CAN_ERRSR_EPVF ((uint32_t)0x00000002) /* Error Passive Flag */
  1324. #define CAN_ERRSR_BOFF ((uint32_t)0x00000004) /* Bus-Off Flag */
  1325. #define CAN_ERRSR_LEC ((uint32_t)0x00000070) /* LEC[2:0] bits (Last Error Code) */
  1326. #define CAN_ERRSR_LEC_0 ((uint32_t)0x00000010) /* Bit 0 */
  1327. #define CAN_ERRSR_LEC_1 ((uint32_t)0x00000020) /* Bit 1 */
  1328. #define CAN_ERRSR_LEC_2 ((uint32_t)0x00000040) /* Bit 2 */
  1329. #define CAN_ERRSR_TEC ((uint32_t)0x00FF0000) /* Least significant byte of the 9-bit Transmit Error Counter */
  1330. #define CAN_ERRSR_REC ((uint32_t)0xFF000000) /* Receive Error Counter */
  1331. /******************* Bit definition for CAN_BTIMR register ********************/
  1332. #define CAN_BTIMR_BRP ((uint32_t)0x000003FF) /* Baud Rate Prescaler */
  1333. #define CAN_BTIMR_TS1 ((uint32_t)0x000F0000) /* Time Segment 1 */
  1334. #define CAN_BTIMR_TS2 ((uint32_t)0x00700000) /* Time Segment 2 */
  1335. #define CAN_BTIMR_SJW ((uint32_t)0x03000000) /* Resynchronization Jump Width */
  1336. #define CAN_BTIMR_LBKM ((uint32_t)0x40000000) /* Loop Back Mode (Debug) */
  1337. #define CAN_BTIMR_SILM ((uint32_t)0x80000000) /* Silent Mode */
  1338. /****************** Bit definition for CAN_TXMI0R register ********************/
  1339. #define CAN_TXMI0R_TXRQ ((uint32_t)0x00000001) /* Transmit Mailbox Request */
  1340. #define CAN_TXMI0R_RTR ((uint32_t)0x00000002) /* Remote Transmission Request */
  1341. #define CAN_TXMI0R_IDE ((uint32_t)0x00000004) /* Identifier Extension */
  1342. #define CAN_TXMI0R_EXID ((uint32_t)0x001FFFF8) /* Extended Identifier */
  1343. #define CAN_TXMI0R_STID ((uint32_t)0xFFE00000) /* Standard Identifier or Extended Identifier */
  1344. /****************** Bit definition for CAN_TXMDT0R register *******************/
  1345. #define CAN_TXMDT0R_DLC ((uint32_t)0x0000000F) /* Data Length Code */
  1346. #define CAN_TXMDT0R_TGT ((uint32_t)0x00000100) /* Transmit Global Time */
  1347. #define CAN_TXMDT0R_TIME ((uint32_t)0xFFFF0000) /* Message Time Stamp */
  1348. /****************** Bit definition for CAN_TXMDL0R register *******************/
  1349. #define CAN_TXMDL0R_DATA0 ((uint32_t)0x000000FF) /* Data byte 0 */
  1350. #define CAN_TXMDL0R_DATA1 ((uint32_t)0x0000FF00) /* Data byte 1 */
  1351. #define CAN_TXMDL0R_DATA2 ((uint32_t)0x00FF0000) /* Data byte 2 */
  1352. #define CAN_TXMDL0R_DATA3 ((uint32_t)0xFF000000) /* Data byte 3 */
  1353. /****************** Bit definition for CAN_TXMDH0R register *******************/
  1354. #define CAN_TXMDH0R_DATA4 ((uint32_t)0x000000FF) /* Data byte 4 */
  1355. #define CAN_TXMDH0R_DATA5 ((uint32_t)0x0000FF00) /* Data byte 5 */
  1356. #define CAN_TXMDH0R_DATA6 ((uint32_t)0x00FF0000) /* Data byte 6 */
  1357. #define CAN_TXMDH0R_DATA7 ((uint32_t)0xFF000000) /* Data byte 7 */
  1358. /******************* Bit definition for CAN_TXMI1R register *******************/
  1359. #define CAN_TXMI1R_TXRQ ((uint32_t)0x00000001) /* Transmit Mailbox Request */
  1360. #define CAN_TXMI1R_RTR ((uint32_t)0x00000002) /* Remote Transmission Request */
  1361. #define CAN_TXMI1R_IDE ((uint32_t)0x00000004) /* Identifier Extension */
  1362. #define CAN_TXMI1R_EXID ((uint32_t)0x001FFFF8) /* Extended Identifier */
  1363. #define CAN_TXMI1R_STID ((uint32_t)0xFFE00000) /* Standard Identifier or Extended Identifier */
  1364. /******************* Bit definition for CAN_TXMDT1R register ******************/
  1365. #define CAN_TXMDT1R_DLC ((uint32_t)0x0000000F) /* Data Length Code */
  1366. #define CAN_TXMDT1R_TGT ((uint32_t)0x00000100) /* Transmit Global Time */
  1367. #define CAN_TXMDT1R_TIME ((uint32_t)0xFFFF0000) /* Message Time Stamp */
  1368. /******************* Bit definition for CAN_TXMDL1R register ******************/
  1369. #define CAN_TXMDL1R_DATA0 ((uint32_t)0x000000FF) /* Data byte 0 */
  1370. #define CAN_TXMDL1R_DATA1 ((uint32_t)0x0000FF00) /* Data byte 1 */
  1371. #define CAN_TXMDL1R_DATA2 ((uint32_t)0x00FF0000) /* Data byte 2 */
  1372. #define CAN_TXMDL1R_DATA3 ((uint32_t)0xFF000000) /* Data byte 3 */
  1373. /******************* Bit definition for CAN_TXMDH1R register ******************/
  1374. #define CAN_TXMDH1R_DATA4 ((uint32_t)0x000000FF) /* Data byte 4 */
  1375. #define CAN_TXMDH1R_DATA5 ((uint32_t)0x0000FF00) /* Data byte 5 */
  1376. #define CAN_TXMDH1R_DATA6 ((uint32_t)0x00FF0000) /* Data byte 6 */
  1377. #define CAN_TXMDH1R_DATA7 ((uint32_t)0xFF000000) /* Data byte 7 */
  1378. /******************* Bit definition for CAN_TXMI2R register *******************/
  1379. #define CAN_TXMI2R_TXRQ ((uint32_t)0x00000001) /* Transmit Mailbox Request */
  1380. #define CAN_TXMI2R_RTR ((uint32_t)0x00000002) /* Remote Transmission Request */
  1381. #define CAN_TXMI2R_IDE ((uint32_t)0x00000004) /* Identifier Extension */
  1382. #define CAN_TXMI2R_EXID ((uint32_t)0x001FFFF8) /* Extended identifier */
  1383. #define CAN_TXMI2R_STID ((uint32_t)0xFFE00000) /* Standard Identifier or Extended Identifier */
  1384. /******************* Bit definition for CAN_TXMDT2R register ******************/
  1385. #define CAN_TXMDT2R_DLC ((uint32_t)0x0000000F) /* Data Length Code */
  1386. #define CAN_TXMDT2R_TGT ((uint32_t)0x00000100) /* Transmit Global Time */
  1387. #define CAN_TXMDT2R_TIME ((uint32_t)0xFFFF0000) /* Message Time Stamp */
  1388. /******************* Bit definition for CAN_TXMDL2R register ******************/
  1389. #define CAN_TXMDL2R_DATA0 ((uint32_t)0x000000FF) /* Data byte 0 */
  1390. #define CAN_TXMDL2R_DATA1 ((uint32_t)0x0000FF00) /* Data byte 1 */
  1391. #define CAN_TXMDL2R_DATA2 ((uint32_t)0x00FF0000) /* Data byte 2 */
  1392. #define CAN_TXMDL2R_DATA3 ((uint32_t)0xFF000000) /* Data byte 3 */
  1393. /******************* Bit definition for CAN_TXMDH2R register ******************/
  1394. #define CAN_TXMDH2R_DATA4 ((uint32_t)0x000000FF) /* Data byte 4 */
  1395. #define CAN_TXMDH2R_DATA5 ((uint32_t)0x0000FF00) /* Data byte 5 */
  1396. #define CAN_TXMDH2R_DATA6 ((uint32_t)0x00FF0000) /* Data byte 6 */
  1397. #define CAN_TXMDH2R_DATA7 ((uint32_t)0xFF000000) /* Data byte 7 */
  1398. /******************* Bit definition for CAN_RXMI0R register *******************/
  1399. #define CAN_RXMI0R_RTR ((uint32_t)0x00000002) /* Remote Transmission Request */
  1400. #define CAN_RXMI0R_IDE ((uint32_t)0x00000004) /* Identifier Extension */
  1401. #define CAN_RXMI0R_EXID ((uint32_t)0x001FFFF8) /* Extended Identifier */
  1402. #define CAN_RXMI0R_STID ((uint32_t)0xFFE00000) /* Standard Identifier or Extended Identifier */
  1403. /******************* Bit definition for CAN_RXMDT0R register ******************/
  1404. #define CAN_RXMDT0R_DLC ((uint32_t)0x0000000F) /* Data Length Code */
  1405. #define CAN_RXMDT0R_FMI ((uint32_t)0x0000FF00) /* Filter Match Index */
  1406. #define CAN_RXMDT0R_TIME ((uint32_t)0xFFFF0000) /* Message Time Stamp */
  1407. /******************* Bit definition for CAN_RXMDL0R register ******************/
  1408. #define CAN_RXMDL0R_DATA0 ((uint32_t)0x000000FF) /* Data byte 0 */
  1409. #define CAN_RXMDL0R_DATA1 ((uint32_t)0x0000FF00) /* Data byte 1 */
  1410. #define CAN_RXMDL0R_DATA2 ((uint32_t)0x00FF0000) /* Data byte 2 */
  1411. #define CAN_RXMDL0R_DATA3 ((uint32_t)0xFF000000) /* Data byte 3 */
  1412. /******************* Bit definition for CAN_RXMDH0R register ******************/
  1413. #define CAN_RXMDH0R_DATA4 ((uint32_t)0x000000FF) /* Data byte 4 */
  1414. #define CAN_RXMDH0R_DATA5 ((uint32_t)0x0000FF00) /* Data byte 5 */
  1415. #define CAN_RXMDH0R_DATA6 ((uint32_t)0x00FF0000) /* Data byte 6 */
  1416. #define CAN_RXMDH0R_DATA7 ((uint32_t)0xFF000000) /* Data byte 7 */
  1417. /******************* Bit definition for CAN_RXMI1R register *******************/
  1418. #define CAN_RXMI1R_RTR ((uint32_t)0x00000002) /* Remote Transmission Request */
  1419. #define CAN_RXMI1R_IDE ((uint32_t)0x00000004) /* Identifier Extension */
  1420. #define CAN_RXMI1R_EXID ((uint32_t)0x001FFFF8) /* Extended identifier */
  1421. #define CAN_RXMI1R_STID ((uint32_t)0xFFE00000) /* Standard Identifier or Extended Identifier */
  1422. /******************* Bit definition for CAN_RXMDT1R register ******************/
  1423. #define CAN_RXMDT1R_DLC ((uint32_t)0x0000000F) /* Data Length Code */
  1424. #define CAN_RXMDT1R_FMI ((uint32_t)0x0000FF00) /* Filter Match Index */
  1425. #define CAN_RXMDT1R_TIME ((uint32_t)0xFFFF0000) /* Message Time Stamp */
  1426. /******************* Bit definition for CAN_RXMDL1R register ******************/
  1427. #define CAN_RXMDL1R_DATA0 ((uint32_t)0x000000FF) /* Data byte 0 */
  1428. #define CAN_RXMDL1R_DATA1 ((uint32_t)0x0000FF00) /* Data byte 1 */
  1429. #define CAN_RXMDL1R_DATA2 ((uint32_t)0x00FF0000) /* Data byte 2 */
  1430. #define CAN_RXMDL1R_DATA3 ((uint32_t)0xFF000000) /* Data byte 3 */
  1431. /******************* Bit definition for CAN_RXMDH1R register ******************/
  1432. #define CAN_RXMDH1R_DATA4 ((uint32_t)0x000000FF) /* Data byte 4 */
  1433. #define CAN_RXMDH1R_DATA5 ((uint32_t)0x0000FF00) /* Data byte 5 */
  1434. #define CAN_RXMDH1R_DATA6 ((uint32_t)0x00FF0000) /* Data byte 6 */
  1435. #define CAN_RXMDH1R_DATA7 ((uint32_t)0xFF000000) /* Data byte 7 */
  1436. /******************* Bit definition for CAN_FCTLR register ********************/
  1437. #define CAN_FCTLR_FINIT ((uint8_t)0x01) /* Filter Init Mode */
  1438. /******************* Bit definition for CAN_FMCFGR register *******************/
  1439. #define CAN_FMCFGR_FBM ((uint16_t)0x3FFF) /* Filter Mode */
  1440. #define CAN_FMCFGR_FBM0 ((uint16_t)0x0001) /* Filter Init Mode bit 0 */
  1441. #define CAN_FMCFGR_FBM1 ((uint16_t)0x0002) /* Filter Init Mode bit 1 */
  1442. #define CAN_FMCFGR_FBM2 ((uint16_t)0x0004) /* Filter Init Mode bit 2 */
  1443. #define CAN_FMCFGR_FBM3 ((uint16_t)0x0008) /* Filter Init Mode bit 3 */
  1444. #define CAN_FMCFGR_FBM4 ((uint16_t)0x0010) /* Filter Init Mode bit 4 */
  1445. #define CAN_FMCFGR_FBM5 ((uint16_t)0x0020) /* Filter Init Mode bit 5 */
  1446. #define CAN_FMCFGR_FBM6 ((uint16_t)0x0040) /* Filter Init Mode bit 6 */
  1447. #define CAN_FMCFGR_FBM7 ((uint16_t)0x0080) /* Filter Init Mode bit 7 */
  1448. #define CAN_FMCFGR_FBM8 ((uint16_t)0x0100) /* Filter Init Mode bit 8 */
  1449. #define CAN_FMCFGR_FBM9 ((uint16_t)0x0200) /* Filter Init Mode bit 9 */
  1450. #define CAN_FMCFGR_FBM10 ((uint16_t)0x0400) /* Filter Init Mode bit 10 */
  1451. #define CAN_FMCFGR_FBM11 ((uint16_t)0x0800) /* Filter Init Mode bit 11 */
  1452. #define CAN_FMCFGR_FBM12 ((uint16_t)0x1000) /* Filter Init Mode bit 12 */
  1453. #define CAN_FMCFGR_FBM13 ((uint16_t)0x2000) /* Filter Init Mode bit 13 */
  1454. /******************* Bit definition for CAN_FSCFGR register *******************/
  1455. #define CAN_FSCFGR_FSC ((uint16_t)0x3FFF) /* Filter Scale Configuration */
  1456. #define CAN_FSCFGR_FSC0 ((uint16_t)0x0001) /* Filter Scale Configuration bit 0 */
  1457. #define CAN_FSCFGR_FSC1 ((uint16_t)0x0002) /* Filter Scale Configuration bit 1 */
  1458. #define CAN_FSCFGR_FSC2 ((uint16_t)0x0004) /* Filter Scale Configuration bit 2 */
  1459. #define CAN_FSCFGR_FSC3 ((uint16_t)0x0008) /* Filter Scale Configuration bit 3 */
  1460. #define CAN_FSCFGR_FSC4 ((uint16_t)0x0010) /* Filter Scale Configuration bit 4 */
  1461. #define CAN_FSCFGR_FSC5 ((uint16_t)0x0020) /* Filter Scale Configuration bit 5 */
  1462. #define CAN_FSCFGR_FSC6 ((uint16_t)0x0040) /* Filter Scale Configuration bit 6 */
  1463. #define CAN_FSCFGR_FSC7 ((uint16_t)0x0080) /* Filter Scale Configuration bit 7 */
  1464. #define CAN_FSCFGR_FSC8 ((uint16_t)0x0100) /* Filter Scale Configuration bit 8 */
  1465. #define CAN_FSCFGR_FSC9 ((uint16_t)0x0200) /* Filter Scale Configuration bit 9 */
  1466. #define CAN_FSCFGR_FSC10 ((uint16_t)0x0400) /* Filter Scale Configuration bit 10 */
  1467. #define CAN_FSCFGR_FSC11 ((uint16_t)0x0800) /* Filter Scale Configuration bit 11 */
  1468. #define CAN_FSCFGR_FSC12 ((uint16_t)0x1000) /* Filter Scale Configuration bit 12 */
  1469. #define CAN_FSCFGR_FSC13 ((uint16_t)0x2000) /* Filter Scale Configuration bit 13 */
  1470. /****************** Bit definition for CAN_FAFIFOR register *******************/
  1471. #define CAN_FAFIFOR_FFA ((uint16_t)0x3FFF) /* Filter FIFO Assignment */
  1472. #define CAN_FAFIFOR_FFA0 ((uint16_t)0x0001) /* Filter FIFO Assignment for Filter 0 */
  1473. #define CAN_FAFIFOR_FFA1 ((uint16_t)0x0002) /* Filter FIFO Assignment for Filter 1 */
  1474. #define CAN_FAFIFOR_FFA2 ((uint16_t)0x0004) /* Filter FIFO Assignment for Filter 2 */
  1475. #define CAN_FAFIFOR_FFA3 ((uint16_t)0x0008) /* Filter FIFO Assignment for Filter 3 */
  1476. #define CAN_FAFIFOR_FFA4 ((uint16_t)0x0010) /* Filter FIFO Assignment for Filter 4 */
  1477. #define CAN_FAFIFOR_FFA5 ((uint16_t)0x0020) /* Filter FIFO Assignment for Filter 5 */
  1478. #define CAN_FAFIFOR_FFA6 ((uint16_t)0x0040) /* Filter FIFO Assignment for Filter 6 */
  1479. #define CAN_FAFIFOR_FFA7 ((uint16_t)0x0080) /* Filter FIFO Assignment for Filter 7 */
  1480. #define CAN_FAFIFOR_FFA8 ((uint16_t)0x0100) /* Filter FIFO Assignment for Filter 8 */
  1481. #define CAN_FAFIFOR_FFA9 ((uint16_t)0x0200) /* Filter FIFO Assignment for Filter 9 */
  1482. #define CAN_FAFIFOR_FFA10 ((uint16_t)0x0400) /* Filter FIFO Assignment for Filter 10 */
  1483. #define CAN_FAFIFOR_FFA11 ((uint16_t)0x0800) /* Filter FIFO Assignment for Filter 11 */
  1484. #define CAN_FAFIFOR_FFA12 ((uint16_t)0x1000) /* Filter FIFO Assignment for Filter 12 */
  1485. #define CAN_FAFIFOR_FFA13 ((uint16_t)0x2000) /* Filter FIFO Assignment for Filter 13 */
  1486. /******************* Bit definition for CAN_FWR register *******************/
  1487. #define CAN_FWR_FACT ((uint16_t)0x3FFF) /* Filter Active */
  1488. #define CAN_FWR_FACT0 ((uint16_t)0x0001) /* Filter 0 Active */
  1489. #define CAN_FWR_FACT1 ((uint16_t)0x0002) /* Filter 1 Active */
  1490. #define CAN_FWR_FACT2 ((uint16_t)0x0004) /* Filter 2 Active */
  1491. #define CAN_FWR_FACT3 ((uint16_t)0x0008) /* Filter 3 Active */
  1492. #define CAN_FWR_FACT4 ((uint16_t)0x0010) /* Filter 4 Active */
  1493. #define CAN_FWR_FACT5 ((uint16_t)0x0020) /* Filter 5 Active */
  1494. #define CAN_FWR_FACT6 ((uint16_t)0x0040) /* Filter 6 Active */
  1495. #define CAN_FWR_FACT7 ((uint16_t)0x0080) /* Filter 7 Active */
  1496. #define CAN_FWR_FACT8 ((uint16_t)0x0100) /* Filter 8 Active */
  1497. #define CAN_FWR_FACT9 ((uint16_t)0x0200) /* Filter 9 Active */
  1498. #define CAN_FWR_FACT10 ((uint16_t)0x0400) /* Filter 10 Active */
  1499. #define CAN_FWR_FACT11 ((uint16_t)0x0800) /* Filter 11 Active */
  1500. #define CAN_FWR_FACT12 ((uint16_t)0x1000) /* Filter 12 Active */
  1501. #define CAN_FWR_FACT13 ((uint16_t)0x2000) /* Filter 13 Active */
  1502. /******************* Bit definition for CAN_F0R1 register *******************/
  1503. #define CAN_F0R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1504. #define CAN_F0R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1505. #define CAN_F0R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1506. #define CAN_F0R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1507. #define CAN_F0R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1508. #define CAN_F0R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1509. #define CAN_F0R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1510. #define CAN_F0R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1511. #define CAN_F0R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1512. #define CAN_F0R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1513. #define CAN_F0R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1514. #define CAN_F0R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1515. #define CAN_F0R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1516. #define CAN_F0R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1517. #define CAN_F0R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1518. #define CAN_F0R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1519. #define CAN_F0R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1520. #define CAN_F0R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1521. #define CAN_F0R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1522. #define CAN_F0R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1523. #define CAN_F0R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1524. #define CAN_F0R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1525. #define CAN_F0R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1526. #define CAN_F0R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1527. #define CAN_F0R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1528. #define CAN_F0R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1529. #define CAN_F0R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1530. #define CAN_F0R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1531. #define CAN_F0R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1532. #define CAN_F0R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1533. #define CAN_F0R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1534. #define CAN_F0R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1535. /******************* Bit definition for CAN_F1R1 register *******************/
  1536. #define CAN_F1R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1537. #define CAN_F1R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1538. #define CAN_F1R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1539. #define CAN_F1R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1540. #define CAN_F1R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1541. #define CAN_F1R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1542. #define CAN_F1R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1543. #define CAN_F1R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1544. #define CAN_F1R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1545. #define CAN_F1R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1546. #define CAN_F1R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1547. #define CAN_F1R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1548. #define CAN_F1R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1549. #define CAN_F1R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1550. #define CAN_F1R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1551. #define CAN_F1R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1552. #define CAN_F1R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1553. #define CAN_F1R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1554. #define CAN_F1R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1555. #define CAN_F1R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1556. #define CAN_F1R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1557. #define CAN_F1R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1558. #define CAN_F1R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1559. #define CAN_F1R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1560. #define CAN_F1R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1561. #define CAN_F1R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1562. #define CAN_F1R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1563. #define CAN_F1R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1564. #define CAN_F1R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1565. #define CAN_F1R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1566. #define CAN_F1R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1567. #define CAN_F1R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1568. /******************* Bit definition for CAN_F2R1 register *******************/
  1569. #define CAN_F2R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1570. #define CAN_F2R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1571. #define CAN_F2R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1572. #define CAN_F2R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1573. #define CAN_F2R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1574. #define CAN_F2R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1575. #define CAN_F2R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1576. #define CAN_F2R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1577. #define CAN_F2R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1578. #define CAN_F2R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1579. #define CAN_F2R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1580. #define CAN_F2R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1581. #define CAN_F2R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1582. #define CAN_F2R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1583. #define CAN_F2R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1584. #define CAN_F2R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1585. #define CAN_F2R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1586. #define CAN_F2R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1587. #define CAN_F2R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1588. #define CAN_F2R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1589. #define CAN_F2R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1590. #define CAN_F2R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1591. #define CAN_F2R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1592. #define CAN_F2R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1593. #define CAN_F2R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1594. #define CAN_F2R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1595. #define CAN_F2R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1596. #define CAN_F2R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1597. #define CAN_F2R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1598. #define CAN_F2R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1599. #define CAN_F2R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1600. #define CAN_F2R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1601. /******************* Bit definition for CAN_F3R1 register *******************/
  1602. #define CAN_F3R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1603. #define CAN_F3R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1604. #define CAN_F3R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1605. #define CAN_F3R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1606. #define CAN_F3R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1607. #define CAN_F3R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1608. #define CAN_F3R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1609. #define CAN_F3R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1610. #define CAN_F3R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1611. #define CAN_F3R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1612. #define CAN_F3R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1613. #define CAN_F3R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1614. #define CAN_F3R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1615. #define CAN_F3R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1616. #define CAN_F3R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1617. #define CAN_F3R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1618. #define CAN_F3R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1619. #define CAN_F3R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1620. #define CAN_F3R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1621. #define CAN_F3R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1622. #define CAN_F3R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1623. #define CAN_F3R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1624. #define CAN_F3R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1625. #define CAN_F3R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1626. #define CAN_F3R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1627. #define CAN_F3R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1628. #define CAN_F3R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1629. #define CAN_F3R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1630. #define CAN_F3R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1631. #define CAN_F3R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1632. #define CAN_F3R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1633. #define CAN_F3R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1634. /******************* Bit definition for CAN_F4R1 register *******************/
  1635. #define CAN_F4R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1636. #define CAN_F4R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1637. #define CAN_F4R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1638. #define CAN_F4R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1639. #define CAN_F4R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1640. #define CAN_F4R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1641. #define CAN_F4R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1642. #define CAN_F4R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1643. #define CAN_F4R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1644. #define CAN_F4R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1645. #define CAN_F4R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1646. #define CAN_F4R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1647. #define CAN_F4R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1648. #define CAN_F4R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1649. #define CAN_F4R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1650. #define CAN_F4R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1651. #define CAN_F4R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1652. #define CAN_F4R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1653. #define CAN_F4R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1654. #define CAN_F4R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1655. #define CAN_F4R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1656. #define CAN_F4R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1657. #define CAN_F4R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1658. #define CAN_F4R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1659. #define CAN_F4R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1660. #define CAN_F4R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1661. #define CAN_F4R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1662. #define CAN_F4R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1663. #define CAN_F4R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1664. #define CAN_F4R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1665. #define CAN_F4R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1666. #define CAN_F4R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1667. /******************* Bit definition for CAN_F5R1 register *******************/
  1668. #define CAN_F5R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1669. #define CAN_F5R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1670. #define CAN_F5R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1671. #define CAN_F5R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1672. #define CAN_F5R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1673. #define CAN_F5R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1674. #define CAN_F5R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1675. #define CAN_F5R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1676. #define CAN_F5R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1677. #define CAN_F5R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1678. #define CAN_F5R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1679. #define CAN_F5R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1680. #define CAN_F5R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1681. #define CAN_F5R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1682. #define CAN_F5R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1683. #define CAN_F5R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1684. #define CAN_F5R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1685. #define CAN_F5R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1686. #define CAN_F5R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1687. #define CAN_F5R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1688. #define CAN_F5R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1689. #define CAN_F5R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1690. #define CAN_F5R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1691. #define CAN_F5R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1692. #define CAN_F5R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1693. #define CAN_F5R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1694. #define CAN_F5R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1695. #define CAN_F5R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1696. #define CAN_F5R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1697. #define CAN_F5R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1698. #define CAN_F5R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1699. #define CAN_F5R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1700. /******************* Bit definition for CAN_F6R1 register *******************/
  1701. #define CAN_F6R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1702. #define CAN_F6R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1703. #define CAN_F6R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1704. #define CAN_F6R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1705. #define CAN_F6R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1706. #define CAN_F6R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1707. #define CAN_F6R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1708. #define CAN_F6R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1709. #define CAN_F6R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1710. #define CAN_F6R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1711. #define CAN_F6R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1712. #define CAN_F6R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1713. #define CAN_F6R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1714. #define CAN_F6R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1715. #define CAN_F6R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1716. #define CAN_F6R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1717. #define CAN_F6R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1718. #define CAN_F6R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1719. #define CAN_F6R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1720. #define CAN_F6R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1721. #define CAN_F6R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1722. #define CAN_F6R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1723. #define CAN_F6R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1724. #define CAN_F6R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1725. #define CAN_F6R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1726. #define CAN_F6R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1727. #define CAN_F6R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1728. #define CAN_F6R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1729. #define CAN_F6R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1730. #define CAN_F6R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1731. #define CAN_F6R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1732. #define CAN_F6R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1733. /******************* Bit definition for CAN_F7R1 register *******************/
  1734. #define CAN_F7R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1735. #define CAN_F7R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1736. #define CAN_F7R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1737. #define CAN_F7R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1738. #define CAN_F7R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1739. #define CAN_F7R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1740. #define CAN_F7R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1741. #define CAN_F7R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1742. #define CAN_F7R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1743. #define CAN_F7R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1744. #define CAN_F7R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1745. #define CAN_F7R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1746. #define CAN_F7R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1747. #define CAN_F7R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1748. #define CAN_F7R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1749. #define CAN_F7R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1750. #define CAN_F7R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1751. #define CAN_F7R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1752. #define CAN_F7R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1753. #define CAN_F7R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1754. #define CAN_F7R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1755. #define CAN_F7R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1756. #define CAN_F7R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1757. #define CAN_F7R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1758. #define CAN_F7R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1759. #define CAN_F7R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1760. #define CAN_F7R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1761. #define CAN_F7R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1762. #define CAN_F7R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1763. #define CAN_F7R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1764. #define CAN_F7R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1765. #define CAN_F7R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1766. /******************* Bit definition for CAN_F8R1 register *******************/
  1767. #define CAN_F8R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1768. #define CAN_F8R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1769. #define CAN_F8R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1770. #define CAN_F8R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1771. #define CAN_F8R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1772. #define CAN_F8R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1773. #define CAN_F8R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1774. #define CAN_F8R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1775. #define CAN_F8R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1776. #define CAN_F8R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1777. #define CAN_F8R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1778. #define CAN_F8R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1779. #define CAN_F8R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1780. #define CAN_F8R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1781. #define CAN_F8R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1782. #define CAN_F8R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1783. #define CAN_F8R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1784. #define CAN_F8R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1785. #define CAN_F8R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1786. #define CAN_F8R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1787. #define CAN_F8R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1788. #define CAN_F8R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1789. #define CAN_F8R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1790. #define CAN_F8R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1791. #define CAN_F8R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1792. #define CAN_F8R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1793. #define CAN_F8R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1794. #define CAN_F8R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1795. #define CAN_F8R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1796. #define CAN_F8R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1797. #define CAN_F8R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1798. #define CAN_F8R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1799. /******************* Bit definition for CAN_F9R1 register *******************/
  1800. #define CAN_F9R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1801. #define CAN_F9R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1802. #define CAN_F9R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1803. #define CAN_F9R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1804. #define CAN_F9R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1805. #define CAN_F9R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1806. #define CAN_F9R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1807. #define CAN_F9R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1808. #define CAN_F9R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1809. #define CAN_F9R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1810. #define CAN_F9R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1811. #define CAN_F9R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1812. #define CAN_F9R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1813. #define CAN_F9R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1814. #define CAN_F9R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1815. #define CAN_F9R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1816. #define CAN_F9R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1817. #define CAN_F9R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1818. #define CAN_F9R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1819. #define CAN_F9R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1820. #define CAN_F9R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1821. #define CAN_F9R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1822. #define CAN_F9R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1823. #define CAN_F9R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1824. #define CAN_F9R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1825. #define CAN_F9R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1826. #define CAN_F9R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1827. #define CAN_F9R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1828. #define CAN_F9R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1829. #define CAN_F9R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1830. #define CAN_F9R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1831. #define CAN_F9R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1832. /******************* Bit definition for CAN_F10R1 register ******************/
  1833. #define CAN_F10R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1834. #define CAN_F10R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1835. #define CAN_F10R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1836. #define CAN_F10R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1837. #define CAN_F10R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1838. #define CAN_F10R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1839. #define CAN_F10R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1840. #define CAN_F10R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1841. #define CAN_F10R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1842. #define CAN_F10R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1843. #define CAN_F10R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1844. #define CAN_F10R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1845. #define CAN_F10R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1846. #define CAN_F10R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1847. #define CAN_F10R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1848. #define CAN_F10R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1849. #define CAN_F10R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1850. #define CAN_F10R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1851. #define CAN_F10R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1852. #define CAN_F10R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1853. #define CAN_F10R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1854. #define CAN_F10R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1855. #define CAN_F10R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1856. #define CAN_F10R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1857. #define CAN_F10R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1858. #define CAN_F10R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1859. #define CAN_F10R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1860. #define CAN_F10R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1861. #define CAN_F10R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1862. #define CAN_F10R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1863. #define CAN_F10R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1864. #define CAN_F10R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1865. /******************* Bit definition for CAN_F11R1 register ******************/
  1866. #define CAN_F11R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1867. #define CAN_F11R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1868. #define CAN_F11R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1869. #define CAN_F11R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1870. #define CAN_F11R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1871. #define CAN_F11R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1872. #define CAN_F11R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1873. #define CAN_F11R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1874. #define CAN_F11R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1875. #define CAN_F11R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1876. #define CAN_F11R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1877. #define CAN_F11R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1878. #define CAN_F11R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1879. #define CAN_F11R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1880. #define CAN_F11R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1881. #define CAN_F11R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1882. #define CAN_F11R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1883. #define CAN_F11R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1884. #define CAN_F11R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1885. #define CAN_F11R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1886. #define CAN_F11R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1887. #define CAN_F11R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1888. #define CAN_F11R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1889. #define CAN_F11R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1890. #define CAN_F11R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1891. #define CAN_F11R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1892. #define CAN_F11R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1893. #define CAN_F11R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1894. #define CAN_F11R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1895. #define CAN_F11R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1896. #define CAN_F11R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1897. #define CAN_F11R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1898. /******************* Bit definition for CAN_F12R1 register ******************/
  1899. #define CAN_F12R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1900. #define CAN_F12R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1901. #define CAN_F12R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1902. #define CAN_F12R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1903. #define CAN_F12R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1904. #define CAN_F12R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1905. #define CAN_F12R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1906. #define CAN_F12R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1907. #define CAN_F12R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1908. #define CAN_F12R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1909. #define CAN_F12R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1910. #define CAN_F12R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1911. #define CAN_F12R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1912. #define CAN_F12R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1913. #define CAN_F12R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1914. #define CAN_F12R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1915. #define CAN_F12R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1916. #define CAN_F12R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1917. #define CAN_F12R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1918. #define CAN_F12R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1919. #define CAN_F12R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1920. #define CAN_F12R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1921. #define CAN_F12R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1922. #define CAN_F12R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1923. #define CAN_F12R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1924. #define CAN_F12R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1925. #define CAN_F12R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1926. #define CAN_F12R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1927. #define CAN_F12R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1928. #define CAN_F12R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1929. #define CAN_F12R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1930. #define CAN_F12R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1931. /******************* Bit definition for CAN_F13R1 register ******************/
  1932. #define CAN_F13R1_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1933. #define CAN_F13R1_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1934. #define CAN_F13R1_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1935. #define CAN_F13R1_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1936. #define CAN_F13R1_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1937. #define CAN_F13R1_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1938. #define CAN_F13R1_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1939. #define CAN_F13R1_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1940. #define CAN_F13R1_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1941. #define CAN_F13R1_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1942. #define CAN_F13R1_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1943. #define CAN_F13R1_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1944. #define CAN_F13R1_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1945. #define CAN_F13R1_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1946. #define CAN_F13R1_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1947. #define CAN_F13R1_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1948. #define CAN_F13R1_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1949. #define CAN_F13R1_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1950. #define CAN_F13R1_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1951. #define CAN_F13R1_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1952. #define CAN_F13R1_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1953. #define CAN_F13R1_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1954. #define CAN_F13R1_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1955. #define CAN_F13R1_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1956. #define CAN_F13R1_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1957. #define CAN_F13R1_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1958. #define CAN_F13R1_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1959. #define CAN_F13R1_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1960. #define CAN_F13R1_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1961. #define CAN_F13R1_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1962. #define CAN_F13R1_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1963. #define CAN_F13R1_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1964. /******************* Bit definition for CAN_F0R2 register *******************/
  1965. #define CAN_F0R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1966. #define CAN_F0R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  1967. #define CAN_F0R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  1968. #define CAN_F0R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  1969. #define CAN_F0R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  1970. #define CAN_F0R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  1971. #define CAN_F0R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  1972. #define CAN_F0R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  1973. #define CAN_F0R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  1974. #define CAN_F0R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  1975. #define CAN_F0R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  1976. #define CAN_F0R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  1977. #define CAN_F0R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  1978. #define CAN_F0R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  1979. #define CAN_F0R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  1980. #define CAN_F0R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  1981. #define CAN_F0R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  1982. #define CAN_F0R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  1983. #define CAN_F0R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  1984. #define CAN_F0R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  1985. #define CAN_F0R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  1986. #define CAN_F0R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  1987. #define CAN_F0R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  1988. #define CAN_F0R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  1989. #define CAN_F0R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  1990. #define CAN_F0R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  1991. #define CAN_F0R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  1992. #define CAN_F0R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  1993. #define CAN_F0R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  1994. #define CAN_F0R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  1995. #define CAN_F0R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  1996. #define CAN_F0R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  1997. /******************* Bit definition for CAN_F1R2 register *******************/
  1998. #define CAN_F1R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  1999. #define CAN_F1R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2000. #define CAN_F1R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2001. #define CAN_F1R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2002. #define CAN_F1R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2003. #define CAN_F1R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2004. #define CAN_F1R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2005. #define CAN_F1R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2006. #define CAN_F1R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2007. #define CAN_F1R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2008. #define CAN_F1R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2009. #define CAN_F1R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2010. #define CAN_F1R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2011. #define CAN_F1R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2012. #define CAN_F1R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2013. #define CAN_F1R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2014. #define CAN_F1R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2015. #define CAN_F1R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2016. #define CAN_F1R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2017. #define CAN_F1R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2018. #define CAN_F1R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2019. #define CAN_F1R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2020. #define CAN_F1R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2021. #define CAN_F1R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2022. #define CAN_F1R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2023. #define CAN_F1R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2024. #define CAN_F1R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2025. #define CAN_F1R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2026. #define CAN_F1R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2027. #define CAN_F1R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2028. #define CAN_F1R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2029. #define CAN_F1R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2030. /******************* Bit definition for CAN_F2R2 register *******************/
  2031. #define CAN_F2R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2032. #define CAN_F2R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2033. #define CAN_F2R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2034. #define CAN_F2R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2035. #define CAN_F2R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2036. #define CAN_F2R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2037. #define CAN_F2R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2038. #define CAN_F2R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2039. #define CAN_F2R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2040. #define CAN_F2R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2041. #define CAN_F2R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2042. #define CAN_F2R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2043. #define CAN_F2R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2044. #define CAN_F2R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2045. #define CAN_F2R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2046. #define CAN_F2R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2047. #define CAN_F2R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2048. #define CAN_F2R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2049. #define CAN_F2R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2050. #define CAN_F2R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2051. #define CAN_F2R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2052. #define CAN_F2R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2053. #define CAN_F2R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2054. #define CAN_F2R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2055. #define CAN_F2R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2056. #define CAN_F2R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2057. #define CAN_F2R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2058. #define CAN_F2R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2059. #define CAN_F2R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2060. #define CAN_F2R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2061. #define CAN_F2R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2062. #define CAN_F2R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2063. /******************* Bit definition for CAN_F3R2 register *******************/
  2064. #define CAN_F3R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2065. #define CAN_F3R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2066. #define CAN_F3R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2067. #define CAN_F3R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2068. #define CAN_F3R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2069. #define CAN_F3R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2070. #define CAN_F3R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2071. #define CAN_F3R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2072. #define CAN_F3R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2073. #define CAN_F3R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2074. #define CAN_F3R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2075. #define CAN_F3R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2076. #define CAN_F3R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2077. #define CAN_F3R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2078. #define CAN_F3R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2079. #define CAN_F3R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2080. #define CAN_F3R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2081. #define CAN_F3R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2082. #define CAN_F3R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2083. #define CAN_F3R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2084. #define CAN_F3R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2085. #define CAN_F3R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2086. #define CAN_F3R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2087. #define CAN_F3R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2088. #define CAN_F3R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2089. #define CAN_F3R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2090. #define CAN_F3R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2091. #define CAN_F3R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2092. #define CAN_F3R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2093. #define CAN_F3R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2094. #define CAN_F3R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2095. #define CAN_F3R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2096. /******************* Bit definition for CAN_F4R2 register *******************/
  2097. #define CAN_F4R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2098. #define CAN_F4R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2099. #define CAN_F4R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2100. #define CAN_F4R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2101. #define CAN_F4R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2102. #define CAN_F4R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2103. #define CAN_F4R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2104. #define CAN_F4R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2105. #define CAN_F4R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2106. #define CAN_F4R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2107. #define CAN_F4R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2108. #define CAN_F4R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2109. #define CAN_F4R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2110. #define CAN_F4R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2111. #define CAN_F4R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2112. #define CAN_F4R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2113. #define CAN_F4R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2114. #define CAN_F4R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2115. #define CAN_F4R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2116. #define CAN_F4R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2117. #define CAN_F4R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2118. #define CAN_F4R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2119. #define CAN_F4R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2120. #define CAN_F4R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2121. #define CAN_F4R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2122. #define CAN_F4R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2123. #define CAN_F4R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2124. #define CAN_F4R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2125. #define CAN_F4R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2126. #define CAN_F4R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2127. #define CAN_F4R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2128. #define CAN_F4R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2129. /******************* Bit definition for CAN_F5R2 register *******************/
  2130. #define CAN_F5R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2131. #define CAN_F5R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2132. #define CAN_F5R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2133. #define CAN_F5R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2134. #define CAN_F5R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2135. #define CAN_F5R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2136. #define CAN_F5R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2137. #define CAN_F5R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2138. #define CAN_F5R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2139. #define CAN_F5R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2140. #define CAN_F5R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2141. #define CAN_F5R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2142. #define CAN_F5R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2143. #define CAN_F5R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2144. #define CAN_F5R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2145. #define CAN_F5R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2146. #define CAN_F5R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2147. #define CAN_F5R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2148. #define CAN_F5R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2149. #define CAN_F5R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2150. #define CAN_F5R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2151. #define CAN_F5R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2152. #define CAN_F5R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2153. #define CAN_F5R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2154. #define CAN_F5R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2155. #define CAN_F5R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2156. #define CAN_F5R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2157. #define CAN_F5R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2158. #define CAN_F5R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2159. #define CAN_F5R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2160. #define CAN_F5R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2161. #define CAN_F5R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2162. /******************* Bit definition for CAN_F6R2 register *******************/
  2163. #define CAN_F6R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2164. #define CAN_F6R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2165. #define CAN_F6R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2166. #define CAN_F6R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2167. #define CAN_F6R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2168. #define CAN_F6R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2169. #define CAN_F6R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2170. #define CAN_F6R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2171. #define CAN_F6R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2172. #define CAN_F6R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2173. #define CAN_F6R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2174. #define CAN_F6R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2175. #define CAN_F6R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2176. #define CAN_F6R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2177. #define CAN_F6R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2178. #define CAN_F6R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2179. #define CAN_F6R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2180. #define CAN_F6R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2181. #define CAN_F6R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2182. #define CAN_F6R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2183. #define CAN_F6R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2184. #define CAN_F6R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2185. #define CAN_F6R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2186. #define CAN_F6R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2187. #define CAN_F6R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2188. #define CAN_F6R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2189. #define CAN_F6R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2190. #define CAN_F6R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2191. #define CAN_F6R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2192. #define CAN_F6R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2193. #define CAN_F6R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2194. #define CAN_F6R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2195. /******************* Bit definition for CAN_F7R2 register *******************/
  2196. #define CAN_F7R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2197. #define CAN_F7R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2198. #define CAN_F7R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2199. #define CAN_F7R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2200. #define CAN_F7R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2201. #define CAN_F7R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2202. #define CAN_F7R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2203. #define CAN_F7R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2204. #define CAN_F7R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2205. #define CAN_F7R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2206. #define CAN_F7R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2207. #define CAN_F7R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2208. #define CAN_F7R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2209. #define CAN_F7R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2210. #define CAN_F7R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2211. #define CAN_F7R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2212. #define CAN_F7R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2213. #define CAN_F7R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2214. #define CAN_F7R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2215. #define CAN_F7R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2216. #define CAN_F7R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2217. #define CAN_F7R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2218. #define CAN_F7R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2219. #define CAN_F7R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2220. #define CAN_F7R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2221. #define CAN_F7R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2222. #define CAN_F7R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2223. #define CAN_F7R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2224. #define CAN_F7R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2225. #define CAN_F7R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2226. #define CAN_F7R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2227. #define CAN_F7R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2228. /******************* Bit definition for CAN_F8R2 register *******************/
  2229. #define CAN_F8R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2230. #define CAN_F8R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2231. #define CAN_F8R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2232. #define CAN_F8R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2233. #define CAN_F8R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2234. #define CAN_F8R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2235. #define CAN_F8R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2236. #define CAN_F8R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2237. #define CAN_F8R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2238. #define CAN_F8R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2239. #define CAN_F8R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2240. #define CAN_F8R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2241. #define CAN_F8R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2242. #define CAN_F8R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2243. #define CAN_F8R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2244. #define CAN_F8R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2245. #define CAN_F8R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2246. #define CAN_F8R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2247. #define CAN_F8R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2248. #define CAN_F8R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2249. #define CAN_F8R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2250. #define CAN_F8R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2251. #define CAN_F8R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2252. #define CAN_F8R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2253. #define CAN_F8R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2254. #define CAN_F8R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2255. #define CAN_F8R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2256. #define CAN_F8R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2257. #define CAN_F8R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2258. #define CAN_F8R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2259. #define CAN_F8R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2260. #define CAN_F8R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2261. /******************* Bit definition for CAN_F9R2 register *******************/
  2262. #define CAN_F9R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2263. #define CAN_F9R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2264. #define CAN_F9R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2265. #define CAN_F9R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2266. #define CAN_F9R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2267. #define CAN_F9R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2268. #define CAN_F9R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2269. #define CAN_F9R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2270. #define CAN_F9R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2271. #define CAN_F9R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2272. #define CAN_F9R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2273. #define CAN_F9R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2274. #define CAN_F9R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2275. #define CAN_F9R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2276. #define CAN_F9R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2277. #define CAN_F9R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2278. #define CAN_F9R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2279. #define CAN_F9R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2280. #define CAN_F9R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2281. #define CAN_F9R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2282. #define CAN_F9R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2283. #define CAN_F9R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2284. #define CAN_F9R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2285. #define CAN_F9R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2286. #define CAN_F9R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2287. #define CAN_F9R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2288. #define CAN_F9R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2289. #define CAN_F9R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2290. #define CAN_F9R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2291. #define CAN_F9R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2292. #define CAN_F9R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2293. #define CAN_F9R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2294. /******************* Bit definition for CAN_F10R2 register ******************/
  2295. #define CAN_F10R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2296. #define CAN_F10R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2297. #define CAN_F10R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2298. #define CAN_F10R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2299. #define CAN_F10R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2300. #define CAN_F10R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2301. #define CAN_F10R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2302. #define CAN_F10R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2303. #define CAN_F10R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2304. #define CAN_F10R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2305. #define CAN_F10R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2306. #define CAN_F10R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2307. #define CAN_F10R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2308. #define CAN_F10R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2309. #define CAN_F10R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2310. #define CAN_F10R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2311. #define CAN_F10R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2312. #define CAN_F10R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2313. #define CAN_F10R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2314. #define CAN_F10R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2315. #define CAN_F10R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2316. #define CAN_F10R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2317. #define CAN_F10R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2318. #define CAN_F10R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2319. #define CAN_F10R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2320. #define CAN_F10R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2321. #define CAN_F10R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2322. #define CAN_F10R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2323. #define CAN_F10R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2324. #define CAN_F10R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2325. #define CAN_F10R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2326. #define CAN_F10R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2327. /******************* Bit definition for CAN_F11R2 register ******************/
  2328. #define CAN_F11R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2329. #define CAN_F11R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2330. #define CAN_F11R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2331. #define CAN_F11R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2332. #define CAN_F11R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2333. #define CAN_F11R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2334. #define CAN_F11R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2335. #define CAN_F11R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2336. #define CAN_F11R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2337. #define CAN_F11R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2338. #define CAN_F11R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2339. #define CAN_F11R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2340. #define CAN_F11R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2341. #define CAN_F11R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2342. #define CAN_F11R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2343. #define CAN_F11R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2344. #define CAN_F11R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2345. #define CAN_F11R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2346. #define CAN_F11R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2347. #define CAN_F11R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2348. #define CAN_F11R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2349. #define CAN_F11R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2350. #define CAN_F11R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2351. #define CAN_F11R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2352. #define CAN_F11R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2353. #define CAN_F11R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2354. #define CAN_F11R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2355. #define CAN_F11R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2356. #define CAN_F11R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2357. #define CAN_F11R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2358. #define CAN_F11R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2359. #define CAN_F11R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2360. /******************* Bit definition for CAN_F12R2 register ******************/
  2361. #define CAN_F12R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2362. #define CAN_F12R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2363. #define CAN_F12R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2364. #define CAN_F12R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2365. #define CAN_F12R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2366. #define CAN_F12R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2367. #define CAN_F12R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2368. #define CAN_F12R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2369. #define CAN_F12R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2370. #define CAN_F12R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2371. #define CAN_F12R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2372. #define CAN_F12R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2373. #define CAN_F12R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2374. #define CAN_F12R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2375. #define CAN_F12R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2376. #define CAN_F12R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2377. #define CAN_F12R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2378. #define CAN_F12R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2379. #define CAN_F12R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2380. #define CAN_F12R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2381. #define CAN_F12R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2382. #define CAN_F12R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2383. #define CAN_F12R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2384. #define CAN_F12R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2385. #define CAN_F12R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2386. #define CAN_F12R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2387. #define CAN_F12R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2388. #define CAN_F12R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2389. #define CAN_F12R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2390. #define CAN_F12R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2391. #define CAN_F12R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2392. #define CAN_F12R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2393. /******************* Bit definition for CAN_F13R2 register ******************/
  2394. #define CAN_F13R2_FB0 ((uint32_t)0x00000001) /* Filter bit 0 */
  2395. #define CAN_F13R2_FB1 ((uint32_t)0x00000002) /* Filter bit 1 */
  2396. #define CAN_F13R2_FB2 ((uint32_t)0x00000004) /* Filter bit 2 */
  2397. #define CAN_F13R2_FB3 ((uint32_t)0x00000008) /* Filter bit 3 */
  2398. #define CAN_F13R2_FB4 ((uint32_t)0x00000010) /* Filter bit 4 */
  2399. #define CAN_F13R2_FB5 ((uint32_t)0x00000020) /* Filter bit 5 */
  2400. #define CAN_F13R2_FB6 ((uint32_t)0x00000040) /* Filter bit 6 */
  2401. #define CAN_F13R2_FB7 ((uint32_t)0x00000080) /* Filter bit 7 */
  2402. #define CAN_F13R2_FB8 ((uint32_t)0x00000100) /* Filter bit 8 */
  2403. #define CAN_F13R2_FB9 ((uint32_t)0x00000200) /* Filter bit 9 */
  2404. #define CAN_F13R2_FB10 ((uint32_t)0x00000400) /* Filter bit 10 */
  2405. #define CAN_F13R2_FB11 ((uint32_t)0x00000800) /* Filter bit 11 */
  2406. #define CAN_F13R2_FB12 ((uint32_t)0x00001000) /* Filter bit 12 */
  2407. #define CAN_F13R2_FB13 ((uint32_t)0x00002000) /* Filter bit 13 */
  2408. #define CAN_F13R2_FB14 ((uint32_t)0x00004000) /* Filter bit 14 */
  2409. #define CAN_F13R2_FB15 ((uint32_t)0x00008000) /* Filter bit 15 */
  2410. #define CAN_F13R2_FB16 ((uint32_t)0x00010000) /* Filter bit 16 */
  2411. #define CAN_F13R2_FB17 ((uint32_t)0x00020000) /* Filter bit 17 */
  2412. #define CAN_F13R2_FB18 ((uint32_t)0x00040000) /* Filter bit 18 */
  2413. #define CAN_F13R2_FB19 ((uint32_t)0x00080000) /* Filter bit 19 */
  2414. #define CAN_F13R2_FB20 ((uint32_t)0x00100000) /* Filter bit 20 */
  2415. #define CAN_F13R2_FB21 ((uint32_t)0x00200000) /* Filter bit 21 */
  2416. #define CAN_F13R2_FB22 ((uint32_t)0x00400000) /* Filter bit 22 */
  2417. #define CAN_F13R2_FB23 ((uint32_t)0x00800000) /* Filter bit 23 */
  2418. #define CAN_F13R2_FB24 ((uint32_t)0x01000000) /* Filter bit 24 */
  2419. #define CAN_F13R2_FB25 ((uint32_t)0x02000000) /* Filter bit 25 */
  2420. #define CAN_F13R2_FB26 ((uint32_t)0x04000000) /* Filter bit 26 */
  2421. #define CAN_F13R2_FB27 ((uint32_t)0x08000000) /* Filter bit 27 */
  2422. #define CAN_F13R2_FB28 ((uint32_t)0x10000000) /* Filter bit 28 */
  2423. #define CAN_F13R2_FB29 ((uint32_t)0x20000000) /* Filter bit 29 */
  2424. #define CAN_F13R2_FB30 ((uint32_t)0x40000000) /* Filter bit 30 */
  2425. #define CAN_F13R2_FB31 ((uint32_t)0x80000000) /* Filter bit 31 */
  2426. /******************************************************************************/
  2427. /* CRC Calculation Unit */
  2428. /******************************************************************************/
  2429. /******************* Bit definition for CRC_DATAR register *********************/
  2430. #define CRC_DATAR_DR ((uint32_t)0xFFFFFFFF) /* Data register bits */
  2431. /******************* Bit definition for CRC_IDATAR register ********************/
  2432. #define CRC_IDR_IDATAR ((uint8_t)0xFF) /* General-purpose 8-bit data register bits */
  2433. /******************** Bit definition for CRC_CTLR register ********************/
  2434. #define CRC_CTLR_RESET ((uint8_t)0x01) /* RESET bit */
  2435. /******************************************************************************/
  2436. /* DMA Controller */
  2437. /******************************************************************************/
  2438. /******************* Bit definition for DMA_INTFR register ********************/
  2439. #define DMA_GIF1 ((uint32_t)0x00000001) /* Channel 1 Global interrupt flag */
  2440. #define DMA_TCIF1 ((uint32_t)0x00000002) /* Channel 1 Transfer Complete flag */
  2441. #define DMA_HTIF1 ((uint32_t)0x00000004) /* Channel 1 Half Transfer flag */
  2442. #define DMA_TEIF1 ((uint32_t)0x00000008) /* Channel 1 Transfer Error flag */
  2443. #define DMA_GIF2 ((uint32_t)0x00000010) /* Channel 2 Global interrupt flag */
  2444. #define DMA_TCIF2 ((uint32_t)0x00000020) /* Channel 2 Transfer Complete flag */
  2445. #define DMA_HTIF2 ((uint32_t)0x00000040) /* Channel 2 Half Transfer flag */
  2446. #define DMA_TEIF2 ((uint32_t)0x00000080) /* Channel 2 Transfer Error flag */
  2447. #define DMA_GIF3 ((uint32_t)0x00000100) /* Channel 3 Global interrupt flag */
  2448. #define DMA_TCIF3 ((uint32_t)0x00000200) /* Channel 3 Transfer Complete flag */
  2449. #define DMA_HTIF3 ((uint32_t)0x00000400) /* Channel 3 Half Transfer flag */
  2450. #define DMA_TEIF3 ((uint32_t)0x00000800) /* Channel 3 Transfer Error flag */
  2451. #define DMA_GIF4 ((uint32_t)0x00001000) /* Channel 4 Global interrupt flag */
  2452. #define DMA_TCIF4 ((uint32_t)0x00002000) /* Channel 4 Transfer Complete flag */
  2453. #define DMA_HTIF4 ((uint32_t)0x00004000) /* Channel 4 Half Transfer flag */
  2454. #define DMA_TEIF4 ((uint32_t)0x00008000) /* Channel 4 Transfer Error flag */
  2455. #define DMA_GIF5 ((uint32_t)0x00010000) /* Channel 5 Global interrupt flag */
  2456. #define DMA_TCIF5 ((uint32_t)0x00020000) /* Channel 5 Transfer Complete flag */
  2457. #define DMA_HTIF5 ((uint32_t)0x00040000) /* Channel 5 Half Transfer flag */
  2458. #define DMA_TEIF5 ((uint32_t)0x00080000) /* Channel 5 Transfer Error flag */
  2459. #define DMA_GIF6 ((uint32_t)0x00100000) /* Channel 6 Global interrupt flag */
  2460. #define DMA_TCIF6 ((uint32_t)0x00200000) /* Channel 6 Transfer Complete flag */
  2461. #define DMA_HTIF6 ((uint32_t)0x00400000) /* Channel 6 Half Transfer flag */
  2462. #define DMA_TEIF6 ((uint32_t)0x00800000) /* Channel 6 Transfer Error flag */
  2463. #define DMA_GIF7 ((uint32_t)0x01000000) /* Channel 7 Global interrupt flag */
  2464. #define DMA_TCIF7 ((uint32_t)0x02000000) /* Channel 7 Transfer Complete flag */
  2465. #define DMA_HTIF7 ((uint32_t)0x04000000) /* Channel 7 Half Transfer flag */
  2466. #define DMA_TEIF7 ((uint32_t)0x08000000) /* Channel 7 Transfer Error flag */
  2467. #define DMA_GIF8 ((uint32_t)0x00000001) /* Channel 8 Global interrupt flag */
  2468. #define DMA_TCIF8 ((uint32_t)0x00000002) /* Channel 8 Transfer Complete flag */
  2469. #define DMA_HTIF8 ((uint32_t)0x00000004) /* Channel 8 Half Transfer flag */
  2470. #define DMA_TEIF8 ((uint32_t)0x00000008) /* Channel 8 Transfer Error flag */
  2471. #define DMA_GIF9 ((uint32_t)0x00000010) /* Channel 9 Global interrupt flag */
  2472. #define DMA_TCIF9 ((uint32_t)0x00000020) /* Channel 9 Transfer Complete flag */
  2473. #define DMA_HTIF9 ((uint32_t)0x00000040) /* Channel 9 Half Transfer flag */
  2474. #define DMA_TEIF9 ((uint32_t)0x00000080) /* Channel 9 Transfer Error flag */
  2475. #define DMA_GIF10 ((uint32_t)0x00000100) /* Channel 10 Global interrupt flag */
  2476. #define DMA_TCIF10 ((uint32_t)0x00000200) /* Channel 10 Transfer Complete flag */
  2477. #define DMA_HTIF10 ((uint32_t)0x00000400) /* Channel 10 Half Transfer flag */
  2478. #define DMA_TEIF10 ((uint32_t)0x00000800) /* Channel 10 Transfer Error flag */
  2479. #define DMA_GIF11 ((uint32_t)0x00001000) /* Channel 11 Global interrupt flag */
  2480. #define DMA_TCIF11 ((uint32_t)0x00002000) /* Channel 11 Transfer Complete flag */
  2481. #define DMA_HTIF11 ((uint32_t)0x00004000) /* Channel 11 Half Transfer flag */
  2482. #define DMA_TEIF11 ((uint32_t)0x00008000) /* Channel 11 Transfer Error flag */
  2483. /******************* Bit definition for DMA_INTFCR register *******************/
  2484. #define DMA_CGIF1 ((uint32_t)0x00000001) /* Channel 1 Global interrupt clear */
  2485. #define DMA_CTCIF1 ((uint32_t)0x00000002) /* Channel 1 Transfer Complete clear */
  2486. #define DMA_CHTIF1 ((uint32_t)0x00000004) /* Channel 1 Half Transfer clear */
  2487. #define DMA_CTEIF1 ((uint32_t)0x00000008) /* Channel 1 Transfer Error clear */
  2488. #define DMA_CGIF2 ((uint32_t)0x00000010) /* Channel 2 Global interrupt clear */
  2489. #define DMA_CTCIF2 ((uint32_t)0x00000020) /* Channel 2 Transfer Complete clear */
  2490. #define DMA_CHTIF2 ((uint32_t)0x00000040) /* Channel 2 Half Transfer clear */
  2491. #define DMA_CTEIF2 ((uint32_t)0x00000080) /* Channel 2 Transfer Error clear */
  2492. #define DMA_CGIF3 ((uint32_t)0x00000100) /* Channel 3 Global interrupt clear */
  2493. #define DMA_CTCIF3 ((uint32_t)0x00000200) /* Channel 3 Transfer Complete clear */
  2494. #define DMA_CHTIF3 ((uint32_t)0x00000400) /* Channel 3 Half Transfer clear */
  2495. #define DMA_CTEIF3 ((uint32_t)0x00000800) /* Channel 3 Transfer Error clear */
  2496. #define DMA_CGIF4 ((uint32_t)0x00001000) /* Channel 4 Global interrupt clear */
  2497. #define DMA_CTCIF4 ((uint32_t)0x00002000) /* Channel 4 Transfer Complete clear */
  2498. #define DMA_CHTIF4 ((uint32_t)0x00004000) /* Channel 4 Half Transfer clear */
  2499. #define DMA_CTEIF4 ((uint32_t)0x00008000) /* Channel 4 Transfer Error clear */
  2500. #define DMA_CGIF5 ((uint32_t)0x00010000) /* Channel 5 Global interrupt clear */
  2501. #define DMA_CTCIF5 ((uint32_t)0x00020000) /* Channel 5 Transfer Complete clear */
  2502. #define DMA_CHTIF5 ((uint32_t)0x00040000) /* Channel 5 Half Transfer clear */
  2503. #define DMA_CTEIF5 ((uint32_t)0x00080000) /* Channel 5 Transfer Error clear */
  2504. #define DMA_CGIF6 ((uint32_t)0x00100000) /* Channel 6 Global interrupt clear */
  2505. #define DMA_CTCIF6 ((uint32_t)0x00200000) /* Channel 6 Transfer Complete clear */
  2506. #define DMA_CHTIF6 ((uint32_t)0x00400000) /* Channel 6 Half Transfer clear */
  2507. #define DMA_CTEIF6 ((uint32_t)0x00800000) /* Channel 6 Transfer Error clear */
  2508. #define DMA_CGIF7 ((uint32_t)0x01000000) /* Channel 7 Global interrupt clear */
  2509. #define DMA_CTCIF7 ((uint32_t)0x02000000) /* Channel 7 Transfer Complete clear */
  2510. #define DMA_CHTIF7 ((uint32_t)0x04000000) /* Channel 7 Half Transfer clear */
  2511. #define DMA_CTEIF7 ((uint32_t)0x08000000) /* Channel 7 Transfer Error clear */
  2512. /******************* Bit definition for DMA_CFGR1 register *******************/
  2513. #define DMA_CFGR1_EN ((uint16_t)0x0001) /* Channel enable*/
  2514. #define DMA_CFGR1_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2515. #define DMA_CFGR1_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2516. #define DMA_CFGR1_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2517. #define DMA_CFGR1_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2518. #define DMA_CFGR1_CIRC ((uint16_t)0x0020) /* Circular mode */
  2519. #define DMA_CFGR1_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2520. #define DMA_CFGR1_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2521. #define DMA_CFGR1_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2522. #define DMA_CFGR1_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2523. #define DMA_CFGR1_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2524. #define DMA_CFGR1_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2525. #define DMA_CFGR1_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2526. #define DMA_CFGR1_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2527. #define DMA_CFGR1_PL ((uint16_t)0x3000) /* PL[1:0] bits(Channel Priority level) */
  2528. #define DMA_CFGR1_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2529. #define DMA_CFGR1_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2530. #define DMA_CFGR1_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode */
  2531. /******************* Bit definition for DMA_CFGR2 register *******************/
  2532. #define DMA_CFGR2_EN ((uint16_t)0x0001) /* Channel enable */
  2533. #define DMA_CFGR2_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2534. #define DMA_CFGR2_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2535. #define DMA_CFGR2_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2536. #define DMA_CFGR2_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2537. #define DMA_CFGR2_CIRC ((uint16_t)0x0020) /* Circular mode */
  2538. #define DMA_CFGR2_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2539. #define DMA_CFGR2_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2540. #define DMA_CFGR2_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2541. #define DMA_CFGR2_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2542. #define DMA_CFGR2_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2543. #define DMA_CFGR2_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2544. #define DMA_CFGR2_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2545. #define DMA_CFGR2_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2546. #define DMA_CFGR2_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2547. #define DMA_CFGR2_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2548. #define DMA_CFGR2_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2549. #define DMA_CFGR2_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode */
  2550. /******************* Bit definition for DMA_CFGR3 register *******************/
  2551. #define DMA_CFGR3_EN ((uint16_t)0x0001) /* Channel enable */
  2552. #define DMA_CFGR3_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2553. #define DMA_CFGR3_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2554. #define DMA_CFGR3_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2555. #define DMA_CFGR3_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2556. #define DMA_CFGR3_CIRC ((uint16_t)0x0020) /* Circular mode */
  2557. #define DMA_CFGR3_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2558. #define DMA_CFGR3_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2559. #define DMA_CFGR3_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2560. #define DMA_CFGR3_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2561. #define DMA_CFGR3_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2562. #define DMA_CFGR3_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2563. #define DMA_CFGR3_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2564. #define DMA_CFGR3_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2565. #define DMA_CFGR3_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2566. #define DMA_CFGR3_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2567. #define DMA_CFGR3_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2568. #define DMA_CFGR3_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode */
  2569. /******************* Bit definition for DMA_CFG4 register *******************/
  2570. #define DMA_CFG4_EN ((uint16_t)0x0001) /* Channel enable */
  2571. #define DMA_CFG4_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2572. #define DMA_CFG4_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2573. #define DMA_CFG4_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2574. #define DMA_CFG4_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2575. #define DMA_CFG4_CIRC ((uint16_t)0x0020) /* Circular mode */
  2576. #define DMA_CFG4_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2577. #define DMA_CFG4_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2578. #define DMA_CFG4_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2579. #define DMA_CFG4_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2580. #define DMA_CFG4_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2581. #define DMA_CFG4_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2582. #define DMA_CFG4_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2583. #define DMA_CFG4_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2584. #define DMA_CFG4_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2585. #define DMA_CFG4_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2586. #define DMA_CFG4_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2587. #define DMA_CFG4_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode */
  2588. /****************** Bit definition for DMA_CFG5 register *******************/
  2589. #define DMA_CFG5_EN ((uint16_t)0x0001) /* Channel enable */
  2590. #define DMA_CFG5_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2591. #define DMA_CFG5_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2592. #define DMA_CFG5_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2593. #define DMA_CFG5_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2594. #define DMA_CFG5_CIRC ((uint16_t)0x0020) /* Circular mode */
  2595. #define DMA_CFG5_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2596. #define DMA_CFG5_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2597. #define DMA_CFG5_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2598. #define DMA_CFG5_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2599. #define DMA_CFG5_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2600. #define DMA_CFG5_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2601. #define DMA_CFG5_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2602. #define DMA_CFG5_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2603. #define DMA_CFG5_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2604. #define DMA_CFG5_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2605. #define DMA_CFG5_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2606. #define DMA_CFG5_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode enable */
  2607. /******************* Bit definition for DMA_CFG6 register *******************/
  2608. #define DMA_CFG6_EN ((uint16_t)0x0001) /* Channel enable */
  2609. #define DMA_CFG6_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2610. #define DMA_CFG6_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2611. #define DMA_CFG6_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2612. #define DMA_CFG6_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2613. #define DMA_CFG6_CIRC ((uint16_t)0x0020) /* Circular mode */
  2614. #define DMA_CFG6_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2615. #define DMA_CFG6_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2616. #define DMA_CFG6_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2617. #define DMA_CFG6_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2618. #define DMA_CFG6_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2619. #define DMA_CFG6_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2620. #define DMA_CFG6_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2621. #define DMA_CFG6_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2622. #define DMA_CFG6_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2623. #define DMA_CFG6_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2624. #define DMA_CFG6_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2625. #define DMA_CFG6_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode */
  2626. /******************* Bit definition for DMA_CFG7 register *******************/
  2627. #define DMA_CFG7_EN ((uint16_t)0x0001) /* Channel enable */
  2628. #define DMA_CFG7_TCIE ((uint16_t)0x0002) /* Transfer complete interrupt enable */
  2629. #define DMA_CFG7_HTIE ((uint16_t)0x0004) /* Half Transfer interrupt enable */
  2630. #define DMA_CFG7_TEIE ((uint16_t)0x0008) /* Transfer error interrupt enable */
  2631. #define DMA_CFG7_DIR ((uint16_t)0x0010) /* Data transfer direction */
  2632. #define DMA_CFG7_CIRC ((uint16_t)0x0020) /* Circular mode */
  2633. #define DMA_CFG7_PINC ((uint16_t)0x0040) /* Peripheral increment mode */
  2634. #define DMA_CFG7_MINC ((uint16_t)0x0080) /* Memory increment mode */
  2635. #define DMA_CFG7_PSIZE ((uint16_t)0x0300) /* PSIZE[1:0] bits (Peripheral size) */
  2636. #define DMA_CFG7_PSIZE_0 ((uint16_t)0x0100) /* Bit 0 */
  2637. #define DMA_CFG7_PSIZE_1 ((uint16_t)0x0200) /* Bit 1 */
  2638. #define DMA_CFG7_MSIZE ((uint16_t)0x0C00) /* MSIZE[1:0] bits (Memory size) */
  2639. #define DMA_CFG7_MSIZE_0 ((uint16_t)0x0400) /* Bit 0 */
  2640. #define DMA_CFG7_MSIZE_1 ((uint16_t)0x0800) /* Bit 1 */
  2641. #define DMA_CFG7_PL ((uint16_t)0x3000) /* PL[1:0] bits (Channel Priority level) */
  2642. #define DMA_CFG7_PL_0 ((uint16_t)0x1000) /* Bit 0 */
  2643. #define DMA_CFG7_PL_1 ((uint16_t)0x2000) /* Bit 1 */
  2644. #define DMA_CFG7_MEM2MEM ((uint16_t)0x4000) /* Memory to memory mode enable */
  2645. /****************** Bit definition for DMA_CNTR1 register ******************/
  2646. #define DMA_CNTR1_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2647. /****************** Bit definition for DMA_CNTR2 register ******************/
  2648. #define DMA_CNTR2_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2649. /****************** Bit definition for DMA_CNTR3 register ******************/
  2650. #define DMA_CNTR3_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2651. /****************** Bit definition for DMA_CNTR4 register ******************/
  2652. #define DMA_CNTR4_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2653. /****************** Bit definition for DMA_CNTR5 register ******************/
  2654. #define DMA_CNTR5_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2655. /****************** Bit definition for DMA_CNTR6 register ******************/
  2656. #define DMA_CNTR6_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2657. /****************** Bit definition for DMA_CNTR7 register ******************/
  2658. #define DMA_CNTR7_NDT ((uint16_t)0xFFFF) /* Number of data to Transfer */
  2659. /****************** Bit definition for DMA_PADDR1 register *******************/
  2660. #define DMA_PADDR1_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2661. /****************** Bit definition for DMA_PADDR2 register *******************/
  2662. #define DMA_PADDR2_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2663. /****************** Bit definition for DMA_PADDR3 register *******************/
  2664. #define DMA_PADDR3_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2665. /****************** Bit definition for DMA_PADDR4 register *******************/
  2666. #define DMA_PADDR4_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2667. /****************** Bit definition for DMA_PADDR5 register *******************/
  2668. #define DMA_PADDR5_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2669. /****************** Bit definition for DMA_PADDR6 register *******************/
  2670. #define DMA_PADDR6_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2671. /****************** Bit definition for DMA_PADDR7 register *******************/
  2672. #define DMA_PADDR7_PA ((uint32_t)0xFFFFFFFF) /* Peripheral Address */
  2673. /****************** Bit definition for DMA_MADDR1 register *******************/
  2674. #define DMA_MADDR1_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2675. /****************** Bit definition for DMA_MADDR2 register *******************/
  2676. #define DMA_MADDR2_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2677. /****************** Bit definition for DMA_MADDR3 register *******************/
  2678. #define DMA_MADDR3_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2679. /****************** Bit definition for DMA_MADDR4 register *******************/
  2680. #define DMA_MADDR4_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2681. /****************** Bit definition for DMA_MADDR5 register *******************/
  2682. #define DMA_MADDR5_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2683. /****************** Bit definition for DMA_MADDR6 register *******************/
  2684. #define DMA_MADDR6_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2685. /****************** Bit definition for DMA_MADDR7 register *******************/
  2686. #define DMA_MADDR7_MA ((uint32_t)0xFFFFFFFF) /* Memory Address */
  2687. /******************************************************************************/
  2688. /* External Interrupt/Event Controller */
  2689. /******************************************************************************/
  2690. /******************* Bit definition for EXTI_INTENR register *******************/
  2691. #define EXTI_INTENR_MR0 ((uint32_t)0x00000001) /* Interrupt Mask on line 0 */
  2692. #define EXTI_INTENR_MR1 ((uint32_t)0x00000002) /* Interrupt Mask on line 1 */
  2693. #define EXTI_INTENR_MR2 ((uint32_t)0x00000004) /* Interrupt Mask on line 2 */
  2694. #define EXTI_INTENR_MR3 ((uint32_t)0x00000008) /* Interrupt Mask on line 3 */
  2695. #define EXTI_INTENR_MR4 ((uint32_t)0x00000010) /* Interrupt Mask on line 4 */
  2696. #define EXTI_INTENR_MR5 ((uint32_t)0x00000020) /* Interrupt Mask on line 5 */
  2697. #define EXTI_INTENR_MR6 ((uint32_t)0x00000040) /* Interrupt Mask on line 6 */
  2698. #define EXTI_INTENR_MR7 ((uint32_t)0x00000080) /* Interrupt Mask on line 7 */
  2699. #define EXTI_INTENR_MR8 ((uint32_t)0x00000100) /* Interrupt Mask on line 8 */
  2700. #define EXTI_INTENR_MR9 ((uint32_t)0x00000200) /* Interrupt Mask on line 9 */
  2701. #define EXTI_INTENR_MR10 ((uint32_t)0x00000400) /* Interrupt Mask on line 10 */
  2702. #define EXTI_INTENR_MR11 ((uint32_t)0x00000800) /* Interrupt Mask on line 11 */
  2703. #define EXTI_INTENR_MR12 ((uint32_t)0x00001000) /* Interrupt Mask on line 12 */
  2704. #define EXTI_INTENR_MR13 ((uint32_t)0x00002000) /* Interrupt Mask on line 13 */
  2705. #define EXTI_INTENR_MR14 ((uint32_t)0x00004000) /* Interrupt Mask on line 14 */
  2706. #define EXTI_INTENR_MR15 ((uint32_t)0x00008000) /* Interrupt Mask on line 15 */
  2707. #define EXTI_INTENR_MR16 ((uint32_t)0x00010000) /* Interrupt Mask on line 16 */
  2708. #define EXTI_INTENR_MR17 ((uint32_t)0x00020000) /* Interrupt Mask on line 17 */
  2709. #define EXTI_INTENR_MR18 ((uint32_t)0x00040000) /* Interrupt Mask on line 18 */
  2710. #define EXTI_INTENR_MR19 ((uint32_t)0x00080000) /* Interrupt Mask on line 19 */
  2711. /******************* Bit definition for EXTI_EVENR register *******************/
  2712. #define EXTI_EVENR_MR0 ((uint32_t)0x00000001) /* Event Mask on line 0 */
  2713. #define EXTI_EVENR_MR1 ((uint32_t)0x00000002) /* Event Mask on line 1 */
  2714. #define EXTI_EVENR_MR2 ((uint32_t)0x00000004) /* Event Mask on line 2 */
  2715. #define EXTI_EVENR_MR3 ((uint32_t)0x00000008) /* Event Mask on line 3 */
  2716. #define EXTI_EVENR_MR4 ((uint32_t)0x00000010) /* Event Mask on line 4 */
  2717. #define EXTI_EVENR_MR5 ((uint32_t)0x00000020) /* Event Mask on line 5 */
  2718. #define EXTI_EVENR_MR6 ((uint32_t)0x00000040) /* Event Mask on line 6 */
  2719. #define EXTI_EVENR_MR7 ((uint32_t)0x00000080) /* Event Mask on line 7 */
  2720. #define EXTI_EVENR_MR8 ((uint32_t)0x00000100) /* Event Mask on line 8 */
  2721. #define EXTI_EVENR_MR9 ((uint32_t)0x00000200) /* Event Mask on line 9 */
  2722. #define EXTI_EVENR_MR10 ((uint32_t)0x00000400) /* Event Mask on line 10 */
  2723. #define EXTI_EVENR_MR11 ((uint32_t)0x00000800) /* Event Mask on line 11 */
  2724. #define EXTI_EVENR_MR12 ((uint32_t)0x00001000) /* Event Mask on line 12 */
  2725. #define EXTI_EVENR_MR13 ((uint32_t)0x00002000) /* Event Mask on line 13 */
  2726. #define EXTI_EVENR_MR14 ((uint32_t)0x00004000) /* Event Mask on line 14 */
  2727. #define EXTI_EVENR_MR15 ((uint32_t)0x00008000) /* Event Mask on line 15 */
  2728. #define EXTI_EVENR_MR16 ((uint32_t)0x00010000) /* Event Mask on line 16 */
  2729. #define EXTI_EVENR_MR17 ((uint32_t)0x00020000) /* Event Mask on line 17 */
  2730. #define EXTI_EVENR_MR18 ((uint32_t)0x00040000) /* Event Mask on line 18 */
  2731. #define EXTI_EVENR_MR19 ((uint32_t)0x00080000) /* Event Mask on line 19 */
  2732. /****************** Bit definition for EXTI_RTENR register *******************/
  2733. #define EXTI_RTENR_TR0 ((uint32_t)0x00000001) /* Rising trigger event configuration bit of line 0 */
  2734. #define EXTI_RTENR_TR1 ((uint32_t)0x00000002) /* Rising trigger event configuration bit of line 1 */
  2735. #define EXTI_RTENR_TR2 ((uint32_t)0x00000004) /* Rising trigger event configuration bit of line 2 */
  2736. #define EXTI_RTENR_TR3 ((uint32_t)0x00000008) /* Rising trigger event configuration bit of line 3 */
  2737. #define EXTI_RTENR_TR4 ((uint32_t)0x00000010) /* Rising trigger event configuration bit of line 4 */
  2738. #define EXTI_RTENR_TR5 ((uint32_t)0x00000020) /* Rising trigger event configuration bit of line 5 */
  2739. #define EXTI_RTENR_TR6 ((uint32_t)0x00000040) /* Rising trigger event configuration bit of line 6 */
  2740. #define EXTI_RTENR_TR7 ((uint32_t)0x00000080) /* Rising trigger event configuration bit of line 7 */
  2741. #define EXTI_RTENR_TR8 ((uint32_t)0x00000100) /* Rising trigger event configuration bit of line 8 */
  2742. #define EXTI_RTENR_TR9 ((uint32_t)0x00000200) /* Rising trigger event configuration bit of line 9 */
  2743. #define EXTI_RTENR_TR10 ((uint32_t)0x00000400) /* Rising trigger event configuration bit of line 10 */
  2744. #define EXTI_RTENR_TR11 ((uint32_t)0x00000800) /* Rising trigger event configuration bit of line 11 */
  2745. #define EXTI_RTENR_TR12 ((uint32_t)0x00001000) /* Rising trigger event configuration bit of line 12 */
  2746. #define EXTI_RTENR_TR13 ((uint32_t)0x00002000) /* Rising trigger event configuration bit of line 13 */
  2747. #define EXTI_RTENR_TR14 ((uint32_t)0x00004000) /* Rising trigger event configuration bit of line 14 */
  2748. #define EXTI_RTENR_TR15 ((uint32_t)0x00008000) /* Rising trigger event configuration bit of line 15 */
  2749. #define EXTI_RTENR_TR16 ((uint32_t)0x00010000) /* Rising trigger event configuration bit of line 16 */
  2750. #define EXTI_RTENR_TR17 ((uint32_t)0x00020000) /* Rising trigger event configuration bit of line 17 */
  2751. #define EXTI_RTENR_TR18 ((uint32_t)0x00040000) /* Rising trigger event configuration bit of line 18 */
  2752. #define EXTI_RTENR_TR19 ((uint32_t)0x00080000) /* Rising trigger event configuration bit of line 19 */
  2753. /****************** Bit definition for EXTI_FTENR register *******************/
  2754. #define EXTI_FTENR_TR0 ((uint32_t)0x00000001) /* Falling trigger event configuration bit of line 0 */
  2755. #define EXTI_FTENR_TR1 ((uint32_t)0x00000002) /* Falling trigger event configuration bit of line 1 */
  2756. #define EXTI_FTENR_TR2 ((uint32_t)0x00000004) /* Falling trigger event configuration bit of line 2 */
  2757. #define EXTI_FTENR_TR3 ((uint32_t)0x00000008) /* Falling trigger event configuration bit of line 3 */
  2758. #define EXTI_FTENR_TR4 ((uint32_t)0x00000010) /* Falling trigger event configuration bit of line 4 */
  2759. #define EXTI_FTENR_TR5 ((uint32_t)0x00000020) /* Falling trigger event configuration bit of line 5 */
  2760. #define EXTI_FTENR_TR6 ((uint32_t)0x00000040) /* Falling trigger event configuration bit of line 6 */
  2761. #define EXTI_FTENR_TR7 ((uint32_t)0x00000080) /* Falling trigger event configuration bit of line 7 */
  2762. #define EXTI_FTENR_TR8 ((uint32_t)0x00000100) /* Falling trigger event configuration bit of line 8 */
  2763. #define EXTI_FTENR_TR9 ((uint32_t)0x00000200) /* Falling trigger event configuration bit of line 9 */
  2764. #define EXTI_FTENR_TR10 ((uint32_t)0x00000400) /* Falling trigger event configuration bit of line 10 */
  2765. #define EXTI_FTENR_TR11 ((uint32_t)0x00000800) /* Falling trigger event configuration bit of line 11 */
  2766. #define EXTI_FTENR_TR12 ((uint32_t)0x00001000) /* Falling trigger event configuration bit of line 12 */
  2767. #define EXTI_FTENR_TR13 ((uint32_t)0x00002000) /* Falling trigger event configuration bit of line 13 */
  2768. #define EXTI_FTENR_TR14 ((uint32_t)0x00004000) /* Falling trigger event configuration bit of line 14 */
  2769. #define EXTI_FTENR_TR15 ((uint32_t)0x00008000) /* Falling trigger event configuration bit of line 15 */
  2770. #define EXTI_FTENR_TR16 ((uint32_t)0x00010000) /* Falling trigger event configuration bit of line 16 */
  2771. #define EXTI_FTENR_TR17 ((uint32_t)0x00020000) /* Falling trigger event configuration bit of line 17 */
  2772. #define EXTI_FTENR_TR18 ((uint32_t)0x00040000) /* Falling trigger event configuration bit of line 18 */
  2773. #define EXTI_FTENR_TR19 ((uint32_t)0x00080000) /* Falling trigger event configuration bit of line 19 */
  2774. /****************** Bit definition for EXTI_SWIEVR register ******************/
  2775. #define EXTI_SWIEVR_SWIEVR0 ((uint32_t)0x00000001) /* Software Interrupt on line 0 */
  2776. #define EXTI_SWIEVR_SWIEVR1 ((uint32_t)0x00000002) /* Software Interrupt on line 1 */
  2777. #define EXTI_SWIEVR_SWIEVR2 ((uint32_t)0x00000004) /* Software Interrupt on line 2 */
  2778. #define EXTI_SWIEVR_SWIEVR3 ((uint32_t)0x00000008) /* Software Interrupt on line 3 */
  2779. #define EXTI_SWIEVR_SWIEVR4 ((uint32_t)0x00000010) /* Software Interrupt on line 4 */
  2780. #define EXTI_SWIEVR_SWIEVR5 ((uint32_t)0x00000020) /* Software Interrupt on line 5 */
  2781. #define EXTI_SWIEVR_SWIEVR6 ((uint32_t)0x00000040) /* Software Interrupt on line 6 */
  2782. #define EXTI_SWIEVR_SWIEVR7 ((uint32_t)0x00000080) /* Software Interrupt on line 7 */
  2783. #define EXTI_SWIEVR_SWIEVR8 ((uint32_t)0x00000100) /* Software Interrupt on line 8 */
  2784. #define EXTI_SWIEVR_SWIEVR9 ((uint32_t)0x00000200) /* Software Interrupt on line 9 */
  2785. #define EXTI_SWIEVR_SWIEVR10 ((uint32_t)0x00000400) /* Software Interrupt on line 10 */
  2786. #define EXTI_SWIEVR_SWIEVR11 ((uint32_t)0x00000800) /* Software Interrupt on line 11 */
  2787. #define EXTI_SWIEVR_SWIEVR12 ((uint32_t)0x00001000) /* Software Interrupt on line 12 */
  2788. #define EXTI_SWIEVR_SWIEVR13 ((uint32_t)0x00002000) /* Software Interrupt on line 13 */
  2789. #define EXTI_SWIEVR_SWIEVR14 ((uint32_t)0x00004000) /* Software Interrupt on line 14 */
  2790. #define EXTI_SWIEVR_SWIEVR15 ((uint32_t)0x00008000) /* Software Interrupt on line 15 */
  2791. #define EXTI_SWIEVR_SWIEVR16 ((uint32_t)0x00010000) /* Software Interrupt on line 16 */
  2792. #define EXTI_SWIEVR_SWIEVR17 ((uint32_t)0x00020000) /* Software Interrupt on line 17 */
  2793. #define EXTI_SWIEVR_SWIEVR18 ((uint32_t)0x00040000) /* Software Interrupt on line 18 */
  2794. #define EXTI_SWIEVR_SWIEVR19 ((uint32_t)0x00080000) /* Software Interrupt on line 19 */
  2795. /******************* Bit definition for EXTI_INTFR register ********************/
  2796. #define EXTI_INTF_INTF0 ((uint32_t)0x00000001) /* Pending bit for line 0 */
  2797. #define EXTI_INTF_INTF1 ((uint32_t)0x00000002) /* Pending bit for line 1 */
  2798. #define EXTI_INTF_INTF2 ((uint32_t)0x00000004) /* Pending bit for line 2 */
  2799. #define EXTI_INTF_INTF3 ((uint32_t)0x00000008) /* Pending bit for line 3 */
  2800. #define EXTI_INTF_INTF4 ((uint32_t)0x00000010) /* Pending bit for line 4 */
  2801. #define EXTI_INTF_INTF5 ((uint32_t)0x00000020) /* Pending bit for line 5 */
  2802. #define EXTI_INTF_INTF6 ((uint32_t)0x00000040) /* Pending bit for line 6 */
  2803. #define EXTI_INTF_INTF7 ((uint32_t)0x00000080) /* Pending bit for line 7 */
  2804. #define EXTI_INTF_INTF8 ((uint32_t)0x00000100) /* Pending bit for line 8 */
  2805. #define EXTI_INTF_INTF9 ((uint32_t)0x00000200) /* Pending bit for line 9 */
  2806. #define EXTI_INTF_INTF10 ((uint32_t)0x00000400) /* Pending bit for line 10 */
  2807. #define EXTI_INTF_INTF11 ((uint32_t)0x00000800) /* Pending bit for line 11 */
  2808. #define EXTI_INTF_INTF12 ((uint32_t)0x00001000) /* Pending bit for line 12 */
  2809. #define EXTI_INTF_INTF13 ((uint32_t)0x00002000) /* Pending bit for line 13 */
  2810. #define EXTI_INTF_INTF14 ((uint32_t)0x00004000) /* Pending bit for line 14 */
  2811. #define EXTI_INTF_INTF15 ((uint32_t)0x00008000) /* Pending bit for line 15 */
  2812. #define EXTI_INTF_INTF16 ((uint32_t)0x00010000) /* Pending bit for line 16 */
  2813. #define EXTI_INTF_INTF17 ((uint32_t)0x00020000) /* Pending bit for line 17 */
  2814. #define EXTI_INTF_INTF18 ((uint32_t)0x00040000) /* Pending bit for line 18 */
  2815. #define EXTI_INTF_INTF19 ((uint32_t)0x00080000) /* Pending bit for line 19 */
  2816. /******************************************************************************/
  2817. /* FLASH and Option Bytes Registers */
  2818. /******************************************************************************/
  2819. /******************* Bit definition for FLASH_ACTLR register ******************/
  2820. /****************** Bit definition for FLASH_KEYR register ******************/
  2821. #define FLASH_KEYR_FKEYR ((uint32_t)0xFFFFFFFF) /* FPEC Key */
  2822. /***************** Bit definition for FLASH_OBKEYR register ****************/
  2823. #define FLASH_OBKEYR_OBKEYR ((uint32_t)0xFFFFFFFF) /* Option Byte Key */
  2824. /****************** Bit definition for FLASH_STATR register *******************/
  2825. #define FLASH_STATR_BSY ((uint8_t)0x01) /* Busy */
  2826. #define FLASH_STATR_PGERR ((uint8_t)0x04) /* Programming Error */
  2827. #define FLASH_STATR_WRPRTERR ((uint8_t)0x10) /* Write Protection Error */
  2828. #define FLASH_STATR_EOP ((uint8_t)0x20) /* End of operation */
  2829. /******************* Bit definition for FLASH_CTLR register *******************/
  2830. #define FLASH_CTLR_PG ((uint32_t)0x00000001) /* Programming */
  2831. #define FLASH_CTLR_PER ((uint32_t)0x00000002) /* Sector Erase 4K */
  2832. #define FLASH_CTLR_MER ((uint32_t)0x00000004) /* Mass Erase */
  2833. #define FLASH_CTLR_OPTPG ((uint32_t)0x00000010) /* Option Byte Programming */
  2834. #define FLASH_CTLR_OPTER ((uint32_t)0x00000020) /* Option Byte Erase */
  2835. #define FLASH_CTLR_STRT ((uint32_t)0x00000040) /* Start */
  2836. #define FLASH_CTLR_LOCK ((uint32_t)0x00000080) /* Lock */
  2837. #define FLASH_CTLR_OPTWRE ((uint32_t)0x00000200) /* Option Bytes Write Enable */
  2838. #define FLASH_CTLR_ERRIE ((uint32_t)0x00000400) /* Error Interrupt Enable */
  2839. #define FLASH_CTLR_EOPIE ((uint32_t)0x00001000) /* End of operation interrupt enable */
  2840. #define FLASH_CTLR_FAST_LOCK ((uint32_t)0x00008000) /* Fast Lock */
  2841. #define FLASH_CTLR_PAGE_PG ((uint32_t)0x00010000) /* Page Programming 256Byte */
  2842. #define FLASH_CTLR_PAGE_ER ((uint32_t)0x00020000) /* Page Erase 256Byte */
  2843. #define FLASH_CTLR_PAGE_BER32 ((uint32_t)0x00040000) /* Block Erase 32K */
  2844. #define FLASH_CTLR_PG_STRT ((uint32_t)0x00200000) /* Page Programming Start */
  2845. /******************* Bit definition for FLASH_ADDR register *******************/
  2846. #define FLASH_ADDR_FAR ((uint32_t)0xFFFFFFFF) /* Flash Address */
  2847. /****************** Bit definition for FLASH_OBR register *******************/
  2848. #define FLASH_OBR_OPTERR ((uint16_t)0x0001) /* Option Byte Error */
  2849. #define FLASH_OBR_RDPRT ((uint16_t)0x0002) /* Read protection */
  2850. #define FLASH_OBR_USER ((uint16_t)0x03FC) /* User Option Bytes */
  2851. #define FLASH_OBR_WDG_SW ((uint16_t)0x0004) /* WDG_SW */
  2852. #define FLASH_OBR_nRST_STOP ((uint16_t)0x0008) /* nRST_STOP */
  2853. #define FLASH_OBR_nRST_STDBY ((uint16_t)0x0010) /* nRST_STDBY */
  2854. #define FLASH_OBR_BFB2 ((uint16_t)0x0020) /* BFB2 */
  2855. /****************** Bit definition for FLASH_WPR register ******************/
  2856. #define FLASH_WPR_WRP ((uint32_t)0xFFFFFFFF) /* Write Protect */
  2857. /****************** Bit definition for FLASH_RDPR register *******************/
  2858. #define FLASH_RDPR_RDPR ((uint32_t)0x000000FF) /* Read protection option byte */
  2859. #define FLASH_RDPR_nRDPR ((uint32_t)0x0000FF00) /* Read protection complemented option byte */
  2860. /****************** Bit definition for FLASH_USER register ******************/
  2861. #define FLASH_USER_USER ((uint32_t)0x00FF0000) /* User option byte */
  2862. #define FLASH_USER_nUSER ((uint32_t)0xFF000000) /* User complemented option byte */
  2863. /****************** Bit definition for FLASH_Data0 register *****************/
  2864. #define FLASH_Data0_Data0 ((uint32_t)0x000000FF) /* User data storage option byte */
  2865. #define FLASH_Data0_nData0 ((uint32_t)0x0000FF00) /* User data storage complemented option byte */
  2866. /****************** Bit definition for FLASH_Data1 register *****************/
  2867. #define FLASH_Data1_Data1 ((uint32_t)0x00FF0000) /* User data storage option byte */
  2868. #define FLASH_Data1_nData1 ((uint32_t)0xFF000000) /* User data storage complemented option byte */
  2869. /****************** Bit definition for FLASH_WRPR0 register ******************/
  2870. #define FLASH_WRPR0_WRPR0 ((uint32_t)0x000000FF) /* Flash memory write protection option bytes */
  2871. #define FLASH_WRPR0_nWRPR0 ((uint32_t)0x0000FF00) /* Flash memory write protection complemented option bytes */
  2872. /****************** Bit definition for FLASH_WRPR1 register ******************/
  2873. #define FLASH_WRPR1_WRPR1 ((uint32_t)0x00FF0000) /* Flash memory write protection option bytes */
  2874. #define FLASH_WRPR1_nWRPR1 ((uint32_t)0xFF000000) /* Flash memory write protection complemented option bytes */
  2875. /****************** Bit definition for FLASH_WRPR2 register ******************/
  2876. #define FLASH_WRPR2_WRPR2 ((uint32_t)0x000000FF) /* Flash memory write protection option bytes */
  2877. #define FLASH_WRPR2_nWRPR2 ((uint32_t)0x0000FF00) /* Flash memory write protection complemented option bytes */
  2878. /****************** Bit definition for FLASH_WRPR3 register ******************/
  2879. #define FLASH_WRPR3_WRPR3 ((uint32_t)0x00FF0000) /* Flash memory write protection option bytes */
  2880. #define FLASH_WRPR3_nWRPR3 ((uint32_t)0xFF000000) /* Flash memory write protection complemented option bytes */
  2881. /******************************************************************************/
  2882. /* General Purpose and Alternate Function I/O */
  2883. /******************************************************************************/
  2884. /******************* Bit definition for GPIO_CFGLR register *******************/
  2885. #define GPIO_CFGLR_MODE ((uint32_t)0x33333333) /* Port x mode bits */
  2886. #define GPIO_CFGLR_MODE0 ((uint32_t)0x00000003) /* MODE0[1:0] bits (Port x mode bits, pin 0) */
  2887. #define GPIO_CFGLR_MODE0_0 ((uint32_t)0x00000001) /* Bit 0 */
  2888. #define GPIO_CFGLR_MODE0_1 ((uint32_t)0x00000002) /* Bit 1 */
  2889. #define GPIO_CFGLR_MODE1 ((uint32_t)0x00000030) /* MODE1[1:0] bits (Port x mode bits, pin 1) */
  2890. #define GPIO_CFGLR_MODE1_0 ((uint32_t)0x00000010) /* Bit 0 */
  2891. #define GPIO_CFGLR_MODE1_1 ((uint32_t)0x00000020) /* Bit 1 */
  2892. #define GPIO_CFGLR_MODE2 ((uint32_t)0x00000300) /* MODE2[1:0] bits (Port x mode bits, pin 2) */
  2893. #define GPIO_CFGLR_MODE2_0 ((uint32_t)0x00000100) /* Bit 0 */
  2894. #define GPIO_CFGLR_MODE2_1 ((uint32_t)0x00000200) /* Bit 1 */
  2895. #define GPIO_CFGLR_MODE3 ((uint32_t)0x00003000) /* MODE3[1:0] bits (Port x mode bits, pin 3) */
  2896. #define GPIO_CFGLR_MODE3_0 ((uint32_t)0x00001000) /* Bit 0 */
  2897. #define GPIO_CFGLR_MODE3_1 ((uint32_t)0x00002000) /* Bit 1 */
  2898. #define GPIO_CFGLR_MODE4 ((uint32_t)0x00030000) /* MODE4[1:0] bits (Port x mode bits, pin 4) */
  2899. #define GPIO_CFGLR_MODE4_0 ((uint32_t)0x00010000) /* Bit 0 */
  2900. #define GPIO_CFGLR_MODE4_1 ((uint32_t)0x00020000) /* Bit 1 */
  2901. #define GPIO_CFGLR_MODE5 ((uint32_t)0x00300000) /* MODE5[1:0] bits (Port x mode bits, pin 5) */
  2902. #define GPIO_CFGLR_MODE5_0 ((uint32_t)0x00100000) /* Bit 0 */
  2903. #define GPIO_CFGLR_MODE5_1 ((uint32_t)0x00200000) /* Bit 1 */
  2904. #define GPIO_CFGLR_MODE6 ((uint32_t)0x03000000) /* MODE6[1:0] bits (Port x mode bits, pin 6) */
  2905. #define GPIO_CFGLR_MODE6_0 ((uint32_t)0x01000000) /* Bit 0 */
  2906. #define GPIO_CFGLR_MODE6_1 ((uint32_t)0x02000000) /* Bit 1 */
  2907. #define GPIO_CFGLR_MODE7 ((uint32_t)0x30000000) /* MODE7[1:0] bits (Port x mode bits, pin 7) */
  2908. #define GPIO_CFGLR_MODE7_0 ((uint32_t)0x10000000) /* Bit 0 */
  2909. #define GPIO_CFGLR_MODE7_1 ((uint32_t)0x20000000) /* Bit 1 */
  2910. #define GPIO_CFGLR_CNF ((uint32_t)0xCCCCCCCC) /* Port x configuration bits */
  2911. #define GPIO_CFGLR_CNF0 ((uint32_t)0x0000000C) /* CNF0[1:0] bits (Port x configuration bits, pin 0) */
  2912. #define GPIO_CFGLR_CNF0_0 ((uint32_t)0x00000004) /* Bit 0 */
  2913. #define GPIO_CFGLR_CNF0_1 ((uint32_t)0x00000008) /* Bit 1 */
  2914. #define GPIO_CFGLR_CNF1 ((uint32_t)0x000000C0) /* CNF1[1:0] bits (Port x configuration bits, pin 1) */
  2915. #define GPIO_CFGLR_CNF1_0 ((uint32_t)0x00000040) /* Bit 0 */
  2916. #define GPIO_CFGLR_CNF1_1 ((uint32_t)0x00000080) /* Bit 1 */
  2917. #define GPIO_CFGLR_CNF2 ((uint32_t)0x00000C00) /* CNF2[1:0] bits (Port x configuration bits, pin 2) */
  2918. #define GPIO_CFGLR_CNF2_0 ((uint32_t)0x00000400) /* Bit 0 */
  2919. #define GPIO_CFGLR_CNF2_1 ((uint32_t)0x00000800) /* Bit 1 */
  2920. #define GPIO_CFGLR_CNF3 ((uint32_t)0x0000C000) /* CNF3[1:0] bits (Port x configuration bits, pin 3) */
  2921. #define GPIO_CFGLR_CNF3_0 ((uint32_t)0x00004000) /* Bit 0 */
  2922. #define GPIO_CFGLR_CNF3_1 ((uint32_t)0x00008000) /* Bit 1 */
  2923. #define GPIO_CFGLR_CNF4 ((uint32_t)0x000C0000) /* CNF4[1:0] bits (Port x configuration bits, pin 4) */
  2924. #define GPIO_CFGLR_CNF4_0 ((uint32_t)0x00040000) /* Bit 0 */
  2925. #define GPIO_CFGLR_CNF4_1 ((uint32_t)0x00080000) /* Bit 1 */
  2926. #define GPIO_CFGLR_CNF5 ((uint32_t)0x00C00000) /* CNF5[1:0] bits (Port x configuration bits, pin 5) */
  2927. #define GPIO_CFGLR_CNF5_0 ((uint32_t)0x00400000) /* Bit 0 */
  2928. #define GPIO_CFGLR_CNF5_1 ((uint32_t)0x00800000) /* Bit 1 */
  2929. #define GPIO_CFGLR_CNF6 ((uint32_t)0x0C000000) /* CNF6[1:0] bits (Port x configuration bits, pin 6) */
  2930. #define GPIO_CFGLR_CNF6_0 ((uint32_t)0x04000000) /* Bit 0 */
  2931. #define GPIO_CFGLR_CNF6_1 ((uint32_t)0x08000000) /* Bit 1 */
  2932. #define GPIO_CFGLR_CNF7 ((uint32_t)0xC0000000) /* CNF7[1:0] bits (Port x configuration bits, pin 7) */
  2933. #define GPIO_CFGLR_CNF7_0 ((uint32_t)0x40000000) /* Bit 0 */
  2934. #define GPIO_CFGLR_CNF7_1 ((uint32_t)0x80000000) /* Bit 1 */
  2935. /******************* Bit definition for GPIO_CFGHR register *******************/
  2936. #define GPIO_CFGHR_MODE ((uint32_t)0x33333333) /* Port x mode bits */
  2937. #define GPIO_CFGHR_MODE8 ((uint32_t)0x00000003) /* MODE8[1:0] bits (Port x mode bits, pin 8) */
  2938. #define GPIO_CFGHR_MODE8_0 ((uint32_t)0x00000001) /* Bit 0 */
  2939. #define GPIO_CFGHR_MODE8_1 ((uint32_t)0x00000002) /* Bit 1 */
  2940. #define GPIO_CFGHR_MODE9 ((uint32_t)0x00000030) /* MODE9[1:0] bits (Port x mode bits, pin 9) */
  2941. #define GPIO_CFGHR_MODE9_0 ((uint32_t)0x00000010) /* Bit 0 */
  2942. #define GPIO_CFGHR_MODE9_1 ((uint32_t)0x00000020) /* Bit 1 */
  2943. #define GPIO_CFGHR_MODE10 ((uint32_t)0x00000300) /* MODE10[1:0] bits (Port x mode bits, pin 10) */
  2944. #define GPIO_CFGHR_MODE10_0 ((uint32_t)0x00000100) /* Bit 0 */
  2945. #define GPIO_CFGHR_MODE10_1 ((uint32_t)0x00000200) /* Bit 1 */
  2946. #define GPIO_CFGHR_MODE11 ((uint32_t)0x00003000) /* MODE11[1:0] bits (Port x mode bits, pin 11) */
  2947. #define GPIO_CFGHR_MODE11_0 ((uint32_t)0x00001000) /* Bit 0 */
  2948. #define GPIO_CFGHR_MODE11_1 ((uint32_t)0x00002000) /* Bit 1 */
  2949. #define GPIO_CFGHR_MODE12 ((uint32_t)0x00030000) /* MODE12[1:0] bits (Port x mode bits, pin 12) */
  2950. #define GPIO_CFGHR_MODE12_0 ((uint32_t)0x00010000) /* Bit 0 */
  2951. #define GPIO_CFGHR_MODE12_1 ((uint32_t)0x00020000) /* Bit 1 */
  2952. #define GPIO_CFGHR_MODE13 ((uint32_t)0x00300000) /* MODE13[1:0] bits (Port x mode bits, pin 13) */
  2953. #define GPIO_CFGHR_MODE13_0 ((uint32_t)0x00100000) /* Bit 0 */
  2954. #define GPIO_CFGHR_MODE13_1 ((uint32_t)0x00200000) /* Bit 1 */
  2955. #define GPIO_CFGHR_MODE14 ((uint32_t)0x03000000) /* MODE14[1:0] bits (Port x mode bits, pin 14) */
  2956. #define GPIO_CFGHR_MODE14_0 ((uint32_t)0x01000000) /* Bit 0 */
  2957. #define GPIO_CFGHR_MODE14_1 ((uint32_t)0x02000000) /* Bit 1 */
  2958. #define GPIO_CFGHR_MODE15 ((uint32_t)0x30000000) /* MODE15[1:0] bits (Port x mode bits, pin 15) */
  2959. #define GPIO_CFGHR_MODE15_0 ((uint32_t)0x10000000) /* Bit 0 */
  2960. #define GPIO_CFGHR_MODE15_1 ((uint32_t)0x20000000) /* Bit 1 */
  2961. #define GPIO_CFGHR_CNF ((uint32_t)0xCCCCCCCC) /* Port x configuration bits */
  2962. #define GPIO_CFGHR_CNF8 ((uint32_t)0x0000000C) /* CNF8[1:0] bits (Port x configuration bits, pin 8) */
  2963. #define GPIO_CFGHR_CNF8_0 ((uint32_t)0x00000004) /* Bit 0 */
  2964. #define GPIO_CFGHR_CNF8_1 ((uint32_t)0x00000008) /* Bit 1 */
  2965. #define GPIO_CFGHR_CNF9 ((uint32_t)0x000000C0) /* CNF9[1:0] bits (Port x configuration bits, pin 9) */
  2966. #define GPIO_CFGHR_CNF9_0 ((uint32_t)0x00000040) /* Bit 0 */
  2967. #define GPIO_CFGHR_CNF9_1 ((uint32_t)0x00000080) /* Bit 1 */
  2968. #define GPIO_CFGHR_CNF10 ((uint32_t)0x00000C00) /* CNF10[1:0] bits (Port x configuration bits, pin 10) */
  2969. #define GPIO_CFGHR_CNF10_0 ((uint32_t)0x00000400) /* Bit 0 */
  2970. #define GPIO_CFGHR_CNF10_1 ((uint32_t)0x00000800) /* Bit 1 */
  2971. #define GPIO_CFGHR_CNF11 ((uint32_t)0x0000C000) /* CNF11[1:0] bits (Port x configuration bits, pin 11) */
  2972. #define GPIO_CFGHR_CNF11_0 ((uint32_t)0x00004000) /* Bit 0 */
  2973. #define GPIO_CFGHR_CNF11_1 ((uint32_t)0x00008000) /* Bit 1 */
  2974. #define GPIO_CFGHR_CNF12 ((uint32_t)0x000C0000) /* CNF12[1:0] bits (Port x configuration bits, pin 12) */
  2975. #define GPIO_CFGHR_CNF12_0 ((uint32_t)0x00040000) /* Bit 0 */
  2976. #define GPIO_CFGHR_CNF12_1 ((uint32_t)0x00080000) /* Bit 1 */
  2977. #define GPIO_CFGHR_CNF13 ((uint32_t)0x00C00000) /* CNF13[1:0] bits (Port x configuration bits, pin 13) */
  2978. #define GPIO_CFGHR_CNF13_0 ((uint32_t)0x00400000) /* Bit 0 */
  2979. #define GPIO_CFGHR_CNF13_1 ((uint32_t)0x00800000) /* Bit 1 */
  2980. #define GPIO_CFGHR_CNF14 ((uint32_t)0x0C000000) /* CNF14[1:0] bits (Port x configuration bits, pin 14) */
  2981. #define GPIO_CFGHR_CNF14_0 ((uint32_t)0x04000000) /* Bit 0 */
  2982. #define GPIO_CFGHR_CNF14_1 ((uint32_t)0x08000000) /* Bit 1 */
  2983. #define GPIO_CFGHR_CNF15 ((uint32_t)0xC0000000) /* CNF15[1:0] bits (Port x configuration bits, pin 15) */
  2984. #define GPIO_CFGHR_CNF15_0 ((uint32_t)0x40000000) /* Bit 0 */
  2985. #define GPIO_CFGHR_CNF15_1 ((uint32_t)0x80000000) /* Bit 1 */
  2986. /******************* Bit definition for GPIO_INDR register *******************/
  2987. #define GPIO_INDR_IDR0 ((uint16_t)0x0001) /* Port input data, bit 0 */
  2988. #define GPIO_INDR_IDR1 ((uint16_t)0x0002) /* Port input data, bit 1 */
  2989. #define GPIO_INDR_IDR2 ((uint16_t)0x0004) /* Port input data, bit 2 */
  2990. #define GPIO_INDR_IDR3 ((uint16_t)0x0008) /* Port input data, bit 3 */
  2991. #define GPIO_INDR_IDR4 ((uint16_t)0x0010) /* Port input data, bit 4 */
  2992. #define GPIO_INDR_IDR5 ((uint16_t)0x0020) /* Port input data, bit 5 */
  2993. #define GPIO_INDR_IDR6 ((uint16_t)0x0040) /* Port input data, bit 6 */
  2994. #define GPIO_INDR_IDR7 ((uint16_t)0x0080) /* Port input data, bit 7 */
  2995. #define GPIO_INDR_IDR8 ((uint16_t)0x0100) /* Port input data, bit 8 */
  2996. #define GPIO_INDR_IDR9 ((uint16_t)0x0200) /* Port input data, bit 9 */
  2997. #define GPIO_INDR_IDR10 ((uint16_t)0x0400) /* Port input data, bit 10 */
  2998. #define GPIO_INDR_IDR11 ((uint16_t)0x0800) /* Port input data, bit 11 */
  2999. #define GPIO_INDR_IDR12 ((uint16_t)0x1000) /* Port input data, bit 12 */
  3000. #define GPIO_INDR_IDR13 ((uint16_t)0x2000) /* Port input data, bit 13 */
  3001. #define GPIO_INDR_IDR14 ((uint16_t)0x4000) /* Port input data, bit 14 */
  3002. #define GPIO_INDR_IDR15 ((uint16_t)0x8000) /* Port input data, bit 15 */
  3003. /******************* Bit definition for GPIO_OUTDR register *******************/
  3004. #define GPIO_OUTDR_ODR0 ((uint16_t)0x0001) /* Port output data, bit 0 */
  3005. #define GPIO_OUTDR_ODR1 ((uint16_t)0x0002) /* Port output data, bit 1 */
  3006. #define GPIO_OUTDR_ODR2 ((uint16_t)0x0004) /* Port output data, bit 2 */
  3007. #define GPIO_OUTDR_ODR3 ((uint16_t)0x0008) /* Port output data, bit 3 */
  3008. #define GPIO_OUTDR_ODR4 ((uint16_t)0x0010) /* Port output data, bit 4 */
  3009. #define GPIO_OUTDR_ODR5 ((uint16_t)0x0020) /* Port output data, bit 5 */
  3010. #define GPIO_OUTDR_ODR6 ((uint16_t)0x0040) /* Port output data, bit 6 */
  3011. #define GPIO_OUTDR_ODR7 ((uint16_t)0x0080) /* Port output data, bit 7 */
  3012. #define GPIO_OUTDR_ODR8 ((uint16_t)0x0100) /* Port output data, bit 8 */
  3013. #define GPIO_OUTDR_ODR9 ((uint16_t)0x0200) /* Port output data, bit 9 */
  3014. #define GPIO_OUTDR_ODR10 ((uint16_t)0x0400) /* Port output data, bit 10 */
  3015. #define GPIO_OUTDR_ODR11 ((uint16_t)0x0800) /* Port output data, bit 11 */
  3016. #define GPIO_OUTDR_ODR12 ((uint16_t)0x1000) /* Port output data, bit 12 */
  3017. #define GPIO_OUTDR_ODR13 ((uint16_t)0x2000) /* Port output data, bit 13 */
  3018. #define GPIO_OUTDR_ODR14 ((uint16_t)0x4000) /* Port output data, bit 14 */
  3019. #define GPIO_OUTDR_ODR15 ((uint16_t)0x8000) /* Port output data, bit 15 */
  3020. /****************** Bit definition for GPIO_BSHR register *******************/
  3021. #define GPIO_BSHR_BS0 ((uint32_t)0x00000001) /* Port x Set bit 0 */
  3022. #define GPIO_BSHR_BS1 ((uint32_t)0x00000002) /* Port x Set bit 1 */
  3023. #define GPIO_BSHR_BS2 ((uint32_t)0x00000004) /* Port x Set bit 2 */
  3024. #define GPIO_BSHR_BS3 ((uint32_t)0x00000008) /* Port x Set bit 3 */
  3025. #define GPIO_BSHR_BS4 ((uint32_t)0x00000010) /* Port x Set bit 4 */
  3026. #define GPIO_BSHR_BS5 ((uint32_t)0x00000020) /* Port x Set bit 5 */
  3027. #define GPIO_BSHR_BS6 ((uint32_t)0x00000040) /* Port x Set bit 6 */
  3028. #define GPIO_BSHR_BS7 ((uint32_t)0x00000080) /* Port x Set bit 7 */
  3029. #define GPIO_BSHR_BS8 ((uint32_t)0x00000100) /* Port x Set bit 8 */
  3030. #define GPIO_BSHR_BS9 ((uint32_t)0x00000200) /* Port x Set bit 9 */
  3031. #define GPIO_BSHR_BS10 ((uint32_t)0x00000400) /* Port x Set bit 10 */
  3032. #define GPIO_BSHR_BS11 ((uint32_t)0x00000800) /* Port x Set bit 11 */
  3033. #define GPIO_BSHR_BS12 ((uint32_t)0x00001000) /* Port x Set bit 12 */
  3034. #define GPIO_BSHR_BS13 ((uint32_t)0x00002000) /* Port x Set bit 13 */
  3035. #define GPIO_BSHR_BS14 ((uint32_t)0x00004000) /* Port x Set bit 14 */
  3036. #define GPIO_BSHR_BS15 ((uint32_t)0x00008000) /* Port x Set bit 15 */
  3037. #define GPIO_BSHR_BR0 ((uint32_t)0x00010000) /* Port x Reset bit 0 */
  3038. #define GPIO_BSHR_BR1 ((uint32_t)0x00020000) /* Port x Reset bit 1 */
  3039. #define GPIO_BSHR_BR2 ((uint32_t)0x00040000) /* Port x Reset bit 2 */
  3040. #define GPIO_BSHR_BR3 ((uint32_t)0x00080000) /* Port x Reset bit 3 */
  3041. #define GPIO_BSHR_BR4 ((uint32_t)0x00100000) /* Port x Reset bit 4 */
  3042. #define GPIO_BSHR_BR5 ((uint32_t)0x00200000) /* Port x Reset bit 5 */
  3043. #define GPIO_BSHR_BR6 ((uint32_t)0x00400000) /* Port x Reset bit 6 */
  3044. #define GPIO_BSHR_BR7 ((uint32_t)0x00800000) /* Port x Reset bit 7 */
  3045. #define GPIO_BSHR_BR8 ((uint32_t)0x01000000) /* Port x Reset bit 8 */
  3046. #define GPIO_BSHR_BR9 ((uint32_t)0x02000000) /* Port x Reset bit 9 */
  3047. #define GPIO_BSHR_BR10 ((uint32_t)0x04000000) /* Port x Reset bit 10 */
  3048. #define GPIO_BSHR_BR11 ((uint32_t)0x08000000) /* Port x Reset bit 11 */
  3049. #define GPIO_BSHR_BR12 ((uint32_t)0x10000000) /* Port x Reset bit 12 */
  3050. #define GPIO_BSHR_BR13 ((uint32_t)0x20000000) /* Port x Reset bit 13 */
  3051. #define GPIO_BSHR_BR14 ((uint32_t)0x40000000) /* Port x Reset bit 14 */
  3052. #define GPIO_BSHR_BR15 ((uint32_t)0x80000000) /* Port x Reset bit 15 */
  3053. /******************* Bit definition for GPIO_BCR register *******************/
  3054. #define GPIO_BCR_BR0 ((uint16_t)0x0001) /* Port x Reset bit 0 */
  3055. #define GPIO_BCR_BR1 ((uint16_t)0x0002) /* Port x Reset bit 1 */
  3056. #define GPIO_BCR_BR2 ((uint16_t)0x0004) /* Port x Reset bit 2 */
  3057. #define GPIO_BCR_BR3 ((uint16_t)0x0008) /* Port x Reset bit 3 */
  3058. #define GPIO_BCR_BR4 ((uint16_t)0x0010) /* Port x Reset bit 4 */
  3059. #define GPIO_BCR_BR5 ((uint16_t)0x0020) /* Port x Reset bit 5 */
  3060. #define GPIO_BCR_BR6 ((uint16_t)0x0040) /* Port x Reset bit 6 */
  3061. #define GPIO_BCR_BR7 ((uint16_t)0x0080) /* Port x Reset bit 7 */
  3062. #define GPIO_BCR_BR8 ((uint16_t)0x0100) /* Port x Reset bit 8 */
  3063. #define GPIO_BCR_BR9 ((uint16_t)0x0200) /* Port x Reset bit 9 */
  3064. #define GPIO_BCR_BR10 ((uint16_t)0x0400) /* Port x Reset bit 10 */
  3065. #define GPIO_BCR_BR11 ((uint16_t)0x0800) /* Port x Reset bit 11 */
  3066. #define GPIO_BCR_BR12 ((uint16_t)0x1000) /* Port x Reset bit 12 */
  3067. #define GPIO_BCR_BR13 ((uint16_t)0x2000) /* Port x Reset bit 13 */
  3068. #define GPIO_BCR_BR14 ((uint16_t)0x4000) /* Port x Reset bit 14 */
  3069. #define GPIO_BCR_BR15 ((uint16_t)0x8000) /* Port x Reset bit 15 */
  3070. /****************** Bit definition for GPIO_LCKR register *******************/
  3071. #define GPIO_LCK0 ((uint32_t)0x00000001) /* Port x Lock bit 0 */
  3072. #define GPIO_LCK1 ((uint32_t)0x00000002) /* Port x Lock bit 1 */
  3073. #define GPIO_LCK2 ((uint32_t)0x00000004) /* Port x Lock bit 2 */
  3074. #define GPIO_LCK3 ((uint32_t)0x00000008) /* Port x Lock bit 3 */
  3075. #define GPIO_LCK4 ((uint32_t)0x00000010) /* Port x Lock bit 4 */
  3076. #define GPIO_LCK5 ((uint32_t)0x00000020) /* Port x Lock bit 5 */
  3077. #define GPIO_LCK6 ((uint32_t)0x00000040) /* Port x Lock bit 6 */
  3078. #define GPIO_LCK7 ((uint32_t)0x00000080) /* Port x Lock bit 7 */
  3079. #define GPIO_LCK8 ((uint32_t)0x00000100) /* Port x Lock bit 8 */
  3080. #define GPIO_LCK9 ((uint32_t)0x00000200) /* Port x Lock bit 9 */
  3081. #define GPIO_LCK10 ((uint32_t)0x00000400) /* Port x Lock bit 10 */
  3082. #define GPIO_LCK11 ((uint32_t)0x00000800) /* Port x Lock bit 11 */
  3083. #define GPIO_LCK12 ((uint32_t)0x00001000) /* Port x Lock bit 12 */
  3084. #define GPIO_LCK13 ((uint32_t)0x00002000) /* Port x Lock bit 13 */
  3085. #define GPIO_LCK14 ((uint32_t)0x00004000) /* Port x Lock bit 14 */
  3086. #define GPIO_LCK15 ((uint32_t)0x00008000) /* Port x Lock bit 15 */
  3087. #define GPIO_LCKK ((uint32_t)0x00010000) /* Lock key */
  3088. /****************** Bit definition for AFIO_ECR register *******************/
  3089. #define AFIO_ECR_PIN ((uint8_t)0x0F) /* PIN[3:0] bits (Pin selection) */
  3090. #define AFIO_ECR_PIN_0 ((uint8_t)0x01) /* Bit 0 */
  3091. #define AFIO_ECR_PIN_1 ((uint8_t)0x02) /* Bit 1 */
  3092. #define AFIO_ECR_PIN_2 ((uint8_t)0x04) /* Bit 2 */
  3093. #define AFIO_ECR_PIN_3 ((uint8_t)0x08) /* Bit 3 */
  3094. #define AFIO_ECR_PIN_PX0 ((uint8_t)0x00) /* Pin 0 selected */
  3095. #define AFIO_ECR_PIN_PX1 ((uint8_t)0x01) /* Pin 1 selected */
  3096. #define AFIO_ECR_PIN_PX2 ((uint8_t)0x02) /* Pin 2 selected */
  3097. #define AFIO_ECR_PIN_PX3 ((uint8_t)0x03) /* Pin 3 selected */
  3098. #define AFIO_ECR_PIN_PX4 ((uint8_t)0x04) /* Pin 4 selected */
  3099. #define AFIO_ECR_PIN_PX5 ((uint8_t)0x05) /* Pin 5 selected */
  3100. #define AFIO_ECR_PIN_PX6 ((uint8_t)0x06) /* Pin 6 selected */
  3101. #define AFIO_ECR_PIN_PX7 ((uint8_t)0x07) /* Pin 7 selected */
  3102. #define AFIO_ECR_PIN_PX8 ((uint8_t)0x08) /* Pin 8 selected */
  3103. #define AFIO_ECR_PIN_PX9 ((uint8_t)0x09) /* Pin 9 selected */
  3104. #define AFIO_ECR_PIN_PX10 ((uint8_t)0x0A) /* Pin 10 selected */
  3105. #define AFIO_ECR_PIN_PX11 ((uint8_t)0x0B) /* Pin 11 selected */
  3106. #define AFIO_ECR_PIN_PX12 ((uint8_t)0x0C) /* Pin 12 selected */
  3107. #define AFIO_ECR_PIN_PX13 ((uint8_t)0x0D) /* Pin 13 selected */
  3108. #define AFIO_ECR_PIN_PX14 ((uint8_t)0x0E) /* Pin 14 selected */
  3109. #define AFIO_ECR_PIN_PX15 ((uint8_t)0x0F) /* Pin 15 selected */
  3110. #define AFIO_ECR_PORT ((uint8_t)0x70) /* PORT[2:0] bits (Port selection) */
  3111. #define AFIO_ECR_PORT_0 ((uint8_t)0x10) /* Bit 0 */
  3112. #define AFIO_ECR_PORT_1 ((uint8_t)0x20) /* Bit 1 */
  3113. #define AFIO_ECR_PORT_2 ((uint8_t)0x40) /* Bit 2 */
  3114. #define AFIO_ECR_PORT_PA ((uint8_t)0x00) /* Port A selected */
  3115. #define AFIO_ECR_PORT_PB ((uint8_t)0x10) /* Port B selected */
  3116. #define AFIO_ECR_PORT_PC ((uint8_t)0x20) /* Port C selected */
  3117. #define AFIO_ECR_PORT_PD ((uint8_t)0x30) /* Port D selected */
  3118. #define AFIO_ECR_PORT_PE ((uint8_t)0x40) /* Port E selected */
  3119. #define AFIO_ECR_EVOE ((uint8_t)0x80) /* Event Output Enable */
  3120. /****************** Bit definition for AFIO_PCFR1register *******************/
  3121. #define AFIO_PCFR1_SPI1_REMAP ((uint32_t)0x00000001) /* SPI1 remapping */
  3122. #define AFIO_PCFR1_I2C1_REMAP ((uint32_t)0x00000002) /* I2C1 remapping */
  3123. #define AFIO_PCFR1_USART1_REMAP ((uint32_t)0x00000004) /* USART1 remapping */
  3124. #define AFIO_PCFR1_USART2_REMAP ((uint32_t)0x00000008) /* USART2 remapping */
  3125. #define AFIO_PCFR1_USART3_REMAP ((uint32_t)0x00000030) /* USART3_REMAP[1:0] bits (USART3 remapping) */
  3126. #define AFIO_PCFR1_USART3_REMAP_0 ((uint32_t)0x00000010) /* Bit 0 */
  3127. #define AFIO_PCFR1_USART3_REMAP_1 ((uint32_t)0x00000020) /* Bit 1 */
  3128. #define AFIO_PCFR1_USART3_REMAP_NOREMAP ((uint32_t)0x00000000) /* No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14) */
  3129. #define AFIO_PCFR1_USART3_REMAP_PARTIALREMAP ((uint32_t)0x00000010) /* Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14) */
  3130. #define AFIO_PCFR1_USART3_REMAP_FULLREMAP ((uint32_t)0x00000030) /* Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12) */
  3131. #define AFIO_PCFR1_TIM1_REMAP ((uint32_t)0x000000C0) /* TIM1_REMAP[1:0] bits (TIM1 remapping) */
  3132. #define AFIO_PCFR1_TIM1_REMAP_0 ((uint32_t)0x00000040) /* Bit 0 */
  3133. #define AFIO_PCFR1_TIM1_REMAP_1 ((uint32_t)0x00000080) /* Bit 1 */
  3134. #define AFIO_PCFR1_TIM1_REMAP_NOREMAP ((uint32_t)0x00000000) /* No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15) */
  3135. #define AFIO_PCFR1_TIM1_REMAP_PARTIALREMAP ((uint32_t)0x00000040) /* Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1) */
  3136. #define AFIO_PCFR1_TIM1_REMAP_FULLREMAP ((uint32_t)0x000000C0) /* Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12) */
  3137. #define AFIO_PCFR1_TIM2_REMAP ((uint32_t)0x00000300) /* TIM2_REMAP[1:0] bits (TIM2 remapping) */
  3138. #define AFIO_PCFR1_TIM2_REMAP_0 ((uint32_t)0x00000100) /* Bit 0 */
  3139. #define AFIO_PCFR1_TIM2_REMAP_1 ((uint32_t)0x00000200) /* Bit 1 */
  3140. #define AFIO_PCFR1_TIM2_REMAP_NOREMAP ((uint32_t)0x00000000) /* No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3) */
  3141. #define AFIO_PCFR1_TIM2_REMAP_PARTIALREMAP1 ((uint32_t)0x00000100) /* Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3) */
  3142. #define AFIO_PCFR1_TIM2_REMAP_PARTIALREMAP2 ((uint32_t)0x00000200) /* Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11) */
  3143. #define AFIO_PCFR1_TIM2_REMAP_FULLREMAP ((uint32_t)0x00000300) /* Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11) */
  3144. #define AFIO_PCFR1_TIM3_REMAP ((uint32_t)0x00000C00) /* TIM3_REMAP[1:0] bits (TIM3 remapping) */
  3145. #define AFIO_PCFR1_TIM3_REMAP_0 ((uint32_t)0x00000400) /* Bit 0 */
  3146. #define AFIO_PCFR1_TIM3_REMAP_1 ((uint32_t)0x00000800) /* Bit 1 */
  3147. #define AFIO_PCFR1_TIM3_REMAP_NOREMAP ((uint32_t)0x00000000) /* No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1) */
  3148. #define AFIO_PCFR1_TIM3_REMAP_PARTIALREMAP ((uint32_t)0x00000800) /* Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1) */
  3149. #define AFIO_PCFR1_TIM3_REMAP_FULLREMAP ((uint32_t)0x00000C00) /* Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9) */
  3150. #define AFIO_PCFR1_TIM4_REMAP ((uint32_t)0x00001000) /* TIM4_REMAP bit (TIM4 remapping) */
  3151. #define AFIO_PCFR1_CAN_REMAP ((uint32_t)0x00006000) /* CAN_REMAP[1:0] bits (CAN Alternate function remapping) */
  3152. #define AFIO_PCFR1_CAN_REMAP_0 ((uint32_t)0x00002000) /* Bit 0 */
  3153. #define AFIO_PCFR1_CAN_REMAP_1 ((uint32_t)0x00004000) /* Bit 1 */
  3154. #define AFIO_PCFR1_CAN_REMAP_REMAP1 ((uint32_t)0x00000000) /* CANRX mapped to PA11, CANTX mapped to PA12 */
  3155. #define AFIO_PCFR1_CAN_REMAP_REMAP2 ((uint32_t)0x00004000) /* CANRX mapped to PB8, CANTX mapped to PB9 */
  3156. #define AFIO_PCFR1_CAN_REMAP_REMAP3 ((uint32_t)0x00006000) /* CANRX mapped to PD0, CANTX mapped to PD1 */
  3157. #define AFIO_PCFR1_PD01_REMAP ((uint32_t)0x00008000) /* Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
  3158. #define AFIO_PCFR1_TIM5CH4_IREMAP ((uint32_t)0x00010000) /* TIM5 Channel4 Internal Remap */
  3159. #define AFIO_PCFR1_ADC1_ETRGINJ_REMAP ((uint32_t)0x00020000) /* ADC 1 External Trigger Injected Conversion remapping */
  3160. #define AFIO_PCFR1_ADC1_ETRGREG_REMAP ((uint32_t)0x00040000) /* ADC 1 External Trigger Regular Conversion remapping */
  3161. #define AFIO_PCFR1_ADC2_ETRGINJ_REMAP ((uint32_t)0x00080000) /* ADC 2 External Trigger Injected Conversion remapping */
  3162. #define AFIO_PCFR1_ADC2_ETRGREG_REMAP ((uint32_t)0x00100000) /* ADC 2 External Trigger Regular Conversion remapping */
  3163. #define AFIO_PCFR1_SWJ_CFG ((uint32_t)0x07000000) /* SWJ_CFG[2:0] bits (Serial Wire JTAG configuration) */
  3164. #define AFIO_PCFR1_SWJ_CFG_0 ((uint32_t)0x01000000) /* Bit 0 */
  3165. #define AFIO_PCFR1_SWJ_CFG_1 ((uint32_t)0x02000000) /* Bit 1 */
  3166. #define AFIO_PCFR1_SWJ_CFG_2 ((uint32_t)0x04000000) /* Bit 2 */
  3167. #define AFIO_PCFR1_SWJ_CFG_RESET ((uint32_t)0x00000000) /* Full SWJ (JTAG-DP + SW-DP) : Reset State */
  3168. #define AFIO_PCFR1_SWJ_CFG_NOJNTRST ((uint32_t)0x01000000) /* Full SWJ (JTAG-DP + SW-DP) but without JNTRST */
  3169. #define AFIO_PCFR1_SWJ_CFG_JTAGDISABLE ((uint32_t)0x02000000) /* JTAG-DP Disabled and SW-DP Enabled */
  3170. #define AFIO_PCFR1_SWJ_CFG_DISABLE ((uint32_t)0x04000000) /* JTAG-DP Disabled and SW-DP Disabled */
  3171. /***************** Bit definition for AFIO_EXTICR1 register *****************/
  3172. #define AFIO_EXTICR1_EXTI0 ((uint16_t)0x000F) /* EXTI 0 configuration */
  3173. #define AFIO_EXTICR1_EXTI1 ((uint16_t)0x00F0) /* EXTI 1 configuration */
  3174. #define AFIO_EXTICR1_EXTI2 ((uint16_t)0x0F00) /* EXTI 2 configuration */
  3175. #define AFIO_EXTICR1_EXTI3 ((uint16_t)0xF000) /* EXTI 3 configuration */
  3176. #define AFIO_EXTICR1_EXTI0_PA ((uint16_t)0x0000) /* PA[0] pin */
  3177. #define AFIO_EXTICR1_EXTI0_PB ((uint16_t)0x0001) /* PB[0] pin */
  3178. #define AFIO_EXTICR1_EXTI0_PC ((uint16_t)0x0002) /* PC[0] pin */
  3179. #define AFIO_EXTICR1_EXTI0_PD ((uint16_t)0x0003) /* PD[0] pin */
  3180. #define AFIO_EXTICR1_EXTI0_PE ((uint16_t)0x0004) /* PE[0] pin */
  3181. #define AFIO_EXTICR1_EXTI0_PF ((uint16_t)0x0005) /* PF[0] pin */
  3182. #define AFIO_EXTICR1_EXTI0_PG ((uint16_t)0x0006) /* PG[0] pin */
  3183. #define AFIO_EXTICR1_EXTI1_PA ((uint16_t)0x0000) /* PA[1] pin */
  3184. #define AFIO_EXTICR1_EXTI1_PB ((uint16_t)0x0010) /* PB[1] pin */
  3185. #define AFIO_EXTICR1_EXTI1_PC ((uint16_t)0x0020) /* PC[1] pin */
  3186. #define AFIO_EXTICR1_EXTI1_PD ((uint16_t)0x0030) /* PD[1] pin */
  3187. #define AFIO_EXTICR1_EXTI1_PE ((uint16_t)0x0040) /* PE[1] pin */
  3188. #define AFIO_EXTICR1_EXTI1_PF ((uint16_t)0x0050) /* PF[1] pin */
  3189. #define AFIO_EXTICR1_EXTI1_PG ((uint16_t)0x0060) /* PG[1] pin */
  3190. #define AFIO_EXTICR1_EXTI2_PA ((uint16_t)0x0000) /* PA[2] pin */
  3191. #define AFIO_EXTICR1_EXTI2_PB ((uint16_t)0x0100) /* PB[2] pin */
  3192. #define AFIO_EXTICR1_EXTI2_PC ((uint16_t)0x0200) /* PC[2] pin */
  3193. #define AFIO_EXTICR1_EXTI2_PD ((uint16_t)0x0300) /* PD[2] pin */
  3194. #define AFIO_EXTICR1_EXTI2_PE ((uint16_t)0x0400) /* PE[2] pin */
  3195. #define AFIO_EXTICR1_EXTI2_PF ((uint16_t)0x0500) /* PF[2] pin */
  3196. #define AFIO_EXTICR1_EXTI2_PG ((uint16_t)0x0600) /* PG[2] pin */
  3197. #define AFIO_EXTICR1_EXTI3_PA ((uint16_t)0x0000) /* PA[3] pin */
  3198. #define AFIO_EXTICR1_EXTI3_PB ((uint16_t)0x1000) /* PB[3] pin */
  3199. #define AFIO_EXTICR1_EXTI3_PC ((uint16_t)0x2000) /* PC[3] pin */
  3200. #define AFIO_EXTICR1_EXTI3_PD ((uint16_t)0x3000) /* PD[3] pin */
  3201. #define AFIO_EXTICR1_EXTI3_PE ((uint16_t)0x4000) /* PE[3] pin */
  3202. #define AFIO_EXTICR1_EXTI3_PF ((uint16_t)0x5000) /* PF[3] pin */
  3203. #define AFIO_EXTICR1_EXTI3_PG ((uint16_t)0x6000) /* PG[3] pin */
  3204. /***************** Bit definition for AFIO_EXTICR2 register *****************/
  3205. #define AFIO_EXTICR2_EXTI4 ((uint16_t)0x000F) /* EXTI 4 configuration */
  3206. #define AFIO_EXTICR2_EXTI5 ((uint16_t)0x00F0) /* EXTI 5 configuration */
  3207. #define AFIO_EXTICR2_EXTI6 ((uint16_t)0x0F00) /* EXTI 6 configuration */
  3208. #define AFIO_EXTICR2_EXTI7 ((uint16_t)0xF000) /* EXTI 7 configuration */
  3209. #define AFIO_EXTICR2_EXTI4_PA ((uint16_t)0x0000) /* PA[4] pin */
  3210. #define AFIO_EXTICR2_EXTI4_PB ((uint16_t)0x0001) /* PB[4] pin */
  3211. #define AFIO_EXTICR2_EXTI4_PC ((uint16_t)0x0002) /* PC[4] pin */
  3212. #define AFIO_EXTICR2_EXTI4_PD ((uint16_t)0x0003) /* PD[4] pin */
  3213. #define AFIO_EXTICR2_EXTI4_PE ((uint16_t)0x0004) /* PE[4] pin */
  3214. #define AFIO_EXTICR2_EXTI4_PF ((uint16_t)0x0005) /* PF[4] pin */
  3215. #define AFIO_EXTICR2_EXTI4_PG ((uint16_t)0x0006) /* PG[4] pin */
  3216. #define AFIO_EXTICR2_EXTI5_PA ((uint16_t)0x0000) /* PA[5] pin */
  3217. #define AFIO_EXTICR2_EXTI5_PB ((uint16_t)0x0010) /* PB[5] pin */
  3218. #define AFIO_EXTICR2_EXTI5_PC ((uint16_t)0x0020) /* PC[5] pin */
  3219. #define AFIO_EXTICR2_EXTI5_PD ((uint16_t)0x0030) /* PD[5] pin */
  3220. #define AFIO_EXTICR2_EXTI5_PE ((uint16_t)0x0040) /* PE[5] pin */
  3221. #define AFIO_EXTICR2_EXTI5_PF ((uint16_t)0x0050) /* PF[5] pin */
  3222. #define AFIO_EXTICR2_EXTI5_PG ((uint16_t)0x0060) /* PG[5] pin */
  3223. #define AFIO_EXTICR2_EXTI6_PA ((uint16_t)0x0000) /* PA[6] pin */
  3224. #define AFIO_EXTICR2_EXTI6_PB ((uint16_t)0x0100) /* PB[6] pin */
  3225. #define AFIO_EXTICR2_EXTI6_PC ((uint16_t)0x0200) /* PC[6] pin */
  3226. #define AFIO_EXTICR2_EXTI6_PD ((uint16_t)0x0300) /* PD[6] pin */
  3227. #define AFIO_EXTICR2_EXTI6_PE ((uint16_t)0x0400) /* PE[6] pin */
  3228. #define AFIO_EXTICR2_EXTI6_PF ((uint16_t)0x0500) /* PF[6] pin */
  3229. #define AFIO_EXTICR2_EXTI6_PG ((uint16_t)0x0600) /* PG[6] pin */
  3230. #define AFIO_EXTICR2_EXTI7_PA ((uint16_t)0x0000) /* PA[7] pin */
  3231. #define AFIO_EXTICR2_EXTI7_PB ((uint16_t)0x1000) /* PB[7] pin */
  3232. #define AFIO_EXTICR2_EXTI7_PC ((uint16_t)0x2000) /* PC[7] pin */
  3233. #define AFIO_EXTICR2_EXTI7_PD ((uint16_t)0x3000) /* PD[7] pin */
  3234. #define AFIO_EXTICR2_EXTI7_PE ((uint16_t)0x4000) /* PE[7] pin */
  3235. #define AFIO_EXTICR2_EXTI7_PF ((uint16_t)0x5000) /* PF[7] pin */
  3236. #define AFIO_EXTICR2_EXTI7_PG ((uint16_t)0x6000) /* PG[7] pin */
  3237. /***************** Bit definition for AFIO_EXTICR3 register *****************/
  3238. #define AFIO_EXTICR3_EXTI8 ((uint16_t)0x000F) /* EXTI 8 configuration */
  3239. #define AFIO_EXTICR3_EXTI9 ((uint16_t)0x00F0) /* EXTI 9 configuration */
  3240. #define AFIO_EXTICR3_EXTI10 ((uint16_t)0x0F00) /* EXTI 10 configuration */
  3241. #define AFIO_EXTICR3_EXTI11 ((uint16_t)0xF000) /* EXTI 11 configuration */
  3242. #define AFIO_EXTICR3_EXTI8_PA ((uint16_t)0x0000) /* PA[8] pin */
  3243. #define AFIO_EXTICR3_EXTI8_PB ((uint16_t)0x0001) /* PB[8] pin */
  3244. #define AFIO_EXTICR3_EXTI8_PC ((uint16_t)0x0002) /* PC[8] pin */
  3245. #define AFIO_EXTICR3_EXTI8_PD ((uint16_t)0x0003) /* PD[8] pin */
  3246. #define AFIO_EXTICR3_EXTI8_PE ((uint16_t)0x0004) /* PE[8] pin */
  3247. #define AFIO_EXTICR3_EXTI8_PF ((uint16_t)0x0005) /* PF[8] pin */
  3248. #define AFIO_EXTICR3_EXTI8_PG ((uint16_t)0x0006) /* PG[8] pin */
  3249. #define AFIO_EXTICR3_EXTI9_PA ((uint16_t)0x0000) /* PA[9] pin */
  3250. #define AFIO_EXTICR3_EXTI9_PB ((uint16_t)0x0010) /* PB[9] pin */
  3251. #define AFIO_EXTICR3_EXTI9_PC ((uint16_t)0x0020) /* PC[9] pin */
  3252. #define AFIO_EXTICR3_EXTI9_PD ((uint16_t)0x0030) /* PD[9] pin */
  3253. #define AFIO_EXTICR3_EXTI9_PE ((uint16_t)0x0040) /* PE[9] pin */
  3254. #define AFIO_EXTICR3_EXTI9_PF ((uint16_t)0x0050) /* PF[9] pin */
  3255. #define AFIO_EXTICR3_EXTI9_PG ((uint16_t)0x0060) /* PG[9] pin */
  3256. #define AFIO_EXTICR3_EXTI10_PA ((uint16_t)0x0000) /* PA[10] pin */
  3257. #define AFIO_EXTICR3_EXTI10_PB ((uint16_t)0x0100) /* PB[10] pin */
  3258. #define AFIO_EXTICR3_EXTI10_PC ((uint16_t)0x0200) /* PC[10] pin */
  3259. #define AFIO_EXTICR3_EXTI10_PD ((uint16_t)0x0300) /* PD[10] pin */
  3260. #define AFIO_EXTICR3_EXTI10_PE ((uint16_t)0x0400) /* PE[10] pin */
  3261. #define AFIO_EXTICR3_EXTI10_PF ((uint16_t)0x0500) /* PF[10] pin */
  3262. #define AFIO_EXTICR3_EXTI10_PG ((uint16_t)0x0600) /* PG[10] pin */
  3263. #define AFIO_EXTICR3_EXTI11_PA ((uint16_t)0x0000) /* PA[11] pin */
  3264. #define AFIO_EXTICR3_EXTI11_PB ((uint16_t)0x1000) /* PB[11] pin */
  3265. #define AFIO_EXTICR3_EXTI11_PC ((uint16_t)0x2000) /* PC[11] pin */
  3266. #define AFIO_EXTICR3_EXTI11_PD ((uint16_t)0x3000) /* PD[11] pin */
  3267. #define AFIO_EXTICR3_EXTI11_PE ((uint16_t)0x4000) /* PE[11] pin */
  3268. #define AFIO_EXTICR3_EXTI11_PF ((uint16_t)0x5000) /* PF[11] pin */
  3269. #define AFIO_EXTICR3_EXTI11_PG ((uint16_t)0x6000) /* PG[11] pin */
  3270. /***************** Bit definition for AFIO_EXTICR4 register *****************/
  3271. #define AFIO_EXTICR4_EXTI12 ((uint16_t)0x000F) /* EXTI 12 configuration */
  3272. #define AFIO_EXTICR4_EXTI13 ((uint16_t)0x00F0) /* EXTI 13 configuration */
  3273. #define AFIO_EXTICR4_EXTI14 ((uint16_t)0x0F00) /* EXTI 14 configuration */
  3274. #define AFIO_EXTICR4_EXTI15 ((uint16_t)0xF000) /* EXTI 15 configuration */
  3275. #define AFIO_EXTICR4_EXTI12_PA ((uint16_t)0x0000) /* PA[12] pin */
  3276. #define AFIO_EXTICR4_EXTI12_PB ((uint16_t)0x0001) /* PB[12] pin */
  3277. #define AFIO_EXTICR4_EXTI12_PC ((uint16_t)0x0002) /* PC[12] pin */
  3278. #define AFIO_EXTICR4_EXTI12_PD ((uint16_t)0x0003) /* PD[12] pin */
  3279. #define AFIO_EXTICR4_EXTI12_PE ((uint16_t)0x0004) /* PE[12] pin */
  3280. #define AFIO_EXTICR4_EXTI12_PF ((uint16_t)0x0005) /* PF[12] pin */
  3281. #define AFIO_EXTICR4_EXTI12_PG ((uint16_t)0x0006) /* PG[12] pin */
  3282. #define AFIO_EXTICR4_EXTI13_PA ((uint16_t)0x0000) /* PA[13] pin */
  3283. #define AFIO_EXTICR4_EXTI13_PB ((uint16_t)0x0010) /* PB[13] pin */
  3284. #define AFIO_EXTICR4_EXTI13_PC ((uint16_t)0x0020) /* PC[13] pin */
  3285. #define AFIO_EXTICR4_EXTI13_PD ((uint16_t)0x0030) /* PD[13] pin */
  3286. #define AFIO_EXTICR4_EXTI13_PE ((uint16_t)0x0040) /* PE[13] pin */
  3287. #define AFIO_EXTICR4_EXTI13_PF ((uint16_t)0x0050) /* PF[13] pin */
  3288. #define AFIO_EXTICR4_EXTI13_PG ((uint16_t)0x0060) /* PG[13] pin */
  3289. #define AFIO_EXTICR4_EXTI14_PA ((uint16_t)0x0000) /* PA[14] pin */
  3290. #define AFIO_EXTICR4_EXTI14_PB ((uint16_t)0x0100) /* PB[14] pin */
  3291. #define AFIO_EXTICR4_EXTI14_PC ((uint16_t)0x0200) /* PC[14] pin */
  3292. #define AFIO_EXTICR4_EXTI14_PD ((uint16_t)0x0300) /* PD[14] pin */
  3293. #define AFIO_EXTICR4_EXTI14_PE ((uint16_t)0x0400) /* PE[14] pin */
  3294. #define AFIO_EXTICR4_EXTI14_PF ((uint16_t)0x0500) /* PF[14] pin */
  3295. #define AFIO_EXTICR4_EXTI14_PG ((uint16_t)0x0600) /* PG[14] pin */
  3296. #define AFIO_EXTICR4_EXTI15_PA ((uint16_t)0x0000) /* PA[15] pin */
  3297. #define AFIO_EXTICR4_EXTI15_PB ((uint16_t)0x1000) /* PB[15] pin */
  3298. #define AFIO_EXTICR4_EXTI15_PC ((uint16_t)0x2000) /* PC[15] pin */
  3299. #define AFIO_EXTICR4_EXTI15_PD ((uint16_t)0x3000) /* PD[15] pin */
  3300. #define AFIO_EXTICR4_EXTI15_PE ((uint16_t)0x4000) /* PE[15] pin */
  3301. #define AFIO_EXTICR4_EXTI15_PF ((uint16_t)0x5000) /* PF[15] pin */
  3302. #define AFIO_EXTICR4_EXTI15_PG ((uint16_t)0x6000) /* PG[15] pin */
  3303. /******************************************************************************/
  3304. /* Independent WATCHDOG */
  3305. /******************************************************************************/
  3306. /******************* Bit definition for IWDG_CTLR register ********************/
  3307. #define IWDG_KEY ((uint16_t)0xFFFF) /* Key value (write only, read 0000h) */
  3308. /******************* Bit definition for IWDG_PSCR register ********************/
  3309. #define IWDG_PR ((uint8_t)0x07) /* PR[2:0] (Prescaler divider) */
  3310. #define IWDG_PR_0 ((uint8_t)0x01) /* Bit 0 */
  3311. #define IWDG_PR_1 ((uint8_t)0x02) /* Bit 1 */
  3312. #define IWDG_PR_2 ((uint8_t)0x04) /* Bit 2 */
  3313. /******************* Bit definition for IWDG_RLDR register *******************/
  3314. #define IWDG_RL ((uint16_t)0x0FFF) /* Watchdog counter reload value */
  3315. /******************* Bit definition for IWDG_STATR register ********************/
  3316. #define IWDG_PVU ((uint8_t)0x01) /* Watchdog prescaler value update */
  3317. #define IWDG_RVU ((uint8_t)0x02) /* Watchdog counter reload value update */
  3318. /******************************************************************************/
  3319. /* Inter-integrated Circuit Interface */
  3320. /******************************************************************************/
  3321. /******************* Bit definition for I2C_CTLR1 register ********************/
  3322. #define I2C_CTLR1_PE ((uint16_t)0x0001) /* Peripheral Enable */
  3323. #define I2C_CTLR1_SMBUS ((uint16_t)0x0002) /* SMBus Mode */
  3324. #define I2C_CTLR1_SMBTYPE ((uint16_t)0x0008) /* SMBus Type */
  3325. #define I2C_CTLR1_ENARP ((uint16_t)0x0010) /* ARP Enable */
  3326. #define I2C_CTLR1_ENPEC ((uint16_t)0x0020) /* PEC Enable */
  3327. #define I2C_CTLR1_ENGC ((uint16_t)0x0040) /* General Call Enable */
  3328. #define I2C_CTLR1_NOSTRETCH ((uint16_t)0x0080) /* Clock Stretching Disable (Slave mode) */
  3329. #define I2C_CTLR1_START ((uint16_t)0x0100) /* Start Generation */
  3330. #define I2C_CTLR1_STOP ((uint16_t)0x0200) /* Stop Generation */
  3331. #define I2C_CTLR1_ACK ((uint16_t)0x0400) /* Acknowledge Enable */
  3332. #define I2C_CTLR1_POS ((uint16_t)0x0800) /* Acknowledge/PEC Position (for data reception) */
  3333. #define I2C_CTLR1_PEC ((uint16_t)0x1000) /* Packet Error Checking */
  3334. #define I2C_CTLR1_ALERT ((uint16_t)0x2000) /* SMBus Alert */
  3335. #define I2C_CTLR1_SWRST ((uint16_t)0x8000) /* Software Reset */
  3336. /******************* Bit definition for I2C_CTLR2 register ********************/
  3337. #define I2C_CTLR2_FREQ ((uint16_t)0x003F) /* FREQ[5:0] bits (Peripheral Clock Frequency) */
  3338. #define I2C_CTLR2_FREQ_0 ((uint16_t)0x0001) /* Bit 0 */
  3339. #define I2C_CTLR2_FREQ_1 ((uint16_t)0x0002) /* Bit 1 */
  3340. #define I2C_CTLR2_FREQ_2 ((uint16_t)0x0004) /* Bit 2 */
  3341. #define I2C_CTLR2_FREQ_3 ((uint16_t)0x0008) /* Bit 3 */
  3342. #define I2C_CTLR2_FREQ_4 ((uint16_t)0x0010) /* Bit 4 */
  3343. #define I2C_CTLR2_FREQ_5 ((uint16_t)0x0020) /* Bit 5 */
  3344. #define I2C_CTLR2_ITERREN ((uint16_t)0x0100) /* Error Interrupt Enable */
  3345. #define I2C_CTLR2_ITEVTEN ((uint16_t)0x0200) /* Event Interrupt Enable */
  3346. #define I2C_CTLR2_ITBUFEN ((uint16_t)0x0400) /* Buffer Interrupt Enable */
  3347. #define I2C_CTLR2_DMAEN ((uint16_t)0x0800) /* DMA Requests Enable */
  3348. #define I2C_CTLR2_LAST ((uint16_t)0x1000) /* DMA Last Transfer */
  3349. /******************* Bit definition for I2C_OADDR1 register *******************/
  3350. #define I2C_OADDR1_ADD1_7 ((uint16_t)0x00FE) /* Interface Address */
  3351. #define I2C_OADDR1_ADD8_9 ((uint16_t)0x0300) /* Interface Address */
  3352. #define I2C_OADDR1_ADD0 ((uint16_t)0x0001) /* Bit 0 */
  3353. #define I2C_OADDR1_ADD1 ((uint16_t)0x0002) /* Bit 1 */
  3354. #define I2C_OADDR1_ADD2 ((uint16_t)0x0004) /* Bit 2 */
  3355. #define I2C_OADDR1_ADD3 ((uint16_t)0x0008) /* Bit 3 */
  3356. #define I2C_OADDR1_ADD4 ((uint16_t)0x0010) /* Bit 4 */
  3357. #define I2C_OADDR1_ADD5 ((uint16_t)0x0020) /* Bit 5 */
  3358. #define I2C_OADDR1_ADD6 ((uint16_t)0x0040) /* Bit 6 */
  3359. #define I2C_OADDR1_ADD7 ((uint16_t)0x0080) /* Bit 7 */
  3360. #define I2C_OADDR1_ADD8 ((uint16_t)0x0100) /* Bit 8 */
  3361. #define I2C_OADDR1_ADD9 ((uint16_t)0x0200) /* Bit 9 */
  3362. #define I2C_OADDR1_ADDMODE ((uint16_t)0x8000) /* Addressing Mode (Slave mode) */
  3363. /******************* Bit definition for I2C_OADDR2 register *******************/
  3364. #define I2C_OADDR2_ENDUAL ((uint8_t)0x01) /* Dual addressing mode enable */
  3365. #define I2C_OADDR2_ADD2 ((uint8_t)0xFE) /* Interface address */
  3366. /******************** Bit definition for I2C_DATAR register ********************/
  3367. #define I2C_DR_DATAR ((uint8_t)0xFF) /* 8-bit Data Register */
  3368. /******************* Bit definition for I2C_STAR1 register ********************/
  3369. #define I2C_STAR1_SB ((uint16_t)0x0001) /* Start Bit (Master mode) */
  3370. #define I2C_STAR1_ADDR ((uint16_t)0x0002) /* Address sent (master mode)/matched (slave mode) */
  3371. #define I2C_STAR1_BTF ((uint16_t)0x0004) /* Byte Transfer Finished */
  3372. #define I2C_STAR1_ADD10 ((uint16_t)0x0008) /* 10-bit header sent (Master mode) */
  3373. #define I2C_STAR1_STOPF ((uint16_t)0x0010) /* Stop detection (Slave mode) */
  3374. #define I2C_STAR1_RXNE ((uint16_t)0x0040) /* Data Register not Empty (receivers) */
  3375. #define I2C_STAR1_TXE ((uint16_t)0x0080) /* Data Register Empty (transmitters) */
  3376. #define I2C_STAR1_BERR ((uint16_t)0x0100) /* Bus Error */
  3377. #define I2C_STAR1_ARLO ((uint16_t)0x0200) /* Arbitration Lost (master mode) */
  3378. #define I2C_STAR1_AF ((uint16_t)0x0400) /* Acknowledge Failure */
  3379. #define I2C_STAR1_OVR ((uint16_t)0x0800) /* Overrun/Underrun */
  3380. #define I2C_STAR1_PECERR ((uint16_t)0x1000) /* PEC Error in reception */
  3381. #define I2C_STAR1_TIMEOUT ((uint16_t)0x4000) /* Timeout or Tlow Error */
  3382. #define I2C_STAR1_SMBALERT ((uint16_t)0x8000) /* SMBus Alert */
  3383. /******************* Bit definition for I2C_STAR2 register ********************/
  3384. #define I2C_STAR2_MSL ((uint16_t)0x0001) /* Master/Slave */
  3385. #define I2C_STAR2_BUSY ((uint16_t)0x0002) /* Bus Busy */
  3386. #define I2C_STAR2_TRA ((uint16_t)0x0004) /* Transmitter/Receiver */
  3387. #define I2C_STAR2_GENCALL ((uint16_t)0x0010) /* General Call Address (Slave mode) */
  3388. #define I2C_STAR2_SMBDEFAULT ((uint16_t)0x0020) /* SMBus Device Default Address (Slave mode) */
  3389. #define I2C_STAR2_SMBHOST ((uint16_t)0x0040) /* SMBus Host Header (Slave mode) */
  3390. #define I2C_STAR2_DUALF ((uint16_t)0x0080) /* Dual Flag (Slave mode) */
  3391. #define I2C_STAR2_PEC ((uint16_t)0xFF00) /* Packet Error Checking Register */
  3392. /******************* Bit definition for I2C_CKCFGR register ********************/
  3393. #define I2C_CKCFGR_CCR ((uint16_t)0x0FFF) /* Clock Control Register in Fast/Standard mode (Master mode) */
  3394. #define I2C_CKCFGR_DUTY ((uint16_t)0x4000) /* Fast Mode Duty Cycle */
  3395. #define I2C_CKCFGR_FS ((uint16_t)0x8000) /* I2C Master Mode Selection */
  3396. /****************** Bit definition for I2C_RTR register *******************/
  3397. #define I2C_RTR_TRISE ((uint8_t)0x3F) /* Maximum Rise Time in Fast/Standard mode (Master mode) */
  3398. /******************************************************************************/
  3399. /* Power Control */
  3400. /******************************************************************************/
  3401. /******************** Bit definition for PWR_CTLR register ********************/
  3402. #define PWR_CTLR_LPDS ((uint16_t)0x0001) /* Low-Power Deepsleep */
  3403. #define PWR_CTLR_PDDS ((uint16_t)0x0002) /* Power Down Deepsleep */
  3404. #define PWR_CTLR_CWUF ((uint16_t)0x0004) /* Clear Wakeup Flag */
  3405. #define PWR_CTLR_CSBF ((uint16_t)0x0008) /* Clear Standby Flag */
  3406. #define PWR_CTLR_PVDE ((uint16_t)0x0010) /* Power Voltage Detector Enable */
  3407. #define PWR_CTLR_PLS ((uint16_t)0x00E0) /* PLS[2:0] bits (PVD Level Selection) */
  3408. #define PWR_CTLR_PLS_0 ((uint16_t)0x0020) /* Bit 0 */
  3409. #define PWR_CTLR_PLS_1 ((uint16_t)0x0040) /* Bit 1 */
  3410. #define PWR_CTLR_PLS_2 ((uint16_t)0x0080) /* Bit 2 */
  3411. #define PWR_CTLR_PLS_MODE0 ((uint16_t)0x0000)
  3412. #define PWR_CTLR_PLS_MODE1 ((uint16_t)0x0020)
  3413. #define PWR_CTLR_PLS_MODE2 ((uint16_t)0x0040)
  3414. #define PWR_CTLR_PLS_MODE3 ((uint16_t)0x0060)
  3415. #define PWR_CTLR_PLS_MODE4 ((uint16_t)0x0080)
  3416. #define PWR_CTLR_PLS_MODE5 ((uint16_t)0x00A0)
  3417. #define PWR_CTLR_PLS_MODE6 ((uint16_t)0x00C0)
  3418. #define PWR_CTLR_PLS_MODE7 ((uint16_t)0x00E0)
  3419. #define PWR_CTLR_PLS_2V2 PWR_CTLR_PLS_MODE0
  3420. #define PWR_CTLR_PLS_2V3 PWR_CTLR_PLS_MODE1
  3421. #define PWR_CTLR_PLS_2V4 PWR_CTLR_PLS_MODE2
  3422. #define PWR_CTLR_PLS_2V5 PWR_CTLR_PLS_MODE3
  3423. #define PWR_CTLR_PLS_2V6 PWR_CTLR_PLS_MODE4
  3424. #define PWR_CTLR_PLS_2V7 PWR_CTLR_PLS_MODE5
  3425. #define PWR_CTLR_PLS_2V8 PWR_CTLR_PLS_MODE6
  3426. #define PWR_CTLR_PLS_2V9 PWR_CTLR_PLS_MODE7
  3427. #define PWR_CTLR_DBP ((uint16_t)0x0100) /* Disable Backup Domain write protection */
  3428. /******************* Bit definition for PWR_CSR register ********************/
  3429. #define PWR_CSR_WUF ((uint16_t)0x0001) /* Wakeup Flag */
  3430. #define PWR_CSR_SBF ((uint16_t)0x0002) /* Standby Flag */
  3431. #define PWR_CSR_PVDO ((uint16_t)0x0004) /* PVD Output */
  3432. #define PWR_CSR_EWUP ((uint16_t)0x0100) /* Enable WKUP pin */
  3433. /******************************************************************************/
  3434. /* Reset and Clock Control */
  3435. /******************************************************************************/
  3436. /******************** Bit definition for RCC_CTLR register ********************/
  3437. #define RCC_HSION ((uint32_t)0x00000001) /* Internal High Speed clock enable */
  3438. #define RCC_HSIRDY ((uint32_t)0x00000002) /* Internal High Speed clock ready flag */
  3439. #define RCC_HSITRIM ((uint32_t)0x000000F8) /* Internal High Speed clock trimming */
  3440. #define RCC_HSICAL ((uint32_t)0x0000FF00) /* Internal High Speed clock Calibration */
  3441. #define RCC_HSEON ((uint32_t)0x00010000) /* External High Speed clock enable */
  3442. #define RCC_HSERDY ((uint32_t)0x00020000) /* External High Speed clock ready flag */
  3443. #define RCC_HSEBYP ((uint32_t)0x00040000) /* External High Speed clock Bypass */
  3444. #define RCC_CSSON ((uint32_t)0x00080000) /* Clock Security System enable */
  3445. #define RCC_PLLON ((uint32_t)0x01000000) /* PLL enable */
  3446. #define RCC_PLLRDY ((uint32_t)0x02000000) /* PLL clock ready flag */
  3447. /******************* Bit definition for RCC_CFGR0 register *******************/
  3448. #define RCC_SW ((uint32_t)0x00000003) /* SW[1:0] bits (System clock Switch) */
  3449. #define RCC_SW_0 ((uint32_t)0x00000001) /* Bit 0 */
  3450. #define RCC_SW_1 ((uint32_t)0x00000002) /* Bit 1 */
  3451. #define RCC_SW_HSI ((uint32_t)0x00000000) /* HSI selected as system clock */
  3452. #define RCC_SW_HSE ((uint32_t)0x00000001) /* HSE selected as system clock */
  3453. #define RCC_SW_PLL ((uint32_t)0x00000002) /* PLL selected as system clock */
  3454. #define RCC_SWS ((uint32_t)0x0000000C) /* SWS[1:0] bits (System Clock Switch Status) */
  3455. #define RCC_SWS_0 ((uint32_t)0x00000004) /* Bit 0 */
  3456. #define RCC_SWS_1 ((uint32_t)0x00000008) /* Bit 1 */
  3457. #define RCC_SWS_HSI ((uint32_t)0x00000000) /* HSI oscillator used as system clock */
  3458. #define RCC_SWS_HSE ((uint32_t)0x00000004) /* HSE oscillator used as system clock */
  3459. #define RCC_SWS_PLL ((uint32_t)0x00000008) /* PLL used as system clock */
  3460. #define RCC_HPRE ((uint32_t)0x000000F0) /* HPRE[3:0] bits (AHB prescaler) */
  3461. #define RCC_HPRE_0 ((uint32_t)0x00000010) /* Bit 0 */
  3462. #define RCC_HPRE_1 ((uint32_t)0x00000020) /* Bit 1 */
  3463. #define RCC_HPRE_2 ((uint32_t)0x00000040) /* Bit 2 */
  3464. #define RCC_HPRE_3 ((uint32_t)0x00000080) /* Bit 3 */
  3465. #define RCC_HPRE_DIV1 ((uint32_t)0x00000000) /* SYSCLK not divided */
  3466. #define RCC_HPRE_DIV2 ((uint32_t)0x00000080) /* SYSCLK divided by 2 */
  3467. #define RCC_HPRE_DIV4 ((uint32_t)0x00000090) /* SYSCLK divided by 4 */
  3468. #define RCC_HPRE_DIV8 ((uint32_t)0x000000A0) /* SYSCLK divided by 8 */
  3469. #define RCC_HPRE_DIV16 ((uint32_t)0x000000B0) /* SYSCLK divided by 16 */
  3470. #define RCC_HPRE_DIV64 ((uint32_t)0x000000C0) /* SYSCLK divided by 64 */
  3471. #define RCC_HPRE_DIV128 ((uint32_t)0x000000D0) /* SYSCLK divided by 128 */
  3472. #define RCC_HPRE_DIV256 ((uint32_t)0x000000E0) /* SYSCLK divided by 256 */
  3473. #define RCC_HPRE_DIV512 ((uint32_t)0x000000F0) /* SYSCLK divided by 512 */
  3474. #define RCC_PPRE1 ((uint32_t)0x00000700) /* PRE1[2:0] bits (APB1 prescaler) */
  3475. #define RCC_PPRE1_0 ((uint32_t)0x00000100) /* Bit 0 */
  3476. #define RCC_PPRE1_1 ((uint32_t)0x00000200) /* Bit 1 */
  3477. #define RCC_PPRE1_2 ((uint32_t)0x00000400) /* Bit 2 */
  3478. #define RCC_PPRE1_DIV1 ((uint32_t)0x00000000) /* PPRE1 not divided */
  3479. #define RCC_PPRE1_DIV2 ((uint32_t)0x00000400) /* PPRE1 divided by 2 */
  3480. #define RCC_PPRE1_DIV4 ((uint32_t)0x00000500) /* PPRE1 divided by 4 */
  3481. #define RCC_PPRE1_DIV8 ((uint32_t)0x00000600) /* PPRE1 divided by 8 */
  3482. #define RCC_PPRE1_DIV16 ((uint32_t)0x00000700) /* PPRE1 divided by 16 */
  3483. #define RCC_PPRE2 ((uint32_t)0x00003800) /* PRE2[2:0] bits (APB2 prescaler) */
  3484. #define RCC_PPRE2_0 ((uint32_t)0x00000800) /* Bit 0 */
  3485. #define RCC_PPRE2_1 ((uint32_t)0x00001000) /* Bit 1 */
  3486. #define RCC_PPRE2_2 ((uint32_t)0x00002000) /* Bit 2 */
  3487. #define RCC_PPRE2_DIV1 ((uint32_t)0x00000000) /* PPRE2 not divided */
  3488. #define RCC_PPRE2_DIV2 ((uint32_t)0x00002000) /* PPRE2 divided by 2 */
  3489. #define RCC_PPRE2_DIV4 ((uint32_t)0x00002800) /* PPRE2 divided by 4 */
  3490. #define RCC_PPRE2_DIV8 ((uint32_t)0x00003000) /* PPRE2 divided by 8 */
  3491. #define RCC_PPRE2_DIV16 ((uint32_t)0x00003800) /* PPRE2 divided by 16 */
  3492. #define RCC_ADCPRE ((uint32_t)0x0000C000) /* ADCPRE[1:0] bits (ADC prescaler) */
  3493. #define RCC_ADCPRE_0 ((uint32_t)0x00004000) /* Bit 0 */
  3494. #define RCC_ADCPRE_1 ((uint32_t)0x00008000) /* Bit 1 */
  3495. #define RCC_ADCPRE_DIV2 ((uint32_t)0x00000000) /* ADCPRE divided by 2 */
  3496. #define RCC_ADCPRE_DIV4 ((uint32_t)0x00004000) /* ADCPRE divided by 4 */
  3497. #define RCC_ADCPRE_DIV6 ((uint32_t)0x00008000) /* ADCPRE divided by 6 */
  3498. #define RCC_ADCPRE_DIV8 ((uint32_t)0x0000C000) /* ADCPRE divided by 8 */
  3499. #define RCC_PLLSRC ((uint32_t)0x00010000) /* PLL entry clock source */
  3500. #define RCC_PLLXTPRE ((uint32_t)0x00020000) /* HSE divider for PLL entry */
  3501. #define RCC_PLLMULL ((uint32_t)0x003C0000) /* PLLMUL[3:0] bits (PLL multiplication factor) */
  3502. #define RCC_PLLMULL_0 ((uint32_t)0x00040000) /* Bit 0 */
  3503. #define RCC_PLLMULL_1 ((uint32_t)0x00080000) /* Bit 1 */
  3504. #define RCC_PLLMULL_2 ((uint32_t)0x00100000) /* Bit 2 */
  3505. #define RCC_PLLMULL_3 ((uint32_t)0x00200000) /* Bit 3 */
  3506. #define RCC_PLLSRC_HSI_Div2 ((uint32_t)0x00000000) /* HSI clock divided by 2 selected as PLL entry clock source */
  3507. #define RCC_PLLSRC_HSE ((uint32_t)0x00010000) /* HSE clock selected as PLL entry clock source */
  3508. #define RCC_PLLXTPRE_HSE ((uint32_t)0x00000000) /* HSE clock not divided for PLL entry */
  3509. #define RCC_PLLXTPRE_HSE_Div2 ((uint32_t)0x00020000) /* HSE clock divided by 2 for PLL entry */
  3510. /* for other CH32V20x */
  3511. #define RCC_PLLMULL2 ((uint32_t)0x00000000) /* PLL input clock*2 */
  3512. #define RCC_PLLMULL3 ((uint32_t)0x00040000) /* PLL input clock*3 */
  3513. #define RCC_PLLMULL4 ((uint32_t)0x00080000) /* PLL input clock*4 */
  3514. #define RCC_PLLMULL5 ((uint32_t)0x000C0000) /* PLL input clock*5 */
  3515. #define RCC_PLLMULL6 ((uint32_t)0x00100000) /* PLL input clock*6 */
  3516. #define RCC_PLLMULL7 ((uint32_t)0x00140000) /* PLL input clock*7 */
  3517. #define RCC_PLLMULL8 ((uint32_t)0x00180000) /* PLL input clock*8 */
  3518. #define RCC_PLLMULL9 ((uint32_t)0x001C0000) /* PLL input clock*9 */
  3519. #define RCC_PLLMULL10 ((uint32_t)0x00200000) /* PLL input clock10 */
  3520. #define RCC_PLLMULL11 ((uint32_t)0x00240000) /* PLL input clock*11 */
  3521. #define RCC_PLLMULL12 ((uint32_t)0x00280000) /* PLL input clock*12 */
  3522. #define RCC_PLLMULL13 ((uint32_t)0x002C0000) /* PLL input clock*13 */
  3523. #define RCC_PLLMULL14 ((uint32_t)0x00300000) /* PLL input clock*14 */
  3524. #define RCC_PLLMULL15 ((uint32_t)0x00340000) /* PLL input clock*15 */
  3525. #define RCC_PLLMULL16 ((uint32_t)0x00380000) /* PLL input clock*16 */
  3526. #define RCC_PLLMULL18 ((uint32_t)0x003C0000) /* PLL input clock*18 */
  3527. #define RCC_USBPRE ((uint32_t)0x00400000) /* USB Device prescaler */
  3528. #define RCC_CFGR0_MCO ((uint32_t)0x07000000) /* MCO[2:0] bits (Microcontroller Clock Output) */
  3529. #define RCC_MCO_0 ((uint32_t)0x01000000) /* Bit 0 */
  3530. #define RCC_MCO_1 ((uint32_t)0x02000000) /* Bit 1 */
  3531. #define RCC_MCO_2 ((uint32_t)0x04000000) /* Bit 2 */
  3532. #define RCC_MCO_NOCLOCK ((uint32_t)0x00000000) /* No clock */
  3533. #define RCC_CFGR0_MCO_SYSCLK ((uint32_t)0x04000000) /* System clock selected as MCO source */
  3534. #define RCC_CFGR0_MCO_HSI ((uint32_t)0x05000000) /* HSI clock selected as MCO source */
  3535. #define RCC_CFGR0_MCO_HSE ((uint32_t)0x06000000) /* HSE clock selected as MCO source */
  3536. #define RCC_CFGR0_MCO_PLL ((uint32_t)0x07000000) /* PLL clock divided by 2 selected as MCO source */
  3537. /******************* Bit definition for RCC_INTR register ********************/
  3538. #define RCC_LSIRDYF ((uint32_t)0x00000001) /* LSI Ready Interrupt flag */
  3539. #define RCC_LSERDYF ((uint32_t)0x00000002) /* LSE Ready Interrupt flag */
  3540. #define RCC_HSIRDYF ((uint32_t)0x00000004) /* HSI Ready Interrupt flag */
  3541. #define RCC_HSERDYF ((uint32_t)0x00000008) /* HSE Ready Interrupt flag */
  3542. #define RCC_PLLRDYF ((uint32_t)0x00000010) /* PLL Ready Interrupt flag */
  3543. #define RCC_CSSF ((uint32_t)0x00000080) /* Clock Security System Interrupt flag */
  3544. #define RCC_LSIRDYIE ((uint32_t)0x00000100) /* LSI Ready Interrupt Enable */
  3545. #define RCC_LSERDYIE ((uint32_t)0x00000200) /* LSE Ready Interrupt Enable */
  3546. #define RCC_HSIRDYIE ((uint32_t)0x00000400) /* HSI Ready Interrupt Enable */
  3547. #define RCC_HSERDYIE ((uint32_t)0x00000800) /* HSE Ready Interrupt Enable */
  3548. #define RCC_PLLRDYIE ((uint32_t)0x00001000) /* PLL Ready Interrupt Enable */
  3549. #define RCC_LSIRDYC ((uint32_t)0x00010000) /* LSI Ready Interrupt Clear */
  3550. #define RCC_LSERDYC ((uint32_t)0x00020000) /* LSE Ready Interrupt Clear */
  3551. #define RCC_HSIRDYC ((uint32_t)0x00040000) /* HSI Ready Interrupt Clear */
  3552. #define RCC_HSERDYC ((uint32_t)0x00080000) /* HSE Ready Interrupt Clear */
  3553. #define RCC_PLLRDYC ((uint32_t)0x00100000) /* PLL Ready Interrupt Clear */
  3554. #define RCC_CSSC ((uint32_t)0x00800000) /* Clock Security System Interrupt Clear */
  3555. /***************** Bit definition for RCC_APB2PRSTR register *****************/
  3556. #define RCC_AFIORST ((uint32_t)0x00000001) /* Alternate Function I/O reset */
  3557. #define RCC_IOPARST ((uint32_t)0x00000004) /* I/O port A reset */
  3558. #define RCC_IOPBRST ((uint32_t)0x00000008) /* I/O port B reset */
  3559. #define RCC_IOPCRST ((uint32_t)0x00000010) /* I/O port C reset */
  3560. #define RCC_IOPDRST ((uint32_t)0x00000020) /* I/O port D reset */
  3561. #define RCC_ADC1RST ((uint32_t)0x00000200) /* ADC 1 interface reset */
  3562. #define RCC_ADC2RST ((uint32_t)0x00000400) /* ADC 2 interface reset */
  3563. #define RCC_TIM1RST ((uint32_t)0x00000800) /* TIM1 Timer reset */
  3564. #define RCC_SPI1RST ((uint32_t)0x00001000) /* SPI 1 reset */
  3565. #define RCC_USART1RST ((uint32_t)0x00004000) /* USART1 reset */
  3566. #define RCC_IOPERST ((uint32_t)0x00000040) /* I/O port E reset */
  3567. /***************** Bit definition for RCC_APB1PRSTR register *****************/
  3568. #define RCC_TIM2RST ((uint32_t)0x00000001) /* Timer 2 reset */
  3569. #define RCC_TIM3RST ((uint32_t)0x00000002) /* Timer 3 reset */
  3570. #define RCC_WWDGRST ((uint32_t)0x00000800) /* Window Watchdog reset */
  3571. #define RCC_USART2RST ((uint32_t)0x00020000) /* USART 2 reset */
  3572. #define RCC_I2C1RST ((uint32_t)0x00200000) /* I2C 1 reset */
  3573. #define RCC_CAN1RST ((uint32_t)0x02000000) /* CAN1 reset */
  3574. #define RCC_BKPRST ((uint32_t)0x08000000) /* Backup interface reset */
  3575. #define RCC_PWRRST ((uint32_t)0x10000000) /* Power interface reset */
  3576. #define RCC_TIM4RST ((uint32_t)0x00000004) /* Timer 4 reset */
  3577. #define RCC_SPI2RST ((uint32_t)0x00004000) /* SPI 2 reset */
  3578. #define RCC_USART3RST ((uint32_t)0x00040000) /* USART 3 reset */
  3579. #define RCC_I2C2RST ((uint32_t)0x00400000) /* I2C 2 reset */
  3580. #define RCC_USBRST ((uint32_t)0x00800000) /* USB Device reset */
  3581. /****************** Bit definition for RCC_AHBPCENR register ******************/
  3582. #define RCC_DMA1EN ((uint16_t)0x0001) /* DMA1 clock enable */
  3583. #define RCC_SRAMEN ((uint16_t)0x0004) /* SRAM interface clock enable */
  3584. #define RCC_FLITFEN ((uint16_t)0x0010) /* FLITF clock enable */
  3585. #define RCC_CRCEN ((uint16_t)0x0040) /* CRC clock enable */
  3586. #define RCC_USBFS ((uint16_t)0x1000)
  3587. #define RCC_USBHD RCC_USBFS
  3588. /****************** Bit definition for RCC_APB2PCENR register *****************/
  3589. #define RCC_AFIOEN ((uint32_t)0x00000001) /* Alternate Function I/O clock enable */
  3590. #define RCC_IOPAEN ((uint32_t)0x00000004) /* I/O port A clock enable */
  3591. #define RCC_IOPBEN ((uint32_t)0x00000008) /* I/O port B clock enable */
  3592. #define RCC_IOPCEN ((uint32_t)0x00000010) /* I/O port C clock enable */
  3593. #define RCC_IOPDEN ((uint32_t)0x00000020) /* I/O port D clock enable */
  3594. #define RCC_ADC1EN ((uint32_t)0x00000200) /* ADC 1 interface clock enable */
  3595. #define RCC_ADC2EN ((uint32_t)0x00000400) /* ADC 2 interface clock enable */
  3596. #define RCC_TIM1EN ((uint32_t)0x00000800) /* TIM1 Timer clock enable */
  3597. #define RCC_SPI1EN ((uint32_t)0x00001000) /* SPI 1 clock enable */
  3598. #define RCC_USART1EN ((uint32_t)0x00004000) /* USART1 clock enable */
  3599. /***************** Bit definition for RCC_APB1PCENR register ******************/
  3600. #define RCC_TIM2EN ((uint32_t)0x00000001) /* Timer 2 clock enabled*/
  3601. #define RCC_TIM3EN ((uint32_t)0x00000002) /* Timer 3 clock enable */
  3602. #define RCC_WWDGEN ((uint32_t)0x00000800) /* Window Watchdog clock enable */
  3603. #define RCC_USART2EN ((uint32_t)0x00020000) /* USART 2 clock enable */
  3604. #define RCC_I2C1EN ((uint32_t)0x00200000) /* I2C 1 clock enable */
  3605. #define RCC_BKPEN ((uint32_t)0x08000000) /* Backup interface clock enable */
  3606. #define RCC_PWREN ((uint32_t)0x10000000) /* Power interface clock enable */
  3607. #define RCC_USBEN ((uint32_t)0x00800000) /* USB Device clock enable */
  3608. /******************* Bit definition for RCC_BDCTLR register *******************/
  3609. #define RCC_LSEON ((uint32_t)0x00000001) /* External Low Speed oscillator enable */
  3610. #define RCC_LSERDY ((uint32_t)0x00000002) /* External Low Speed oscillator Ready */
  3611. #define RCC_LSEBYP ((uint32_t)0x00000004) /* External Low Speed oscillator Bypass */
  3612. #define RCC_RTCSEL ((uint32_t)0x00000300) /* RTCSEL[1:0] bits (RTC clock source selection) */
  3613. #define RCC_RTCSEL_0 ((uint32_t)0x00000100) /* Bit 0 */
  3614. #define RCC_RTCSEL_1 ((uint32_t)0x00000200) /* Bit 1 */
  3615. #define RCC_RTCSEL_NOCLOCK ((uint32_t)0x00000000) /* No clock */
  3616. #define RCC_RTCSEL_LSE ((uint32_t)0x00000100) /* LSE oscillator clock used as RTC clock */
  3617. #define RCC_RTCSEL_LSI ((uint32_t)0x00000200) /* LSI oscillator clock used as RTC clock */
  3618. #define RCC_RTCSEL_HSE ((uint32_t)0x00000300) /* HSE oscillator clock divided by 128 used as RTC clock */
  3619. #define RCC_RTCEN ((uint32_t)0x00008000) /* RTC clock enable */
  3620. #define RCC_BDRST ((uint32_t)0x00010000) /* Backup domain software reset */
  3621. /******************* Bit definition for RCC_RSTSCKR register ********************/
  3622. #define RCC_LSION ((uint32_t)0x00000001) /* Internal Low Speed oscillator enable */
  3623. #define RCC_LSIRDY ((uint32_t)0x00000002) /* Internal Low Speed oscillator Ready */
  3624. #define RCC_RMVF ((uint32_t)0x01000000) /* Remove reset flag */
  3625. #define RCC_PINRSTF ((uint32_t)0x04000000) /* PIN reset flag */
  3626. #define RCC_PORRSTF ((uint32_t)0x08000000) /* POR/PDR reset flag */
  3627. #define RCC_SFTRSTF ((uint32_t)0x10000000) /* Software Reset flag */
  3628. #define RCC_IWDGRSTF ((uint32_t)0x20000000) /* Independent Watchdog reset flag */
  3629. #define RCC_WWDGRSTF ((uint32_t)0x40000000) /* Window watchdog reset flag */
  3630. #define RCC_LPWRRSTF ((uint32_t)0x80000000) /* Low-Power reset flag */
  3631. /******************************************************************************/
  3632. /* Real-Time Clock */
  3633. /******************************************************************************/
  3634. /******************* Bit definition for RTC_CTLRH register ********************/
  3635. #define RTC_CTLRH_SECIE ((uint8_t)0x01) /* Second Interrupt Enable */
  3636. #define RTC_CTLRH_ALRIE ((uint8_t)0x02) /* Alarm Interrupt Enable */
  3637. #define RTC_CTLRH_OWIE ((uint8_t)0x04) /* OverfloW Interrupt Enable */
  3638. /******************* Bit definition for RTC_CTLRL register ********************/
  3639. #define RTC_CTLRL_SECF ((uint8_t)0x01) /* Second Flag */
  3640. #define RTC_CTLRL_ALRF ((uint8_t)0x02) /* Alarm Flag */
  3641. #define RTC_CTLRL_OWF ((uint8_t)0x04) /* OverfloW Flag */
  3642. #define RTC_CTLRL_RSF ((uint8_t)0x08) /* Registers Synchronized Flag */
  3643. #define RTC_CTLRL_CNF ((uint8_t)0x10) /* Configuration Flag */
  3644. #define RTC_CTLRL_RTOFF ((uint8_t)0x20) /* RTC operation OFF */
  3645. /******************* Bit definition for RTC_PSCH register *******************/
  3646. #define RTC_PSCH_PRL ((uint16_t)0x000F) /* RTC Prescaler Reload Value High */
  3647. /******************* Bit definition for RTC_PRLL register *******************/
  3648. #define RTC_PSCL_PRL ((uint16_t)0xFFFF) /* RTC Prescaler Reload Value Low */
  3649. /******************* Bit definition for RTC_DIVH register *******************/
  3650. #define RTC_DIVH_RTC_DIV ((uint16_t)0x000F) /* RTC Clock Divider High */
  3651. /******************* Bit definition for RTC_DIVL register *******************/
  3652. #define RTC_DIVL_RTC_DIV ((uint16_t)0xFFFF) /* RTC Clock Divider Low */
  3653. /******************* Bit definition for RTC_CNTH register *******************/
  3654. #define RTC_CNTH_RTC_CNT ((uint16_t)0xFFFF) /* RTC Counter High */
  3655. /******************* Bit definition for RTC_CNTL register *******************/
  3656. #define RTC_CNTL_RTC_CNT ((uint16_t)0xFFFF) /* RTC Counter Low */
  3657. /******************* Bit definition for RTC_ALRMH register *******************/
  3658. #define RTC_ALRMH_RTC_ALRM ((uint16_t)0xFFFF) /* RTC Alarm High */
  3659. /******************* Bit definition for RTC_ALRML register *******************/
  3660. #define RTC_ALRML_RTC_ALRM ((uint16_t)0xFFFF) /* RTC Alarm Low */
  3661. /******************************************************************************/
  3662. /* Serial Peripheral Interface */
  3663. /******************************************************************************/
  3664. /******************* Bit definition for SPI_CTLR1 register ********************/
  3665. #define SPI_CTLR1_CPHA ((uint16_t)0x0001) /* Clock Phase */
  3666. #define SPI_CTLR1_CPOL ((uint16_t)0x0002) /* Clock Polarity */
  3667. #define SPI_CTLR1_MSTR ((uint16_t)0x0004) /* Master Selection */
  3668. #define SPI_CTLR1_BR ((uint16_t)0x0038) /* BR[2:0] bits (Baud Rate Control) */
  3669. #define SPI_CTLR1_BR_0 ((uint16_t)0x0008) /* Bit 0 */
  3670. #define SPI_CTLR1_BR_1 ((uint16_t)0x0010) /* Bit 1 */
  3671. #define SPI_CTLR1_BR_2 ((uint16_t)0x0020) /* Bit 2 */
  3672. #define SPI_CTLR1_SPE ((uint16_t)0x0040) /* SPI Enable */
  3673. #define SPI_CTLR1_LSBFIRST ((uint16_t)0x0080) /* Frame Format */
  3674. #define SPI_CTLR1_SSI ((uint16_t)0x0100) /* Internal slave select */
  3675. #define SPI_CTLR1_SSM ((uint16_t)0x0200) /* Software slave management */
  3676. #define SPI_CTLR1_RXONLY ((uint16_t)0x0400) /* Receive only */
  3677. #define SPI_CTLR1_DFF ((uint16_t)0x0800) /* Data Frame Format */
  3678. #define SPI_CTLR1_CRCNEXT ((uint16_t)0x1000) /* Transmit CRC next */
  3679. #define SPI_CTLR1_CRCEN ((uint16_t)0x2000) /* Hardware CRC calculation enable */
  3680. #define SPI_CTLR1_BIDIOE ((uint16_t)0x4000) /* Output enable in bidirectional mode */
  3681. #define SPI_CTLR1_BIDIMODE ((uint16_t)0x8000) /* Bidirectional data mode enable */
  3682. /******************* Bit definition for SPI_CTLR2 register ********************/
  3683. #define SPI_CTLR2_RXDMAEN ((uint8_t)0x01) /* Rx Buffer DMA Enable */
  3684. #define SPI_CTLR2_TXDMAEN ((uint8_t)0x02) /* Tx Buffer DMA Enable */
  3685. #define SPI_CTLR2_SSOE ((uint8_t)0x04) /* SS Output Enable */
  3686. #define SPI_CTLR2_ERRIE ((uint8_t)0x20) /* Error Interrupt Enable */
  3687. #define SPI_CTLR2_RXNEIE ((uint8_t)0x40) /* RX buffer Not Empty Interrupt Enable */
  3688. #define SPI_CTLR2_TXEIE ((uint8_t)0x80) /* Tx buffer Empty Interrupt Enable */
  3689. /******************** Bit definition for SPI_STATR register ********************/
  3690. #define SPI_STATR_RXNE ((uint8_t)0x01) /* Receive buffer Not Empty */
  3691. #define SPI_STATR_TXE ((uint8_t)0x02) /* Transmit buffer Empty */
  3692. #define SPI_STATR_CHSIDE ((uint8_t)0x04) /* Channel side */
  3693. #define SPI_STATR_UDR ((uint8_t)0x08) /* Underrun flag */
  3694. #define SPI_STATR_CRCERR ((uint8_t)0x10) /* CRC Error flag */
  3695. #define SPI_STATR_MODF ((uint8_t)0x20) /* Mode fault */
  3696. #define SPI_STATR_OVR ((uint8_t)0x40) /* Overrun flag */
  3697. #define SPI_STATR_BSY ((uint8_t)0x80) /* Busy flag */
  3698. /******************** Bit definition for SPI_DATAR register ********************/
  3699. #define SPI_DATAR_DR ((uint16_t)0xFFFF) /* Data Register */
  3700. /******************* Bit definition for SPI_CRCR register ******************/
  3701. #define SPI_CRCR_CRCPOLY ((uint16_t)0xFFFF) /* CRC polynomial register */
  3702. /****************** Bit definition for SPI_RCRCR register ******************/
  3703. #define SPI_RCRCR_RXCRC ((uint16_t)0xFFFF) /* Rx CRC Register */
  3704. /****************** Bit definition for SPI_TCRCR register ******************/
  3705. #define SPI_TCRCR_TXCRC ((uint16_t)0xFFFF) /* Tx CRC Register */
  3706. /****************** Bit definition for SPI_I2SCFGR register *****************/
  3707. #define SPI_I2SCFGR_CHLEN ((uint16_t)0x0001) /* Channel length (number of bits per audio channel) */
  3708. #define SPI_I2SCFGR_DATLEN ((uint16_t)0x0006) /* DATLEN[1:0] bits (Data length to be transferred) */
  3709. #define SPI_I2SCFGR_DATLEN_0 ((uint16_t)0x0002) /* Bit 0 */
  3710. #define SPI_I2SCFGR_DATLEN_1 ((uint16_t)0x0004) /* Bit 1 */
  3711. #define SPI_I2SCFGR_CKPOL ((uint16_t)0x0008) /* steady state clock polarity */
  3712. #define SPI_I2SCFGR_I2SSTD ((uint16_t)0x0030) /* I2SSTD[1:0] bits (I2S standard selection) */
  3713. #define SPI_I2SCFGR_I2SSTD_0 ((uint16_t)0x0010) /* Bit 0 */
  3714. #define SPI_I2SCFGR_I2SSTD_1 ((uint16_t)0x0020) /* Bit 1 */
  3715. #define SPI_I2SCFGR_PCMSYNC ((uint16_t)0x0080) /* PCM frame synchronization */
  3716. #define SPI_I2SCFGR_I2SCFG ((uint16_t)0x0300) /* I2SCFG[1:0] bits (I2S configuration mode) */
  3717. #define SPI_I2SCFGR_I2SCFG_0 ((uint16_t)0x0100) /* Bit 0 */
  3718. #define SPI_I2SCFGR_I2SCFG_1 ((uint16_t)0x0200) /* Bit 1 */
  3719. #define SPI_I2SCFGR_I2SE ((uint16_t)0x0400) /* I2S Enable */
  3720. #define SPI_I2SCFGR_I2SMOD ((uint16_t)0x0800) /* I2S mode selection */
  3721. /****************** Bit definition for SPI_I2SPR register *******************/
  3722. #define SPI_I2SPR_I2SDIV ((uint16_t)0x00FF) /* I2S Linear prescaler */
  3723. #define SPI_I2SPR_ODD ((uint16_t)0x0100) /* Odd factor for the prescaler */
  3724. #define SPI_I2SPR_MCKOE ((uint16_t)0x0200) /* Master Clock Output Enable */
  3725. /******************************************************************************/
  3726. /* TIM */
  3727. /******************************************************************************/
  3728. /******************* Bit definition for TIM_CTLR1 register ********************/
  3729. #define TIM_CEN ((uint16_t)0x0001) /* Counter enable */
  3730. #define TIM_UDIS ((uint16_t)0x0002) /* Update disable */
  3731. #define TIM_URS ((uint16_t)0x0004) /* Update request source */
  3732. #define TIM_OPM ((uint16_t)0x0008) /* One pulse mode */
  3733. #define TIM_DIR ((uint16_t)0x0010) /* Direction */
  3734. #define TIM_CMS ((uint16_t)0x0060) /* CMS[1:0] bits (Center-aligned mode selection) */
  3735. #define TIM_CMS_0 ((uint16_t)0x0020) /* Bit 0 */
  3736. #define TIM_CMS_1 ((uint16_t)0x0040) /* Bit 1 */
  3737. #define TIM_ARPE ((uint16_t)0x0080) /* Auto-reload preload enable */
  3738. #define TIM_CTLR1_CKD ((uint16_t)0x0300) /* CKD[1:0] bits (clock division) */
  3739. #define TIM_CKD_0 ((uint16_t)0x0100) /* Bit 0 */
  3740. #define TIM_CKD_1 ((uint16_t)0x0200) /* Bit 1 */
  3741. /******************* Bit definition for TIM_CTLR2 register ********************/
  3742. #define TIM_CCPC ((uint16_t)0x0001) /* Capture/Compare Preloaded Control */
  3743. #define TIM_CCUS ((uint16_t)0x0004) /* Capture/Compare Control Update Selection */
  3744. #define TIM_CCDS ((uint16_t)0x0008) /* Capture/Compare DMA Selection */
  3745. #define TIM_MMS ((uint16_t)0x0070) /* MMS[2:0] bits (Master Mode Selection) */
  3746. #define TIM_MMS_0 ((uint16_t)0x0010) /* Bit 0 */
  3747. #define TIM_MMS_1 ((uint16_t)0x0020) /* Bit 1 */
  3748. #define TIM_MMS_2 ((uint16_t)0x0040) /* Bit 2 */
  3749. #define TIM_TI1S ((uint16_t)0x0080) /* TI1 Selection */
  3750. #define TIM_OIS1 ((uint16_t)0x0100) /* Output Idle state 1 (OC1 output) */
  3751. #define TIM_OIS1N ((uint16_t)0x0200) /* Output Idle state 1 (OC1N output) */
  3752. #define TIM_OIS2 ((uint16_t)0x0400) /* Output Idle state 2 (OC2 output) */
  3753. #define TIM_OIS2N ((uint16_t)0x0800) /* Output Idle state 2 (OC2N output) */
  3754. #define TIM_OIS3 ((uint16_t)0x1000) /* Output Idle state 3 (OC3 output) */
  3755. #define TIM_OIS3N ((uint16_t)0x2000) /* Output Idle state 3 (OC3N output) */
  3756. #define TIM_OIS4 ((uint16_t)0x4000) /* Output Idle state 4 (OC4 output) */
  3757. /******************* Bit definition for TIM_SMCFGR register *******************/
  3758. #define TIM_SMS ((uint16_t)0x0007) /* SMS[2:0] bits (Slave mode selection) */
  3759. #define TIM_SMS_0 ((uint16_t)0x0001) /* Bit 0 */
  3760. #define TIM_SMS_1 ((uint16_t)0x0002) /* Bit 1 */
  3761. #define TIM_SMS_2 ((uint16_t)0x0004) /* Bit 2 */
  3762. #define TIM_TS ((uint16_t)0x0070) /* TS[2:0] bits (Trigger selection) */
  3763. #define TIM_TS_0 ((uint16_t)0x0010) /* Bit 0 */
  3764. #define TIM_TS_1 ((uint16_t)0x0020) /* Bit 1 */
  3765. #define TIM_TS_2 ((uint16_t)0x0040) /* Bit 2 */
  3766. #define TIM_MSM ((uint16_t)0x0080) /* Master/slave mode */
  3767. #define TIM_ETF ((uint16_t)0x0F00) /* ETF[3:0] bits (External trigger filter) */
  3768. #define TIM_ETF_0 ((uint16_t)0x0100) /* Bit 0 */
  3769. #define TIM_ETF_1 ((uint16_t)0x0200) /* Bit 1 */
  3770. #define TIM_ETF_2 ((uint16_t)0x0400) /* Bit 2 */
  3771. #define TIM_ETF_3 ((uint16_t)0x0800) /* Bit 3 */
  3772. #define TIM_ETPS ((uint16_t)0x3000) /* ETPS[1:0] bits (External trigger prescaler) */
  3773. #define TIM_ETPS_0 ((uint16_t)0x1000) /* Bit 0 */
  3774. #define TIM_ETPS_1 ((uint16_t)0x2000) /* Bit 1 */
  3775. #define TIM_ECE ((uint16_t)0x4000) /* External clock enable */
  3776. #define TIM_ETP ((uint16_t)0x8000) /* External trigger polarity */
  3777. /******************* Bit definition for TIM_DMAINTENR register *******************/
  3778. #define TIM_UIE ((uint16_t)0x0001) /* Update interrupt enable */
  3779. #define TIM_CC1IE ((uint16_t)0x0002) /* Capture/Compare 1 interrupt enable */
  3780. #define TIM_CC2IE ((uint16_t)0x0004) /* Capture/Compare 2 interrupt enable */
  3781. #define TIM_CC3IE ((uint16_t)0x0008) /* Capture/Compare 3 interrupt enable */
  3782. #define TIM_CC4IE ((uint16_t)0x0010) /* Capture/Compare 4 interrupt enable */
  3783. #define TIM_COMIE ((uint16_t)0x0020) /* COM interrupt enable */
  3784. #define TIM_TIE ((uint16_t)0x0040) /* Trigger interrupt enable */
  3785. #define TIM_BIE ((uint16_t)0x0080) /* Break interrupt enable */
  3786. #define TIM_UDE ((uint16_t)0x0100) /* Update DMA request enable */
  3787. #define TIM_CC1DE ((uint16_t)0x0200) /* Capture/Compare 1 DMA request enable */
  3788. #define TIM_CC2DE ((uint16_t)0x0400) /* Capture/Compare 2 DMA request enable */
  3789. #define TIM_CC3DE ((uint16_t)0x0800) /* Capture/Compare 3 DMA request enable */
  3790. #define TIM_CC4DE ((uint16_t)0x1000) /* Capture/Compare 4 DMA request enable */
  3791. #define TIM_COMDE ((uint16_t)0x2000) /* COM DMA request enable */
  3792. #define TIM_TDE ((uint16_t)0x4000) /* Trigger DMA request enable */
  3793. /******************** Bit definition for TIM_INTFR register ********************/
  3794. #define TIM_UIF ((uint16_t)0x0001) /* Update interrupt Flag */
  3795. #define TIM_CC1IF ((uint16_t)0x0002) /* Capture/Compare 1 interrupt Flag */
  3796. #define TIM_CC2IF ((uint16_t)0x0004) /* Capture/Compare 2 interrupt Flag */
  3797. #define TIM_CC3IF ((uint16_t)0x0008) /* Capture/Compare 3 interrupt Flag */
  3798. #define TIM_CC4IF ((uint16_t)0x0010) /* Capture/Compare 4 interrupt Flag */
  3799. #define TIM_COMIF ((uint16_t)0x0020) /* COM interrupt Flag */
  3800. #define TIM_TIF ((uint16_t)0x0040) /* Trigger interrupt Flag */
  3801. #define TIM_BIF ((uint16_t)0x0080) /* Break interrupt Flag */
  3802. #define TIM_CC1OF ((uint16_t)0x0200) /* Capture/Compare 1 Overcapture Flag */
  3803. #define TIM_CC2OF ((uint16_t)0x0400) /* Capture/Compare 2 Overcapture Flag */
  3804. #define TIM_CC3OF ((uint16_t)0x0800) /* Capture/Compare 3 Overcapture Flag */
  3805. #define TIM_CC4OF ((uint16_t)0x1000) /* Capture/Compare 4 Overcapture Flag */
  3806. /******************* Bit definition for TIM_SWEVGR register ********************/
  3807. #define TIM_UG ((uint8_t)0x01) /* Update Generation */
  3808. #define TIM_CC1G ((uint8_t)0x02) /* Capture/Compare 1 Generation */
  3809. #define TIM_CC2G ((uint8_t)0x04) /* Capture/Compare 2 Generation */
  3810. #define TIM_CC3G ((uint8_t)0x08) /* Capture/Compare 3 Generation */
  3811. #define TIM_CC4G ((uint8_t)0x10) /* Capture/Compare 4 Generation */
  3812. #define TIM_COMG ((uint8_t)0x20) /* Capture/Compare Control Update Generation */
  3813. #define TIM_TG ((uint8_t)0x40) /* Trigger Generation */
  3814. #define TIM_BG ((uint8_t)0x80) /* Break Generation */
  3815. /****************** Bit definition for TIM_CHCTLR1 register *******************/
  3816. #define TIM_CC1S ((uint16_t)0x0003) /* CC1S[1:0] bits (Capture/Compare 1 Selection) */
  3817. #define TIM_CC1S_0 ((uint16_t)0x0001) /* Bit 0 */
  3818. #define TIM_CC1S_1 ((uint16_t)0x0002) /* Bit 1 */
  3819. #define TIM_OC1FE ((uint16_t)0x0004) /* Output Compare 1 Fast enable */
  3820. #define TIM_OC1PE ((uint16_t)0x0008) /* Output Compare 1 Preload enable */
  3821. #define TIM_OC1M ((uint16_t)0x0070) /* OC1M[2:0] bits (Output Compare 1 Mode) */
  3822. #define TIM_OC1M_0 ((uint16_t)0x0010) /* Bit 0 */
  3823. #define TIM_OC1M_1 ((uint16_t)0x0020) /* Bit 1 */
  3824. #define TIM_OC1M_2 ((uint16_t)0x0040) /* Bit 2 */
  3825. #define TIM_OC1CE ((uint16_t)0x0080) /* Output Compare 1Clear Enable */
  3826. #define TIM_CC2S ((uint16_t)0x0300) /* CC2S[1:0] bits (Capture/Compare 2 Selection) */
  3827. #define TIM_CC2S_0 ((uint16_t)0x0100) /* Bit 0 */
  3828. #define TIM_CC2S_1 ((uint16_t)0x0200) /* Bit 1 */
  3829. #define TIM_OC2FE ((uint16_t)0x0400) /* Output Compare 2 Fast enable */
  3830. #define TIM_OC2PE ((uint16_t)0x0800) /* Output Compare 2 Preload enable */
  3831. #define TIM_OC2M ((uint16_t)0x7000) /* OC2M[2:0] bits (Output Compare 2 Mode) */
  3832. #define TIM_OC2M_0 ((uint16_t)0x1000) /* Bit 0 */
  3833. #define TIM_OC2M_1 ((uint16_t)0x2000) /* Bit 1 */
  3834. #define TIM_OC2M_2 ((uint16_t)0x4000) /* Bit 2 */
  3835. #define TIM_OC2CE ((uint16_t)0x8000) /* Output Compare 2 Clear Enable */
  3836. #define TIM_IC1PSC ((uint16_t)0x000C) /* IC1PSC[1:0] bits (Input Capture 1 Prescaler) */
  3837. #define TIM_IC1PSC_0 ((uint16_t)0x0004) /* Bit 0 */
  3838. #define TIM_IC1PSC_1 ((uint16_t)0x0008) /* Bit 1 */
  3839. #define TIM_IC1F ((uint16_t)0x00F0) /* IC1F[3:0] bits (Input Capture 1 Filter) */
  3840. #define TIM_IC1F_0 ((uint16_t)0x0010) /* Bit 0 */
  3841. #define TIM_IC1F_1 ((uint16_t)0x0020) /* Bit 1 */
  3842. #define TIM_IC1F_2 ((uint16_t)0x0040) /* Bit 2 */
  3843. #define TIM_IC1F_3 ((uint16_t)0x0080) /* Bit 3 */
  3844. #define TIM_IC2PSC ((uint16_t)0x0C00) /* IC2PSC[1:0] bits (Input Capture 2 Prescaler) */
  3845. #define TIM_IC2PSC_0 ((uint16_t)0x0400) /* Bit 0 */
  3846. #define TIM_IC2PSC_1 ((uint16_t)0x0800) /* Bit 1 */
  3847. #define TIM_IC2F ((uint16_t)0xF000) /* IC2F[3:0] bits (Input Capture 2 Filter) */
  3848. #define TIM_IC2F_0 ((uint16_t)0x1000) /* Bit 0 */
  3849. #define TIM_IC2F_1 ((uint16_t)0x2000) /* Bit 1 */
  3850. #define TIM_IC2F_2 ((uint16_t)0x4000) /* Bit 2 */
  3851. #define TIM_IC2F_3 ((uint16_t)0x8000) /* Bit 3 */
  3852. /****************** Bit definition for TIM_CHCTLR2 register *******************/
  3853. #define TIM_CC3S ((uint16_t)0x0003) /* CC3S[1:0] bits (Capture/Compare 3 Selection) */
  3854. #define TIM_CC3S_0 ((uint16_t)0x0001) /* Bit 0 */
  3855. #define TIM_CC3S_1 ((uint16_t)0x0002) /* Bit 1 */
  3856. #define TIM_OC3FE ((uint16_t)0x0004) /* Output Compare 3 Fast enable */
  3857. #define TIM_OC3PE ((uint16_t)0x0008) /* Output Compare 3 Preload enable */
  3858. #define TIM_OC3M ((uint16_t)0x0070) /* OC3M[2:0] bits (Output Compare 3 Mode) */
  3859. #define TIM_OC3M_0 ((uint16_t)0x0010) /* Bit 0 */
  3860. #define TIM_OC3M_1 ((uint16_t)0x0020) /* Bit 1 */
  3861. #define TIM_OC3M_2 ((uint16_t)0x0040) /* Bit 2 */
  3862. #define TIM_OC3CE ((uint16_t)0x0080) /* Output Compare 3 Clear Enable */
  3863. #define TIM_CC4S ((uint16_t)0x0300) /* CC4S[1:0] bits (Capture/Compare 4 Selection) */
  3864. #define TIM_CC4S_0 ((uint16_t)0x0100) /* Bit 0 */
  3865. #define TIM_CC4S_1 ((uint16_t)0x0200) /* Bit 1 */
  3866. #define TIM_OC4FE ((uint16_t)0x0400) /* Output Compare 4 Fast enable */
  3867. #define TIM_OC4PE ((uint16_t)0x0800) /* Output Compare 4 Preload enable */
  3868. #define TIM_OC4M ((uint16_t)0x7000) /* OC4M[2:0] bits (Output Compare 4 Mode) */
  3869. #define TIM_OC4M_0 ((uint16_t)0x1000) /* Bit 0 */
  3870. #define TIM_OC4M_1 ((uint16_t)0x2000) /* Bit 1 */
  3871. #define TIM_OC4M_2 ((uint16_t)0x4000) /* Bit 2 */
  3872. #define TIM_OC4CE ((uint16_t)0x8000) /* Output Compare 4 Clear Enable */
  3873. #define TIM_IC3PSC ((uint16_t)0x000C) /* IC3PSC[1:0] bits (Input Capture 3 Prescaler) */
  3874. #define TIM_IC3PSC_0 ((uint16_t)0x0004) /* Bit 0 */
  3875. #define TIM_IC3PSC_1 ((uint16_t)0x0008) /* Bit 1 */
  3876. #define TIM_IC3F ((uint16_t)0x00F0) /* IC3F[3:0] bits (Input Capture 3 Filter) */
  3877. #define TIM_IC3F_0 ((uint16_t)0x0010) /* Bit 0 */
  3878. #define TIM_IC3F_1 ((uint16_t)0x0020) /* Bit 1 */
  3879. #define TIM_IC3F_2 ((uint16_t)0x0040) /* Bit 2 */
  3880. #define TIM_IC3F_3 ((uint16_t)0x0080) /* Bit 3 */
  3881. #define TIM_IC4PSC ((uint16_t)0x0C00) /* IC4PSC[1:0] bits (Input Capture 4 Prescaler) */
  3882. #define TIM_IC4PSC_0 ((uint16_t)0x0400) /* Bit 0 */
  3883. #define TIM_IC4PSC_1 ((uint16_t)0x0800) /* Bit 1 */
  3884. #define TIM_IC4F ((uint16_t)0xF000) /* IC4F[3:0] bits (Input Capture 4 Filter) */
  3885. #define TIM_IC4F_0 ((uint16_t)0x1000) /* Bit 0 */
  3886. #define TIM_IC4F_1 ((uint16_t)0x2000) /* Bit 1 */
  3887. #define TIM_IC4F_2 ((uint16_t)0x4000) /* Bit 2 */
  3888. #define TIM_IC4F_3 ((uint16_t)0x8000) /* Bit 3 */
  3889. /******************* Bit definition for TIM_CCER register *******************/
  3890. #define TIM_CC1E ((uint16_t)0x0001) /* Capture/Compare 1 output enable */
  3891. #define TIM_CC1P ((uint16_t)0x0002) /* Capture/Compare 1 output Polarity */
  3892. #define TIM_CC1NE ((uint16_t)0x0004) /* Capture/Compare 1 Complementary output enable */
  3893. #define TIM_CC1NP ((uint16_t)0x0008) /* Capture/Compare 1 Complementary output Polarity */
  3894. #define TIM_CC2E ((uint16_t)0x0010) /* Capture/Compare 2 output enable */
  3895. #define TIM_CC2P ((uint16_t)0x0020) /* Capture/Compare 2 output Polarity */
  3896. #define TIM_CC2NE ((uint16_t)0x0040) /* Capture/Compare 2 Complementary output enable */
  3897. #define TIM_CC2NP ((uint16_t)0x0080) /* Capture/Compare 2 Complementary output Polarity */
  3898. #define TIM_CC3E ((uint16_t)0x0100) /* Capture/Compare 3 output enable */
  3899. #define TIM_CC3P ((uint16_t)0x0200) /* Capture/Compare 3 output Polarity */
  3900. #define TIM_CC3NE ((uint16_t)0x0400) /* Capture/Compare 3 Complementary output enable */
  3901. #define TIM_CC3NP ((uint16_t)0x0800) /* Capture/Compare 3 Complementary output Polarity */
  3902. #define TIM_CC4E ((uint16_t)0x1000) /* Capture/Compare 4 output enable */
  3903. #define TIM_CC4P ((uint16_t)0x2000) /* Capture/Compare 4 output Polarity */
  3904. #define TIM_CC4NP ((uint16_t)0x8000) /* Capture/Compare 4 Complementary output Polarity */
  3905. /******************* Bit definition for TIM_CNT register ********************/
  3906. #define TIM_CNT ((uint16_t)0xFFFF) /* Counter Value */
  3907. /******************* Bit definition for TIM_PSC register ********************/
  3908. #define TIM_PSC ((uint16_t)0xFFFF) /* Prescaler Value */
  3909. /******************* Bit definition for TIM_ATRLR register ********************/
  3910. #define TIM_ARR ((uint16_t)0xFFFF) /* actual auto-reload Value */
  3911. /******************* Bit definition for TIM_RPTCR register ********************/
  3912. #define TIM_REP ((uint8_t)0xFF) /* Repetition Counter Value */
  3913. /******************* Bit definition for TIM_CH1CVR register *******************/
  3914. #define TIM_CCR1 ((uint16_t)0xFFFF) /* Capture/Compare 1 Value */
  3915. /******************* Bit definition for TIM_CH2CVR register *******************/
  3916. #define TIM_CCR2 ((uint16_t)0xFFFF) /* Capture/Compare 2 Value */
  3917. /******************* Bit definition for TIM_CH3CVR register *******************/
  3918. #define TIM_CCR3 ((uint16_t)0xFFFF) /* Capture/Compare 3 Value */
  3919. /******************* Bit definition for TIM_CH4CVR register *******************/
  3920. #define TIM_CCR4 ((uint16_t)0xFFFF) /* Capture/Compare 4 Value */
  3921. /******************* Bit definition for TIM_BDTR register *******************/
  3922. #define TIM_DTG ((uint16_t)0x00FF) /* DTG[0:7] bits (Dead-Time Generator set-up) */
  3923. #define TIM_DTG_0 ((uint16_t)0x0001) /* Bit 0 */
  3924. #define TIM_DTG_1 ((uint16_t)0x0002) /* Bit 1 */
  3925. #define TIM_DTG_2 ((uint16_t)0x0004) /* Bit 2 */
  3926. #define TIM_DTG_3 ((uint16_t)0x0008) /* Bit 3 */
  3927. #define TIM_DTG_4 ((uint16_t)0x0010) /* Bit 4 */
  3928. #define TIM_DTG_5 ((uint16_t)0x0020) /* Bit 5 */
  3929. #define TIM_DTG_6 ((uint16_t)0x0040) /* Bit 6 */
  3930. #define TIM_DTG_7 ((uint16_t)0x0080) /* Bit 7 */
  3931. #define TIM_LOCK ((uint16_t)0x0300) /* LOCK[1:0] bits (Lock Configuration) */
  3932. #define TIM_LOCK_0 ((uint16_t)0x0100) /* Bit 0 */
  3933. #define TIM_LOCK_1 ((uint16_t)0x0200) /* Bit 1 */
  3934. #define TIM_OSSI ((uint16_t)0x0400) /* Off-State Selection for Idle mode */
  3935. #define TIM_OSSR ((uint16_t)0x0800) /* Off-State Selection for Run mode */
  3936. #define TIM_BKE ((uint16_t)0x1000) /* Break enable */
  3937. #define TIM_BKP ((uint16_t)0x2000) /* Break Polarity */
  3938. #define TIM_AOE ((uint16_t)0x4000) /* Automatic Output enable */
  3939. #define TIM_MOE ((uint16_t)0x8000) /* Main Output enable */
  3940. /******************* Bit definition for TIM_DMACFGR register ********************/
  3941. #define TIM_DBA ((uint16_t)0x001F) /* DBA[4:0] bits (DMA Base Address) */
  3942. #define TIM_DBA_0 ((uint16_t)0x0001) /* Bit 0 */
  3943. #define TIM_DBA_1 ((uint16_t)0x0002) /* Bit 1 */
  3944. #define TIM_DBA_2 ((uint16_t)0x0004) /* Bit 2 */
  3945. #define TIM_DBA_3 ((uint16_t)0x0008) /* Bit 3 */
  3946. #define TIM_DBA_4 ((uint16_t)0x0010) /* Bit 4 */
  3947. #define TIM_DBL ((uint16_t)0x1F00) /* DBL[4:0] bits (DMA Burst Length) */
  3948. #define TIM_DBL_0 ((uint16_t)0x0100) /* Bit 0 */
  3949. #define TIM_DBL_1 ((uint16_t)0x0200) /* Bit 1 */
  3950. #define TIM_DBL_2 ((uint16_t)0x0400) /* Bit 2 */
  3951. #define TIM_DBL_3 ((uint16_t)0x0800) /* Bit 3 */
  3952. #define TIM_DBL_4 ((uint16_t)0x1000) /* Bit 4 */
  3953. /******************* Bit definition for TIM_DMAADR register *******************/
  3954. #define TIM_DMAR_DMAB ((uint16_t)0xFFFF) /* DMA register for burst accesses */
  3955. /******************************************************************************/
  3956. /* Universal Synchronous Asynchronous Receiver Transmitter */
  3957. /******************************************************************************/
  3958. /******************* Bit definition for USART_STATR register *******************/
  3959. #define USART_STATR_PE ((uint16_t)0x0001) /* Parity Error */
  3960. #define USART_STATR_FE ((uint16_t)0x0002) /* Framing Error */
  3961. #define USART_STATR_NE ((uint16_t)0x0004) /* Noise Error Flag */
  3962. #define USART_STATR_ORE ((uint16_t)0x0008) /* OverRun Error */
  3963. #define USART_STATR_IDLE ((uint16_t)0x0010) /* IDLE line detected */
  3964. #define USART_STATR_RXNE ((uint16_t)0x0020) /* Read Data Register Not Empty */
  3965. #define USART_STATR_TC ((uint16_t)0x0040) /* Transmission Complete */
  3966. #define USART_STATR_TXE ((uint16_t)0x0080) /* Transmit Data Register Empty */
  3967. #define USART_STATR_LBD ((uint16_t)0x0100) /* LIN Break Detection Flag */
  3968. #define USART_STATR_CTS ((uint16_t)0x0200) /* CTS Flag */
  3969. /******************* Bit definition for USART_DATAR register *******************/
  3970. #define USART_DATAR_DR ((uint16_t)0x01FF) /* Data value */
  3971. /****************** Bit definition for USART_BRR register *******************/
  3972. #define USART_BRR_DIV_Fraction ((uint16_t)0x000F) /* Fraction of USARTDIV */
  3973. #define USART_BRR_DIV_Mantissa ((uint16_t)0xFFF0) /* Mantissa of USARTDIV */
  3974. /****************** Bit definition for USART_CTLR1 register *******************/
  3975. #define USART_CTLR1_SBK ((uint16_t)0x0001) /* Send Break */
  3976. #define USART_CTLR1_RWU ((uint16_t)0x0002) /* Receiver wakeup */
  3977. #define USART_CTLR1_RE ((uint16_t)0x0004) /* Receiver Enable */
  3978. #define USART_CTLR1_TE ((uint16_t)0x0008) /* Transmitter Enable */
  3979. #define USART_CTLR1_IDLEIE ((uint16_t)0x0010) /* IDLE Interrupt Enable */
  3980. #define USART_CTLR1_RXNEIE ((uint16_t)0x0020) /* RXNE Interrupt Enable */
  3981. #define USART_CTLR1_TCIE ((uint16_t)0x0040) /* Transmission Complete Interrupt Enable */
  3982. #define USART_CTLR1_TXEIE ((uint16_t)0x0080) /* PE Interrupt Enable */
  3983. #define USART_CTLR1_PEIE ((uint16_t)0x0100) /* PE Interrupt Enable */
  3984. #define USART_CTLR1_PS ((uint16_t)0x0200) /* Parity Selection */
  3985. #define USART_CTLR1_PCE ((uint16_t)0x0400) /* Parity Control Enable */
  3986. #define USART_CTLR1_WAKE ((uint16_t)0x0800) /* Wakeup method */
  3987. #define USART_CTLR1_M ((uint16_t)0x1000) /* Word length */
  3988. #define USART_CTLR1_UE ((uint16_t)0x2000) /* USART Enable */
  3989. #define USART_CTLR1_OVER8 ((uint16_t)0x8000) /* USART Oversmapling 8-bits */
  3990. /****************** Bit definition for USART_CTLR2 register *******************/
  3991. #define USART_CTLR2_ADD ((uint16_t)0x000F) /* Address of the USART node */
  3992. #define USART_CTLR2_LBDL ((uint16_t)0x0020) /* LIN Break Detection Length */
  3993. #define USART_CTLR2_LBDIE ((uint16_t)0x0040) /* LIN Break Detection Interrupt Enable */
  3994. #define USART_CTLR2_LBCL ((uint16_t)0x0100) /* Last Bit Clock pulse */
  3995. #define USART_CTLR2_CPHA ((uint16_t)0x0200) /* Clock Phase */
  3996. #define USART_CTLR2_CPOL ((uint16_t)0x0400) /* Clock Polarity */
  3997. #define USART_CTLR2_CLKEN ((uint16_t)0x0800) /* Clock Enable */
  3998. #define USART_CTLR2_STOP ((uint16_t)0x3000) /* STOP[1:0] bits (STOP bits) */
  3999. #define USART_CTLR2_STOP_0 ((uint16_t)0x1000) /* Bit 0 */
  4000. #define USART_CTLR2_STOP_1 ((uint16_t)0x2000) /* Bit 1 */
  4001. #define USART_CTLR2_LINEN ((uint16_t)0x4000) /* LIN mode enable */
  4002. /****************** Bit definition for USART_CTLR3 register *******************/
  4003. #define USART_CTLR3_EIE ((uint16_t)0x0001) /* Error Interrupt Enable */
  4004. #define USART_CTLR3_IREN ((uint16_t)0x0002) /* IrDA mode Enable */
  4005. #define USART_CTLR3_IRLP ((uint16_t)0x0004) /* IrDA Low-Power */
  4006. #define USART_CTLR3_HDSEL ((uint16_t)0x0008) /* Half-Duplex Selection */
  4007. #define USART_CTLR3_NACK ((uint16_t)0x0010) /* Smartcard NACK enable */
  4008. #define USART_CTLR3_SCEN ((uint16_t)0x0020) /* Smartcard mode enable */
  4009. #define USART_CTLR3_DMAR ((uint16_t)0x0040) /* DMA Enable Receiver */
  4010. #define USART_CTLR3_DMAT ((uint16_t)0x0080) /* DMA Enable Transmitter */
  4011. #define USART_CTLR3_RTSE ((uint16_t)0x0100) /* RTS Enable */
  4012. #define USART_CTLR3_CTSE ((uint16_t)0x0200) /* CTS Enable */
  4013. #define USART_CTLR3_CTSIE ((uint16_t)0x0400) /* CTS Interrupt Enable */
  4014. #define USART_CTLR3_ONEBIT ((uint16_t)0x0800) /* One Bit method */
  4015. /****************** Bit definition for USART_GPR register ******************/
  4016. #define USART_GPR_PSC ((uint16_t)0x00FF) /* PSC[7:0] bits (Prescaler value) */
  4017. #define USART_GPR_PSC_0 ((uint16_t)0x0001) /* Bit 0 */
  4018. #define USART_GPR_PSC_1 ((uint16_t)0x0002) /* Bit 1 */
  4019. #define USART_GPR_PSC_2 ((uint16_t)0x0004) /* Bit 2 */
  4020. #define USART_GPR_PSC_3 ((uint16_t)0x0008) /* Bit 3 */
  4021. #define USART_GPR_PSC_4 ((uint16_t)0x0010) /* Bit 4 */
  4022. #define USART_GPR_PSC_5 ((uint16_t)0x0020) /* Bit 5 */
  4023. #define USART_GPR_PSC_6 ((uint16_t)0x0040) /* Bit 6 */
  4024. #define USART_GPR_PSC_7 ((uint16_t)0x0080) /* Bit 7 */
  4025. #define USART_GPR_GT ((uint16_t)0xFF00) /* Guard time value */
  4026. /******************************************************************************/
  4027. /* Window WATCHDOG */
  4028. /******************************************************************************/
  4029. /******************* Bit definition for WWDG_CTLR register ********************/
  4030. #define WWDG_CTLR_T ((uint8_t)0x7F) /* T[6:0] bits (7-Bit counter (MSB to LSB)) */
  4031. #define WWDG_CTLR_T0 ((uint8_t)0x01) /* Bit 0 */
  4032. #define WWDG_CTLR_T1 ((uint8_t)0x02) /* Bit 1 */
  4033. #define WWDG_CTLR_T2 ((uint8_t)0x04) /* Bit 2 */
  4034. #define WWDG_CTLR_T3 ((uint8_t)0x08) /* Bit 3 */
  4035. #define WWDG_CTLR_T4 ((uint8_t)0x10) /* Bit 4 */
  4036. #define WWDG_CTLR_T5 ((uint8_t)0x20) /* Bit 5 */
  4037. #define WWDG_CTLR_T6 ((uint8_t)0x40) /* Bit 6 */
  4038. #define WWDG_CTLR_WDGA ((uint8_t)0x80) /* Activation bit */
  4039. /******************* Bit definition for WWDG_CFGR register *******************/
  4040. #define WWDG_CFGR_W ((uint16_t)0x007F) /* W[6:0] bits (7-bit window value) */
  4041. #define WWDG_CFGR_W0 ((uint16_t)0x0001) /* Bit 0 */
  4042. #define WWDG_CFGR_W1 ((uint16_t)0x0002) /* Bit 1 */
  4043. #define WWDG_CFGR_W2 ((uint16_t)0x0004) /* Bit 2 */
  4044. #define WWDG_CFGR_W3 ((uint16_t)0x0008) /* Bit 3 */
  4045. #define WWDG_CFGR_W4 ((uint16_t)0x0010) /* Bit 4 */
  4046. #define WWDG_CFGR_W5 ((uint16_t)0x0020) /* Bit 5 */
  4047. #define WWDG_CFGR_W6 ((uint16_t)0x0040) /* Bit 6 */
  4048. #define WWDG_CFGR_WDGTB ((uint16_t)0x0180) /* WDGTB[1:0] bits (Timer Base) */
  4049. #define WWDG_CFGR_WDGTB0 ((uint16_t)0x0080) /* Bit 0 */
  4050. #define WWDG_CFGR_WDGTB1 ((uint16_t)0x0100) /* Bit 1 */
  4051. #define WWDG_CFGR_EWI ((uint16_t)0x0200) /* Early Wakeup Interrupt */
  4052. /******************* Bit definition for WWDG_STATR register ********************/
  4053. #define WWDG_STATR_EWIF ((uint8_t)0x01) /* Early Wakeup Interrupt Flag */
  4054. /******************************************************************************/
  4055. /* ENHANCED FUNNCTION */
  4056. /******************************************************************************/
  4057. /**************************** Enhanced register *****************************/
  4058. #define EXTEN_USBD_LS ((uint32_t)0x00000001) /* Bit 0 */
  4059. #define EXTEN_USBD_PU_EN ((uint32_t)0x00000002) /* Bit 1 */
  4060. #define EXTEN_ETH_10M_EN ((uint32_t)0x00000004) /* Bit 2 */
  4061. #define EXTEN_PLL_HSI_PRE ((uint32_t)0x00000010) /* Bit 4 */
  4062. #define EXTEN_LOCKUP_EN ((uint32_t)0x00000040) /* Bit 5 */
  4063. #define EXTEN_LOCKUP_RSTF ((uint32_t)0x00000080) /* Bit 7 */
  4064. #define EXTEN_ULLDO_TRIM ((uint32_t)0x00000300) /* ULLDO_TRIM[1:0] bits */
  4065. #define EXTEN_ULLDO_TRIM0 ((uint32_t)0x00000100) /* Bit 0 */
  4066. #define EXTEN_ULLDO_TRIM1 ((uint32_t)0x00000200) /* Bit 1 */
  4067. #define EXTEN_LDO_TRIM ((uint32_t)0x00000C00) /* LDO_TRIM[1:0] bits */
  4068. #define EXTEN_LDO_TRIM0 ((uint32_t)0x00000400) /* Bit 0 */
  4069. #define EXTEN_LDO_TRIM1 ((uint32_t)0x00000800) /* Bit 1 */
  4070. /******************************************************************************/
  4071. /* DVP */
  4072. /******************************************************************************/
  4073. /******************* Bit definition for DVP_CR0 register ********************/
  4074. #define RB_DVP_ENABLE 0x01 // RW, DVP enable
  4075. #define RB_DVP_V_POLAR 0x02 // RW, DVP VSYNC polarity control: 1 = invert, 0 = not invert
  4076. #define RB_DVP_H_POLAR 0x04 // RW, DVP HSYNC polarity control: 1 = invert, 0 = not invert
  4077. #define RB_DVP_P_POLAR 0x08 // RW, DVP PCLK polarity control: 1 = invert, 0 = not invert
  4078. #define RB_DVP_MSK_DAT_MOD 0x30
  4079. #define RB_DVP_D8_MOD 0x00 // RW, DVP 8bits data mode
  4080. #define RB_DVP_D10_MOD 0x10 // RW, DVP 10bits data mode
  4081. #define RB_DVP_D12_MOD 0x20 // RW, DVP 12bits data mode
  4082. #define RB_DVP_JPEG 0x40 // RW, DVP JPEG mode
  4083. /******************* Bit definition for DVP_CR1 register ********************/
  4084. #define RB_DVP_DMA_EN 0x01 // RW, DVP dma enable
  4085. #define RB_DVP_ALL_CLR 0x02 // RW, DVP all clear, high action
  4086. #define RB_DVP_RCV_CLR 0x04 // RW, DVP receive logic clear, high action
  4087. #define RB_DVP_BUF_TOG 0x08 // RW, DVP bug toggle by software, write 1 to toggle, ignored writing 0
  4088. #define RB_DVP_CM 0x10 // RW, DVP capture mode
  4089. #define RB_DVP_CROP 0x20 // RW, DVP Crop feature enable
  4090. #define RB_DVP_FCRC 0xC0 // RW, DVP frame capture rate control:
  4091. #define DVP_RATE_100P 0x00 //00 = every frame captured (100%)
  4092. #define DVP_RATE_50P 0x40 //01 = every alternate frame captured (50%)
  4093. #define DVP_RATE_25P 0x80 //10 = one frame in four frame captured (25%)
  4094. /******************* Bit definition for DVP_IER register ********************/
  4095. #define RB_DVP_IE_STR_FRM 0x01 // RW, DVP frame start interrupt enable
  4096. #define RB_DVP_IE_ROW_DONE 0x02 // RW, DVP row received done interrupt enable
  4097. #define RB_DVP_IE_FRM_DONE 0x04 // RW, DVP frame received done interrupt enable
  4098. #define RB_DVP_IE_FIFO_OV 0x08 // RW, DVP receive fifo overflow interrupt enable
  4099. #define RB_DVP_IE_STP_FRM 0x10 // RW, DVP frame stop interrupt enable
  4100. /******************* Bit definition for DVP_IFR register ********************/
  4101. #define RB_DVP_IF_STR_FRM 0x01 // RW1, interrupt flag for DVP frame start
  4102. #define RB_DVP_IF_ROW_DONE 0x02 // RW1, interrupt flag for DVP row receive done
  4103. #define RB_DVP_IF_FRM_DONE 0x04 // RW1, interrupt flag for DVP frame receive done
  4104. #define RB_DVP_IF_FIFO_OV 0x08 // RW1, interrupt flag for DVP receive fifo overflow
  4105. #define RB_DVP_IF_STP_FRM 0x10 // RW1, interrupt flag for DVP frame stop
  4106. /******************* Bit definition for DVP_STATUS register ********************/
  4107. #define RB_DVP_FIFO_RDY 0x01 // RO, DVP receive fifo ready
  4108. #define RB_DVP_FIFO_FULL 0x02 // RO, DVP receive fifo full
  4109. #define RB_DVP_FIFO_OV 0x04 // RO, DVP receive fifo overflow
  4110. #define RB_DVP_MSK_FIFO_CNT 0x70 // RO, DVP receive fifo count
  4111. /******************************************************************************/
  4112. /* ETH10M */
  4113. /******************************************************************************/
  4114. /* ETH register */
  4115. #define R8_ETH_EIE (*((volatile uint8_t *)(0x40028000+3))) /* Interrupt Enable Register */
  4116. #define RB_ETH_EIE_INTIE 0x80 /* RW interrupt enable*/
  4117. #define RB_ETH_EIE_RXIE 0x40 /* RW Receive complete interrupt enable */
  4118. #define RB_ETH_EIE_LINKIE 0x10 /* RW Link Change Interrupt Enable */
  4119. #define RB_ETH_EIE_TXIE 0x08 /* RW send complete interrupt enable */
  4120. #define RB_ETH_EIE_R_EN50 0x04 /* RW TX 50�� resistor adjustment. 1: On-chip 50�� connected 0: On-chip 50�� disconnected */
  4121. #define RB_ETH_EIE_TXERIE 0x02 /* RW Transmit Error Interrupt Enable */
  4122. #define RB_ETH_EIE_RXERIE 0x01 /* RW1 receive error flag */
  4123. #define R8_ETH_EIR (*((volatile uint8_t *)(0x40028000+4))) /* Interrupt Flag Register */
  4124. #define RB_ETH_EIR_RXIF 0x40 /* RW1 Receive complete flag */
  4125. #define RB_ETH_EIR_LINKIF 0x10 /* RW1 Link Change Flag */
  4126. #define RB_ETH_EIR_TXIF 0x08 /* RW1 Link Change Flag */
  4127. #define RB_ETH_EIR_TXERIF 0x02 /* RW1 send error flag */
  4128. #define RB_ETH_EIR_RXERIF 0x01 /* RW1 receive error flag */
  4129. #define R8_ETH_ESTAT (*((volatile uint8_t *)(0x40028000+5))) /* status register */
  4130. #define RB_ETH_ESTAT_INT 0x80 /* RW1 interrupt */
  4131. #define RB_ETH_ESTAT_BUFER 0x40 /* RW1 Buffer error */
  4132. #define RB_ETH_ESTAT_RXCRCER 0x20 /* RO receive crc error */
  4133. #define RB_ETH_ESTAT_RXNIBBLE 0x10 /* RO receives nibble error */
  4134. #define RB_ETH_ESTAT_RXMORE 0x08 /* RO receives more than maximum packets */
  4135. #define RB_ETH_ESTAT_RXBUSY 0x04 /* RO receive busy */
  4136. #define RB_ETH_ESTAT_TXABRT 0x02 /* RO send interrupted by mcu */
  4137. #define R8_ETH_ECON2 (*((volatile uint8_t *)(0x40028000+6))) /* ETH PHY Analog Block Control Register */
  4138. #define RB_ETH_ECON2_RX 0x0E /* 011b must be written */
  4139. #define RB_ETH_ECON2_TX 0x01
  4140. #define RB_ETH_ECON2_MUST 0x06 /* 011b must be written */
  4141. #define R8_ETH_ECON1 (*((volatile uint8_t *)(0x40028000+7))) /* Transceiver Control Register */
  4142. #define RB_ETH_ECON1_TXRST 0x80 /* RW Send module reset */
  4143. #define RB_ETH_ECON1_RXRST 0x40 /* RW Receiver module reset */
  4144. #define RB_ETH_ECON1_TXRTS 0x08 /* RW The transmission starts, and it is automatically cleared after the transmission is completed. */
  4145. #define RB_ETH_ECON1_RXEN 0x04 /* RW Receive is enabled, when cleared, the error flag RXERIF will change to 1 if it is receiving */
  4146. #define R32_ETH_TX (*((volatile uint32_t *)(0x40028000+8))) /* send control */
  4147. #define R16_ETH_ETXST (*((volatile uint16_t *)(0x40028000+8))) /* RW Send DMA buffer start address */
  4148. #define R16_ETH_ETXLN (*((volatile uint16_t *)(0x40028000+0xA))) /* RW send length */
  4149. #define R32_ETH_RX (*((volatile uint32_t *)(0x40028000+0xC))) /* receive control */
  4150. #define R16_ETH_ERXST (*((volatile uint16_t *)(0x40028000+0xC))) /* RW Receive DMA buffer start address */
  4151. #define R16_ETH_ERXLN (*((volatile uint16_t *)(0x40028000+0xE))) /* RO receive length */
  4152. #define R32_ETH_HTL (*((volatile uint32_t *)(0x40028000+0x10)))
  4153. #define R8_ETH_EHT0 (*((volatile uint8_t *)(0x40028000+0x10))) /* RW Hash Table Byte0 */
  4154. #define R8_ETH_EHT1 (*((volatile uint8_t *)(0x40028000+0x11))) /* RW Hash Table Byte1 */
  4155. #define R8_ETH_EHT2 (*((volatile uint8_t *)(0x40028000+0x12))) /* RW Hash Table Byte2 */
  4156. #define R8_ETH_EHT3 (*((volatile uint8_t *)(0x40028000+0x13))) /* RW Hash Table Byte3 */
  4157. #define R32_ETH_HTH (*((volatile uint32_t *)(0x40028000+0x14)))
  4158. #define R8_ETH_EHT4 (*((volatile uint8_t *)(0x40028000+0x14))) /* RW Hash Table Byte4 */
  4159. #define R8_ETH_EHT5 (*((volatile uint8_t *)(0x40028000+0x15))) /* RW Hash Table Byte5 */
  4160. #define R8_ETH_EHT6 (*((volatile uint8_t *)(0x40028000+0x16))) /* RW Hash Table Byte6 */
  4161. #define R8_ETH_EHT7 (*((volatile uint8_t *)(0x40028000+0x17))) /* RW Hash Table Byte7 */
  4162. #define R32_ETH_MACON (*((volatile uint32_t *)(0x40028000+0x18)))
  4163. #define R8_ETH_ERXFCON (*((volatile uint8_t *)(0x40028000+0x18))) /* Received Packet Filtering Control Register */
  4164. /* RW 0=Do not enable this filter condition, 1=When ANDOR=1,
  4165. target address mismatch will be filtered, when ANDOR=0, target address match will be accepted */
  4166. #define RB_ETH_ERXFCON_UCEN 0x80
  4167. #define RB_ETH_ERXFCON_CRCEN 0x20
  4168. #define RB_ETH_ERXFCON_EN 0x10
  4169. #define RB_ETH_ERXFCON_MPEN 0x08
  4170. #define RB_ETH_ERXFCON_HTEN 0x04
  4171. #define RB_ETH_ERXFCON_MCEN 0x02
  4172. #define RB_ETH_ERXFCON_BCEN 0x01
  4173. #define R8_ETH_MACON1 (*((volatile uint8_t *)(0x40028000+0x19))) /* Mac flow control registers */
  4174. /* RW When FULDPX=0 is invalid, when FULDPX=1, 11=send 0 timer pause frame,
  4175. then stop sending, 10=send pause frame periodically, 01=send pause frame once, then stop sending, 00=stop sending pause frame */
  4176. #define RB_ETH_MACON1_FCEN 0x30
  4177. #define RB_ETH_MACON1_TXPAUS 0x08 /* RW Send pause frame enable*/
  4178. #define RB_ETH_MACON1_RXPAUS 0x04 /* RW Receive pause frame enable */
  4179. #define RB_ETH_MACON1_PASSALL 0x02 /* RW 1=Unfiltered control frames will be written to the buffer, 0=Control frames will be filtered */
  4180. #define RB_ETH_MACON1_MARXEN 0x01 /* RW MAC layer receive enable */
  4181. #define R8_ETH_MACON2 (*((volatile uint8_t *)(0x40028000+0x1A))) /* Mac Layer Packet Control Register */
  4182. #define RB_ETH_MACON2_PADCFG 0xE0 /* RW Short Packet Padding Settings */
  4183. #define RB_ETH_MACON2_TXCRCEN 0x10 /* RW Send to add crc, if you need to add crc in PADCFG, this position is 1 */
  4184. #define RB_ETH_MACON2_PHDREN 0x08 /* RW Special 4 bytes do not participate in crc check */
  4185. #define RB_ETH_MACON2_HFRMEN 0x04 /* RW Allow jumbo frames */
  4186. #define RB_ETH_MACON2_FULDPX 0x01 /* RW full duplex */
  4187. #define R8_ETH_MABBIPG (*((volatile uint8_t *)(0x40028000+0x1B))) /* Minimum Interpacket Interval Register */
  4188. #define RB_ETH_MABBIPG_MABBIPG 0x7F /* RW Minimum number of bytes between packets */
  4189. #define R32_ETH_TIM (*((volatile uint32_t *)(0x40028000+0x1C)))
  4190. #define R16_ETH_EPAUS (*((volatile uint16_t *)(0x40028000+0x1C))) /* RW Flow Control Pause Frame Time Register */
  4191. #define R16_ETH_MAMXFL (*((volatile uint16_t *)(0x40028000+0x1E))) /* RW Maximum Received Packet Length Register */
  4192. #define R16_ETH_MIRD (*((volatile uint16_t *)(0x40028000+0x20))) /* RW MII read data register */
  4193. #define R32_ETH_MIWR (*((volatile uint32_t *)(0x40028000+0x24)))
  4194. #define R8_ETH_MIREGADR (*((volatile uint8_t *)(0x40028000+0x24))) /* MII address register*/
  4195. #define RB_ETH_MIREGADR_MASK 0x1F /* RW PHY register address mask */
  4196. #define R8_ETH_MISTAT (*((volatile uint8_t *)(0x40028000+0x25))) /* RW PHY register address mask */
  4197. //#define RB_ETH_MIREGADR_MIIWR 0x20 /* WO MII write command */
  4198. #define R16_ETH_MIWR (*((volatile uint16_t *)(0x40028000+0x26))) /* WO MII Write Data Register */
  4199. #define R32_ETH_MAADRL (*((volatile uint32_t *)(0x40028000+0x28))) /* RW MAC 1-4 */
  4200. #define R8_ETH_MAADRL1 (*((volatile uint8_t *)(0x40028000+0x28))) /* RW MAC 1 */
  4201. #define R8_ETH_MAADRL2 (*((volatile uint8_t *)(0x40028000+0x29))) /* RW MAC 2 */
  4202. #define R8_ETH_MAADRL3 (*((volatile uint8_t *)(0x40028000+0x2A))) /* RW MAC 3 */
  4203. #define R8_ETH_MAADRL4 (*((volatile uint8_t *)(0x40028000+0x2B))) /* RW MAC 4 */
  4204. #define R16_ETH_MAADRH (*((volatile uint16_t *)(0x40028000+0x2C))) /* RW MAC 5-6 */
  4205. #define R8_ETH_MAADRL5 (*((volatile uint8_t *)(0x40028000+0x2C))) /* RW MAC 4 */
  4206. #define R8_ETH_MAADRL6 (*((volatile uint8_t *)(0x40028000+0x2D))) /* RW MAC 4 */
  4207. //PHY address
  4208. #define PHY_BMCR 0x00 /* Control Register */
  4209. #define PHY_BMSR 0x01 /* Status Register */
  4210. #define PHY_ANAR 0x04 /* Auto-Negotiation Advertisement Register */
  4211. #define PHY_ANLPAR 0x05 /* Auto-Negotiation Link Partner Base Page Ability Register*/
  4212. #define PHY_ANER 0x06 /* Auto-Negotiation Expansion Register */
  4213. #define PHY_MDIX 0x1e /* Custom MDIX Mode Register */
  4214. //Custom MDIX Mode Register @PHY_MDIX
  4215. #define PN_NORMAL 0x04 /* Analog p, n polarity selection */
  4216. #define MDIX_MODE_MASK 0x03 /* mdix settings */
  4217. #define MDIX_MODE_AUTO 0x00 /* */
  4218. #define MDIX_MODE_MDIX 0x01
  4219. #define MDIX_MODE_MDI 0x02
  4220. //ECON2 test mode, to be determined
  4221. #define RX_VCM_MODE_0
  4222. #define RX_VCM_MODE_1
  4223. #define RX_VCM_MODE_2
  4224. #define RX_VCM_MODE_3
  4225. //RX reference voltage value setting @RX_REF
  4226. #define RX_REF_25mV (0<<2) /* 25mV */
  4227. #define RX_REF_49mV (1<<2) /* 49mV */
  4228. #define RX_REF_74mV (2<<2) /* 74mV */
  4229. #define RX_REF_98mV (3<<2) /* 98mV */
  4230. #define RX_REF_123mV (4<<2) /* 123mV */
  4231. #define RX_REF_148mV (5<<2) /* 148mV */
  4232. #define RX_REF_173mV (6<<2) /* 173mV */
  4233. #define RX_REF_198mV (7<<2) /* 198mV */
  4234. //TX DRIVER Bias Current @TX_AMP
  4235. #define TX_AMP_0 (0<<0) /* 43mA / 14.5mA (1.4V/0.7V) */
  4236. #define TX_AMP_1 (1<<0) /* 53.1mA / 18mA (1.8V/0.9V) */
  4237. #define TX_AMP_2 (2<<0) /* 75.6mA / 25.6mA (2.6V/1.3V) */
  4238. #define TX_AMP_3 (3<<0) /* 122mA / 41.45mA (4.1V/2.3V) */
  4239. //FCEN pause frame control @FCEN
  4240. #define FCEN_0_TIMER (3<<4) /* Send a 0 timer pause frame, then stop sending */
  4241. #define FCEN_CYCLE (2<<4) /* Periodically send pause frames */
  4242. #define FCEN_ONCE (1<<4) /* Send pause frame once, then stop sending */
  4243. #define FCEN_STOP (0<<4) /* Stop sending pause frames */
  4244. //PADCFG short packet control @PADCFG
  4245. #define PADCFG_AUTO_0 (7<<5) /* All short packets are filled with 00h to 64 bytes, then 4 bytes crc */
  4246. #define PADCFG_NO_ACT_0 (6<<5) /* No padding for short packets */
  4247. /* The detected VLAN network packet whose field is 8100h is automatically filled
  4248. with 00h to 64 bytes, otherwise the short packet is filled with 60 bytes of 0, and then 4 bytes of crc after filling */
  4249. #define PADCFG_DETE_AUTO (5<<5)
  4250. #define PADCFG_NO_ACT_1 (4<<5) /* No padding for short packets */
  4251. #define PADCFG_AUTO_1 (3<<5) /* All short packets are filled with 00h to 64 bytes, then 4 bytes crc */
  4252. #define PADCFG_NO_ACT_2 (2<<5) /* No padding for short packets */
  4253. #define PADCFG_AUTO_3 (1<<5) /* All short packets are filled with 00h to 60 bytes, and then 4 bytes crc */
  4254. #define PADCFG_NO_ACT_3 (0<<5) /* No padding for short packets */
  4255. /* Bit or field definition for PHY basic status register */
  4256. #define PHY_Linked_Status ((uint16_t)0x0004) /* Valid link established */
  4257. #define PHY_Reset ((uint16_t)0x8000) /* PHY Reset */
  4258. #define PHY_AutoNego_Complete ((uint16_t)0x0020) /* Auto-Negotioation process completed */
  4259. //MII control
  4260. #define RB_ETH_MIREGADR_MIIWR 0x20 /* WO MII write command */
  4261. #define RB_ETH_MIREGADR_MIRDL 0x1f /* RW PHY register address */
  4262. #include "ch32v20x_conf.h"
  4263. #ifdef __cplusplus
  4264. }
  4265. #endif
  4266. #endif