stm32h7xx_ll_spi.h 125 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_spi.h
  4. * @author MCD Application Team
  5. * @brief Header file of SPI LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32H7xx_LL_SPI_H
  20. #define STM32H7xx_LL_SPI_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h7xx.h"
  26. /** @addtogroup STM32H7xx_LL_Driver
  27. * @{
  28. */
  29. #if defined(SPI1) || defined(SPI2) || defined(SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6)
  30. /** @defgroup SPI_LL SPI
  31. * @{
  32. */
  33. /* Private variables ---------------------------------------------------------*/
  34. /* Private constants ---------------------------------------------------------*/
  35. /* Private macros ------------------------------------------------------------*/
  36. /** @defgroup SPI_LL_Private_Macros SPI Private Macros
  37. * @{
  38. */
  39. /**
  40. * @}
  41. */
  42. /* Exported types ------------------------------------------------------------*/
  43. #if defined(USE_FULL_LL_DRIVER)
  44. /** @defgroup SPI_LL_Exported_Types SPI Exported Types
  45. * @{
  46. */
  47. /**
  48. * @brief SPI Init structures definition
  49. */
  50. typedef struct
  51. {
  52. uint32_t TransferDirection; /*!< Specifies the SPI unidirectional or bidirectional data mode.
  53. This parameter can be a value of @ref SPI_LL_EC_TRANSFER_MODE.
  54. This feature can be modified afterwards using unitary function
  55. @ref LL_SPI_SetTransferDirection().*/
  56. uint32_t Mode; /*!< Specifies the SPI mode (Master/Slave).
  57. This parameter can be a value of @ref SPI_LL_EC_MODE.
  58. This feature can be modified afterwards using unitary function
  59. @ref LL_SPI_SetMode().*/
  60. uint32_t DataWidth; /*!< Specifies the SPI data width.
  61. This parameter can be a value of @ref SPI_LL_EC_DATAWIDTH.
  62. This feature can be modified afterwards using unitary function
  63. @ref LL_SPI_SetDataWidth().*/
  64. uint32_t ClockPolarity; /*!< Specifies the serial clock steady state.
  65. This parameter can be a value of @ref SPI_LL_EC_POLARITY.
  66. This feature can be modified afterwards using unitary function
  67. @ref LL_SPI_SetClockPolarity().*/
  68. uint32_t ClockPhase; /*!< Specifies the clock active edge for the bit capture.
  69. This parameter can be a value of @ref SPI_LL_EC_PHASE.
  70. This feature can be modified afterwards using unitary function
  71. @ref LL_SPI_SetClockPhase().*/
  72. uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin)
  73. or by software using the SSI bit.
  74. This parameter can be a value of @ref SPI_LL_EC_NSS_MODE.
  75. This feature can be modified afterwards using unitary function
  76. @ref LL_SPI_SetNSSMode().*/
  77. uint32_t BaudRate; /*!< Specifies the BaudRate prescaler value which will be used to configure
  78. the transmit and receive SCK clock.
  79. This parameter can be a value of @ref SPI_LL_EC_BAUDRATEPRESCALER.
  80. @note The communication clock is derived from the master clock.
  81. The slave clock does not need to be set.
  82. This feature can be modified afterwards using unitary function
  83. @ref LL_SPI_SetBaudRatePrescaler().*/
  84. uint32_t BitOrder; /*!< Specifies whether data transfers start from MSB or LSB bit.
  85. This parameter can be a value of @ref SPI_LL_EC_BIT_ORDER.
  86. This feature can be modified afterwards using unitary function
  87. @ref LL_SPI_SetTransferBitOrder().*/
  88. uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not.
  89. This parameter can be a value of @ref SPI_LL_EC_CRC_CALCULATION.
  90. This feature can be modified afterwards using unitary functions
  91. @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/
  92. uint32_t CRCPoly; /*!< Specifies the polynomial used for the CRC calculation.
  93. This parameter must be a number between Min_Data = 0x00
  94. and Max_Data = 0xFFFFFFFF.
  95. This feature can be modified afterwards using unitary function
  96. @ref LL_SPI_SetCRCPolynomial().*/
  97. } LL_SPI_InitTypeDef;
  98. /**
  99. * @}
  100. */
  101. #endif /*USE_FULL_LL_DRIVER*/
  102. /* Exported types ------------------------------------------------------------*/
  103. /* Exported constants --------------------------------------------------------*/
  104. /** @defgroup SPI_LL_Exported_Constants SPI Exported Constants
  105. * @{
  106. */
  107. /** @defgroup SPI_LL_EC_GET_FLAG Get Flags Defines
  108. * @brief Flags defines which can be used with LL_SPI_ReadReg function
  109. * @{
  110. */
  111. #define LL_SPI_SR_RXP (SPI_SR_RXP)
  112. #define LL_SPI_SR_TXP (SPI_SR_TXP)
  113. #define LL_SPI_SR_DXP (SPI_SR_DXP)
  114. #define LL_SPI_SR_EOT (SPI_SR_EOT)
  115. #define LL_SPI_SR_TXTF (SPI_SR_TXTF)
  116. #define LL_SPI_SR_UDR (SPI_SR_UDR)
  117. #define LL_SPI_SR_CRCE (SPI_SR_CRCE)
  118. #define LL_SPI_SR_MODF (SPI_SR_MODF)
  119. #define LL_SPI_SR_OVR (SPI_SR_OVR)
  120. #define LL_SPI_SR_TIFRE (SPI_SR_TIFRE)
  121. #define LL_SPI_SR_TSERF (SPI_SR_TSERF)
  122. #define LL_SPI_SR_SUSP (SPI_SR_SUSP)
  123. #define LL_SPI_SR_TXC (SPI_SR_TXC)
  124. #define LL_SPI_SR_RXWNE (SPI_SR_RXWNE)
  125. /**
  126. * @}
  127. */
  128. /** @defgroup SPI_LL_EC_IT IT Defines
  129. * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions
  130. * @{
  131. */
  132. #define LL_SPI_IER_RXPIE (SPI_IER_RXPIE)
  133. #define LL_SPI_IER_TXPIE (SPI_IER_TXPIE)
  134. #define LL_SPI_IER_DXPIE (SPI_IER_DXPIE)
  135. #define LL_SPI_IER_EOTIE (SPI_IER_EOTIE)
  136. #define LL_SPI_IER_TXTFIE (SPI_IER_TXTFIE)
  137. #define LL_SPI_IER_UDRIE (SPI_IER_UDRIE)
  138. #define LL_SPI_IER_OVRIE (SPI_IER_OVRIE)
  139. #define LL_SPI_IER_CRCEIE (SPI_IER_CRCEIE)
  140. #define LL_SPI_IER_TIFREIE (SPI_IER_TIFREIE)
  141. #define LL_SPI_IER_MODFIE (SPI_IER_MODFIE)
  142. #define LL_SPI_IER_TSERFIE (SPI_IER_TSERFIE)
  143. /**
  144. * @}
  145. */
  146. /** @defgroup SPI_LL_EC_MODE Mode
  147. * @{
  148. */
  149. #define LL_SPI_MODE_MASTER (SPI_CFG2_MASTER)
  150. #define LL_SPI_MODE_SLAVE (0x00000000UL)
  151. /**
  152. * @}
  153. */
  154. /** @defgroup SPI_LL_EC_SS_LEVEL SS Level
  155. * @{
  156. */
  157. #define LL_SPI_SS_LEVEL_HIGH (SPI_CR1_SSI)
  158. #define LL_SPI_SS_LEVEL_LOW (0x00000000UL)
  159. /**
  160. * @}
  161. */
  162. /** @defgroup SPI_LL_EC_SS_IDLENESS SS Idleness
  163. * @{
  164. */
  165. #define LL_SPI_SS_IDLENESS_00CYCLE (0x00000000UL)
  166. #define LL_SPI_SS_IDLENESS_01CYCLE (SPI_CFG2_MSSI_0)
  167. #define LL_SPI_SS_IDLENESS_02CYCLE (SPI_CFG2_MSSI_1)
  168. #define LL_SPI_SS_IDLENESS_03CYCLE (SPI_CFG2_MSSI_0 | SPI_CFG2_MSSI_1)
  169. #define LL_SPI_SS_IDLENESS_04CYCLE (SPI_CFG2_MSSI_2)
  170. #define LL_SPI_SS_IDLENESS_05CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_0)
  171. #define LL_SPI_SS_IDLENESS_06CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1)
  172. #define LL_SPI_SS_IDLENESS_07CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0)
  173. #define LL_SPI_SS_IDLENESS_08CYCLE (SPI_CFG2_MSSI_3)
  174. #define LL_SPI_SS_IDLENESS_09CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_0)
  175. #define LL_SPI_SS_IDLENESS_10CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_1)
  176. #define LL_SPI_SS_IDLENESS_11CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0)
  177. #define LL_SPI_SS_IDLENESS_12CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2)
  178. #define LL_SPI_SS_IDLENESS_13CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_0)
  179. #define LL_SPI_SS_IDLENESS_14CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1)
  180. #define LL_SPI_SS_IDLENESS_15CYCLE (SPI_CFG2_MSSI_3\
  181. | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0)
  182. /**
  183. * @}
  184. */
  185. /** @defgroup SPI_LL_EC_ID_IDLENESS Master Inter-Data Idleness
  186. * @{
  187. */
  188. #define LL_SPI_ID_IDLENESS_00CYCLE (0x00000000UL)
  189. #define LL_SPI_ID_IDLENESS_01CYCLE (SPI_CFG2_MIDI_0)
  190. #define LL_SPI_ID_IDLENESS_02CYCLE (SPI_CFG2_MIDI_1)
  191. #define LL_SPI_ID_IDLENESS_03CYCLE (SPI_CFG2_MIDI_0 | SPI_CFG2_MIDI_1)
  192. #define LL_SPI_ID_IDLENESS_04CYCLE (SPI_CFG2_MIDI_2)
  193. #define LL_SPI_ID_IDLENESS_05CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_0)
  194. #define LL_SPI_ID_IDLENESS_06CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1)
  195. #define LL_SPI_ID_IDLENESS_07CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0)
  196. #define LL_SPI_ID_IDLENESS_08CYCLE (SPI_CFG2_MIDI_3)
  197. #define LL_SPI_ID_IDLENESS_09CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_0)
  198. #define LL_SPI_ID_IDLENESS_10CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_1)
  199. #define LL_SPI_ID_IDLENESS_11CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0)
  200. #define LL_SPI_ID_IDLENESS_12CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2)
  201. #define LL_SPI_ID_IDLENESS_13CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_0)
  202. #define LL_SPI_ID_IDLENESS_14CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1)
  203. #define LL_SPI_ID_IDLENESS_15CYCLE (SPI_CFG2_MIDI_3\
  204. | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0)
  205. /**
  206. * @}
  207. */
  208. /** @defgroup SPI_LL_EC_TXCRCINIT_ALL TXCRC Init All
  209. * @{
  210. */
  211. #define LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN (0x00000000UL)
  212. #define LL_SPI_TXCRCINIT_ALL_ONES_PATTERN (SPI_CR1_TCRCINI)
  213. /**
  214. * @}
  215. */
  216. /** @defgroup SPI_LL_EC_RXCRCINIT_ALL RXCRC Init All
  217. * @{
  218. */
  219. #define LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN (0x00000000UL)
  220. #define LL_SPI_RXCRCINIT_ALL_ONES_PATTERN (SPI_CR1_RCRCINI)
  221. /**
  222. * @}
  223. */
  224. /** @defgroup SPI_LL_EC_UDR_CONFIG_REGISTER UDR Config Register
  225. * @{
  226. */
  227. #define LL_SPI_UDR_CONFIG_REGISTER_PATTERN (0x00000000UL)
  228. #define LL_SPI_UDR_CONFIG_LAST_RECEIVED (SPI_CFG1_UDRCFG_0)
  229. #define LL_SPI_UDR_CONFIG_LAST_TRANSMITTED (SPI_CFG1_UDRCFG_1)
  230. /**
  231. * @}
  232. */
  233. /** @defgroup SPI_LL_EC_UDR_DETECT_BEGIN_DATA UDR Detect Begin Data
  234. * @{
  235. */
  236. #define LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME (0x00000000UL)
  237. #define LL_SPI_UDR_DETECT_END_DATA_FRAME (SPI_CFG1_UDRDET_0)
  238. #define LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS (SPI_CFG1_UDRDET_1)
  239. /**
  240. * @}
  241. */
  242. /** @defgroup SPI_LL_EC_PROTOCOL Protocol
  243. * @{
  244. */
  245. #define LL_SPI_PROTOCOL_MOTOROLA (0x00000000UL)
  246. #define LL_SPI_PROTOCOL_TI (SPI_CFG2_SP_0)
  247. /**
  248. * @}
  249. */
  250. /** @defgroup SPI_LL_EC_PHASE Phase
  251. * @{
  252. */
  253. #define LL_SPI_PHASE_1EDGE (0x00000000UL)
  254. #define LL_SPI_PHASE_2EDGE (SPI_CFG2_CPHA)
  255. /**
  256. * @}
  257. */
  258. /** @defgroup SPI_LL_EC_POLARITY Polarity
  259. * @{
  260. */
  261. #define LL_SPI_POLARITY_LOW (0x00000000UL)
  262. #define LL_SPI_POLARITY_HIGH (SPI_CFG2_CPOL)
  263. /**
  264. * @}
  265. */
  266. /** @defgroup SPI_LL_EC_NSS_POLARITY NSS Polarity
  267. * @{
  268. */
  269. #define LL_SPI_NSS_POLARITY_LOW (0x00000000UL)
  270. #define LL_SPI_NSS_POLARITY_HIGH (SPI_CFG2_SSIOP)
  271. /**
  272. * @}
  273. */
  274. /** @defgroup SPI_LL_EC_BAUDRATEPRESCALER Baud Rate Prescaler
  275. * @{
  276. */
  277. #define LL_SPI_BAUDRATEPRESCALER_DIV2 (0x00000000UL)
  278. #define LL_SPI_BAUDRATEPRESCALER_DIV4 (SPI_CFG1_MBR_0)
  279. #define LL_SPI_BAUDRATEPRESCALER_DIV8 (SPI_CFG1_MBR_1)
  280. #define LL_SPI_BAUDRATEPRESCALER_DIV16 (SPI_CFG1_MBR_1 | SPI_CFG1_MBR_0)
  281. #define LL_SPI_BAUDRATEPRESCALER_DIV32 (SPI_CFG1_MBR_2)
  282. #define LL_SPI_BAUDRATEPRESCALER_DIV64 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_0)
  283. #define LL_SPI_BAUDRATEPRESCALER_DIV128 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_1)
  284. #define LL_SPI_BAUDRATEPRESCALER_DIV256 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_1 | SPI_CFG1_MBR_0)
  285. /**
  286. * @}
  287. */
  288. /** @defgroup SPI_LL_EC_BIT_ORDER Bit Order
  289. * @{
  290. */
  291. #define LL_SPI_LSB_FIRST (SPI_CFG2_LSBFRST)
  292. #define LL_SPI_MSB_FIRST (0x00000000UL)
  293. /**
  294. * @}
  295. */
  296. /** @defgroup SPI_LL_EC_TRANSFER_MODE Transfer Mode
  297. * @{
  298. */
  299. #define LL_SPI_FULL_DUPLEX (0x00000000UL)
  300. #define LL_SPI_SIMPLEX_TX (SPI_CFG2_COMM_0)
  301. #define LL_SPI_SIMPLEX_RX (SPI_CFG2_COMM_1)
  302. #define LL_SPI_HALF_DUPLEX_RX (SPI_CFG2_COMM_0|SPI_CFG2_COMM_1)
  303. #define LL_SPI_HALF_DUPLEX_TX (SPI_CFG2_COMM_0|SPI_CFG2_COMM_1|SPI_CR1_HDDIR)
  304. /**
  305. * @}
  306. */
  307. /** @defgroup SPI_LL_EC_DATAWIDTH Data Width
  308. * @{
  309. */
  310. #define LL_SPI_DATAWIDTH_4BIT (SPI_CFG1_DSIZE_0 | SPI_CFG1_DSIZE_1)
  311. #define LL_SPI_DATAWIDTH_5BIT (SPI_CFG1_DSIZE_2)
  312. #define LL_SPI_DATAWIDTH_6BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0)
  313. #define LL_SPI_DATAWIDTH_7BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1)
  314. #define LL_SPI_DATAWIDTH_8BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  315. #define LL_SPI_DATAWIDTH_9BIT (SPI_CFG1_DSIZE_3)
  316. #define LL_SPI_DATAWIDTH_10BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_0)
  317. #define LL_SPI_DATAWIDTH_11BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1)
  318. #define LL_SPI_DATAWIDTH_12BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  319. #define LL_SPI_DATAWIDTH_13BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2)
  320. #define LL_SPI_DATAWIDTH_14BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0)
  321. #define LL_SPI_DATAWIDTH_15BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1)
  322. #define LL_SPI_DATAWIDTH_16BIT (SPI_CFG1_DSIZE_3\
  323. | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  324. #define LL_SPI_DATAWIDTH_17BIT (SPI_CFG1_DSIZE_4)
  325. #define LL_SPI_DATAWIDTH_18BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_0)
  326. #define LL_SPI_DATAWIDTH_19BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_1)
  327. #define LL_SPI_DATAWIDTH_20BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_0 | SPI_CFG1_DSIZE_1)
  328. #define LL_SPI_DATAWIDTH_21BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2)
  329. #define LL_SPI_DATAWIDTH_22BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0)
  330. #define LL_SPI_DATAWIDTH_23BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1)
  331. #define LL_SPI_DATAWIDTH_24BIT (SPI_CFG1_DSIZE_4\
  332. | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  333. #define LL_SPI_DATAWIDTH_25BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3)
  334. #define LL_SPI_DATAWIDTH_26BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_0)
  335. #define LL_SPI_DATAWIDTH_27BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1)
  336. #define LL_SPI_DATAWIDTH_28BIT (SPI_CFG1_DSIZE_4\
  337. | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  338. #define LL_SPI_DATAWIDTH_29BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2)
  339. #define LL_SPI_DATAWIDTH_30BIT (SPI_CFG1_DSIZE_4\
  340. | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0)
  341. #define LL_SPI_DATAWIDTH_31BIT (SPI_CFG1_DSIZE_4\
  342. | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1)
  343. #define LL_SPI_DATAWIDTH_32BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3\
  344. | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0)
  345. /**
  346. * @}
  347. */
  348. /** @defgroup SPI_LL_EC_FIFO_TH FIFO Threshold
  349. * @{
  350. */
  351. #define LL_SPI_FIFO_TH_01DATA (0x00000000UL)
  352. #define LL_SPI_FIFO_TH_02DATA (SPI_CFG1_FTHLV_0)
  353. #define LL_SPI_FIFO_TH_03DATA (SPI_CFG1_FTHLV_1)
  354. #define LL_SPI_FIFO_TH_04DATA (SPI_CFG1_FTHLV_0 | SPI_CFG1_FTHLV_1)
  355. #define LL_SPI_FIFO_TH_05DATA (SPI_CFG1_FTHLV_2)
  356. #define LL_SPI_FIFO_TH_06DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_0)
  357. #define LL_SPI_FIFO_TH_07DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1)
  358. #define LL_SPI_FIFO_TH_08DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0)
  359. #define LL_SPI_FIFO_TH_09DATA (SPI_CFG1_FTHLV_3)
  360. #define LL_SPI_FIFO_TH_10DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_0)
  361. #define LL_SPI_FIFO_TH_11DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_1)
  362. #define LL_SPI_FIFO_TH_12DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0)
  363. #define LL_SPI_FIFO_TH_13DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2)
  364. #define LL_SPI_FIFO_TH_14DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_0)
  365. #define LL_SPI_FIFO_TH_15DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1)
  366. #define LL_SPI_FIFO_TH_16DATA (SPI_CFG1_FTHLV_3\
  367. | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0)
  368. /**
  369. * @}
  370. */
  371. #if defined(USE_FULL_LL_DRIVER)
  372. /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation
  373. * @{
  374. */
  375. #define LL_SPI_CRCCALCULATION_DISABLE (0x00000000UL) /*!< CRC calculation disabled */
  376. #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CFG1_CRCEN) /*!< CRC calculation enabled */
  377. /**
  378. * @}
  379. */
  380. #endif /* USE_FULL_LL_DRIVER */
  381. /** @defgroup SPI_LL_EC_CRC CRC
  382. * @{
  383. */
  384. #define LL_SPI_CRC_4BIT (SPI_CFG1_CRCSIZE_0 | SPI_CFG1_CRCSIZE_1)
  385. #define LL_SPI_CRC_5BIT (SPI_CFG1_CRCSIZE_2)
  386. #define LL_SPI_CRC_6BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0)
  387. #define LL_SPI_CRC_7BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1)
  388. #define LL_SPI_CRC_8BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  389. #define LL_SPI_CRC_9BIT (SPI_CFG1_CRCSIZE_3)
  390. #define LL_SPI_CRC_10BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_0)
  391. #define LL_SPI_CRC_11BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1)
  392. #define LL_SPI_CRC_12BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  393. #define LL_SPI_CRC_13BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2)
  394. #define LL_SPI_CRC_14BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0)
  395. #define LL_SPI_CRC_15BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1)
  396. #define LL_SPI_CRC_16BIT (SPI_CFG1_CRCSIZE_3\
  397. | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  398. #define LL_SPI_CRC_17BIT (SPI_CFG1_CRCSIZE_4)
  399. #define LL_SPI_CRC_18BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_0)
  400. #define LL_SPI_CRC_19BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_1)
  401. #define LL_SPI_CRC_20BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_0 | SPI_CFG1_CRCSIZE_1)
  402. #define LL_SPI_CRC_21BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2)
  403. #define LL_SPI_CRC_22BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0)
  404. #define LL_SPI_CRC_23BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1)
  405. #define LL_SPI_CRC_24BIT (SPI_CFG1_CRCSIZE_4\
  406. | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  407. #define LL_SPI_CRC_25BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3)
  408. #define LL_SPI_CRC_26BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_0)
  409. #define LL_SPI_CRC_27BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1)
  410. #define LL_SPI_CRC_28BIT (SPI_CFG1_CRCSIZE_4\
  411. | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  412. #define LL_SPI_CRC_29BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2)
  413. #define LL_SPI_CRC_30BIT (SPI_CFG1_CRCSIZE_4\
  414. | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0)
  415. #define LL_SPI_CRC_31BIT (SPI_CFG1_CRCSIZE_4\
  416. | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1)
  417. #define LL_SPI_CRC_32BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3\
  418. | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0)
  419. /**
  420. * @}
  421. */
  422. /** @defgroup SPI_LL_EC_NSS_MODE NSS Mode
  423. * @{
  424. */
  425. #define LL_SPI_NSS_SOFT (SPI_CFG2_SSM)
  426. #define LL_SPI_NSS_HARD_INPUT (0x00000000UL)
  427. #define LL_SPI_NSS_HARD_OUTPUT (SPI_CFG2_SSOE)
  428. /**
  429. * @}
  430. */
  431. /** @defgroup SPI_LL_EC_RX_FIFO RxFIFO Packing LeVel
  432. * @{
  433. */
  434. #define LL_SPI_RX_FIFO_0PACKET (0x00000000UL) /* 0 or multiple of 4 packet available is the RxFIFO */
  435. #define LL_SPI_RX_FIFO_1PACKET (SPI_SR_RXPLVL_0)
  436. #define LL_SPI_RX_FIFO_2PACKET (SPI_SR_RXPLVL_1)
  437. #define LL_SPI_RX_FIFO_3PACKET (SPI_SR_RXPLVL_1 | SPI_SR_RXPLVL_0)
  438. /**
  439. * @}
  440. */
  441. /**
  442. * @}
  443. */
  444. /* Exported macro ------------------------------------------------------------*/
  445. /** @defgroup SPI_LL_Exported_Macros SPI Exported Macros
  446. * @{
  447. */
  448. /** @defgroup SPI_LL_EM_WRITE_READ Common Write and read registers Macros
  449. * @{
  450. */
  451. /**
  452. * @brief Write a value in SPI register
  453. * @param __INSTANCE__ SPI Instance
  454. * @param __REG__ Register to be written
  455. * @param __VALUE__ Value to be written in the register
  456. * @retval None
  457. */
  458. #define LL_SPI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  459. /**
  460. * @brief Read a value in SPI register
  461. * @param __INSTANCE__ SPI Instance
  462. * @param __REG__ Register to be read
  463. * @retval Register value
  464. */
  465. #define LL_SPI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  466. /**
  467. * @}
  468. */
  469. /**
  470. * @}
  471. */
  472. /* Exported functions --------------------------------------------------------*/
  473. /** @defgroup SPI_LL_Exported_Functions SPI Exported Functions
  474. * @{
  475. */
  476. /** @defgroup SPI_LL_EF_Configuration Configuration
  477. * @{
  478. */
  479. /**
  480. * @brief Enable SPI peripheral
  481. * @rmtoll CR1 SPE LL_SPI_Enable
  482. * @param SPIx SPI Instance
  483. * @retval None
  484. */
  485. __STATIC_INLINE void LL_SPI_Enable(SPI_TypeDef *SPIx)
  486. {
  487. SET_BIT(SPIx->CR1, SPI_CR1_SPE);
  488. }
  489. /**
  490. * @brief Disable SPI peripheral
  491. * @note When disabling the SPI, follow the procedure described in the Reference Manual.
  492. * @rmtoll CR1 SPE LL_SPI_Disable
  493. * @param SPIx SPI Instance
  494. * @retval None
  495. */
  496. __STATIC_INLINE void LL_SPI_Disable(SPI_TypeDef *SPIx)
  497. {
  498. CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  499. }
  500. /**
  501. * @brief Check if SPI peripheral is enabled
  502. * @rmtoll CR1 SPE LL_SPI_IsEnabled
  503. * @param SPIx SPI Instance
  504. * @retval State of bit (1 or 0)
  505. */
  506. __STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx)
  507. {
  508. return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL);
  509. }
  510. /**
  511. * @brief Swap the MOSI and MISO pin
  512. * @note This configuration can not be changed when SPI is enabled.
  513. * @rmtoll CFG2 IOSWP LL_SPI_EnableIOSwap
  514. * @param SPIx SPI Instance
  515. * @retval None
  516. */
  517. __STATIC_INLINE void LL_SPI_EnableIOSwap(SPI_TypeDef *SPIx)
  518. {
  519. SET_BIT(SPIx->CFG2, SPI_CFG2_IOSWP);
  520. }
  521. /**
  522. * @brief Restore default function for MOSI and MISO pin
  523. * @note This configuration can not be changed when SPI is enabled.
  524. * @rmtoll CFG2 IOSWP LL_SPI_DisableIOSwap
  525. * @param SPIx SPI Instance
  526. * @retval None
  527. */
  528. __STATIC_INLINE void LL_SPI_DisableIOSwap(SPI_TypeDef *SPIx)
  529. {
  530. CLEAR_BIT(SPIx->CFG2, SPI_CFG2_IOSWP);
  531. }
  532. /**
  533. * @brief Check if MOSI and MISO pin are swapped
  534. * @rmtoll CFG2 IOSWP LL_SPI_IsEnabledIOSwap
  535. * @param SPIx SPI Instance
  536. * @retval State of bit (1 or 0)
  537. */
  538. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIOSwap(SPI_TypeDef *SPIx)
  539. {
  540. return ((READ_BIT(SPIx->CFG2, SPI_CFG2_IOSWP) == (SPI_CFG2_IOSWP)) ? 1UL : 0UL);
  541. }
  542. /**
  543. * @brief Enable GPIO control
  544. * @note This configuration can not be changed when SPI is enabled.
  545. * @rmtoll CFG2 AFCNTR LL_SPI_EnableGPIOControl
  546. * @param SPIx SPI Instance
  547. * @retval None
  548. */
  549. __STATIC_INLINE void LL_SPI_EnableGPIOControl(SPI_TypeDef *SPIx)
  550. {
  551. SET_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR);
  552. }
  553. /**
  554. * @brief Disable GPIO control
  555. * @note This configuration can not be changed when SPI is enabled.
  556. * @rmtoll CFG2 AFCNTR LL_SPI_DisableGPIOControl
  557. * @param SPIx SPI Instance
  558. * @retval None
  559. */
  560. __STATIC_INLINE void LL_SPI_DisableGPIOControl(SPI_TypeDef *SPIx)
  561. {
  562. CLEAR_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR);
  563. }
  564. /**
  565. * @brief Check if GPIO control is active
  566. * @rmtoll CFG2 AFCNTR LL_SPI_IsEnabledGPIOControl
  567. * @param SPIx SPI Instance
  568. * @retval State of bit (1 or 0)
  569. */
  570. __STATIC_INLINE uint32_t LL_SPI_IsEnabledGPIOControl(SPI_TypeDef *SPIx)
  571. {
  572. return ((READ_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR) == (SPI_CFG2_AFCNTR)) ? 1UL : 0UL);
  573. }
  574. /**
  575. * @brief Set SPI Mode to Master or Slave
  576. * @note This configuration can not be changed when SPI is enabled.
  577. * @rmtoll CFG2 MASTER LL_SPI_SetMode
  578. * @param SPIx SPI Instance
  579. * @param Mode This parameter can be one of the following values:
  580. * @arg @ref LL_SPI_MODE_MASTER
  581. * @arg @ref LL_SPI_MODE_SLAVE
  582. * @retval None
  583. */
  584. __STATIC_INLINE void LL_SPI_SetMode(SPI_TypeDef *SPIx, uint32_t Mode)
  585. {
  586. MODIFY_REG(SPIx->CFG2, SPI_CFG2_MASTER, Mode);
  587. }
  588. /**
  589. * @brief Get SPI Mode (Master or Slave)
  590. * @rmtoll CFG2 MASTER LL_SPI_GetMode
  591. * @param SPIx SPI Instance
  592. * @retval Returned value can be one of the following values:
  593. * @arg @ref LL_SPI_MODE_MASTER
  594. * @arg @ref LL_SPI_MODE_SLAVE
  595. */
  596. __STATIC_INLINE uint32_t LL_SPI_GetMode(SPI_TypeDef *SPIx)
  597. {
  598. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MASTER));
  599. }
  600. /**
  601. * @brief Configure the Idleness applied by master between active edge of SS and first send data
  602. * @rmtoll CFG2 MSSI LL_SPI_SetMasterSSIdleness
  603. * @param SPIx SPI Instance
  604. * @param MasterSSIdleness This parameter can be one of the following values:
  605. * @arg @ref LL_SPI_SS_IDLENESS_00CYCLE
  606. * @arg @ref LL_SPI_SS_IDLENESS_01CYCLE
  607. * @arg @ref LL_SPI_SS_IDLENESS_02CYCLE
  608. * @arg @ref LL_SPI_SS_IDLENESS_03CYCLE
  609. * @arg @ref LL_SPI_SS_IDLENESS_04CYCLE
  610. * @arg @ref LL_SPI_SS_IDLENESS_05CYCLE
  611. * @arg @ref LL_SPI_SS_IDLENESS_06CYCLE
  612. * @arg @ref LL_SPI_SS_IDLENESS_07CYCLE
  613. * @arg @ref LL_SPI_SS_IDLENESS_08CYCLE
  614. * @arg @ref LL_SPI_SS_IDLENESS_09CYCLE
  615. * @arg @ref LL_SPI_SS_IDLENESS_10CYCLE
  616. * @arg @ref LL_SPI_SS_IDLENESS_11CYCLE
  617. * @arg @ref LL_SPI_SS_IDLENESS_12CYCLE
  618. * @arg @ref LL_SPI_SS_IDLENESS_13CYCLE
  619. * @arg @ref LL_SPI_SS_IDLENESS_14CYCLE
  620. * @arg @ref LL_SPI_SS_IDLENESS_15CYCLE
  621. * @retval None
  622. */
  623. __STATIC_INLINE void LL_SPI_SetMasterSSIdleness(SPI_TypeDef *SPIx, uint32_t MasterSSIdleness)
  624. {
  625. MODIFY_REG(SPIx->CFG2, SPI_CFG2_MSSI, MasterSSIdleness);
  626. }
  627. /**
  628. * @brief Get the configured Idleness applied by master
  629. * @rmtoll CFG2 MSSI LL_SPI_GetMasterSSIdleness
  630. * @param SPIx SPI Instance
  631. * @retval Returned value can be one of the following values:
  632. * @arg @ref LL_SPI_SS_IDLENESS_00CYCLE
  633. * @arg @ref LL_SPI_SS_IDLENESS_01CYCLE
  634. * @arg @ref LL_SPI_SS_IDLENESS_02CYCLE
  635. * @arg @ref LL_SPI_SS_IDLENESS_03CYCLE
  636. * @arg @ref LL_SPI_SS_IDLENESS_04CYCLE
  637. * @arg @ref LL_SPI_SS_IDLENESS_05CYCLE
  638. * @arg @ref LL_SPI_SS_IDLENESS_06CYCLE
  639. * @arg @ref LL_SPI_SS_IDLENESS_07CYCLE
  640. * @arg @ref LL_SPI_SS_IDLENESS_08CYCLE
  641. * @arg @ref LL_SPI_SS_IDLENESS_09CYCLE
  642. * @arg @ref LL_SPI_SS_IDLENESS_10CYCLE
  643. * @arg @ref LL_SPI_SS_IDLENESS_11CYCLE
  644. * @arg @ref LL_SPI_SS_IDLENESS_12CYCLE
  645. * @arg @ref LL_SPI_SS_IDLENESS_13CYCLE
  646. * @arg @ref LL_SPI_SS_IDLENESS_14CYCLE
  647. * @arg @ref LL_SPI_SS_IDLENESS_15CYCLE
  648. */
  649. __STATIC_INLINE uint32_t LL_SPI_GetMasterSSIdleness(SPI_TypeDef *SPIx)
  650. {
  651. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MSSI));
  652. }
  653. /**
  654. * @brief Configure the idleness applied by master between data frame
  655. * @rmtoll CFG2 MIDI LL_SPI_SetInterDataIdleness
  656. * @param SPIx SPI Instance
  657. * @param MasterInterDataIdleness This parameter can be one of the following values:
  658. * @arg @ref LL_SPI_ID_IDLENESS_00CYCLE
  659. * @arg @ref LL_SPI_ID_IDLENESS_01CYCLE
  660. * @arg @ref LL_SPI_ID_IDLENESS_02CYCLE
  661. * @arg @ref LL_SPI_ID_IDLENESS_03CYCLE
  662. * @arg @ref LL_SPI_ID_IDLENESS_04CYCLE
  663. * @arg @ref LL_SPI_ID_IDLENESS_05CYCLE
  664. * @arg @ref LL_SPI_ID_IDLENESS_06CYCLE
  665. * @arg @ref LL_SPI_ID_IDLENESS_07CYCLE
  666. * @arg @ref LL_SPI_ID_IDLENESS_08CYCLE
  667. * @arg @ref LL_SPI_ID_IDLENESS_09CYCLE
  668. * @arg @ref LL_SPI_ID_IDLENESS_10CYCLE
  669. * @arg @ref LL_SPI_ID_IDLENESS_11CYCLE
  670. * @arg @ref LL_SPI_ID_IDLENESS_12CYCLE
  671. * @arg @ref LL_SPI_ID_IDLENESS_13CYCLE
  672. * @arg @ref LL_SPI_ID_IDLENESS_14CYCLE
  673. * @arg @ref LL_SPI_ID_IDLENESS_15CYCLE
  674. * @retval None
  675. */
  676. __STATIC_INLINE void LL_SPI_SetInterDataIdleness(SPI_TypeDef *SPIx, uint32_t MasterInterDataIdleness)
  677. {
  678. MODIFY_REG(SPIx->CFG2, SPI_CFG2_MIDI, MasterInterDataIdleness);
  679. }
  680. /**
  681. * @brief Get the configured inter data idleness
  682. * @rmtoll CFG2 MIDI LL_SPI_SetInterDataIdleness
  683. * @param SPIx SPI Instance
  684. * @retval Returned value can be one of the following values:
  685. * @arg @ref LL_SPI_ID_IDLENESS_00CYCLE
  686. * @arg @ref LL_SPI_ID_IDLENESS_01CYCLE
  687. * @arg @ref LL_SPI_ID_IDLENESS_02CYCLE
  688. * @arg @ref LL_SPI_ID_IDLENESS_03CYCLE
  689. * @arg @ref LL_SPI_ID_IDLENESS_04CYCLE
  690. * @arg @ref LL_SPI_ID_IDLENESS_05CYCLE
  691. * @arg @ref LL_SPI_ID_IDLENESS_06CYCLE
  692. * @arg @ref LL_SPI_ID_IDLENESS_07CYCLE
  693. * @arg @ref LL_SPI_ID_IDLENESS_08CYCLE
  694. * @arg @ref LL_SPI_ID_IDLENESS_09CYCLE
  695. * @arg @ref LL_SPI_ID_IDLENESS_10CYCLE
  696. * @arg @ref LL_SPI_ID_IDLENESS_11CYCLE
  697. * @arg @ref LL_SPI_ID_IDLENESS_12CYCLE
  698. * @arg @ref LL_SPI_ID_IDLENESS_13CYCLE
  699. * @arg @ref LL_SPI_ID_IDLENESS_14CYCLE
  700. * @arg @ref LL_SPI_ID_IDLENESS_15CYCLE
  701. */
  702. __STATIC_INLINE uint32_t LL_SPI_GetInterDataIdleness(SPI_TypeDef *SPIx)
  703. {
  704. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MIDI));
  705. }
  706. /**
  707. * @brief Set transfer size
  708. * @note Count is the number of frame to be transferred
  709. * @rmtoll CR2 TSIZE LL_SPI_SetTransferSize
  710. * @param SPIx SPI Instance
  711. * @param Count 0..0xFFFF
  712. * @retval None
  713. */
  714. __STATIC_INLINE void LL_SPI_SetTransferSize(SPI_TypeDef *SPIx, uint32_t Count)
  715. {
  716. MODIFY_REG(SPIx->CR2, SPI_CR2_TSIZE, Count);
  717. }
  718. /**
  719. * @brief Get transfer size
  720. * @note Count is the number of frame to be transferred
  721. * @rmtoll CR2 TSIZE LL_SPI_GetTransferSize
  722. * @param SPIx SPI Instance
  723. * @retval 0..0xFFFF
  724. */
  725. __STATIC_INLINE uint32_t LL_SPI_GetTransferSize(SPI_TypeDef *SPIx)
  726. {
  727. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_TSIZE));
  728. }
  729. /**
  730. * @brief Set reload transfer size
  731. * @note Count is the number of frame to be transferred
  732. * @rmtoll CR2 TSER LL_SPI_SetReloadSize
  733. * @param SPIx SPI Instance
  734. * @param Count 0..0xFFFF
  735. * @retval None
  736. */
  737. __STATIC_INLINE void LL_SPI_SetReloadSize(SPI_TypeDef *SPIx, uint32_t Count)
  738. {
  739. MODIFY_REG(SPIx->CR2, SPI_CR2_TSER, Count << SPI_CR2_TSER_Pos);
  740. }
  741. /**
  742. * @brief Get reload transfer size
  743. * @note Count is the number of frame to be transferred
  744. * @rmtoll CR2 TSER LL_SPI_GetReloadSize
  745. * @param SPIx SPI Instance
  746. * @retval 0..0xFFFF
  747. */
  748. __STATIC_INLINE uint32_t LL_SPI_GetReloadSize(SPI_TypeDef *SPIx)
  749. {
  750. return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_TSER) >> SPI_CR2_TSER_Pos);
  751. }
  752. /**
  753. * @brief Lock the AF configuration of associated IOs
  754. * @note Once this bit is set, the AF configuration remains locked until a hardware reset occurs.
  755. * the reset of the IOLock bit is done by hardware. for that, LL_SPI_DisableIOLock can not exist.
  756. * @rmtoll CR1 IOLOCK LL_SPI_EnableIOLock
  757. * @param SPIx SPI Instance
  758. * @retval None
  759. */
  760. __STATIC_INLINE void LL_SPI_EnableIOLock(SPI_TypeDef *SPIx)
  761. {
  762. SET_BIT(SPIx->CR1, SPI_CR1_IOLOCK);
  763. }
  764. /**
  765. * @brief Check if the AF configuration is locked.
  766. * @rmtoll CR1 IOLOCK LL_SPI_IsEnabledIOLock
  767. * @param SPIx SPI Instance
  768. * @retval State of bit (1 or 0)
  769. */
  770. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIOLock(SPI_TypeDef *SPIx)
  771. {
  772. return ((READ_BIT(SPIx->CR1, SPI_CR1_IOLOCK) == (SPI_CR1_IOLOCK)) ? 1UL : 0UL);
  773. }
  774. /**
  775. * @brief Set Tx CRC Initialization Pattern
  776. * @rmtoll CR1 TCRCINI LL_SPI_SetTxCRCInitPattern
  777. * @param SPIx SPI Instance
  778. * @param TXCRCInitAll This parameter can be one of the following values:
  779. * @arg @ref LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN
  780. * @arg @ref LL_SPI_TXCRCINIT_ALL_ONES_PATTERN
  781. * @retval None
  782. */
  783. __STATIC_INLINE void LL_SPI_SetTxCRCInitPattern(SPI_TypeDef *SPIx, uint32_t TXCRCInitAll)
  784. {
  785. MODIFY_REG(SPIx->CR1, SPI_CR1_RCRCINI, TXCRCInitAll);
  786. }
  787. /**
  788. * @brief Get Tx CRC Initialization Pattern
  789. * @rmtoll CR1 TCRCINI LL_SPI_GetTxCRCInitPattern
  790. * @param SPIx SPI Instance
  791. * @retval Returned value can be one of the following values:
  792. * @arg @ref LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN
  793. * @arg @ref LL_SPI_TXCRCINIT_ALL_ONES_PATTERN
  794. */
  795. __STATIC_INLINE uint32_t LL_SPI_GetTxCRCInitPattern(SPI_TypeDef *SPIx)
  796. {
  797. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_TCRCINI));
  798. }
  799. /**
  800. * @brief Set Rx CRC Initialization Pattern
  801. * @rmtoll CR1 RCRCINI LL_SPI_SetRxCRCInitPattern
  802. * @param SPIx SPI Instance
  803. * @param RXCRCInitAll This parameter can be one of the following values:
  804. * @arg @ref LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN
  805. * @arg @ref LL_SPI_RXCRCINIT_ALL_ONES_PATTERN
  806. * @retval None
  807. */
  808. __STATIC_INLINE void LL_SPI_SetRxCRCInitPattern(SPI_TypeDef *SPIx, uint32_t RXCRCInitAll)
  809. {
  810. MODIFY_REG(SPIx->CR1, SPI_CR1_RCRCINI, RXCRCInitAll);
  811. }
  812. /**
  813. * @brief Get Rx CRC Initialization Pattern
  814. * @rmtoll CR1 RCRCINI LL_SPI_GetRxCRCInitPattern
  815. * @param SPIx SPI Instance
  816. * @retval Returned value can be one of the following values:
  817. * @arg @ref LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN
  818. * @arg @ref LL_SPI_RXCRCINIT_ALL_ONES_PATTERN
  819. */
  820. __STATIC_INLINE uint32_t LL_SPI_GetRxCRCInitPattern(SPI_TypeDef *SPIx)
  821. {
  822. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RCRCINI));
  823. }
  824. /**
  825. * @brief Set internal SS input level ignoring what comes from PIN.
  826. * @note This configuration has effect only with config LL_SPI_NSS_SOFT
  827. * @rmtoll CR1 SSI LL_SPI_SetInternalSSLevel
  828. * @param SPIx SPI Instance
  829. * @param SSLevel This parameter can be one of the following values:
  830. * @arg @ref LL_SPI_SS_LEVEL_HIGH
  831. * @arg @ref LL_SPI_SS_LEVEL_LOW
  832. * @retval None
  833. */
  834. __STATIC_INLINE void LL_SPI_SetInternalSSLevel(SPI_TypeDef *SPIx, uint32_t SSLevel)
  835. {
  836. MODIFY_REG(SPIx->CR1, SPI_CR1_SSI, SSLevel);
  837. }
  838. /**
  839. * @brief Get internal SS input level
  840. * @rmtoll CR1 SSI LL_SPI_GetInternalSSLevel
  841. * @param SPIx SPI Instance
  842. * @retval Returned value can be one of the following values:
  843. * @arg @ref LL_SPI_SS_LEVEL_HIGH
  844. * @arg @ref LL_SPI_SS_LEVEL_LOW
  845. */
  846. __STATIC_INLINE uint32_t LL_SPI_GetInternalSSLevel(SPI_TypeDef *SPIx)
  847. {
  848. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_SSI));
  849. }
  850. /**
  851. * @brief Enable CRC computation on 33/17 bits
  852. * @rmtoll CR1 CRC33_17 LL_SPI_EnableFullSizeCRC
  853. * @param SPIx SPI Instance
  854. * @retval None
  855. */
  856. __STATIC_INLINE void LL_SPI_EnableFullSizeCRC(SPI_TypeDef *SPIx)
  857. {
  858. SET_BIT(SPIx->CR1, SPI_CR1_CRC33_17);
  859. }
  860. /**
  861. * @brief Disable CRC computation on 33/17 bits
  862. * @rmtoll CR1 CRC33_17 LL_SPI_DisableFullSizeCRC
  863. * @param SPIx SPI Instance
  864. * @retval None
  865. */
  866. __STATIC_INLINE void LL_SPI_DisableFullSizeCRC(SPI_TypeDef *SPIx)
  867. {
  868. CLEAR_BIT(SPIx->CR1, SPI_CR1_CRC33_17);
  869. }
  870. /**
  871. * @brief Check if Enable CRC computation on 33/17 bits is enabled
  872. * @rmtoll CR1 CRC33_17 LL_SPI_IsEnabledFullSizeCRC
  873. * @param SPIx SPI Instance
  874. * @retval State of bit (1 or 0)
  875. */
  876. __STATIC_INLINE uint32_t LL_SPI_IsEnabledFullSizeCRC(SPI_TypeDef *SPIx)
  877. {
  878. return ((READ_BIT(SPIx->CR1, SPI_CR1_CRC33_17) == (SPI_CR1_CRC33_17)) ? 1UL : 0UL);
  879. }
  880. /**
  881. * @brief Suspend an ongoing transfer for Master configuration
  882. * @rmtoll CR1 CSUSP LL_SPI_SuspendMasterTransfer
  883. * @param SPIx SPI Instance
  884. * @retval None
  885. */
  886. __STATIC_INLINE void LL_SPI_SuspendMasterTransfer(SPI_TypeDef *SPIx)
  887. {
  888. SET_BIT(SPIx->CR1, SPI_CR1_CSUSP);
  889. }
  890. /**
  891. * @brief Start effective transfer on wire for Master configuration
  892. * @rmtoll CR1 CSTART LL_SPI_StartMasterTransfer
  893. * @param SPIx SPI Instance
  894. * @retval None
  895. */
  896. __STATIC_INLINE void LL_SPI_StartMasterTransfer(SPI_TypeDef *SPIx)
  897. {
  898. SET_BIT(SPIx->CR1, SPI_CR1_CSTART);
  899. }
  900. /**
  901. * @brief Check if there is an unfinished master transfer
  902. * @rmtoll CR1 CSTART LL_SPI_IsActiveMasterTransfer
  903. * @param SPIx SPI Instance
  904. * @retval State of bit (1 or 0)
  905. */
  906. __STATIC_INLINE uint32_t LL_SPI_IsActiveMasterTransfer(SPI_TypeDef *SPIx)
  907. {
  908. return ((READ_BIT(SPIx->CR1, SPI_CR1_CSTART) == (SPI_CR1_CSTART)) ? 1UL : 0UL);
  909. }
  910. /**
  911. * @brief Enable Master Rx auto suspend in case of overrun
  912. * @rmtoll CR1 MASRX LL_SPI_EnableMasterRxAutoSuspend
  913. * @param SPIx SPI Instance
  914. * @retval None
  915. */
  916. __STATIC_INLINE void LL_SPI_EnableMasterRxAutoSuspend(SPI_TypeDef *SPIx)
  917. {
  918. SET_BIT(SPIx->CR1, SPI_CR1_MASRX);
  919. }
  920. /**
  921. * @brief Disable Master Rx auto suspend in case of overrun
  922. * @rmtoll CR1 MASRX LL_SPI_DisableMasterRxAutoSuspend
  923. * @param SPIx SPI Instance
  924. * @retval None
  925. */
  926. __STATIC_INLINE void LL_SPI_DisableMasterRxAutoSuspend(SPI_TypeDef *SPIx)
  927. {
  928. CLEAR_BIT(SPIx->CR1, SPI_CR1_MASRX);
  929. }
  930. /**
  931. * @brief Check if Master Rx auto suspend is activated
  932. * @rmtoll CR1 MASRX LL_SPI_IsEnabledMasterRxAutoSuspend
  933. * @param SPIx SPI Instance
  934. * @retval State of bit (1 or 0)
  935. */
  936. __STATIC_INLINE uint32_t LL_SPI_IsEnabledMasterRxAutoSuspend(SPI_TypeDef *SPIx)
  937. {
  938. return ((READ_BIT(SPIx->CR1, SPI_CR1_MASRX) == (SPI_CR1_MASRX)) ? 1UL : 0UL);
  939. }
  940. /**
  941. * @brief Set Underrun behavior
  942. * @note This configuration can not be changed when SPI is enabled.
  943. * @rmtoll CFG1 UDRCFG LL_SPI_SetUDRConfiguration
  944. * @param SPIx SPI Instance
  945. * @param UDRConfig This parameter can be one of the following values:
  946. * @arg @ref LL_SPI_UDR_CONFIG_REGISTER_PATTERN
  947. * @arg @ref LL_SPI_UDR_CONFIG_LAST_RECEIVED
  948. * @arg @ref LL_SPI_UDR_CONFIG_LAST_TRANSMITTED
  949. * @retval None
  950. */
  951. __STATIC_INLINE void LL_SPI_SetUDRConfiguration(SPI_TypeDef *SPIx, uint32_t UDRConfig)
  952. {
  953. MODIFY_REG(SPIx->CFG1, SPI_CFG1_UDRCFG, UDRConfig);
  954. }
  955. /**
  956. * @brief Get Underrun behavior
  957. * @rmtoll CFG1 UDRCFG LL_SPI_GetUDRConfiguration
  958. * @param SPIx SPI Instance
  959. * @retval Returned value can be one of the following values:
  960. * @arg @ref LL_SPI_UDR_CONFIG_REGISTER_PATTERN
  961. * @arg @ref LL_SPI_UDR_CONFIG_LAST_RECEIVED
  962. * @arg @ref LL_SPI_UDR_CONFIG_LAST_TRANSMITTED
  963. */
  964. __STATIC_INLINE uint32_t LL_SPI_GetUDRConfiguration(SPI_TypeDef *SPIx)
  965. {
  966. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_UDRCFG));
  967. }
  968. /**
  969. * @brief Set Underrun Detection method
  970. * @note This configuration can not be changed when SPI is enabled.
  971. * @rmtoll CFG1 UDRDET LL_SPI_SetUDRDetection
  972. * @param SPIx SPI Instance
  973. * @param UDRDetection This parameter can be one of the following values:
  974. * @arg @ref LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME
  975. * @arg @ref LL_SPI_UDR_DETECT_END_DATA_FRAME
  976. * @arg @ref LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS
  977. * @retval None
  978. */
  979. __STATIC_INLINE void LL_SPI_SetUDRDetection(SPI_TypeDef *SPIx, uint32_t UDRDetection)
  980. {
  981. MODIFY_REG(SPIx->CFG1, SPI_CFG1_UDRDET, UDRDetection);
  982. }
  983. /**
  984. * @brief Get Underrun Detection method
  985. * @rmtoll CFG1 UDRDET LL_SPI_GetUDRDetection
  986. * @param SPIx SPI Instance
  987. * @retval Returned value can be one of the following values:
  988. * @arg @ref LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME
  989. * @arg @ref LL_SPI_UDR_DETECT_END_DATA_FRAME
  990. * @arg @ref LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS
  991. */
  992. __STATIC_INLINE uint32_t LL_SPI_GetUDRDetection(SPI_TypeDef *SPIx)
  993. {
  994. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_UDRDET));
  995. }
  996. /**
  997. * @brief Set Serial protocol used
  998. * @note This configuration can not be changed when SPI is enabled.
  999. * @rmtoll CFG2 SP LL_SPI_SetStandard
  1000. * @param SPIx SPI Instance
  1001. * @param Standard This parameter can be one of the following values:
  1002. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  1003. * @arg @ref LL_SPI_PROTOCOL_TI
  1004. * @retval None
  1005. */
  1006. __STATIC_INLINE void LL_SPI_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard)
  1007. {
  1008. MODIFY_REG(SPIx->CFG2, SPI_CFG2_SP, Standard);
  1009. }
  1010. /**
  1011. * @brief Get Serial protocol used
  1012. * @rmtoll CFG2 SP LL_SPI_GetStandard
  1013. * @param SPIx SPI Instance
  1014. * @retval Returned value can be one of the following values:
  1015. * @arg @ref LL_SPI_PROTOCOL_MOTOROLA
  1016. * @arg @ref LL_SPI_PROTOCOL_TI
  1017. */
  1018. __STATIC_INLINE uint32_t LL_SPI_GetStandard(SPI_TypeDef *SPIx)
  1019. {
  1020. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SP));
  1021. }
  1022. /**
  1023. * @brief Set Clock phase
  1024. * @note This configuration can not be changed when SPI is enabled.
  1025. * This bit is not used in SPI TI mode.
  1026. * @rmtoll CFG2 CPHA LL_SPI_SetClockPhase
  1027. * @param SPIx SPI Instance
  1028. * @param ClockPhase This parameter can be one of the following values:
  1029. * @arg @ref LL_SPI_PHASE_1EDGE
  1030. * @arg @ref LL_SPI_PHASE_2EDGE
  1031. * @retval None
  1032. */
  1033. __STATIC_INLINE void LL_SPI_SetClockPhase(SPI_TypeDef *SPIx, uint32_t ClockPhase)
  1034. {
  1035. MODIFY_REG(SPIx->CFG2, SPI_CFG2_CPHA, ClockPhase);
  1036. }
  1037. /**
  1038. * @brief Get Clock phase
  1039. * @rmtoll CFG2 CPHA LL_SPI_GetClockPhase
  1040. * @param SPIx SPI Instance
  1041. * @retval Returned value can be one of the following values:
  1042. * @arg @ref LL_SPI_PHASE_1EDGE
  1043. * @arg @ref LL_SPI_PHASE_2EDGE
  1044. */
  1045. __STATIC_INLINE uint32_t LL_SPI_GetClockPhase(SPI_TypeDef *SPIx)
  1046. {
  1047. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_CPHA));
  1048. }
  1049. /**
  1050. * @brief Set Clock polarity
  1051. * @note This configuration can not be changed when SPI is enabled.
  1052. * This bit is not used in SPI TI mode.
  1053. * @rmtoll CFG2 CPOL LL_SPI_SetClockPolarity
  1054. * @param SPIx SPI Instance
  1055. * @param ClockPolarity This parameter can be one of the following values:
  1056. * @arg @ref LL_SPI_POLARITY_LOW
  1057. * @arg @ref LL_SPI_POLARITY_HIGH
  1058. * @retval None
  1059. */
  1060. __STATIC_INLINE void LL_SPI_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity)
  1061. {
  1062. MODIFY_REG(SPIx->CFG2, SPI_CFG2_CPOL, ClockPolarity);
  1063. }
  1064. /**
  1065. * @brief Get Clock polarity
  1066. * @rmtoll CFG2 CPOL LL_SPI_GetClockPolarity
  1067. * @param SPIx SPI Instance
  1068. * @retval Returned value can be one of the following values:
  1069. * @arg @ref LL_SPI_POLARITY_LOW
  1070. * @arg @ref LL_SPI_POLARITY_HIGH
  1071. */
  1072. __STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(SPI_TypeDef *SPIx)
  1073. {
  1074. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_CPOL));
  1075. }
  1076. /**
  1077. * @brief Set NSS polarity
  1078. * @note This configuration can not be changed when SPI is enabled.
  1079. * This bit is not used in SPI TI mode.
  1080. * @rmtoll CFG2 SSIOP LL_SPI_SetNSSPolarity
  1081. * @param SPIx SPI Instance
  1082. * @param NSSPolarity This parameter can be one of the following values:
  1083. * @arg @ref LL_SPI_NSS_POLARITY_LOW
  1084. * @arg @ref LL_SPI_NSS_POLARITY_HIGH
  1085. * @retval None
  1086. */
  1087. __STATIC_INLINE void LL_SPI_SetNSSPolarity(SPI_TypeDef *SPIx, uint32_t NSSPolarity)
  1088. {
  1089. MODIFY_REG(SPIx->CFG2, SPI_CFG2_SSIOP, NSSPolarity);
  1090. }
  1091. /**
  1092. * @brief Get NSS polarity
  1093. * @rmtoll CFG2 SSIOP LL_SPI_GetNSSPolarity
  1094. * @param SPIx SPI Instance
  1095. * @retval Returned value can be one of the following values:
  1096. * @arg @ref LL_SPI_NSS_POLARITY_LOW
  1097. * @arg @ref LL_SPI_NSS_POLARITY_HIGH
  1098. */
  1099. __STATIC_INLINE uint32_t LL_SPI_GetNSSPolarity(SPI_TypeDef *SPIx)
  1100. {
  1101. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SSIOP));
  1102. }
  1103. /**
  1104. * @brief Set Baudrate Prescaler
  1105. * @note This configuration can not be changed when SPI is enabled.
  1106. * SPI BaudRate = fPCLK/Pescaler.
  1107. * @rmtoll CFG1 MBR LL_SPI_SetBaudRatePrescaler
  1108. * @param SPIx SPI Instance
  1109. * @param Baudrate This parameter can be one of the following values:
  1110. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  1111. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  1112. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  1113. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  1114. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  1115. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  1116. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  1117. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  1118. * @retval None
  1119. */
  1120. __STATIC_INLINE void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef *SPIx, uint32_t Baudrate)
  1121. {
  1122. MODIFY_REG(SPIx->CFG1, SPI_CFG1_MBR, Baudrate);
  1123. }
  1124. /**
  1125. * @brief Get Baudrate Prescaler
  1126. * @rmtoll CFG1 MBR LL_SPI_GetBaudRatePrescaler
  1127. * @param SPIx SPI Instance
  1128. * @retval Returned value can be one of the following values:
  1129. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
  1130. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
  1131. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
  1132. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
  1133. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
  1134. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
  1135. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
  1136. * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
  1137. */
  1138. __STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(SPI_TypeDef *SPIx)
  1139. {
  1140. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_MBR));
  1141. }
  1142. /**
  1143. * @brief Set Transfer Bit Order
  1144. * @note This configuration can not be changed when SPI is enabled.
  1145. * This bit is not used in SPI TI mode.
  1146. * @rmtoll CFG2 LSBFRST LL_SPI_SetTransferBitOrder
  1147. * @param SPIx SPI Instance
  1148. * @param BitOrder This parameter can be one of the following values:
  1149. * @arg @ref LL_SPI_LSB_FIRST
  1150. * @arg @ref LL_SPI_MSB_FIRST
  1151. * @retval None
  1152. */
  1153. __STATIC_INLINE void LL_SPI_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder)
  1154. {
  1155. MODIFY_REG(SPIx->CFG2, SPI_CFG2_LSBFRST, BitOrder);
  1156. }
  1157. /**
  1158. * @brief Get Transfer Bit Order
  1159. * @rmtoll CFG2 LSBFRST LL_SPI_GetTransferBitOrder
  1160. * @param SPIx SPI Instance
  1161. * @retval Returned value can be one of the following values:
  1162. * @arg @ref LL_SPI_LSB_FIRST
  1163. * @arg @ref LL_SPI_MSB_FIRST
  1164. */
  1165. __STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(SPI_TypeDef *SPIx)
  1166. {
  1167. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_LSBFRST));
  1168. }
  1169. /**
  1170. * @brief Set Transfer Mode
  1171. * @note This configuration can not be changed when SPI is enabled except for half duplex direction
  1172. * using LL_SPI_SetHalfDuplexDirection.
  1173. * @rmtoll CR1 HDDIR LL_SPI_SetTransferDirection\n
  1174. * CFG2 COMM LL_SPI_SetTransferDirection
  1175. * @param SPIx SPI Instance
  1176. * @param TransferDirection This parameter can be one of the following values:
  1177. * @arg @ref LL_SPI_FULL_DUPLEX
  1178. * @arg @ref LL_SPI_SIMPLEX_TX
  1179. * @arg @ref LL_SPI_SIMPLEX_RX
  1180. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  1181. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  1182. * @retval None
  1183. */
  1184. __STATIC_INLINE void LL_SPI_SetTransferDirection(SPI_TypeDef *SPIx, uint32_t TransferDirection)
  1185. {
  1186. MODIFY_REG(SPIx->CR1, SPI_CR1_HDDIR, TransferDirection & SPI_CR1_HDDIR);
  1187. MODIFY_REG(SPIx->CFG2, SPI_CFG2_COMM, TransferDirection & SPI_CFG2_COMM);
  1188. }
  1189. /**
  1190. * @brief Get Transfer Mode
  1191. * @rmtoll CR1 HDDIR LL_SPI_GetTransferDirection\n
  1192. * CFG2 COMM LL_SPI_GetTransferDirection
  1193. * @param SPIx SPI Instance
  1194. * @retval Returned value can be one of the following values:
  1195. * @arg @ref LL_SPI_FULL_DUPLEX
  1196. * @arg @ref LL_SPI_SIMPLEX_TX
  1197. * @arg @ref LL_SPI_SIMPLEX_RX
  1198. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  1199. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  1200. */
  1201. __STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(SPI_TypeDef *SPIx)
  1202. {
  1203. uint32_t Hddir = READ_BIT(SPIx->CR1, SPI_CR1_HDDIR);
  1204. uint32_t Comm = READ_BIT(SPIx->CFG2, SPI_CFG2_COMM);
  1205. return (Hddir | Comm);
  1206. }
  1207. /**
  1208. * @brief Set direction for Half-Duplex Mode
  1209. * @note In master mode the MOSI pin is used and in slave mode the MISO pin is used for Half-Duplex.
  1210. * @rmtoll CR1 HDDIR LL_SPI_SetHalfDuplexDirection
  1211. * @param SPIx SPI Instance
  1212. * @param HalfDuplexDirection This parameter can be one of the following values:
  1213. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  1214. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  1215. * @retval None
  1216. */
  1217. __STATIC_INLINE void LL_SPI_SetHalfDuplexDirection(SPI_TypeDef *SPIx, uint32_t HalfDuplexDirection)
  1218. {
  1219. MODIFY_REG(SPIx->CR1, SPI_CR1_HDDIR, HalfDuplexDirection & SPI_CR1_HDDIR);
  1220. }
  1221. /**
  1222. * @brief Get direction for Half-Duplex Mode
  1223. * @note In master mode the MOSI pin is used and in slave mode the MISO pin is used for Half-Duplex.
  1224. * @rmtoll CR1 HDDIR LL_SPI_GetHalfDuplexDirection
  1225. * @param SPIx SPI Instance
  1226. * @retval Returned value can be one of the following values:
  1227. * @arg @ref LL_SPI_HALF_DUPLEX_RX
  1228. * @arg @ref LL_SPI_HALF_DUPLEX_TX
  1229. */
  1230. __STATIC_INLINE uint32_t LL_SPI_GetHalfDuplexDirection(SPI_TypeDef *SPIx)
  1231. {
  1232. return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_HDDIR) | SPI_CFG2_COMM);
  1233. }
  1234. /**
  1235. * @brief Set Frame Data Size
  1236. * @note This configuration can not be changed when SPI is enabled.
  1237. * @rmtoll CFG1 DSIZE LL_SPI_SetDataWidth
  1238. * @param SPIx SPI Instance
  1239. * @param DataWidth This parameter can be one of the following values:
  1240. * @arg @ref LL_SPI_DATAWIDTH_4BIT
  1241. * @arg @ref LL_SPI_DATAWIDTH_5BIT
  1242. * @arg @ref LL_SPI_DATAWIDTH_6BIT
  1243. * @arg @ref LL_SPI_DATAWIDTH_7BIT
  1244. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  1245. * @arg @ref LL_SPI_DATAWIDTH_9BIT
  1246. * @arg @ref LL_SPI_DATAWIDTH_10BIT
  1247. * @arg @ref LL_SPI_DATAWIDTH_11BIT
  1248. * @arg @ref LL_SPI_DATAWIDTH_12BIT
  1249. * @arg @ref LL_SPI_DATAWIDTH_13BIT
  1250. * @arg @ref LL_SPI_DATAWIDTH_14BIT
  1251. * @arg @ref LL_SPI_DATAWIDTH_15BIT
  1252. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  1253. * @arg @ref LL_SPI_DATAWIDTH_17BIT
  1254. * @arg @ref LL_SPI_DATAWIDTH_18BIT
  1255. * @arg @ref LL_SPI_DATAWIDTH_19BIT
  1256. * @arg @ref LL_SPI_DATAWIDTH_20BIT
  1257. * @arg @ref LL_SPI_DATAWIDTH_21BIT
  1258. * @arg @ref LL_SPI_DATAWIDTH_22BIT
  1259. * @arg @ref LL_SPI_DATAWIDTH_23BIT
  1260. * @arg @ref LL_SPI_DATAWIDTH_24BIT
  1261. * @arg @ref LL_SPI_DATAWIDTH_25BIT
  1262. * @arg @ref LL_SPI_DATAWIDTH_26BIT
  1263. * @arg @ref LL_SPI_DATAWIDTH_27BIT
  1264. * @arg @ref LL_SPI_DATAWIDTH_28BIT
  1265. * @arg @ref LL_SPI_DATAWIDTH_29BIT
  1266. * @arg @ref LL_SPI_DATAWIDTH_30BIT
  1267. * @arg @ref LL_SPI_DATAWIDTH_31BIT
  1268. * @arg @ref LL_SPI_DATAWIDTH_32BIT
  1269. * @retval None
  1270. */
  1271. __STATIC_INLINE void LL_SPI_SetDataWidth(SPI_TypeDef *SPIx, uint32_t DataWidth)
  1272. {
  1273. MODIFY_REG(SPIx->CFG1, SPI_CFG1_DSIZE, DataWidth);
  1274. }
  1275. /**
  1276. * @brief Get Frame Data Size
  1277. * @rmtoll CFG1 DSIZE LL_SPI_GetDataWidth
  1278. * @param SPIx SPI Instance
  1279. * @retval Returned value can be one of the following values:
  1280. * @arg @ref LL_SPI_DATAWIDTH_4BIT
  1281. * @arg @ref LL_SPI_DATAWIDTH_5BIT
  1282. * @arg @ref LL_SPI_DATAWIDTH_6BIT
  1283. * @arg @ref LL_SPI_DATAWIDTH_7BIT
  1284. * @arg @ref LL_SPI_DATAWIDTH_8BIT
  1285. * @arg @ref LL_SPI_DATAWIDTH_9BIT
  1286. * @arg @ref LL_SPI_DATAWIDTH_10BIT
  1287. * @arg @ref LL_SPI_DATAWIDTH_11BIT
  1288. * @arg @ref LL_SPI_DATAWIDTH_12BIT
  1289. * @arg @ref LL_SPI_DATAWIDTH_13BIT
  1290. * @arg @ref LL_SPI_DATAWIDTH_14BIT
  1291. * @arg @ref LL_SPI_DATAWIDTH_15BIT
  1292. * @arg @ref LL_SPI_DATAWIDTH_16BIT
  1293. * @arg @ref LL_SPI_DATAWIDTH_17BIT
  1294. * @arg @ref LL_SPI_DATAWIDTH_18BIT
  1295. * @arg @ref LL_SPI_DATAWIDTH_19BIT
  1296. * @arg @ref LL_SPI_DATAWIDTH_20BIT
  1297. * @arg @ref LL_SPI_DATAWIDTH_21BIT
  1298. * @arg @ref LL_SPI_DATAWIDTH_22BIT
  1299. * @arg @ref LL_SPI_DATAWIDTH_23BIT
  1300. * @arg @ref LL_SPI_DATAWIDTH_24BIT
  1301. * @arg @ref LL_SPI_DATAWIDTH_25BIT
  1302. * @arg @ref LL_SPI_DATAWIDTH_26BIT
  1303. * @arg @ref LL_SPI_DATAWIDTH_27BIT
  1304. * @arg @ref LL_SPI_DATAWIDTH_28BIT
  1305. * @arg @ref LL_SPI_DATAWIDTH_29BIT
  1306. * @arg @ref LL_SPI_DATAWIDTH_30BIT
  1307. * @arg @ref LL_SPI_DATAWIDTH_31BIT
  1308. * @arg @ref LL_SPI_DATAWIDTH_32BIT
  1309. */
  1310. __STATIC_INLINE uint32_t LL_SPI_GetDataWidth(SPI_TypeDef *SPIx)
  1311. {
  1312. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_DSIZE));
  1313. }
  1314. /**
  1315. * @brief Set threshold of FIFO that triggers a transfer event
  1316. * @note This configuration can not be changed when SPI is enabled.
  1317. * @rmtoll CFG1 FTHLV LL_SPI_SetFIFOThreshold
  1318. * @param SPIx SPI Instance
  1319. * @param Threshold This parameter can be one of the following values:
  1320. * @arg @ref LL_SPI_FIFO_TH_01DATA
  1321. * @arg @ref LL_SPI_FIFO_TH_02DATA
  1322. * @arg @ref LL_SPI_FIFO_TH_03DATA
  1323. * @arg @ref LL_SPI_FIFO_TH_04DATA
  1324. * @arg @ref LL_SPI_FIFO_TH_05DATA
  1325. * @arg @ref LL_SPI_FIFO_TH_06DATA
  1326. * @arg @ref LL_SPI_FIFO_TH_07DATA
  1327. * @arg @ref LL_SPI_FIFO_TH_08DATA
  1328. * @arg @ref LL_SPI_FIFO_TH_09DATA
  1329. * @arg @ref LL_SPI_FIFO_TH_10DATA
  1330. * @arg @ref LL_SPI_FIFO_TH_11DATA
  1331. * @arg @ref LL_SPI_FIFO_TH_12DATA
  1332. * @arg @ref LL_SPI_FIFO_TH_13DATA
  1333. * @arg @ref LL_SPI_FIFO_TH_14DATA
  1334. * @arg @ref LL_SPI_FIFO_TH_15DATA
  1335. * @arg @ref LL_SPI_FIFO_TH_16DATA
  1336. * @retval None
  1337. */
  1338. __STATIC_INLINE void LL_SPI_SetFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Threshold)
  1339. {
  1340. MODIFY_REG(SPIx->CFG1, SPI_CFG1_FTHLV, Threshold);
  1341. }
  1342. /**
  1343. * @brief Get threshold of FIFO that triggers a transfer event
  1344. * @rmtoll CFG1 FTHLV LL_SPI_GetFIFOThreshold
  1345. * @param SPIx SPI Instance
  1346. * @retval Returned value can be one of the following values:
  1347. * @arg @ref LL_SPI_FIFO_TH_01DATA
  1348. * @arg @ref LL_SPI_FIFO_TH_02DATA
  1349. * @arg @ref LL_SPI_FIFO_TH_03DATA
  1350. * @arg @ref LL_SPI_FIFO_TH_04DATA
  1351. * @arg @ref LL_SPI_FIFO_TH_05DATA
  1352. * @arg @ref LL_SPI_FIFO_TH_06DATA
  1353. * @arg @ref LL_SPI_FIFO_TH_07DATA
  1354. * @arg @ref LL_SPI_FIFO_TH_08DATA
  1355. * @arg @ref LL_SPI_FIFO_TH_09DATA
  1356. * @arg @ref LL_SPI_FIFO_TH_10DATA
  1357. * @arg @ref LL_SPI_FIFO_TH_11DATA
  1358. * @arg @ref LL_SPI_FIFO_TH_12DATA
  1359. * @arg @ref LL_SPI_FIFO_TH_13DATA
  1360. * @arg @ref LL_SPI_FIFO_TH_14DATA
  1361. * @arg @ref LL_SPI_FIFO_TH_15DATA
  1362. * @arg @ref LL_SPI_FIFO_TH_16DATA
  1363. */
  1364. __STATIC_INLINE uint32_t LL_SPI_GetFIFOThreshold(SPI_TypeDef *SPIx)
  1365. {
  1366. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_FTHLV));
  1367. }
  1368. /**
  1369. * @brief Enable CRC
  1370. * @note This configuration can not be changed when SPI is enabled.
  1371. * @rmtoll CFG1 CRCEN LL_SPI_EnableCRC
  1372. * @param SPIx SPI Instance
  1373. * @retval None
  1374. */
  1375. __STATIC_INLINE void LL_SPI_EnableCRC(SPI_TypeDef *SPIx)
  1376. {
  1377. SET_BIT(SPIx->CFG1, SPI_CFG1_CRCEN);
  1378. }
  1379. /**
  1380. * @brief Disable CRC
  1381. * @rmtoll CFG1 CRCEN LL_SPI_DisableCRC
  1382. * @param SPIx SPI Instance
  1383. * @retval None
  1384. */
  1385. __STATIC_INLINE void LL_SPI_DisableCRC(SPI_TypeDef *SPIx)
  1386. {
  1387. CLEAR_BIT(SPIx->CFG1, SPI_CFG1_CRCEN);
  1388. }
  1389. /**
  1390. * @brief Check if CRC is enabled
  1391. * @rmtoll CFG1 CRCEN LL_SPI_IsEnabledCRC
  1392. * @param SPIx SPI Instance
  1393. * @retval State of bit (1 or 0).
  1394. */
  1395. __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx)
  1396. {
  1397. return ((READ_BIT(SPIx->CFG1, SPI_CFG1_CRCEN) == SPI_CFG1_CRCEN) ? 1UL : 0UL);
  1398. }
  1399. /**
  1400. * @brief Set CRC Length
  1401. * @note This configuration can not be changed when SPI is enabled.
  1402. * @rmtoll CFG1 CRCSIZE LL_SPI_SetCRCWidth
  1403. * @param SPIx SPI Instance
  1404. * @param CRCLength This parameter can be one of the following values:
  1405. * @arg @ref LL_SPI_CRC_4BIT
  1406. * @arg @ref LL_SPI_CRC_5BIT
  1407. * @arg @ref LL_SPI_CRC_6BIT
  1408. * @arg @ref LL_SPI_CRC_7BIT
  1409. * @arg @ref LL_SPI_CRC_8BIT
  1410. * @arg @ref LL_SPI_CRC_9BIT
  1411. * @arg @ref LL_SPI_CRC_10BIT
  1412. * @arg @ref LL_SPI_CRC_11BIT
  1413. * @arg @ref LL_SPI_CRC_12BIT
  1414. * @arg @ref LL_SPI_CRC_13BIT
  1415. * @arg @ref LL_SPI_CRC_14BIT
  1416. * @arg @ref LL_SPI_CRC_15BIT
  1417. * @arg @ref LL_SPI_CRC_16BIT
  1418. * @arg @ref LL_SPI_CRC_17BIT
  1419. * @arg @ref LL_SPI_CRC_18BIT
  1420. * @arg @ref LL_SPI_CRC_19BIT
  1421. * @arg @ref LL_SPI_CRC_20BIT
  1422. * @arg @ref LL_SPI_CRC_21BIT
  1423. * @arg @ref LL_SPI_CRC_22BIT
  1424. * @arg @ref LL_SPI_CRC_23BIT
  1425. * @arg @ref LL_SPI_CRC_24BIT
  1426. * @arg @ref LL_SPI_CRC_25BIT
  1427. * @arg @ref LL_SPI_CRC_26BIT
  1428. * @arg @ref LL_SPI_CRC_27BIT
  1429. * @arg @ref LL_SPI_CRC_28BIT
  1430. * @arg @ref LL_SPI_CRC_29BIT
  1431. * @arg @ref LL_SPI_CRC_30BIT
  1432. * @arg @ref LL_SPI_CRC_31BIT
  1433. * @arg @ref LL_SPI_CRC_32BIT
  1434. * @retval None
  1435. */
  1436. __STATIC_INLINE void LL_SPI_SetCRCWidth(SPI_TypeDef *SPIx, uint32_t CRCLength)
  1437. {
  1438. MODIFY_REG(SPIx->CFG1, SPI_CFG1_CRCSIZE, CRCLength);
  1439. }
  1440. /**
  1441. * @brief Get CRC Length
  1442. * @rmtoll CFG1 CRCSIZE LL_SPI_GetCRCWidth
  1443. * @param SPIx SPI Instance
  1444. * @retval Returned value can be one of the following values:
  1445. * @arg @ref LL_SPI_CRC_4BIT
  1446. * @arg @ref LL_SPI_CRC_5BIT
  1447. * @arg @ref LL_SPI_CRC_6BIT
  1448. * @arg @ref LL_SPI_CRC_7BIT
  1449. * @arg @ref LL_SPI_CRC_8BIT
  1450. * @arg @ref LL_SPI_CRC_9BIT
  1451. * @arg @ref LL_SPI_CRC_10BIT
  1452. * @arg @ref LL_SPI_CRC_11BIT
  1453. * @arg @ref LL_SPI_CRC_12BIT
  1454. * @arg @ref LL_SPI_CRC_13BIT
  1455. * @arg @ref LL_SPI_CRC_14BIT
  1456. * @arg @ref LL_SPI_CRC_15BIT
  1457. * @arg @ref LL_SPI_CRC_16BIT
  1458. * @arg @ref LL_SPI_CRC_17BIT
  1459. * @arg @ref LL_SPI_CRC_18BIT
  1460. * @arg @ref LL_SPI_CRC_19BIT
  1461. * @arg @ref LL_SPI_CRC_20BIT
  1462. * @arg @ref LL_SPI_CRC_21BIT
  1463. * @arg @ref LL_SPI_CRC_22BIT
  1464. * @arg @ref LL_SPI_CRC_23BIT
  1465. * @arg @ref LL_SPI_CRC_24BIT
  1466. * @arg @ref LL_SPI_CRC_25BIT
  1467. * @arg @ref LL_SPI_CRC_26BIT
  1468. * @arg @ref LL_SPI_CRC_27BIT
  1469. * @arg @ref LL_SPI_CRC_28BIT
  1470. * @arg @ref LL_SPI_CRC_29BIT
  1471. * @arg @ref LL_SPI_CRC_30BIT
  1472. * @arg @ref LL_SPI_CRC_31BIT
  1473. * @arg @ref LL_SPI_CRC_32BIT
  1474. */
  1475. __STATIC_INLINE uint32_t LL_SPI_GetCRCWidth(SPI_TypeDef *SPIx)
  1476. {
  1477. return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_CRCSIZE));
  1478. }
  1479. /**
  1480. * @brief Set NSS Mode
  1481. * @note This configuration can not be changed when SPI is enabled.
  1482. * This bit is not used in SPI TI mode.
  1483. * @rmtoll CFG2 SSM LL_SPI_SetNSSMode\n
  1484. * CFG2 SSOE LL_SPI_SetNSSMode
  1485. * @param SPIx SPI Instance
  1486. * @param NSS This parameter can be one of the following values:
  1487. * @arg @ref LL_SPI_NSS_SOFT
  1488. * @arg @ref LL_SPI_NSS_HARD_INPUT
  1489. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  1490. * @retval None
  1491. */
  1492. __STATIC_INLINE void LL_SPI_SetNSSMode(SPI_TypeDef *SPIx, uint32_t NSS)
  1493. {
  1494. MODIFY_REG(SPIx->CFG2, SPI_CFG2_SSM | SPI_CFG2_SSOE, NSS);
  1495. }
  1496. /**
  1497. * @brief Set NSS Mode
  1498. * @rmtoll CFG2 SSM LL_SPI_GetNSSMode\n
  1499. * CFG2 SSOE LL_SPI_GetNSSMode
  1500. * @param SPIx SPI Instance
  1501. * @retval Returned value can be one of the following values:
  1502. * @arg @ref LL_SPI_NSS_SOFT
  1503. * @arg @ref LL_SPI_NSS_HARD_INPUT
  1504. * @arg @ref LL_SPI_NSS_HARD_OUTPUT
  1505. */
  1506. __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx)
  1507. {
  1508. return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SSM | SPI_CFG2_SSOE));
  1509. }
  1510. /**
  1511. * @brief Enable NSS pulse mgt
  1512. * @note This configuration can not be changed when SPI is enabled.
  1513. * This bit is not used in SPI TI mode.
  1514. * @rmtoll CFG2 SSOM LL_SPI_EnableNSSPulseMgt
  1515. * @param SPIx SPI Instance
  1516. * @retval None
  1517. */
  1518. __STATIC_INLINE void LL_SPI_EnableNSSPulseMgt(SPI_TypeDef *SPIx)
  1519. {
  1520. SET_BIT(SPIx->CFG2, SPI_CFG2_SSOM);
  1521. }
  1522. /**
  1523. * @brief Disable NSS pulse mgt
  1524. * @note This configuration can not be changed when SPI is enabled.
  1525. * This bit is not used in SPI TI mode.
  1526. * @rmtoll CFG2 SSOM LL_SPI_DisableNSSPulseMgt
  1527. * @param SPIx SPI Instance
  1528. * @retval None
  1529. */
  1530. __STATIC_INLINE void LL_SPI_DisableNSSPulseMgt(SPI_TypeDef *SPIx)
  1531. {
  1532. CLEAR_BIT(SPIx->CFG2, SPI_CFG2_SSOM);
  1533. }
  1534. /**
  1535. * @brief Check if NSS pulse is enabled
  1536. * @rmtoll CFG2 SSOM LL_SPI_IsEnabledNSSPulse
  1537. * @param SPIx SPI Instance
  1538. * @retval State of bit (1 or 0)
  1539. */
  1540. __STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(SPI_TypeDef *SPIx)
  1541. {
  1542. return ((READ_BIT(SPIx->CFG2, SPI_CFG2_SSOM) == SPI_CFG2_SSOM) ? 1UL : 0UL);
  1543. }
  1544. /**
  1545. * @}
  1546. */
  1547. /** @defgroup SPI_LL_EF_FLAG_Management FLAG_Management
  1548. * @{
  1549. */
  1550. /**
  1551. * @brief Check if there is enough data in FIFO to read a full packet
  1552. * @rmtoll SR RXP LL_SPI_IsActiveFlag_RXP
  1553. * @param SPIx SPI Instance
  1554. * @retval State of bit (1 or 0)
  1555. */
  1556. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXP(SPI_TypeDef *SPIx)
  1557. {
  1558. return ((READ_BIT(SPIx->SR, SPI_SR_RXP) == (SPI_SR_RXP)) ? 1UL : 0UL);
  1559. }
  1560. /**
  1561. * @brief Check if there is enough space in FIFO to hold a full packet
  1562. * @rmtoll SR TXP LL_SPI_IsActiveFlag_TXP
  1563. * @param SPIx SPI Instance
  1564. * @retval State of bit (1 or 0)
  1565. */
  1566. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXP(SPI_TypeDef *SPIx)
  1567. {
  1568. return ((READ_BIT(SPIx->SR, SPI_SR_TXP) == (SPI_SR_TXP)) ? 1UL : 0UL);
  1569. }
  1570. /**
  1571. * @brief Check if there enough space in FIFO to hold a full packet, AND enough data to read a full packet
  1572. * @rmtoll SR DXP LL_SPI_IsActiveFlag_DXP
  1573. * @param SPIx SPI Instance
  1574. * @retval State of bit (1 or 0)
  1575. */
  1576. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_DXP(SPI_TypeDef *SPIx)
  1577. {
  1578. return ((READ_BIT(SPIx->SR, SPI_SR_DXP) == (SPI_SR_DXP)) ? 1UL : 0UL);
  1579. }
  1580. /**
  1581. * @brief Check that end of transfer event occurred
  1582. * @rmtoll SR EOT LL_SPI_IsActiveFlag_EOT
  1583. * @param SPIx SPI Instance
  1584. * @retval State of bit (1 or 0).
  1585. */
  1586. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_EOT(SPI_TypeDef *SPIx)
  1587. {
  1588. return ((READ_BIT(SPIx->SR, SPI_SR_EOT) == (SPI_SR_EOT)) ? 1UL : 0UL);
  1589. }
  1590. /**
  1591. * @brief Check that all required data has been filled in the fifo according to transfer size
  1592. * @rmtoll SR TXTF LL_SPI_IsActiveFlag_TXTF
  1593. * @param SPIx SPI Instance
  1594. * @retval State of bit (1 or 0).
  1595. */
  1596. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXTF(SPI_TypeDef *SPIx)
  1597. {
  1598. return ((READ_BIT(SPIx->SR, SPI_SR_TXTF) == (SPI_SR_TXTF)) ? 1UL : 0UL);
  1599. }
  1600. /**
  1601. * @brief Get Underrun error flag
  1602. * @rmtoll SR UDR LL_SPI_IsActiveFlag_UDR
  1603. * @param SPIx SPI Instance
  1604. * @retval State of bit (1 or 0).
  1605. */
  1606. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_UDR(SPI_TypeDef *SPIx)
  1607. {
  1608. return ((READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)) ? 1UL : 0UL);
  1609. }
  1610. /**
  1611. * @brief Get CRC error flag
  1612. * @rmtoll SR CRCE LL_SPI_IsActiveFlag_CRCERR
  1613. * @param SPIx SPI Instance
  1614. * @retval State of bit (1 or 0).
  1615. */
  1616. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx)
  1617. {
  1618. return ((READ_BIT(SPIx->SR, SPI_SR_CRCE) == (SPI_SR_CRCE)) ? 1UL : 0UL);
  1619. }
  1620. /**
  1621. * @brief Get Mode fault error flag
  1622. * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF
  1623. * @param SPIx SPI Instance
  1624. * @retval State of bit (1 or 0).
  1625. */
  1626. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx)
  1627. {
  1628. return ((READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)) ? 1UL : 0UL);
  1629. }
  1630. /**
  1631. * @brief Get Overrun error flag
  1632. * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR
  1633. * @param SPIx SPI Instance
  1634. * @retval State of bit (1 or 0).
  1635. */
  1636. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx)
  1637. {
  1638. return ((READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)) ? 1UL : 0UL);
  1639. }
  1640. /**
  1641. * @brief Get TI Frame format error flag
  1642. * @rmtoll SR TIFRE LL_SPI_IsActiveFlag_FRE
  1643. * @param SPIx SPI Instance
  1644. * @retval State of bit (1 or 0).
  1645. */
  1646. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(SPI_TypeDef *SPIx)
  1647. {
  1648. return ((READ_BIT(SPIx->SR, SPI_SR_TIFRE) == (SPI_SR_TIFRE)) ? 1UL : 0UL);
  1649. }
  1650. /**
  1651. * @brief Check if the additional number of data has been reloaded
  1652. * @rmtoll SR TSERF LL_SPI_IsActiveFlag_TSER
  1653. * @param SPIx SPI Instance
  1654. * @retval State of bit (1 or 0).
  1655. */
  1656. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TSER(SPI_TypeDef *SPIx)
  1657. {
  1658. return ((READ_BIT(SPIx->SR, SPI_SR_TSERF) == (SPI_SR_TSERF)) ? 1UL : 0UL);
  1659. }
  1660. /**
  1661. * @brief Check if a suspend operation is done
  1662. * @rmtoll SR SUSP LL_SPI_IsActiveFlag_SUSP
  1663. * @param SPIx SPI Instance
  1664. * @retval State of bit (1 or 0)
  1665. */
  1666. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_SUSP(SPI_TypeDef *SPIx)
  1667. {
  1668. return ((READ_BIT(SPIx->SR, SPI_SR_SUSP) == (SPI_SR_SUSP)) ? 1UL : 0UL);
  1669. }
  1670. /**
  1671. * @brief Check if last TxFIFO or CRC frame transmission is completed
  1672. * @rmtoll SR TXC LL_SPI_IsActiveFlag_TXC
  1673. * @param SPIx SPI Instance
  1674. * @retval State of bit (1 or 0).
  1675. */
  1676. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXC(SPI_TypeDef *SPIx)
  1677. {
  1678. return ((READ_BIT(SPIx->SR, SPI_SR_TXC) == (SPI_SR_TXC)) ? 1UL : 0UL);
  1679. }
  1680. /**
  1681. * @brief Check if at least one 32-bit data is available in RxFIFO
  1682. * @rmtoll SR RXWNE LL_SPI_IsActiveFlag_RXWNE
  1683. * @param SPIx SPI Instance
  1684. * @retval State of bit (1 or 0)
  1685. */
  1686. __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXWNE(SPI_TypeDef *SPIx)
  1687. {
  1688. return ((READ_BIT(SPIx->SR, SPI_SR_RXWNE) == (SPI_SR_RXWNE)) ? 1UL : 0UL);
  1689. }
  1690. /**
  1691. * @brief Get number of data framed remaining in current TSIZE
  1692. * @rmtoll SR CTSIZE LL_SPI_GetRemainingDataFrames
  1693. * @param SPIx SPI Instance
  1694. * @retval 0..0xFFFF
  1695. */
  1696. __STATIC_INLINE uint32_t LL_SPI_GetRemainingDataFrames(SPI_TypeDef *SPIx)
  1697. {
  1698. return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_CTSIZE) >> SPI_SR_CTSIZE_Pos);
  1699. }
  1700. /**
  1701. * @brief Get RxFIFO packing Level
  1702. * @rmtoll SR RXPLVL LL_SPI_GetRxFIFOPackingLevel
  1703. * @param SPIx SPI Instance
  1704. * @retval Returned value can be one of the following values:
  1705. * @arg @ref LL_SPI_RX_FIFO_0PACKET
  1706. * @arg @ref LL_SPI_RX_FIFO_1PACKET
  1707. * @arg @ref LL_SPI_RX_FIFO_2PACKET
  1708. * @arg @ref LL_SPI_RX_FIFO_3PACKET
  1709. */
  1710. __STATIC_INLINE uint32_t LL_SPI_GetRxFIFOPackingLevel(SPI_TypeDef *SPIx)
  1711. {
  1712. return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_RXPLVL));
  1713. }
  1714. /**
  1715. * @brief Clear End Of Transfer flag
  1716. * @rmtoll IFCR EOTC LL_SPI_ClearFlag_EOT
  1717. * @param SPIx SPI Instance
  1718. * @retval None
  1719. */
  1720. __STATIC_INLINE void LL_SPI_ClearFlag_EOT(SPI_TypeDef *SPIx)
  1721. {
  1722. SET_BIT(SPIx->IFCR, SPI_IFCR_EOTC);
  1723. }
  1724. /**
  1725. * @brief Clear TXTF flag
  1726. * @rmtoll IFCR TXTFC LL_SPI_ClearFlag_TXTF
  1727. * @param SPIx SPI Instance
  1728. * @retval None
  1729. */
  1730. __STATIC_INLINE void LL_SPI_ClearFlag_TXTF(SPI_TypeDef *SPIx)
  1731. {
  1732. SET_BIT(SPIx->IFCR, SPI_IFCR_TXTFC);
  1733. }
  1734. /**
  1735. * @brief Clear Underrun error flag
  1736. * @rmtoll IFCR UDRC LL_SPI_ClearFlag_UDR
  1737. * @param SPIx SPI Instance
  1738. * @retval None
  1739. */
  1740. __STATIC_INLINE void LL_SPI_ClearFlag_UDR(SPI_TypeDef *SPIx)
  1741. {
  1742. SET_BIT(SPIx->IFCR, SPI_IFCR_UDRC);
  1743. }
  1744. /**
  1745. * @brief Clear Overrun error flag
  1746. * @rmtoll IFCR OVRC LL_SPI_ClearFlag_OVR
  1747. * @param SPIx SPI Instance
  1748. * @retval None
  1749. */
  1750. __STATIC_INLINE void LL_SPI_ClearFlag_OVR(SPI_TypeDef *SPIx)
  1751. {
  1752. SET_BIT(SPIx->IFCR, SPI_IFCR_OVRC);
  1753. }
  1754. /**
  1755. * @brief Clear CRC error flag
  1756. * @rmtoll IFCR CRCEC LL_SPI_ClearFlag_CRCERR
  1757. * @param SPIx SPI Instance
  1758. * @retval None
  1759. */
  1760. __STATIC_INLINE void LL_SPI_ClearFlag_CRCERR(SPI_TypeDef *SPIx)
  1761. {
  1762. SET_BIT(SPIx->IFCR, SPI_IFCR_CRCEC);
  1763. }
  1764. /**
  1765. * @brief Clear Mode fault error flag
  1766. * @rmtoll IFCR MODFC LL_SPI_ClearFlag_MODF
  1767. * @param SPIx SPI Instance
  1768. * @retval None
  1769. */
  1770. __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx)
  1771. {
  1772. SET_BIT(SPIx->IFCR, SPI_IFCR_MODFC);
  1773. }
  1774. /**
  1775. * @brief Clear Frame format error flag
  1776. * @rmtoll IFCR TIFREC LL_SPI_ClearFlag_FRE
  1777. * @param SPIx SPI Instance
  1778. * @retval None
  1779. */
  1780. __STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx)
  1781. {
  1782. SET_BIT(SPIx->IFCR, SPI_IFCR_TIFREC);
  1783. }
  1784. /**
  1785. * @brief Clear TSER flag
  1786. * @rmtoll IFCR TSERFC LL_SPI_ClearFlag_TSER
  1787. * @param SPIx SPI Instance
  1788. * @retval None
  1789. */
  1790. __STATIC_INLINE void LL_SPI_ClearFlag_TSER(SPI_TypeDef *SPIx)
  1791. {
  1792. SET_BIT(SPIx->IFCR, SPI_IFCR_TSERFC);
  1793. }
  1794. /**
  1795. * @brief Clear SUSP flag
  1796. * @rmtoll IFCR SUSPC LL_SPI_ClearFlag_SUSP
  1797. * @param SPIx SPI Instance
  1798. * @retval None
  1799. */
  1800. __STATIC_INLINE void LL_SPI_ClearFlag_SUSP(SPI_TypeDef *SPIx)
  1801. {
  1802. SET_BIT(SPIx->IFCR, SPI_IFCR_SUSPC);
  1803. }
  1804. /**
  1805. * @}
  1806. */
  1807. /** @defgroup SPI_LL_EF_IT_Management IT_Management
  1808. * @{
  1809. */
  1810. /**
  1811. * @brief Enable Rx Packet available IT
  1812. * @rmtoll IER RXPIE LL_SPI_EnableIT_RXP
  1813. * @param SPIx SPI Instance
  1814. * @retval None
  1815. */
  1816. __STATIC_INLINE void LL_SPI_EnableIT_RXP(SPI_TypeDef *SPIx)
  1817. {
  1818. SET_BIT(SPIx->IER, SPI_IER_RXPIE);
  1819. }
  1820. /**
  1821. * @brief Enable Tx Packet space available IT
  1822. * @rmtoll IER TXPIE LL_SPI_EnableIT_TXP
  1823. * @param SPIx SPI Instance
  1824. * @retval None
  1825. */
  1826. __STATIC_INLINE void LL_SPI_EnableIT_TXP(SPI_TypeDef *SPIx)
  1827. {
  1828. SET_BIT(SPIx->IER, SPI_IER_TXPIE);
  1829. }
  1830. /**
  1831. * @brief Enable Duplex Packet available IT
  1832. * @rmtoll IER DXPIE LL_SPI_EnableIT_DXP
  1833. * @param SPIx SPI Instance
  1834. * @retval None
  1835. */
  1836. __STATIC_INLINE void LL_SPI_EnableIT_DXP(SPI_TypeDef *SPIx)
  1837. {
  1838. SET_BIT(SPIx->IER, SPI_IER_DXPIE);
  1839. }
  1840. /**
  1841. * @brief Enable End Of Transfer IT
  1842. * @rmtoll IER EOTIE LL_SPI_EnableIT_EOT
  1843. * @param SPIx SPI Instance
  1844. * @retval None
  1845. */
  1846. __STATIC_INLINE void LL_SPI_EnableIT_EOT(SPI_TypeDef *SPIx)
  1847. {
  1848. SET_BIT(SPIx->IER, SPI_IER_EOTIE);
  1849. }
  1850. /**
  1851. * @brief Enable TXTF IT
  1852. * @rmtoll IER TXTFIE LL_SPI_EnableIT_TXTF
  1853. * @param SPIx SPI Instance
  1854. * @retval None
  1855. */
  1856. __STATIC_INLINE void LL_SPI_EnableIT_TXTF(SPI_TypeDef *SPIx)
  1857. {
  1858. SET_BIT(SPIx->IER, SPI_IER_TXTFIE);
  1859. }
  1860. /**
  1861. * @brief Enable Underrun IT
  1862. * @rmtoll IER UDRIE LL_SPI_EnableIT_UDR
  1863. * @param SPIx SPI Instance
  1864. * @retval None
  1865. */
  1866. __STATIC_INLINE void LL_SPI_EnableIT_UDR(SPI_TypeDef *SPIx)
  1867. {
  1868. SET_BIT(SPIx->IER, SPI_IER_UDRIE);
  1869. }
  1870. /**
  1871. * @brief Enable Overrun IT
  1872. * @rmtoll IER OVRIE LL_SPI_EnableIT_OVR
  1873. * @param SPIx SPI Instance
  1874. * @retval None
  1875. */
  1876. __STATIC_INLINE void LL_SPI_EnableIT_OVR(SPI_TypeDef *SPIx)
  1877. {
  1878. SET_BIT(SPIx->IER, SPI_IER_OVRIE);
  1879. }
  1880. /**
  1881. * @brief Enable CRC Error IT
  1882. * @rmtoll IER CRCEIE LL_SPI_EnableIT_CRCERR
  1883. * @param SPIx SPI Instance
  1884. * @retval None
  1885. */
  1886. __STATIC_INLINE void LL_SPI_EnableIT_CRCERR(SPI_TypeDef *SPIx)
  1887. {
  1888. SET_BIT(SPIx->IER, SPI_IER_CRCEIE);
  1889. }
  1890. /**
  1891. * @brief Enable TI Frame Format Error IT
  1892. * @rmtoll IER TIFREIE LL_SPI_EnableIT_FRE
  1893. * @param SPIx SPI Instance
  1894. * @retval None
  1895. */
  1896. __STATIC_INLINE void LL_SPI_EnableIT_FRE(SPI_TypeDef *SPIx)
  1897. {
  1898. SET_BIT(SPIx->IER, SPI_IER_TIFREIE);
  1899. }
  1900. /**
  1901. * @brief Enable MODF IT
  1902. * @rmtoll IER MODFIE LL_SPI_EnableIT_MODF
  1903. * @param SPIx SPI Instance
  1904. * @retval None
  1905. */
  1906. __STATIC_INLINE void LL_SPI_EnableIT_MODF(SPI_TypeDef *SPIx)
  1907. {
  1908. SET_BIT(SPIx->IER, SPI_IER_MODFIE);
  1909. }
  1910. /**
  1911. * @brief Enable TSER reload IT
  1912. * @rmtoll IER TSERFIE LL_SPI_EnableIT_TSER
  1913. * @param SPIx SPI Instance
  1914. * @retval None
  1915. */
  1916. __STATIC_INLINE void LL_SPI_EnableIT_TSER(SPI_TypeDef *SPIx)
  1917. {
  1918. SET_BIT(SPIx->IER, SPI_IER_TSERFIE);
  1919. }
  1920. /**
  1921. * @brief Disable Rx Packet available IT
  1922. * @rmtoll IER RXPIE LL_SPI_DisableIT_RXP
  1923. * @param SPIx SPI Instance
  1924. * @retval None
  1925. */
  1926. __STATIC_INLINE void LL_SPI_DisableIT_RXP(SPI_TypeDef *SPIx)
  1927. {
  1928. CLEAR_BIT(SPIx->IER, SPI_IER_RXPIE);
  1929. }
  1930. /**
  1931. * @brief Disable Tx Packet space available IT
  1932. * @rmtoll IER TXPIE LL_SPI_DisableIT_TXP
  1933. * @param SPIx SPI Instance
  1934. * @retval None
  1935. */
  1936. __STATIC_INLINE void LL_SPI_DisableIT_TXP(SPI_TypeDef *SPIx)
  1937. {
  1938. CLEAR_BIT(SPIx->IER, SPI_IER_TXPIE);
  1939. }
  1940. /**
  1941. * @brief Disable Duplex Packet available IT
  1942. * @rmtoll IER DXPIE LL_SPI_DisableIT_DXP
  1943. * @param SPIx SPI Instance
  1944. * @retval None
  1945. */
  1946. __STATIC_INLINE void LL_SPI_DisableIT_DXP(SPI_TypeDef *SPIx)
  1947. {
  1948. CLEAR_BIT(SPIx->IER, SPI_IER_DXPIE);
  1949. }
  1950. /**
  1951. * @brief Disable End Of Transfer IT
  1952. * @rmtoll IER EOTIE LL_SPI_DisableIT_EOT
  1953. * @param SPIx SPI Instance
  1954. * @retval None
  1955. */
  1956. __STATIC_INLINE void LL_SPI_DisableIT_EOT(SPI_TypeDef *SPIx)
  1957. {
  1958. CLEAR_BIT(SPIx->IER, SPI_IER_EOTIE);
  1959. }
  1960. /**
  1961. * @brief Disable TXTF IT
  1962. * @rmtoll IER TXTFIE LL_SPI_DisableIT_TXTF
  1963. * @param SPIx SPI Instance
  1964. * @retval None
  1965. */
  1966. __STATIC_INLINE void LL_SPI_DisableIT_TXTF(SPI_TypeDef *SPIx)
  1967. {
  1968. CLEAR_BIT(SPIx->IER, SPI_IER_TXTFIE);
  1969. }
  1970. /**
  1971. * @brief Disable Underrun IT
  1972. * @rmtoll IER UDRIE LL_SPI_DisableIT_UDR
  1973. * @param SPIx SPI Instance
  1974. * @retval None
  1975. */
  1976. __STATIC_INLINE void LL_SPI_DisableIT_UDR(SPI_TypeDef *SPIx)
  1977. {
  1978. CLEAR_BIT(SPIx->IER, SPI_IER_UDRIE);
  1979. }
  1980. /**
  1981. * @brief Disable Overrun IT
  1982. * @rmtoll IER OVRIE LL_SPI_DisableIT_OVR
  1983. * @param SPIx SPI Instance
  1984. * @retval None
  1985. */
  1986. __STATIC_INLINE void LL_SPI_DisableIT_OVR(SPI_TypeDef *SPIx)
  1987. {
  1988. CLEAR_BIT(SPIx->IER, SPI_IER_OVRIE);
  1989. }
  1990. /**
  1991. * @brief Disable CRC Error IT
  1992. * @rmtoll IER CRCEIE LL_SPI_DisableIT_CRCERR
  1993. * @param SPIx SPI Instance
  1994. * @retval None
  1995. */
  1996. __STATIC_INLINE void LL_SPI_DisableIT_CRCERR(SPI_TypeDef *SPIx)
  1997. {
  1998. CLEAR_BIT(SPIx->IER, SPI_IER_CRCEIE);
  1999. }
  2000. /**
  2001. * @brief Disable TI Frame Format Error IT
  2002. * @rmtoll IER TIFREIE LL_SPI_DisableIT_FRE
  2003. * @param SPIx SPI Instance
  2004. * @retval None
  2005. */
  2006. __STATIC_INLINE void LL_SPI_DisableIT_FRE(SPI_TypeDef *SPIx)
  2007. {
  2008. CLEAR_BIT(SPIx->IER, SPI_IER_TIFREIE);
  2009. }
  2010. /**
  2011. * @brief Disable MODF IT
  2012. * @rmtoll IER MODFIE LL_SPI_DisableIT_MODF
  2013. * @param SPIx SPI Instance
  2014. * @retval None
  2015. */
  2016. __STATIC_INLINE void LL_SPI_DisableIT_MODF(SPI_TypeDef *SPIx)
  2017. {
  2018. CLEAR_BIT(SPIx->IER, SPI_IER_MODFIE);
  2019. }
  2020. /**
  2021. * @brief Disable TSER reload IT
  2022. * @rmtoll IER TSERFIE LL_SPI_DisableIT_TSER
  2023. * @param SPIx SPI Instance
  2024. * @retval None
  2025. */
  2026. __STATIC_INLINE void LL_SPI_DisableIT_TSER(SPI_TypeDef *SPIx)
  2027. {
  2028. CLEAR_BIT(SPIx->IER, SPI_IER_TSERFIE);
  2029. }
  2030. /**
  2031. * @brief Check if Rx Packet available IT is enabled
  2032. * @rmtoll IER RXPIE LL_SPI_IsEnabledIT_RXP
  2033. * @param SPIx SPI Instance
  2034. * @retval State of bit (1 or 0)
  2035. */
  2036. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXP(SPI_TypeDef *SPIx)
  2037. {
  2038. return ((READ_BIT(SPIx->IER, SPI_IER_RXPIE) == (SPI_IER_RXPIE)) ? 1UL : 0UL);
  2039. }
  2040. /**
  2041. * @brief Check if Tx Packet space available IT is enabled
  2042. * @rmtoll IER TXPIE LL_SPI_IsEnabledIT_TXP
  2043. * @param SPIx SPI Instance
  2044. * @retval State of bit (1 or 0)
  2045. */
  2046. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXP(SPI_TypeDef *SPIx)
  2047. {
  2048. return ((READ_BIT(SPIx->IER, SPI_IER_TXPIE) == (SPI_IER_TXPIE)) ? 1UL : 0UL);
  2049. }
  2050. /**
  2051. * @brief Check if Duplex Packet available IT is enabled
  2052. * @rmtoll IER DXPIE LL_SPI_IsEnabledIT_DXP
  2053. * @param SPIx SPI Instance
  2054. * @retval State of bit (1 or 0)
  2055. */
  2056. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_DXP(SPI_TypeDef *SPIx)
  2057. {
  2058. return ((READ_BIT(SPIx->IER, SPI_IER_DXPIE) == (SPI_IER_DXPIE)) ? 1UL : 0UL);
  2059. }
  2060. /**
  2061. * @brief Check if End Of Transfer IT is enabled
  2062. * @rmtoll IER EOTIE LL_SPI_IsEnabledIT_EOT
  2063. * @param SPIx SPI Instance
  2064. * @retval State of bit (1 or 0)
  2065. */
  2066. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_EOT(SPI_TypeDef *SPIx)
  2067. {
  2068. return ((READ_BIT(SPIx->IER, SPI_IER_EOTIE) == (SPI_IER_EOTIE)) ? 1UL : 0UL);
  2069. }
  2070. /**
  2071. * @brief Check if TXTF IT is enabled
  2072. * @rmtoll IER TXTFIE LL_SPI_IsEnabledIT_TXTF
  2073. * @param SPIx SPI Instance
  2074. * @retval State of bit (1 or 0)
  2075. */
  2076. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXTF(SPI_TypeDef *SPIx)
  2077. {
  2078. return ((READ_BIT(SPIx->IER, SPI_IER_TXTFIE) == (SPI_IER_TXTFIE)) ? 1UL : 0UL);
  2079. }
  2080. /**
  2081. * @brief Check if Underrun IT is enabled
  2082. * @rmtoll IER UDRIE LL_SPI_IsEnabledIT_UDR
  2083. * @param SPIx SPI Instance
  2084. * @retval State of bit (1 or 0)
  2085. */
  2086. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_UDR(SPI_TypeDef *SPIx)
  2087. {
  2088. return ((READ_BIT(SPIx->IER, SPI_IER_UDRIE) == (SPI_IER_UDRIE)) ? 1UL : 0UL);
  2089. }
  2090. /**
  2091. * @brief Check if Overrun IT is enabled
  2092. * @rmtoll IER OVRIE LL_SPI_IsEnabledIT_OVR
  2093. * @param SPIx SPI Instance
  2094. * @retval State of bit (1 or 0)
  2095. */
  2096. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_OVR(SPI_TypeDef *SPIx)
  2097. {
  2098. return ((READ_BIT(SPIx->IER, SPI_IER_OVRIE) == (SPI_IER_OVRIE)) ? 1UL : 0UL);
  2099. }
  2100. /**
  2101. * @brief Check if CRC Error IT is enabled
  2102. * @rmtoll IER CRCEIE LL_SPI_IsEnabledIT_CRCERR
  2103. * @param SPIx SPI Instance
  2104. * @retval State of bit (1 or 0)
  2105. */
  2106. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_CRCERR(SPI_TypeDef *SPIx)
  2107. {
  2108. return ((READ_BIT(SPIx->IER, SPI_IER_CRCEIE) == (SPI_IER_CRCEIE)) ? 1UL : 0UL);
  2109. }
  2110. /**
  2111. * @brief Check if TI Frame Format Error IT is enabled
  2112. * @rmtoll IER TIFREIE LL_SPI_IsEnabledIT_FRE
  2113. * @param SPIx SPI Instance
  2114. * @retval State of bit (1 or 0)
  2115. */
  2116. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_FRE(SPI_TypeDef *SPIx)
  2117. {
  2118. return ((READ_BIT(SPIx->IER, SPI_IER_TIFREIE) == (SPI_IER_TIFREIE)) ? 1UL : 0UL);
  2119. }
  2120. /**
  2121. * @brief Check if MODF IT is enabled
  2122. * @rmtoll IER MODFIE LL_SPI_IsEnabledIT_MODF
  2123. * @param SPIx SPI Instance
  2124. * @retval State of bit (1 or 0)
  2125. */
  2126. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_MODF(SPI_TypeDef *SPIx)
  2127. {
  2128. return ((READ_BIT(SPIx->IER, SPI_IER_MODFIE) == (SPI_IER_MODFIE)) ? 1UL : 0UL);
  2129. }
  2130. /**
  2131. * @brief Check if TSER reload IT is enabled
  2132. * @rmtoll IER TSERFIE LL_SPI_IsEnabledIT_TSER
  2133. * @param SPIx SPI Instance
  2134. * @retval State of bit (1 or 0)
  2135. */
  2136. __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TSER(SPI_TypeDef *SPIx)
  2137. {
  2138. return ((READ_BIT(SPIx->IER, SPI_IER_TSERFIE) == (SPI_IER_TSERFIE)) ? 1UL : 0UL);
  2139. }
  2140. /**
  2141. * @}
  2142. */
  2143. /** @defgroup SPI_LL_EF_DMA_Management DMA Management
  2144. * @{
  2145. */
  2146. /**
  2147. * @brief Enable DMA Rx
  2148. * @rmtoll CFG1 RXDMAEN LL_SPI_EnableDMAReq_RX
  2149. * @param SPIx SPI Instance
  2150. * @retval None
  2151. */
  2152. __STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx)
  2153. {
  2154. SET_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN);
  2155. }
  2156. /**
  2157. * @brief Disable DMA Rx
  2158. * @rmtoll CFG1 RXDMAEN LL_SPI_DisableDMAReq_RX
  2159. * @param SPIx SPI Instance
  2160. * @retval None
  2161. */
  2162. __STATIC_INLINE void LL_SPI_DisableDMAReq_RX(SPI_TypeDef *SPIx)
  2163. {
  2164. CLEAR_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN);
  2165. }
  2166. /**
  2167. * @brief Check if DMA Rx is enabled
  2168. * @rmtoll CFG1 RXDMAEN LL_SPI_IsEnabledDMAReq_RX
  2169. * @param SPIx SPI Instance
  2170. * @retval State of bit (1 or 0)
  2171. */
  2172. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx)
  2173. {
  2174. return ((READ_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN) == (SPI_CFG1_RXDMAEN)) ? 1UL : 0UL);
  2175. }
  2176. /**
  2177. * @brief Enable DMA Tx
  2178. * @rmtoll CFG1 TXDMAEN LL_SPI_EnableDMAReq_TX
  2179. * @param SPIx SPI Instance
  2180. * @retval None
  2181. */
  2182. __STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx)
  2183. {
  2184. SET_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN);
  2185. }
  2186. /**
  2187. * @brief Disable DMA Tx
  2188. * @rmtoll CFG1 TXDMAEN LL_SPI_DisableDMAReq_TX
  2189. * @param SPIx SPI Instance
  2190. * @retval None
  2191. */
  2192. __STATIC_INLINE void LL_SPI_DisableDMAReq_TX(SPI_TypeDef *SPIx)
  2193. {
  2194. CLEAR_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN);
  2195. }
  2196. /**
  2197. * @brief Check if DMA Tx is enabled
  2198. * @rmtoll CFG1 TXDMAEN LL_SPI_IsEnabledDMAReq_TX
  2199. * @param SPIx SPI Instance
  2200. * @retval State of bit (1 or 0)
  2201. */
  2202. __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx)
  2203. {
  2204. return ((READ_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN) == (SPI_CFG1_TXDMAEN)) ? 1UL : 0UL);
  2205. }
  2206. /**
  2207. * @}
  2208. */
  2209. /** @defgroup SPI_LL_EF_DATA_Management DATA_Management
  2210. * @{
  2211. */
  2212. /**
  2213. * @brief Read Data Register
  2214. * @rmtoll RXDR . LL_SPI_ReceiveData8
  2215. * @param SPIx SPI Instance
  2216. * @retval 0..0xFF
  2217. */
  2218. __STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)
  2219. {
  2220. return (*((__IO uint8_t *)&SPIx->RXDR));
  2221. }
  2222. /**
  2223. * @brief Read Data Register
  2224. * @rmtoll RXDR . LL_SPI_ReceiveData16
  2225. * @param SPIx SPI Instance
  2226. * @retval 0..0xFFFF
  2227. */
  2228. __STATIC_INLINE uint16_t LL_SPI_ReceiveData16(SPI_TypeDef *SPIx)
  2229. {
  2230. return (uint16_t)(READ_REG(SPIx->RXDR));
  2231. }
  2232. /**
  2233. * @brief Read Data Register
  2234. * @rmtoll RXDR . LL_SPI_ReceiveData32
  2235. * @param SPIx SPI Instance
  2236. * @retval 0..0xFFFFFFFF
  2237. */
  2238. __STATIC_INLINE uint32_t LL_SPI_ReceiveData32(SPI_TypeDef *SPIx)
  2239. {
  2240. return (*((__IO uint32_t *)&SPIx->RXDR));
  2241. }
  2242. /**
  2243. * @brief Write Data Register
  2244. * @rmtoll TXDR . LL_SPI_TransmitData8
  2245. * @param SPIx SPI Instance
  2246. * @param TxData 0..0xFF
  2247. * @retval None
  2248. */
  2249. __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)
  2250. {
  2251. *((__IO uint8_t *)&SPIx->TXDR) = TxData;
  2252. }
  2253. /**
  2254. * @brief Write Data Register
  2255. * @rmtoll TXDR . LL_SPI_TransmitData16
  2256. * @param SPIx SPI Instance
  2257. * @param TxData 0..0xFFFF
  2258. * @retval None
  2259. */
  2260. __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
  2261. {
  2262. #if defined (__GNUC__)
  2263. __IO uint16_t *spitxdr = ((__IO uint16_t *)&SPIx->TXDR);
  2264. *spitxdr = TxData;
  2265. #else
  2266. SPIx->TXDR = TxData;
  2267. #endif /* __GNUC__ */
  2268. }
  2269. /**
  2270. * @brief Write Data Register
  2271. * @rmtoll TXDR . LL_SPI_TransmitData32
  2272. * @param SPIx SPI Instance
  2273. * @param TxData 0..0xFFFFFFFF
  2274. * @retval None
  2275. */
  2276. __STATIC_INLINE void LL_SPI_TransmitData32(SPI_TypeDef *SPIx, uint32_t TxData)
  2277. {
  2278. *((__IO uint32_t *)&SPIx->TXDR) = TxData;
  2279. }
  2280. /**
  2281. * @brief Set polynomial for CRC calcul
  2282. * @rmtoll CRCPOLY CRCPOLY LL_SPI_SetCRCPolynomial
  2283. * @param SPIx SPI Instance
  2284. * @param CRCPoly 0..0xFFFFFFFF
  2285. * @retval None
  2286. */
  2287. __STATIC_INLINE void LL_SPI_SetCRCPolynomial(SPI_TypeDef *SPIx, uint32_t CRCPoly)
  2288. {
  2289. WRITE_REG(SPIx->CRCPOLY, CRCPoly);
  2290. }
  2291. /**
  2292. * @brief Get polynomial for CRC calcul
  2293. * @rmtoll CRCPOLY CRCPOLY LL_SPI_GetCRCPolynomial
  2294. * @param SPIx SPI Instance
  2295. * @retval 0..0xFFFFFFFF
  2296. */
  2297. __STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef *SPIx)
  2298. {
  2299. return (uint32_t)(READ_REG(SPIx->CRCPOLY));
  2300. }
  2301. /**
  2302. * @brief Set the underrun pattern
  2303. * @rmtoll UDRDR UDRDR LL_SPI_SetUDRPattern
  2304. * @param SPIx SPI Instance
  2305. * @param Pattern 0..0xFFFFFFFF
  2306. * @retval None
  2307. */
  2308. __STATIC_INLINE void LL_SPI_SetUDRPattern(SPI_TypeDef *SPIx, uint32_t Pattern)
  2309. {
  2310. WRITE_REG(SPIx->UDRDR, Pattern);
  2311. }
  2312. /**
  2313. * @brief Get the underrun pattern
  2314. * @rmtoll UDRDR UDRDR LL_SPI_GetUDRPattern
  2315. * @param SPIx SPI Instance
  2316. * @retval 0..0xFFFFFFFF
  2317. */
  2318. __STATIC_INLINE uint32_t LL_SPI_GetUDRPattern(SPI_TypeDef *SPIx)
  2319. {
  2320. return (uint32_t)(READ_REG(SPIx->UDRDR));
  2321. }
  2322. /**
  2323. * @brief Get Rx CRC
  2324. * @rmtoll RXCRCR RXCRC LL_SPI_GetRxCRC
  2325. * @param SPIx SPI Instance
  2326. * @retval 0..0xFFFFFFFF
  2327. */
  2328. __STATIC_INLINE uint32_t LL_SPI_GetRxCRC(SPI_TypeDef *SPIx)
  2329. {
  2330. return (uint32_t)(READ_REG(SPIx->RXCRC));
  2331. }
  2332. /**
  2333. * @brief Get Tx CRC
  2334. * @rmtoll TXCRCR TXCRC LL_SPI_GetTxCRC
  2335. * @param SPIx SPI Instance
  2336. * @retval 0..0xFFFFFFFF
  2337. */
  2338. __STATIC_INLINE uint32_t LL_SPI_GetTxCRC(SPI_TypeDef *SPIx)
  2339. {
  2340. return (uint32_t)(READ_REG(SPIx->TXCRC));
  2341. }
  2342. /**
  2343. * @}
  2344. */
  2345. #if defined(USE_FULL_LL_DRIVER)
  2346. /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions
  2347. * @{
  2348. */
  2349. ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx);
  2350. ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct);
  2351. void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct);
  2352. /**
  2353. * @}
  2354. */
  2355. #endif /* USE_FULL_LL_DRIVER */
  2356. /**
  2357. * @}
  2358. */
  2359. /** @defgroup I2S_LL I2S
  2360. * @{
  2361. */
  2362. /* Private variables ---------------------------------------------------------*/
  2363. /* Private constants ---------------------------------------------------------*/
  2364. /* Private macros ------------------------------------------------------------*/
  2365. /* Exported types ------------------------------------------------------------*/
  2366. #if defined(USE_FULL_LL_DRIVER)
  2367. /** @defgroup I2S_LL_ES_INIT I2S Exported Init structure
  2368. * @{
  2369. */
  2370. /**
  2371. * @brief I2S Init structure definition
  2372. */
  2373. typedef struct
  2374. {
  2375. uint32_t Mode; /*!< Specifies the I2S operating mode.
  2376. This parameter can be a value of @ref I2S_LL_EC_MODE
  2377. This feature can be modified afterwards using unitary function
  2378. @ref LL_I2S_SetTransferMode().*/
  2379. uint32_t Standard; /*!< Specifies the standard used for the I2S communication.
  2380. This parameter can be a value of @ref I2S_LL_EC_STANDARD
  2381. This feature can be modified afterwards using unitary function
  2382. @ref LL_I2S_SetStandard().*/
  2383. uint32_t DataFormat; /*!< Specifies the data format for the I2S communication.
  2384. This parameter can be a value of @ref I2S_LL_EC_DATA_FORMAT
  2385. This feature can be modified afterwards using unitary function
  2386. @ref LL_I2S_SetDataFormat().*/
  2387. uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
  2388. This parameter can be a value of @ref I2S_LL_EC_MCLK_OUTPUT
  2389. This feature can be modified afterwards using unitary functions
  2390. @ref LL_I2S_EnableMasterClock() or @ref LL_I2S_DisableMasterClock.*/
  2391. uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
  2392. This parameter can be a value of @ref I2S_LL_EC_AUDIO_FREQ
  2393. Audio Frequency can be modified afterwards using Reference manual formulas
  2394. to calculate Prescaler Linear, Parity and unitary functions
  2395. @ref LL_I2S_SetPrescalerLinear() and @ref LL_I2S_SetPrescalerParity()
  2396. to set it.*/
  2397. uint32_t ClockPolarity; /*!< Specifies the idle state of the I2S clock.
  2398. This parameter can be a value of @ref I2S_LL_EC_POLARITY
  2399. This feature can be modified afterwards using unitary function
  2400. @ref LL_I2S_SetClockPolarity().*/
  2401. } LL_I2S_InitTypeDef;
  2402. /**
  2403. * @}
  2404. */
  2405. #endif /*USE_FULL_LL_DRIVER*/
  2406. /* Exported constants --------------------------------------------------------*/
  2407. /** @defgroup I2S_LL_Exported_Constants I2S Exported Constants
  2408. * @{
  2409. */
  2410. /** @defgroup I2S_LL_EC_DATA_FORMAT Data Format
  2411. * @{
  2412. */
  2413. #define LL_I2S_DATAFORMAT_16B (0x00000000UL)
  2414. #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN)
  2415. #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0)
  2416. #define LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0 | SPI_I2SCFGR_DATFMT)
  2417. #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1)
  2418. /**
  2419. * @}
  2420. */
  2421. /** @defgroup I2S_LL_EC_CHANNEL_LENGTH_TYPE Type of Channel Length
  2422. * @{
  2423. */
  2424. #define LL_I2S_SLAVE_VARIABLE_CH_LENGTH (0x00000000UL)
  2425. #define LL_I2S_SLAVE_FIXED_CH_LENGTH (SPI_I2SCFGR_FIXCH)
  2426. /**
  2427. * @}
  2428. */
  2429. /** @defgroup I2S_LL_EC_POLARITY Clock Polarity
  2430. * @{
  2431. */
  2432. #define LL_I2S_POLARITY_LOW (0x00000000UL)
  2433. #define LL_I2S_POLARITY_HIGH (SPI_I2SCFGR_CKPOL)
  2434. /**
  2435. * @}
  2436. */
  2437. /** @defgroup I2S_LL_EC_STANDARD I2S Standard
  2438. * @{
  2439. */
  2440. #define LL_I2S_STANDARD_PHILIPS (0x00000000UL)
  2441. #define LL_I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0)
  2442. #define LL_I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1)
  2443. #define LL_I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1)
  2444. #define LL_I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC)
  2445. /**
  2446. * @}
  2447. */
  2448. /** @defgroup I2S_LL_EC_MODE Operation Mode
  2449. * @{
  2450. */
  2451. #define LL_I2S_MODE_SLAVE_TX (0x00000000UL)
  2452. #define LL_I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0)
  2453. #define LL_I2S_MODE_SLAVE_FULL_DUPLEX (SPI_I2SCFGR_I2SCFG_2)
  2454. #define LL_I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1)
  2455. #define LL_I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_1 | SPI_I2SCFGR_I2SCFG_0)
  2456. #define LL_I2S_MODE_MASTER_FULL_DUPLEX (SPI_I2SCFGR_I2SCFG_2 | SPI_I2SCFGR_I2SCFG_0)
  2457. /**
  2458. * @}
  2459. */
  2460. /** @defgroup I2S_LL_EC_PRESCALER_PARITY Prescaler Factor
  2461. * @{
  2462. */
  2463. #define LL_I2S_PRESCALER_PARITY_EVEN (0x00000000UL) /*!< Odd factor: Real divider value is = I2SDIV * 2 */
  2464. #define LL_I2S_PRESCALER_PARITY_ODD (0x00000001UL) /*!< Odd factor: Real divider value is = (I2SDIV * 2)+1 */
  2465. /**
  2466. * @}
  2467. */
  2468. /** @defgroup I2S_LL_EC_FIFO_TH FIFO Threshold Level
  2469. * @{
  2470. */
  2471. #define LL_I2S_FIFO_TH_01DATA (LL_SPI_FIFO_TH_01DATA)
  2472. #define LL_I2S_FIFO_TH_02DATA (LL_SPI_FIFO_TH_02DATA)
  2473. #define LL_I2S_FIFO_TH_03DATA (LL_SPI_FIFO_TH_03DATA)
  2474. #define LL_I2S_FIFO_TH_04DATA (LL_SPI_FIFO_TH_04DATA)
  2475. #define LL_I2S_FIFO_TH_05DATA (LL_SPI_FIFO_TH_05DATA)
  2476. #define LL_I2S_FIFO_TH_06DATA (LL_SPI_FIFO_TH_06DATA)
  2477. #define LL_I2S_FIFO_TH_07DATA (LL_SPI_FIFO_TH_07DATA)
  2478. #define LL_I2S_FIFO_TH_08DATA (LL_SPI_FIFO_TH_08DATA)
  2479. /**
  2480. * @}
  2481. */
  2482. /** @defgroup I2S_LL_EC_BIT_ORDER Transmission Bit Order
  2483. * @{
  2484. */
  2485. #define LL_I2S_LSB_FIRST (LL_SPI_LSB_FIRST)
  2486. #define LL_I2S_MSB_FIRST (LL_SPI_MSB_FIRST)
  2487. /**
  2488. * @}
  2489. */
  2490. #if defined(USE_FULL_LL_DRIVER)
  2491. /** @defgroup I2S_LL_EC_MCLK_OUTPUT MCLK Output
  2492. * @{
  2493. */
  2494. #define LL_I2S_MCLK_OUTPUT_DISABLE (0x00000000UL)
  2495. #define LL_I2S_MCLK_OUTPUT_ENABLE (SPI_I2SCFGR_MCKOE)
  2496. /**
  2497. * @}
  2498. */
  2499. /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency
  2500. * @{
  2501. */
  2502. #define LL_I2S_AUDIOFREQ_192K 192000UL /*!< Audio Frequency configuration 192000 Hz */
  2503. #define LL_I2S_AUDIOFREQ_96K 96000UL /*!< Audio Frequency configuration 96000 Hz */
  2504. #define LL_I2S_AUDIOFREQ_48K 48000UL /*!< Audio Frequency configuration 48000 Hz */
  2505. #define LL_I2S_AUDIOFREQ_44K 44100UL /*!< Audio Frequency configuration 44100 Hz */
  2506. #define LL_I2S_AUDIOFREQ_32K 32000UL /*!< Audio Frequency configuration 32000 Hz */
  2507. #define LL_I2S_AUDIOFREQ_22K 22050UL /*!< Audio Frequency configuration 22050 Hz */
  2508. #define LL_I2S_AUDIOFREQ_16K 16000UL /*!< Audio Frequency configuration 16000 Hz */
  2509. #define LL_I2S_AUDIOFREQ_11K 11025UL /*!< Audio Frequency configuration 11025 Hz */
  2510. #define LL_I2S_AUDIOFREQ_8K 8000UL /*!< Audio Frequency configuration 8000 Hz */
  2511. #define LL_I2S_AUDIOFREQ_DEFAULT 0UL /*!< Audio Freq not specified. Register I2SDIV = 0 */
  2512. /**
  2513. * @}
  2514. */
  2515. #endif /* USE_FULL_LL_DRIVER */
  2516. /**
  2517. * @}
  2518. */
  2519. /* Exported macro ------------------------------------------------------------*/
  2520. /** @defgroup I2S_LL_Exported_Macros I2S Exported Macros
  2521. * @{
  2522. */
  2523. /** @defgroup I2S_LL_EM_WRITE_READ Common Write and read registers Macros
  2524. * @{
  2525. */
  2526. /**
  2527. * @brief Write a value in I2S register
  2528. * @param __INSTANCE__ I2S Instance
  2529. * @param __REG__ Register to be written
  2530. * @param __VALUE__ Value to be written in the register
  2531. * @retval None
  2532. */
  2533. #define LL_I2S_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  2534. /**
  2535. * @brief Read a value in I2S register
  2536. * @param __INSTANCE__ I2S Instance
  2537. * @param __REG__ Register to be read
  2538. * @retval Register value
  2539. */
  2540. #define LL_I2S_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  2541. /**
  2542. * @}
  2543. */
  2544. /**
  2545. * @}
  2546. */
  2547. /* Exported functions --------------------------------------------------------*/
  2548. /** @defgroup I2S_LL_Exported_Functions I2S Exported Functions
  2549. * @{
  2550. */
  2551. /** @defgroup I2S_LL_EF_Configuration Configuration
  2552. * @{
  2553. */
  2554. /**
  2555. * @brief Set I2S Data frame format
  2556. * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n
  2557. * I2SCFGR CHLEN LL_I2S_SetDataFormat\n
  2558. * I2SCFGR DATFMT LL_I2S_SetDataFormat
  2559. * @param SPIx SPI Handle
  2560. * @param DataLength This parameter can be one of the following values:
  2561. * @arg @ref LL_I2S_DATAFORMAT_16B
  2562. * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
  2563. * @arg @ref LL_I2S_DATAFORMAT_24B
  2564. * @arg @ref LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED
  2565. * @arg @ref LL_I2S_DATAFORMAT_32B
  2566. * @retval None
  2567. */
  2568. __STATIC_INLINE void LL_I2S_SetDataFormat(SPI_TypeDef *SPIx, uint32_t DataLength)
  2569. {
  2570. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATFMT, DataLength);
  2571. }
  2572. /**
  2573. * @brief Get I2S Data frame format
  2574. * @rmtoll I2SCFGR DATLEN LL_I2S_GetDataFormat\n
  2575. * I2SCFGR CHLEN LL_I2S_GetDataFormat\n
  2576. * I2SCFGR DATFMT LL_I2S_GetDataFormat
  2577. * @param SPIx SPI Handle
  2578. * @retval Return value can be one of the following values:
  2579. * @arg @ref LL_I2S_DATAFORMAT_16B
  2580. * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
  2581. * @arg @ref LL_I2S_DATAFORMAT_24B
  2582. * @arg @ref LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED
  2583. * @arg @ref LL_I2S_DATAFORMAT_32B
  2584. */
  2585. __STATIC_INLINE uint32_t LL_I2S_GetDataFormat(SPI_TypeDef *SPIx)
  2586. {
  2587. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATFMT));
  2588. }
  2589. /**
  2590. * @brief Set I2S Channel Length Type
  2591. * @note This feature is useful with SLAVE only
  2592. * @rmtoll I2SCFGR FIXCH LL_I2S_SetChannelLengthType
  2593. * @param SPIx SPI Handle
  2594. * @param ChannelLengthType This parameter can be one of the following values:
  2595. * @arg @ref LL_I2S_SLAVE_VARIABLE_CH_LENGTH
  2596. * @arg @ref LL_I2S_SLAVE_FIXED_CH_LENGTH
  2597. * @retval None
  2598. */
  2599. __STATIC_INLINE void LL_I2S_SetChannelLengthType(SPI_TypeDef *SPIx, uint32_t ChannelLengthType)
  2600. {
  2601. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_FIXCH, ChannelLengthType);
  2602. }
  2603. /**
  2604. * @brief Get I2S Channel Length Type
  2605. * @note This feature is useful with SLAVE only
  2606. * @rmtoll I2SCFGR FIXCH LL_I2S_GetChannelLengthType
  2607. * @param SPIx SPI Handle
  2608. * @retval Return value can be one of the following values:
  2609. * @arg @ref LL_I2S_SLAVE_VARIABLE_CH_LENGTH
  2610. * @arg @ref LL_I2S_SLAVE_FIXED_CH_LENGTH
  2611. */
  2612. __STATIC_INLINE uint32_t LL_I2S_GetChannelLengthType(SPI_TypeDef *SPIx)
  2613. {
  2614. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_FIXCH));
  2615. }
  2616. /**
  2617. * @brief Invert the default polarity of WS signal
  2618. * @rmtoll I2SCFGR WSINV LL_I2S_EnableWordSelectInversion
  2619. * @param SPIx SPI Handle
  2620. * @retval None
  2621. */
  2622. __STATIC_INLINE void LL_I2S_EnableWordSelectInversion(SPI_TypeDef *SPIx)
  2623. {
  2624. SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV);
  2625. }
  2626. /**
  2627. * @brief Use the default polarity of WS signal
  2628. * @rmtoll I2SCFGR WSINV LL_I2S_DisableWordSelectInversion
  2629. * @param SPIx SPI Handle
  2630. * @retval None
  2631. */
  2632. __STATIC_INLINE void LL_I2S_DisableWordSelectInversion(SPI_TypeDef *SPIx)
  2633. {
  2634. CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV);
  2635. }
  2636. /**
  2637. * @brief Check if polarity of WS signal is inverted
  2638. * @rmtoll I2SCFGR WSINV LL_I2S_IsEnabledWordSelectInversion
  2639. * @param SPIx SPI Handle
  2640. * @retval State of bit (1 or 0)
  2641. */
  2642. __STATIC_INLINE uint32_t LL_I2S_IsEnabledWordSelectInversion(SPI_TypeDef *SPIx)
  2643. {
  2644. return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV) == (SPI_I2SCFGR_WSINV)) ? 1UL : 0UL);
  2645. }
  2646. /**
  2647. * @brief Set 2S Clock Polarity
  2648. * @rmtoll I2SCFGR CKPOL LL_I2S_SetClockPolarity
  2649. * @param SPIx SPI Handle
  2650. * @param ClockPolarity This parameter can be one of the following values:
  2651. * @arg @ref LL_I2S_POLARITY_LOW
  2652. * @arg @ref LL_I2S_POLARITY_HIGH
  2653. * @retval None
  2654. */
  2655. __STATIC_INLINE void LL_I2S_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity)
  2656. {
  2657. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL, ClockPolarity);
  2658. }
  2659. /**
  2660. * @brief Get 2S Clock Polarity
  2661. * @rmtoll I2SCFGR CKPOL LL_I2S_GetClockPolarity
  2662. * @param SPIx SPI Handle
  2663. * @retval Return value can be one of the following values:
  2664. * @arg @ref LL_I2S_POLARITY_LOW
  2665. * @arg @ref LL_I2S_POLARITY_HIGH
  2666. */
  2667. __STATIC_INLINE uint32_t LL_I2S_GetClockPolarity(SPI_TypeDef *SPIx)
  2668. {
  2669. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL));
  2670. }
  2671. /**
  2672. * @brief Set I2S standard
  2673. * @rmtoll I2SCFGR I2SSTD LL_I2S_SetStandard\n
  2674. * I2SCFGR PCMSYNC LL_I2S_SetStandard
  2675. * @param SPIx SPI Handle
  2676. * @param Standard This parameter can be one of the following values:
  2677. * @arg @ref LL_I2S_STANDARD_PHILIPS
  2678. * @arg @ref LL_I2S_STANDARD_MSB
  2679. * @arg @ref LL_I2S_STANDARD_LSB
  2680. * @arg @ref LL_I2S_STANDARD_PCM_SHORT
  2681. * @arg @ref LL_I2S_STANDARD_PCM_LONG
  2682. * @retval None
  2683. */
  2684. __STATIC_INLINE void LL_I2S_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard)
  2685. {
  2686. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC, Standard);
  2687. }
  2688. /**
  2689. * @brief Get I2S standard
  2690. * @rmtoll I2SCFGR I2SSTD LL_I2S_GetStandard\n
  2691. * I2SCFGR PCMSYNC LL_I2S_GetStandard
  2692. * @param SPIx SPI Handle
  2693. * @retval Return value can be one of the following values:
  2694. * @arg @ref LL_I2S_STANDARD_PHILIPS
  2695. * @arg @ref LL_I2S_STANDARD_MSB
  2696. * @arg @ref LL_I2S_STANDARD_LSB
  2697. * @arg @ref LL_I2S_STANDARD_PCM_SHORT
  2698. * @arg @ref LL_I2S_STANDARD_PCM_LONG
  2699. */
  2700. __STATIC_INLINE uint32_t LL_I2S_GetStandard(SPI_TypeDef *SPIx)
  2701. {
  2702. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC));
  2703. }
  2704. /**
  2705. * @brief Set I2S config
  2706. * @rmtoll I2SCFGR I2SCFG LL_I2S_SetTransferMode
  2707. * @param SPIx SPI Handle
  2708. * @param Standard This parameter can be one of the following values:
  2709. * @arg @ref LL_I2S_MODE_SLAVE_TX
  2710. * @arg @ref LL_I2S_MODE_SLAVE_RX
  2711. * @arg @ref LL_I2S_MODE_SLAVE_FULL_DUPLEX
  2712. * @arg @ref LL_I2S_MODE_MASTER_TX
  2713. * @arg @ref LL_I2S_MODE_MASTER_RX
  2714. * @arg @ref LL_I2S_MODE_MASTER_FULL_DUPLEX
  2715. * @retval None
  2716. */
  2717. __STATIC_INLINE void LL_I2S_SetTransferMode(SPI_TypeDef *SPIx, uint32_t Standard)
  2718. {
  2719. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG, Standard);
  2720. }
  2721. /**
  2722. * @brief Get I2S config
  2723. * @rmtoll I2SCFGR I2SCFG LL_I2S_GetTransferMode
  2724. * @param SPIx SPI Handle
  2725. * @retval Return value can be one of the following values:
  2726. * @arg @ref LL_I2S_MODE_SLAVE_TX
  2727. * @arg @ref LL_I2S_MODE_SLAVE_RX
  2728. * @arg @ref LL_I2S_MODE_SLAVE_FULL_DUPLEX
  2729. * @arg @ref LL_I2S_MODE_MASTER_TX
  2730. * @arg @ref LL_I2S_MODE_MASTER_RX
  2731. * @arg @ref LL_I2S_MODE_MASTER_FULL_DUPLEX
  2732. */
  2733. __STATIC_INLINE uint32_t LL_I2S_GetTransferMode(SPI_TypeDef *SPIx)
  2734. {
  2735. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG));
  2736. }
  2737. /**
  2738. * @brief Select I2S mode and Enable I2S peripheral
  2739. * @rmtoll I2SCFGR I2SMOD LL_I2S_Enable\n
  2740. * CR1 SPE LL_I2S_Enable
  2741. * @param SPIx SPI Handle
  2742. * @retval None
  2743. */
  2744. __STATIC_INLINE void LL_I2S_Enable(SPI_TypeDef *SPIx)
  2745. {
  2746. SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD);
  2747. SET_BIT(SPIx->CR1, SPI_CR1_SPE);
  2748. }
  2749. /**
  2750. * @brief Disable I2S peripheral and disable I2S mode
  2751. * @rmtoll CR1 SPE LL_I2S_Disable\n
  2752. * I2SCFGR I2SMOD LL_I2S_Disable
  2753. * @param SPIx SPI Handle
  2754. * @retval None
  2755. */
  2756. __STATIC_INLINE void LL_I2S_Disable(SPI_TypeDef *SPIx)
  2757. {
  2758. CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
  2759. CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD);
  2760. }
  2761. /**
  2762. * @brief Swap the SDO and SDI pin
  2763. * @note This configuration can not be changed when I2S is enabled.
  2764. * @rmtoll CFG2 IOSWP LL_I2S_EnableIOSwap
  2765. * @param SPIx SPI Instance
  2766. * @retval None
  2767. */
  2768. __STATIC_INLINE void LL_I2S_EnableIOSwap(SPI_TypeDef *SPIx)
  2769. {
  2770. LL_SPI_EnableIOSwap(SPIx);
  2771. }
  2772. /**
  2773. * @brief Restore default function for SDO and SDI pin
  2774. * @note This configuration can not be changed when I2S is enabled.
  2775. * @rmtoll CFG2 IOSWP LL_I2S_DisableIOSwap
  2776. * @param SPIx SPI Instance
  2777. * @retval None
  2778. */
  2779. __STATIC_INLINE void LL_I2S_DisableIOSwap(SPI_TypeDef *SPIx)
  2780. {
  2781. LL_SPI_DisableIOSwap(SPIx);
  2782. }
  2783. /**
  2784. * @brief Check if SDO and SDI pin are swapped
  2785. * @rmtoll CFG2 IOSWP LL_I2S_IsEnabledIOSwap
  2786. * @param SPIx SPI Instance
  2787. * @retval State of bit (1 or 0)
  2788. */
  2789. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIOSwap(SPI_TypeDef *SPIx)
  2790. {
  2791. return LL_SPI_IsEnabledIOSwap(SPIx);
  2792. }
  2793. /**
  2794. * @brief Enable GPIO control
  2795. * @note This configuration can not be changed when I2S is enabled.
  2796. * @rmtoll CFG2 AFCNTR LL_I2S_EnableGPIOControl
  2797. * @param SPIx SPI Instance
  2798. * @retval None
  2799. */
  2800. __STATIC_INLINE void LL_I2S_EnableGPIOControl(SPI_TypeDef *SPIx)
  2801. {
  2802. LL_SPI_EnableGPIOControl(SPIx);
  2803. }
  2804. /**
  2805. * @brief Disable GPIO control
  2806. * @note This configuration can not be changed when I2S is enabled.
  2807. * @rmtoll CFG2 AFCNTR LL_I2S_DisableGPIOControl
  2808. * @param SPIx SPI Instance
  2809. * @retval None
  2810. */
  2811. __STATIC_INLINE void LL_I2S_DisableGPIOControl(SPI_TypeDef *SPIx)
  2812. {
  2813. LL_SPI_DisableGPIOControl(SPIx);
  2814. }
  2815. /**
  2816. * @brief Check if GPIO control is active
  2817. * @rmtoll CFG2 AFCNTR LL_I2S_IsEnabledGPIOControl
  2818. * @param SPIx SPI Instance
  2819. * @retval State of bit (1 or 0)
  2820. */
  2821. __STATIC_INLINE uint32_t LL_I2S_IsEnabledGPIOControl(SPI_TypeDef *SPIx)
  2822. {
  2823. return LL_SPI_IsEnabledGPIOControl(SPIx);
  2824. }
  2825. /**
  2826. * @brief Lock the AF configuration of associated IOs
  2827. * @note Once this bit is set, the SPI_CFG2 register content can not be modified until a hardware reset occurs.
  2828. * The reset of the IOLock bit is done by hardware. for that, LL_SPI_DisableIOLock can not exist.
  2829. * @rmtoll CR1 IOLOCK LL_SPI_EnableIOLock
  2830. * @param SPIx SPI Instance
  2831. * @retval None
  2832. */
  2833. __STATIC_INLINE void LL_I2S_EnableIOLock(SPI_TypeDef *SPIx)
  2834. {
  2835. LL_SPI_EnableIOLock(SPIx);
  2836. }
  2837. /**
  2838. * @brief Check if the the SPI_CFG2 register is locked
  2839. * @rmtoll CR1 IOLOCK LL_I2S_IsEnabledIOLock
  2840. * @param SPIx SPI Instance
  2841. * @retval State of bit (1 or 0)
  2842. */
  2843. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIOLock(SPI_TypeDef *SPIx)
  2844. {
  2845. return LL_SPI_IsEnabledIOLock(SPIx);
  2846. }
  2847. /**
  2848. * @brief Set Transfer Bit Order
  2849. * @note This configuration can not be changed when I2S is enabled.
  2850. * @rmtoll CFG2 LSBFRST LL_I2S_SetTransferBitOrder
  2851. * @param SPIx SPI Instance
  2852. * @param BitOrder This parameter can be one of the following values:
  2853. * @arg @ref LL_I2S_LSB_FIRST
  2854. * @arg @ref LL_I2S_MSB_FIRST
  2855. * @retval None
  2856. */
  2857. __STATIC_INLINE void LL_I2S_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder)
  2858. {
  2859. LL_SPI_SetTransferBitOrder(SPIx, BitOrder);
  2860. }
  2861. /**
  2862. * @brief Get Transfer Bit Order
  2863. * @rmtoll CFG2 LSBFRST LL_I2S_GetTransferBitOrder
  2864. * @param SPIx SPI Instance
  2865. * @retval Returned value can be one of the following values:
  2866. * @arg @ref LL_I2S_LSB_FIRST
  2867. * @arg @ref LL_I2S_MSB_FIRST
  2868. */
  2869. __STATIC_INLINE uint32_t LL_I2S_GetTransferBitOrder(SPI_TypeDef *SPIx)
  2870. {
  2871. return LL_SPI_GetTransferBitOrder(SPIx);
  2872. }
  2873. /**
  2874. * @brief Start effective transfer on wire
  2875. * @rmtoll CR1 CSTART LL_I2S_StartTransfer
  2876. * @param SPIx SPI Instance
  2877. * @retval None
  2878. */
  2879. __STATIC_INLINE void LL_I2S_StartTransfer(SPI_TypeDef *SPIx)
  2880. {
  2881. LL_SPI_StartMasterTransfer(SPIx);
  2882. }
  2883. /**
  2884. * @brief Check if there is an unfinished transfer
  2885. * @rmtoll CR1 CSTART LL_I2S_IsTransferActive
  2886. * @param SPIx SPI Instance
  2887. * @retval State of bit (1 or 0)
  2888. */
  2889. __STATIC_INLINE uint32_t LL_I2S_IsActiveTransfer(SPI_TypeDef *SPIx)
  2890. {
  2891. return LL_SPI_IsActiveMasterTransfer(SPIx);
  2892. }
  2893. /**
  2894. * @brief Set threshold of FIFO that triggers a transfer event
  2895. * @note This configuration can not be changed when I2S is enabled.
  2896. * @rmtoll CFG1 FTHLV LL_I2S_SetFIFOThreshold
  2897. * @param SPIx SPI Instance
  2898. * @param Threshold This parameter can be one of the following values:
  2899. * @arg @ref LL_I2S_FIFO_TH_01DATA
  2900. * @arg @ref LL_I2S_FIFO_TH_02DATA
  2901. * @arg @ref LL_I2S_FIFO_TH_03DATA
  2902. * @arg @ref LL_I2S_FIFO_TH_04DATA
  2903. * @arg @ref LL_I2S_FIFO_TH_05DATA
  2904. * @arg @ref LL_I2S_FIFO_TH_06DATA
  2905. * @arg @ref LL_I2S_FIFO_TH_07DATA
  2906. * @arg @ref LL_I2S_FIFO_TH_08DATA
  2907. * @retval None
  2908. */
  2909. __STATIC_INLINE void LL_I2S_SetFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Threshold)
  2910. {
  2911. LL_SPI_SetFIFOThreshold(SPIx, Threshold);
  2912. }
  2913. /**
  2914. * @brief Get threshold of FIFO that triggers a transfer event
  2915. * @rmtoll CFG1 FTHLV LL_I2S_GetFIFOThreshold
  2916. * @param SPIx SPI Instance
  2917. * @retval Returned value can be one of the following values:
  2918. * @arg @ref LL_I2S_FIFO_TH_01DATA
  2919. * @arg @ref LL_I2S_FIFO_TH_02DATA
  2920. * @arg @ref LL_I2S_FIFO_TH_03DATA
  2921. * @arg @ref LL_I2S_FIFO_TH_04DATA
  2922. * @arg @ref LL_I2S_FIFO_TH_05DATA
  2923. * @arg @ref LL_I2S_FIFO_TH_06DATA
  2924. * @arg @ref LL_I2S_FIFO_TH_07DATA
  2925. * @arg @ref LL_I2S_FIFO_TH_08DATA
  2926. */
  2927. __STATIC_INLINE uint32_t LL_I2S_GetFIFOThreshold(SPI_TypeDef *SPIx)
  2928. {
  2929. return LL_SPI_GetFIFOThreshold(SPIx);
  2930. }
  2931. /**
  2932. * @brief Set I2S linear prescaler
  2933. * @rmtoll I2SCFGR I2SDIV LL_I2S_SetPrescalerLinear
  2934. * @param SPIx SPI Instance
  2935. * @param PrescalerLinear Value between Min_Data=0x00 and Max_Data=0xFF
  2936. * @note PrescalerLinear '1' is not authorized with parity LL_I2S_PRESCALER_PARITY_ODD
  2937. * @retval None
  2938. */
  2939. __STATIC_INLINE void LL_I2S_SetPrescalerLinear(SPI_TypeDef *SPIx, uint32_t PrescalerLinear)
  2940. {
  2941. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SDIV, (PrescalerLinear << SPI_I2SCFGR_I2SDIV_Pos));
  2942. }
  2943. /**
  2944. * @brief Get I2S linear prescaler
  2945. * @rmtoll I2SCFGR I2SDIV LL_I2S_GetPrescalerLinear
  2946. * @param SPIx SPI Instance
  2947. * @retval PrescalerLinear Value between Min_Data=0x00 and Max_Data=0xFF
  2948. */
  2949. __STATIC_INLINE uint32_t LL_I2S_GetPrescalerLinear(SPI_TypeDef *SPIx)
  2950. {
  2951. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SDIV) >> SPI_I2SCFGR_I2SDIV_Pos);
  2952. }
  2953. /**
  2954. * @brief Set I2S parity prescaler
  2955. * @rmtoll I2SCFGR ODD LL_I2S_SetPrescalerParity
  2956. * @param SPIx SPI Instance
  2957. * @param PrescalerParity This parameter can be one of the following values:
  2958. * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
  2959. * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
  2960. * @retval None
  2961. */
  2962. __STATIC_INLINE void LL_I2S_SetPrescalerParity(SPI_TypeDef *SPIx, uint32_t PrescalerParity)
  2963. {
  2964. MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_ODD, PrescalerParity << SPI_I2SCFGR_ODD_Pos);
  2965. }
  2966. /**
  2967. * @brief Get I2S parity prescaler
  2968. * @rmtoll I2SCFGR ODD LL_I2S_GetPrescalerParity
  2969. * @param SPIx SPI Instance
  2970. * @retval Returned value can be one of the following values:
  2971. * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
  2972. * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
  2973. */
  2974. __STATIC_INLINE uint32_t LL_I2S_GetPrescalerParity(SPI_TypeDef *SPIx)
  2975. {
  2976. return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ODD) >> SPI_I2SCFGR_ODD_Pos);
  2977. }
  2978. /**
  2979. * @brief Enable the Master Clock Output (Pin MCK)
  2980. * @rmtoll I2SCFGR MCKOE LL_I2S_EnableMasterClock
  2981. * @param SPIx SPI Handle
  2982. * @retval None
  2983. */
  2984. __STATIC_INLINE void LL_I2S_EnableMasterClock(SPI_TypeDef *SPIx)
  2985. {
  2986. SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE);
  2987. }
  2988. /**
  2989. * @brief Disable the Master Clock Output (Pin MCK)
  2990. * @rmtoll I2SCFGR MCKOE LL_I2S_DisableMasterClock
  2991. * @param SPIx SPI Handle
  2992. * @retval None
  2993. */
  2994. __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx)
  2995. {
  2996. CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE);
  2997. }
  2998. /**
  2999. * @brief Check if the master clock output (Pin MCK) is enabled
  3000. * @rmtoll I2SCFGR MCKOE LL_I2S_IsEnabledMasterClock
  3001. * @param SPIx SPI Instance
  3002. * @retval State of bit (1 or 0)
  3003. */
  3004. __STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef *SPIx)
  3005. {
  3006. return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE) == (SPI_I2SCFGR_MCKOE)) ? 1UL : 0UL);
  3007. }
  3008. /**
  3009. * @}
  3010. */
  3011. /** @defgroup I2S_LL_EF_FLAG_Management FLAG_Management
  3012. * @{
  3013. */
  3014. /**
  3015. * @brief Check if there enough data in FIFO to read a full packet
  3016. * @rmtoll SR RXP LL_I2S_IsActiveFlag_RXP
  3017. * @param SPIx SPI Instance
  3018. * @retval State of bit (1 or 0)
  3019. */
  3020. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXP(SPI_TypeDef *SPIx)
  3021. {
  3022. return LL_SPI_IsActiveFlag_RXP(SPIx);
  3023. }
  3024. /**
  3025. * @brief Check if there enough space in FIFO to hold a full packet
  3026. * @rmtoll SR TXP LL_I2S_IsActiveFlag_TXP
  3027. * @param SPIx SPI Instance
  3028. * @retval State of bit (1 or 0)
  3029. */
  3030. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXP(SPI_TypeDef *SPIx)
  3031. {
  3032. return LL_SPI_IsActiveFlag_TXP(SPIx);
  3033. }
  3034. /**
  3035. * @brief Get Underrun error flag
  3036. * @rmtoll SR UDR LL_I2S_IsActiveFlag_UDR
  3037. * @param SPIx SPI Instance
  3038. * @retval State of bit (1 or 0)
  3039. */
  3040. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx)
  3041. {
  3042. return LL_SPI_IsActiveFlag_UDR(SPIx);
  3043. }
  3044. /**
  3045. * @brief Get Overrun error flag
  3046. * @rmtoll SR OVR LL_I2S_IsActiveFlag_OVR
  3047. * @param SPIx SPI Instance
  3048. * @retval State of bit (1 or 0).
  3049. */
  3050. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(SPI_TypeDef *SPIx)
  3051. {
  3052. return LL_SPI_IsActiveFlag_OVR(SPIx);
  3053. }
  3054. /**
  3055. * @brief Get TI Frame format error flag
  3056. * @rmtoll SR TIFRE LL_I2S_IsActiveFlag_FRE
  3057. * @param SPIx SPI Instance
  3058. * @retval State of bit (1 or 0).
  3059. */
  3060. __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(SPI_TypeDef *SPIx)
  3061. {
  3062. return LL_SPI_IsActiveFlag_FRE(SPIx);
  3063. }
  3064. /**
  3065. * @brief Clear Underrun error flag
  3066. * @rmtoll IFCR UDRC LL_I2S_ClearFlag_UDR
  3067. * @param SPIx SPI Instance
  3068. * @retval None
  3069. */
  3070. __STATIC_INLINE void LL_I2S_ClearFlag_UDR(SPI_TypeDef *SPIx)
  3071. {
  3072. LL_SPI_ClearFlag_UDR(SPIx);
  3073. }
  3074. /**
  3075. * @brief Clear Overrun error flag
  3076. * @rmtoll IFCR OVRC LL_I2S_ClearFlag_OVR
  3077. * @param SPIx SPI Instance
  3078. * @retval None
  3079. */
  3080. __STATIC_INLINE void LL_I2S_ClearFlag_OVR(SPI_TypeDef *SPIx)
  3081. {
  3082. LL_SPI_ClearFlag_OVR(SPIx);
  3083. }
  3084. /**
  3085. * @brief Clear Frame format error flag
  3086. * @rmtoll IFCR TIFREC LL_I2S_ClearFlag_FRE
  3087. * @param SPIx SPI Instance
  3088. * @retval None
  3089. */
  3090. __STATIC_INLINE void LL_I2S_ClearFlag_FRE(SPI_TypeDef *SPIx)
  3091. {
  3092. LL_SPI_ClearFlag_FRE(SPIx);
  3093. }
  3094. /**
  3095. * @}
  3096. */
  3097. /** @defgroup I2S_LL_EF_IT_Management IT_Management
  3098. * @{
  3099. */
  3100. /**
  3101. * @brief Enable Rx Packet available IT
  3102. * @rmtoll IER RXPIE LL_I2S_EnableIT_RXP
  3103. * @param SPIx SPI Instance
  3104. * @retval None
  3105. */
  3106. __STATIC_INLINE void LL_I2S_EnableIT_RXP(SPI_TypeDef *SPIx)
  3107. {
  3108. LL_SPI_EnableIT_RXP(SPIx);
  3109. }
  3110. /**
  3111. * @brief Enable Tx Packet space available IT
  3112. * @rmtoll IER TXPIE LL_I2S_EnableIT_TXP
  3113. * @param SPIx SPI Instance
  3114. * @retval None
  3115. */
  3116. __STATIC_INLINE void LL_I2S_EnableIT_TXP(SPI_TypeDef *SPIx)
  3117. {
  3118. LL_SPI_EnableIT_TXP(SPIx);
  3119. }
  3120. /**
  3121. * @brief Enable Underrun IT
  3122. * @rmtoll IER UDRIE LL_I2S_EnableIT_UDR
  3123. * @param SPIx SPI Instance
  3124. * @retval None
  3125. */
  3126. __STATIC_INLINE void LL_I2S_EnableIT_UDR(SPI_TypeDef *SPIx)
  3127. {
  3128. LL_SPI_EnableIT_UDR(SPIx);
  3129. }
  3130. /**
  3131. * @brief Enable Overrun IT
  3132. * @rmtoll IER OVRIE LL_I2S_EnableIT_OVR
  3133. * @param SPIx SPI Instance
  3134. * @retval None
  3135. */
  3136. __STATIC_INLINE void LL_I2S_EnableIT_OVR(SPI_TypeDef *SPIx)
  3137. {
  3138. LL_SPI_EnableIT_OVR(SPIx);
  3139. }
  3140. /**
  3141. * @brief Enable TI Frame Format Error IT
  3142. * @rmtoll IER TIFREIE LL_I2S_EnableIT_FRE
  3143. * @param SPIx SPI Instance
  3144. * @retval None
  3145. */
  3146. __STATIC_INLINE void LL_I2S_EnableIT_FRE(SPI_TypeDef *SPIx)
  3147. {
  3148. LL_SPI_EnableIT_FRE(SPIx);
  3149. }
  3150. /**
  3151. * @brief Disable Rx Packet available IT
  3152. * @rmtoll IER RXPIE LL_I2S_DisableIT_RXP
  3153. * @param SPIx SPI Instance
  3154. * @retval None
  3155. */
  3156. __STATIC_INLINE void LL_I2S_DisableIT_RXP(SPI_TypeDef *SPIx)
  3157. {
  3158. LL_SPI_DisableIT_RXP(SPIx);
  3159. }
  3160. /**
  3161. * @brief Disable Tx Packet space available IT
  3162. * @rmtoll IER TXPIE LL_I2S_DisableIT_TXP
  3163. * @param SPIx SPI Instance
  3164. * @retval None
  3165. */
  3166. __STATIC_INLINE void LL_I2S_DisableIT_TXP(SPI_TypeDef *SPIx)
  3167. {
  3168. LL_SPI_DisableIT_TXP(SPIx);
  3169. }
  3170. /**
  3171. * @brief Disable Underrun IT
  3172. * @rmtoll IER UDRIE LL_I2S_DisableIT_UDR
  3173. * @param SPIx SPI Instance
  3174. * @retval None
  3175. */
  3176. __STATIC_INLINE void LL_I2S_DisableIT_UDR(SPI_TypeDef *SPIx)
  3177. {
  3178. LL_SPI_DisableIT_UDR(SPIx);
  3179. }
  3180. /**
  3181. * @brief Disable Overrun IT
  3182. * @rmtoll IER OVRIE LL_I2S_DisableIT_OVR
  3183. * @param SPIx SPI Instance
  3184. * @retval None
  3185. */
  3186. __STATIC_INLINE void LL_I2S_DisableIT_OVR(SPI_TypeDef *SPIx)
  3187. {
  3188. LL_SPI_DisableIT_OVR(SPIx);
  3189. }
  3190. /**
  3191. * @brief Disable TI Frame Format Error IT
  3192. * @rmtoll IER TIFREIE LL_I2S_DisableIT_FRE
  3193. * @param SPIx SPI Instance
  3194. * @retval None
  3195. */
  3196. __STATIC_INLINE void LL_I2S_DisableIT_FRE(SPI_TypeDef *SPIx)
  3197. {
  3198. LL_SPI_DisableIT_FRE(SPIx);
  3199. }
  3200. /**
  3201. * @brief Check if Rx Packet available IT is enabled
  3202. * @rmtoll IER RXPIE LL_I2S_IsEnabledIT_RXP
  3203. * @param SPIx SPI Instance
  3204. * @retval State of bit (1 or 0)
  3205. */
  3206. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXP(SPI_TypeDef *SPIx)
  3207. {
  3208. return LL_SPI_IsEnabledIT_RXP(SPIx);
  3209. }
  3210. /**
  3211. * @brief Check if Tx Packet space available IT is enabled
  3212. * @rmtoll IER TXPIE LL_I2S_IsEnabledIT_TXP
  3213. * @param SPIx SPI Instance
  3214. * @retval State of bit (1 or 0)
  3215. */
  3216. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_TXP(SPI_TypeDef *SPIx)
  3217. {
  3218. return LL_SPI_IsEnabledIT_TXP(SPIx);
  3219. }
  3220. /**
  3221. * @brief Check if Underrun IT is enabled
  3222. * @rmtoll IER UDRIE LL_I2S_IsEnabledIT_UDR
  3223. * @param SPIx SPI Instance
  3224. * @retval State of bit (1 or 0)
  3225. */
  3226. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_UDR(SPI_TypeDef *SPIx)
  3227. {
  3228. return LL_SPI_IsEnabledIT_UDR(SPIx);
  3229. }
  3230. /**
  3231. * @brief Check if Overrun IT is enabled
  3232. * @rmtoll IER OVRIE LL_I2S_IsEnabledIT_OVR
  3233. * @param SPIx SPI Instance
  3234. * @retval State of bit (1 or 0)
  3235. */
  3236. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_OVR(SPI_TypeDef *SPIx)
  3237. {
  3238. return LL_SPI_IsEnabledIT_OVR(SPIx);
  3239. }
  3240. /**
  3241. * @brief Check if TI Frame Format Error IT is enabled
  3242. * @rmtoll IER TIFREIE LL_I2S_IsEnabledIT_FRE
  3243. * @param SPIx SPI Instance
  3244. * @retval State of bit (1 or 0)
  3245. */
  3246. __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_FRE(SPI_TypeDef *SPIx)
  3247. {
  3248. return LL_SPI_IsEnabledIT_FRE(SPIx);
  3249. }
  3250. /**
  3251. * @}
  3252. */
  3253. /** @defgroup I2S_LL_EF_DMA_Management DMA_Management
  3254. * @{
  3255. */
  3256. /**
  3257. * @brief Enable DMA Rx
  3258. * @rmtoll CFG1 RXDMAEN LL_I2S_EnableDMAReq_RX
  3259. * @param SPIx SPI Instance
  3260. * @retval None
  3261. */
  3262. __STATIC_INLINE void LL_I2S_EnableDMAReq_RX(SPI_TypeDef *SPIx)
  3263. {
  3264. LL_SPI_EnableDMAReq_RX(SPIx);
  3265. }
  3266. /**
  3267. * @brief Disable DMA Rx
  3268. * @rmtoll CFG1 RXDMAEN LL_I2S_DisableDMAReq_RX
  3269. * @param SPIx SPI Instance
  3270. * @retval None
  3271. */
  3272. __STATIC_INLINE void LL_I2S_DisableDMAReq_RX(SPI_TypeDef *SPIx)
  3273. {
  3274. LL_SPI_DisableDMAReq_RX(SPIx);
  3275. }
  3276. /**
  3277. * @brief Check if DMA Rx is enabled
  3278. * @rmtoll CFG1 RXDMAEN LL_I2S_IsEnabledDMAReq_RX
  3279. * @param SPIx SPI Instance
  3280. * @retval State of bit (1 or 0)
  3281. */
  3282. __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx)
  3283. {
  3284. return LL_SPI_IsEnabledDMAReq_RX(SPIx);
  3285. }
  3286. /**
  3287. * @brief Enable DMA Tx
  3288. * @rmtoll CFG1 TXDMAEN LL_I2S_EnableDMAReq_TX
  3289. * @param SPIx SPI Instance
  3290. * @retval None
  3291. */
  3292. __STATIC_INLINE void LL_I2S_EnableDMAReq_TX(SPI_TypeDef *SPIx)
  3293. {
  3294. LL_SPI_EnableDMAReq_TX(SPIx);
  3295. }
  3296. /**
  3297. * @brief Disable DMA Tx
  3298. * @rmtoll CFG1 TXDMAEN LL_I2S_DisableDMAReq_TX
  3299. * @param SPIx SPI Instance
  3300. * @retval None
  3301. */
  3302. __STATIC_INLINE void LL_I2S_DisableDMAReq_TX(SPI_TypeDef *SPIx)
  3303. {
  3304. LL_SPI_DisableDMAReq_TX(SPIx);
  3305. }
  3306. /**
  3307. * @brief Check if DMA Tx is enabled
  3308. * @rmtoll CFG1 TXDMAEN LL_I2S_IsEnabledDMAReq_TX
  3309. * @param SPIx SPI Instance
  3310. * @retval State of bit (1 or 0)
  3311. */
  3312. __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx)
  3313. {
  3314. return LL_SPI_IsEnabledDMAReq_TX(SPIx);
  3315. }
  3316. /**
  3317. * @}
  3318. */
  3319. /** @defgroup I2S_LL_EF_DATA_Management DATA_Management
  3320. * @{
  3321. */
  3322. /**
  3323. * @brief Read Data Register
  3324. * @rmtoll RXDR . LL_I2S_ReceiveData16
  3325. * @param SPIx SPI Instance
  3326. * @retval 0..0xFFFF
  3327. */
  3328. __STATIC_INLINE uint16_t LL_I2S_ReceiveData16(SPI_TypeDef *SPIx)
  3329. {
  3330. return LL_SPI_ReceiveData16(SPIx);
  3331. }
  3332. /**
  3333. * @brief Read Data Register
  3334. * @rmtoll RXDR . LL_I2S_ReceiveData32
  3335. * @param SPIx SPI Instance
  3336. * @retval 0..0xFFFFFFFF
  3337. */
  3338. __STATIC_INLINE uint32_t LL_I2S_ReceiveData32(SPI_TypeDef *SPIx)
  3339. {
  3340. return LL_SPI_ReceiveData32(SPIx);
  3341. }
  3342. /**
  3343. * @brief Write Data Register
  3344. * @rmtoll TXDR . LL_I2S_TransmitData16
  3345. * @param SPIx SPI Instance
  3346. * @param TxData 0..0xFFFF
  3347. * @retval None
  3348. */
  3349. __STATIC_INLINE void LL_I2S_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData)
  3350. {
  3351. LL_SPI_TransmitData16(SPIx, TxData);
  3352. }
  3353. /**
  3354. * @brief Write Data Register
  3355. * @rmtoll TXDR . LL_I2S_TransmitData32
  3356. * @param SPIx SPI Instance
  3357. * @param TxData 0..0xFFFFFFFF
  3358. * @retval None
  3359. */
  3360. __STATIC_INLINE void LL_I2S_TransmitData32(SPI_TypeDef *SPIx, uint32_t TxData)
  3361. {
  3362. LL_SPI_TransmitData32(SPIx, TxData);
  3363. }
  3364. /**
  3365. * @}
  3366. */
  3367. #if defined(USE_FULL_LL_DRIVER)
  3368. /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions
  3369. * @{
  3370. */
  3371. ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx);
  3372. ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct);
  3373. void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct);
  3374. void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity);
  3375. /**
  3376. * @}
  3377. */
  3378. #endif /* USE_FULL_LL_DRIVER */
  3379. /**
  3380. * @}
  3381. */
  3382. /**
  3383. * @}
  3384. */
  3385. #endif /* defined(SPI1) || defined(SPI2) || defined(SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6) */
  3386. /**
  3387. * @}
  3388. */
  3389. /**
  3390. * @}
  3391. */
  3392. #ifdef __cplusplus
  3393. }
  3394. #endif
  3395. #endif /* STM32H7xx_LL_SPI_H */