/*----- main.c ------*/ #include "mcc_generated_files/mcc.h" #include #include "USB_1459_CDC.h" #include "i2cLCD_AQM0802A.h" #define BFSIZE 32 char NEWLINE[] = "\r\n"; static char rBuf[BFSIZE]; // USB Read Buffer static char wBuf[BFSIZE]; // USB Write Buffer int tmFlg; // Timer2 Flag /*==== Main application ==== */ void main(void) { SYSTEM_Initialize(); // initialize the device INTERRUPT_GlobalInterruptEnable(); // Enable the Global Interrupts INTERRUPT_PeripheralInterruptEnable(); // Enable the Peripheral Interrupts int swFlg = 0; // Switch Flag int adFlg = 0; // ADconvert Flag int num, i; int aVal; // AD Converted data LCD_init(); char msg[] = "Hello!\n"; LCD_str(msg); SendUSB_str(msg); SendUSB_str(NEWLINE); while (1) { num = RecvUSB(rBuf, BFSIZE); if(num > 0) { for(i=0; i "); SendUSB_int(num); SendUSB_str(wBuf); SendUSB_str(NEWLINE); if(( rBuf[0] & 0x01) == 0) LED_SetLow(); else LED_SetHigh(); } if((SWC3_GetValue() == 0) & (swFlg == 0)){ swFlg = 1; if(adFlg == 0){ sprintf(wBuf,"ADC Start\n\r"); SendUSB_str(wBuf); SendUSB_str(NEWLINE); adFlg = 1; }else{ sprintf(wBuf,"ADC Hold\n\r"); SendUSB_str(wBuf); SendUSB_str(NEWLINE); adFlg = 0; } }else if((SWC3_GetValue() > 0) & (swFlg == 1)){ swFlg = 0; } aVal = ADC_GetConversion(3); if((tmFlg > 0) & (adFlg > 0)){ sprintf(wBuf,"ADC:%4d\n\r",aVal); LCD_cursor(0,1); LCD_str(wBuf); SendUSB_str(wBuf); SendUSB_str(NEWLINE); tmFlg = 0; } } } /******** End of File ******/