Lab1
Dependencies: HEPTA_SENSOR mbed HEPTA_EPS HEPTA_COM HEPTA_CDH
main.cpp
00001 #include "mbed.h" 00002 #include "HEPTA_EPS.h" 00003 #include "HEPTA_CDH.h" 00004 #include "HEPTA_SENSOR.h" 00005 #include "HEPTA_COM.h" 00006 00007 Serial pc(USBTX,USBRX); 00008 00009 DigitalOut myleds[] = {LED1,LED2,LED3,LED4};; 00010 00011 int rcmd = 0,cmdflag = 0; 00012 00013 void commandget() 00014 { 00015 rcmd=pc.getc(); 00016 cmdflag = 1; 00017 } 00018 void receive(int *xrcmd, int *xcmdflag) 00019 { 00020 pc.attach(commandget,Serial::RxIrq); 00021 *xrcmd = rcmd; 00022 *xcmdflag = cmdflag; 00023 } 00024 00025 void initialize() 00026 { 00027 rcmd = 0; 00028 cmdflag = 0; 00029 } 00030 00031 int main() 00032 { 00033 pc.baud(9600); 00034 receive(&rcmd,&cmdflag); 00035 while(1) { 00036 myleds[0] = 1; 00037 wait(0.5); 00038 myleds[0] = 0; 00039 wait(0.5); 00040 if (cmdflag == 1) { 00041 if (rcmd == 'a') { 00042 //Please enter your answer in this part 00043 00044 00045 // 00046 } 00047 initialize(); 00048 } 00049 } 00050 }
Generated on Tue Aug 16 2022 07:47:26 by 1.7.2