for textbook v4.4

Dependencies:   HEPTA_SENSOR mbed HEPTA_EPS HEPTA_COM

Committer:
HeptaSatTraining2019
Date:
Thu Oct 31 08:29:43 2019 +0000
Revision:
29:3ce10b41568c
Parent:
28:5af09d71985e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:bdbd3d6fc5d5 1 #include "mbed.h"
HeptaSatTraining2019 28:5af09d71985e 2 #include"HEPTA_EPS.h"
HeptaSatTraining2019 28:5af09d71985e 3 #include"HEPTA_SENSOR.h"
HeptaSatTraining2019 28:5af09d71985e 4 #include"HEPTA_COM.h"
umeume 2:1c5cdb2c3e0f 5
umeume 2:1c5cdb2c3e0f 6 Serial pc(USBTX,USBRX);
HeptaSatTraining2019 28:5af09d71985e 7 HEPTA_EPS eps(p16,p26);
HeptaSatTraining2019 28:5af09d71985e 8 HEPTA_SENSOR sensor(p17,
HeptaSatTraining2019 28:5af09d71985e 9 p28,p27,0xD0,0x18,
HeptaSatTraining2019 28:5af09d71985e 10 p13, p14,p25,p24);
HeptaSatTraining2019 28:5af09d71985e 11 HEPTA_COM com(p9,p10);
umeume 5:c5ccb1b07e8f 12
umeume 2:1c5cdb2c3e0f 13 int main()
umeume 2:1c5cdb2c3e0f 14 {
HeptaSatTraining2019 26:1a95952b6fd1 15 int i = 0,rcmd=0,cmdflag=0;
HeptaSatTraining2019 28:5af09d71985e 16 float bt,ax,ay,az;
HeptaSatTraining2019 26:1a95952b6fd1 17 com.printf("Count Up!\r\n");
HeptaSatTraining2019 26:1a95952b6fd1 18 while(1) {
HeptaSatTraining2019 26:1a95952b6fd1 19 com.printf("num = %d\r\n",i);
HeptaSatTraining2019 26:1a95952b6fd1 20 i++;
HeptaSatTraining2019 26:1a95952b6fd1 21 wait(1.0);
HeptaSatTraining2019 26:1a95952b6fd1 22 com.xbee_receive(&rcmd,&cmdflag);
HeptaSatTraining2019 26:1a95952b6fd1 23 pc.printf("rcmd=%d, cmdflag=%d\r\n",rcmd, cmdflag);
HeptaSatTraining2019 26:1a95952b6fd1 24 if (cmdflag == 1) {
HeptaSatTraining2019 26:1a95952b6fd1 25 if (rcmd == 'a') {
HeptaSatTraining2019 26:1a95952b6fd1 26 pc.printf("Command Get %d\r\n",rcmd);
HeptaSatTraining2019 26:1a95952b6fd1 27 com.printf("HEPTA Uplink OK\r\n");
HeptaSatTraining2019 26:1a95952b6fd1 28 pc.printf("===================\r\n");
HeptaSatTraining2019 26:1a95952b6fd1 29 pc.printf("Accel sensing Mode\r\n");
HeptaSatTraining2019 26:1a95952b6fd1 30 pc.printf("===================\r\n");
HeptaSatTraining2019 26:1a95952b6fd1 31 for(int ii = 0; ii < 10; ii++) {
HeptaSatTraining2019 26:1a95952b6fd1 32 sensor.sen_acc(&ax,&ay,&az);
HeptaSatTraining2019 26:1a95952b6fd1 33 eps.vol(&bt);
HeptaSatTraining2019 28:5af09d71985e 34 com.printf("AX = %f\r\n",ax);
HeptaSatTraining2019 28:5af09d71985e 35 com.printf("AY = %f\r\n",ay);
HeptaSatTraining2019 28:5af09d71985e 36 com.printf("AZ = %f\r\n",az);
HeptaSatTraining2019 28:5af09d71985e 37 com.printf("V = %f\r\n",bt);
HeptaSatTraining2019 26:1a95952b6fd1 38 wait(0.5);
HeptaSatTraining2019 26:1a95952b6fd1 39 }
HeptaSatTraining2019 26:1a95952b6fd1 40 }
HeptaSatTraining2019 26:1a95952b6fd1 41 com.initialize();
HeptaSatTraining2019 26:1a95952b6fd1 42 }
HeptaSatTraining2019 26:1a95952b6fd1 43 }
umeume 2:1c5cdb2c3e0f 44 }