stm32f1xx_ll_gpio.h 86 KB

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