50 lines
757 B
C
50 lines
757 B
C
#include "stm32f10x.h"
|
|
#include <Driver_GPIO.h>
|
|
#include <MyTimer.h>
|
|
#include <MyADC.h>
|
|
|
|
int a ;
|
|
|
|
void Callback(void){
|
|
startADC();
|
|
a=read();
|
|
}
|
|
|
|
|
|
int main (void)
|
|
{
|
|
|
|
MyGPIO_Struct_TypeDef GPIOA0={
|
|
GPIOA,
|
|
0,
|
|
In_Floating
|
|
};
|
|
MyGPIO_Struct_TypeDef GPIOA1={
|
|
GPIOA,
|
|
1,
|
|
In_Floating
|
|
};
|
|
//char channel = 1;
|
|
|
|
// Configuration du timer
|
|
MyTimer_Struct_TypeDef TIM;
|
|
TIM.Timer = TIM2;
|
|
TIM.ARR = 360; // todo
|
|
TIM.PSC = 0;
|
|
|
|
MyTimer_Base_Init(&TIM);
|
|
|
|
TIM2->CCMR1 |= 0x1 << 8; //CH2
|
|
TIM2->CCMR1 |= 0x1 << 0; //CH1
|
|
TIM2->SMCR |= 0x1 << 0; // Capture Mode : 1 => seulement les fronts montants 2 => seulement les fronts descendants 3 => les 2
|
|
|
|
MyGPIO_Init(&GPIOA0);
|
|
MyGPIO_Init(&GPIOA1);
|
|
|
|
|
|
|
|
MyTimer_Base_Start(TIM2);
|
|
|
|
while (1) {
|
|
}
|
|
}
|