This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (4) */ | |
GPIO_WriteBit(GPIOC , GPIO_Pin_9 , (ledval) ? Bit_SET : Bit_RESET); | |
ledval = 1 - ledval; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (3) */ | |
if (SysTick_Config(SystemCoreClock / 1000)) | |
while (1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* (5) */ | |
static __IO uint32_t TimingDelay; | |
void Delay(uint32_t nTime){ | |
TimingDelay = nTime; | |
while(TimingDelay != 0); | |
} | |
void SysTick_Handler(void){ | |
if (TimingDelay != 0x00) | |
TimingDelay --; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RCC_APB1PeriphClockCmd(uint32_t RCC_APB1PERIPH , FunctionalState NewState); | |
RCC_APB2PeriphClockCmd(uint32_t RCC_APB2PERIPH , FunctionalState NewState); | |
RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPERIPH , FunctionalState NewState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB , ENABLE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see stm32f10x_gpio.h | |
GPIO_InitTypeDef GPIO_InitStructure; | |
GPIO_StructInit (& GPIO_InitStructure); | |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; | |
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; | |
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; | |
GPIO_Init(GPIOC , &GPIO_InitStructure); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPIO_WriteBit(GPIOC , GPIO_Pin_9 , x); // x is Bit_SET or Bit_RESET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; | |
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; | |
GPIO_Init(GPIOA , &GPIO_InitStructure); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GPIO_ReadInputDataBit(GPIOA , GPIO_Pin_0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct | |
{ | |
volatile uint32_t CRL; | |
volatile uint32_t CRH; | |
volatile uint32_t IDR; | |
volatile uint32_t ODR; | |
volatile uint32_t BSRR; | |
volatile uint32_t BRR; | |
volatile uint32_t LCKR; | |
} GPIO_TypeDef; |