Hepta_template_program

Dependencies:   mbed PowerControl SDFileSystem

Fork of Hepta_UplinkData by HEPTA-Sat Hands-On

Committer:
tomoya123
Date:
Tue Dec 13 09:47:15 2016 +0000
Revision:
1:2a3dc618aef7
Parent:
0:b96079b7d167
Child:
2:1d66645de649
Xbee DataUplink

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomoya123 0:b96079b7d167 1 #include "mbed.h"
tomoya123 0:b96079b7d167 2 #include "HeptaXbee.h"
tomoya123 0:b96079b7d167 3 #include "HeptaAccel.h"
tomoya123 0:b96079b7d167 4 #include "HeptaBattery.h"
tomoya123 0:b96079b7d167 5
tomoya123 0:b96079b7d167 6 Serial pc(USBTX,USBRX);
tomoya123 0:b96079b7d167 7 HeptaXbee xbee(p9, p10);//(tx,rx)=(Din,Dout)
tomoya123 0:b96079b7d167 8 HeptaBattery battery(p16,p29,p26);
tomoya123 0:b96079b7d167 9 HeptaAccel accel(p28,p27,0x38);
tomoya123 0:b96079b7d167 10
tomoya123 0:b96079b7d167 11 int main() {
tomoya123 0:b96079b7d167 12 pc.baud(9600);
tomoya123 0:b96079b7d167 13 xbee.baud(9600);
tomoya123 0:b96079b7d167 14 xbee.printf("Xbee Uplink Ok Mode\r\n");
tomoya123 0:b96079b7d167 15 int rcmd=0,cmdflag=0;
tomoya123 1:2a3dc618aef7 16 char acx[4],acy[4],acz[4],bat[4];
tomoya123 0:b96079b7d167 17 for(int i=1;i<10;i++){
tomoya123 0:b96079b7d167 18 xbee.printf("num = %d\r\n",i);
tomoya123 0:b96079b7d167 19 xbee.xbee_recieve(&rcmd,&cmdflag);
tomoya123 0:b96079b7d167 20 pc.printf("rcmd=%d,cmdflag=%d\r\n",rcmd,cmdflag);
tomoya123 0:b96079b7d167 21 if(cmdflag==1){
tomoya123 0:b96079b7d167 22 if(rcmd=='a'){
tomoya123 1:2a3dc618aef7 23 xbee.printf("Command Get\r\n");
tomoya123 0:b96079b7d167 24 for(int j=1;j<10;j++){
tomoya123 1:2a3dc618aef7 25 accel.sensing_u16(acx,acy,acz);
tomoya123 0:b96079b7d167 26 battery.vol_u16(bat,&dsize[1]);
tomoya123 1:2a3dc618aef7 27 xbee.xbee_s_transmit(acx,acy,acz,bat);
tomoya123 1:2a3dc618aef7 28 wait(1.0);
tomoya123 0:b96079b7d167 29 }
tomoya123 0:b96079b7d167 30 }
tomoya123 0:b96079b7d167 31 xbee.initialize();
tomoya123 0:b96079b7d167 32 }
tomoya123 0:b96079b7d167 33 wait (1.0);
tomoya123 0:b96079b7d167 34 }
tomoya123 0:b96079b7d167 35 }