forked from trocache/RefKEIL
36 lines
841 B
C
36 lines
841 B
C
#include "stm32f10x.h"
|
|
#include "../../Drivers/gpiodriver.h"
|
|
#include "../../Drivers/timerdriver.h"
|
|
|
|
void ToggleLed(void)
|
|
{
|
|
MyGPIO_Toggle(GPIOA,5);
|
|
}
|
|
|
|
int main (void)
|
|
{
|
|
MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
|
|
MyGPIO_Struct_TypeDef pwm1timer1 = {GPIOA,1,AltOut_Ppull};
|
|
MyTimer_Struct_TypeDef timer2 = {TIM2,499,7199}; //timer
|
|
|
|
//init & start LED, PWM, Timer
|
|
MyGPIO_Init(&led);
|
|
MyGPIO_Init(&pwm1timer1);
|
|
MyTimer_Base_Init(&timer2);
|
|
MyTimer_Base_Start(TIM2);
|
|
|
|
//Init Interruption & Activate
|
|
Init_Periph(ToggleLed);
|
|
MyTimer_ActiveIT(TIM2,2);
|
|
|
|
//PWM enable
|
|
MyPWM_Struct_TypeDef timer2channel2 = {TIM2,1,400};
|
|
MyTimer_PWM_Init(&timer2channel2);
|
|
//TIM2->CCMR1 |= (0x6<<12);
|
|
//TIM2->BDTR |= (1<<MOE);
|
|
//TIM2->CCR2 = 10;
|
|
//TIM2->CCER |= (1<<4); //0 pour CC1E, 4 pour CC2E // 4*(channel-1)
|
|
do{
|
|
}while(1) ;
|
|
|
|
}
|