corrections
utilisation de defines pour les etats de brk, mab ...
This commit is contained in:
parent
e4c0d123cc
commit
a73b8236b0
2 changed files with 20 additions and 15 deletions
|
|
@ -40,7 +40,12 @@ byte tab_temp_dmx[TEMPDMXRX];
|
|||
volatile int index_input_pc=0; // entrée serial 0
|
||||
volatile int index_output_pc=0; // sortie serial 0
|
||||
volatile int index_input_dmx=513; // entrée dmx
|
||||
volatile int index_output_dmx=0; //sortie dmx -2 en attente de fin de transmission; -1 break; 0 à 512 transmission
|
||||
volatile int index_output_dmx=0; //sortie dmx
|
||||
|
||||
#define IOUTDMX_FIN -4
|
||||
#define IOUTDMX_IDLE -1
|
||||
#define IOUTDMX_BRK -2
|
||||
#define IOUTDMX_MAB -3
|
||||
|
||||
volatile int etat_input_pc=0; // 0 raz ; 1 esc reçu ; 2 D reçu : pret à recevoir ; 3 prèt à emmetre
|
||||
|
||||
|
|
@ -216,8 +221,8 @@ ISR(USART1_RX_vect)
|
|||
ISR(USART1_TX_vect)
|
||||
{
|
||||
// si l'USART 1 est vide => break
|
||||
if(index_output_dmx==-4){
|
||||
index_output_dmx=-1;
|
||||
if(index_output_dmx==IOUTDMX_FIN){
|
||||
index_output_dmx=IOUTDMX_IDLE;
|
||||
}
|
||||
}
|
||||
// vecteur : USART 1 transmission registre vide
|
||||
|
|
@ -230,21 +235,21 @@ ISR(USART1_UDRE_vect)
|
|||
}
|
||||
// si 512 transmits => mise en attente de fin de transmission
|
||||
// desactivation de l'intéruption sur le registre
|
||||
if (index_output_dmx>nb_circuits) {index_output_dmx=-4;cbi(UCSR1B, UDRIE1);}
|
||||
if (index_output_dmx>nb_circuits) {index_output_dmx=IOUTDMX_FIN;cbi(UCSR1B, UDRIE1);}
|
||||
|
||||
}
|
||||
|
||||
ISR(TIMER4_COMPA_vect) {
|
||||
if (index_output_dmx==-2 ) {
|
||||
if (index_output_dmx==IOUTDMX_BRK ) {
|
||||
digitalWrite(tx1pin, HIGH); // on met la broche à 1
|
||||
|
||||
index_output_dmx=-3;
|
||||
index_output_dmx=IOUTDMX_MAB;
|
||||
OCR4A = mab_timer_end ;
|
||||
TCNT4 = 0 ;// RAZ compteur timer
|
||||
TIFR4 = 0 ; //Clear Flags timer
|
||||
return;
|
||||
}
|
||||
if (index_output_dmx==-3 ) {
|
||||
if (index_output_dmx==IOUTDMX_MAB ) {
|
||||
sbi(UCSR1B, TXEN1); // on redémarre la transmission
|
||||
index_output_dmx=0; // on se prépare à émmettre à partir du stat code ( 513 octets )
|
||||
sbi(UCSR1B, UDRIE1); // on réactive l'intéruption du registre
|
||||
|
|
@ -290,7 +295,7 @@ void setup() {
|
|||
sei();
|
||||
|
||||
// préparation du premier break
|
||||
index_output_dmx=-1;
|
||||
index_output_dmx=IOUTDMX_IDLE;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -299,8 +304,8 @@ void loop() {
|
|||
// lancement du break
|
||||
|
||||
|
||||
if (index_output_dmx==-1 ) {
|
||||
index_output_dmx=-2;
|
||||
if (index_output_dmx==IOUTDMX_IDLE ) {
|
||||
index_output_dmx=IOUTDMX_BRK;
|
||||
pinMode(tx1pin, OUTPUT); // on met la broche en mode sortie
|
||||
cbi(UCSR1B, TXEN1); //on stop la transmission
|
||||
digitalWrite(tx1pin, LOW); // on met la broche à 0
|
||||
|
|
@ -334,9 +339,9 @@ void loop() {
|
|||
else RXLED0;
|
||||
if(txledcpt) txledcpt--;
|
||||
else TXLED0;
|
||||
}
|
||||
if(blkcpt>=blinkon) { digitalWrite(ledPin, HIGH); }
|
||||
if(blkcpt>=blinkp){ digitalWrite(ledPin, LOW); blkcpt=0; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -67,13 +67,13 @@ SIGNAL(TIMER0_OVF_vect)
|
|||
unsigned long millis()
|
||||
{
|
||||
unsigned long m;
|
||||
//uint8_t oldSREG = SREG;
|
||||
uint8_t oldSREG = SREG;
|
||||
|
||||
// disable interrupts while we read timer0_millis or we might get an
|
||||
// inconsistent value (e.g. in the middle of a write to timer0_millis)
|
||||
//cli();
|
||||
cli();
|
||||
m = timer0_millis;
|
||||
//SREG = oldSREG;
|
||||
SREG = oldSREG;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue