1
0

stm32f1xx_ll_gpio.h 86 KB

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