Amelioration lecture USB
This commit is contained in:
parent
1c751026e1
commit
6417d3adea
1 changed files with 15 additions and 31 deletions
|
|
@ -35,6 +35,7 @@ int main(void)
|
||||||
byte tab_input_pc[514]; // venant du pc
|
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_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 tab_temp_dmx[TEMPDMXRX];
|
||||||
|
byte inbuffer[6];
|
||||||
|
|
||||||
// reception
|
// reception
|
||||||
volatile int index_input_pc=0; // entrée serial 0
|
volatile int index_input_pc=0; // entrée serial 0
|
||||||
|
|
@ -63,7 +64,6 @@ volatile bool emissionPc=0;
|
||||||
|
|
||||||
// Fonctions
|
// Fonctions
|
||||||
|
|
||||||
void litUSB(char c);
|
|
||||||
void ecritUSB();
|
void ecritUSB();
|
||||||
void CDC_accept();
|
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)
|
// l'interet est de ne pas utiliser le buffer de la classe Serial, trop petit (64o)
|
||||||
void CDC_accept()
|
void CDC_accept()
|
||||||
{
|
{
|
||||||
int c = USB_Recv(CDC_RX);
|
char c;
|
||||||
litUSB(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lecture d'un caractere sur USB
|
|
||||||
void litUSB(char c)
|
|
||||||
{
|
|
||||||
//char c;
|
|
||||||
byte *pb, *pe;
|
byte *pb, *pe;
|
||||||
|
|
||||||
|
|
||||||
switch (etat_input_pc) {
|
switch (etat_input_pc) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
|
USB_Recv(CDC_RX,&c,1);
|
||||||
// on attend un 'esc' pour commencer
|
// on attend un 'esc' pour commencer
|
||||||
if (c==27) { etat_input_pc=1; break;}
|
if (c==27) { etat_input_pc=1; break;}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
USB_Recv(CDC_RX,&c,1);
|
||||||
// on attend 'D' pour recevoir
|
// on attend 'D' pour recevoir
|
||||||
if (c==68) {
|
if (c==68) {
|
||||||
etat_input_pc=2;
|
etat_input_pc=2;
|
||||||
|
|
@ -116,7 +110,7 @@ void litUSB(char c)
|
||||||
|
|
||||||
}
|
}
|
||||||
// Esc 'B' parametrage
|
// Esc 'B' parametrage
|
||||||
if (c==66) {etat_input_pc=10;
|
if (c==66) {etat_input_pc=10;index_input_pc=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Esc 'A' probe
|
// Esc 'A' probe
|
||||||
|
|
@ -132,33 +126,23 @@ void litUSB(char c)
|
||||||
|
|
||||||
case 2: // reception trame pc
|
case 2: // reception trame pc
|
||||||
// on rempli le tableau
|
// on rempli le tableau
|
||||||
tab_input_pc[index_input_pc]=c;
|
index_input_pc+=USB_Recv(CDC_RX,tab_input_pc+index_input_pc,513-index_input_pc);
|
||||||
index_input_pc++;
|
|
||||||
// si on arrive à 512
|
// 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;
|
etat_input_pc=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10: // 1er parametre : nb de circuits / 2 - 1 ( de 2 a 512 )
|
case 10:
|
||||||
etat_input_pc++;
|
index_input_pc+=USB_Recv(CDC_RX,inbuffer+index_input_pc,4-index_input_pc);
|
||||||
|
if(index_input_pc<4) return;
|
||||||
|
|
||||||
//nb_circuits= ((int)c)*2 + 2;
|
//nb_circuits= ((int)inbuffer[0])*2 + 2;
|
||||||
break;
|
brk_timer_end = (inbuffer[1]/2);
|
||||||
|
mab_timer_end = (inbuffer[2]/2);
|
||||||
|
flag_merge1 = inbuffer[3] & 1;
|
||||||
|
|
||||||
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;
|
etat_input_pc=0;
|
||||||
flag_merge1 = c & 1;
|
|
||||||
|
|
||||||
// on a tout recu, on reponds
|
// on a tout recu, on reponds
|
||||||
tab_input_dmx[517]=66;
|
tab_input_dmx[517]=66;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue