simulate satellite program structure

Dependencies:   mbed HeptaBattery SDFileSystem HeptaCamera_GPS Hepta9axis HeptaTemp HeptaXbee

Fork of Lab7-01_template by HEPTA-Sat Training 2017~2018

Committer:
HEPTA
Date:
Tue Aug 20 10:00:48 2019 +0000
Revision:
19:fe8b70bfc20e
Parent:
17:ccae1368497e
revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
umeume 2:1c5cdb2c3e0f 2
umeume 2:1c5cdb2c3e0f 3 Serial pc(USBTX,USBRX);
HEPTA 17:ccae1368497e 4
HEPTA 17:ccae1368497e 5 DigitalOut myleds[] = {LED1,LED2,LED3,LED4};;
HEPTA 17:ccae1368497e 6
HEPTA 17:ccae1368497e 7 int rcmd = 0,cmdflag = 0;
umeume 2:1c5cdb2c3e0f 8
HEPTA 17:ccae1368497e 9 void commandget()
HEPTA 17:ccae1368497e 10 {
HEPTA 17:ccae1368497e 11 rcmd=pc.getc();
HEPTA 17:ccae1368497e 12 cmdflag = 1;
HEPTA 17:ccae1368497e 13 }
HEPTA 17:ccae1368497e 14 void receive(int *xrcmd, int *xcmdflag)
HEPTA 17:ccae1368497e 15 {
HEPTA 17:ccae1368497e 16 pc.attach(commandget,Serial::RxIrq);
HEPTA 17:ccae1368497e 17 *xrcmd = rcmd;
HEPTA 17:ccae1368497e 18 *xcmdflag = cmdflag;
HEPTA 17:ccae1368497e 19 }
HEPTA 17:ccae1368497e 20
HEPTA 17:ccae1368497e 21 void initialize()
HEPTA 17:ccae1368497e 22 {
HEPTA 17:ccae1368497e 23 rcmd = 0;
HEPTA 17:ccae1368497e 24 cmdflag = 0;
HEPTA 17:ccae1368497e 25 }
umeume 5:c5ccb1b07e8f 26
umeume 2:1c5cdb2c3e0f 27 int main()
umeume 2:1c5cdb2c3e0f 28 {
HEPTA 17:ccae1368497e 29 pc.baud(9600);
HEPTA 19:fe8b70bfc20e 30 receive(&rcmd,&cmdflag);
HEPTA 17:ccae1368497e 31 while(1) {
HEPTA 17:ccae1368497e 32 myleds[0] = 1;
HEPTA 17:ccae1368497e 33 wait(0.5);
HEPTA 17:ccae1368497e 34 myleds[0] = 0;
HEPTA 17:ccae1368497e 35 wait(0.5);
HEPTA 17:ccae1368497e 36 if (cmdflag == 1) {
HEPTA 17:ccae1368497e 37 if (rcmd == 'a') {
HEPTA 19:fe8b70bfc20e 38 pc.printf("Command Get = %d\r\n",rcmd);
HEPTA 19:fe8b70bfc20e 39 for(int i = 0;i < 10;i++){
HEPTA 19:fe8b70bfc20e 40 pc.printf("Count = %d\r\n",i);
HEPTA 19:fe8b70bfc20e 41 wait(1.0);
HEPTA 19:fe8b70bfc20e 42 }
HEPTA 17:ccae1368497e 43 }
HEPTA 17:ccae1368497e 44 initialize();
HEPTA 17:ccae1368497e 45 }
HEPTA 17:ccae1368497e 46 }
umeume 2:1c5cdb2c3e0f 47 }