1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#if defined(__18CXX)
void main(void)
#else
int main(void)
#endif
{
char input_buffer[64];
LATA = 0xFF;
ADCON1 = 0x0F; // toutes les broches du PortA en Digital
TRISA &= 0xF0; // configuration des broches RA0 à RA3 en sorties
InitializeSystem();
TRISBbits.TRISB0=1; // RB0=INT0 en entree
INTCON2bits.RBPU=0; // Pull-Up sur le port B
while(1){
// Check bus status and service USB interrupts.
USBDeviceTasks(); // Interrupt or polling method. If using polling, must call
// this function periodically. This function will take care
// of processing and responding to SETUP transactions
// (such as during the enumeration process when you first
// plug in). USB hosts require that USB devices should accept
// and process SETUP packets in a timely fashion. Therefore,
// when using polling, this function should be called
// frequently (such as once about every 100 microseconds) at any
// time that a SETUP packet might reasonably be expected to
// be sent by the host to your device. In most cases, the
// USBDeviceTasks() function does not take very long to
// execute (~50 instruction cycles) before it returns.
// Application-specific tasks.
// Application related code may be added here, or in the ProcessIO() function.
ProcessIO();
if( getsUSBUSART(input_buffer, 1) ){
switch(input_buffer[0]){
case '1':
LATA=0xFF; // toutes les broches à l'état Haut
LATAbits.LATA0=0;
sprintf(USB_Out_Buffer, "Antenna1\n");
putsUSBUSART(USB_Out_Buffer);
break;
case '2':
LATA=0xFF; // toutes les broches à l'état Haut
LATAbits.LATA1=0;
sprintf(USB_Out_Buffer, "Antenna2\n");
putsUSBUSART(USB_Out_Buffer);
break;
case '3':
LATA=0xFF; // toutes les broches à l'état Haut
LATAbits.LATA2=0;
sprintf(USB_Out_Buffer, "Antenna3\n");
putsUSBUSART(USB_Out_Buffer);
break;
case '4':
LATA=0xFF; // toutes les broches à l'état Haut
LATAbits.LATA3=0;
sprintf(USB_Out_Buffer, "Antenna4\n");
putsUSBUSART(USB_Out_Buffer);
break;
default:
sprintf(USB_Out_Buffer, "NoAntenna\n");
putsUSBUSART(USB_Out_Buffer);
break;
}
}
}//end while
}//end main |
Partager