summaryrefslogtreecommitdiff
path: root/n/es/src/tourelle.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/es/src/tourelle.c')
-rw-r--r--n/es/src/tourelle.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/n/es/src/tourelle.c b/n/es/src/tourelle.c
index 1a65864..7d07298 100644
--- a/n/es/src/tourelle.c
+++ b/n/es/src/tourelle.c
@@ -40,12 +40,15 @@ const uint8_t MILIEU = 2;
* 1 = continu */
uint16_t tableau_longueur[25];
-/*
+
extern uint8_t continu;
+
extern uint8_t etat;
+
extern uint8_t envoie;
+
extern uint8_t sens;
-*/
+
uint8_t valeur_actuelle1 = 0;
uint8_t valeur_actuelle2 = 0;
uint8_t angle_actuel1 = 0;
@@ -60,17 +63,17 @@ uint8_t nombre_ancien = 0;
void tourelle_init (uint16_t prescaler)
{
delay = 0;
- DDRB = 0x07;
+ DDRC = 0x80;
SFIOR |= 0x01; // prescaler autorisé
- crenaux(delay,PORTB,7); // on met le capteur à 0°
+ crenaux(delay,PORTC,7); // on met le capteur à 0°
delay_ms(20L);
- crenaux(delay,PORTB,7);
+ crenaux(delay,PORTC,7);
delay_ms(20L);
- crenaux(delay,PORTB,7);
+ crenaux(delay,PORTC,7);
switch(prescaler)
{
@@ -107,16 +110,16 @@ void tourelle_init (uint16_t prescaler)
void crenaux(uint8_t temps, uint8_t port, uint8_t pin)
{
uint8_t delay_crenaux = 0;
- port |= pin; // en admettant que je sois sur le portb et la troisième pin
+ port |= _BV (pin); // en admettant que je sois sur le portb et la troisième pin
for(delay_crenaux=0;delay_crenaux<temps;delay_crenaux++)
{
delay_us(10L);
}
- port &= 0xFF - pin; // on remet l'impulsion à 0
+ port &= ~_BV (pin); // on remet l'impulsion à 0
}
-void rs232_callback (uint8_t cmd, uint8_t size, uint8_t *args, uint8_t *etat,uint8_t *envoie)
+void rs232_callback (uint8_t cmd, uint8_t size,uint8_t* args)
{
#define c(cmd, size) (cmd << 8 | size)
switch (c (cmd, size))
@@ -126,26 +129,26 @@ void rs232_callback (uint8_t cmd, uint8_t size, uint8_t *args, uint8_t *etat,uin
/* Commands. */
case c ('c', 0):{ // continu
- (*etat) = 1;
- (*envoie) = 1;
+ etat = 1;
+ envoie = 1;
// if(c(0,1)) sendValeur(); /// METTRE LA BONNE FONCTION
}break;
case c ('u',0):{ // unique
- (*envoie) = 0;
+ envoie = 0;
// sendValeur(); /// METTRE LA BONNE FONCTION
etat = 0;
}break;
case c ('s',0): { // stop
- (*etat) = 0;
- (*envoie) = 0;
+ etat = 0;
+ envoie = 0;
}break;
}
}
-void TournerTourelle(uint8_t sens)
+void TournerTourelle(void)
{
if( delay==delayMax || delay==delayMin)
{
@@ -163,7 +166,7 @@ void TournerTourelle(uint8_t sens)
}
delay += 2 * sens;
- crenaux(delay,PORTB,0x07);
+ crenaux(delay,PORTC,0x07);
}
int16_t mesurer(void)
@@ -181,6 +184,9 @@ SIGNAL (SIG_INTERRUPT1)
uint8_t i = 0;
uint8_t temp = 0;
+
+ TournerTourelle ();
+
for(i=0;i<(MILIEU*2+1);i++)
{
if(temp < tableau_longueur [i]) temp = tableau_longueur[i];
@@ -207,6 +213,6 @@ SIGNAL (SIG_INTERRUPT1)
}
}
-
+ etat = 1;
}