stm32f1xx_ll_gpio.h 86 KB

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