stm32f1xx_ll_gpio.h 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348
  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)((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)((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)((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)((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)((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)((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. uint32_t odr = READ_REG(GPIOx->ODR);
  798. uint32_t pinmask = ((PinMask >> GPIO_PIN_MASK_POS) & 0x0000FFFFU);
  799. WRITE_REG(GPIOx->BSRR, ((odr & pinmask) << 16u) | (~odr & pinmask));
  800. }
  801. /**
  802. * @}
  803. */
  804. /** @defgroup GPIO_AF_REMAPPING Alternate Function Remapping
  805. * @brief This section propose definition to remap the alternate function to some other port/pins.
  806. * @{
  807. */
  808. /**
  809. * @brief Enable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
  810. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_EnableRemap_SPI1
  811. * @note ENABLE: Remap (NSS/PA15, SCK/PB3, MISO/PB4, MOSI/PB5)
  812. * @retval None
  813. */
  814. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SPI1(void)
  815. {
  816. SET_BIT(AFIO->MAPR, AFIO_MAPR_SPI1_REMAP | AFIO_MAPR_SWJ_CFG);
  817. }
  818. /**
  819. * @brief Disable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
  820. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_DisableRemap_SPI1
  821. * @note DISABLE: No remap (NSS/PA4, SCK/PA5, MISO/PA6, MOSI/PA7)
  822. * @retval None
  823. */
  824. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SPI1(void)
  825. {
  826. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_SPI1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  827. }
  828. /**
  829. * @brief Check if SPI1 has been remaped or not
  830. * @rmtoll MAPR SPI1_REMAP LL_GPIO_AF_IsEnabledRemap_SPI1
  831. * @retval State of bit (1 or 0).
  832. */
  833. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_SPI1(void)
  834. {
  835. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_SPI1_REMAP) == (AFIO_MAPR_SPI1_REMAP));
  836. }
  837. /**
  838. * @brief Enable the remapping of I2C1 alternate function SCL and SDA.
  839. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_EnableRemap_I2C1
  840. * @note ENABLE: Remap (SCL/PB8, SDA/PB9)
  841. * @retval None
  842. */
  843. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_I2C1(void)
  844. {
  845. SET_BIT(AFIO->MAPR, AFIO_MAPR_I2C1_REMAP | AFIO_MAPR_SWJ_CFG);
  846. }
  847. /**
  848. * @brief Disable the remapping of I2C1 alternate function SCL and SDA.
  849. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_DisableRemap_I2C1
  850. * @note DISABLE: No remap (SCL/PB6, SDA/PB7)
  851. * @retval None
  852. */
  853. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_I2C1(void)
  854. {
  855. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_I2C1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  856. }
  857. /**
  858. * @brief Check if I2C1 has been remaped or not
  859. * @rmtoll MAPR I2C1_REMAP LL_GPIO_AF_IsEnabledRemap_I2C1
  860. * @retval State of bit (1 or 0).
  861. */
  862. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_I2C1(void)
  863. {
  864. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_I2C1_REMAP) == (AFIO_MAPR_I2C1_REMAP));
  865. }
  866. /**
  867. * @brief Enable the remapping of USART1 alternate function TX and RX.
  868. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_EnableRemap_USART1
  869. * @note ENABLE: Remap (TX/PB6, RX/PB7)
  870. * @retval None
  871. */
  872. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART1(void)
  873. {
  874. SET_BIT(AFIO->MAPR, AFIO_MAPR_USART1_REMAP | AFIO_MAPR_SWJ_CFG);
  875. }
  876. /**
  877. * @brief Disable the remapping of USART1 alternate function TX and RX.
  878. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_DisableRemap_USART1
  879. * @note DISABLE: No remap (TX/PA9, RX/PA10)
  880. * @retval None
  881. */
  882. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART1(void)
  883. {
  884. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART1_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  885. }
  886. /**
  887. * @brief Check if USART1 has been remaped or not
  888. * @rmtoll MAPR USART1_REMAP LL_GPIO_AF_IsEnabledRemap_USART1
  889. * @retval State of bit (1 or 0).
  890. */
  891. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_USART1(void)
  892. {
  893. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_USART1_REMAP) == (AFIO_MAPR_USART1_REMAP));
  894. }
  895. /**
  896. * @brief Enable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
  897. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_EnableRemap_USART2
  898. * @note ENABLE: Remap (CTS/PD3, RTS/PD4, TX/PD5, RX/PD6, CK/PD7)
  899. * @retval None
  900. */
  901. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART2(void)
  902. {
  903. SET_BIT(AFIO->MAPR, AFIO_MAPR_USART2_REMAP | AFIO_MAPR_SWJ_CFG);
  904. }
  905. /**
  906. * @brief Disable the remapping of USART2 alternate function CTS, RTS, CK, TX and RX.
  907. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_DisableRemap_USART2
  908. * @note DISABLE: No remap (CTS/PA0, RTS/PA1, TX/PA2, RX/PA3, CK/PA4)
  909. * @retval None
  910. */
  911. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART2(void)
  912. {
  913. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART2_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  914. }
  915. /**
  916. * @brief Check if USART2 has been remaped or not
  917. * @rmtoll MAPR USART2_REMAP LL_GPIO_AF_IsEnabledRemap_USART2
  918. * @retval State of bit (1 or 0).
  919. */
  920. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_USART2(void)
  921. {
  922. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_USART2_REMAP) == (AFIO_MAPR_USART2_REMAP));
  923. }
  924. #if defined (AFIO_MAPR_USART3_REMAP)
  925. /**
  926. * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  927. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_EnableRemap_USART3
  928. * @note ENABLE: Full remap (TX/PD8, RX/PD9, CK/PD10, CTS/PD11, RTS/PD12)
  929. * @retval None
  930. */
  931. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_USART3(void)
  932. {
  933. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  934. }
  935. /**
  936. * @brief Enable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  937. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_RemapPartial_USART3
  938. * @note PARTIAL: Partial remap (TX/PC10, RX/PC11, CK/PC12, CTS/PB13, RTS/PB14)
  939. * @retval None
  940. */
  941. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_USART3(void)
  942. {
  943. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  944. }
  945. /**
  946. * @brief Disable the remapping of USART3 alternate function CTS, RTS, CK, TX and RX.
  947. * @rmtoll MAPR USART3_REMAP LL_GPIO_AF_DisableRemap_USART3
  948. * @note DISABLE: No remap (TX/PB10, RX/PB11, CK/PB12, CTS/PB13, RTS/PB14)
  949. * @retval None
  950. */
  951. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_USART3(void)
  952. {
  953. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_USART3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_USART3_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  954. }
  955. #endif
  956. /**
  957. * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  958. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_EnableRemap_TIM1
  959. * @note ENABLE: Full remap (ETR/PE7, CH1/PE9, CH2/PE11, CH3/PE13, CH4/PE14, BKIN/PE15, CH1N/PE8, CH2N/PE10, CH3N/PE12)
  960. * @retval None
  961. */
  962. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM1(void)
  963. {
  964. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  965. }
  966. /**
  967. * @brief Enable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  968. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_RemapPartial_TIM1
  969. * @note PARTIAL: Partial remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PA6, CH1N/PA7, CH2N/PB0, CH3N/PB1)
  970. * @retval None
  971. */
  972. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_TIM1(void)
  973. {
  974. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  975. }
  976. /**
  977. * @brief Disable the remapping of TIM1 alternate function channels 1 to 4, 1N to 3N, external trigger (ETR) and Break input (BKIN)
  978. * @rmtoll MAPR TIM1_REMAP LL_GPIO_AF_DisableRemap_TIM1
  979. * @note DISABLE: No remap (ETR/PA12, CH1/PA8, CH2/PA9, CH3/PA10, CH4/PA11, BKIN/PB12, CH1N/PB13, CH2N/PB14, CH3N/PB15)
  980. * @retval None
  981. */
  982. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM1(void)
  983. {
  984. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM1_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM1_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  985. }
  986. /**
  987. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  988. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_EnableRemap_TIM2
  989. * @note ENABLE: Full remap (CH1/ETR/PA15, CH2/PB3, CH3/PB10, CH4/PB11)
  990. * @retval None
  991. */
  992. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM2(void)
  993. {
  994. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  995. }
  996. /**
  997. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  998. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_RemapPartial2_TIM2
  999. * @note PARTIAL_2: Partial remap (CH1/ETR/PA0, CH2/PA1, CH3/PB10, CH4/PB11)
  1000. * @retval None
  1001. */
  1002. __STATIC_INLINE void LL_GPIO_AF_RemapPartial2_TIM2(void)
  1003. {
  1004. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_PARTIALREMAP2 | AFIO_MAPR_SWJ_CFG));
  1005. }
  1006. /**
  1007. * @brief Enable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  1008. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_RemapPartial1_TIM2
  1009. * @note PARTIAL_1: Partial remap (CH1/ETR/PA15, CH2/PB3, CH3/PA2, CH4/PA3)
  1010. * @retval None
  1011. */
  1012. __STATIC_INLINE void LL_GPIO_AF_RemapPartial1_TIM2(void)
  1013. {
  1014. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_PARTIALREMAP1 | AFIO_MAPR_SWJ_CFG));
  1015. }
  1016. /**
  1017. * @brief Disable the remapping of TIM2 alternate function channels 1 to 4 and external trigger (ETR)
  1018. * @rmtoll MAPR TIM2_REMAP LL_GPIO_AF_DisableRemap_TIM2
  1019. * @note DISABLE: No remap (CH1/ETR/PA0, CH2/PA1, CH3/PA2, CH4/PA3)
  1020. * @retval None
  1021. */
  1022. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM2(void)
  1023. {
  1024. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM2_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  1025. }
  1026. /**
  1027. * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
  1028. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_EnableRemap_TIM3
  1029. * @note ENABLE: Full remap (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9)
  1030. * @note TIM3_ETR on PE0 is not re-mapped.
  1031. * @retval None
  1032. */
  1033. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM3(void)
  1034. {
  1035. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_FULLREMAP | AFIO_MAPR_SWJ_CFG));
  1036. }
  1037. /**
  1038. * @brief Enable the remapping of TIM3 alternate function channels 1 to 4
  1039. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_RemapPartial_TIM3
  1040. * @note PARTIAL: Partial remap (CH1/PB4, CH2/PB5, CH3/PB0, CH4/PB1)
  1041. * @note TIM3_ETR on PE0 is not re-mapped.
  1042. * @retval None
  1043. */
  1044. __STATIC_INLINE void LL_GPIO_AF_RemapPartial_TIM3(void)
  1045. {
  1046. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_PARTIALREMAP | AFIO_MAPR_SWJ_CFG));
  1047. }
  1048. /**
  1049. * @brief Disable the remapping of TIM3 alternate function channels 1 to 4
  1050. * @rmtoll MAPR TIM3_REMAP LL_GPIO_AF_DisableRemap_TIM3
  1051. * @note DISABLE: No remap (CH1/PA6, CH2/PA7, CH3/PB0, CH4/PB1)
  1052. * @note TIM3_ETR on PE0 is not re-mapped.
  1053. * @retval None
  1054. */
  1055. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM3(void)
  1056. {
  1057. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM3_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_TIM3_REMAP_NOREMAP | AFIO_MAPR_SWJ_CFG));
  1058. }
  1059. #if defined(AFIO_MAPR_TIM4_REMAP)
  1060. /**
  1061. * @brief Enable the remapping of TIM4 alternate function channels 1 to 4.
  1062. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_EnableRemap_TIM4
  1063. * @note ENABLE: Full remap (TIM4_CH1/PD12, TIM4_CH2/PD13, TIM4_CH3/PD14, TIM4_CH4/PD15)
  1064. * @note TIM4_ETR on PE0 is not re-mapped.
  1065. * @retval None
  1066. */
  1067. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM4(void)
  1068. {
  1069. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM4_REMAP | AFIO_MAPR_SWJ_CFG);
  1070. }
  1071. /**
  1072. * @brief Disable the remapping of TIM4 alternate function channels 1 to 4.
  1073. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_DisableRemap_TIM4
  1074. * @note DISABLE: No remap (TIM4_CH1/PB6, TIM4_CH2/PB7, TIM4_CH3/PB8, TIM4_CH4/PB9)
  1075. * @note TIM4_ETR on PE0 is not re-mapped.
  1076. * @retval None
  1077. */
  1078. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM4(void)
  1079. {
  1080. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM4_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1081. }
  1082. /**
  1083. * @brief Check if TIM4 has been remaped or not
  1084. * @rmtoll MAPR TIM4_REMAP LL_GPIO_AF_IsEnabledRemap_TIM4
  1085. * @retval State of bit (1 or 0).
  1086. */
  1087. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM4(void)
  1088. {
  1089. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_TIM4_REMAP) == (AFIO_MAPR_TIM4_REMAP));
  1090. }
  1091. #endif
  1092. #if defined(AFIO_MAPR_CAN_REMAP_REMAP1)
  1093. /**
  1094. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1095. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial1_CAN1
  1096. * @note CASE 1: CAN_RX mapped to PA11, CAN_TX mapped to PA12
  1097. * @retval None
  1098. */
  1099. __STATIC_INLINE void LL_GPIO_AF_RemapPartial1_CAN1(void)
  1100. {
  1101. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP1 | AFIO_MAPR_SWJ_CFG));
  1102. }
  1103. /**
  1104. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1105. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial2_CAN1
  1106. * @note CASE 2: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (not available on 36-pin package)
  1107. * @retval None
  1108. */
  1109. __STATIC_INLINE void LL_GPIO_AF_RemapPartial2_CAN1(void)
  1110. {
  1111. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP2 | AFIO_MAPR_SWJ_CFG));
  1112. }
  1113. /**
  1114. * @brief Enable or disable the remapping of CAN alternate function CAN_RX and CAN_TX in devices with a single CAN interface.
  1115. * @rmtoll MAPR CAN_REMAP LL_GPIO_AF_RemapPartial3_CAN1
  1116. * @note CASE 3: CAN_RX mapped to PD0, CAN_TX mapped to PD1
  1117. * @retval None
  1118. */
  1119. __STATIC_INLINE void LL_GPIO_AF_RemapPartial3_CAN1(void)
  1120. {
  1121. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN_REMAP | AFIO_MAPR_SWJ_CFG), (AFIO_MAPR_CAN_REMAP_REMAP3 | AFIO_MAPR_SWJ_CFG));
  1122. }
  1123. #endif
  1124. /**
  1125. * @brief Enable the remapping of PD0 and PD1. When the HSE oscillator is not used
  1126. * (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
  1127. * OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
  1128. * on 100-pin and 144-pin packages, no need for remapping).
  1129. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_EnableRemap_PD01
  1130. * @note ENABLE: PD0 remapped on OSC_IN, PD1 remapped on OSC_OUT.
  1131. * @retval None
  1132. */
  1133. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_PD01(void)
  1134. {
  1135. SET_BIT(AFIO->MAPR, AFIO_MAPR_PD01_REMAP | AFIO_MAPR_SWJ_CFG);
  1136. }
  1137. /**
  1138. * @brief Disable the remapping of PD0 and PD1. When the HSE oscillator is not used
  1139. * (application running on internal 8 MHz RC) PD0 and PD1 can be mapped on OSC_IN and
  1140. * OSC_OUT. This is available only on 36, 48 and 64 pins packages (PD0 and PD1 are available
  1141. * on 100-pin and 144-pin packages, no need for remapping).
  1142. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_DisableRemap_PD01
  1143. * @note DISABLE: No remapping of PD0 and PD1
  1144. * @retval None
  1145. */
  1146. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_PD01(void)
  1147. {
  1148. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_PD01_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1149. }
  1150. /**
  1151. * @brief Check if PD01 has been remaped or not
  1152. * @rmtoll MAPR PD01_REMAP LL_GPIO_AF_IsEnabledRemap_PD01
  1153. * @retval State of bit (1 or 0).
  1154. */
  1155. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_PD01(void)
  1156. {
  1157. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_PD01_REMAP) == (AFIO_MAPR_PD01_REMAP));
  1158. }
  1159. #if defined(AFIO_MAPR_TIM5CH4_IREMAP)
  1160. /**
  1161. * @brief Enable the remapping of TIM5CH4.
  1162. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_EnableRemap_TIM5CH4
  1163. * @note ENABLE: LSI internal clock is connected to TIM5_CH4 input for calibration purpose.
  1164. * @note This function is available only in high density value line devices.
  1165. * @retval None
  1166. */
  1167. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM5CH4(void)
  1168. {
  1169. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM5CH4_IREMAP | AFIO_MAPR_SWJ_CFG);
  1170. }
  1171. /**
  1172. * @brief Disable the remapping of TIM5CH4.
  1173. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_DisableRemap_TIM5CH4
  1174. * @note DISABLE: TIM5_CH4 is connected to PA3
  1175. * @note This function is available only in high density value line devices.
  1176. * @retval None
  1177. */
  1178. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM5CH4(void)
  1179. {
  1180. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM5CH4_IREMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1181. }
  1182. /**
  1183. * @brief Check if TIM5CH4 has been remaped or not
  1184. * @rmtoll MAPR TIM5CH4_IREMAP LL_GPIO_AF_IsEnabledRemap_TIM5CH4
  1185. * @retval State of bit (1 or 0).
  1186. */
  1187. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM5CH4(void)
  1188. {
  1189. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_TIM5CH4_IREMAP) == (AFIO_MAPR_TIM5CH4_IREMAP));
  1190. }
  1191. #endif
  1192. #if defined(AFIO_MAPR_ETH_REMAP)
  1193. /**
  1194. * @brief Enable the remapping of Ethernet MAC connections with the PHY.
  1195. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_EnableRemap_ETH
  1196. * @note ENABLE: Remap (RX_DV-CRS_DV/PD8, RXD0/PD9, RXD1/PD10, RXD2/PD11, RXD3/PD12)
  1197. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1198. * @retval None
  1199. */
  1200. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ETH(void)
  1201. {
  1202. SET_BIT(AFIO->MAPR, AFIO_MAPR_ETH_REMAP | AFIO_MAPR_SWJ_CFG);
  1203. }
  1204. /**
  1205. * @brief Disable the remapping of Ethernet MAC connections with the PHY.
  1206. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_DisableRemap_ETH
  1207. * @note DISABLE: No remap (RX_DV-CRS_DV/PA7, RXD0/PC4, RXD1/PC5, RXD2/PB0, RXD3/PB1)
  1208. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1209. * @retval None
  1210. */
  1211. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ETH(void)
  1212. {
  1213. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ETH_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1214. }
  1215. /**
  1216. * @brief Check if ETH has been remaped or not
  1217. * @rmtoll MAPR ETH_REMAP LL_GPIO_AF_IsEnabledRemap_ETH
  1218. * @retval State of bit (1 or 0).
  1219. */
  1220. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ETH(void)
  1221. {
  1222. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ETH_REMAP) == (AFIO_MAPR_ETH_REMAP));
  1223. }
  1224. #endif
  1225. #if defined(AFIO_MAPR_CAN2_REMAP)
  1226. /**
  1227. * @brief Enable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
  1228. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_EnableRemap_CAN2
  1229. * @note ENABLE: Remap (CAN2_RX/PB5, CAN2_TX/PB6)
  1230. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1231. * @retval None
  1232. */
  1233. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_CAN2(void)
  1234. {
  1235. SET_BIT(AFIO->MAPR, AFIO_MAPR_CAN2_REMAP | AFIO_MAPR_SWJ_CFG);
  1236. }
  1237. /**
  1238. * @brief Disable the remapping of CAN2 alternate function CAN2_RX and CAN2_TX.
  1239. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_DisableRemap_CAN2
  1240. * @note DISABLE: No remap (CAN2_RX/PB12, CAN2_TX/PB13)
  1241. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1242. * @retval None
  1243. */
  1244. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_CAN2(void)
  1245. {
  1246. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_CAN2_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1247. }
  1248. /**
  1249. * @brief Check if CAN2 has been remaped or not
  1250. * @rmtoll MAPR CAN2_REMAP LL_GPIO_AF_IsEnabledRemap_CAN2
  1251. * @retval State of bit (1 or 0).
  1252. */
  1253. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_CAN2(void)
  1254. {
  1255. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_CAN2_REMAP) == (AFIO_MAPR_CAN2_REMAP));
  1256. }
  1257. #endif
  1258. #if defined(AFIO_MAPR_MII_RMII_SEL)
  1259. /**
  1260. * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
  1261. * @rmtoll MAPR MII_RMII_SEL LL_GPIO_AF_Select_ETH_RMII
  1262. * @note ETH_RMII: Configure Ethernet MAC for connection with an RMII PHY
  1263. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1264. * @retval None
  1265. */
  1266. __STATIC_INLINE void LL_GPIO_AF_Select_ETH_RMII(void)
  1267. {
  1268. SET_BIT(AFIO->MAPR, AFIO_MAPR_MII_RMII_SEL | AFIO_MAPR_SWJ_CFG);
  1269. }
  1270. /**
  1271. * @brief Configures the Ethernet MAC internally for use with an external MII or RMII PHY.
  1272. * @rmtoll MAPR MII_RMII_SEL LL_GPIO_AF_Select_ETH_MII
  1273. * @note ETH_MII: Configure Ethernet MAC for connection with an MII PHY
  1274. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1275. * @retval None
  1276. */
  1277. __STATIC_INLINE void LL_GPIO_AF_Select_ETH_MII(void)
  1278. {
  1279. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_MII_RMII_SEL | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1280. }
  1281. #endif
  1282. #if defined(AFIO_MAPR_ADC1_ETRGINJ_REMAP)
  1283. /**
  1284. * @brief Enable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
  1285. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_EnableRemap_ADC1_ETRGINJ
  1286. * @note ENABLE: ADC1 External Event injected conversion is connected to TIM8 Channel4.
  1287. * @retval None
  1288. */
  1289. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC1_ETRGINJ(void)
  1290. {
  1291. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG);
  1292. }
  1293. /**
  1294. * @brief Disable the remapping of ADC1_ETRGINJ (ADC 1 External trigger injected conversion).
  1295. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_DisableRemap_ADC1_ETRGINJ
  1296. * @note DISABLE: ADC1 External trigger injected conversion is connected to EXTI15
  1297. * @retval None
  1298. */
  1299. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC1_ETRGINJ(void)
  1300. {
  1301. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC1_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1302. }
  1303. /**
  1304. * @brief Check if ADC1_ETRGINJ has been remaped or not
  1305. * @rmtoll MAPR ADC1_ETRGINJ_REMAP LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGINJ
  1306. * @retval State of bit (1 or 0).
  1307. */
  1308. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGINJ(void)
  1309. {
  1310. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGINJ_REMAP) == (AFIO_MAPR_ADC1_ETRGINJ_REMAP));
  1311. }
  1312. #endif
  1313. #if defined(AFIO_MAPR_ADC1_ETRGREG_REMAP)
  1314. /**
  1315. * @brief Enable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
  1316. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_EnableRemap_ADC1_ETRGREG
  1317. * @note ENABLE: ADC1 External Event regular conversion is connected to TIM8 TRG0.
  1318. * @retval None
  1319. */
  1320. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC1_ETRGREG(void)
  1321. {
  1322. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG);
  1323. }
  1324. /**
  1325. * @brief Disable the remapping of ADC1_ETRGREG (ADC 1 External trigger regular conversion).
  1326. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_DisableRemap_ADC1_ETRGREG
  1327. * @note DISABLE: ADC1 External trigger regular conversion is connected to EXTI11
  1328. * @retval None
  1329. */
  1330. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC1_ETRGREG(void)
  1331. {
  1332. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC1_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1333. }
  1334. /**
  1335. * @brief Check if ADC1_ETRGREG has been remaped or not
  1336. * @rmtoll MAPR ADC1_ETRGREG_REMAP LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGREG
  1337. * @retval State of bit (1 or 0).
  1338. */
  1339. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC1_ETRGREG(void)
  1340. {
  1341. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC1_ETRGREG_REMAP) == (AFIO_MAPR_ADC1_ETRGREG_REMAP));
  1342. }
  1343. #endif
  1344. #if defined(AFIO_MAPR_ADC2_ETRGINJ_REMAP)
  1345. /**
  1346. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
  1347. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_EnableRemap_ADC2_ETRGINJ
  1348. * @note ENABLE: ADC2 External Event injected conversion is connected to TIM8 Channel4.
  1349. * @retval None
  1350. */
  1351. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC2_ETRGINJ(void)
  1352. {
  1353. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG);
  1354. }
  1355. /**
  1356. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger injected conversion).
  1357. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_DisableRemap_ADC2_ETRGINJ
  1358. * @note DISABLE: ADC2 External trigger injected conversion is connected to EXTI15
  1359. * @retval None
  1360. */
  1361. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC2_ETRGINJ(void)
  1362. {
  1363. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC2_ETRGINJ_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1364. }
  1365. /**
  1366. * @brief Check if ADC2_ETRGINJ has been remaped or not
  1367. * @rmtoll MAPR ADC2_ETRGINJ_REMAP LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGINJ
  1368. * @retval State of bit (1 or 0).
  1369. */
  1370. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGINJ(void)
  1371. {
  1372. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGINJ_REMAP) == (AFIO_MAPR_ADC2_ETRGINJ_REMAP));
  1373. }
  1374. #endif
  1375. #if defined (AFIO_MAPR_ADC2_ETRGREG_REMAP)
  1376. /**
  1377. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1378. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_EnableRemap_ADC2_ETRGREG
  1379. * @note ENABLE: ADC2 External Event regular conversion is connected to TIM8 TRG0.
  1380. * @retval None
  1381. */
  1382. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ADC2_ETRGREG(void)
  1383. {
  1384. SET_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG);
  1385. }
  1386. /**
  1387. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1388. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_DisableRemap_ADC2_ETRGREG
  1389. * @note DISABLE: ADC2 External trigger regular conversion is connected to EXTI11
  1390. * @retval None
  1391. */
  1392. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ADC2_ETRGREG(void)
  1393. {
  1394. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_ADC2_ETRGREG_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1395. }
  1396. /**
  1397. * @brief Check if ADC2_ETRGREG has been remaped or not
  1398. * @rmtoll MAPR ADC2_ETRGREG_REMAP LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGREG
  1399. * @retval State of bit (1 or 0).
  1400. */
  1401. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_ADC2_ETRGREG(void)
  1402. {
  1403. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_ADC2_ETRGREG_REMAP) == (AFIO_MAPR_ADC2_ETRGREG_REMAP));
  1404. }
  1405. #endif
  1406. /**
  1407. * @brief Enable the Serial wire JTAG configuration
  1408. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_EnableRemap_SWJ
  1409. * @note ENABLE: Full SWJ (JTAG-DP + SW-DP): Reset State
  1410. * @retval None
  1411. */
  1412. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SWJ(void)
  1413. {
  1414. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1415. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_RESET);
  1416. }
  1417. /**
  1418. * @brief Enable the Serial wire JTAG configuration
  1419. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_Remap_SWJ_NONJTRST
  1420. * @note NONJTRST: Full SWJ (JTAG-DP + SW-DP) but without NJTRST
  1421. * @retval None
  1422. */
  1423. __STATIC_INLINE void LL_GPIO_AF_Remap_SWJ_NONJTRST(void)
  1424. {
  1425. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1426. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_NOJNTRST);
  1427. }
  1428. /**
  1429. * @brief Enable the Serial wire JTAG configuration
  1430. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_Remap_SWJ_NOJTAG
  1431. * @note NOJTAG: JTAG-DP Disabled and SW-DP Enabled
  1432. * @retval None
  1433. */
  1434. __STATIC_INLINE void LL_GPIO_AF_Remap_SWJ_NOJTAG(void)
  1435. {
  1436. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1437. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_JTAGDISABLE);
  1438. }
  1439. /**
  1440. * @brief Disable the Serial wire JTAG configuration
  1441. * @rmtoll MAPR SWJ_CFG LL_GPIO_AF_DisableRemap_SWJ
  1442. * @note DISABLE: JTAG-DP Disabled and SW-DP Disabled
  1443. * @retval None
  1444. */
  1445. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SWJ(void)
  1446. {
  1447. CLEAR_BIT(AFIO->MAPR,AFIO_MAPR_SWJ_CFG);
  1448. SET_BIT(AFIO->MAPR, AFIO_MAPR_SWJ_CFG_DISABLE);
  1449. }
  1450. #if defined(AFIO_MAPR_SPI3_REMAP)
  1451. /**
  1452. * @brief Enable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
  1453. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_EnableRemap_SPI3
  1454. * @note ENABLE: Remap (SPI3_NSS-I2S3_WS/PA4, SPI3_SCK-I2S3_CK/PC10, SPI3_MISO/PC11, SPI3_MOSI-I2S3_SD/PC12)
  1455. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1456. * @retval None
  1457. */
  1458. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_SPI3(void)
  1459. {
  1460. SET_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP | AFIO_MAPR_SWJ_CFG);
  1461. }
  1462. /**
  1463. * @brief Disable the remapping of SPI3 alternate functions SPI3_NSS/I2S3_WS, SPI3_SCK/I2S3_CK, SPI3_MISO, SPI3_MOSI/I2S3_SD.
  1464. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_DisableRemap_SPI3
  1465. * @note DISABLE: No remap (SPI3_NSS-I2S3_WS/PA15, SPI3_SCK-I2S3_CK/PB3, SPI3_MISO/PB4, SPI3_MOSI-I2S3_SD/PB5).
  1466. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1467. * @retval None
  1468. */
  1469. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_SPI3(void)
  1470. {
  1471. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_SPI3_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1472. }
  1473. /**
  1474. * @brief Check if SPI3 has been remaped or not
  1475. * @rmtoll MAPR SPI3_REMAP LL_GPIO_AF_IsEnabledRemap_SPI3_REMAP
  1476. * @retval State of bit (1 or 0).
  1477. */
  1478. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_SPI3(void)
  1479. {
  1480. return (READ_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP) == (AFIO_MAPR_SPI3_REMAP));
  1481. }
  1482. #endif
  1483. #if defined(AFIO_MAPR_TIM2ITR1_IREMAP)
  1484. /**
  1485. * @brief Control of TIM2_ITR1 internal mapping.
  1486. * @rmtoll MAPR TIM2ITR1_IREMAP LL_GPIO_AF_Remap_TIM2ITR1_TO_USB
  1487. * @note TO_USB: Connect USB OTG SOF (Start of Frame) output to TIM2_ITR1 for calibration purposes.
  1488. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1489. * @retval None
  1490. */
  1491. __STATIC_INLINE void LL_GPIO_AF_Remap_TIM2ITR1_TO_USB(void)
  1492. {
  1493. SET_BIT(AFIO->MAPR, AFIO_MAPR_TIM2ITR1_IREMAP | AFIO_MAPR_SWJ_CFG);
  1494. }
  1495. /**
  1496. * @brief Control of TIM2_ITR1 internal mapping.
  1497. * @rmtoll MAPR TIM2ITR1_IREMAP LL_GPIO_AF_Remap_TIM2ITR1_TO_ETH
  1498. * @note TO_ETH: Connect TIM2_ITR1 internally to the Ethernet PTP output for calibration purposes.
  1499. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1500. * @retval None
  1501. */
  1502. __STATIC_INLINE void LL_GPIO_AF_Remap_TIM2ITR1_TO_ETH(void)
  1503. {
  1504. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_TIM2ITR1_IREMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1505. }
  1506. #endif
  1507. #if defined(AFIO_MAPR_PTP_PPS_REMAP)
  1508. /**
  1509. * @brief Enable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1510. * @rmtoll MAPR PTP_PPS_REMAP LL_GPIO_AF_EnableRemap_ETH_PTP_PPS
  1511. * @note ENABLE: PTP_PPS is output on PB5 pin.
  1512. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1513. * @retval None
  1514. */
  1515. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_ETH_PTP_PPS(void)
  1516. {
  1517. SET_BIT(AFIO->MAPR, AFIO_MAPR_PTP_PPS_REMAP | AFIO_MAPR_SWJ_CFG);
  1518. }
  1519. /**
  1520. * @brief Disable the remapping of ADC2_ETRGREG (ADC 2 External trigger regular conversion).
  1521. * @rmtoll MAPR PTP_PPS_REMAP LL_GPIO_AF_DisableRemap_ETH_PTP_PPS
  1522. * @note DISABLE: PTP_PPS not output on PB5 pin.
  1523. * @note This bit is available only in connectivity line devices and is reserved otherwise.
  1524. * @retval None
  1525. */
  1526. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_ETH_PTP_PPS(void)
  1527. {
  1528. MODIFY_REG(AFIO->MAPR, (AFIO_MAPR_PTP_PPS_REMAP | AFIO_MAPR_SWJ_CFG), AFIO_MAPR_SWJ_CFG);
  1529. }
  1530. #endif
  1531. #if defined(AFIO_MAPR2_TIM9_REMAP)
  1532. /**
  1533. * @brief Enable the remapping of TIM9_CH1 and TIM9_CH2.
  1534. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_EnableRemap_TIM9
  1535. * @note ENABLE: Remap (TIM9_CH1 on PE5 and TIM9_CH2 on PE6).
  1536. * @retval None
  1537. */
  1538. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM9(void)
  1539. {
  1540. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP);
  1541. }
  1542. /**
  1543. * @brief Disable the remapping of TIM9_CH1 and TIM9_CH2.
  1544. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_DisableRemap_TIM9
  1545. * @note DISABLE: No remap (TIM9_CH1 on PA2 and TIM9_CH2 on PA3).
  1546. * @retval None
  1547. */
  1548. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM9(void)
  1549. {
  1550. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP);
  1551. }
  1552. /**
  1553. * @brief Check if TIM9_CH1 and TIM9_CH2 have been remaped or not
  1554. * @rmtoll MAPR2 TIM9_REMAP LL_GPIO_AF_IsEnabledRemap_TIM9
  1555. * @retval State of bit (1 or 0).
  1556. */
  1557. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM9(void)
  1558. {
  1559. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM9_REMAP) == (AFIO_MAPR2_TIM9_REMAP));
  1560. }
  1561. #endif
  1562. #if defined(AFIO_MAPR2_TIM10_REMAP)
  1563. /**
  1564. * @brief Enable the remapping of TIM10_CH1.
  1565. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_EnableRemap_TIM10
  1566. * @note ENABLE: Remap (TIM10_CH1 on PF6).
  1567. * @retval None
  1568. */
  1569. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM10(void)
  1570. {
  1571. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP);
  1572. }
  1573. /**
  1574. * @brief Disable the remapping of TIM10_CH1.
  1575. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_DisableRemap_TIM10
  1576. * @note DISABLE: No remap (TIM10_CH1 on PB8).
  1577. * @retval None
  1578. */
  1579. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM10(void)
  1580. {
  1581. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP);
  1582. }
  1583. /**
  1584. * @brief Check if TIM10_CH1 has been remaped or not
  1585. * @rmtoll MAPR2 TIM10_REMAP LL_GPIO_AF_IsEnabledRemap_TIM10
  1586. * @retval State of bit (1 or 0).
  1587. */
  1588. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM10(void)
  1589. {
  1590. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM10_REMAP) == (AFIO_MAPR2_TIM10_REMAP));
  1591. }
  1592. #endif
  1593. #if defined(AFIO_MAPR2_TIM11_REMAP)
  1594. /**
  1595. * @brief Enable the remapping of TIM11_CH1.
  1596. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_EnableRemap_TIM11
  1597. * @note ENABLE: Remap (TIM11_CH1 on PF7).
  1598. * @retval None
  1599. */
  1600. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM11(void)
  1601. {
  1602. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP);
  1603. }
  1604. /**
  1605. * @brief Disable the remapping of TIM11_CH1.
  1606. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_DisableRemap_TIM11
  1607. * @note DISABLE: No remap (TIM11_CH1 on PB9).
  1608. * @retval None
  1609. */
  1610. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM11(void)
  1611. {
  1612. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP);
  1613. }
  1614. /**
  1615. * @brief Check if TIM11_CH1 has been remaped or not
  1616. * @rmtoll MAPR2 TIM11_REMAP LL_GPIO_AF_IsEnabledRemap_TIM11
  1617. * @retval State of bit (1 or 0).
  1618. */
  1619. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM11(void)
  1620. {
  1621. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM11_REMAP) == (AFIO_MAPR2_TIM11_REMAP));
  1622. }
  1623. #endif
  1624. #if defined(AFIO_MAPR2_TIM13_REMAP)
  1625. /**
  1626. * @brief Enable the remapping of TIM13_CH1.
  1627. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_EnableRemap_TIM13
  1628. * @note ENABLE: Remap STM32F100:(TIM13_CH1 on PF8). Others:(TIM13_CH1 on PB0).
  1629. * @retval None
  1630. */
  1631. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM13(void)
  1632. {
  1633. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP);
  1634. }
  1635. /**
  1636. * @brief Disable the remapping of TIM13_CH1.
  1637. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_DisableRemap_TIM13
  1638. * @note DISABLE: No remap STM32F100:(TIM13_CH1 on PA6). Others:(TIM13_CH1 on PC8).
  1639. * @retval None
  1640. */
  1641. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM13(void)
  1642. {
  1643. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP);
  1644. }
  1645. /**
  1646. * @brief Check if TIM13_CH1 has been remaped or not
  1647. * @rmtoll MAPR2 TIM13_REMAP LL_GPIO_AF_IsEnabledRemap_TIM13
  1648. * @retval State of bit (1 or 0).
  1649. */
  1650. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM13(void)
  1651. {
  1652. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM13_REMAP) == (AFIO_MAPR2_TIM13_REMAP));
  1653. }
  1654. #endif
  1655. #if defined(AFIO_MAPR2_TIM14_REMAP)
  1656. /**
  1657. * @brief Enable the remapping of TIM14_CH1.
  1658. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_EnableRemap_TIM14
  1659. * @note ENABLE: Remap STM32F100:(TIM14_CH1 on PB1). Others:(TIM14_CH1 on PF9).
  1660. * @retval None
  1661. */
  1662. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM14(void)
  1663. {
  1664. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP);
  1665. }
  1666. /**
  1667. * @brief Disable the remapping of TIM14_CH1.
  1668. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_DisableRemap_TIM14
  1669. * @note DISABLE: No remap STM32F100:(TIM14_CH1 on PC9). Others:(TIM14_CH1 on PA7).
  1670. * @retval None
  1671. */
  1672. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM14(void)
  1673. {
  1674. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP);
  1675. }
  1676. /**
  1677. * @brief Check if TIM14_CH1 has been remaped or not
  1678. * @rmtoll MAPR2 TIM14_REMAP LL_GPIO_AF_IsEnabledRemap_TIM14
  1679. * @retval State of bit (1 or 0).
  1680. */
  1681. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM14(void)
  1682. {
  1683. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM14_REMAP) == (AFIO_MAPR2_TIM14_REMAP));
  1684. }
  1685. #endif
  1686. #if defined(AFIO_MAPR2_FSMC_NADV_REMAP)
  1687. /**
  1688. * @brief Controls the use of the optional FSMC_NADV signal.
  1689. * @rmtoll MAPR2 FSMC_NADV LL_GPIO_AF_Disconnect_FSMCNADV
  1690. * @note DISCONNECTED: The NADV signal is not connected. The I/O pin can be used by another peripheral.
  1691. * @retval None
  1692. */
  1693. __STATIC_INLINE void LL_GPIO_AF_Disconnect_FSMCNADV(void)
  1694. {
  1695. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP);
  1696. }
  1697. /**
  1698. * @brief Controls the use of the optional FSMC_NADV signal.
  1699. * @rmtoll MAPR2 FSMC_NADV LL_GPIO_AF_Connect_FSMCNADV
  1700. * @note CONNECTED: The NADV signal is connected to the output (default).
  1701. * @retval None
  1702. */
  1703. __STATIC_INLINE void LL_GPIO_AF_Connect_FSMCNADV(void)
  1704. {
  1705. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_FSMC_NADV_REMAP);
  1706. }
  1707. #endif
  1708. #if defined(AFIO_MAPR2_TIM15_REMAP)
  1709. /**
  1710. * @brief Enable the remapping of TIM15_CH1 and TIM15_CH2.
  1711. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_EnableRemap_TIM15
  1712. * @note ENABLE: Remap (TIM15_CH1 on PB14 and TIM15_CH2 on PB15).
  1713. * @retval None
  1714. */
  1715. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM15(void)
  1716. {
  1717. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP);
  1718. }
  1719. /**
  1720. * @brief Disable the remapping of TIM15_CH1 and TIM15_CH2.
  1721. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_DisableRemap_TIM15
  1722. * @note DISABLE: No remap (TIM15_CH1 on PA2 and TIM15_CH2 on PA3).
  1723. * @retval None
  1724. */
  1725. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM15(void)
  1726. {
  1727. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP);
  1728. }
  1729. /**
  1730. * @brief Check if TIM15_CH1 has been remaped or not
  1731. * @rmtoll MAPR2 TIM15_REMAP LL_GPIO_AF_IsEnabledRemap_TIM15
  1732. * @retval State of bit (1 or 0).
  1733. */
  1734. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM15(void)
  1735. {
  1736. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM15_REMAP) == (AFIO_MAPR2_TIM15_REMAP));
  1737. }
  1738. #endif
  1739. #if defined(AFIO_MAPR2_TIM16_REMAP)
  1740. /**
  1741. * @brief Enable the remapping of TIM16_CH1.
  1742. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_EnableRemap_TIM16
  1743. * @note ENABLE: Remap (TIM16_CH1 on PA6).
  1744. * @retval None
  1745. */
  1746. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM16(void)
  1747. {
  1748. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP);
  1749. }
  1750. /**
  1751. * @brief Disable the remapping of TIM16_CH1.
  1752. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_DisableRemap_TIM16
  1753. * @note DISABLE: No remap (TIM16_CH1 on PB8).
  1754. * @retval None
  1755. */
  1756. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM16(void)
  1757. {
  1758. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP);
  1759. }
  1760. /**
  1761. * @brief Check if TIM16_CH1 has been remaped or not
  1762. * @rmtoll MAPR2 TIM16_REMAP LL_GPIO_AF_IsEnabledRemap_TIM16
  1763. * @retval State of bit (1 or 0).
  1764. */
  1765. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM16(void)
  1766. {
  1767. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM16_REMAP) == (AFIO_MAPR2_TIM16_REMAP));
  1768. }
  1769. #endif
  1770. #if defined(AFIO_MAPR2_TIM17_REMAP)
  1771. /**
  1772. * @brief Enable the remapping of TIM17_CH1.
  1773. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_EnableRemap_TIM17
  1774. * @note ENABLE: Remap (TIM17_CH1 on PA7).
  1775. * @retval None
  1776. */
  1777. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM17(void)
  1778. {
  1779. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP);
  1780. }
  1781. /**
  1782. * @brief Disable the remapping of TIM17_CH1.
  1783. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_DisableRemap_TIM17
  1784. * @note DISABLE: No remap (TIM17_CH1 on PB9).
  1785. * @retval None
  1786. */
  1787. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM17(void)
  1788. {
  1789. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP);
  1790. }
  1791. /**
  1792. * @brief Check if TIM17_CH1 has been remaped or not
  1793. * @rmtoll MAPR2 TIM17_REMAP LL_GPIO_AF_IsEnabledRemap_TIM17
  1794. * @retval State of bit (1 or 0).
  1795. */
  1796. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM17(void)
  1797. {
  1798. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM17_REMAP) == (AFIO_MAPR2_TIM17_REMAP));
  1799. }
  1800. #endif
  1801. #if defined(AFIO_MAPR2_CEC_REMAP)
  1802. /**
  1803. * @brief Enable the remapping of CEC.
  1804. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_EnableRemap_CEC
  1805. * @note ENABLE: Remap (CEC on PB10).
  1806. * @retval None
  1807. */
  1808. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_CEC(void)
  1809. {
  1810. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP);
  1811. }
  1812. /**
  1813. * @brief Disable the remapping of CEC.
  1814. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_DisableRemap_CEC
  1815. * @note DISABLE: No remap (CEC on PB8).
  1816. * @retval None
  1817. */
  1818. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_CEC(void)
  1819. {
  1820. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP);
  1821. }
  1822. /**
  1823. * @brief Check if CEC has been remaped or not
  1824. * @rmtoll MAPR2 CEC_REMAP LL_GPIO_AF_IsEnabledRemap_CEC
  1825. * @retval State of bit (1 or 0).
  1826. */
  1827. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_CEC(void)
  1828. {
  1829. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_CEC_REMAP) == (AFIO_MAPR2_CEC_REMAP));
  1830. }
  1831. #endif
  1832. #if defined(AFIO_MAPR2_TIM1_DMA_REMAP)
  1833. /**
  1834. * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
  1835. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_EnableRemap_TIM1DMA
  1836. * @note ENABLE: Remap (TIM1_CH1 DMA request/DMA1 Channel6, TIM1_CH2 DMA request/DMA1 Channel6)
  1837. * @retval None
  1838. */
  1839. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM1DMA(void)
  1840. {
  1841. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP);
  1842. }
  1843. /**
  1844. * @brief Controls the mapping of the TIM1_CH1 TIM1_CH2 DMA requests onto the DMA1 channels.
  1845. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_DisableRemap_TIM1DMA
  1846. * @note DISABLE: No remap (TIM1_CH1 DMA request/DMA1 Channel2, TIM1_CH2 DMA request/DMA1 Channel3).
  1847. * @retval None
  1848. */
  1849. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM1DMA(void)
  1850. {
  1851. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP);
  1852. }
  1853. /**
  1854. * @brief Check if TIM1DMA has been remaped or not
  1855. * @rmtoll MAPR2 TIM1_DMA_REMAP LL_GPIO_AF_IsEnabledRemap_TIM1DMA
  1856. * @retval State of bit (1 or 0).
  1857. */
  1858. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM1DMA(void)
  1859. {
  1860. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM1_DMA_REMAP) == (AFIO_MAPR2_TIM1_DMA_REMAP));
  1861. }
  1862. #endif
  1863. #if defined(AFIO_MAPR2_TIM67_DAC_DMA_REMAP)
  1864. /**
  1865. * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
  1866. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_EnableRemap_TIM67DACDMA
  1867. * @note ENABLE: Remap (TIM6_DAC1 DMA request/DMA1 Channel3, TIM7_DAC2 DMA request/DMA1 Channel4)
  1868. * @retval None
  1869. */
  1870. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM67DACDMA(void)
  1871. {
  1872. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP);
  1873. }
  1874. /**
  1875. * @brief Controls the mapping of the TIM6_DAC1 and TIM7_DAC2 DMA requests onto the DMA1 channels.
  1876. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_DisableRemap_TIM67DACDMA
  1877. * @note DISABLE: No remap (TIM6_DAC1 DMA request/DMA2 Channel3, TIM7_DAC2 DMA request/DMA2 Channel4)
  1878. * @retval None
  1879. */
  1880. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM67DACDMA(void)
  1881. {
  1882. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP);
  1883. }
  1884. /**
  1885. * @brief Check if TIM67DACDMA has been remaped or not
  1886. * @rmtoll MAPR2 TIM76_DAC_DMA_REMAP LL_GPIO_AF_IsEnabledRemap_TIM67DACDMA
  1887. * @retval State of bit (1 or 0).
  1888. */
  1889. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM67DACDMA(void)
  1890. {
  1891. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM67_DAC_DMA_REMAP) == (AFIO_MAPR2_TIM67_DAC_DMA_REMAP));
  1892. }
  1893. #endif
  1894. #if defined(AFIO_MAPR2_TIM12_REMAP)
  1895. /**
  1896. * @brief Enable the remapping of TIM12_CH1 and TIM12_CH2.
  1897. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_EnableRemap_TIM12
  1898. * @note ENABLE: Remap (TIM12_CH1 on PB12 and TIM12_CH2 on PB13).
  1899. * @note This bit is available only in high density value line devices.
  1900. * @retval None
  1901. */
  1902. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_TIM12(void)
  1903. {
  1904. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP);
  1905. }
  1906. /**
  1907. * @brief Disable the remapping of TIM12_CH1 and TIM12_CH2.
  1908. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_DisableRemap_TIM12
  1909. * @note DISABLE: No remap (TIM12_CH1 on PC4 and TIM12_CH2 on PC5).
  1910. * @note This bit is available only in high density value line devices.
  1911. * @retval None
  1912. */
  1913. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_TIM12(void)
  1914. {
  1915. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP);
  1916. }
  1917. /**
  1918. * @brief Check if TIM12_CH1 has been remaped or not
  1919. * @rmtoll MAPR2 TIM12_REMAP LL_GPIO_AF_IsEnabledRemap_TIM12
  1920. * @retval State of bit (1 or 0).
  1921. */
  1922. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_TIM12(void)
  1923. {
  1924. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_TIM12_REMAP) == (AFIO_MAPR2_TIM12_REMAP));
  1925. }
  1926. #endif
  1927. #if defined(AFIO_MAPR2_MISC_REMAP)
  1928. /**
  1929. * @brief Miscellaneous features remapping.
  1930. * This bit is set and cleared by software. It controls miscellaneous features.
  1931. * The DMA2 channel 5 interrupt position in the vector table.
  1932. * The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
  1933. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_EnableRemap_MISC
  1934. * @note ENABLE: DMA2 channel 5 interrupt is mapped separately at position 60 and TIM15 TRGO event is
  1935. * selected as DAC Trigger 3, TIM15 triggers TIM1/3.
  1936. * @note This bit is available only in high density value line devices.
  1937. * @retval None
  1938. */
  1939. __STATIC_INLINE void LL_GPIO_AF_EnableRemap_MISC(void)
  1940. {
  1941. SET_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP);
  1942. }
  1943. /**
  1944. * @brief Miscellaneous features remapping.
  1945. * This bit is set and cleared by software. It controls miscellaneous features.
  1946. * The DMA2 channel 5 interrupt position in the vector table.
  1947. * The timer selection for DAC trigger 3 (TSEL[2:0] = 011, for more details refer to the DAC_CR register).
  1948. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_DisableRemap_MISC
  1949. * @note DISABLE: DMA2 channel 5 interrupt is mapped with DMA2 channel 4 at position 59, TIM5 TRGO
  1950. * event is selected as DAC Trigger 3, TIM5 triggers TIM1/3.
  1951. * @note This bit is available only in high density value line devices.
  1952. * @retval None
  1953. */
  1954. __STATIC_INLINE void LL_GPIO_AF_DisableRemap_MISC(void)
  1955. {
  1956. CLEAR_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP);
  1957. }
  1958. /**
  1959. * @brief Check if MISC has been remaped or not
  1960. * @rmtoll MAPR2 MISC_REMAP LL_GPIO_AF_IsEnabledRemap_MISC
  1961. * @retval State of bit (1 or 0).
  1962. */
  1963. __STATIC_INLINE uint32_t LL_GPIO_AF_IsEnabledRemap_MISC(void)
  1964. {
  1965. return (READ_BIT(AFIO->MAPR2, AFIO_MAPR2_MISC_REMAP) == (AFIO_MAPR2_MISC_REMAP));
  1966. }
  1967. #endif
  1968. /**
  1969. * @}
  1970. */
  1971. /** @defgroup GPIO_AF_LL_EVENTOUT Output Event configuration
  1972. * @brief This section propose definition to Configure EVENTOUT Cortex feature .
  1973. * @{
  1974. */
  1975. /**
  1976. * @brief Configures the port and pin on which the EVENTOUT Cortex signal will be connected.
  1977. * @rmtoll EVCR PORT LL_GPIO_AF_ConfigEventout\n
  1978. * EVCR PIN LL_GPIO_AF_ConfigEventout
  1979. * @param LL_GPIO_PortSource This parameter can be one of the following values:
  1980. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_A
  1981. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_B
  1982. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_C
  1983. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_D
  1984. * @arg @ref LL_GPIO_AF_EVENTOUT_PORT_E
  1985. * @param LL_GPIO_PinSource This parameter can be one of the following values:
  1986. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_0
  1987. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_1
  1988. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_2
  1989. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_3
  1990. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_4
  1991. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_5
  1992. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_6
  1993. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_7
  1994. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_8
  1995. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_9
  1996. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_10
  1997. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_11
  1998. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_12
  1999. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_13
  2000. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_14
  2001. * @arg @ref LL_GPIO_AF_EVENTOUT_PIN_15
  2002. * @retval None
  2003. */
  2004. __STATIC_INLINE void LL_GPIO_AF_ConfigEventout(uint32_t LL_GPIO_PortSource, uint32_t LL_GPIO_PinSource)
  2005. {
  2006. MODIFY_REG(AFIO->EVCR, (AFIO_EVCR_PORT) | (AFIO_EVCR_PIN), (LL_GPIO_PortSource) | (LL_GPIO_PinSource));
  2007. }
  2008. /**
  2009. * @brief Enables the Event Output.
  2010. * @rmtoll EVCR EVOE LL_GPIO_AF_EnableEventout
  2011. * @retval None
  2012. */
  2013. __STATIC_INLINE void LL_GPIO_AF_EnableEventout(void)
  2014. {
  2015. SET_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  2016. }
  2017. /**
  2018. * @brief Disables the Event Output.
  2019. * @rmtoll EVCR EVOE LL_GPIO_AF_DisableEventout
  2020. * @retval None
  2021. */
  2022. __STATIC_INLINE void LL_GPIO_AF_DisableEventout(void)
  2023. {
  2024. CLEAR_BIT(AFIO->EVCR, AFIO_EVCR_EVOE);
  2025. }
  2026. /**
  2027. * @}
  2028. */
  2029. /** @defgroup GPIO_AF_LL_EXTI EXTI external interrupt
  2030. * @brief This section Configure source input for the EXTI external interrupt .
  2031. * @{
  2032. */
  2033. /**
  2034. * @brief Configure source input for the EXTI external interrupt.
  2035. * @rmtoll AFIO_EXTICR1 EXTIx LL_GPIO_AF_SetEXTISource\n
  2036. * AFIO_EXTICR2 EXTIx LL_GPIO_AF_SetEXTISource\n
  2037. * AFIO_EXTICR3 EXTIx LL_GPIO_AF_SetEXTISource\n
  2038. * AFIO_EXTICR4 EXTIx LL_GPIO_AF_SetEXTISource
  2039. * @param Port This parameter can be one of the following values:
  2040. * @arg @ref LL_GPIO_AF_EXTI_PORTA
  2041. * @arg @ref LL_GPIO_AF_EXTI_PORTB
  2042. * @arg @ref LL_GPIO_AF_EXTI_PORTC
  2043. * @arg @ref LL_GPIO_AF_EXTI_PORTD
  2044. * @arg @ref LL_GPIO_AF_EXTI_PORTE
  2045. * @arg @ref LL_GPIO_AF_EXTI_PORTF
  2046. * @arg @ref LL_GPIO_AF_EXTI_PORTG
  2047. * @param Line This parameter can be one of the following values:
  2048. * @arg @ref LL_GPIO_AF_EXTI_LINE0
  2049. * @arg @ref LL_GPIO_AF_EXTI_LINE1
  2050. * @arg @ref LL_GPIO_AF_EXTI_LINE2
  2051. * @arg @ref LL_GPIO_AF_EXTI_LINE3
  2052. * @arg @ref LL_GPIO_AF_EXTI_LINE4
  2053. * @arg @ref LL_GPIO_AF_EXTI_LINE5
  2054. * @arg @ref LL_GPIO_AF_EXTI_LINE6
  2055. * @arg @ref LL_GPIO_AF_EXTI_LINE7
  2056. * @arg @ref LL_GPIO_AF_EXTI_LINE8
  2057. * @arg @ref LL_GPIO_AF_EXTI_LINE9
  2058. * @arg @ref LL_GPIO_AF_EXTI_LINE10
  2059. * @arg @ref LL_GPIO_AF_EXTI_LINE11
  2060. * @arg @ref LL_GPIO_AF_EXTI_LINE12
  2061. * @arg @ref LL_GPIO_AF_EXTI_LINE13
  2062. * @arg @ref LL_GPIO_AF_EXTI_LINE14
  2063. * @arg @ref LL_GPIO_AF_EXTI_LINE15
  2064. * @retval None
  2065. */
  2066. __STATIC_INLINE void LL_GPIO_AF_SetEXTISource(uint32_t Port, uint32_t Line)
  2067. {
  2068. MODIFY_REG(AFIO->EXTICR[Line & 0xFF], (Line >> 16), Port << POSITION_VAL((Line >> 16)));
  2069. }
  2070. /**
  2071. * @brief Get the configured defined for specific EXTI Line
  2072. * @rmtoll AFIO_EXTICR1 EXTIx LL_GPIO_AF_GetEXTISource\n
  2073. * AFIO_EXTICR2 EXTIx LL_GPIO_AF_GetEXTISource\n
  2074. * AFIO_EXTICR3 EXTIx LL_GPIO_AF_GetEXTISource\n
  2075. * AFIO_EXTICR4 EXTIx LL_GPIO_AF_GetEXTISource
  2076. * @param Line This parameter can be one of the following values:
  2077. * @arg @ref LL_GPIO_AF_EXTI_LINE0
  2078. * @arg @ref LL_GPIO_AF_EXTI_LINE1
  2079. * @arg @ref LL_GPIO_AF_EXTI_LINE2
  2080. * @arg @ref LL_GPIO_AF_EXTI_LINE3
  2081. * @arg @ref LL_GPIO_AF_EXTI_LINE4
  2082. * @arg @ref LL_GPIO_AF_EXTI_LINE5
  2083. * @arg @ref LL_GPIO_AF_EXTI_LINE6
  2084. * @arg @ref LL_GPIO_AF_EXTI_LINE7
  2085. * @arg @ref LL_GPIO_AF_EXTI_LINE8
  2086. * @arg @ref LL_GPIO_AF_EXTI_LINE9
  2087. * @arg @ref LL_GPIO_AF_EXTI_LINE10
  2088. * @arg @ref LL_GPIO_AF_EXTI_LINE11
  2089. * @arg @ref LL_GPIO_AF_EXTI_LINE12
  2090. * @arg @ref LL_GPIO_AF_EXTI_LINE13
  2091. * @arg @ref LL_GPIO_AF_EXTI_LINE14
  2092. * @arg @ref LL_GPIO_AF_EXTI_LINE15
  2093. * @retval Returned value can be one of the following values:
  2094. * @arg @ref LL_GPIO_AF_EXTI_PORTA
  2095. * @arg @ref LL_GPIO_AF_EXTI_PORTB
  2096. * @arg @ref LL_GPIO_AF_EXTI_PORTC
  2097. * @arg @ref LL_GPIO_AF_EXTI_PORTD
  2098. * @arg @ref LL_GPIO_AF_EXTI_PORTE
  2099. * @arg @ref LL_GPIO_AF_EXTI_PORTF
  2100. * @arg @ref LL_GPIO_AF_EXTI_PORTG
  2101. */
  2102. __STATIC_INLINE uint32_t LL_GPIO_AF_GetEXTISource(uint32_t Line)
  2103. {
  2104. return (uint32_t)(READ_BIT(AFIO->EXTICR[Line & 0xFF], (Line >> 16)) >> POSITION_VAL(Line >> 16));
  2105. }
  2106. /**
  2107. * @}
  2108. */
  2109. #if defined(USE_FULL_LL_DRIVER)
  2110. /** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
  2111. * @{
  2112. */
  2113. ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
  2114. ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
  2115. void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
  2116. /**
  2117. * @}
  2118. */
  2119. #endif /* USE_FULL_LL_DRIVER */
  2120. /**
  2121. * @}
  2122. */
  2123. /**
  2124. * @}
  2125. */
  2126. #endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOF) || defined (GPIOG) */
  2127. /**
  2128. * @}
  2129. */
  2130. #ifdef __cplusplus
  2131. }
  2132. #endif
  2133. #endif /* STM32F1xx_LL_GPIO_H */
  2134. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/