simulate satellite program structure
Dependencies: mbed HeptaBattery SDFileSystem HeptaCamera_GPS Hepta9axis HeptaTemp HeptaXbee
Fork of Lab7-01_template by
main.cpp@17:ccae1368497e, 2018-08-08 (annotated)
- Committer:
- HEPTA
- Date:
- Wed Aug 08 10:37:28 2018 +0000
- Revision:
- 17:ccae1368497e
- Parent:
- 13:a1fa75a002f6
- Child:
- 19:fe8b70bfc20e
Question1
Who changed what in which revision?
User | Revision | Line number | New 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 | 17:ccae1368497e | 30 | while(1) { |
HEPTA | 17:ccae1368497e | 31 | myleds[0] = 1; |
HEPTA | 17:ccae1368497e | 32 | wait(0.5); |
HEPTA | 17:ccae1368497e | 33 | myleds[0] = 0; |
HEPTA | 17:ccae1368497e | 34 | wait(0.5); |
HEPTA | 17:ccae1368497e | 35 | receive(&rcmd,&cmdflag); |
HEPTA | 17:ccae1368497e | 36 | if (cmdflag == 1) { |
HEPTA | 17:ccae1368497e | 37 | if (rcmd == 'a') { |
HEPTA | 17:ccae1368497e | 38 | |
HEPTA | 17:ccae1368497e | 39 | |
HEPTA | 17:ccae1368497e | 40 | |
HEPTA | 17:ccae1368497e | 41 | } |
HEPTA | 17:ccae1368497e | 42 | initialize(); |
HEPTA | 17:ccae1368497e | 43 | } |
HEPTA | 17:ccae1368497e | 44 | } |
umeume | 2:1c5cdb2c3e0f | 45 | } |