51 lines
984 B
C
51 lines
984 B
C
#include "DriverJeuLaser.h"
|
|
|
|
extern void timer_callback_son(void);
|
|
|
|
extern void start_son(void);
|
|
int bouton = 0 ;
|
|
|
|
int main(void)
|
|
{
|
|
|
|
// ===========================================================================
|
|
// ============= INIT PERIPH (faites qu'une seule fois) =====================
|
|
// ===========================================================================
|
|
|
|
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
|
|
CLOCK_Configure();
|
|
|
|
// configuration du Timer 4 en débordement 91 microsecondes
|
|
|
|
Timer_1234_Init_ff( TIM4, 91*72);
|
|
|
|
int Periode_ticks = 720;
|
|
|
|
PWM_Init_ff(TIM3, 3, Periode_ticks);
|
|
|
|
/* Calcul fPWM */
|
|
int fPWM ;
|
|
fPWM = (1/Periode_ticks)*72000000 ;
|
|
|
|
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
|
|
|
|
|
|
|
Active_IT_Debordement_Timer( TIM4, 2, timer_callback_son );
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
while (1)
|
|
{
|
|
if (bouton == 1) {
|
|
start_son();
|
|
bouton = 0;
|
|
}
|
|
}
|
|
}
|
|
|