From 479f270bb72961a4d2b6d5b9c51bafc815cbf122 Mon Sep 17 00:00:00 2001 From: dalmais Date: Tue, 19 Apr 2005 20:20:09 +0000 Subject: la tourelle marche test des sharps. --- n/es/src/avrconfig.h | 4 ++-- n/es/src/main.c | 23 ++++++++++++++++------- n/es/src/tourelle.c | 42 +++++++++++++++++++++++++++++++----------- n/es/src/tourelle.h | 2 +- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/n/es/src/avrconfig.h b/n/es/src/avrconfig.h index 3fd9eb1..fa38a0b 100644 --- a/n/es/src/avrconfig.h +++ b/n/es/src/avrconfig.h @@ -37,9 +37,9 @@ /** Send mode : * - POLLING : no interrupts; * - RING : interrupts, ring buffer. */ -#define AC_RS232_SEND_MODE RING +#define AC_RS232_SEND_MODE POLLING /** Recv mode, same as send mode. */ -#define AC_RS232_RECV_MODE RING +#define AC_RS232_RECV_MODE POLLING /** Character size : 5, 6, 7, 8, 9 (only 8 implemented). */ #define AC_RS232_CHAR_SIZE 8 /** Parity : ODD, EVEN, NONE. */ diff --git a/n/es/src/main.c b/n/es/src/main.c index bd2b80f..bcb123c 100644 --- a/n/es/src/main.c +++ b/n/es/src/main.c @@ -37,7 +37,7 @@ uint8_t sens = 1; // sens du scan uint8_t continu = 0; // demande fait d'un envoi en continu sur le RS232 uint8_t envoie = 0; // demande fait par I2C d'un envoi char buffer_serie ; // buffer RS232 -const uint16_t prescaler = 1024;// prescaler +const uint16_t prescaler = 8;// prescaler uint16_t tableau_longueur[25]; int main (void) @@ -47,29 +47,38 @@ int main (void) uint16_t tableau_sharp[3]; /// intialisation + DDRD = 0x80; rs232_init (); + rs232_putc('R'); twi_init (0x02); tourelle_init (prescaler); adc_init (); - sei (); + + + + sei (); // on met les interruptions - rs232_putc('I'); + rs232_putc('1'); // fin de l'initialisation /// programme principal - while(1) + while(1) // boucle principale { if(etat == 1) { - etat = 0; + rs232_putc('2'); + etat = 0; // METTRE L'ACTIVATION DE L'INTERRUPTION - TCNT1 = (65535L - ((20L*14745600L)/(1024L*1000L))); // LE PASSER EN COMPARATEUR. + TCNT1 = 5; //(65535L - ((20L*14745600L)/(1024L*1000L))); // LE PASSER EN COMPARATEUR. + if(temp_sens != sens) { + rs232_putc('S'); temp_sens = sens; // if(continu == 1) renvoi_RS232(); // nom de la fonction qui renvoie la valeur } // if(buffer_serie != 0) callback_RS232(); + TIMSK |= 0x04; } for(compteur=0;compteur<3;compteur++) @@ -78,7 +87,7 @@ int main (void) while(!adc_checkf()){} tableau_sharp[compteur]=adc_read(); } - twi_update (tableau_sharp,6); +twi_update (tableau_sharp,6); } } diff --git a/n/es/src/tourelle.c b/n/es/src/tourelle.c index 7d07298..62f037f 100644 --- a/n/es/src/tourelle.c +++ b/n/es/src/tourelle.c @@ -28,7 +28,7 @@ const uint8_t delayMax = 125; const uint8_t delayMin = 175; const uint8_t pin_sharp = 3 ; uint8_t delay = 0; -const uint8_t SEUIL = 180; // 10 cm = 2.25V et 80 cm = 1.75 V +const uint8_t SEUIL = 280; // 10 cm = 2.25V et 80 cm = 1.75 V const uint8_t MILIEU = 2; // const int8_t PROUT = 12; A VERIFIER !! @@ -62,19 +62,33 @@ uint8_t nombre_ancien = 0; void tourelle_init (uint16_t prescaler) { - delay = 0; - DDRC = 0x80; + delay = 135; SFIOR |= 0x01; // prescaler autorisé - + + rs232_putc('T'); crenaux(delay,PORTC,7); // on met le capteur à 0° delay_ms(20L); crenaux(delay,PORTC,7); delay_ms(20L); + crenaux(delay,PORTC,7); // on met le capteur à 0° + delay_ms(20L); + DDRD = 0x80; + crenaux(delay,PORTD,7); + delay_ms(20L); + crenaux(delay,PORTD,7); + rs232_putc('C'); + + crenaux(delay,PORTC,7); // on met le capteur à 0° + delay_ms(20L); + crenaux(delay,PORTC,7); + delay_ms(20L); + rs232_putc('F'); + switch(prescaler) { @@ -110,13 +124,13 @@ void tourelle_init (uint16_t prescaler) void crenaux(uint8_t temps, uint8_t port, uint8_t pin) { uint8_t delay_crenaux = 0; - port |= _BV (pin); // en admettant que je sois sur le portb et la troisième pin + PORTD |= _BV (7); // en admettant que je sois sur le portb et la troisième pin for(delay_crenaux=0;delay_crenaux SEUIL ) { if(nombre_actuel == 0) @@ -213,6 +229,10 @@ SIGNAL (SIG_INTERRUPT1) } } + */ + + TournerTourelle (); etat = 1; + rs232_putc('4'); } diff --git a/n/es/src/tourelle.h b/n/es/src/tourelle.h index 402d19f..79091b8 100644 --- a/n/es/src/tourelle.h +++ b/n/es/src/tourelle.h @@ -27,7 +27,7 @@ #include "n/avr/utils/utils.h" #include "n/avr/twi-slave/twi_slave.h" #include "n/avr/adc/adc.h" - +#include "n/avr/proto/proto.h" /* proto */ void tourelle_init (uint16_t prescaler); -- cgit v1.2.3