stm32f1xx_ll_gpio.h 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_gpio.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32F1xx_LL_GPIO_H
  21. #define STM32F1xx_LL_GPIO_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f1xx.h"
  27. /** @addtogroup STM32F1xx_LL_Driver
  28. * @{
  29. */
  30. #if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG)
  31. /** @defgroup GPIO_LL GPIO
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup GPIO_LL_Private_Constants GPIO Private Constants
  38. * @{
  39. */
  40. /* Defines used for Pin Mask Initialization */
  41. #define GPIO_PIN_MASK_POS 8U
  42. #define GPIO_PIN_NB 16U
  43. /**
  44. * @}
  45. */
  46. /* Private macros ------------------------------------------------------------*/
  47. #if defined(USE_FULL_LL_DRIVER)
  48. /** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
  49. * @{
  50. */
  51. /**
  52. * @}
  53. */
  54. #endif /*USE_FULL_LL_DRIVER*/
  55. /* Exported types ------------------------------------------------------------*/
  56. #if defined(USE_FULL_LL_DRIVER)
  57. /** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
  58. * @{
  59. */
  60. /**
  61. * @brief LL GPIO Init Structure definition
  62. */
  63. typedef struct
  64. {
  65. uint32_t Pin; /*!< Specifies the GPIO pins to be configured.
  66. This parameter can be any value of @ref GPIO_LL_EC_PIN */
  67. uint32_t Mode; /*!< Specifies the operating mode for the selected pins.
  68. This parameter can be a value of @ref GPIO_LL_EC_MODE.
  69. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
  70. uint32_t Speed; /*!< Specifies the speed for the selected pins.
  71. This parameter can be a value of @ref GPIO_LL_EC_SPEED.
  72. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
  73. uint32_t OutputType; /*!< Specifies the operating output type for the selected pins.
  74. This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
  75. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
  76. uint32_t Pull; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
  77. This parameter can be a value of @ref GPIO_LL_EC_PULL.
  78. GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
  79. } LL_GPIO_InitTypeDef;
  80. /**
  81. * @}
  82. */
  83. #endif /* USE_FULL_LL_DRIVER */
  84. /* Exported constants --------------------------------------------------------*/
  85. /** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
  86. * @{
  87. */
  88. /** @defgroup GPIO_LL_EC_PIN PIN
  89. * @{
  90. */
  91. #define LL_GPIO_PIN_0 ((GPIO_BSRR_BS0 << GPIO_PIN_MASK_POS) | 0x00000001U) /*!< Select pin 0 */
  92. #define LL_GPIO_PIN_1 ((GPIO_BSRR_BS1 << GPIO_PIN_MASK_POS) | 0x00000002U) /*!< Select pin 1 */
  93. #define LL_GPIO_PIN_2 ((GPIO_BSRR_BS2 << GPIO_PIN_MASK_POS) | 0x00000004U) /*!< Select pin 2 */
  94. #define LL_GPIO_PIN_3 ((GPIO_BSRR_BS3 << GPIO_PIN_MASK_POS) | 0x00000008U) /*!< Select pin 3 */
  95. #define LL_GPIO_PIN_4 ((GPIO_BSRR_BS4 << GPIO_PIN_MASK_POS) | 0x00000010U) /*!< Select pin 4 */
  96. #define LL_GPIO_PIN_5 ((GPIO_BSRR_BS5 << GPIO_PIN_MASK_POS) | 0x00000020U) /*!< Select pin 5 */
  97. #define LL_GPIO_PIN_6 ((GPIO_BSRR_BS6 << GPIO_PIN_MASK_POS) | 0x00000040U) /*!< Select pin 6 */
  98. #define LL_GPIO_PIN_7 ((GPIO_BSRR_BS7 << GPIO_PIN_MASK_POS) | 0x00000080U) /*!< Select pin 7 */
  99. #define LL_GPIO_PIN_8 ((GPIO_BSRR_BS8 << GPIO_PIN_MASK_POS) | 0x04000001U) /*!< Select pin 8 */
  100. #define LL_GPIO_PIN_9 ((GPIO_BSRR_BS9 << GPIO_PIN_MASK_POS) | 0x04000002U) /*!< Select pin 9 */
  101. #define LL_GPIO_PIN_10 ((GPIO_BSRR_BS10 << GPIO_PIN_MASK_POS) | 0x04000004U) /*!< Select pin 10 */
  102. #define LL_GPIO_PIN_11 ((GPIO_BSRR_BS11 << GPIO_PIN_MASK_POS) | 0x04000008U) /*!< Select pin 11 */
  103. #define LL_GPIO_PIN_12 ((GPIO_BSRR_BS12 << GPIO_PIN_MASK_POS) | 0x04000010U) /*!< Select pin 12 */
  104. #define LL_GPIO_PIN_13 ((GPIO_BSRR_BS13 << GPIO_PIN_MASK_POS) | 0x04000020U) /*!< Select pin 13 */
  105. #define LL_GPIO_PIN_14 ((GPIO_BSRR_BS14 << GPIO_PIN_MASK_POS) | 0x04000040U) /*!< Select pin 14 */
  106. #define LL_GPIO_PIN_15 ((GPIO_BSRR_BS15 << GPIO_PIN_MASK_POS) | 0x04000080U) /*!< Select pin 15 */
  107. #define LL_GPIO_PIN_ALL (LL_GPIO_PIN_0 | LL_GPIO_PIN_1 | LL_GPIO_PIN_2 | \
  108. LL_GPIO_PIN_3 | LL_GPIO_PIN_4 | LL_GPIO_PIN_5 | \
  109. LL_GPIO_PIN_6 | LL_GPIO_PIN_7 | LL_GPIO_PIN_8 | \
  110. LL_GPIO_PIN_9 | LL_GPIO_PIN_10 | LL_GPIO_PIN_11 | \
  111. LL_GPIO_PIN_12 | LL_GPIO_PIN_13 | LL_GPIO_PIN_14 | \
  112. LL_GPIO_PIN_15) /*!< Select all pins */
  113. /**
  114. * @}
  115. */
  116. /** @defgroup GPIO_LL_EC_MODE Mode
  117. * @{
  118. */
  119. #define LL_GPIO_MODE_ANALOG 0x00000000U /*!< Select analog mode */
  120. #define LL_GPIO_MODE_FLOATING GPIO_CRL_CNF0_0 /*!< Select floating mode */
  121. #define LL_GPIO_MODE_INPUT GPIO_CRL_CNF0_1 /*!< Select input mode */
  122. #define LL_GPIO_MODE_OUTPUT GPIO_CRL_MODE0_0 /*!< Select general purpose output mode */
  123. #define LL_GPIO_MODE_ALTERNATE (GPIO_CRL_CNF0_1 | GPIO_CRL_MODE0_0) /*!< Select alternate function mode */
  124. /**
  125. * @}
  126. */
  127. /** @defgroup GPIO_LL_EC_OUTPUT Output Type
  128. * @{
  129. */
  130. #define LL_GPIO_OUTPUT_PUSHPULL 0x00000000U /*!< Select push-pull as output type */
  131. #define LL_GPIO_OUTPUT_OPENDRAIN GPIO_CRL_CNF0_0 /*!< Select open-drain as output type */
  132. /**
  133. * @}
  134. */
  135. /** @defgroup GPIO_LL_EC_SPEED Output Speed
  136. * @{
  137. */
  138. #define LL_GPIO_MODE_OUTPUT_10MHz GPIO_CRL_MODE0_0 /*!< Select Output mode, max speed 10 MHz */
  139. #define LL_GPIO_MODE_OUTPUT_2MHz GPIO_CRL_MODE0_1 /*!< Select Output mode, max speed 20 MHz */
  140. #define LL_GPIO_MODE_OUTPUT_50MHz GPIO_CRL_MODE0 /*!< Select Output mode, max speed 50 MHz */
  141. /**
  142. * @}
  143. */
  144. #define LL_GPIO_SPEED_FREQ_LOW LL_GPIO_MODE_OUTPUT_2MHz /*!< Select I/O low output speed */
  145. #define LL_GPIO_SPEED_FREQ_MEDIUM LL_GPIO_MODE_OUTPUT_10MHz /*!< Select I/O medium output speed */
  146. #define LL_GPIO_SPEED_FREQ_HIGH LL_GPIO_MODE_OUTPUT_50MHz /*!< Select I/O high output speed */
  147. /** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
  148. * @{
  149. */
  150. #define LL_GPIO_PULL_DOWN 0x00000000U /*!< Select I/O pull down */
  151. #define LL_GPIO_PULL_UP GPIO_ODR_ODR0 /*!< Select I/O pull up */
  152. /**
  153. * @}
  154. */
  155. /** @defgroup GPIO_LL_EVENTOUT_PIN EVENTOUT Pin
  156. * @{
  157. */
  158. #define LL_GPIO_AF_EVENTOUT_PIN_0 AFIO_EVCR_PIN_PX0 /*!< EVENTOUT on pin 0 */
  159. #define LL_GPIO_AF_EVENTOUT_PIN_1 AFIO_EVCR_PIN_PX1 /*!< EVENTOUT on pin 1 */
  160. #define LL_GPIO_AF_EVENTOUT_PIN_2 AFIO_EVCR_PIN_PX2 /*!< EVENTOUT on pin 2 */
  161. #define LL_GPIO_AF_EVENTOUT_PIN_3 AFIO_EVCR_PIN_PX3 /*!< EVENTOUT on pin 3 */
  162. #define LL_GPIO_AF_EVENTOUT_PIN_4 AFIO_EVCR_PIN_PX4 /*!< EVENTOUT on pin 4 */
  163. #define LL_GPIO_AF_EVENTOUT_PIN_5 AFIO_EVCR_PIN_PX5 /*!< EVENTOUT on pin 5 */
  164. #define LL_GPIO_AF_EVENTOUT_PIN_6 AFIO_EVCR_PIN_PX6 /*!< EVENTOUT on pin 6 */
  165. #define LL_GPIO_AF_EVENTOUT_PIN_7 AFIO_EVCR_PIN_PX7 /*!< EVENTOUT on pin 7 */
  166. #define LL_GPIO_AF_EVENTOUT_PIN_8 AFIO_EVCR_PIN_PX8 /*!< EVENTOUT on pin 8 */
  167. #define LL_GPIO_AF_EVENTOUT_PIN_9 AFIO_EVCR_PIN_PX9 /*!< EVENTOUT on pin 9 */
  168. #define LL_GPIO_AF_EVENTOUT_PIN_10 AFIO_EVCR_PIN_PX10 /*!< EVENTOUT on pin 10 */
  169. #define LL_GPIO_AF_EVENTOUT_PIN_11 AFIO_EVCR_PIN_PX11 /*!< EVENTOUT on pin 11 */
  170. #define LL_GPIO_AF_EVENTOUT_PIN_12 AFIO_EVCR_PIN_PX12 /*!< EVENTOUT on pin 12 */
  171. #define LL_GPIO_AF_EVENTOUT_PIN_13 AFIO_EVCR_PIN_PX13 /*!< EVENTOUT on pin 13 */
  172. #define LL_GPIO_AF_EVENTOUT_PIN_14 AFIO_EVCR_PIN_PX14 /*!< EVENTOUT on pin 14 */
  173. #define LL_GPIO_AF_EVENTOUT_PIN_15 AFIO_EVCR_PIN_PX15 /*!< EVENTOUT on pin 15 */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup GPIO_LL_EVENTOUT_PORT EVENTOUT Port
  178. * @{
  179. */
  180. #define LL_GPIO_AF_EVENTOUT_PORT_A AFIO_EVCR_PORT_PA /*!< EVENTOUT on port A */
  181. #define LL_GPIO_AF_EVENTOUT_PORT_B AFIO_EVCR_PORT_PB /*!< EVENTOUT on port B */
  182. #define LL_GPIO_AF_EVENTOUT_PORT_C AFIO_EVCR_PORT_PC /*!< EVENTOUT on port C */
  183. #define LL_GPIO_AF_EVENTOUT_PORT_D AFIO_EVCR_PORT_PD /*!< EVENTOUT on port D */
  184. #define LL_GPIO_AF_EVENTOUT_PORT_E AFIO_EVCR_PORT_PE /*!< EVENTOUT on port E */
  185. /**
  186. * @}
  187. */
  188. /** @defgroup GPIO_LL_EC_EXTI_PORT GPIO EXTI PORT
  189. * @{
  190. */
  191. #define LL_GPIO_AF_EXTI_PORTA 0U /*!< EXTI PORT A */
  192. #define LL_GPIO_AF_EXTI_PORTB 1U /*!< EXTI PORT B */
  193. #define LL_GPIO_AF_EXTI_PORTC 2U /*!< EXTI PORT C */
  194. #define LL_GPIO_AF_EXTI_PORTD 3U /*!< EXTI PORT D */
  195. #define LL_GPIO_AF_EXTI_PORTE 4U /*!< EXTI PORT E */
  196. #define LL_GPIO_AF_EXTI_PORTF 5U /*!< EXTI PORT F */
  197. #define LL_GPIO_AF_EXTI_PORTG 6U /*!< EXTI PORT G */
  198. /**
  199. * @}
  200. */
  201. /** @defgroup GPIO_LL_EC_EXTI_LINE GPIO EXTI LINE
  202. * @{
  203. */
  204. #define LL_GPIO_AF_EXTI_LINE0 (0x000FU << 16U | 0U) /*!< EXTI_POSITION_0 | EXTICR[0] */
  205. #define LL_GPIO_AF_EXTI_LINE1 (0x00F0U << 16U | 0U) /*!< EXTI_POSITION_4 | EXTICR[0] */
  206. #define LL_GPIO_AF_EXTI_LINE2 (0x0F00U << 16U | 0U) /*!< EXTI_POSITION_8 | EXTICR[0] */
  207. #define LL_GPIO_AF_EXTI_LINE3 (0xF000U << 16U | 0U) /*!< EXTI_POSITION_12 | EXTICR[0] */
  208. #define LL_GPIO_AF_EXTI_LINE4 (0x000FU << 16U | 1U) /*!< EXTI_POSITION_0 | EXTICR[1] */
  209. #define LL_GPIO_AF_EXTI_LINE5 (0x00F0U << 16U | 1U) /*!< EXTI_POSITION_4 | EXTICR[1] */
  210. #define LL_GPIO_AF_EXTI_LINE6 (0x0F00U << 16U | 1U) /*!< EXTI_POSITION_8 | EXTICR[1] */
  211. #define LL_GPIO_AF_EXTI_LINE7 (0xF000U << 16U | 1U) /*!< EXTI_POSITION_12 | EXTICR[1] */
  212. #define LL_GPIO_AF_EXTI_LINE8 (0x000FU << 16U | 2U) /*!< EXTI_POSITION_0 | EXTICR[2] */
  213. #define LL_GPIO_AF_EXTI_LINE9 (0x00F0U << 16U | 2U) /*!< EXTI_POSITION_4 | EXTICR[2] */
  214. #define LL_GPIO_AF_EXTI_LINE10 (0x0F00U << 16U | 2U) /*!< EXTI_POSITION_8 | EXTICR[2] */
  215. #define LL_GPIO_AF_EXTI_LINE11 (0xF000U << 16U | 2U) /*!< EXTI_POSITION_12 | EXTICR[2] */
  216. #define LL_GPIO_AF_EXTI_LINE12 (0x000FU << 16U | 3U) /*!< EXTI_POSITION_0 | EXTICR[3] */
  217. #define LL_GPIO_AF_EXTI_LINE13 (0x00F0U << 16U | 3U) /*!< EXTI_POSITION_4 | EXTICR[3] */
  218. #define LL_GPIO_AF_EXTI_LINE14 (0x0F00U << 16U | 3U) /*!< EXTI_POSITION_8 | EXTICR[3] */
  219. #define LL_GPIO_AF_EXTI_LINE15 (0xF000U << 16U | 3U) /*!< EXTI_POSITION_12 | EXTICR[3] */
  220. /**
  221. * @}
  222. */
  223. /**
  224. * @}
  225. */
  226. /* Exported macro ------------------------------------------------------------*/
  227. /** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
  228. * @{
  229. */
  230. /** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
  231. * @{
  232. */
  233. /**
  234. * @brief Write a value in GPIO register
  235. * @param __INSTANCE__ GPIO Instance
  236. * @param __REG__ Register to be written
  237. * @param __VALUE__ Value to be written in the register
  238. * @retval None
  239. */
  240. #define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  241. /**
  242. * @brief Read a value in GPIO register
  243. * @param __INSTANCE__ GPIO Instance
  244. * @param __REG__ Register to be read
  245. * @retval Register value
  246. */
  247. #define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  248. /**
  249. * @}
  250. */
  251. /**
  252. * @}
  253. */
  254. /* Exported functions --------------------------------------------------------*/
  255. /** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
  256. * @{
  257. */
  258. /** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
  259. * @{
  260. */
  261. /**
  262. * @brief Configure gpio mode for a dedicated pin on dedicated port.
  263. * @note I/O mode can be Analog, Floating input, Input with pull-up/pull-down, General purpose Output,
  264. * Alternate function Output.
  265. * @note Warning: only one pin can be passed as parameter.
  266. * @rmtoll CRL CNFy LL_GPIO_SetPinMode
  267. * @rmtoll CRL MODEy LL_GPIO_SetPinMode
  268. * @rmtoll CRH CNFy LL_GPIO_SetPinMode
  269. * @rmtoll CRH MODEy LL_GPIO_SetPinMode
  270. * @param GPIOx GPIO Port
  271. * @param Pin This parameter can be one of the following values:
  272. * @arg @ref LL_GPIO_PIN_0
  273. * @arg @ref LL_GPIO_PIN_1
  274. * @arg @ref LL_GPIO_PIN_2
  275. * @arg @ref LL_GPIO_PIN_3
  276. * @arg @ref LL_GPIO_PIN_4
  277. * @arg @ref LL_GPIO_PIN_5
  278. * @arg @ref LL_GPIO_PIN_6
  279. * @arg @ref LL_GPIO_PIN_7
  280. * @arg @ref LL_GPIO_PIN_8
  281. * @arg @ref LL_GPIO_PIN_9
  282. * @arg @ref LL_GPIO_PIN_10
  283. * @arg @ref LL_GPIO_PIN_11
  284. * @arg @ref LL_GPIO_PIN_12
  285. * @arg @ref LL_GPIO_PIN_13
  286. * @arg @ref LL_GPIO_PIN_14
  287. * @arg @ref LL_GPIO_PIN_15
  288. * @param Mode This parameter can be one of the following values:
  289. * @arg @ref LL_GPIO_MODE_ANALOG
  290. * @arg @ref LL_GPIO_MODE_FLOATING
  291. * @arg @ref LL_GPIO_MODE_INPUT
  292. * @arg @ref LL_GPIO_MODE_OUTPUT
  293. * @arg @ref LL_GPIO_MODE_ALTERNATE
  294. * @retval None
  295. */
  296. __STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
  297. {
  298. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  299. MODIFY_REG(*pReg, ((GPIO_CRL_CNF0 | GPIO_CRL_MODE0) << (POSITION_VAL(Pin) * 4U)), (Mode << (POSITION_VAL(Pin) * 4U)));
  300. }
  301. /**
  302. * @brief Return gpio mode for a dedicated pin on dedicated port.
  303. * @note I/O mode can be Analog, Floating input, Input with pull-up/pull-down, General purpose Output,
  304. * Alternate function Output.
  305. * @note Warning: only one pin can be passed as parameter.
  306. * @rmtoll CRL CNFy LL_GPIO_GetPinMode
  307. * @rmtoll CRL MODEy LL_GPIO_GetPinMode
  308. * @rmtoll CRH CNFy LL_GPIO_GetPinMode
  309. * @rmtoll CRH MODEy LL_GPIO_GetPinMode
  310. * @param GPIOx GPIO Port
  311. * @param Pin This parameter can be one of the following values:
  312. * @arg @ref LL_GPIO_PIN_0
  313. * @arg @ref LL_GPIO_PIN_1
  314. * @arg @ref LL_GPIO_PIN_2
  315. * @arg @ref LL_GPIO_PIN_3
  316. * @arg @ref LL_GPIO_PIN_4
  317. * @arg @ref LL_GPIO_PIN_5
  318. * @arg @ref LL_GPIO_PIN_6
  319. * @arg @ref LL_GPIO_PIN_7
  320. * @arg @ref LL_GPIO_PIN_8
  321. * @arg @ref LL_GPIO_PIN_9
  322. * @arg @ref LL_GPIO_PIN_10
  323. * @arg @ref LL_GPIO_PIN_11
  324. * @arg @ref LL_GPIO_PIN_12
  325. * @arg @ref LL_GPIO_PIN_13
  326. * @arg @ref LL_GPIO_PIN_14
  327. * @arg @ref LL_GPIO_PIN_15
  328. * @retval Returned value can be one of the following values:
  329. * @arg @ref LL_GPIO_MODE_ANALOG
  330. * @arg @ref LL_GPIO_MODE_FLOATING
  331. * @arg @ref LL_GPIO_MODE_INPUT
  332. * @arg @ref LL_GPIO_MODE_OUTPUT
  333. * @arg @ref LL_GPIO_MODE_ALTERNATE
  334. */
  335. __STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin)
  336. {
  337. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  338. return (READ_BIT(*pReg, ((GPIO_CRL_CNF0 | GPIO_CRL_MODE0) << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U));
  339. }
  340. /**
  341. * @brief Configure gpio speed for a dedicated pin on dedicated port.
  342. * @note I/O speed can be Low, Medium or Fast speed.
  343. * @note Warning: only one pin can be passed as parameter.
  344. * @note Refer to datasheet for frequency specifications and the power
  345. * supply and load conditions for each speed.
  346. * @rmtoll CRL MODEy LL_GPIO_SetPinSpeed
  347. * @rmtoll CRH MODEy LL_GPIO_SetPinSpeed
  348. * @param GPIOx GPIO Port
  349. * @param Pin This parameter can be one of the following values:
  350. * @arg @ref LL_GPIO_PIN_0
  351. * @arg @ref LL_GPIO_PIN_1
  352. * @arg @ref LL_GPIO_PIN_2
  353. * @arg @ref LL_GPIO_PIN_3
  354. * @arg @ref LL_GPIO_PIN_4
  355. * @arg @ref LL_GPIO_PIN_5
  356. * @arg @ref LL_GPIO_PIN_6
  357. * @arg @ref LL_GPIO_PIN_7
  358. * @arg @ref LL_GPIO_PIN_8
  359. * @arg @ref LL_GPIO_PIN_9
  360. * @arg @ref LL_GPIO_PIN_10
  361. * @arg @ref LL_GPIO_PIN_11
  362. * @arg @ref LL_GPIO_PIN_12
  363. * @arg @ref LL_GPIO_PIN_13
  364. * @arg @ref LL_GPIO_PIN_14
  365. * @arg @ref LL_GPIO_PIN_15
  366. * @param Speed This parameter can be one of the following values:
  367. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  368. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  369. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  370. * @retval None
  371. */
  372. __STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Speed)
  373. {
  374. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  375. MODIFY_REG(*pReg, (GPIO_CRL_MODE0 << (POSITION_VAL(Pin) * 4U)),
  376. (Speed << (POSITION_VAL(Pin) * 4U)));
  377. }
  378. /**
  379. * @brief Return gpio speed for a dedicated pin on dedicated port.
  380. * @note I/O speed can be Low, Medium, Fast or High speed.
  381. * @note Warning: only one pin can be passed as parameter.
  382. * @note Refer to datasheet for frequency specifications and the power
  383. * supply and load conditions for each speed.
  384. * @rmtoll CRL MODEy LL_GPIO_GetPinSpeed
  385. * @rmtoll CRH MODEy LL_GPIO_GetPinSpeed
  386. * @param GPIOx GPIO Port
  387. * @param Pin This parameter can be one of the following values:
  388. * @arg @ref LL_GPIO_PIN_0
  389. * @arg @ref LL_GPIO_PIN_1
  390. * @arg @ref LL_GPIO_PIN_2
  391. * @arg @ref LL_GPIO_PIN_3
  392. * @arg @ref LL_GPIO_PIN_4
  393. * @arg @ref LL_GPIO_PIN_5
  394. * @arg @ref LL_GPIO_PIN_6
  395. * @arg @ref LL_GPIO_PIN_7
  396. * @arg @ref LL_GPIO_PIN_8
  397. * @arg @ref LL_GPIO_PIN_9
  398. * @arg @ref LL_GPIO_PIN_10
  399. * @arg @ref LL_GPIO_PIN_11
  400. * @arg @ref LL_GPIO_PIN_12
  401. * @arg @ref LL_GPIO_PIN_13
  402. * @arg @ref LL_GPIO_PIN_14
  403. * @arg @ref LL_GPIO_PIN_15
  404. * @retval Returned value can be one of the following values:
  405. * @arg @ref LL_GPIO_SPEED_FREQ_LOW
  406. * @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
  407. * @arg @ref LL_GPIO_SPEED_FREQ_HIGH
  408. */
  409. __STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin)
  410. {
  411. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  412. return (READ_BIT(*pReg, (GPIO_CRL_MODE0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U));
  413. }
  414. /**
  415. * @brief Configure gpio output type for several pins on dedicated port.
  416. * @note Output type as to be set when gpio pin is in output or
  417. * alternate modes. Possible type are Push-pull or Open-drain.
  418. * @rmtoll CRL MODEy LL_GPIO_SetPinOutputType
  419. * @rmtoll CRH MODEy LL_GPIO_SetPinOutputType
  420. * @param GPIOx GPIO Port
  421. * @param Pin This parameter can be a combination of the following values:
  422. * @arg @ref LL_GPIO_PIN_0
  423. * @arg @ref LL_GPIO_PIN_1
  424. * @arg @ref LL_GPIO_PIN_2
  425. * @arg @ref LL_GPIO_PIN_3
  426. * @arg @ref LL_GPIO_PIN_4
  427. * @arg @ref LL_GPIO_PIN_5
  428. * @arg @ref LL_GPIO_PIN_6
  429. * @arg @ref LL_GPIO_PIN_7
  430. * @arg @ref LL_GPIO_PIN_8
  431. * @arg @ref LL_GPIO_PIN_9
  432. * @arg @ref LL_GPIO_PIN_10
  433. * @arg @ref LL_GPIO_PIN_11
  434. * @arg @ref LL_GPIO_PIN_12
  435. * @arg @ref LL_GPIO_PIN_13
  436. * @arg @ref LL_GPIO_PIN_14
  437. * @arg @ref LL_GPIO_PIN_15
  438. * @arg @ref LL_GPIO_PIN_ALL
  439. * @param OutputType This parameter can be one of the following values:
  440. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  441. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  442. * @retval None
  443. */
  444. __STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t OutputType)
  445. {
  446. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  447. MODIFY_REG(*pReg, (GPIO_CRL_CNF0_0 << (POSITION_VAL(Pin) * 4U)),
  448. (OutputType << (POSITION_VAL(Pin) * 4U)));
  449. }
  450. /**
  451. * @brief Return gpio output type for several pins on dedicated port.
  452. * @note Output type as to be set when gpio pin is in output or
  453. * alternate modes. Possible type are Push-pull or Open-drain.
  454. * @note Warning: only one pin can be passed as parameter.
  455. * @rmtoll CRL MODEy LL_GPIO_GetPinOutputType
  456. * @rmtoll CRH MODEy LL_GPIO_GetPinOutputType
  457. * @param GPIOx GPIO Port
  458. * @param Pin This parameter can be one of the following values:
  459. * @arg @ref LL_GPIO_PIN_0
  460. * @arg @ref LL_GPIO_PIN_1
  461. * @arg @ref LL_GPIO_PIN_2
  462. * @arg @ref LL_GPIO_PIN_3
  463. * @arg @ref LL_GPIO_PIN_4
  464. * @arg @ref LL_GPIO_PIN_5
  465. * @arg @ref LL_GPIO_PIN_6
  466. * @arg @ref LL_GPIO_PIN_7
  467. * @arg @ref LL_GPIO_PIN_8
  468. * @arg @ref LL_GPIO_PIN_9
  469. * @arg @ref LL_GPIO_PIN_10
  470. * @arg @ref LL_GPIO_PIN_11
  471. * @arg @ref LL_GPIO_PIN_12
  472. * @arg @ref LL_GPIO_PIN_13
  473. * @arg @ref LL_GPIO_PIN_14
  474. * @arg @ref LL_GPIO_PIN_15
  475. * @arg @ref LL_GPIO_PIN_ALL
  476. * @retval Returned value can be one of the following values:
  477. * @arg @ref LL_GPIO_OUTPUT_PUSHPULL
  478. * @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
  479. */
  480. __STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin)
  481. {
  482. register uint32_t *pReg = (uint32_t *)((uint32_t)(&GPIOx->CRL) + (Pin >> 24));
  483. return (READ_BIT(*pReg, (GPIO_CRL_CNF0_0 << (POSITION_VAL(Pin) * 4U))) >> (POSITION_VAL(Pin) * 4U));
  484. }
  485. /**
  486. * @brief Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
  487. * @note Warning: only one pin can be passed as parameter.
  488. * @rmtoll ODR ODR LL_GPIO_SetPinPull
  489. * @param GPIOx GPIO Port
  490. * @param Pin This parameter can be one of the following values:
  491. * @arg @ref LL_GPIO_PIN_0
  492. * @arg @ref LL_GPIO_PIN_1
  493. * @arg @ref LL_GPIO_PIN_2
  494. * @arg @ref LL_GPIO_PIN_3
  495. * @arg @ref LL_GPIO_PIN_4
  496. * @arg @ref LL_GPIO_PIN_5
  497. * @arg @ref LL_GPIO_PIN_6
  498. * @arg @ref LL_GPIO_PIN_7
  499. * @arg @ref LL_GPIO_PIN_8
  500. * @arg @ref LL_GPIO_PIN_9
  501. * @arg @ref LL_GPIO_PIN_10
  502. * @arg @ref LL_GPIO_PIN_11
  503. * @arg @ref LL_GPIO_PIN_12
  504. * @arg @ref LL_GPIO_PIN_13
  505. * @arg @ref LL_GPIO_PIN_14
  506. * @arg @ref LL_GPIO_PIN_15
  507. * @param Pull This parameter can be one of the following values:
  508. * @arg @ref LL_GPIO_PULL_DOWN
  509. * @arg @ref LL_GPIO_PULL_UP
  510. * @retval None
  511. */
  512. __STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
  513. {
  514. MODIFY_REG(GPIOx->ODR, (Pin >> GPIO_PIN_MASK_POS), Pull << (POSITION_VAL(Pin >> GPIO_PIN_MASK_POS)));
  515. }
  516. /**
  517. * @brief Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
  518. * @note Warning: only one pin can be passed as parameter.
  519. * @rmtoll ODR ODR LL_GPIO_GetPinPull
  520. * @param GPIOx GPIO Port
  521. * @param Pin This parameter can be one of the following values:
  522. * @arg @ref LL_GPIO_PIN_0
  523. * @arg @ref LL_GPIO_PIN_1
  524. * @arg @ref LL_GPIO_PIN_2
  525. * @arg @ref LL_GPIO_PIN_3
  526. * @arg @ref LL_GPIO_PIN_4
  527. * @arg @ref LL_GPIO_PIN_5
  528. * @arg @ref LL_GPIO_PIN_6
  529. * @arg @ref LL_GPIO_PIN_7
  530. * @arg @ref LL_GPIO_PIN_8
  531. * @arg @ref LL_GPIO_PIN_9
  532. * @arg @ref LL_GPIO_PIN_10
  533. * @arg @ref LL_GPIO_PIN_11
  534. * @arg @ref LL_GPIO_PIN_12
  535. * @arg @ref LL_GPIO_PIN_13
  536. * @arg @ref LL_GPIO_PIN_14
  537. * @arg @ref LL_GPIO_PIN_15
  538. * @retval Returned value can be one of the following values:
  539. * @arg @ref LL_GPIO_PULL_DOWN
  540. * @arg @ref LL_GPIO_PULL_UP
  541. */
  542. __STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin)
  543. {
  544. return (READ_BIT(GPIOx->ODR, (GPIO_ODR_ODR0 << (POSITION_VAL(Pin >> GPIO_PIN_MASK_POS)))) >> (POSITION_VAL(Pin >> GPIO_PIN_MASK_POS)));
  545. }
  546. /**
  547. * @brief Lock configuration of several pins for a dedicated port.
  548. * @note When the lock sequence has been applied on a port bit, the
  549. * value of this port bit can no longer be modified until the
  550. * next reset.
  551. * @note Each lock bit freezes a specific configuration register
  552. * (control and alternate function registers).
  553. * @rmtoll LCKR LCKK LL_GPIO_LockPin
  554. * @param GPIOx GPIO Port
  555. * @param PinMask This parameter can be a combination of the following values:
  556. * @arg @ref LL_GPIO_PIN_0
  557. * @arg @ref LL_GPIO_PIN_1
  558. * @arg @ref LL_GPIO_PIN_2
  559. * @arg @ref LL_GPIO_PIN_3
  560. * @arg @ref LL_GPIO_PIN_4
  561. * @arg @ref LL_GPIO_PIN_5
  562. * @arg @ref LL_GPIO_PIN_6
  563. * @arg @ref LL_GPIO_PIN_7
  564. * @arg @ref LL_GPIO_PIN_8
  565. * @arg @ref LL_GPIO_PIN_9
  566. * @arg @ref LL_GPIO_PIN_10
  567. * @arg @ref LL_GPIO_PIN_11
  568. * @arg @ref LL_GPIO_PIN_12
  569. * @arg @ref LL_GPIO_PIN_13
  570. * @arg @ref LL_GPIO_PIN_14
  571. * @arg @ref LL_GPIO_PIN_15
  572. * @arg @ref LL_GPIO_PIN_ALL
  573. * @retval None
  574. */
  575. __STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  576. {
  577. __IO uint32_t temp;
  578. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  579. WRITE_REG(GPIOx->LCKR, ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  580. WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  581. temp = READ_REG(GPIOx->LCKR);
  582. (void) temp;
  583. }
  584. /**
  585. * @brief Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
  586. * @rmtoll LCKR LCKy LL_GPIO_IsPinLocked
  587. * @param GPIOx GPIO Port
  588. * @param PinMask This parameter can be a combination of the following values:
  589. * @arg @ref LL_GPIO_PIN_0
  590. * @arg @ref LL_GPIO_PIN_1
  591. * @arg @ref LL_GPIO_PIN_2
  592. * @arg @ref LL_GPIO_PIN_3
  593. * @arg @ref LL_GPIO_PIN_4
  594. * @arg @ref LL_GPIO_PIN_5
  595. * @arg @ref LL_GPIO_PIN_6
  596. * @arg @ref LL_GPIO_PIN_7
  597. * @arg @ref LL_GPIO_PIN_8
  598. * @arg @ref LL_GPIO_PIN_9
  599. * @arg @ref LL_GPIO_PIN_10
  600. * @arg @ref LL_GPIO_PIN_11
  601. * @arg @ref LL_GPIO_PIN_12
  602. * @arg @ref LL_GPIO_PIN_13
  603. * @arg @ref LL_GPIO_PIN_14
  604. * @arg @ref LL_GPIO_PIN_15
  605. * @arg @ref LL_GPIO_PIN_ALL
  606. * @retval State of bit (1 or 0).
  607. */
  608. __STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  609. {
  610. return (READ_BIT(GPIOx->LCKR, ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU)) == ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  611. }
  612. /**
  613. * @brief Return 1 if one of the pin of a dedicated port is locked. else return 0.
  614. * @rmtoll LCKR LCKK LL_GPIO_IsAnyPinLocked
  615. * @param GPIOx GPIO Port
  616. * @retval State of bit (1 or 0).
  617. */
  618. __STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx)
  619. {
  620. return (READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK));
  621. }
  622. /**
  623. * @}
  624. */
  625. /** @defgroup GPIO_LL_EF_Data_Access Data Access
  626. * @{
  627. */
  628. /**
  629. * @brief Return full input data register value for a dedicated port.
  630. * @rmtoll IDR IDy LL_GPIO_ReadInputPort
  631. * @param GPIOx GPIO Port
  632. * @retval Input data register value of port
  633. */
  634. __STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx)
  635. {
  636. return (READ_REG(GPIOx->IDR));
  637. }
  638. /**
  639. * @brief Return if input data level for several pins of dedicated port is high or low.
  640. * @rmtoll IDR IDy LL_GPIO_IsInputPinSet
  641. * @param GPIOx GPIO Port
  642. * @param PinMask This parameter can be a combination of the following values:
  643. * @arg @ref LL_GPIO_PIN_0
  644. * @arg @ref LL_GPIO_PIN_1
  645. * @arg @ref LL_GPIO_PIN_2
  646. * @arg @ref LL_GPIO_PIN_3
  647. * @arg @ref LL_GPIO_PIN_4
  648. * @arg @ref LL_GPIO_PIN_5
  649. * @arg @ref LL_GPIO_PIN_6
  650. * @arg @ref LL_GPIO_PIN_7
  651. * @arg @ref LL_GPIO_PIN_8
  652. * @arg @ref LL_GPIO_PIN_9
  653. * @arg @ref LL_GPIO_PIN_10
  654. * @arg @ref LL_GPIO_PIN_11
  655. * @arg @ref LL_GPIO_PIN_12
  656. * @arg @ref LL_GPIO_PIN_13
  657. * @arg @ref LL_GPIO_PIN_14
  658. * @arg @ref LL_GPIO_PIN_15
  659. * @arg @ref LL_GPIO_PIN_ALL
  660. * @retval State of bit (1 or 0).
  661. */
  662. __STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  663. {
  664. return (READ_BIT(GPIOx->IDR, (PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU) == ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  665. }
  666. /**
  667. * @brief Write output data register for the port.
  668. * @rmtoll ODR ODy LL_GPIO_WriteOutputPort
  669. * @param GPIOx GPIO Port
  670. * @param PortValue Level value for each pin of the port
  671. * @retval None
  672. */
  673. __STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
  674. {
  675. WRITE_REG(GPIOx->ODR, PortValue);
  676. }
  677. /**
  678. * @brief Return full output data register value for a dedicated port.
  679. * @rmtoll ODR ODy LL_GPIO_ReadOutputPort
  680. * @param GPIOx GPIO Port
  681. * @retval Output data register value of port
  682. */
  683. __STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx)
  684. {
  685. return (uint32_t)(READ_REG(GPIOx->ODR));
  686. }
  687. /**
  688. * @brief Return if input data level for several pins of dedicated port is high or low.
  689. * @rmtoll ODR ODy LL_GPIO_IsOutputPinSet
  690. * @param GPIOx GPIO Port
  691. * @param PinMask This parameter can be a combination of the following values:
  692. * @arg @ref LL_GPIO_PIN_0
  693. * @arg @ref LL_GPIO_PIN_1
  694. * @arg @ref LL_GPIO_PIN_2
  695. * @arg @ref LL_GPIO_PIN_3
  696. * @arg @ref LL_GPIO_PIN_4
  697. * @arg @ref LL_GPIO_PIN_5
  698. * @arg @ref LL_GPIO_PIN_6
  699. * @arg @ref LL_GPIO_PIN_7
  700. * @arg @ref LL_GPIO_PIN_8
  701. * @arg @ref LL_GPIO_PIN_9
  702. * @arg @ref LL_GPIO_PIN_10
  703. * @arg @ref LL_GPIO_PIN_11
  704. * @arg @ref LL_GPIO_PIN_12
  705. * @arg @ref LL_GPIO_PIN_13
  706. * @arg @ref LL_GPIO_PIN_14
  707. * @arg @ref LL_GPIO_PIN_15
  708. * @arg @ref LL_GPIO_PIN_ALL
  709. * @retval State of bit (1 or 0).
  710. */
  711. __STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  712. {
  713. return (READ_BIT(GPIOx->ODR, (PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU) == ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  714. }
  715. /**
  716. * @brief Set several pins to high level on dedicated gpio port.
  717. * @rmtoll BSRR BSy LL_GPIO_SetOutputPin
  718. * @param GPIOx GPIO Port
  719. * @param PinMask This parameter can be a combination of the following values:
  720. * @arg @ref LL_GPIO_PIN_0
  721. * @arg @ref LL_GPIO_PIN_1
  722. * @arg @ref LL_GPIO_PIN_2
  723. * @arg @ref LL_GPIO_PIN_3
  724. * @arg @ref LL_GPIO_PIN_4
  725. * @arg @ref LL_GPIO_PIN_5
  726. * @arg @ref LL_GPIO_PIN_6
  727. * @arg @ref LL_GPIO_PIN_7
  728. * @arg @ref LL_GPIO_PIN_8
  729. * @arg @ref LL_GPIO_PIN_9
  730. * @arg @ref LL_GPIO_PIN_10
  731. * @arg @ref LL_GPIO_PIN_11
  732. * @arg @ref LL_GPIO_PIN_12
  733. * @arg @ref LL_GPIO_PIN_13
  734. * @arg @ref LL_GPIO_PIN_14
  735. * @arg @ref LL_GPIO_PIN_15
  736. * @arg @ref LL_GPIO_PIN_ALL
  737. * @retval None
  738. */
  739. __STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  740. {
  741. WRITE_REG(GPIOx->BSRR, (PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU);
  742. }
  743. /**
  744. * @brief Set several pins to low level on dedicated gpio port.
  745. * @rmtoll BRR BRy LL_GPIO_ResetOutputPin
  746. * @param GPIOx GPIO Port
  747. * @param PinMask This parameter can be a combination of the following values:
  748. * @arg @ref LL_GPIO_PIN_0
  749. * @arg @ref LL_GPIO_PIN_1
  750. * @arg @ref LL_GPIO_PIN_2
  751. * @arg @ref LL_GPIO_PIN_3
  752. * @arg @ref LL_GPIO_PIN_4
  753. * @arg @ref LL_GPIO_PIN_5
  754. * @arg @ref LL_GPIO_PIN_6
  755. * @arg @ref LL_GPIO_PIN_7
  756. * @arg @ref LL_GPIO_PIN_8
  757. * @arg @ref LL_GPIO_PIN_9
  758. * @arg @ref LL_GPIO_PIN_10
  759. * @arg @ref LL_GPIO_PIN_11
  760. * @arg @ref LL_GPIO_PIN_12
  761. * @arg @ref LL_GPIO_PIN_13
  762. * @arg @ref LL_GPIO_PIN_14
  763. * @arg @ref LL_GPIO_PIN_15
  764. * @arg @ref LL_GPIO_PIN_ALL
  765. * @retval None
  766. */
  767. __STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  768. {
  769. WRITE_REG(GPIOx->BRR, (PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU);
  770. }
  771. /**
  772. * @brief Toggle data value for several pin of dedicated port.
  773. * @rmtoll ODR ODy LL_GPIO_TogglePin
  774. * @param GPIOx GPIO Port
  775. * @param PinMask This parameter can be a combination of the following values:
  776. * @arg @ref LL_GPIO_PIN_0
  777. * @arg @ref LL_GPIO_PIN_1
  778. * @arg @ref LL_GPIO_PIN_2
  779. * @arg @ref LL_GPIO_PIN_3
  780. * @arg @ref LL_GPIO_PIN_4
  781. * @arg @ref LL_GPIO_PIN_5
  782. * @arg @ref LL_GPIO_PIN_6
  783. * @arg @ref LL_GPIO_PIN_7
  784. * @arg @ref LL_GPIO_PIN_8
  785. * @arg @ref LL_GPIO_PIN_9
  786. * @arg @ref LL_GPIO_PIN_10
  787. * @arg @ref LL_GPIO_PIN_11
  788. * @arg @ref LL_GPIO_PIN_12
  789. * @arg @ref LL_GPIO_PIN_13
  790. * @arg @ref LL_GPIO_PIN_14
  791. * @arg @ref LL_GPIO_PIN_15
  792. * @arg @ref LL_GPIO_PIN_ALL
  793. * @retval None
  794. */
  795. __STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
  796. {
  797. WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU));
  798. }
  799. /**
  800. * @}
  801. */
  802. /** @defgroup GPIO_AF_REMAPPING Alternate Function Remapping
  803. * @brief This section propose definition to remap the alternate function to some other port/pins.
  804. * @{
  805. */
  806. /**
  807. * @brief Enable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
  808. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_EnableRemap_SPI1
  809. * @note ENABLE: Remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5)
  810. * @retval None
  811. */
  812. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SPI1(void)
  813. {
  814. SET_BIT(AFIO->MAPR, AFIO_MAPR_SPI1_REMAP | AFIO_MAPR_SWJ_CFG);
  815. }
  816. /**
  817. * @brief Disable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
  818. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_DisableRemap_SPI1
  819. * @note DISABLE: No remap (NSS/PA4, SCK/PA5, MISO/PA6, MOSI/PA7)
  820. * @retval None
  821. */
  822. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SPI1(void)
  823. {
  824. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_SPI1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  825. }
  826. /**
  827. * @brief Check if SPI1 has been remaped or not
  828. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_IsEnabledRemap_SPI1
  829. * @retval State of bit (1 or 0).
  830. */
  831. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_SPI1(void)
  832. {
  833. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_SPI1_REMAP) == (AFIO_MAPR_SPI1_REMAP));
  834. }
  835. /**
  836. * @brief Enable the remapping of I2C1 alternate function SCL and SDA.
  837. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_EnableRemap_I2C1
  838. * @note ENABLE: Remap (SCL/PB8, SDA/PB9)
  839. * @retval None
  840. */
  841. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_I2C1(void)
  842. {
  843. SET_BIT(AFIO->MAPR, AFIO_MAPR_I2C1_REMAP | AFIO_MAPR_SWJ_CFG);
  844. }
  845. /**
  846. * @brief Disable the remapping of I2C1 alternate function SCL and SDA.
  847. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_DisableRemap_I2C1
  848. * @note DISABLE: No remap (SCL/PB6, SDA/PB7)
  849. * @retval None
  850. */
  851. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_I2C1(void)
  852. {
  853. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_I2C1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  854. }
  855. /**
  856. * @brief Check if I2C1 has been remaped or not
  857. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_IsEnabledRemap_I2C1
  858. * @retval State of bit (1 or 0).
  859. */
  860. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_I2C1(void)
  861. {
  862. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_I2C1_REMAP) == (AFIO_MAPR_I2C1_REMAP));
  863. }
  864. /**
  865. * @brief Enable the remapping of USART1 alternate function TX and RX.
  866. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_EnableRemap_USART1
  867. * @note ENABLE: Remap (TX/PB6, RX/PB7)
  868. * @retval None
  869. */
  870. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART1(void)
  871. {
  872. SET_BIT(AFIO->MAPR, AFIO_MAPR_USART1_REMAP | AFIO_MAPR_SWJ_CFG);
  873. }
  874. /**
  875. * @brief Disable the remapping of USART1 alternate function TX and RX.
  876. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_DisableRemap_USART1
  877. * @note DISABLE: No remap (TX/PA9, RX/PA10)
  878. * @retval None
  879. */
  880. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART1(void)
  881. {
  882. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  883. }
  884. /**
  885. * @brief Check if USART1 has been remaped or not
  886. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_IsEnabledRemap_USART1
  887. * @retval State of bit (1 or 0).
  888. */
  889. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_USART1(void)
  890. {
  891. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_USART1_REMAP) == (AFIO_MAPR_USART1_REMAP));
  892. }
  893. /**
  894. * @brief Enable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
  895. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_EnableRemap_USART2
  896. * @note ENABLE: Remap (CTS/PD3, RTS/PD4, TX/PD5, RX/PD6, CK/PD7)
  897. * @retval None
  898. */
  899. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART2(void)
  900. {
  901. SET_BIT(AFIO->MAPR, AFIO_MAPR_USART2_REMAP | AFIO_MAPR_SWJ_CFG);
  902. }
  903. /**
  904. * @brief Disable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
  905. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_DisableRemap_USART2
  906. * @note DISABLE: No remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4)
  907. * @retval None
  908. */
  909. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART2(void)
  910. {
  911. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART2_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  912. }
  913. /**
  914. * @brief Check if USART2 has been remaped or not
  915. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_IsEnabledRemap_USART2
  916. * @retval State of bit (1 or 0).
  917. */
  918. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_USART2(void)
  919. {
  920. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_USART2_REMAP) == (AFIO_MAPR_USART2_REMAP));
  921. }
  922. #if defined (AFIO_MAPR_USART3_REMAP)
  923. /**
  924. * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  925. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_EnableRemap_USART3
  926. * @note ENABLE: Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12)
  927. * @retval None
  928. */
  929. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART3(void)
  930. {
  931. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  932. }
  933. /**
  934. * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  935. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_RemapPartial_USART3
  936. * @note PARTIAL: Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14)
  937. * @retval None
  938. */
  939. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_USART3(void)
  940. {
  941. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  942. }
  943. /**
  944. * @brief Disable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  945. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_DisableRemap_USART3
  946. * @note DISABLE: No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14)
  947. * @retval None
  948. */
  949. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART3(void)
  950. {
  951. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  952. }
  953. #endif
  954. /**
  955. * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  956. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_EnableRemap_TIM1
  957. * @note ENABLE: Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12)
  958. * @retval None
  959. */
  960. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM1(void)
  961. {
  962. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  963. }
  964. /**
  965. * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  966. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_RemapPartial_TIM1
  967. * @note PARTIAL: Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1)
  968. * @retval None
  969. */
  970. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_TIM1(void)
  971. {
  972. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  973. }
  974. /**
  975. * @brief Disable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  976. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_DisableRemap_TIM1
  977. * @note DISABLE: No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15)
  978. * @retval None
  979. */
  980. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM1(void)
  981. {
  982. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  983. }
  984. /**
  985. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  986. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_EnableRemap_TIM2
  987. * @note ENABLE: Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11)
  988. * @retval None
  989. */
  990. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM2(void)
  991. {
  992. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  993. }
  994. /**
  995. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  996. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_RemapPartial2_TIM2
  997. * @note PARTIAL_2: Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11)
  998. * @retval None
  999. */
  1000. __STATIC_INLINE void LL_GPIO_AF_RemapPartial2_TIM2(void)
  1001. {
  1002. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2 | AFIO_MAPR_SWJ_CFG));
  1003. }
  1004. /**
  1005. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  1006. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_RemapPartial1_TIM2
  1007. * @note PARTIAL_1: Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3)
  1008. * @retval None
  1009. */
  1010. __STATIC_INLINE void LL_GPIO_AF_RemapPartial1_TIM2(void)
  1011. {
  1012. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1 | AFIO_MAPR_SWJ_CFG));
  1013. }
  1014. /**
  1015. * @brief Disable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  1016. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_DisableRemap_TIM2
  1017. * @note DISABLE: No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3)
  1018. * @retval None
  1019. */
  1020. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM2(void)
  1021. {
  1022. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  1023. }
  1024. /**
  1025. * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
  1026. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_EnableRemap_TIM3
  1027. * @note ENABLE: Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9)
  1028. * @note TIM3_ETR on PE0 is not re-mapped.
  1029. * @retval None
  1030. */
  1031. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM3(void)
  1032. {
  1033. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  1034. }
  1035. /**
  1036. * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
  1037. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_RemapPartial_TIM3
  1038. * @note PARTIAL: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1)
  1039. * @note TIM3_ETR on PE0 is not re-mapped.
  1040. * @retval None
  1041. */
  1042. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_TIM3(void)
  1043. {
  1044. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  1045. }
  1046. /**
  1047. * @brief Disable the remapping of TIM3 alternate function channels 1 to 4
  1048. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_DisableRemap_TIM3
  1049. * @note DISABLE: No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1)
  1050. * @note TIM3_ETR on PE0 is not re-mapped.
  1051. * @retval None
  1052. */
  1053. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM3(void)
  1054. {
  1055. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  1056. }
  1057. #if defined(AFIO_MAPR_TIM4_REMAP)
  1058. /**
  1059. * @brief Enable the remapping of TIM4 alternate function channels 1 to 4.
  1060. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_EnableRemap_TIM4
  1061. * @note ENABLE: Full remap (TIM4_CH1/PD12, TIM4_CH2/PD13, TIM4_CH3/PD14, TIM4_CH4/PD15)
  1062. * @note TIM4_ETR on PE0 is not re-mapped.
  1063. * @retval None
  1064. */
  1065. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM4(void)
  1066. {
  1067. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM4_REMAP | AFIO_MAPR_SWJ_CFG);
  1068. }
  1069. /**
  1070. * @brief Disable the remapping of TIM4 alternate function channels 1 to 4.
  1071. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_DisableRemap_TIM4
  1072. * @note DISABLE: No remap (TIM4_CH1/PB6, TIM4_CH2/PB7, TIM4_CH3/PB8, TIM4_CH4/PB9)
  1073. * @note TIM4_ETR on PE0 is not re-mapped.
  1074. * @retval None
  1075. */
  1076. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM4(void)
  1077. {
  1078. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM4_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1079. }
  1080. /**
  1081. * @brief Check if TIM4 has been remaped or not
  1082. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_IsEnabledRemap_TIM4
  1083. * @retval State of bit (1 or 0).
  1084. */
  1085. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM4(void)
  1086. {
  1087. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_TIM4_REMAP) == (AFIO_MAPR_TIM4_REMAP));
  1088. }
  1089. #endif
  1090. #if defined(AFIO_MAPR_CAN_REMAP_REMAP1)
  1091. /**
  1092. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1093. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial1_CAN1
  1094. * @note CASE 1: CAN_RX mapped to PA11, CAN_TX mapped to PA12
  1095. * @retval None
  1096. */
  1097. __STATIC_INLINE void LL_GPIO_AF_RemapPartial1_CAN1(void)
  1098. {
  1099. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP1 | AFIO_MAPR_SWJ_CFG));
  1100. }
  1101. /**
  1102. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1103. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial2_CAN1
  1104. * @note CASE 2: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (not available on 36-pin package)
  1105. * @retval None
  1106. */
  1107. __STATIC_INLINE void LL_GPIO_AF_RemapPartial2_CAN1(void)
  1108. {
  1109. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP2 | AFIO_MAPR_SWJ_CFG));
  1110. }
  1111. /**
  1112. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1113. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial3_CAN1
  1114. * @note CASE 3: CAN_RX mapped to PD0, CAN_TX mapped to PD1
  1115. * @retval None
  1116. */
  1117. __STATIC_INLINE void LL_GPIO_AF_RemapPartial3_CAN1(void)
  1118. {
  1119. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP3 | AFIO_MAPR_SWJ_CFG));
  1120. }
  1121. #endif
  1122. /**
  1123. * @brief Enable the remapping of PD0 and PD1. When the HSE oscillator is not used
  1124. * (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
  1125. * OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
  1126. * on 100-pin and 144-pin packages, no need for remapping).
  1127. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_EnableRemap_PD01
  1128. * @note ENABLE: PD0 remapped on OSC_IN, PD1 remapped on OSC_OUT.
  1129. * @retval None
  1130. */
  1131. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_PD01(void)
  1132. {
  1133. SET_BIT(AFIO->MAPR, AFIO_MAPR_PD01_REMAP | AFIO_MAPR_SWJ_CFG);
  1134. }
  1135. /**
  1136. * @brief Disable the remapping of PD0 and PD1. When the HSE oscillator is not used
  1137. * (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
  1138. * OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
  1139. * on 100-pin and 144-pin packages, no need for remapping).
  1140. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_DisableRemap_PD01
  1141. * @note DISABLE: No remapping of PD0 and PD1
  1142. * @retval None
  1143. */
  1144. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_PD01(void)
  1145. {
  1146. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_PD01_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1147. }
  1148. /**
  1149. * @brief Check if PD01 has been remaped or not
  1150. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_IsEnabledRemap_PD01
  1151. * @retval State of bit (1 or 0).
  1152. */
  1153. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_PD01(void)
  1154. {
  1155. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_PD01_REMAP) == (AFIO_MAPR_PD01_REMAP));
  1156. }
  1157. #if defined(AFIO_MAPR_TIM5CH4_IREMAP)
  1158. /**
  1159. * @brief Enable the remapping of TIM5CH4.
  1160. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_EnableRemap_TIM5CH4
  1161. * @note ENABLE: LSI internal clock is connected to TIM5_CH4 input for calibration purpose.
  1162. * @note This function is available only in high density value line devices.
  1163. * @retval None
  1164. */
  1165. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM5CH4(void)
  1166. {
  1167. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM5CH4_IREMAP | AFIO_MAPR_SWJ_CFG);
  1168. }
  1169. /**
  1170. * @brief Disable the remapping of TIM5CH4.
  1171. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_DisableRemap_TIM5CH4
  1172. * @note DISABLE: TIM5_CH4 is connected to PA3
  1173. * @note This function is available only in high density value line devices.
  1174. * @retval None
  1175. */
  1176. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM5CH4(void)
  1177. {
  1178. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM5CH4_IREMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1179. }
  1180. /**
  1181. * @brief Check if TIM5CH4 has been remaped or not
  1182. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_IsEnabledRemap_TIM5CH4
  1183. * @retval State of bit (1 or 0).
  1184. */
  1185. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM5CH4(void)
  1186. {
  1187. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_TIM5CH4_IREMAP) == (AFIO_MAPR_TIM5CH4_IREMAP));
  1188. }
  1189. #endif
  1190. #if defined(AFIO_MAPR_ETH_REMAP)
  1191. /**
  1192. * @brief Enable the remapping of Ethernet MAC connections with the PHY.
  1193. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_EnableRemap_ETH
  1194. * @note ENABLE: Remap (RX_DV-CRS_DV/PD8, RXD0/PD9, RXD1/PD10, RXD2/PD11, RXD3/PD12)
  1195. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1196. * @retval None
  1197. */
  1198. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ETH(void)
  1199. {
  1200. SET_BIT(AFIO->MAPR, AFIO_MAPR_ETH_REMAP | AFIO_MAPR_SWJ_CFG);
  1201. }
  1202. /**
  1203. * @brief Disable the remapping of Ethernet MAC connections with the PHY.
  1204. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_DisableRemap_ETH
  1205. * @note DISABLE: No remap (RX_DV-CRS_DV/PA7, RXD0/PC4, RXD1/PC5, RXD2/PB0, RXD3/PB1)
  1206. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1207. * @retval None
  1208. */
  1209. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ETH(void)
  1210. {
  1211. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ETH_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1212. }
  1213. /**
  1214. * @brief Check if ETH has been remaped or not
  1215. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_IsEnabledRemap_ETH
  1216. * @retval State of bit (1 or 0).
  1217. */
  1218. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ETH(void)
  1219. {
  1220. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ETH_REMAP) == (AFIO_MAPR_ETH_REMAP));
  1221. }
  1222. #endif
  1223. #if defined(AFIO_MAPR_CAN2_REMAP)
  1224. /**
  1225. * @brief Enable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
  1226. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_EnableRemap_CAN2
  1227. * @note ENABLE: Remap (CAN2_RX/PB5, CAN2_TX/PB6)
  1228. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1229. * @retval None
  1230. */
  1231. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_CAN2(void)
  1232. {
  1233. SET_BIT(AFIO->MAPR, AFIO_MAPR_CAN2_REMAP | AFIO_MAPR_SWJ_CFG);
  1234. }
  1235. /**
  1236. * @brief Disable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
  1237. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_DisableRemap_CAN2
  1238. * @note DISABLE: No remap (CAN2_RX/PB12, CAN2_TX/PB13)
  1239. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1240. * @retval None
  1241. */
  1242. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_CAN2(void)
  1243. {
  1244. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN2_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1245. }
  1246. /**
  1247. * @brief Check if CAN2 has been remaped or not
  1248. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_IsEnabledRemap_CAN2
  1249. * @retval State of bit (1 or 0).
  1250. */
  1251. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_CAN2(void)
  1252. {
  1253. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_CAN2_REMAP) == (AFIO_MAPR_CAN2_REMAP));
  1254. }
  1255. #endif
  1256. #if defined(AFIO_MAPR_MII_RMII_SEL)
  1257. /**
  1258. * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
  1259. * @rmtoll MAPR MII_RMII_SEL LL_GPIO_AF_Select_ETH_RMII
  1260. * @note ETH_RMII: Configure Ethernet MAC for connection with an RMII PHY
  1261. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1262. * @retval None
  1263. */
  1264. __STATIC_INLINE void LL_GPIO_AF_Select_ETH_RMII(void)
  1265. {
  1266. SET_BIT(AFIO->MAPR, AFIO_MAPR_MII_RMII_SEL | AFIO_MAPR_SWJ_CFG);
  1267. }
  1268. /**
  1269. * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
  1270. * @rmtoll MAPR MII_RMII_SEL LL_GPIO_AF_Select_ETH_MII
  1271. * @note ETH_MII: Configure Ethernet MAC for connection with an MII PHY
  1272. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1273. * @retval None
  1274. */
  1275. __STATIC_INLINE void LL_GPIO_AF_Select_ETH_MII(void)
  1276. {
  1277. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_MII_RMII_SEL | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1278. }
  1279. #endif
  1280. #if defined(AFIO_MAPR_ADC1_ETRGINJ_REMAP)
  1281. /**
  1282. * @brief Enable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
  1283. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_EnableRemap_ADC1_ETRGINJ
  1284. * @note ENABLE: ADC1 External Event injected conversion is connected to TIM8 Channel4.
  1285. * @retval None
  1286. */
  1287. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC1_ETRGINJ(void)
  1288. {
  1289. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG);
  1290. }
  1291. /**
  1292. * @brief Disable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
  1293. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_DisableRemap_ADC1_ETRGINJ
  1294. * @note DISABLE: ADC1 External trigger injected conversion is connected to EXTI15
  1295. * @retval None
  1296. */
  1297. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC1_ETRGINJ(void)
  1298. {
  1299. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC1_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1300. }
  1301. /**
  1302. * @brief Check if ADC1_ETRGINJ has been remaped or not
  1303. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGINJ
  1304. * @retval State of bit (1 or 0).
  1305. */
  1306. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGINJ(void)
  1307. {
  1308. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGINJ_REMAP) == (AFIO_MAPR_ADC1_ETRGINJ_REMAP));
  1309. }
  1310. #endif
  1311. #if defined(AFIO_MAPR_ADC1_ETRGREG_REMAP)
  1312. /**
  1313. * @brief Enable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
  1314. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_EnableRemap_ADC1_ETRGREG
  1315. * @note ENABLE: ADC1 External Event regular conversion is connected to TIM8 TRG0.
  1316. * @retval None
  1317. */
  1318. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC1_ETRGREG(void)
  1319. {
  1320. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG);
  1321. }
  1322. /**
  1323. * @brief Disable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
  1324. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_DisableRemap_ADC1_ETRGREG
  1325. * @note DISABLE: ADC1 External trigger regular conversion is connected to EXTI11
  1326. * @retval None
  1327. */
  1328. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC1_ETRGREG(void)
  1329. {
  1330. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC1_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1331. }
  1332. /**
  1333. * @brief Check if ADC1_ETRGREG has been remaped or not
  1334. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGREG
  1335. * @retval State of bit (1 or 0).
  1336. */
  1337. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGREG(void)
  1338. {
  1339. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGREG_REMAP) == (AFIO_MAPR_ADC1_ETRGREG_REMAP));
  1340. }
  1341. #endif
  1342. #if defined(AFIO_MAPR_ADC2_ETRGINJ_REMAP)
  1343. /**
  1344. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
  1345. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_EnableRemap_ADC2_ETRGINJ
  1346. * @note ENABLE: ADC2 External Event injected conversion is connected to TIM8 Channel4.
  1347. * @retval None
  1348. */
  1349. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC2_ETRGINJ(void)
  1350. {
  1351. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG);
  1352. }
  1353. /**
  1354. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
  1355. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_DisableRemap_ADC2_ETRGINJ
  1356. * @note DISABLE: ADC2 External trigger injected conversion is connected to EXTI15
  1357. * @retval None
  1358. */
  1359. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC2_ETRGINJ(void)
  1360. {
  1361. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC2_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1362. }
  1363. /**
  1364. * @brief Check if ADC2_ETRGINJ has been remaped or not
  1365. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGINJ
  1366. * @retval State of bit (1 or 0).
  1367. */
  1368. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGINJ(void)
  1369. {
  1370. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGINJ_REMAP) == (AFIO_MAPR_ADC2_ETRGINJ_REMAP));
  1371. }
  1372. #endif
  1373. #if defined (AFIO_MAPR_ADC2_ETRGREG_REMAP)
  1374. /**
  1375. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1376. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_EnableRemap_ADC2_ETRGREG
  1377. * @note ENABLE: ADC2 External Event regular conversion is connected to TIM8 TRG0.
  1378. * @retval None
  1379. */
  1380. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC2_ETRGREG(void)
  1381. {
  1382. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG);
  1383. }
  1384. /**
  1385. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1386. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_DisableRemap_ADC2_ETRGREG
  1387. * @note DISABLE: ADC2 External trigger regular conversion is connected to EXTI11
  1388. * @retval None
  1389. */
  1390. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC2_ETRGREG(void)
  1391. {
  1392. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC2_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1393. }
  1394. /**
  1395. * @brief Check if ADC2_ETRGREG has been remaped or not
  1396. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGREG
  1397. * @retval State of bit (1 or 0).
  1398. */
  1399. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGREG(void)
  1400. {
  1401. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGREG_REMAP) == (AFIO_MAPR_ADC2_ETRGREG_REMAP));
  1402. }
  1403. #endif
  1404. /**
  1405. * @brief Enable the Serial wire JTAG configuration
  1406. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_EnableRemap_SWJ
  1407. * @note ENABLE: Full SWJ (JTAG-DP + SW-DP): Reset State
  1408. * @retval None
  1409. */
  1410. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SWJ(void)
  1411. {
  1412. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1413. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_RESET);
  1414. }
  1415. /**
  1416. * @brief Enable the Serial wire JTAG configuration
  1417. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_Remap_SWJ_NONJTRST
  1418. * @note NONJTRST: Full SWJ (JTAG-DP + SW-DP) but without NJTRST
  1419. * @retval None
  1420. */
  1421. __STATIC_INLINE void LL_GPIO_AF_Remap_SWJ_NONJTRST(void)
  1422. {
  1423. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1424. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_NOJNTRST);
  1425. }
  1426. /**
  1427. * @brief Enable the Serial wire JTAG configuration
  1428. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_Remap_SWJ_NOJTAG
  1429. * @note NOJTAG: JTAG-DP Disabled and SW-DP Enabled
  1430. * @retval None
  1431. */
  1432. __STATIC_INLINE void LL_GPIO_AF_Remap_SWJ_NOJTAG(void)
  1433. {
  1434. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1435. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_JTAGDISABLE);
  1436. }
  1437. /**
  1438. * @brief Disable the Serial wire JTAG configuration
  1439. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_DisableRemap_SWJ
  1440. * @note DISABLE: JTAG-DP Disabled and SW-DP Disabled
  1441. * @retval None
  1442. */
  1443. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SWJ(void)
  1444. {
  1445. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1446. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_DISABLE);
  1447. }
  1448. #if defined(AFIO_MAPR_SPI3_REMAP)
  1449. /**
  1450. * @brief Enable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
  1451. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_EnableRemap_SPI3
  1452. * @note ENABLE: Remap (SPI3_NSS-I2S3_WS/PA4, SPI3_SCK-I2S3_CK/PC10, SPI3_MISO/PC11, SPI3_MOSI-I2S3_SD/PC12)
  1453. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1454. * @retval None
  1455. */
  1456. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SPI3(void)
  1457. {
  1458. SET_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP | AFIO_MAPR_SWJ_CFG);
  1459. }
  1460. /**
  1461. * @brief Disable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
  1462. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_DisableRemap_SPI3
  1463. * @note DISABLE: No remap (SPI3_NSS-I2S3_WS/PA15, SPI3_SCK-I2S3_CK/PB3, SPI3_MISO/PB4, SPI3_MOSI-I2S3_SD/PB5).
  1464. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1465. * @retval None
  1466. */
  1467. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SPI3(void)
  1468. {
  1469. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_SPI3_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1470. }
  1471. /**
  1472. * @brief Check if SPI3 has been remaped or not
  1473. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_IsEnabledRemap_SPI3_REMAP
  1474. * @retval State of bit (1 or 0).
  1475. */
  1476. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_SPI3(void)
  1477. {
  1478. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP) == (AFIO_MAPR_SPI3_REMAP));
  1479. }
  1480. #endif
  1481. #if defined(AFIO_MAPR_TIM2ITR1_IREMAP)
  1482. /**
  1483. * @brief Control of TIM2_ITR1 internal mapping.
  1484. * @rmtoll MAPR TIM2ITR1_IREMAP LL_GPIO_AF_Remap_TIM2ITR1_TO_USB
  1485. * @note TO_USB: Connect USB OTG SOF (Start of Frame) output to TIM2_ITR1 for calibration purposes.
  1486. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1487. * @retval None
  1488. */
  1489. __STATIC_INLINE void LL_GPIO_AF_Remap_TIM2ITR1_TO_USB(void)
  1490. {
  1491. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM2ITR1_IREMAP | AFIO_MAPR_SWJ_CFG);
  1492. }
  1493. /**
  1494. * @brief Control of TIM2_ITR1 internal mapping.
  1495. * @rmtoll MAPR TIM2ITR1_IREMAP LL_GPIO_AF_Remap_TIM2ITR1_TO_ETH
  1496. * @note TO_ETH: Connect TIM2_ITR1 internally to the Ethernet PTP output for calibration purposes.
  1497. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1498. * @retval None
  1499. */
  1500. __STATIC_INLINE void LL_GPIO_AF_Remap_TIM2ITR1_TO_ETH(void)
  1501. {
  1502. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2ITR1_IREMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1503. }
  1504. #endif
  1505. #if defined(AFIO_MAPR_PTP_PPS_REMAP)
  1506. /**
  1507. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1508. * @rmtoll MAPR PTP_PPS_REMAP LL_GPIO_AF_EnableRemap_ETH_PTP_PPS
  1509. * @note ENABLE: PTP_PPS is output on PB5 pin.
  1510. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1511. * @retval None
  1512. */
  1513. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ETH_PTP_PPS(void)
  1514. {
  1515. SET_BIT(AFIO->MAPR, AFIO_MAPR_PTP_PPS_REMAP | AFIO_MAPR_SWJ_CFG);
  1516. }
  1517. /**
  1518. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1519. * @rmtoll MAPR PTP_PPS_REMAP LL_GPIO_AF_DisableRemap_ETH_PTP_PPS
  1520. * @note DISABLE: PTP_PPS not output on PB5 pin.
  1521. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1522. * @retval None
  1523. */
  1524. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ETH_PTP_PPS(void)
  1525. {
  1526. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_PTP_PPS_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1527. }
  1528. #endif
  1529. #if defined(AFIO_MAPR2_TIM9_REMAP)
  1530. /**
  1531. * @brief Enable the remapping of TIM9_CH1 and TIM9_CH2.
  1532. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_EnableRemap_TIM9
  1533. * @note ENABLE: Remap (TIM9_CH1 on PE5 and TIM9_CH2 on PE6).
  1534. * @retval None
  1535. */
  1536. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM9(void)
  1537. {
  1538. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP);
  1539. }
  1540. /**
  1541. * @brief Disable the remapping of TIM9_CH1 and TIM9_CH2.
  1542. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_DisableRemap_TIM9
  1543. * @note DISABLE: No remap (TIM9_CH1 on PA2 and TIM9_CH2 on PA3).
  1544. * @retval None
  1545. */
  1546. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM9(void)
  1547. {
  1548. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP);
  1549. }
  1550. /**
  1551. * @brief Check if TIM9_CH1 and TIM9_CH2 have been remaped or not
  1552. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_IsEnabledRemap_TIM9
  1553. * @retval State of bit (1 or 0).
  1554. */
  1555. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM9(void)
  1556. {
  1557. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP) == (AFIO_MAPR2_TIM9_REMAP));
  1558. }
  1559. #endif
  1560. #if defined(AFIO_MAPR2_TIM10_REMAP)
  1561. /**
  1562. * @brief Enable the remapping of TIM10_CH1.
  1563. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_EnableRemap_TIM10
  1564. * @note ENABLE: Remap (TIM10_CH1 on PF6).
  1565. * @retval None
  1566. */
  1567. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM10(void)
  1568. {
  1569. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP);
  1570. }
  1571. /**
  1572. * @brief Disable the remapping of TIM10_CH1.
  1573. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_DisableRemap_TIM10
  1574. * @note DISABLE: No remap (TIM10_CH1 on PB8).
  1575. * @retval None
  1576. */
  1577. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM10(void)
  1578. {
  1579. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP);
  1580. }
  1581. /**
  1582. * @brief Check if TIM10_CH1 has been remaped or not
  1583. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_IsEnabledRemap_TIM10
  1584. * @retval State of bit (1 or 0).
  1585. */
  1586. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM10(void)
  1587. {
  1588. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP) == (AFIO_MAPR2_TIM10_REMAP));
  1589. }
  1590. #endif
  1591. #if defined(AFIO_MAPR2_TIM11_REMAP)
  1592. /**
  1593. * @brief Enable the remapping of TIM11_CH1.
  1594. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_EnableRemap_TIM11
  1595. * @note ENABLE: Remap (TIM11_CH1 on PF7).
  1596. * @retval None
  1597. */
  1598. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM11(void)
  1599. {
  1600. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP);
  1601. }
  1602. /**
  1603. * @brief Disable the remapping of TIM11_CH1.
  1604. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_DisableRemap_TIM11
  1605. * @note DISABLE: No remap (TIM11_CH1 on PB9).
  1606. * @retval None
  1607. */
  1608. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM11(void)
  1609. {
  1610. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP);
  1611. }
  1612. /**
  1613. * @brief Check if TIM11_CH1 has been remaped or not
  1614. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_IsEnabledRemap_TIM11
  1615. * @retval State of bit (1 or 0).
  1616. */
  1617. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM11(void)
  1618. {
  1619. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP) == (AFIO_MAPR2_TIM11_REMAP));
  1620. }
  1621. #endif
  1622. #if defined(AFIO_MAPR2_TIM13_REMAP)
  1623. /**
  1624. * @brief Enable the remapping of TIM13_CH1.
  1625. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_EnableRemap_TIM13
  1626. * @note ENABLE: Remap STM32F100:(TIM13_CH1 on PF8). Others:(TIM13_CH1 on PB0).
  1627. * @retval None
  1628. */
  1629. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM13(void)
  1630. {
  1631. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP);
  1632. }
  1633. /**
  1634. * @brief Disable the remapping of TIM13_CH1.
  1635. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_DisableRemap_TIM13
  1636. * @note DISABLE: No remap STM32F100:(TIM13_CH1 on PA6). Others:(TIM13_CH1 on PC8).
  1637. * @retval None
  1638. */
  1639. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM13(void)
  1640. {
  1641. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP);
  1642. }
  1643. /**
  1644. * @brief Check if TIM13_CH1 has been remaped or not
  1645. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_IsEnabledRemap_TIM13
  1646. * @retval State of bit (1 or 0).
  1647. */
  1648. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM13(void)
  1649. {
  1650. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP) == (AFIO_MAPR2_TIM13_REMAP));
  1651. }
  1652. #endif
  1653. #if defined(AFIO_MAPR2_TIM14_REMAP)
  1654. /**
  1655. * @brief Enable the remapping of TIM14_CH1.
  1656. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_EnableRemap_TIM14
  1657. * @note ENABLE: Remap STM32F100:(TIM14_CH1 on PB1). Others:(TIM14_CH1 on PF9).
  1658. * @retval None
  1659. */
  1660. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM14(void)
  1661. {
  1662. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP);
  1663. }
  1664. /**
  1665. * @brief Disable the remapping of TIM14_CH1.
  1666. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_DisableRemap_TIM14
  1667. * @note DISABLE: No remap STM32F100:(TIM14_CH1 on PC9). Others:(TIM14_CH1 on PA7).
  1668. * @retval None
  1669. */
  1670. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM14(void)
  1671. {
  1672. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP);
  1673. }
  1674. /**
  1675. * @brief Check if TIM14_CH1 has been remaped or not
  1676. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_IsEnabledRemap_TIM14
  1677. * @retval State of bit (1 or 0).
  1678. */
  1679. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM14(void)
  1680. {
  1681. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP) == (AFIO_MAPR2_TIM14_REMAP));
  1682. }
  1683. #endif
  1684. #if defined(AFIO_MAPR2_FSMC_NADV_REMAP)
  1685. /**
  1686. * @brief Controls the use of the optional FSMC_NADV signal.
  1687. * @rmtoll MAPR2 FSMC_NADV LL_GPIO_AF_Disconnect_FSMCNADV
  1688. * @note DISCONNECTED: The NADV signal is not connected. The I/O pin can be used by another peripheral.
  1689. * @retval None
  1690. */
  1691. __STATIC_INLINE void LL_GPIO_AF_Disconnect_FSMCNADV(void)
  1692. {
  1693. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP);
  1694. }
  1695. /**
  1696. * @brief Controls the use of the optional FSMC_NADV signal.
  1697. * @rmtoll MAPR2 FSMC_NADV LL_GPIO_AF_Connect_FSMCNADV
  1698. * @note CONNECTED: The NADV signal is connected to the output (default).
  1699. * @retval None
  1700. */
  1701. __STATIC_INLINE void LL_GPIO_AF_Connect_FSMCNADV(void)
  1702. {
  1703. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP);
  1704. }
  1705. #endif
  1706. #if defined(AFIO_MAPR2_TIM15_REMAP)
  1707. /**
  1708. * @brief Enable the remapping of TIM15_CH1 and TIM15_CH2.
  1709. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_EnableRemap_TIM15
  1710. * @note ENABLE: Remap (TIM15_CH1 on PB14 and TIM15_CH2 on PB15).
  1711. * @retval None
  1712. */
  1713. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM15(void)
  1714. {
  1715. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP);
  1716. }
  1717. /**
  1718. * @brief Disable the remapping of TIM15_CH1 and TIM15_CH2.
  1719. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_DisableRemap_TIM15
  1720. * @note DISABLE: No remap (TIM15_CH1 on PA2 and TIM15_CH2 on PA3).
  1721. * @retval None
  1722. */
  1723. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM15(void)
  1724. {
  1725. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP);
  1726. }
  1727. /**
  1728. * @brief Check if TIM15_CH1 has been remaped or not
  1729. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_IsEnabledRemap_TIM15
  1730. * @retval State of bit (1 or 0).
  1731. */
  1732. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM15(void)
  1733. {
  1734. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP) == (AFIO_MAPR2_TIM15_REMAP));
  1735. }
  1736. #endif
  1737. #if defined(AFIO_MAPR2_TIM16_REMAP)
  1738. /**
  1739. * @brief Enable the remapping of TIM16_CH1.
  1740. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_EnableRemap_TIM16
  1741. * @note ENABLE: Remap (TIM16_CH1 on PA6).
  1742. * @retval None
  1743. */
  1744. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM16(void)
  1745. {
  1746. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP);
  1747. }
  1748. /**
  1749. * @brief Disable the remapping of TIM16_CH1.
  1750. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_DisableRemap_TIM16
  1751. * @note DISABLE: No remap (TIM16_CH1 on PB8).
  1752. * @retval None
  1753. */
  1754. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM16(void)
  1755. {
  1756. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP);
  1757. }
  1758. /**
  1759. * @brief Check if TIM16_CH1 has been remaped or not
  1760. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_IsEnabledRemap_TIM16
  1761. * @retval State of bit (1 or 0).
  1762. */
  1763. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM16(void)
  1764. {
  1765. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP) == (AFIO_MAPR2_TIM16_REMAP));
  1766. }
  1767. #endif
  1768. #if defined(AFIO_MAPR2_TIM17_REMAP)
  1769. /**
  1770. * @brief Enable the remapping of TIM17_CH1.
  1771. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_EnableRemap_TIM17
  1772. * @note ENABLE: Remap (TIM17_CH1 on PA7).
  1773. * @retval None
  1774. */
  1775. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM17(void)
  1776. {
  1777. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP);
  1778. }
  1779. /**
  1780. * @brief Disable the remapping of TIM17_CH1.
  1781. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_DisableRemap_TIM17
  1782. * @note DISABLE: No remap (TIM17_CH1 on PB9).
  1783. * @retval None
  1784. */
  1785. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM17(void)
  1786. {
  1787. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP);
  1788. }
  1789. /**
  1790. * @brief Check if TIM17_CH1 has been remaped or not
  1791. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_IsEnabledRemap_TIM17
  1792. * @retval State of bit (1 or 0).
  1793. */
  1794. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM17(void)
  1795. {
  1796. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP) == (AFIO_MAPR2_TIM17_REMAP));
  1797. }
  1798. #endif
  1799. #if defined(AFIO_MAPR2_CEC_REMAP)
  1800. /**
  1801. * @brief Enable the remapping of CEC.
  1802. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_EnableRemap_CEC
  1803. * @note ENABLE: Remap (CEC on PB10).
  1804. * @retval None
  1805. */
  1806. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_CEC(void)
  1807. {
  1808. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP);
  1809. }
  1810. /**
  1811. * @brief Disable the remapping of CEC.
  1812. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_DisableRemap_CEC
  1813. * @note DISABLE: No remap (CEC on PB8).
  1814. * @retval None
  1815. */
  1816. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_CEC(void)
  1817. {
  1818. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP);
  1819. }
  1820. /**
  1821. * @brief Check if CEC has been remaped or not
  1822. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_IsEnabledRemap_CEC
  1823. * @retval State of bit (1 or 0).
  1824. */
  1825. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_CEC(void)
  1826. {
  1827. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP) == (AFIO_MAPR2_CEC_REMAP));
  1828. }
  1829. #endif
  1830. #if defined(AFIO_MAPR2_TIM1_DMA_REMAP)
  1831. /**
  1832. * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
  1833. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_EnableRemap_TIM1DMA
  1834. * @note ENABLE: Remap (TIM1_CH1 DMA request/DMA1 Channel6, TIM1_CH2 DMA request/DMA1 Channel6)
  1835. * @retval None
  1836. */
  1837. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM1DMA(void)
  1838. {
  1839. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP);
  1840. }
  1841. /**
  1842. * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
  1843. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_DisableRemap_TIM1DMA
  1844. * @note DISABLE: No remap (TIM1_CH1 DMA request/DMA1 Channel2, TIM1_CH2 DMA request/DMA1 Channel3).
  1845. * @retval None
  1846. */
  1847. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM1DMA(void)
  1848. {
  1849. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP);
  1850. }
  1851. /**
  1852. * @brief Check if TIM1DMA has been remaped or not
  1853. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_IsEnabledRemap_TIM1DMA
  1854. * @retval State of bit (1 or 0).
  1855. */
  1856. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM1DMA(void)
  1857. {
  1858. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP) == (AFIO_MAPR2_TIM1_DMA_REMAP));
  1859. }
  1860. #endif
  1861. #if defined(AFIO_MAPR2_TIM67_DAC_DMA_REMAP)
  1862. /**
  1863. * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
  1864. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_EnableRemap_TIM67DACDMA
  1865. * @note ENABLE: Remap (TIM6_DAC1 DMA request/DMA1 Channel3, TIM7_DAC2 DMA request/DMA1 Channel4)
  1866. * @retval None
  1867. */
  1868. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM67DACDMA(void)
  1869. {
  1870. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP);
  1871. }
  1872. /**
  1873. * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
  1874. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_DisableRemap_TIM67DACDMA
  1875. * @note DISABLE: No remap (TIM6_DAC1 DMA request/DMA2 Channel3, TIM7_DAC2 DMA request/DMA2 Channel4)
  1876. * @retval None
  1877. */
  1878. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM67DACDMA(void)
  1879. {
  1880. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP);
  1881. }
  1882. /**
  1883. * @brief Check if TIM67DACDMA has been remaped or not
  1884. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_IsEnabledRemap_TIM67DACDMA
  1885. * @retval State of bit (1 or 0).
  1886. */
  1887. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM67DACDMA(void)
  1888. {
  1889. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP) == (AFIO_MAPR2_TIM67_DAC_DMA_REMAP));
  1890. }
  1891. #endif
  1892. #if defined(AFIO_MAPR2_TIM12_REMAP)
  1893. /**
  1894. * @brief Enable the remapping of TIM12_CH1 and TIM12_CH2.
  1895. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_EnableRemap_TIM12
  1896. * @note ENABLE: Remap (TIM12_CH1 on PB12 and TIM12_CH2 on PB13).
  1897. * @note This bit is available only in high density value line devices.
  1898. * @retval None
  1899. */
  1900. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM12(void)
  1901. {
  1902. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP);
  1903. }
  1904. /**
  1905. * @brief Disable the remapping of TIM12_CH1 and TIM12_CH2.
  1906. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_DisableRemap_TIM12
  1907. * @note DISABLE: No remap (TIM12_CH1 on PC4 and TIM12_CH2 on PC5).
  1908. * @note This bit is available only in high density value line devices.
  1909. * @retval None
  1910. */
  1911. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM12(void)
  1912. {
  1913. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP);
  1914. }
  1915. /**
  1916. * @brief Check if TIM12_CH1 has been remaped or not
  1917. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_IsEnabledRemap_TIM12
  1918. * @retval State of bit (1 or 0).
  1919. */
  1920. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM12(void)
  1921. {
  1922. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP) == (AFIO_MAPR2_TIM12_REMAP));
  1923. }
  1924. #endif
  1925. #if defined(AFIO_MAPR2_MISC_REMAP)
  1926. /**
  1927. * @brief Miscellaneous features remapping.
  1928. * This bit is set and cleared by software. It controls miscellaneous features.
  1929. * The DMA2 channel 5 interrupt position in the vector table.
  1930. * The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
  1931. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_EnableRemap_MISC
  1932. * @note ENABLE: DMA2 channel 5 interrupt is mapped separately at position 60 and TIM15 TRGO event is
  1933. * selected as DAC Trigger 3, TIM15 triggers TIM1/3.
  1934. * @note This bit is available only in high density value line devices.
  1935. * @retval None
  1936. */
  1937. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_MISC(void)
  1938. {
  1939. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP);
  1940. }
  1941. /**
  1942. * @brief Miscellaneous features remapping.
  1943. * This bit is set and cleared by software. It controls miscellaneous features.
  1944. * The DMA2 channel 5 interrupt position in the vector table.
  1945. * The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
  1946. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_DisableRemap_MISC
  1947. * @note DISABLE: DMA2 channel 5 interrupt is mapped with DMA2 channel 4 at position 59, TIM5 TRGO
  1948. * event is selected as DAC Trigger 3, TIM5 triggers TIM1/3.
  1949. * @note This bit is available only in high density value line devices.
  1950. * @retval None
  1951. */
  1952. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_MISC(void)
  1953. {
  1954. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP);
  1955. }
  1956. /**
  1957. * @brief Check if MISC has been remaped or not
  1958. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_IsEnabledRemap_MISC
  1959. * @retval State of bit (1 or 0).
  1960. */
  1961. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_MISC(void)
  1962. {
  1963. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP) == (AFIO_MAPR2_MISC_REMAP));
  1964. }
  1965. #endif
  1966. /**
  1967. * @}
  1968. */
  1969. /** @defgroup GPIO_AF_LL_EVENTOUT Output Event configuration
  1970. * @brief This section propose definition to Configure EVENTOUT Cortex feature .
  1971. * @{
  1972. */
  1973. /**
  1974. * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected.
  1975. * @rmtoll EVCR PORT LL_GPIO_AF_ConfigEventout\n
  1976. * EVCR PIN LL_GPIO_AF_ConfigEventout
  1977. * @param LL_GPIO_PortSource This parameter can be one of the following values:
  1978. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_A
  1979. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_B
  1980. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_C
  1981. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_D
  1982. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_E
  1983. * @param LL_GPIO_PinSource This parameter can be one of the following values:
  1984. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_0
  1985. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_1
  1986. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_2
  1987. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_3
  1988. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_4
  1989. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_5
  1990. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_6
  1991. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_7
  1992. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_8
  1993. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_9
  1994. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_10
  1995. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_11
  1996. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_12
  1997. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_13
  1998. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_14
  1999. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_15
  2000. * @retval None
  2001. */
  2002. __STATIC_INLINE void LL_GPIO_AF_ConfigEventout(uint32_t LL_GPIO_PortSource, uint32_t LL_GPIO_PinSource)
  2003. {
  2004. MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (LL_GPIO_PortSource) | (LL_GPIO_PinSource));
  2005. }
  2006. /**
  2007. * @brief Enables the Event Output.
  2008. * @rmtoll EVCR EVOE LL_GPIO_AF_EnableEventout
  2009. * @retval None
  2010. */
  2011. __STATIC_INLINE void LL_GPIO_AF_EnableEventout(void)
  2012. {
  2013. SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  2014. }
  2015. /**
  2016. * @brief Disables the Event Output.
  2017. * @rmtoll EVCR EVOE LL_GPIO_AF_DisableEventout
  2018. * @retval None
  2019. */
  2020. __STATIC_INLINE void LL_GPIO_AF_DisableEventout(void)
  2021. {
  2022. CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  2023. }
  2024. /**
  2025. * @}
  2026. */
  2027. /** @defgroup GPIO_AF_LL_EXTI EXTI external interrupt
  2028. * @brief This section Configure source input for the EXTI external interrupt .
  2029. * @{
  2030. */
  2031. /**
  2032. * @brief Configure source input for the EXTI external interrupt.
  2033. * @rmtoll AFIO_EXTICR1 EXTIx LL_GPIO_AF_SetEXTISource\n
  2034. * AFIO_EXTICR2 EXTIx LL_GPIO_AF_SetEXTISource\n
  2035. * AFIO_EXTICR3 EXTIx LL_GPIO_AF_SetEXTISource\n
  2036. * AFIO_EXTICR4 EXTIx LL_GPIO_AF_SetEXTISource
  2037. * @param Port This parameter can be one of the following values:
  2038. * @arg @ref LL_GPIO_AF_EXTI_PORTA
  2039. * @arg @ref LL_GPIO_AF_EXTI_PORTB
  2040. * @arg @ref LL_GPIO_AF_EXTI_PORTC
  2041. * @arg @ref LL_GPIO_AF_EXTI_PORTD
  2042. * @arg @ref LL_GPIO_AF_EXTI_PORTE
  2043. * @arg @ref LL_GPIO_AF_EXTI_PORTF
  2044. * @arg @ref LL_GPIO_AF_EXTI_PORTG
  2045. * @param Line This parameter can be one of the following values:
  2046. * @arg @ref LL_GPIO_AF_EXTI_LINE0
  2047. * @arg @ref LL_GPIO_AF_EXTI_LINE1
  2048. * @arg @ref LL_GPIO_AF_EXTI_LINE2
  2049. * @arg @ref LL_GPIO_AF_EXTI_LINE3
  2050. * @arg @ref LL_GPIO_AF_EXTI_LINE4
  2051. * @arg @ref LL_GPIO_AF_EXTI_LINE5
  2052. * @arg @ref LL_GPIO_AF_EXTI_LINE6
  2053. * @arg @ref LL_GPIO_AF_EXTI_LINE7
  2054. * @arg @ref LL_GPIO_AF_EXTI_LINE8
  2055. * @arg @ref LL_GPIO_AF_EXTI_LINE9
  2056. * @arg @ref LL_GPIO_AF_EXTI_LINE10
  2057. * @arg @ref LL_GPIO_AF_EXTI_LINE11
  2058. * @arg @ref LL_GPIO_AF_EXTI_LINE12
  2059. * @arg @ref LL_GPIO_AF_EXTI_LINE13
  2060. * @arg @ref LL_GPIO_AF_EXTI_LINE14
  2061. * @arg @ref LL_GPIO_AF_EXTI_LINE15
  2062. * @retval None
  2063. */
  2064. __STATIC_INLINE void LL_GPIO_AF_SetEXTISource(uint32_t Port, uint32_t Line)
  2065. {
  2066. MODIFY_REG(AFIO->EXTICR[Line & 0xFF], (Line >> 16), Port << POSITION_VAL((Line >> 16)));
  2067. }
  2068. /**
  2069. * @brief Get the configured defined for specific EXTI Line
  2070. * @rmtoll AFIO_EXTICR1 EXTIx LL_GPIO_AF_GetEXTISource\n
  2071. * AFIO_EXTICR2 EXTIx LL_GPIO_AF_GetEXTISource\n
  2072. * AFIO_EXTICR3 EXTIx LL_GPIO_AF_GetEXTISource\n
  2073. * AFIO_EXTICR4 EXTIx LL_GPIO_AF_GetEXTISource
  2074. * @param Line This parameter can be one of the following values:
  2075. * @arg @ref LL_GPIO_AF_EXTI_LINE0
  2076. * @arg @ref LL_GPIO_AF_EXTI_LINE1
  2077. * @arg @ref LL_GPIO_AF_EXTI_LINE2
  2078. * @arg @ref LL_GPIO_AF_EXTI_LINE3
  2079. * @arg @ref LL_GPIO_AF_EXTI_LINE4
  2080. * @arg @ref LL_GPIO_AF_EXTI_LINE5
  2081. * @arg @ref LL_GPIO_AF_EXTI_LINE6
  2082. * @arg @ref LL_GPIO_AF_EXTI_LINE7
  2083. * @arg @ref LL_GPIO_AF_EXTI_LINE8
  2084. * @arg @ref LL_GPIO_AF_EXTI_LINE9
  2085. * @arg @ref LL_GPIO_AF_EXTI_LINE10
  2086. * @arg @ref LL_GPIO_AF_EXTI_LINE11
  2087. * @arg @ref LL_GPIO_AF_EXTI_LINE12
  2088. * @arg @ref LL_GPIO_AF_EXTI_LINE13
  2089. * @arg @ref LL_GPIO_AF_EXTI_LINE14
  2090. * @arg @ref LL_GPIO_AF_EXTI_LINE15
  2091. * @retval Returned value can be one of the following values:
  2092. * @arg @ref LL_GPIO_AF_EXTI_PORTA
  2093. * @arg @ref LL_GPIO_AF_EXTI_PORTB
  2094. * @arg @ref LL_GPIO_AF_EXTI_PORTC
  2095. * @arg @ref LL_GPIO_AF_EXTI_PORTD
  2096. * @arg @ref LL_GPIO_AF_EXTI_PORTE
  2097. * @arg @ref LL_GPIO_AF_EXTI_PORTF
  2098. * @arg @ref LL_GPIO_AF_EXTI_PORTG
  2099. */
  2100. __STATIC_INLINE uint32_t LL_GPIO_AF_GetEXTISource(uint32_t Line)
  2101. {
  2102. return (uint32_t)(READ_BIT(AFIO->EXTICR[Line & 0xFF], (Line >> 16)) >> POSITION_VAL(Line >> 16));
  2103. }
  2104. /**
  2105. * @}
  2106. */
  2107. #if defined(USE_FULL_LL_DRIVER)
  2108. /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
  2109. * @{
  2110. */
  2111. ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
  2112. ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
  2113. void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
  2114. /**
  2115. * @}
  2116. */
  2117. #endif /* USE_FULL_LL_DRIVER */
  2118. /**
  2119. * @}
  2120. */
  2121. /**
  2122. * @}
  2123. */
  2124. #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) */
  2125. /**
  2126. * @}
  2127. */
  2128. #ifdef __cplusplus
  2129. }
  2130. #endif
  2131. #endif /* STM32F1xx_LL_GPIO_H */
  2132. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/