CARME-M4 BSP  V1.5
stm32f4xx_syscfg.c
Go to the documentation of this file.
1 
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32f4xx_syscfg.h"
51 #include "stm32f4xx_rcc.h"
52 
62 /* Private typedef -----------------------------------------------------------*/
63 /* Private define ------------------------------------------------------------*/
64 /* ------------ RCC registers bit address in the alias region ----------- */
65 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
66 /* --- MEMRMP Register ---*/
67 /* Alias word address of UFB_MODE bit */
68 #define MEMRMP_OFFSET SYSCFG_OFFSET
69 #define UFB_MODE_BitNumber ((uint8_t)0x8)
70 #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BitNumber * 4))
71 
72 
73 /* --- PMC Register ---*/
74 /* Alias word address of MII_RMII_SEL bit */
75 #define PMC_OFFSET (SYSCFG_OFFSET + 0x04)
76 #define MII_RMII_SEL_BitNumber ((uint8_t)0x17)
77 #define PMC_MII_RMII_SEL_BB (PERIPH_BB_BASE + (PMC_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4))
78 
79 /* --- CMPCR Register ---*/
80 /* Alias word address of CMP_PD bit */
81 #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
82 #define CMP_PD_BitNumber ((uint8_t)0x00)
83 #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4))
84 
85 /* Private macro -------------------------------------------------------------*/
86 /* Private variables ---------------------------------------------------------*/
87 /* Private function prototypes -----------------------------------------------*/
88 /* Private functions ---------------------------------------------------------*/
89 
100 void SYSCFG_DeInit(void)
101 {
102  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
103  RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, DISABLE);
104 }
105 
118 void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap)
119 {
120  /* Check the parameters */
121  assert_param(IS_SYSCFG_MEMORY_REMAP_CONFING(SYSCFG_MemoryRemap));
122 
123  SYSCFG->MEMRMP = SYSCFG_MemoryRemap;
124 }
125 
139 void SYSCFG_MemorySwappingBank(FunctionalState NewState)
140 {
141  /* Check the parameters */
142  assert_param(IS_FUNCTIONAL_STATE(NewState));
143 
144  *(__IO uint32_t *) UFB_MODE_BB = (uint32_t)NewState;
145 }
146 
162 void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
163 {
164  uint32_t tmp = 0x00;
165 
166  /* Check the parameters */
167  assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx));
168  assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex));
169 
170  tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03));
171  SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp;
172  SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)));
173 }
174 
183 void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface)
184 {
185  assert_param(IS_SYSCFG_ETH_MEDIA_INTERFACE(SYSCFG_ETH_MediaInterface));
186  /* Configure MII_RMII selection bit */
187  *(__IO uint32_t *) PMC_MII_RMII_SEL_BB = SYSCFG_ETH_MediaInterface;
188 }
189 
200 void SYSCFG_CompensationCellCmd(FunctionalState NewState)
201 {
202  /* Check the parameters */
203  assert_param(IS_FUNCTIONAL_STATE(NewState));
204 
205  *(__IO uint32_t *) CMPCR_CMP_PD_BB = (uint32_t)NewState;
206 }
207 
214 {
215  FlagStatus bitstatus = RESET;
216 
217  if ((SYSCFG->CMPCR & SYSCFG_CMPCR_READY ) != (uint32_t)RESET)
218  {
219  bitstatus = SET;
220  }
221  else
222  {
223  bitstatus = RESET;
224  }
225  return bitstatus;
226 }
227 
240 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
This file contains all the functions prototypes for the RCC firmware library.
FlagStatus SYSCFG_GetCompensationCellStatus(void)
Checks whether the I/O Compensation Cell ready flag is set or not.
void SYSCFG_CompensationCellCmd(FunctionalState NewState)
Enables or disables the I/O Compensation Cell.
This file contains all the functions prototypes for the SYSCFG firmware library.
void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap)
Changes the mapping of the specified pin.
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
Selects the GPIO pin used as EXTI Line.
void SYSCFG_DeInit(void)
Deinitializes the Alternate Functions (remap and EXTI configuration) registers to their default reset...
void SYSCFG_MemorySwappingBank(FunctionalState NewState)
Enables or disables the Interal FLASH Bank Swapping.
void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface)
Selects the ETHERNET media interface.
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Forces or releases High Speed APB (APB2) peripheral reset.