diff --git a/dmx512_micro/dmx512_micro.cpp b/dmx512_micro/dmx512_micro.cpp index becc1b3..5c52547 100644 --- a/dmx512_micro/dmx512_micro.cpp +++ b/dmx512_micro/dmx512_micro.cpp @@ -35,6 +35,7 @@ int main(void) byte tab_input_pc[514]; // venant du pc byte tab_input_dmx[518]; // données venant de l'extérieur : les 512 premiers DMX; les 4 suivant 4x8 bp ; byte tab_temp_dmx[TEMPDMXRX]; +byte inbuffer[6]; // reception volatile int index_input_pc=0; // entrée serial 0 @@ -63,7 +64,6 @@ volatile bool emissionPc=0; // Fonctions -void litUSB(char c); void ecritUSB(); void CDC_accept(); @@ -71,26 +71,20 @@ void CDC_accept(); // l'interet est de ne pas utiliser le buffer de la classe Serial, trop petit (64o) void CDC_accept() { - int c = USB_Recv(CDC_RX); - litUSB(c); -} - -// lecture d'un caractere sur USB -void litUSB(char c) -{ - //char c; + char c; byte *pb, *pe; switch (etat_input_pc) { case 0: + USB_Recv(CDC_RX,&c,1); // on attend un 'esc' pour commencer if (c==27) { etat_input_pc=1; break;} - break; case 1: + USB_Recv(CDC_RX,&c,1); // on attend 'D' pour recevoir if (c==68) { etat_input_pc=2; @@ -116,7 +110,7 @@ void litUSB(char c) } // Esc 'B' parametrage - if (c==66) {etat_input_pc=10; + if (c==66) {etat_input_pc=10;index_input_pc=0; } // Esc 'A' probe @@ -132,33 +126,23 @@ void litUSB(char c) case 2: // reception trame pc // on rempli le tableau - tab_input_pc[index_input_pc]=c; - index_input_pc++; + index_input_pc+=USB_Recv(CDC_RX,tab_input_pc+index_input_pc,513-index_input_pc); // si on arrive à 512 - if (index_input_pc > 512) {// on se prépare à emmetre vers le pc + if (index_input_pc > 512) { etat_input_pc=0; } break; - case 10: // 1er parametre : nb de circuits / 2 - 1 ( de 2 a 512 ) - etat_input_pc++; + case 10: + index_input_pc+=USB_Recv(CDC_RX,inbuffer+index_input_pc,4-index_input_pc); + if(index_input_pc<4) return; + + //nb_circuits= ((int)inbuffer[0])*2 + 2; + brk_timer_end = (inbuffer[1]/2); + mab_timer_end = (inbuffer[2]/2); + flag_merge1 = inbuffer[3] & 1; - //nb_circuits= ((int)c)*2 + 2; - break; - - case 11: // 2nd parametre : duree du break en us - etat_input_pc++; - brk_timer_end = (c/2); - break; - - case 12: // 3eme parametre : duree du mab en us - etat_input_pc++; - mab_timer_end = (c/2); - break; - - case 13: // 4eme parametre : merge etat_input_pc=0; - flag_merge1 = c & 1; // on a tout recu, on reponds tab_input_dmx[517]=66;