stm32l0xx_hal_gpio_ex.h 123 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_hal_gpio_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of GPIO HAL Extension module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32L0xx_HAL_GPIO_EX_H
  20. #define __STM32L0xx_HAL_GPIO_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32l0xx_hal_def.h"
  26. /** @addtogroup STM32L0xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup GPIOEx GPIOEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /* Exported constants --------------------------------------------------------*/
  34. /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
  35. * @{
  36. */
  37. /*----------------------------------------------------------------------------*/
  38. /*------------------------- STM32L083xx/STM32L073xx---------------------------*/
  39. /*----------------------------------------------------------------------------*/
  40. #if defined (STM32L083xx) || defined (STM32L073xx)
  41. /* The table below gives an overview of the different alternate functions per port.
  42. * For more details refer yourself to the product data sheet.
  43. *
  44. */
  45. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  46. *______________________________________________________________________________
  47. * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR |USART4 |COMP1 |
  48. * PA1 |EVENTOUT|LCD |TIM2_C2 |TSC |USART2 |TIM21_TR|USART4 | |
  49. * PA2 |TIM21_C1|LCD |TIM2_C3 |TSC |USART2 | |LPUART1 |COMP2 |
  50. * PA3 |TIM21_C2|LCD |TIM2_C4 |TSC |USART2 | |LPUART1 | |
  51. * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | |
  52. * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | |
  53. * PA6 |SPI1 |LCD |TIM3_C1 |TSC |LPUART1 |TIM22_C1|EVENTOUT|COMP1 |
  54. * PA7 |SPI1 |LCD |TIM3_C2 |TSC | |TIM22_C2|EVENTOUT|COMP2 |
  55. * PA8 |MCO |LCD |USB |EVENTOUT|USART1 | | |I2C3 |
  56. * PA9 |MCO |LCD | |TSC |USART1 | |I2C1 |I2C3 |
  57. * PA10| |LCD | |TSC |USART1 | |I2C1 | |
  58. * PA11|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP1 |
  59. * PA12|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP2 |
  60. * PA13|SWDIO | |USB | | | |LPUART1 | |
  61. * PA14|SWCLK | | | |USART2 | |LPUART1 | |
  62. * PA15|SPI1 |LCD |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | |
  63. *______________________________________________________________________________
  64. * PB0 |EVENTOUT|LCD |TIM3_C3 |TSC | | | | |
  65. * PB1 | |LCD |TIM3_C4 |TSC |LPUART1 | | | |
  66. * PB2 | | |LPTIM1_O|TSC | | | |I2C3 |
  67. * PB3 |SPI1 |LCD |TIM2_C2 |TSC |EVENTOUT|USART1 |USART5 | |
  68. * PB4 |SPI1 |LCD |TIM3_C1 |TSC |TIM22_C1|USART1 |USART5 |I2C3 |
  69. * PB5 |SPI1 |LCD |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | |
  70. * | | | | |TIM22_C2| | | |
  71. * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | |
  72. * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | |USART4 | |
  73. * PB8 | |LCD | |TSC |I2C1 | | | |
  74. * PB9 | |LCD |EVENTOUT| |I2C1 |SPI2 | | |
  75. * PB10| |LCD |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 |LPUART1 |
  76. * PB11|EVENTOUT|LCD |TIM2_C4 |TSC |LPUART1 | |I2C2 |LPUART1 |
  77. * PB12|SPI2 |LCD |LPUART1 |TSC | |I2C2 |EVENTOUT| |
  78. * PB13|SPI2 |LCD |MCO |TSC |LPUART1 |I2C2 |TIM21_C1| |
  79. * PB14|SPI2 |LCD |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| |
  80. * PB15|SPI2 |LCD |RTC | | | | | |
  81. *______________________________________________________________________________
  82. * PC0 |LPTIM1_I|LCD |EVENTOUT|TSC | | |LPUART1 |I2C3 |
  83. * PC1 |LPTIM1_O|LCD |EVENTOUT|TSC | | |LPUART1 |I2C3 |
  84. * PC2 |LPTIM1_I|LCD |SPI2 |TSC | | | | |
  85. * PC3 |LPTIM1_T|LCD |SPI2 |TSC | | | | |
  86. * PC4 |EVENTOUT|LCD |LPUART1 | | | | | |
  87. * PC5 | |LCD |LPUART1 |TSC | | | | |
  88. * PC6 |TIM22_C1|LCD |TIM3_C1 |TSC | | | | |
  89. * PC7 |TIM22_C2|LCD |TIM3_C2 |TSC | | | | |
  90. * PC8 |TIM22_TR|LCD |TIM3_C3 |TSC | | | | |
  91. * PC9 |TIM21_TR|LCD |USB |TSC | | | |I2C3 |
  92. * | | |TIM3_C4 | | | | | |
  93. * PC10|LPUART1 |LCD | | | | |USART4 | |
  94. * PC11|LPUART1 |LCD | | | | |USART4 | |
  95. * PC12| |LCD |USART5 | | | |USART4 | |
  96. * PC13| | | | | | | | |
  97. * PC14| | | | | | | | |
  98. * PC15| | | | | | | | |
  99. *______________________________________________________________________________
  100. * PD0 |TIM21_C1|SPI2 | | | | | | |
  101. * PD1 | |SPI2 | | | | | | |
  102. * PD2 |LPUART1 |LCD |TIM3_TR | | | |USART5 | |
  103. * PD3 |USART2 |LCD |SPI2 | | | | | |
  104. * PD4 |USART2 |SPI2 | | | | | | |
  105. * PD5 |USART2 | | | | | | | |
  106. * PD6 |USART2 | | | | | | | |
  107. * PD7 |USART2 |TIM21_C2| | | | | | |
  108. * PD8 |LPUART1 |LCD | | | | | | |
  109. * PD9 |LPUART1 |LCD | | | | | | |
  110. * PD10| |LCD | | | | | | |
  111. * PD11|LPUART1 |LCD | | | | | | |
  112. * PD12|LPUART1 |LCD | | | | | | |
  113. * PD13| |LCD | | | | | | |
  114. * PD14| |LCD | | | | | | |
  115. * PD15|USB |LCD | | | | | | |
  116. *______________________________________________________________________________
  117. * PE0 | |LCD |EVENTOUT| | | | | |
  118. * PE1 | |LCD |EVENTOUT| | | | | |
  119. * PE2 | |LCD |TIM3_TR | | | | | |
  120. * PE3 |TIM22_C1|LCD |TIM3_C1 | | | | | |
  121. * PE4 |TIM22_C2| |TIM3_C2 | | | | | |
  122. * PE5 |TIM21_C1| |TIM3_C3 | | | | | |
  123. * PE6 |TIM21_C2| |TIM3_C4 | | | | | |
  124. * PE7 | |LCD | | | | |USART5 | |
  125. * PE8 | |LCD | | | | |USART4 | |
  126. * PE9 |TIM2_C1 |LCD |TIM2_TR | | | |USART4 | |
  127. * PE10|TIM2_C2 |LCD | | | | |USART5 | |
  128. * PE11|TIM2_C3 | | | | | |USART5 | |
  129. * PE12|TIM2_C4 | |SPI1 | | | | | |
  130. * PE13| |LCD |SPI1 | | | | | |
  131. * PE14| |LCD |SPI1 | | | | | |
  132. * PE15| |LCD |SPI1 | | | | | |
  133. *______________________________________________________________________________
  134. * PH0 |USB | | | | | | | |
  135. * PH1 | | | | | | | | |
  136. * PH9 | | | | | | | | |
  137. * PH10| | | | | | | | |
  138. *
  139. */
  140. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  141. * @{
  142. */
  143. /*
  144. * Alternate function AF0
  145. */
  146. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  147. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  148. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  149. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  150. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  151. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  152. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  153. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  154. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  155. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  156. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  157. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  158. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  159. #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  160. /**
  161. *
  162. */
  163. /*
  164. * Alternate function AF1
  165. */
  166. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  167. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  168. #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */
  169. #define GPIO_AF1_LCD ((uint8_t)0x01U) /* LCD Alternate Function mapping */
  170. /**
  171. *
  172. */
  173. /*
  174. * Alternate function AF2
  175. */
  176. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  177. #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */
  178. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  179. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  180. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  181. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  182. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  183. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  184. #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */
  185. #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */
  186. #define GPIO_AF2_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  187. /**
  188. *
  189. */
  190. /*
  191. * Alternate function AF3
  192. */
  193. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  194. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  195. #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */
  196. /**
  197. *
  198. */
  199. /*
  200. * Alternate function AF4
  201. */
  202. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  203. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  204. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  205. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping*/
  206. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  207. #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */
  208. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  209. /**
  210. *
  211. */
  212. /*
  213. * Alternate function AF5
  214. */
  215. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  216. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  217. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  218. #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */
  219. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  220. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  221. /**
  222. *
  223. */
  224. /*
  225. * Alternate function AF6
  226. */
  227. #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */
  228. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  229. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  230. #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */
  231. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  232. #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */
  233. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  234. /**
  235. *
  236. */
  237. /*
  238. * Alternate function AF7
  239. */
  240. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  241. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  242. #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */
  243. #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */
  244. /**
  245. *
  246. */
  247. /**
  248. * @}
  249. */
  250. /**
  251. * @}
  252. */
  253. /** @defgroup GPIOEx_Private GPIOEx Private
  254. * @{
  255. */
  256. /**
  257. * IS_GPIO_AF macro definition
  258. */
  259. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  260. /**
  261. * @}
  262. */
  263. #endif /* (STM32L083xx) || (STM32L073xx) */
  264. /*----------------------------------------------------------------------------*/
  265. /*------------------------- STM32L082xx and STM32L072xx-----------------------*/
  266. /*----------------------------------------------------------------------------*/
  267. #if defined (STM32L082xx) || defined (STM32L072xx)
  268. /* The table below gives an overview of the different alternate functions per port.
  269. * For more details refer yourself to the product data sheet.
  270. */
  271. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  272. *______________________________________________________________________________
  273. * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR |USART4 |COMP1 |
  274. * PA1 |EVENTOUT| |TIM2_C2 |TSC |USART2 |TIM21_TR|USART4 | |
  275. * PA2 |TIM21_C1| |TIM2_C3 |TSC |USART2 | |LPUART1 |COMP2 |
  276. * PA3 |TIM21_C2| |TIM2_C4 |TSC |USART2 | |LPUART1 | |
  277. * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | |
  278. * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | |
  279. * PA6 |SPI1 | |TIM3_C1 |TSC |LPUART1 |TIM22_C1|EVENTOUT|COMP1 |
  280. * PA7 |SPI1 | |TIM3_C2 |TSC | |TIM22_C2|EVENTOUT|COMP2 |
  281. * PA8 |MCO | |USB |EVENTOUT|USART1 | | |I2C3 |
  282. * PA9 |MCO | | |TSC |USART1 | |I2C1 |I2C3 |
  283. * PA10| | | |TSC |USART1 | |I2C1 | |
  284. * PA11|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP1 |
  285. * PA12|SPI1 | |EVENTOUT|TSC |USART1 | |I2C2 |COMP2 |
  286. * PA13|SWDIO | |USB | | | |LPUART1 | |
  287. * PA14|SWCLK | | | |USART2 | |LPUART1 | |
  288. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | |
  289. *______________________________________________________________________________
  290. * PB0 |EVENTOUT| |TIM3_C3 |TSC | | | | |
  291. * PB1 | | |TIM3_C4 |TSC |LPUART1 | | | |
  292. * PB2 | | |LPTIM1_O|TSC | | | |I2C3 |
  293. * PB3 |SPI1 | |TIM2_C2 |TSC |EVENTOUT|USART1 |USART5 | |
  294. * PB4 |SPI1 | |TIM3_C1 |TSC |TIM22_C1|USART1 |USART5 |I2C3 |
  295. * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | |
  296. * | | | | |TIM22_C2| | | |
  297. * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | |
  298. * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | |USART4 | |
  299. * PB8 | | | |TSC |I2C1 | | | |
  300. * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | |
  301. * PB10| | |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 |LPUART1 |
  302. * PB11|EVENTOUT| |TIM2_C4 |TSC |LPUART1 | |I2C2 |LPUART1 |
  303. * PB12|SPI2 | |LPUART1 |TSC | |I2C2 |EVENTOUT| |
  304. * PB13|SPI2 | |MCO |TSC |LPUART1 |I2C2 |TIM21_C1| |
  305. * PB14|SPI2 | |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| |
  306. * PB15|SPI2 | |RTC | | | | | |
  307. *______________________________________________________________________________
  308. * PC0 |LPTIM1_I| |EVENTOUT|TSC | | |LPUART1 |I2C3 |
  309. * PC1 |LPTIM1_O| |EVENTOUT|TSC | | |LPUART1 |I2C3 |
  310. * PC2 |LPTIM1_I| |SPI2 |TSC | | | | |
  311. * PC3 |LPTIM1_T| |SPI2 |TSC | | | | |
  312. * PC4 |EVENTOUT| |LPUART1 | | | | | |
  313. * PC5 | | |LPUART1 |TSC | | | | |
  314. * PC6 |TIM22_C1| |TIM3_C1 |TSC | | | | |
  315. * PC7 |TIM22_C2| |TIM3_C2 |TSC | | | | |
  316. * PC8 |TIM22_TR| |TIM3_C3 |TSC | | | | |
  317. * PC9 |TIM21_TR| |USB |TSC | | | |I2C3 |
  318. * | | |TIM3_C4 | | | | | |
  319. * PC10|LPUART1 | | | | | |USART4 | |
  320. * PC11|LPUART1 | | | | | |USART4 | |
  321. * PC12| | |USART5 | | | |USART4 | |
  322. * PC13| | | | | | | | |
  323. * PC14| | | | | | | | |
  324. * PC15| | | | | | | | |
  325. *______________________________________________________________________________
  326. * PD0 |TIM21_C1|SPI2 | | | | | | |
  327. * PD1 | |SPI2 | | | | | | |
  328. * PD2 |LPUART1 | |TIM3_TR | | | |USART5 | |
  329. * PD3 |USART2 | |SPI2 | | | | | |
  330. * PD4 |USART2 |SPI2 | | | | | | |
  331. * PD5 |USART2 | | | | | | | |
  332. * PD6 |USART2 | | | | | | | |
  333. * PD7 |USART2 |TIM21_C2| | | | | | |
  334. * PD8 |LPUART1 | | | | | | | |
  335. * PD9 |LPUART1 | | | | | | | |
  336. * PD10| | | | | | | | |
  337. * PD11|LPUART1 | | | | | | | |
  338. * PD12|LPUART1 | | | | | | | |
  339. * PD13| | | | | | | | |
  340. * PD14| | | | | | | | |
  341. * PD15|USB | | | | | | | |
  342. *______________________________________________________________________________
  343. * PE0 | | |EVENTOUT| | | | | |
  344. * PE1 | | |EVENTOUT| | | | | |
  345. * PE2 | | |TIM3_TR | | | | | |
  346. * PE3 |TIM22_C1| |TIM3_C1 | | | | | |
  347. * PE4 |TIM22_C2| |TIM3_C2 | | | | | |
  348. * PE5 |TIM21_C1| |TIM3_C3 | | | | | |
  349. * PE6 |TIM21_C2| |TIM3_C4 | | | | | |
  350. * PE7 | | | | | | |USART5 | |
  351. * PE8 | | | | | | |USART4 | |
  352. * PE9 |TIM2_C1 | |TIM2_TR | | | |USART4 | |
  353. * PE10|TIM2_C2 | | | | | |USART5 | |
  354. * PE11|TIM2_C3 | | | | | |USART5 | |
  355. * PE12|TIM2_C4 | |SPI1 | | | | | |
  356. * PE13| | |SPI1 | | | | | |
  357. * PE14| | |SPI1 | | | | | |
  358. * PE15| | |SPI1 | | | | | |
  359. *______________________________________________________________________________
  360. * PH0 |USB | | | | | | | |
  361. * PH1 | | | | | | | | |
  362. * PH9 | | | | | | | | |
  363. * PH10| | | | | | | | |
  364. *
  365. */
  366. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  367. * @{
  368. */
  369. /*
  370. * Alternate function AF0
  371. */
  372. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  373. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  374. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  375. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  376. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  377. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  378. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  379. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  380. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  381. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  382. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  383. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  384. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  385. #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  386. /**
  387. *
  388. */
  389. /*
  390. * Alternate function AF1
  391. */
  392. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  393. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  394. #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */
  395. /**
  396. *
  397. */
  398. /*
  399. * Alternate function AF2
  400. */
  401. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  402. #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */
  403. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  404. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  405. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  406. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  407. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  408. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  409. #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */
  410. #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */
  411. #define GPIO_AF2_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  412. /**
  413. *
  414. */
  415. /*
  416. * Alternate function AF3
  417. */
  418. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  419. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  420. #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */
  421. /**
  422. *
  423. */
  424. /*
  425. * Alternate function AF4
  426. */
  427. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  428. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  429. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  430. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  431. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  432. #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */
  433. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  434. /**
  435. *
  436. */
  437. /*
  438. * Alternate function AF5
  439. */
  440. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  441. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  442. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  443. #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */
  444. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  445. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  446. /**
  447. *
  448. */
  449. /*
  450. * Alternate function AF6
  451. */
  452. #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */
  453. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  454. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  455. #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */
  456. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  457. #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */
  458. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  459. /**
  460. *
  461. */
  462. /*
  463. * Alternate function AF7
  464. */
  465. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  466. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  467. #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */
  468. #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */
  469. /**
  470. *
  471. */
  472. /**
  473. * @}
  474. */
  475. /**
  476. * @}
  477. */
  478. /** @defgroup GPIOEx_Private GPIOEx Private
  479. * @{
  480. */
  481. /**
  482. * @brief IS_GPIO_AF macro definition
  483. */
  484. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  485. /**
  486. * @}
  487. */
  488. #endif /* (STM32L082xx) || (STM32L072xx) */
  489. /*----------------------------------------------------------------------------*/
  490. /*------------------------- STM32L081xx and STM32L071xx-----------------------*/
  491. /*----------------------------------------------------------------------------*/
  492. #if defined (STM32L081xx) || defined (STM32L071xx)
  493. /* The table below gives an overview of the different alternate functions per port.
  494. * For more details refer yourself to the product data sheet.
  495. *
  496. */
  497. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  498. *______________________________________________________________________________
  499. * PA0 | | |TIM2_C1 | |USART2 |TIM2_TR |USART4 |COMP1 |
  500. * PA1 |EVENTOUT| |TIM2_C2 | |USART2 |TIM21_TR|USART4 | |
  501. * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | |LPUART1 |COMP2 |
  502. * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | |LPUART1 | |
  503. * PA4 |SPI1 | | | |USART2 |TIM22_TR| | |
  504. * PA5 |SPI1 | |TIM2_TR | | |TIM2_C1 | | |
  505. * PA6 |SPI1 | |TIM3_C1 | |LPUART1 |TIM22_C1|EVENTOUT|COMP1 |
  506. * PA7 |SPI1 | |TIM3_C2 | | |TIM22_C2|EVENTOUT|COMP2 |
  507. * PA8 |MCO | | |EVENTOUT|USART1 | | |I2C3 |
  508. * PA9 |MCO | | | |USART1 | |I2C1 |I2C3 |
  509. * PA10| | | | |USART1 | |I2C1 | |
  510. * PA11|SPI1 | |EVENTOUT| |USART1 | |I2C2 |COMP1 |
  511. * PA12|SPI1 | |EVENTOUT| |USART1 | |I2C2 |COMP2 |
  512. * PA13|SWDIO | | | | | |LPUART1 | |
  513. * PA14|SWCLK | | | |USART2 | |LPUART1 | |
  514. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 |USART4 | |
  515. *______________________________________________________________________________
  516. * PB0 |EVENTOUT| |TIM3_C3 | | | | | |
  517. * PB1 | | |TIM3_C4 | |LPUART1 | | | |
  518. * PB2 | | |LPTIM1_O| | | | |I2C3 |
  519. * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT|USART1 |USART5 | |
  520. * PB4 |SPI1 | |TIM3_C1 | |TIM22_C1|USART1 |USART5 |I2C3 |
  521. * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM3_C2 |USART1 |USART5 | |
  522. * | | | | |TIM22_C2| | | |
  523. * PB6 |USART1 |I2C1 |LPTIM1_T| | | | | |
  524. * PB7 |USART1 |I2C1 |LPTIM1_I| | | |USART4 | |
  525. * PB8 | | | | |I2C1 | | | |
  526. * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | |
  527. * PB10| | |TIM2_C3 | |LPUART1 |SPI2 |I2C2 |LPUART1 |
  528. * PB11|EVENTOUT| |TIM2_C4 | |LPUART1 | |I2C2 |LPUART1 |
  529. * PB12|SPI2 | |LPUART1 | | |I2C2 |EVENTOUT| |
  530. * PB13|SPI2 | |MCO | |LPUART1 |I2C2 |TIM21_C1| |
  531. * PB14|SPI2 | |RTC | |LPUART1 |I2C2 |TIM21_C2| |
  532. * PB15|SPI2 | |RTC | | | | | |
  533. *______________________________________________________________________________
  534. * PC0 |LPTIM1_I| |EVENTOUT| | | |LPUART1 |I2C3 |
  535. * PC1 |LPTIM1_O| |EVENTOUT| | | |LPUART1 |I2C3 |
  536. * PC2 |LPTIM1_I| |SPI2 | | | | | |
  537. * PC3 |LPTIM1_T| |SPI2 | | | | | |
  538. * PC4 |EVENTOUT| |LPUART1 | | | | | |
  539. * PC5 | | |LPUART1 | | | | | |
  540. * PC6 |TIM22_C1| |TIM3_C1 | | | | | |
  541. * PC7 |TIM22_C2| |TIM3_C2 | | | | | |
  542. * PC8 |TIM22_TR| |TIM3_C3 | | | | | |
  543. * PC9 |TIM21_TR| | | | | | |I2C3 |
  544. * | | |TIM3_C4 | | | | | |
  545. * PC10|LPUART1 | | | | | |USART4 | |
  546. * PC11|LPUART1 | | | | | |USART4 | |
  547. * PC12| | |USART5 | | | |USART4 | |
  548. * PC13| | | | | | | | |
  549. * PC14| | | | | | | | |
  550. * PC15| | | | | | | | |
  551. *______________________________________________________________________________
  552. * PD0 |TIM21_C1|SPI2 | | | | | | |
  553. * PD1 | |SPI2 | | | | | | |
  554. * PD2 |LPUART1 | |TIM3_TR | | | |USART5 | |
  555. * PD3 |USART2 | |SPI2 | | | | | |
  556. * PD4 |USART2 |SPI2 | | | | | | |
  557. * PD5 |USART2 | | | | | | | |
  558. * PD6 |USART2 | | | | | | | |
  559. * PD7 |USART2 |TIM21_C2| | | | | | |
  560. * PD8 |LPUART1 | | | | | | | |
  561. * PD9 |LPUART1 | | | | | | | |
  562. * PD10| | | | | | | | |
  563. * PD11|LPUART1 | | | | | | | |
  564. * PD12|LPUART1 | | | | | | | |
  565. * PD13| | | | | | | | |
  566. * PD14| | | | | | | | |
  567. * PD15| | | | | | | | |
  568. *______________________________________________________________________________
  569. * PE0 | | |EVENTOUT| | | | | |
  570. * PE1 | | |EVENTOUT| | | | | |
  571. * PE2 | | |TIM3_TR | | | | | |
  572. * PE3 |TIM22_C1| |TIM3_C1 | | | | | |
  573. * PE4 |TIM22_C2| |TIM3_C2 | | | | | |
  574. * PE5 |TIM21_C1| |TIM3_C3 | | | | | |
  575. * PE6 |TIM21_C2| |TIM3_C4 | | | | | |
  576. * PE7 | | | | | | |USART5 | |
  577. * PE8 | | | | | | |USART4 | |
  578. * PE9 |TIM2_C1 | |TIM2_TR | | | |USART4 | |
  579. * PE10|TIM2_C2 | | | | | |USART5 | |
  580. * PE11|TIM2_C3 | | | | | |USART5 | |
  581. * PE12|TIM2_C4 | |SPI1 | | | | | |
  582. * PE13| | |SPI1 | | | | | |
  583. * PE14| | |SPI1 | | | | | |
  584. * PE15| | |SPI1 | | | | | |
  585. *______________________________________________________________________________
  586. * PH0 | | | | | | | | |
  587. * PH1 | | | | | | | | |
  588. * PH9 | | | | | | | | |
  589. * PH10| | | | | | | | |
  590. *
  591. */
  592. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  593. * @{
  594. */
  595. /*
  596. * Alternate function AF0
  597. *
  598. */
  599. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  600. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  601. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  602. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  603. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  604. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  605. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  606. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  607. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  608. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  609. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  610. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  611. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  612. /**
  613. *
  614. */
  615. /*
  616. * Alternate function AF1
  617. *
  618. */
  619. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  620. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  621. #define GPIO_AF1_TIM21 ((uint8_t)0x01U) /* TIM21 Alternate Function mapping */
  622. /**
  623. *
  624. */
  625. /*
  626. * Alternate function AF2
  627. *
  628. */
  629. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  630. #define GPIO_AF2_TIM3 ((uint8_t)0x02U) /* TIM3 Alternate Function mapping */
  631. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  632. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  633. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  634. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  635. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  636. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  637. #define GPIO_AF2_USART5 ((uint8_t)0x02U) /* USART5 Alternate Function mapping */
  638. #define GPIO_AF2_SPI1 ((uint8_t)0x02U) /* SPI1 Alternate Function mapping */
  639. /**
  640. *
  641. */
  642. /*
  643. * Alternate function AF3
  644. * @{
  645. */
  646. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  647. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  648. /**
  649. *
  650. */
  651. /*
  652. * Alternate function AF4
  653. *
  654. */
  655. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  656. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  657. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  658. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  659. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  660. #define GPIO_AF4_TIM3 ((uint8_t)0x04U) /* TIM3 Alternate Function mapping */
  661. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  662. /**
  663. *
  664. */
  665. /*
  666. * Alternate function AF5
  667. *
  668. */
  669. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  670. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  671. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  672. #define GPIO_AF5_USART1 ((uint8_t)0x05U) /* USART1 Alternate Function mapping */
  673. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  674. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  675. /**
  676. *
  677. */
  678. /*
  679. * Alternate function AF6
  680. *
  681. */
  682. #define GPIO_AF6_USART4 ((uint8_t)0x06U) /* USART4 Alternate Function mapping */
  683. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  684. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  685. #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */
  686. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  687. #define GPIO_AF6_USART5 ((uint8_t)0x06U) /* USART5 Alternate Function mapping */
  688. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  689. /**
  690. *
  691. */
  692. /*
  693. * Alternate function AF7
  694. *
  695. */
  696. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  697. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  698. #define GPIO_AF7_I2C3 ((uint8_t)0x07U) /* I2C3 Alternate Function mapping */
  699. #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */
  700. /**
  701. *
  702. */
  703. /**
  704. * @}
  705. */
  706. /**
  707. * @}
  708. */
  709. /** @defgroup GPIOEx_Private GPIOEx Private
  710. * @{
  711. */
  712. /**
  713. * IS_GPIO_AF macro definition
  714. */
  715. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  716. /**
  717. * @}
  718. */
  719. #endif /* (STM32L081xx) || (STM32L071xx) */
  720. /*----------------------------------------------------------------------------*/
  721. /*------------------------- STM32L053xx/STM32L063xx---------------------------*/
  722. /*----------------------------------------------------------------------------*/
  723. #if defined (STM32L053xx) || defined (STM32L063xx)
  724. /* The table below gives an overview of the different alternate functions per port.
  725. * For more details refer yourself to the product data sheet.
  726. *
  727. */
  728. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  729. *______________________________________________________________________________
  730. * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR | |COMP1 |
  731. * PA1 |EVENTOUT|LCD |TIM2_C2 |TSC |USART2 |TIM21_TR| | |
  732. * PA2 |TIM21_C1|LCD |TIM2_C3 |TSC |USART2 | | |COMP2 |
  733. * PA3 |TIM21_C2|LCD |TIM2_C4 |TSC |USART2 | | | |
  734. * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | |
  735. * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | |
  736. * PA6 |SPI1 |LCD | |TSC |LPUART |TIM22_C1|EVENTOUT|COMP1 |
  737. * PA7 |SPI1 |LCD | |TSC | |TIM22_C2|EVENTOUT|COMP2 |
  738. * PA8 |MCO |LCD |USB |EVENTOUT|USART1 | | | |
  739. * PA9 |MCO |LCD | |TSC |USART1 | | | |
  740. * PA10| |LCD | |TSC |USART1 | | | |
  741. * PA11|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP1 |
  742. * PA12|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP2 |
  743. * PA13|SWDIO | |USB | | | | | |
  744. * PA14|SWCLK | | | |USART2 | | | |
  745. * PA15|SPI1 |LCD |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | |
  746. *______________________________________________________________________________
  747. * PB0 |EVENTOUT|LCD | |TSC | | | | |
  748. * PB1 | |LCD | |TSC |LPUART1 | | | |
  749. * PB2 | | |LPTIM1_O|TSC | | | | |
  750. * PB3 |SPI1 |LCD |TIM2_C2 |TSC |EVENTOUT| | | |
  751. * PB4 |SPI1 |LCD |EVENTOUT|TSC |TIM22_C1| | | |
  752. * PB5 |SPI1 |LCD |LPTIM1_I|I2C1 |TIM22_C2| | | |
  753. * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | |
  754. * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | | | |
  755. * PB8 | |LCD | |TSC |I2C1 | | | |
  756. * PB9 | |LCD |EVENTOUT| |I2C1 |SPI2 | | |
  757. * PB10| |LCD |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 | |
  758. * PB11|EVENTOUT|LCD |TIM2_C4 |TSC |LPUART1 | |I2C2 | |
  759. * PB12|SPI2 |LCD |LPUART1 |TSC | |I2C2 |EVENTOUT| |
  760. * PB13|SPI2 |LCD | |TSC |LPUART1 |I2C2 |TIM21_C1| |
  761. * PB14|SPI2 |LCD |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| |
  762. * PB15|SPI2 |LCD |RTC | | | | | |
  763. *______________________________________________________________________________
  764. * PC0 |LPTIM1_I|LCD |EVENTOUT|TSC | | | | |
  765. * PC1 |LPTIM1_O|LCD |EVENTOUT|TSC | | | | |
  766. * PC2 |LPTIM1_I|LCD |SPI2 |TSC | | | | |
  767. * PC3 |LPTIM1_T|LCD |SPI2 |TSC | | | | |
  768. * PC4 |EVENTOUT|LCD |LPUART | | | | | |
  769. * PC5 | |LCD |LPUART |TSC | | | | |
  770. * PC6 |TIM22_C1|LCD | |TSC | | | | |
  771. * PC7 |TIM22_C2|LCD | |TSC | | | | |
  772. * PC8 |TIM22_TR|LCD | |TSC | | | | |
  773. * PC9 |TIM21_TR|LCD |USB |TSC | | | | |
  774. * PC10|LPUART |LCD | | | | | | |
  775. * PC11|LPUART |LCD | | | | | | |
  776. * PC12| |LCD | | | | | | |
  777. * PC13| | | | | | | | |
  778. * PC14| | | | | | | | |
  779. * PC15| | | | | | | | |
  780. *______________________________________________________________________________
  781. * PD2 |LPUART |LCD | | | | | | |
  782. *______________________________________________________________________________
  783. * PH0 |USB | | | | | | | |
  784. * PH1 | | | | | | | | |
  785. * *
  786. */
  787. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  788. * @{
  789. */
  790. /*
  791. * Alternate function AF0
  792. */
  793. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  794. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  795. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  796. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  797. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  798. #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  799. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  800. #define GPIO_AF0_TSC ((uint8_t)0x00U) /* TSC Alternate Function mapping */
  801. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  802. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  803. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  804. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  805. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  806. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  807. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  808. /**
  809. *
  810. */
  811. /*
  812. * Alternate function AF1
  813. */
  814. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  815. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  816. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  817. #define GPIO_AF1_LCD ((uint8_t)0x01U) /* LCD Alternate Function mapping */
  818. /**
  819. *
  820. */
  821. /*
  822. * Alternate function AF2
  823. */
  824. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  825. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  826. #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */
  827. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  828. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  829. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  830. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  831. /**
  832. *
  833. */
  834. /*
  835. * Alternate function AF3
  836. */
  837. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  838. #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */
  839. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  840. /**
  841. *
  842. */
  843. /*
  844. * Alternate function AF4
  845. */
  846. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  847. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  848. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  849. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  850. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  851. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  852. /**
  853. *
  854. */
  855. /*
  856. * Alternate function AF5
  857. */
  858. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  859. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  860. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  861. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  862. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  863. /**
  864. *
  865. */
  866. /*
  867. * Alternate function AF6
  868. */
  869. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  870. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  871. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  872. /**
  873. *
  874. */
  875. /*
  876. * Alternate function AF7
  877. */
  878. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  879. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  880. /**
  881. *
  882. */
  883. /**
  884. * @}
  885. */
  886. /**
  887. * @}
  888. */
  889. /** @defgroup GPIOEx_Private GPIOEx Private
  890. * @{
  891. */
  892. /**
  893. * @brief IS_GPIO_AF macro definition
  894. */
  895. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  896. /**
  897. * @}
  898. */
  899. #endif /* STM32L053xx || STM32L063xx */
  900. /*------------------------------------------------------------------------------------------*/
  901. /*----------------------------------------------------------------------------*/
  902. /*------------------------- STM32L052xx/STM32L062xx---------------------------*/
  903. /*----------------------------------------------------------------------------*/
  904. #if defined (STM32L052xx) || defined (STM32L062xx)
  905. /* The table below gives an overview of the different alternate functions per port.
  906. * For more details refer yourself to the product data sheet.
  907. *
  908. */
  909. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  910. *______________________________________________________________________________
  911. * PA0 | | |TIM2_C1 |TSC |USART2 |TIM2_TR | |COMP1 |
  912. * PA1 |EVENTOUT| |TIM2_C2 |TSC |USART2 |TIM21_TR| | |
  913. * PA2 |TIM21_C1| |TIM2_C3 |TSC |USART2 | | |COMP2 |
  914. * PA3 |TIM21_C2| |TIM2_C4 |TSC |USART2 | | | |
  915. * PA4 |SPI1 | | |TSC |USART2 |TIM22_TR| | |
  916. * PA5 |SPI1 | |TIM2_TR |TSC | |TIM2_C1 | | |
  917. * PA6 |SPI1 | | |TSC |LPUART |TIM22_C1|EVENTOUT|COMP1 |
  918. * PA7 |SPI1 | | |TSC | |TIM22_C2|EVENTOUT|COMP2 |
  919. * PA8 |MCO | |USB |EVENTOUT|USART1 | | | |
  920. * PA9 |MCO | | |TSC |USART1 | | | |
  921. * PA10| | | |TSC |USART1 | | | |
  922. * PA11|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP1 |
  923. * PA12|SPI1 | |EVENTOUT|TSC |USART1 | | |COMP2 |
  924. * PA13|SWDIO | |USB | | | | | |
  925. * PA14|SWCLK | | | |USART2 | | | |
  926. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | |
  927. *______________________________________________________________________________
  928. * PB0 |EVENTOUT| | |TSC | | | | |
  929. * PB1 | | | |TSC |LPUART1 | | | |
  930. * PB2 | | |LPTIM1_O|TSC | | | | |
  931. * PB3 |SPI1 | |TIM2_C2 |TSC |EVENTOUT| | | |
  932. * PB4 |SPI1 | |EVENTOUT|TSC |TIM22_C1| | | |
  933. * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | |
  934. * PB6 |USART1 |I2C1 |LPTIM1_T|TSC | | | | |
  935. * PB7 |USART1 |I2C1 |LPTIM1_I|TSC | | | | |
  936. * PB8 | | | |TSC |I2C1 | | | |
  937. * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | |
  938. * PB10| | |TIM2_C3 |TSC |LPUART1 |SPI2 |I2C2 | |
  939. * PB11|EVENTOUT| |TIM2_C4 |TSC |LPUART1 | |I2C2 | |
  940. * PB12|SPI2 | |LPUART1 |TSC | |I2C2 |EVENTOUT| |
  941. * PB13|SPI2 | | |TSC |LPUART1 |I2C2 |TIM21_C1| |
  942. * PB14|SPI2 | |RTC |TSC |LPUART1 |I2C2 |TIM21_C2| |
  943. * PB15|SPI2 | |RTC | | | | | |
  944. *______________________________________________________________________________
  945. * PC0 |LPTIM1_I| |EVENTOUT|TSC | | | | |
  946. * PC1 |LPTIM1_O| |EVENTOUT|TSC | | | | |
  947. * PC2 |LPTIM1_I| |SPI2 |TSC | | | | |
  948. * PC3 |LPTIM1_T| |SPI2 |TSC | | | | |
  949. * PC4 |EVENTOUT| |LPUART | | | | | |
  950. * PC5 | | |LPUART |TSC | | | | |
  951. * PC6 |TIM22_C1| | |TSC | | | | |
  952. * PC7 |TIM22_C2| | |TSC | | | | |
  953. * PC8 |TIM22_TR| | |TSC | | | | |
  954. * PC9 |TIM21_TR| |USB |TSC | | | | |
  955. * PC10|LPUART | | | | | | | |
  956. * PC11|LPUART | | | | | | | |
  957. * PC12| | | | | | | | |
  958. * PC13| | | | | | | | |
  959. * PC14| | | | | | | | |
  960. * PC15| | | | | | | | |
  961. *______________________________________________________________________________
  962. * PD2 |LPUART | | | | | | | |
  963. *______________________________________________________________________________
  964. * PH0 |USB | | | | | | | |
  965. * PH1 | | | | | | | | |
  966. * *
  967. */
  968. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  969. * @{
  970. */
  971. /*
  972. * Alternate function AF0
  973. */
  974. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  975. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  976. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  977. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  978. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  979. #define GPIO_AF0_USB ((uint8_t)0x00U) /* USB Alternate Function mapping */
  980. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  981. #define GPIO_AF0_TSC ((uint8_t)0x00U) /* TSC Alternate Function mapping */
  982. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  983. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  984. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  985. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  986. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  987. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  988. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  989. /**
  990. *
  991. */
  992. /*
  993. * Alternate function AF1
  994. */
  995. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  996. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  997. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  998. /**
  999. *
  1000. */
  1001. /**
  1002. * Alternate function AF2
  1003. */
  1004. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  1005. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  1006. #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */
  1007. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1008. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1009. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1010. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1011. /**
  1012. *
  1013. */
  1014. /*
  1015. * Alternate function AF3
  1016. */
  1017. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1018. #define GPIO_AF3_TSC ((uint8_t)0x03U) /* TSC Alternate Function mapping */
  1019. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1020. /**
  1021. *
  1022. */
  1023. /*
  1024. * Alternate function AF4
  1025. */
  1026. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1027. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  1028. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1029. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1030. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  1031. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1032. /**
  1033. *
  1034. */
  1035. /*
  1036. * Alternate function AF5
  1037. */
  1038. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  1039. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  1040. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1041. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1042. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  1043. /**
  1044. *
  1045. */
  1046. /*
  1047. * Alternate function AF6
  1048. */
  1049. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  1050. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  1051. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1052. /**
  1053. *
  1054. */
  1055. /*
  1056. * Alternate function AF7
  1057. */
  1058. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  1059. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  1060. /**
  1061. *
  1062. */
  1063. /**
  1064. * @}
  1065. */
  1066. /**
  1067. * @}
  1068. */
  1069. /** @defgroup GPIOEx_Private GPIOEx Private
  1070. * @{
  1071. */
  1072. /**
  1073. * @brief IS_GPIO_AF macro definition
  1074. */
  1075. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  1076. /**
  1077. * @}
  1078. */
  1079. #endif /* STM32L052xx || STM32L062xx */
  1080. /*------------------------------------------------------------------------------------------*/
  1081. /*----------------------------------------------------------------------------*/
  1082. /*------------------------------- STM32L051xx---------------------------------*/
  1083. /*----------------------------------------------------------------------------*/
  1084. #if defined (STM32L051xx)
  1085. /* The table below gives an overview of the different alternate functions per port.
  1086. * For more details refer yourself to the product data sheet.
  1087. *
  1088. */
  1089. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  1090. *______________________________________________________________________________
  1091. * PA0 | | |TIM2_C1 | |USART2 |TIM2_TR | |COMP1 |
  1092. * PA1 |EVENTOUT| |TIM2_C2 | |USART2 |TIM21_TR| | |
  1093. * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | | |COMP2 |
  1094. * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | | | |
  1095. * PA4 |SPI1 | | | |USART2 |TIM22_TR| | |
  1096. * PA5 |SPI1 | |TIM2_TR | | |TIM2_C1 | | |
  1097. * PA6 |SPI1 | | | |LPUART |TIM22_C1|EVENTOUT|COMP1 |
  1098. * PA7 |SPI1 | | | | |TIM22_C2|EVENTOUT|COMP2 |
  1099. * PA8 |MCO | | |EVENTOUT|USART1 | | | |
  1100. * PA9 |MCO | | | |USART1 | | | |
  1101. * PA10| | | | |USART1 | | | |
  1102. * PA11|SPI1 | |EVENTOUT| |USART1 | | |COMP1 |
  1103. * PA12|SPI1 | |EVENTOUT| |USART1 | | |COMP2 |
  1104. * PA13|SWDIO | | | | | | | |
  1105. * PA14|SWCLK | | | |USART2 | | | |
  1106. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | |
  1107. *______________________________________________________________________________
  1108. * PB0 |EVENTOUT| | | | | | | |
  1109. * PB1 | | | | |LPUART1 | | | |
  1110. * PB2 | | |LPTIM1_O| | | | | |
  1111. * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT| | | |
  1112. * PB4 |SPI1 | |EVENTOUT| |TIM22_C1| | | |
  1113. * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | |
  1114. * PB6 |USART1 |I2C1 |LPTIM1_T| | | | | |
  1115. * PB7 |USART1 |I2C1 |LPTIM1_I| | | | | |
  1116. * PB8 | | | | |I2C1 | | | |
  1117. * PB9 | | |EVENTOUT| |I2C1 |SPI2 | | |
  1118. * PB10| | |TIM2_C3 | |LPUART1 |SPI2 |I2C2 | |
  1119. * PB11|EVENTOUT| |TIM2_C4 | |LPUART1 | |I2C2 | |
  1120. * PB12|SPI2 | |LPUART1 | | |I2C2 |EVENTOUT| |
  1121. * PB13|SPI2 | | | |LPUART1 |I2C2 |TIM21_C1| |
  1122. * PB14|SPI2 | |RTC | |LPUART1 |I2C2 |TIM21_C2| |
  1123. * PB15|SPI2 | |RTC | | | | | |
  1124. *______________________________________________________________________________
  1125. * PC0 |LPTIM1_I| |EVENTOUT| | | | | |
  1126. * PC1 |LPTIM1_O| |EVENTOUT| | | | | |
  1127. * PC2 |LPTIM1_I| |SPI2 | | | | | |
  1128. * PC3 |LPTIM1_T| |SPI2 | | | | | |
  1129. * PC4 |EVENTOUT| |LPUART | | | | | |
  1130. * PC5 | | |LPUART | | | | | |
  1131. * PC6 |TIM22_C1| | | | | | | |
  1132. * PC7 |TIM22_C2| | | | | | | |
  1133. * PC8 |TIM22_TR| | | | | | | |
  1134. * PC9 |TIM21_TR| | | | | | | |
  1135. * PC10|LPUART | | | | | | | |
  1136. * PC11|LPUART | | | | | | | |
  1137. * PC12| | | | | | | | |
  1138. * PC13| | | | | | | | |
  1139. * PC14| | | | | | | | |
  1140. * PC15| | | | | | | | |
  1141. *______________________________________________________________________________
  1142. * PD2 |LPUART | | | | | | | |
  1143. *______________________________________________________________________________
  1144. * PH0 | | | | | | | | |
  1145. * PH1 | | | | | | | | |
  1146. * *
  1147. */
  1148. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1149. * @{
  1150. */
  1151. /*
  1152. * Alternate function AF0
  1153. */
  1154. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1155. #define GPIO_AF0_SPI2 ((uint8_t)0x00U) /* SPI2 Alternate Function mapping */
  1156. #define GPIO_AF0_USART1 ((uint8_t)0x00U) /* USART1 Alternate Function mapping */
  1157. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  1158. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  1159. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  1160. #define GPIO_AF0_TIM2 ((uint8_t)0x00U) /* TIM2 Alternate Function mapping */
  1161. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1162. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  1163. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1164. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1165. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1166. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1167. /**
  1168. *
  1169. */
  1170. /*
  1171. * Alternate function AF1
  1172. */
  1173. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  1174. #define GPIO_AF1_SPI2 ((uint8_t)0x01U) /* SPI2 Alternate Function mapping */
  1175. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1176. /**
  1177. *
  1178. */
  1179. /*
  1180. * Alternate function AF2
  1181. */
  1182. #define GPIO_AF2_SPI2 ((uint8_t)0x02U) /* SPI2 Alternate Function mapping */
  1183. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  1184. #define GPIO_AF2_USB ((uint8_t)0x02U) /* USB Alternate Function mapping */
  1185. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1186. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1187. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1188. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1189. /**
  1190. *
  1191. */
  1192. /*
  1193. * Alternate function AF3
  1194. */
  1195. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1196. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1197. /**
  1198. *
  1199. */
  1200. /*
  1201. * Alternate function AF4
  1202. */
  1203. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1204. #define GPIO_AF4_USART1 ((uint8_t)0x04U) /* USART1 Alternate Function mapping */
  1205. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1206. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1207. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  1208. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1209. /**
  1210. *
  1211. */
  1212. /*
  1213. * Alternate function AF5
  1214. */
  1215. #define GPIO_AF5_SPI2 ((uint8_t)0x05U) /* SPI2 Alternate Function mapping */
  1216. #define GPIO_AF5_I2C2 ((uint8_t)0x05U) /* I2C2 Alternate Function mapping */
  1217. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1218. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1219. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  1220. /**
  1221. *
  1222. */
  1223. /*
  1224. * Alternate function AF6
  1225. */
  1226. #define GPIO_AF6_I2C2 ((uint8_t)0x06U) /* I2C2 Alternate Function mapping */
  1227. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  1228. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1229. /**
  1230. *
  1231. */
  1232. /*
  1233. * Alternate function AF7
  1234. */
  1235. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  1236. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  1237. /**
  1238. *
  1239. */
  1240. /**
  1241. * @}
  1242. */
  1243. /**
  1244. * @}
  1245. */
  1246. /** @defgroup GPIOEx_Private GPIOEx Private
  1247. * @{
  1248. */
  1249. /**
  1250. * @brief IS_GPIO_AF macro definition
  1251. */
  1252. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  1253. /**
  1254. * @}
  1255. */
  1256. #endif /* STM32L051xx */
  1257. /*------------------------------------------------------------------------------------------*/
  1258. /*----------------------------------------------------------------------------*/
  1259. /*------------------------- STM32L031xx/STM32L041xx---------------------------*/
  1260. /*----------------------------------------------------------------------------*/
  1261. #if defined (STM32L031xx)|| defined (STM32L041xx)
  1262. /* The table below gives an overview of the different alternate functions per port.
  1263. * For more details refer yourself to the product data sheet.
  1264. *
  1265. */
  1266. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  1267. *______________________________________________________________________________
  1268. * PA0 | |LPTIM1 |TIM2_C1 | |USART2 |TIM2_TR | |COMP1 |
  1269. * PA1 |EVENTOUT|LPTIM1 |TIM2_C2 |I2C1 |USART2 |TIM21_TR| | |
  1270. * PA2 |TIM21_C1| |TIM2_C3 | |USART2 | |LPUART1 |COMP2 |
  1271. * PA3 |TIM21_C2| |TIM2_C4 | |USART2 | |LPUART1 | |
  1272. * PA4 |SPI1 |LPTIM1 | | |USART2 |TIM22_TR| | |
  1273. * PA5 |SPI1 |LPTIM1 |TIM2_TR | | |TIM2_C1 | | |
  1274. * PA6 |SPI1 |LPTIM1 | | |LPUART |TIM22_C1|EVENTOUT|COMP1 |
  1275. * PA7 |SPI1 |LPTIM1 | | |USART2 |TIM22_C2|EVENTOUT|COMP2 |
  1276. * PA8 |MCO | |LPTIM1 |EVENTOUT|USART2 |TIM2_C1 | | |
  1277. * PA9 |MCO |I2C1 | | |USART2 |TIM22_C1| | |
  1278. * PA10| |I2C1 | | |USART2 |TIM22_C2| | |
  1279. * PA11|SPI1 | |EVENTOUT| |USART2 |TIM21_C2| |COMP1 |
  1280. * PA12|SPI1 | |EVENTOUT| |USART2 | | |COMP2 |
  1281. * PA13|SWDIO |LPTIM1 | | | | |LPUART1 | |
  1282. * PA14|SWCLK |LPTIM1 | |I2C1 |USART2 | |LPUART1 | |
  1283. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2 |TIM2_C1 | | |
  1284. *_____________________________________________________________________________|
  1285. * PB0 |EVENTOUT|SPI1 | | |USART2 |TIM2_C3 | | |
  1286. * PB1 |USART2 |SPI1 | | |LPUART1 |TIM2_C4 | | |
  1287. * PB2 | | |LPTIM1_O| | | | | |
  1288. * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT| | | |
  1289. * PB4 |SPI1 | |EVENTOUT| |TIM22_C1| | | |
  1290. * PB5 |SPI1 | |LPTIM1_I|I2C1 |TIM22_C2| | | |
  1291. * PB6 |USART2 |I2C1 |LPTIM1_T| | |TIM21_C1| | |
  1292. * PB7 |USART2 |I2C1 |LPTIM1_I| | | | | |
  1293. * PB8 | | | | |I2C1 | | | |
  1294. * PB9 | | |EVENTOUT| |I2C1 | | | |
  1295. * PB10| | |TIM2_C3 | | | |LPUART1 | |
  1296. * PB11|EVENTOUT| |TIM2_C4 | | | |LPUART1 | |
  1297. * PB12|SPI2 | | | | | |EVENTOUT| |
  1298. * PB13|SPI2 | |MCO | | |TIM21_C1|LPUART1 | |
  1299. * PB14|SPI2 | |RTC | | |TIM21_C2|LPUART1 | |
  1300. * PB15|SPI2 | |RTC | | | | | |
  1301. *_____________________________________________________________________________|
  1302. * PC0 |LPTIM1_I| |EVENTOUT| | | |LPUART1 | |
  1303. * PC13| | | | | | | | |
  1304. * PC14| | | | | | | | |
  1305. * PC15| | | | | | | | |
  1306. *_____________________________________________________________________________|
  1307. * PH0 | | | | | | | | |
  1308. * PH1 | | | | | | | | |
  1309. *_____________________________________________________________________________|
  1310. */
  1311. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1312. * @{
  1313. */
  1314. /*
  1315. * Alternate function AF0
  1316. */
  1317. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1318. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1319. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1320. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  1321. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  1322. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1323. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1324. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1325. /**
  1326. *
  1327. */
  1328. /*
  1329. * Alternate function AF1
  1330. */
  1331. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  1332. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1333. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */
  1334. /**
  1335. *
  1336. */
  1337. /*
  1338. * Alternate function AF2
  1339. */
  1340. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1341. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1342. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  1343. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1344. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1345. /**
  1346. *
  1347. */
  1348. /*
  1349. * Alternate function AF3
  1350. */
  1351. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1352. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1353. /**
  1354. *
  1355. */
  1356. /*
  1357. * Alternate function AF4
  1358. */
  1359. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1360. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1361. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1362. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  1363. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1364. /**
  1365. *
  1366. */
  1367. /*
  1368. * Alternate function AF5
  1369. */
  1370. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1371. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1372. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  1373. /**
  1374. *
  1375. */
  1376. /*
  1377. * Alternate function AF6
  1378. */
  1379. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  1380. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1381. /**
  1382. *
  1383. */
  1384. /*
  1385. * Alternate function AF7
  1386. */
  1387. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  1388. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  1389. /**
  1390. *
  1391. */
  1392. /**
  1393. * @}
  1394. */
  1395. /**
  1396. * @}
  1397. */
  1398. /** @defgroup GPIOEx_Private GPIOEx Private
  1399. * @{
  1400. */
  1401. /**
  1402. * @brief IS_GPIO_AF macro definition
  1403. */
  1404. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  1405. /**
  1406. * @}
  1407. */
  1408. #endif /* STM32L031xx/STM32L041xx*/
  1409. /*------------------------------------------------------------------------------------------*/
  1410. /*----------------------------------------------------------------------------*/
  1411. /*------------------------- STM32L011xx/STM32L021xx---------------------------*/
  1412. /*----------------------------------------------------------------------------*/
  1413. #if defined (STM32L011xx)|| defined (STM32L021xx)
  1414. /* The table below gives an overview of the different alternate functions per port.
  1415. * For more details refer yourself to the product data sheet.
  1416. *
  1417. */
  1418. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  1419. *______________________________________________________________________________________
  1420. * PA0 |USART2_RX|LPTIM1_IN1|TIM2_C1 | |USART2_CTS|TIM2_ETR|LPUART1_RX |COMP1_OUT|
  1421. * PA1 |EVENTOUT |LPTIM1_IN2|TIM2_C2 |I2C1 |USART2_RTS|TIM21_TR|LPUART1_TX | |
  1422. * PA2 |TIM21_C1 | |TIM2_C3 | |USART2_TX | |LPUART1_TX |COMP2_OUT|
  1423. * PA3 |TIM21_C2 | |TIM2_C4 | |USART2_RX | |LPUART1_RX | |
  1424. * PA4 |SPI1 |LPTIM1_IN1|LPTIM1_TR|I2C1_SCL|USART2_CK |TIM2_TR |LPUART1_TX |COMP2_OUT|
  1425. * PA5 |SPI1 |LPTIM1_IN2|TIM2_TR | | |TIM2_C1 | | |
  1426. * PA6 |SPI1 |LPTIM1_ETR| | |LPUART1_CT| |EVENTOUT |COMP1_OUT|
  1427. * PA7 |SPI1 |LPTIM1_OUT| | |USART2_CTS|TIM21_T |EVENTOUT |COMP2_OUT|
  1428. * PA8 |MCO | |LPTIM1_I1|EVENTOUT|USART2_CK |TIM2_C1 | | |
  1429. * PA9 |MCO |I2C1_SCL |LPTIM1_O | |USART2_TX |TIM21_C2| |COMP1_OUT|
  1430. * PA10|TIM21_C1 |I2C1_SDA |RTC_REFIN| |USART2_RX |TIM2_C3 | |COMP1_OUT|
  1431. * PA11|SPI1 |LPTIM1_OUT|EVENTOUT | |USART2_CTS|TIM21_C2| |COMP1_OUT|
  1432. * PA12|SPI1 | |EVENTOUT | |USART2_RTS| | |COMP2_OUT|
  1433. * PA13|SWDIO |LPTIM1_T | |I2C1_SDA| |SPI1 |LPUART1_RX |COMP1_OUT|
  1434. * PA14|SWCLK |LPTIM1_O | |I2C1_SMB|USART2_TX |SPI1 |LPUART1_TX |COMP2_OUT|
  1435. * PA15|SPI1 | |TIM2_TR |EVENTOUT|USART2_RX |TIM2_C1 | | |
  1436. *______________________________________________________________________________________ |
  1437. * PB0 |EVENTOUT |SPI1 |TIM2_C2 | |USART2_RTS|TIM2_C3 | | |
  1438. * PB1 |USART2_CK|SPI1 |LPTIM1_I1| |LPUART1_RT|TIM2_C4 | | |
  1439. * PB2 | | |LPTIM1_O | | | | | |
  1440. * PB3 |SPI1 | |TIM2_C2 | |EVENTOUT | | | |
  1441. * PB4 |SPI1 | |EVENTOUT | | | | | |
  1442. * PB5 |SPI1 | |LPTIM1_I1|I2C1 | |TIM21_C1| | |
  1443. * PB6 |USART2_TX|I2C1_SCL |LPTIM1_T | | |TIM2_C3 |LPUART1_TX | |
  1444. * PB7 |USART2_RX|I2C1 |LPTIM1_I2| | |TIM2_C4 |LPUART1_RX | |
  1445. * PB8 |USART2_TX| |EVENTOUT | |I2C1 |SPI1 | | |
  1446. * PB9 | | | | | | | | |
  1447. *______________________________________________________________________________________ |
  1448. * PC14| | | | | | | | |
  1449. * PC15| | | | | | | | |
  1450. *______________________________________________________________________________________ |
  1451. */
  1452. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1453. * @{
  1454. */
  1455. /*
  1456. * Alternate function AF0
  1457. */
  1458. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1459. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1460. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1461. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  1462. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1463. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1464. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1465. /**
  1466. *
  1467. */
  1468. /*
  1469. * Alternate function AF1
  1470. */
  1471. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  1472. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1473. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */
  1474. /**
  1475. *
  1476. */
  1477. /* Alternate function AF2
  1478. *
  1479. */
  1480. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1481. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1482. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1483. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1484. /**
  1485. *
  1486. */
  1487. /*
  1488. * Alternate function AF3
  1489. */
  1490. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1491. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1492. /**
  1493. *
  1494. */
  1495. /*
  1496. * Alternate function AF4
  1497. */
  1498. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1499. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1500. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1501. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1502. /**
  1503. *
  1504. */
  1505. /*
  1506. * Alternate function AF5
  1507. */
  1508. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1509. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1510. #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */
  1511. /**
  1512. *
  1513. */
  1514. /*
  1515. * Alternate function AF6
  1516. */
  1517. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  1518. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1519. /**
  1520. *
  1521. */
  1522. /*
  1523. * Alternate function AF7
  1524. */
  1525. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  1526. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  1527. /**
  1528. *
  1529. */
  1530. /**
  1531. * @}
  1532. */
  1533. /**
  1534. * @}
  1535. */
  1536. /** @defgroup GPIOEx_Private GPIOEx Private
  1537. * @{
  1538. */
  1539. /**
  1540. * IS_GPIO_AF macro definition
  1541. */
  1542. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  1543. /**
  1544. * @}
  1545. */
  1546. #endif /* STM32L011xx/STM32L021xx*/
  1547. /*----------------------------------------------------------------------------*/
  1548. /*----------------------------- STM32L010xB ----------------------------------*/
  1549. /*----------------------------------------------------------------------------*/
  1550. #if defined (STM32L010xB)
  1551. /* The table below gives an overview of the different alternate functions per port.
  1552. * For more details refer yourself to the product data sheet.
  1553. *
  1554. */
  1555. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 | AF7 |
  1556. *_______________________________________________________________________________________________|
  1557. * PA0 | | |TIM2_CH1 | |USART2_CTS |TIM2_ETR | | |
  1558. * PA1 |EVENTOUT | |TIM2_CH2 | |USART2_RTS |TIM21_ETR| | |
  1559. * PA2 |TIM21_CH1 | |TIM2_CH3 | |USART2_TX | |LPUART1_TX | |
  1560. * PA3 |TIM21_CH2 | |TIM2_CH4 | |USART2_RX | |LPUART1_RX | |
  1561. * PA4 |SPI1_NSS | | | |USART2_CK |TIM22_ETR| | |
  1562. * PA5 |SPI1_SCK | |TIM2_ETR | | |TIM2_CH1 | | |
  1563. * PA6 |SPI1_MISO | | | |LPUART1_CTS|TIM22_CH1|EVENTOUT | |
  1564. * PA7 |SPI1_MOSI | | | | |TIM22_CH2|EVENTOUT | |
  1565. * PA8 |MCO | | |EVENTOUT | | | | |
  1566. * PA9 |MCO | | | | | |I2C1_SCL | |
  1567. * PA10| | | | | | |I2C1_SDA | |
  1568. * PA11|SPI1_MISO | |EVENTOUT | | | | | |
  1569. * PA12|SPI1_MOSI | |EVENTOUT | | | | | |
  1570. * PA13|SWDIO | | | | | |LPUART1_RX | |
  1571. * PA14|SWCLK | | | |USART2_TX | |LPUART1_TX | |
  1572. * PA15|SPI1_NSS | |TIM2_ETR |EVENTOUT |USART2_RX |TIM2_CH1 | | |
  1573. *_______________________________________________________________________________________________|
  1574. * PB0 |EVENTOUT | | | | | | | |
  1575. * PB1 | | | | |LPUART1_RTS| | | |
  1576. * PB2 | | |LPTIM1_OUT | | | | | |
  1577. * PB3 |SPI1_SCK | |TIM2_CH2 | |EVENTOUT | | | |
  1578. * PB4 |SPI1_MISO | | | |TIM22_CH1 | | | |
  1579. * PB5 |SPI1_MOSI | |LPTIM1_IN1 |I2C1_SMBA|TIM22_CH2 | | | |
  1580. * PB6 | |I2C1_SCL |LPTIM1_ETR | | | | | |
  1581. * PB7 | |I2C1_SDA |LPTIM1_IN2 | | | | | |
  1582. * PB8 | | | | |I2C1_SCL | | | |
  1583. * PB9 | | |EVENTOUT | |I2C1_SDA | | | |
  1584. * PB10| | |TIM2_CH3 | |LPUART1_TX | | |LPUART1_RX|
  1585. * PB11|EVENTOUT | |TIM2_CH4 | |LPUART1_RX | | |LPUART1_TX|
  1586. * PB12| | |LPUART1_RTS| | | |EVENTOUT | |
  1587. * PB13| | |MCO | |LPUART1_CTS| |TIM21_CH1 | |
  1588. * PB14| | |RTC_OUT | |LPUART1_RTS| |TIM21_CH2 | |
  1589. * PB15| | |RTC_REFIN | | | | | |
  1590. *_______________________________________________________________________________________________|
  1591. * PC0 |LPTIM1_IN1 | |EVENTOUT | | | |LPUART1_RX | |
  1592. * PC1 |LPTIM1_OUT | |EVENTOUT | | | |LPUART1_TX | |
  1593. * PC2 |LPTIM1_IN2 | | | | | | | |
  1594. * PC3 |LPTIM1_ETR | | | | | | | |
  1595. * PC4 |EVENTOUT | |LPUART1_TX | | | | | |
  1596. * PC5 | | |LPUART1_RX | | | | | |
  1597. * PC6 |TIM22_CH1 | | | | | | | |
  1598. * PC7 |TIM22_CH2 | | | | | | | |
  1599. * PC8 |TIM22_ETR | | | | | | | |
  1600. * PC9 |TIM21_ETR | | | | | | | |
  1601. * PC10|LPUART1_TX | | | | | | | |
  1602. * PC11|LPUART1_RX | | | | | | | |
  1603. *_______________________________________________________________________________________________|
  1604. * PD2 |LPUART1_RTS| | | | | | | |
  1605. *_______________________________________________________________________________________________|
  1606. */
  1607. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1608. * @{
  1609. */
  1610. /*
  1611. * Alternate function AF0
  1612. *
  1613. */
  1614. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1615. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1616. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1617. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1618. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1619. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1620. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  1621. #define GPIO_AF0_TIM22 ((uint8_t)0x00U) /* TIM22 Alternate Function mapping */
  1622. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  1623. /**
  1624. *
  1625. */
  1626. /*
  1627. * Alternate function AF1
  1628. *
  1629. */
  1630. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1631. /**
  1632. *
  1633. */
  1634. /*
  1635. * Alternate function AF2
  1636. *
  1637. */
  1638. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1639. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1640. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1641. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  1642. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  1643. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1644. /**
  1645. *
  1646. */
  1647. /*
  1648. * Alternate function AF3
  1649. * @{
  1650. */
  1651. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1652. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1653. /**
  1654. *
  1655. */
  1656. /*
  1657. * Alternate function AF4
  1658. *
  1659. */
  1660. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1661. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1662. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1663. #define GPIO_AF4_TIM22 ((uint8_t)0x04U) /* TIM22 Alternate Function mapping */
  1664. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1665. /**
  1666. *
  1667. */
  1668. /*
  1669. * Alternate function AF5
  1670. *
  1671. */
  1672. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1673. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1674. #define GPIO_AF5_TIM22 ((uint8_t)0x05U) /* TIM22 Alternate Function mapping */
  1675. /**
  1676. *
  1677. */
  1678. /*
  1679. * Alternate function AF6
  1680. *
  1681. */
  1682. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  1683. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1684. #define GPIO_AF6_I2C1 ((uint8_t)0x06U) /* I2C1 Alternate Function mapping */
  1685. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  1686. /**
  1687. *
  1688. */
  1689. /*
  1690. * Alternate function AF7
  1691. *
  1692. */
  1693. #define GPIO_AF7_LPUART1 ((uint8_t)0x07U) /* LPUART1 Alternate Function mapping */
  1694. /**
  1695. *
  1696. */
  1697. /**
  1698. * @}
  1699. */
  1700. /**
  1701. * @}
  1702. */
  1703. /** @defgroup GPIOEx_Private GPIOEx Private
  1704. * @{
  1705. */
  1706. /**
  1707. * IS_GPIO_AF macro definition
  1708. */
  1709. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x07)
  1710. /**
  1711. * @}
  1712. */
  1713. #endif /* STM32L010xB */
  1714. /*----------------------------------------------------------------------------*/
  1715. /*------------------------- STM32L010x8 --------------------------------------*/
  1716. /*----------------------------------------------------------------------------*/
  1717. #if defined (STM32L010x8)
  1718. /* The table below gives an overview of the different alternate functions per port.
  1719. * For more details refer yourself to the product data sheet.
  1720. *
  1721. */
  1722. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 |
  1723. *________________________________________________________________________________________________|
  1724. * PA0 | | | TIM2_CH1 | | USART2_CTS | TIM2_ETR | |
  1725. * PA1 | EVENTOUT | | TIM2_CH2 | | USART2_RTS | TIM21_ETR | |
  1726. * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | |
  1727. * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | |
  1728. * PA4 | SPI1_NSS | | | | USART2_CK | | |
  1729. * PA5 | SPI1_SCK | | TIM2_ETR | | | TIM2_CH1 | |
  1730. * PA6 | SPI1_MISO | | | | LPUART1_CTS | | EVENTOUT |
  1731. * PA7 | SPI1_MOSI | | | | | | EVENTOUT |
  1732. * PA8 | MCO | | | EVENTOUT | | | |
  1733. * PA9 | MCO | | | | | | |
  1734. * PA10 | | | | | | | |
  1735. * PA11 | SPI1_MISO | | EVENTOUT | | | | |
  1736. * PA12 | SPI1_MOSI | | EVENTOUT | | | | |
  1737. * PA13 | SWDIO | | | | | | |
  1738. * PA14 | SWCLK | | | | USART2_TX | | |
  1739. * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | |
  1740. *________________________________________________________________________________________________|
  1741. * PB0 | EVENTOUT | | | | | | |
  1742. * PB1 | | | | | LPUART1_RTS | | |
  1743. * PB2 | | | LPTIM1_OUT | | | | |
  1744. * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | |
  1745. * PB4 | SPI1_MISO | EVENTOUT | | | | | |
  1746. * PB5 | SPI1_MOSI | LPTIM1_IN1 | I2C1_SMBA | | | | |
  1747. * PB6 | | I2C1_SCL | LPTIM1_ETR | | | | |
  1748. * PB7 | | I2C1_SDA | LPTIM1_IN2 | | | | |
  1749. * PB8 | | | | | I2C1_SCL | | |
  1750. * PB9 | | | EVENTOUT | | I2C1_SDA | | |
  1751. * PB10 | | | TIM2_CH3 | | LPUART1_TX | | |
  1752. * PB11 | EVENTOUT | | TIM2_CH4 | | LPUART1_RX | | |
  1753. * PB12 | | | LPUART1_RTS | | | EVENTOUT | |
  1754. * PB13 | | | | | LPUART1_CTS | | TIM21_CH1 |
  1755. * PB14 | | | RTC_OUT | | LPUART1_RTS | | TIM21_CH2 |
  1756. * PB15 | | | RTC_REFIN | | | | |
  1757. *________________________________________________________________________________________________|
  1758. * PC0 | LPTIM1_IN1 | | EVENTOUT | | | | |
  1759. * PC1 | LPTIM1_OUT | | EVENTOUT | | | | |
  1760. * PC2 | LPTIM1_IN2 | | | | | | |
  1761. * PC3 | LPTIM1_ETR | | | | | | |
  1762. * PC4 | EVENTOUT | | LPUART1_TX | | | | |
  1763. * PC5 | | | LPUART1_RX | | | | |
  1764. * PC9 | TIM21_ETR | | | | | | |
  1765. * PC10 | LPUART1_TX | | | | | | |
  1766. * PC11 | LPUART1_RX | | | | | | |
  1767. * PD2 | LPUART1_RTS | | | | | | |
  1768. *________________________________________________________________________________________________|
  1769. */
  1770. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1771. * @{
  1772. */
  1773. /*
  1774. * Alternate function AF0
  1775. */
  1776. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1777. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1778. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1779. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1780. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1781. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1782. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  1783. #define GPIO_AF0_LPUART1 ((uint8_t)0x00U) /* LPUART1 Alternate Function mapping */
  1784. /**
  1785. *
  1786. */
  1787. /*
  1788. * Alternate function AF1
  1789. */
  1790. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1791. /**
  1792. *
  1793. */
  1794. /*
  1795. * Alternate function AF2
  1796. */
  1797. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1798. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1799. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1800. #define GPIO_AF2_LPUART1 ((uint8_t)0x02U) /* LPUART1 Alternate Function mapping */
  1801. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1802. /**
  1803. *
  1804. */
  1805. /*
  1806. * Alternate function AF3
  1807. */
  1808. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1809. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1810. /**
  1811. *
  1812. */
  1813. /*
  1814. * Alternate function AF4
  1815. */
  1816. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1817. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1818. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1819. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1820. /**
  1821. *
  1822. */
  1823. /*
  1824. * Alternate function AF5
  1825. */
  1826. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1827. /**
  1828. *
  1829. */
  1830. /*
  1831. * Alternate function AF6
  1832. */
  1833. #define GPIO_AF6_TIM21 ((uint8_t)0x06U) /* TIM21 Alternate Function mapping */
  1834. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1835. /**
  1836. *
  1837. */
  1838. /**
  1839. * @}
  1840. */
  1841. /**
  1842. * @}
  1843. */
  1844. /** @defgroup GPIOEx_Private GPIOEx Private
  1845. * @{
  1846. */
  1847. /**
  1848. * @brief IS_GPIO_AF macro definition
  1849. */
  1850. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06)
  1851. /**
  1852. * @}
  1853. */
  1854. #endif /* STM32L010x8 */
  1855. /*----------------------------------------------------------------------------*/
  1856. /*------------------------- STM32L010x6 --------------------------------------*/
  1857. /*----------------------------------------------------------------------------*/
  1858. #if defined (STM32L010x6)
  1859. /* The table below gives an overview of the different alternate functions per port.
  1860. * For more details refer yourself to the product data sheet.
  1861. *
  1862. */
  1863. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 |
  1864. *__________________________________________________________________________________________________|
  1865. * PA1 | EVENTOUT | LPTIM1_IN2 | TIM2_CH2 | I2C1_SMBA | USART2_RTS | TIM21_ETR | |
  1866. * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | LPUART1_TX |
  1867. * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | LPUART1_RX |
  1868. * PA4 | SPI1_NSS | LPTIM1_IN1 | | | USART2_CK | | |
  1869. * PA5 | SPI1_SCK | LPTIM1_IN2 | TIM2_ETR | | | TIM2_CH1 | |
  1870. * PA6 | SPI1_MISO | LPTIM1_ETR | | | LPUART1_CTS | | EVENTOUT |
  1871. * PA7 | SPI1_MOSI | LPTIM1_OUT | | | USART2_CTS | | EVENTOUT |
  1872. * PA8 | MCO | | LPTIM1_IN1 | EVENTOUT | USART2_CK | TIM2_CH1 | |
  1873. * PA9 | MCO | I2C1_SCL | | | USART2_TX | | |
  1874. * PA10 | | I2C1_SDA | | | USART2_RX | | |
  1875. * PA11 | SPI1_MISO | | EVENTOUT | | USART2_CTS | TIM21_CH2 | |
  1876. * PA12 | SPI1_MOSI | | EVENTOUT | | USART2_RTS | | |
  1877. * PA13 | SWDIO | LPTIM1_ETR | | | | | LPUART1_RX |
  1878. * PA14 | SWCLK | LPTIM1_OUT | | I2C1_SMBA | USART2_TX | | LPUART1_TX |
  1879. * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | |
  1880. *__________________________________________________________________________________________________|
  1881. * PB0 | EVENTOUT | SPI1_MISO | | | USART2_RTS | TIM2_CH3 | |
  1882. * PB1 | USART2_CK | SPI1_MOSI | | | LPUART1_RTS | TIM2_CH4 | |
  1883. * PB2 | | | LPTIM1_OUT | | | | |
  1884. * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | |
  1885. * PB4 | SPI1_MISO | | EVENTOUT | | | | |
  1886. * PB5 | SPI1_MOSI | LPTIM1_IN1 | I2C1_SMBA | | | | |
  1887. * PB6 | USART2_TX | I2C1_SCL | LPTIM1_ETR | | | TIM21_CH1 | |
  1888. * PB7 | USART2_RX | I2C1_SDA | LPTIM1_IN2 | | | | |
  1889. * PB8 | | | | | I2C1_SCL | | |
  1890. * PB9 | | | EVENTOUT | | I2C1_SDA | | |
  1891. * PB10 | | | TIM2_CH3 | | | | LPUART1_TX |
  1892. * PB11 | EVENTOUT | | TIM2_CH4 | | | | LPUART1_RX |
  1893. * PB12 | SPI1_NSS | | | | | | EVENTOUT |
  1894. * PB13 | SPI1_SCK | | MCO | | | TIM21_CH1 | LPUART1_CTS|
  1895. * PB14 | SPI1_MISO | | RTC_OUT | | | TIM21_CH2 | LPUART1_RTS|
  1896. * PB15 | SPI1_MOSI | | RTC_REFIN | | | | |
  1897. *__________________________________________________________________________________________________|
  1898. * PC0 | LPTIM1_IN1 | | EVENTOUT | | | | LPUART1_RX |
  1899. *__________________________________________________________________________________________________|
  1900. */
  1901. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  1902. * @{
  1903. */
  1904. /*
  1905. * Alternate function AF0
  1906. */
  1907. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  1908. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  1909. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  1910. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  1911. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  1912. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  1913. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  1914. #define GPIO_AF0_LPTIM1 ((uint8_t)0x00U) /* LPTIM1 Alternate Function mapping */
  1915. /**
  1916. *
  1917. */
  1918. /*
  1919. * Alternate function AF1
  1920. */
  1921. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  1922. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */
  1923. /**
  1924. *
  1925. */
  1926. /*
  1927. * Alternate function AF2
  1928. */
  1929. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  1930. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  1931. #define GPIO_AF2_MCO ((uint8_t)0x02U) /* MCO Alternate Function mapping */
  1932. #define GPIO_AF2_I2C1 ((uint8_t)0x02U) /* I2C1 Alternate Function mapping */
  1933. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  1934. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  1935. /**
  1936. *
  1937. */
  1938. /*
  1939. * Alternate function AF3
  1940. */
  1941. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  1942. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  1943. /**
  1944. *
  1945. */
  1946. /*
  1947. * Alternate function AF4
  1948. */
  1949. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  1950. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  1951. #define GPIO_AF4_I2C1 ((uint8_t)0x04U) /* I2C1 Alternate Function mapping */
  1952. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  1953. /**
  1954. *
  1955. */
  1956. /*
  1957. * Alternate function AF5
  1958. */
  1959. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  1960. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  1961. /**
  1962. *
  1963. */
  1964. /*
  1965. * Alternate function AF6
  1966. */
  1967. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  1968. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /* EVENTOUT Alternate Function mapping */
  1969. /**
  1970. *
  1971. */
  1972. /*
  1973. * Alternate function AF7
  1974. */
  1975. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /* COMP1 Alternate Function mapping */
  1976. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /* COMP2 Alternate Function mapping */
  1977. /**
  1978. *
  1979. */
  1980. /**
  1981. * @}
  1982. */
  1983. /**
  1984. * @}
  1985. */
  1986. /** @defgroup GPIOEx_Private GPIOEx Private
  1987. * @{
  1988. */
  1989. /**
  1990. * @brief IS_GPIO_AF macro definition
  1991. */
  1992. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06)
  1993. /**
  1994. * @}
  1995. */
  1996. #endif /* STM32L010x6 */
  1997. /*----------------------------------------------------------------------------*/
  1998. /*------------------------- STM32L010x4 --------------------------------------*/
  1999. /*----------------------------------------------------------------------------*/
  2000. #if defined (STM32L010x4)
  2001. /* The table below gives an overview of the different alternate functions per port.
  2002. * For more details refer yourself to the product data sheet.
  2003. *
  2004. */
  2005. /* | AF0 | AF1 | AF2 | AF3 | AF4 | AF5 | AF6 |
  2006. *_______________________________________________________________________ _________________________|
  2007. * PA0 | USART2_RX | LPTIM1_IN1 | TIM2_CH1 | | USART2_CTS | TIM2_ETR | LPUART1_RX |
  2008. * PA1 | EVENTOUT | LPTIM1_IN2 | TIM2_CH2 | I2C1_SMBA | USART2_RTS | TIM21_ETR | LPUART1_TX |
  2009. * PA2 | TIM21_CH1 | | TIM2_CH3 | | USART2_TX | | LPUART1_TX |
  2010. * PA3 | TIM21_CH2 | | TIM2_CH4 | | USART2_RX | | LPUART1_RX |
  2011. * PA4 | SPI1_NSS | LPTIM1_IN1 | LPTIM1_ETR | I2C1_SCL | USART2_CK | TIM2_ETR | LPUART1_TX |
  2012. * PA5 | SPI1_SCK | LPTIM1_IN2 | TIM2_ETR | | | TIM2_CH1 | |
  2013. * PA6 | SPI1_MISO | LPTIM1_ETR | | LPUART1_CTS | | EVENTOUT | |
  2014. * PA7 | SPI1_MOSI | LPTIM1_OUT | | USART2_CTS | TIM21_ETR | EVENTOUT | |
  2015. * PA8 | MCO | | LPTIM1_IN1 | EVENTOUT | USART2_CK | TIM2_CH1 | |
  2016. * PA9 | MCO | I2C1_SCL | LPTIM1_OUT | | USART2_TX | TIM21_CH2 | |
  2017. * PA10 | TIM21_CH1 | I2C1_SDA | RTC_REFIN | | USART2_RX | TIM2_CH3 | |
  2018. * PA11 | SPI1_MISO | LPTIM1_OUT | EVENTOUT | | USART2_CTS | TIM21_CH2 | |
  2019. * PA12 | SPI1_MOSI | | EVENTOUT | | USART2_RTS | | |
  2020. * PA13 | SWDIO | LPTIM1_ETR | | I2C1_SDA | | SPI1_SCK | LPUART1_RX |
  2021. * PA14 | SWCLK | LPTIM1_OUT | | I2C1_SMBA | USART2_TX | SPI1_MISO | LPUART1_TX |
  2022. * PA15 | SPI1_NSS | | TIM2_ETR | EVENTOUT | USART2_RX | TIM2_CH1 | |
  2023. *_________________________________________________________________________________________________|
  2024. * PB0 | EVENTOUT | SPI1_MISO | TIM2_CH2 | | USART2_RTS | TIM2_CH3 | |
  2025. * PB1 | USART2_CK | SPI1_MOSI | LPTIM1_IN1 | | LPUART1_RTS | TIM2_CH4 | |
  2026. * PB3 | SPI1_SCK | | TIM2_CH2 | | EVENTOUT | | |
  2027. * PB4 | SPI1_MISO | | EVENTOUT | | | | |
  2028. * PB5 | SPI1_MOSI | | LPTIM1_IN1 | I2C1_SMBA | | TIM21_CH1 | |
  2029. * PB6 | USART2_TX | I2C1_SCL | LPTIM1_ETR | | | TIM2_CH3 | LPUART1_TX |
  2030. * PB7 | USART2_RX | I2C1_SDA | LPTIM1_IN2 | | | TIM2_CH4 | LPUART1_RX |
  2031. *_________________________________________________________________________________________________|
  2032. */
  2033. /** @defgroup GPIOEx_Alternate_function_selection Alternate function selection
  2034. * @{
  2035. */
  2036. /*
  2037. * Alternate function AF0
  2038. */
  2039. #define GPIO_AF0_USART2 ((uint8_t)0x00U) /* USART2 Alternate Function mapping */
  2040. #define GPIO_AF0_EVENTOUT ((uint8_t)0x00U) /* EVENTOUT Alternate Function mapping */
  2041. #define GPIO_AF0_TIM21 ((uint8_t)0x00U) /* TIM21 Alternate Function mapping */
  2042. #define GPIO_AF0_SPI1 ((uint8_t)0x00U) /* SPI1 Alternate Function mapping */
  2043. #define GPIO_AF0_MCO ((uint8_t)0x00U) /* MCO Alternate Function mapping */
  2044. #define GPIO_AF0_SWDIO ((uint8_t)0x00U) /* SWDIO Alternate Function mapping */
  2045. #define GPIO_AF0_SWCLK ((uint8_t)0x00U) /* SWCLK Alternate Function mapping */
  2046. /**
  2047. *
  2048. */
  2049. /*
  2050. * Alternate function AF1
  2051. */
  2052. #define GPIO_AF1_SPI1 ((uint8_t)0x01U) /* SPI1 Alternate Function mapping */
  2053. #define GPIO_AF1_I2C1 ((uint8_t)0x01U) /* I2C1 Alternate Function mapping */
  2054. #define GPIO_AF1_LPTIM1 ((uint8_t)0x01U) /* LPTIM1 Alternate Function mapping */
  2055. /**
  2056. *
  2057. */
  2058. /* Alternate function AF2
  2059. *
  2060. */
  2061. #define GPIO_AF2_LPTIM1 ((uint8_t)0x02U) /* LPTIM1 Alternate Function mapping */
  2062. #define GPIO_AF2_TIM2 ((uint8_t)0x02U) /* TIM2 Alternate Function mapping */
  2063. #define GPIO_AF2_RTC ((uint8_t)0x02U) /* RTC Alternate Function mapping */
  2064. #define GPIO_AF2_EVENTOUT ((uint8_t)0x02U) /* EVENTOUT Alternate Function mapping */
  2065. /**
  2066. *
  2067. */
  2068. /*
  2069. * Alternate function AF3
  2070. */
  2071. #define GPIO_AF3_I2C1 ((uint8_t)0x03U) /* I2C1 Alternate Function mapping */
  2072. #define GPIO_AF3_EVENTOUT ((uint8_t)0x03U) /* EVENTOUT Alternate Function mapping */
  2073. #define GPIO_AF3_LPUART1 ((uint8_t)0x03U) /* LPUART1 Alternate Function mapping */
  2074. #define GPIO_AF3_USART2 ((uint8_t)0x03U) /* USART2 Alternate Function mapping */
  2075. /**
  2076. *
  2077. */
  2078. /*
  2079. * Alternate function AF4
  2080. */
  2081. #define GPIO_AF4_USART2 ((uint8_t)0x04U) /* USART2 Alternate Function mapping */
  2082. #define GPIO_AF4_TIM21 ((uint8_t)0x04U) /* TIM21 Alternate Function mapping */
  2083. #define GPIO_AF4_LPUART1 ((uint8_t)0x04U) /* LPUART1 Alternate Function mapping */
  2084. #define GPIO_AF4_EVENTOUT ((uint8_t)0x04U) /* EVENTOUT Alternate Function mapping */
  2085. /**
  2086. *
  2087. */
  2088. /*
  2089. * Alternate function AF5
  2090. */
  2091. #define GPIO_AF5_TIM2 ((uint8_t)0x05U) /* TIM2 Alternate Function mapping */
  2092. #define GPIO_AF5_TIM21 ((uint8_t)0x05U) /* TIM21 Alternate Function mapping */
  2093. #define GPIO_AF5_SPI1 ((uint8_t)0x05U) /* SPI1 Alternate Function mapping */
  2094. #define GPIO_AF5_EVENTOUT ((uint8_t)0x05U) /* EVENTOUT Alternate Function mapping */
  2095. /**
  2096. *
  2097. */
  2098. /*
  2099. * Alternate function AF6
  2100. */
  2101. #define GPIO_AF6_LPUART1 ((uint8_t)0x06U) /* LPUART1 Alternate Function mapping */
  2102. /**
  2103. *
  2104. */
  2105. /**
  2106. * @}
  2107. */
  2108. /**
  2109. * @}
  2110. */
  2111. /** @defgroup GPIOEx_Private GPIOEx Private
  2112. * @{
  2113. */
  2114. /**
  2115. * IS_GPIO_AF macro definition
  2116. */
  2117. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x06)
  2118. /**
  2119. * @}
  2120. */
  2121. #endif /* STM32L010x4*/
  2122. #if defined (STM32L083xx) || defined (STM32L082xx) || defined (STM32L081xx) || \
  2123. defined (STM32L073xx) || defined (STM32L072xx) || defined (STM32L071xx) || \
  2124. defined (STM32L010xB)
  2125. /** @addtogroup GPIOEx_Exported_Constants
  2126. * @{
  2127. */
  2128. /** @defgroup GPIOEx_Pin_Available Pin available
  2129. * @{
  2130. */
  2131. #define GPIOA_PIN_AVAILABLE GPIO_PIN_All
  2132. #define GPIOB_PIN_AVAILABLE GPIO_PIN_All
  2133. #define GPIOC_PIN_AVAILABLE GPIO_PIN_All
  2134. #define GPIOD_PIN_AVAILABLE GPIO_PIN_All
  2135. #define GPIOE_PIN_AVAILABLE GPIO_PIN_All
  2136. #define GPIOH_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_9 | GPIO_PIN_10)
  2137. /**
  2138. * @}
  2139. */
  2140. /**
  2141. * @}
  2142. */
  2143. /** @addtogroup GPIOEx_Private
  2144. * @{
  2145. */
  2146. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  2147. ((__GPIOx__) == (GPIOB))? 1U :\
  2148. ((__GPIOx__) == (GPIOC))? 2U :\
  2149. ((__GPIOx__) == (GPIOD))? 3U :\
  2150. ((__GPIOx__) == (GPIOE))? 4U :\
  2151. ((__GPIOx__) == (GPIOH))? 5U : 6U)
  2152. #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \
  2153. ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \
  2154. (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \
  2155. (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \
  2156. (((__INSTANCE__) == GPIOD) && (((__PIN__) & (GPIOD_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOD_PIN_AVAILABLE)) == (GPIOD_PIN_AVAILABLE))) || \
  2157. (((__INSTANCE__) == GPIOE) && (((__PIN__) & (GPIOE_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOE_PIN_AVAILABLE)) == (GPIOE_PIN_AVAILABLE))) || \
  2158. (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE))))
  2159. /**
  2160. * @}
  2161. */
  2162. #elif defined (STM32L031xx) || defined (STM32L041xx) || defined (STM32L010x6)
  2163. /** @addtogroup GPIOEx_Exported_Constants
  2164. * @{
  2165. */
  2166. /** @defgroup GPIOEx_Pin_Available Pin available
  2167. * @{
  2168. */
  2169. #define GPIOA_PIN_AVAILABLE GPIO_PIN_All
  2170. #define GPIOB_PIN_AVAILABLE GPIO_PIN_All
  2171. #define GPIOC_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15)
  2172. #define GPIOH_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1)
  2173. /**
  2174. * @}
  2175. */
  2176. /**
  2177. * @}
  2178. */
  2179. /** @addtogroup GPIOEx_Private
  2180. * @{
  2181. */
  2182. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  2183. ((__GPIOx__) == (GPIOB))? 1U :\
  2184. ((__GPIOx__) == (GPIOC))? 2U :\
  2185. ((__GPIOx__) == (GPIOH))? 5U : 6U)
  2186. #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \
  2187. ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \
  2188. (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \
  2189. (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \
  2190. (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE))))
  2191. /**
  2192. * @}
  2193. */
  2194. #elif defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L010x4)
  2195. /** @addtogroup GPIOEx_Exported_Constants
  2196. * @{
  2197. */
  2198. /** @defgroup GPIOEx_Pin_Available Pin available
  2199. * @{
  2200. */
  2201. #define GPIOA_PIN_AVAILABLE GPIO_PIN_All
  2202. #define GPIOB_PIN_AVAILABLE (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | \
  2203. GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 )
  2204. #define GPIOC_PIN_AVAILABLE (GPIO_PIN_14 | GPIO_PIN_15)
  2205. /**
  2206. * @}
  2207. */
  2208. /**
  2209. * @}
  2210. */
  2211. /** @addtogroup GPIOEx_Private
  2212. * @{
  2213. */
  2214. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  2215. ((__GPIOx__) == (GPIOB))? 1U :\
  2216. ((__GPIOx__) == (GPIOC))? 2U : 6U)
  2217. #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \
  2218. ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \
  2219. (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \
  2220. (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))))
  2221. /**
  2222. * @}
  2223. */
  2224. #elif defined (STM32L063xx) || defined (STM32L062xx) || defined (STM32L053xx) || \
  2225. defined (STM32L052xx) || defined (STM32L051xx) || defined (STM32L010x8)
  2226. /** @addtogroup GPIOEx_Exported_Constants
  2227. * @{
  2228. */
  2229. /** @defgroup GPIOEx_Pin_Available Pin available
  2230. * @{
  2231. */
  2232. #define GPIOA_PIN_AVAILABLE GPIO_PIN_All
  2233. #define GPIOB_PIN_AVAILABLE GPIO_PIN_All
  2234. #define GPIOC_PIN_AVAILABLE GPIO_PIN_All
  2235. #define GPIOD_PIN_AVAILABLE GPIO_PIN_2
  2236. #define GPIOH_PIN_AVAILABLE GPIO_PIN_0 | GPIO_PIN_1
  2237. /**
  2238. * @}
  2239. */
  2240. /**
  2241. * @}
  2242. */
  2243. /** @addtogroup GPIOEx_Private
  2244. * @{
  2245. */
  2246. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0U :\
  2247. ((__GPIOx__) == (GPIOB))? 1U :\
  2248. ((__GPIOx__) == (GPIOC))? 2U :\
  2249. ((__GPIOx__) == (GPIOD))? 3U :\
  2250. ((__GPIOx__) == (GPIOH))? 5U : 6U)
  2251. #define IS_GPIO_PIN_AVAILABLE(__INSTANCE__,__PIN__) \
  2252. ((((__INSTANCE__) == GPIOA) && (((__PIN__) & (GPIOA_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOA_PIN_AVAILABLE)) == (GPIOA_PIN_AVAILABLE))) || \
  2253. (((__INSTANCE__) == GPIOB) && (((__PIN__) & (GPIOB_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOB_PIN_AVAILABLE)) == (GPIOB_PIN_AVAILABLE))) || \
  2254. (((__INSTANCE__) == GPIOC) && (((__PIN__) & (GPIOC_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOC_PIN_AVAILABLE)) == (GPIOC_PIN_AVAILABLE))) || \
  2255. (((__INSTANCE__) == GPIOD) && (((__PIN__) & (GPIOD_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOD_PIN_AVAILABLE)) == (GPIOD_PIN_AVAILABLE))) || \
  2256. (((__INSTANCE__) == GPIOH) && (((__PIN__) & (GPIOH_PIN_AVAILABLE)) != 0U) && (((__PIN__) | (GPIOH_PIN_AVAILABLE)) == (GPIOH_PIN_AVAILABLE))))
  2257. /**
  2258. * @}
  2259. */
  2260. #endif /* STM32L083xx || STM32L082xx || STM32L081xx || STM32L073xx || STM32L072xx || STM32L071xx*/
  2261. /**
  2262. * @}
  2263. */
  2264. /**
  2265. * @}
  2266. */
  2267. #ifdef __cplusplus
  2268. }
  2269. #endif
  2270. #endif /* __STM32L0xx_HAL_GPIO_EX_H */