Hepta_template_program

Dependencies:   mbed PowerControl SDFileSystem

Fork of Hepta_UplinkData by HEPTA-Sat Hands-On

Committer:
MEXT1
Date:
Fri Dec 23 03:20:53 2016 +0000
Revision:
3:d9783e219d90
Parent:
2:1d66645de649
Child:
4:4f34143d3f6e
UplinkData

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);
MEXT1 2:1d66645de649 26 battery.vol_u16(bat);
tomoya123 1:2a3dc618aef7 27 xbee.xbee_s_transmit(acx,acy,acz,bat);
tomoya123 1:2a3dc618aef7 28 wait(1.0);
tomoya123 0:b96079b7d167 29 }
MEXT1 3:d9783e219d90 30 xbee.printf("HEPTA Uplink OK\r\n");
MEXT1 3:d9783e219d90 31 }
tomoya123 0:b96079b7d167 32 xbee.initialize();
tomoya123 0:b96079b7d167 33 }
tomoya123 0:b96079b7d167 34 wait (1.0);
tomoya123 0:b96079b7d167 35 }
tomoya123 0:b96079b7d167 36 }