
#include <stm32f0xx.h>
#include <string.h>


int main() {

	RCC_HSICmd(ENABLE);
	RCC_HCLKConfig(RCC_SYSCLK_Div1);
	RCC_PCLKConfig(RCC_HCLK_Div1);
	RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);


	RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);


	init.GPIO_Mode=GPIO_Mode_AF;

	init.GPIO_Pin=GPIO_Pin_6;
	GPIO_Init(GPIOB,&init);

	init.GPIO_Pin=GPIO_Pin_6;
	init.GPIO_Mode=GPIO_Mode_AF;
	init.GPIO_Speed=GPIO_Speed_2MHz;
	init.GPIO_PuPd=GPIO_PuPd_DOWN;

	GPIO_Init(GPIOA,&init);


	GPIO_PinAFConfig(GPIOA,GPIO_PinSource6,GPIO_AF_1);

	

	TIM_TimeBaseInitTypeDef timBase;
	timBase.TIM_ClockDivision=TIM_CKD_DIV1;
	timBase.TIM_CounterMode=TIM_CounterMode_Up;
	timBase.TIM_Period=0xFFFF;
	timBase.TIM_Prescaler=8;

	TIM_TimeBaseInit(TIM3,&timBase);


	TIM_ICInitTypeDef timIC;
	timIC.TIM_Channel=TIM_Channel_1;
	timIC.TIM_ICFilter=0;
	timIC.TIM_ICPolarity=TIM_ICPolarity_Rising;
	timIC.TIM_ICSelection=TIM_ICSelection_DirectTI;
	TIM_ICInit(TIM3,&timIC);

	timIC.TIM_Channel=TIM_Channel_2;
	timIC.TIM_ICFilter=0;
	timIC.TIM_ICPolarity=TIM_ICPolarity_Falling;
	timIC.TIM_ICSelection=TIM_ICSelection_IndirectTI;
	TIM_ICInit(TIM3,&timIC);


	TIM_SelectInputTrigger(TIM3,TIM_TS_TI1FP1);
	TIM_SelectSlaveMode(TIM3,TIM_SlaveMode_Reset);



	TIM_CCxCmd(TIM3,TIM_Channel_1,TIM_CCx_Enable);
	TIM_CCxCmd(TIM3,TIM_Channel_2,TIM_CCx_Enable);

	TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);
	TIM_Cmd(TIM3,ENABLE);

	
	while(1) {


	}

}

