Skip to content

Instantly share code, notes, and snippets.

@mbolivar
Created May 27, 2011 18:54
Show Gist options
  • Save mbolivar/995903 to your computer and use it in GitHub Desktop.
Save mbolivar/995903 to your computer and use it in GitHub Desktop.
gpio_remap.h, from x893
#ifndef _GPIO_REMAP_H
#define _GPIO_REMAP_H
#ifdef __cplusplus
extern "C" {
#endif
#define AFIO_MAPR2 ((volatile uint32*)0x4001001C)
#define DBGMCU_IDCODE ((volatile uint32*)0xE0042000)
#define DBGMCU_CR ((volatile uint32*)0xE0042004)
/*
0x80000000 Use MAPR2 register
0x000F0000 DBGAFR_POSITION_MASK
*/
#define GPIO_Remap_SPI1 ((uint32)0x00000001) /* SPI1 Alternate Function mapping */
#define GPIO_Remap_I2C1 ((uint32)0x00000002) /* I2C1 Alternate Function mapping */
#define GPIO_Remap_USART1 ((uint32)0x00000004) /* USART1 Alternate Function mapping */
#define GPIO_Remap_USART2 ((uint32)0x00000008) /* USART2 Alternate Function mapping */
#define GPIO_PartialRemap_USART3 ((uint32)0x00140010) /* USART3 Partial Alternate Function mapping */
#define GPIO_FullRemap_USART3 ((uint32)0x00140030) /* USART3 Full Alternate Function mapping */
#define GPIO_PartialRemap_TIM1 ((uint32)0x00160040) /* TIM1 Partial Alternate Function mapping */
#define GPIO_FullRemap_TIM1 ((uint32)0x001600C0) /* TIM1 Full Alternate Function mapping */
#define GPIO_PartialRemap1_TIM2 ((uint32)0x00180100) /* TIM2 Partial1 Alternate Function mapping */
#define GPIO_PartialRemap2_TIM2 ((uint32)0x00180200) /* TIM2 Partial2 Alternate Function mapping */
#define GPIO_FullRemap_TIM2 ((uint32)0x00180300) /* TIM2 Full Alternate Function mapping */
#define GPIO_PartialRemap_TIM3 ((uint32)0x001A0800) /* TIM3 Partial Alternate Function mapping */
#define GPIO_FullRemap_TIM3 ((uint32)0x001A0C00) /* TIM3 Full Alternate Function mapping */
#define GPIO_Remap_TIM4 ((uint32)0x00001000) /* TIM4 Alternate Function mapping */
/* CAN1 Alternate Function mapping */
/* 00: CAN_RX mapped to PA11, CAN_TX mapped to PA12 */
#define GPIO_Remap1_CAN1 ((uint32)0x001D4000) /* 10: CAN_RX mapped to PB8, CAN_TX mapped to PB9 (not available on 36-pin package) */
#define GPIO_Remap2_CAN1 ((uint32)0x001D6000) /* 11: CAN_RX mapped to PD0, CAN_TX mapped to PD1 */
#define GPIO_Remap_PD01 ((uint32)0x00008000) /* PD01 Alternate Function mapping */
#define GPIO_Remap_TIM5CH4_LSI ((uint32)0x00200001) /* LSI connected to TIM5 Channel4 input capture for calibration */
#define GPIO_Remap_ADC1_ETRGINJ ((uint32)0x00200002) /* ADC1 External Trigger Injected Conversion remapping */
#define GPIO_Remap_ADC1_ETRGREG ((uint32)0x00200004) /* ADC1 External Trigger Regular Conversion remapping */
#define GPIO_Remap_ADC2_ETRGINJ ((uint32)0x00200008) /* ADC2 External Trigger Injected Conversion remapping */
#define GPIO_Remap_ADC2_ETRGREG ((uint32)0x00200010) /* ADC2 External Trigger Regular Conversion remapping */
#define GPIO_Remap_ETH ((uint32)0x00200020) /* Ethernet remapping (only for Connectivity line devices) */
#define GPIO_Remap_CAN2 ((uint32)0x00200040) /* CAN2 remapping (only for Connectivity line devices) */
#define GPIO_Remap_SWJ_NoJTRST ((uint32)0x00300100) /* Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */
#define GPIO_Remap_SWJ_JTAGDisable ((uint32)0x00300200) /* JTAG-DP Disabled and SW-DP Enabled */
#define GPIO_Remap_SWJ_Disable ((uint32)0x00300400) /* Full SWJ Disabled (JTAG-DP + SW-DP) */
#define GPIO_Remap_SPI3 ((uint32)0x00201000) /* SPI3/I2S3 Alternate Function mapping (only for Connectivity line devices) */
#define GPIO_Remap_TIM2ITR1_PTP_SOF ((uint32)0x00202000) /* Ethernet PTP output or USB OTG SOF (Start of Frame) connected
to TIM2 Internal Trigger 1 for calibration
(only for Connectivity line devices) */
#define GPIO_Remap_PTP_PPS ((uint32)0x00204000) /* Ethernet MAC PPS_PTS output on PB05 (only for Connectivity line devices) */
#define GPIO_Remap_TIM15 ((uint32)0x80000001) /* TIM15 Alternate Function mapping (only for Value line devices) */
#define GPIO_Remap_TIM16 ((uint32)0x80000002) /* TIM16 Alternate Function mapping (only for Value line devices) */
#define GPIO_Remap_TIM17 ((uint32)0x80000004) /* TIM17 Alternate Function mapping (only for Value line devices) */
#define GPIO_Remap_CEC ((uint32)0x80000008) /* CEC Alternate Function mapping (only for Value line devices) */
#define GPIO_Remap_TIM1_DMA ((uint32)0x80000010) /* TIM1 DMA requests mapping (only for Value line devices) */
#define GPIO_Remap_TIM9 ((uint32)0x80000020) /* TIM9 Alternate Function mapping (only for XL-density devices) */
#define GPIO_Remap_TIM10 ((uint32)0x80000040) /* TIM10 Alternate Function mapping (only for XL-density devices) */
#define GPIO_Remap_TIM11 ((uint32)0x80000080) /* TIM11 Alternate Function mapping (only for XL-density devices) */
#define GPIO_Remap_TIM13 ((uint32)0x80000100) /* TIM13 Alternate Function mapping (only for XL-density devices) */
#define GPIO_Remap_TIM14 ((uint32)0x80000200) /* TIM14 Alternate Function mapping (only for XL-density devices) */
#define GPIO_Remap_FSMC_NADV ((uint32)0x80000400) /* FSMC_NADV Alternate Function mapping (only for XL-density devices) */
void gpio_remap(uint32 GPIO_Remap, uint8 NewState);
uint32 DBGMCU_GetREVID(void);
uint32 DBGMCU_GetDEVID(void);
#ifdef __cplusplus
} // extern "C"
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment