123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513 |
- #include "stm32f4xx_syscfg.h"
- #include "stm32f4xx_rcc.h"
-
- #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
-
-
- #define MEMRMP_OFFSET SYSCFG_OFFSET
- #define UFB_MODE_BitNumber ((uint8_t)0x8)
- #define UFB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (UFB_MODE_BitNumber * 4))
-
-
-
- #define PMC_OFFSET (SYSCFG_OFFSET + 0x04)
- #define MII_RMII_SEL_BitNumber ((uint8_t)0x17)
- #define PMC_MII_RMII_SEL_BB (PERIPH_BB_BASE + (PMC_OFFSET * 32) + (MII_RMII_SEL_BitNumber * 4))
-
-
-
- #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20)
- #define CMP_PD_BitNumber ((uint8_t)0x00)
- #define CMPCR_CMP_PD_BB (PERIPH_BB_BASE + (CMPCR_OFFSET * 32) + (CMP_PD_BitNumber * 4))
-
-
- #define MCHDLYCR_OFFSET (SYSCFG_OFFSET + 0x30)
- #define BSCKSEL_BIT_NUMBER POSITION_VAL(SYSCFG_MCHDLYCR_BSCKSEL)
- #define MCHDLYCR_BSCKSEL_BB (uint32_t)(PERIPH_BB_BASE + (MCHDLYCR_OFFSET * 32) + (BSCKSEL_BIT_NUMBER * 4))
-
- void SYSCFG_DeInit(void)
- {
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, DISABLE);
- }
- void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap)
- {
-
- assert_param(IS_SYSCFG_MEMORY_REMAP_CONFING(SYSCFG_MemoryRemap));
- SYSCFG->MEMRMP = SYSCFG_MemoryRemap;
- }
- void SYSCFG_MemorySwappingBank(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- *(__IO uint32_t *) UFB_MODE_BB = (uint32_t)NewState;
- }
- void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
- {
- uint32_t tmp = 0x00;
-
- assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx));
- assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex));
- tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03));
- SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp;
- SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)));
- }
- void SYSCFG_ETH_MediaInterfaceConfig(uint32_t SYSCFG_ETH_MediaInterface)
- {
- assert_param(IS_SYSCFG_ETH_MEDIA_INTERFACE(SYSCFG_ETH_MediaInterface));
-
- *(__IO uint32_t *) PMC_MII_RMII_SEL_BB = SYSCFG_ETH_MediaInterface;
- }
- void SYSCFG_CompensationCellCmd(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- *(__IO uint32_t *) CMPCR_CMP_PD_BB = (uint32_t)NewState;
- }
- FlagStatus SYSCFG_GetCompensationCellStatus(void)
- {
- FlagStatus bitstatus = RESET;
-
- if ((SYSCFG->CMPCR & SYSCFG_CMPCR_READY ) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
- }
- #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F413_423xx)
- void SYSCFG_BreakConfig(uint32_t SYSCFG_Break)
- {
-
- assert_param(IS_SYSCFG_LOCK_CONFIG(SYSCFG_Break));
- SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Break;
- }
- #endif
- #if defined(STM32F413_423xx)
- void DFSDM_BitstreamClock_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- tmp = (tmp &(~SYSCFG_MCHDLYCR_BSCKSEL));
- SYSCFG->MCHDLYCR = (tmp|source);
- }
- void DFSDM_DisableDelayClock(uint32_t MCHDLY)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- if(MCHDLY == MCHDLY_CLOCK_DFSDM2)
- {
- tmp =tmp &(~SYSCFG_MCHDLYCR_MCHDLY2EN);
- }
- else
- {
- tmp =tmp &(~SYSCFG_MCHDLYCR_MCHDLY1EN);
- }
- SYSCFG->MCHDLYCR = tmp;
- }
- void DFSDM_EnableDelayClock(uint32_t MCHDLY)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- tmp = tmp & ~MCHDLY;
- SYSCFG->MCHDLYCR = (tmp|MCHDLY);
- }
- void DFSDM_ClockIn_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- if((source == DFSDM2_CKIN_PAD) || (source == DFSDM2_CKIN_DM))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CFG);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1CFG);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM_ClockOut_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- if((source == DFSDM2_CKOUT_DFSDM2) || (source == DFSDM2_CKOUT_M27))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CKOSEL);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1CKOSEL);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM_DataIn0_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
-
- if((source == DATAIN0_DFSDM2_PAD)|| (source == DATAIN0_DFSDM2_DATAIN1))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2D0SEL);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1D0SEL);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM_DataIn2_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
-
- if((source == DATAIN2_DFSDM2_PAD)|| (source == DATAIN2_DFSDM2_DATAIN3))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2D2SEL);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1D2SEL);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM_DataIn4_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2D4SEL);
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM_DataIn6_SourceSelection(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
-
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2D6SEL);
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM1_BitStreamClk_Config(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- if ((source == DFSDM1_CLKIN0_TIM4OC2) || (source == DFSDM1_CLKIN2_TIM4OC2))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1CK02SEL);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM1CK13SEL);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- void DFSDM2_BitStreamClk_Config(uint32_t source)
- {
- uint32_t tmp = 0;
-
- tmp = SYSCFG->MCHDLYCR;
- if ((source == DFSDM2_CLKIN0_TIM3OC4) || (source == DFSDM2_CLKIN4_TIM3OC4))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CK04SEL);
- }
- else if ((source == DFSDM2_CLKIN1_TIM3OC3) || (source == DFSDM2_CLKIN5_TIM3OC3))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CK15SEL);
-
- }else if ((source == DFSDM2_CLKIN2_TIM3OC2) || (source == DFSDM2_CLKIN6_TIM3OC2))
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CK26SEL);
- }
- else
- {
- tmp = (tmp & ~SYSCFG_MCHDLYCR_DFSDM2CK37SEL);
- }
- SYSCFG->MCHDLYCR |= (source|tmp);
- }
- #endif
|