Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MultiSerial
Revision 9:f05f881226a3, committed 2014-09-04
- Comitter:
- Hatter
- Date:
- Thu Sep 04 02:39:04 2014 +0000
- Parent:
- 8:ee465babfd98
- Child:
- 10:5b67d18f30a9
- Commit message:
- get_data?????????????;
Changed in this revision
| MultiSerial.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MultiSerial.lib Wed Sep 03 06:25:23 2014 +0000 +++ b/MultiSerial.lib Thu Sep 04 02:39:04 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/B/code/MultiSerial/#f48f079a6fe4 +http://mbed.org/teams/B/code/MultiSerial/#26262b75f40b
--- a/main.cpp Wed Sep 03 06:25:23 2014 +0000
+++ b/main.cpp Thu Sep 04 02:39:04 2014 +0000
@@ -14,18 +14,19 @@
#include "mbed.h"
#include "MultiSerial.h"
-#define DATA_NUM 2 //DATA_NUM[byte]通信 この値はmemcpy使ってるんでxbee_packet構造体のメモリ数といい感じに合わせるようにしてください
+#define DATA_NUM 8 //DATA_NUM[byte]通信 この値はmemcpy使ってるんでxbee_packet構造体のメモリ数といい感じに合わせるようにしてください
#define XBEE_KEY 0xAA//keycode
-#define ARM_KEY 0x0A
+#define ARM_KEY 0xAA
-DigitalOut check(LED1);
-DigitalOut arm_check(LED2);
-
+BusOut check(LED1,LED2,LED3,LED4);
+//BusIn sw(p21,p22,p23,p24);
BusOut motors(p21,p22,p23,p24,p25,p26,p27,p28);
+Serial pc(USBTX,USBRX);
-MultiSerial xbee(p13,p14);
-MultiSerial armMbed(p9,p10);
+MultiSerial xbee(p13,p14,read);
+
+//MultiSerial armMbed(p9,p10,write);
typedef struct{
@@ -40,24 +41,37 @@
int main()
{
+ //sw.mode(PullUp);
- xbee_packet *pt_packet=&packet;
+ // xbee_packet *pt_packet=&packet;
+
+ xbee.read_data(get_data,XBEE_KEY);
for(;;){
+
+ wait(0.1);
check = !check;
- xbee.read(get_data,XBEE_KEY);
+ // get_data[0]=0xFF;
+ // get_data[1]=0x01;
+
+ //memcpy(&packet, get_data, DATA_NUM); //ちょい危険
+
+ packet.arm[0] = get_data[0];
+ packet.leg = get_data[1];
- memcpy(&packet, get_data, DATA_NUM); //ちょい危険
-
- armMbed.write(pt_packet->arm,ARM_KEY);
+ check = get_data[1];
if(packet.leg==0x0) motors = 0;
if(packet.leg&0x1) motors = 0x05; //p21,p23
if(packet.leg&0x2) motors = 0x0A; //p22,p24
if(packet.leg&0x4) motors = 0x50; //p25,p27
if(packet.leg&0x8) motors = 0xA0; //p26,p28
-
+
+ pc.printf(" arm = %d" ,packet.arm[1]);
+ pc.printf(" leg = %d" ,packet.leg);
+
+ // armMbed.write_data(pt_packet->arm,ARM_KEY);
}
}
\ No newline at end of file