Skip to content

Instantly share code, notes, and snippets.

View hocarm's full-sized avatar
🎃
Focusing

hocarm

🎃
Focusing
View GitHub Profile
@hocarm
hocarm / RCC.c
Last active August 14, 2016 04:58
RCC_APB1PeriphClockCmd(uint32_t RCC_APB1PERIPH , FunctionalState NewState);
RCC_APB2PeriphClockCmd(uint32_t RCC_APB2PERIPH , FunctionalState NewState);
RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPERIPH , FunctionalState NewState);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB , ENABLE);
// 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);
GPIO_WriteBit(GPIOC , GPIO_Pin_9 , x); // x is Bit_SET or Bit_RESET
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA , &GPIO_InitStructure);
GPIO_ReadInputDataBit(GPIOA , GPIO_Pin_0);
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;