2 ******************************************************************************
\r
3 * @file stm32f4xx_syscfg.c
\r
4 * @author MCD Application Team
\r
6 * @date 30-September-2011
\r
7 * @brief This file provides firmware functions to manage the SYSCFG peripheral.
\r
11 * ===================================================================
\r
12 * How to use this driver
\r
13 * ===================================================================
\r
15 * This driver provides functions for:
\r
17 * 1. Remapping the memory accessible in the code area using SYSCFG_MemoryRemapConfig()
\r
19 * 2. Manage the EXTI lines connection to the GPIOs using SYSCFG_EXTILineConfig()
\r
21 * 3. Select the ETHERNET media interface (RMII/RII) using SYSCFG_ETH_MediaInterfaceConfig()
\r
23 * @note SYSCFG APB clock must be enabled to get write access to SYSCFG registers,
\r
24 * using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
\r
28 ******************************************************************************
\r
31 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
\r
32 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
\r
33 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
\r
34 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
\r
35 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
\r
36 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
\r
38 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
\r
39 ******************************************************************************
\r
42 /* Includes ------------------------------------------------------------------*/
\r
43 #include "stm32f4xx_syscfg.h"
\r
44 #include "stm32f4xx_rcc.h"
\r
46 /** @addtogroup STM32F4xx_StdPeriph_Driver
\r
50 /** @defgroup SYSCFG
\r
51 * @brief SYSCFG driver modules
\r
55 /* Private typedef -----------------------------------------------------------*/
\r
56 /* Private define ------------------------------------------------------------*/
\r
57 /* ------------ RCC registers bit address in the alias region ----------- */
\r
58 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
\r
59 /* --- PMC Register ---*/
\r
60 /* Alias word address of MII_RMII_SEL bit */
\r
61 #define PMC_OFFSET (SYSCFG_OFFSET + 0x04)
\r
62 #define MII_RMII_SEL_BitNumber ((uint8_t)0x17)
\r
63 #define PMC_MII_RMII_SEL_BB (PERIPH_BB_BASE + (PMC_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4))
\r
65 /* --- CMPCR Register ---*/
\r
66 /* Alias word address of CMP_PD bit */
\r
67 #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
\r
68 #define CMP_PD_BitNumber ((uint8_t)0x00)
\r
69 #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4))
\r
71 /* Private macro -------------------------------------------------------------*/
\r
72 /* Private variables ---------------------------------------------------------*/
\r
73 /* Private function prototypes -----------------------------------------------*/
\r
74 /* Private functions ---------------------------------------------------------*/
\r
76 /** @defgroup SYSCFG_Private_Functions
\r
81 * @brief Deinitializes the Alternate Functions (remap and EXTI configuration)
\r
82 * registers to their default reset values.
\r
86 void SYSCFG_DeInit(void)
\r
88 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
\r
89 RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, DISABLE);
\r
93 * @brief Changes the mapping of the specified pin.
\r
94 * @param SYSCFG_Memory: selects the memory remapping.
\r
95 * This parameter can be one of the following values:
\r
96 * @arg SYSCFG_MemoryRemap_Flash: Main Flash memory mapped at 0x00000000
\r
97 * @arg SYSCFG_MemoryRemap_SystemFlash: System Flash memory mapped at 0x00000000
\r
98 * @arg SYSCFG_MemoryRemap_FSMC: FSMC (Bank1 (NOR/PSRAM 1 and 2) mapped at 0x00000000
\r
99 * @arg SYSCFG_MemoryRemap_SRAM: Embedded SRAM (112kB) mapped at 0x00000000
\r
102 void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap)
\r
104 /* Check the parameters */
\r
105 assert_param(IS_SYSCFG_MEMORY_REMAP_CONFING(SYSCFG_MemoryRemap));
\r
107 SYSCFG->MEMRMP = SYSCFG_MemoryRemap;
\r
111 * @brief Selects the GPIO pin used as EXTI Line.
\r
112 * @param EXTI_PortSourceGPIOx : selects the GPIO port to be used as source for
\r
113 * EXTI lines where x can be (A..I).
\r
114 * @param EXTI_PinSourcex: specifies the EXTI line to be configured.
\r
115 * This parameter can be EXTI_PinSourcex where x can be (0..15, except
\r
116 * for EXTI_PortSourceGPIOI x can be (0..11).
\r
119 void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
\r
121 uint32_t tmp = 0x00;
\r
123 /* Check the parameters */
\r
124 assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx));
\r
125 assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex));
\r
127 tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03));
\r
128 SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp;
\r
129 SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)));
\r
133 * @brief Selects the ETHERNET media interface
\r
134 * @param SYSCFG_ETH_MediaInterface: specifies the Media Interface mode.
\r
135 * This parameter can be one of the following values:
\r
136 * @arg SYSCFG_ETH_MediaInterface_MII: MII mode selected
\r
137 * @arg SYSCFG_ETH_MediaInterface_RMII: RMII mode selected
\r
140 void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface)
\r
142 assert_param(IS_SYSCFG_ETH_MEDIA_INTERFACE(SYSCFG_ETH_MediaInterface));
\r
143 /* Configure MII_RMII selection bit */
\r
144 *(__IO uint32_t *) PMC_MII_RMII_SEL_BB = SYSCFG_ETH_MediaInterface;
\r
148 * @brief Enables or disables the I/O Compensation Cell.
\r
149 * @note The I/O compensation cell can be used only when the device supply
\r
150 * voltage ranges from 2.4 to 3.6 V.
\r
151 * @param NewState: new state of the I/O Compensation Cell.
\r
152 * This parameter can be one of the following values:
\r
153 * @arg ENABLE: I/O compensation cell enabled
\r
154 * @arg DISABLE: I/O compensation cell power-down mode
\r
157 void SYSCFG_CompensationCellCmd(FunctionalState NewState)
\r
159 /* Check the parameters */
\r
160 assert_param(IS_FUNCTIONAL_STATE(NewState));
\r
162 *(__IO uint32_t *) CMPCR_CMP_PD_BB = (uint32_t)NewState;
\r
166 * @brief Checks whether the I/O Compensation Cell ready flag is set or not.
\r
168 * @retval The new state of the I/O Compensation Cell ready flag (SET or RESET)
\r
170 FlagStatus SYSCFG_GetCompensationCellStatus(void)
\r
172 FlagStatus bitstatus = RESET;
\r
174 if ((SYSCFG->CMPCR & SYSCFG_CMPCR_READY ) != (uint32_t)RESET)
\r
197 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
\r