2015_robocon_bteam / Mbed 2 deprecated 2015robot_main

Dependencies:   PID QEI mbed

Fork of 2015robot_main by Naoto Deguchi

Committer:
DeguNaoto
Date:
Tue Oct 27 07:49:43 2015 +0000
Revision:
114:325e4c158141
Parent:
108:7eb434cfcbd7
??????????; ????ver

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DeguNaoto 0:bd4719e15f7e 1 /***RS485 Communication.***/
DeguNaoto 18:526124eef0d1 2 #define RS485_TX p13
DeguNaoto 18:526124eef0d1 3 #define RS485_RX p14
DeguNaoto 0:bd4719e15f7e 4 Serial RS485(RS485_TX, RS485_RX);
DeguNaoto 26:8e6c736b6791 5 #define EnablePin p7
DeguNaoto 26:8e6c736b6791 6 DigitalOut Enable(EnablePin);
DeguNaoto 59:9d66edf3e734 7 inline void initializeRS485(){
DeguNaoto 59:9d66edf3e734 8 RS485.format(8,Serial::Even);
DeguNaoto 59:9d66edf3e734 9 }
unicore32 68:2b2b88ecdcce 10
unicore32 68:2b2b88ecdcce 11 /*
DeguNaoto 4:51d87d2b698c 12 inline void sendData(int address, int data5) {
DeguNaoto 4:51d87d2b698c 13 unsigned int data;
DeguNaoto 4:51d87d2b698c 14 if (data5 <= 31) {
DeguNaoto 4:51d87d2b698c 15 data = ((address << 5) | data5);
DeguNaoto 4:51d87d2b698c 16 RS485.putc(data);
DeguNaoto 4:51d87d2b698c 17 }
DeguNaoto 4:51d87d2b698c 18 }
unicore32 68:2b2b88ecdcce 19 */
unicore32 68:2b2b88ecdcce 20
unicore32 68:2b2b88ecdcce 21 inline void sendData(int address, unsigned int data8) {
unicore32 68:2b2b88ecdcce 22 unsigned int data;
DeguNaoto 79:7f86e18f40ef 23 if (data8 <= 15) {
unicore32 68:2b2b88ecdcce 24 data = 128 | (address << 4) | (data8 & 15);
unicore32 68:2b2b88ecdcce 25 RS485.putc(data);
unicore32 68:2b2b88ecdcce 26 }
unicore32 68:2b2b88ecdcce 27 else if (data8 <= 255 && data8 >= 16) {
unicore32 68:2b2b88ecdcce 28 data = (address << 4) | (data8 >> 4);
unicore32 68:2b2b88ecdcce 29 RS485.putc(data);
unicore32 69:bf094811b4a9 30 wait(0.000001);
unicore32 68:2b2b88ecdcce 31 data = 128 | (address << 4) | (data8 & 15);
unicore32 68:2b2b88ecdcce 32 RS485.putc(data);
unicore32 68:2b2b88ecdcce 33 }
unicore32 68:2b2b88ecdcce 34 }
unicore32 68:2b2b88ecdcce 35
DeguNaoto 0:bd4719e15f7e 36
DeguNaoto 57:3fbd487e055e 37 #ifdef IM920
DeguNaoto 44:315d5960f18c 38 /***IM920 Communication.***/
DeguNaoto 51:cb430192b28b 39 char rcvBUFF_IM920[40], rcvBUFF_SBDBT[40];
DeguNaoto 44:315d5960f18c 40 int rcvCOUNT_IM920 = 0, rcvCOUNT_SBDBT = 0;
DeguNaoto 44:315d5960f18c 41 int rcvFLAG = 0;
DeguNaoto 44:315d5960f18c 42 int sendFLAG = 0;
DeguNaoto 44:315d5960f18c 43 int deadCOUNT = 0;
DeguNaoto 51:cb430192b28b 44 int deadflag = 0;
DeguNaoto 44:315d5960f18c 45 int oldDATA;
DeguNaoto 44:315d5960f18c 46 unsigned int cm, a2, b, X, Y;
DeguNaoto 51:cb430192b28b 47 unsigned int sendDATA = 0;
DeguNaoto 51:cb430192b28b 48 unsigned long outDATA[4];
DeguNaoto 44:315d5960f18c 49
DeguNaoto 44:315d5960f18c 50 Serial IM920_USART(p9, p10);
DeguNaoto 51:cb430192b28b 51 Serial SBDBT_USART(p28, p27);
DeguNaoto 44:315d5960f18c 52 DigitalIn BUSY(p8);
DeguNaoto 44:315d5960f18c 53
DeguNaoto 44:315d5960f18c 54 Ticker DTimer;
DeguNaoto 44:315d5960f18c 55
DeguNaoto 44:315d5960f18c 56 void DEVICE_TX(int DATA, int DEVICE = 0) {
DeguNaoto 44:315d5960f18c 57 char sDATA[2];
DeguNaoto 44:315d5960f18c 58 if (DATA <= 15)
DeguNaoto 44:315d5960f18c 59 sprintf(sDATA, "0%X", DATA);
DeguNaoto 44:315d5960f18c 60 else
DeguNaoto 44:315d5960f18c 61 sprintf(sDATA, "%X", DATA);
DeguNaoto 44:315d5960f18c 62
DeguNaoto 44:315d5960f18c 63 if (DEVICE == 1) {
DeguNaoto 44:315d5960f18c 64 IM920_USART.printf("TXDA %s\r\n", sDATA);
DeguNaoto 44:315d5960f18c 65 }
DeguNaoto 44:315d5960f18c 66 else if (DEVICE == 2) {
DeguNaoto 44:315d5960f18c 67 SBDBT_USART.printf("00000000000%s\r\n", sDATA);
DeguNaoto 44:315d5960f18c 68 }
DeguNaoto 44:315d5960f18c 69 else {
DeguNaoto 44:315d5960f18c 70 IM920_USART.printf("TXDA %s\r\n", sDATA);
DeguNaoto 44:315d5960f18c 71 SBDBT_USART.printf("00000000000%s\r\n", sDATA);
DeguNaoto 44:315d5960f18c 72 }
DeguNaoto 44:315d5960f18c 73 }
DeguNaoto 44:315d5960f18c 74
DeguNaoto 51:cb430192b28b 75 int cvsendDATA(int Buzzer, int LED) {
DeguNaoto 108:7eb434cfcbd7 76 /*
DeguNaoto 44:315d5960f18c 77 if (Buzzer > 1)
DeguNaoto 44:315d5960f18c 78 Buzzer = 1;
DeguNaoto 44:315d5960f18c 79 else if (Buzzer < 0)
DeguNaoto 44:315d5960f18c 80 Buzzer = 0;
DeguNaoto 44:315d5960f18c 81 if (LED < 0)
DeguNaoto 44:315d5960f18c 82 LED = 0;
DeguNaoto 44:315d5960f18c 83 else if (LED >= 16)
DeguNaoto 44:315d5960f18c 84 LED = 15;
DeguNaoto 108:7eb434cfcbd7 85 */
DeguNaoto 108:7eb434cfcbd7 86 Buzzer = 0;
DeguNaoto 108:7eb434cfcbd7 87 LED = 0;
DeguNaoto 44:315d5960f18c 88 return (Buzzer << 6) | (LED << 2);
DeguNaoto 44:315d5960f18c 89 }
DeguNaoto 44:315d5960f18c 90
DeguNaoto 44:315d5960f18c 91 void cvrecvDATA(char *buffDATA, unsigned long *outputDATA) {
DeguNaoto 44:315d5960f18c 92 char s1[2], s2[2], s3[2], s4[2];
DeguNaoto 44:315d5960f18c 93 strncpy(s1, buffDATA+11, 2);
DeguNaoto 44:315d5960f18c 94 strncpy(s2, buffDATA+14, 2);
DeguNaoto 44:315d5960f18c 95 strncpy(s3, buffDATA+17, 2);
DeguNaoto 44:315d5960f18c 96 strncpy(s4, buffDATA+20, 2);
DeguNaoto 44:315d5960f18c 97 outputDATA[0] = strtoul(s1, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 98 outputDATA[1] = strtoul(s2, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 99 outputDATA[2] = strtoul(s3, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 100 outputDATA[3] = strtoul(s4, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 101 }
DeguNaoto 44:315d5960f18c 102
DeguNaoto 44:315d5960f18c 103 void cvrecvDATAsbdbt(char *buffDATA, unsigned long *outputDATA) {
DeguNaoto 44:315d5960f18c 104 char s1[2], s2[2];
DeguNaoto 44:315d5960f18c 105 strncpy(s1, buffDATA+5, 2);
DeguNaoto 44:315d5960f18c 106 strncpy(s2, buffDATA+7, 2);
DeguNaoto 44:315d5960f18c 107 outputDATA[0] = strtoul(s1, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 108 outputDATA[1] = strtoul(s2, (char **) NULL, 16);
DeguNaoto 44:315d5960f18c 109 }
DeguNaoto 44:315d5960f18c 110
DeguNaoto 44:315d5960f18c 111 void readDATA(unsigned long* outDATA) {
DeguNaoto 44:315d5960f18c 112 cm = (outDATA[0] & 128) >> 7;
DeguNaoto 44:315d5960f18c 113 a2 = (outDATA[0] & 64) >> 6;
DeguNaoto 44:315d5960f18c 114 X = (outDATA[0] & 56) >> 3;
DeguNaoto 44:315d5960f18c 115 Y = outDATA[0] & 7;
DeguNaoto 44:315d5960f18c 116 b = outDATA[1];
DeguNaoto 44:315d5960f18c 117 }
DeguNaoto 44:315d5960f18c 118
DeguNaoto 44:315d5960f18c 119 void SBDBT_RX() {
DeguNaoto 44:315d5960f18c 120 char rcvDATA;
DeguNaoto 44:315d5960f18c 121 rcvDATA = SBDBT_USART.getc();
DeguNaoto 44:315d5960f18c 122 rcvBUFF_SBDBT[rcvCOUNT_SBDBT] = rcvDATA;
DeguNaoto 44:315d5960f18c 123 rcvCOUNT_SBDBT++;
DeguNaoto 44:315d5960f18c 124 if (rcvDATA == 0x0A) {
DeguNaoto 44:315d5960f18c 125 rcvCOUNT_SBDBT = 0;
DeguNaoto 44:315d5960f18c 126 rcvFLAG = 2;
DeguNaoto 44:315d5960f18c 127 }
DeguNaoto 44:315d5960f18c 128 else if (rcvCOUNT_SBDBT >= 40) {
DeguNaoto 44:315d5960f18c 129 rcvCOUNT_SBDBT = 0;
DeguNaoto 44:315d5960f18c 130 memset(rcvBUFF_SBDBT, '\0', 40);
DeguNaoto 44:315d5960f18c 131 }
DeguNaoto 44:315d5960f18c 132 }
DeguNaoto 44:315d5960f18c 133
DeguNaoto 44:315d5960f18c 134 void IM920_RX() {
DeguNaoto 44:315d5960f18c 135 char rcvDATA;
DeguNaoto 44:315d5960f18c 136 rcvDATA = IM920_USART.getc();
DeguNaoto 44:315d5960f18c 137 rcvBUFF_IM920[rcvCOUNT_IM920] = rcvDATA;
DeguNaoto 44:315d5960f18c 138 rcvCOUNT_IM920++;
DeguNaoto 44:315d5960f18c 139 if (rcvDATA == 0x0A) {
DeguNaoto 44:315d5960f18c 140 rcvCOUNT_IM920 = 0;
DeguNaoto 44:315d5960f18c 141 rcvFLAG = 1;
DeguNaoto 44:315d5960f18c 142 }
DeguNaoto 44:315d5960f18c 143 else if (rcvCOUNT_IM920 >= 40) {
DeguNaoto 44:315d5960f18c 144 rcvCOUNT_IM920 = 0;
DeguNaoto 44:315d5960f18c 145 memset(rcvBUFF_IM920, '\0', 40);
DeguNaoto 44:315d5960f18c 146 }
DeguNaoto 44:315d5960f18c 147 }
DeguNaoto 44:315d5960f18c 148
DeguNaoto 44:315d5960f18c 149 void deadCheck() {
DeguNaoto 44:315d5960f18c 150 if (rcvFLAG == 0 && deadCOUNT >= 5) {
DeguNaoto 51:cb430192b28b 151 deadflag = 1;
DeguNaoto 44:315d5960f18c 152 deadCOUNT = 0;
DeguNaoto 44:315d5960f18c 153 }
DeguNaoto 44:315d5960f18c 154 else if (rcvFLAG == 0 && deadCOUNT >= 2) {
DeguNaoto 44:315d5960f18c 155 deadCOUNT++;
DeguNaoto 51:cb430192b28b 156 DEVICE_TX(sendDATA);
DeguNaoto 44:315d5960f18c 157 }
DeguNaoto 44:315d5960f18c 158 else if (rcvFLAG == 0) {
DeguNaoto 44:315d5960f18c 159 deadCOUNT++;
DeguNaoto 44:315d5960f18c 160 }
DeguNaoto 108:7eb434cfcbd7 161 sendDATA = cvsendDATA(0, 0);
DeguNaoto 44:315d5960f18c 162 }
DeguNaoto 44:315d5960f18c 163
DeguNaoto 44:315d5960f18c 164 inline void initializeIM920(){
DeguNaoto 44:315d5960f18c 165 IM920_USART.baud(9600);
DeguNaoto 44:315d5960f18c 166 IM920_USART.format(8, Serial::None, 1);
DeguNaoto 44:315d5960f18c 167 IM920_USART.attach(IM920_RX, Serial::RxIrq);
DeguNaoto 44:315d5960f18c 168 SBDBT_USART.baud(9600);
DeguNaoto 44:315d5960f18c 169 SBDBT_USART.format(8, Serial::None, 1);
DeguNaoto 44:315d5960f18c 170 SBDBT_USART.attach(SBDBT_RX, Serial::RxIrq);
DeguNaoto 44:315d5960f18c 171 DTimer.attach(deadCheck, 0.3);
DeguNaoto 51:cb430192b28b 172 sendDATA = cvsendDATA(0, 0);
DeguNaoto 44:315d5960f18c 173 }
DeguNaoto 44:315d5960f18c 174
DeguNaoto 44:315d5960f18c 175 inline void readIM920(){
DeguNaoto 44:315d5960f18c 176 if (rcvFLAG == 1) {
DeguNaoto 44:315d5960f18c 177 if (strlen(rcvBUFF_IM920) > 8) {
DeguNaoto 44:315d5960f18c 178 cvrecvDATA(rcvBUFF_IM920, outDATA);
DeguNaoto 44:315d5960f18c 179 readDATA(outDATA);
DeguNaoto 44:315d5960f18c 180 deadCOUNT = 0;
DeguNaoto 51:cb430192b28b 181 deadflag = 0;
DeguNaoto 51:cb430192b28b 182 DEVICE_TX(sendDATA, 1);
DeguNaoto 44:315d5960f18c 183 }
DeguNaoto 44:315d5960f18c 184 memset(rcvBUFF_IM920, '\0', 40);
DeguNaoto 44:315d5960f18c 185 rcvFLAG = 0;
DeguNaoto 44:315d5960f18c 186 }
DeguNaoto 44:315d5960f18c 187 else if (rcvFLAG == 2) {
DeguNaoto 44:315d5960f18c 188 if (strlen(rcvBUFF_SBDBT) > 4) {
DeguNaoto 44:315d5960f18c 189 cvrecvDATAsbdbt(rcvBUFF_SBDBT, outDATA);
DeguNaoto 44:315d5960f18c 190 readDATA(outDATA);
DeguNaoto 44:315d5960f18c 191 deadCOUNT = 0;
DeguNaoto 51:cb430192b28b 192 deadflag = 0;
DeguNaoto 51:cb430192b28b 193 DEVICE_TX(sendDATA, 2);
DeguNaoto 44:315d5960f18c 194 }
DeguNaoto 44:315d5960f18c 195 memset(rcvBUFF_SBDBT, '\0', 40);
DeguNaoto 44:315d5960f18c 196 rcvFLAG = 0;
DeguNaoto 44:315d5960f18c 197 }
DeguNaoto 51:cb430192b28b 198 }
DeguNaoto 57:3fbd487e055e 199 #else
DeguNaoto 0:bd4719e15f7e 200 /***Get state ps3con.***/
DeguNaoto 57:3fbd487e055e 201 #define SBDBT_TX p28
DeguNaoto 18:526124eef0d1 202 #define SBDBT_RX p27
DeguNaoto 0:bd4719e15f7e 203 Serial SBDBT(SBDBT_TX, SBDBT_RX);
DeguNaoto 0:bd4719e15f7e 204 #define ps3_start 0x80
DeguNaoto 18:526124eef0d1 205 short toggle = 0;
DeguNaoto 18:526124eef0d1 206 short edge_circle = 0;
DeguNaoto 18:526124eef0d1 207 short edge_triangle = 0;
DeguNaoto 21:79b94cb922f0 208 short edge_square = 0;
DeguNaoto 18:526124eef0d1 209 short edge_r1 = 0;
DeguNaoto 18:526124eef0d1 210 short edge_l1 = 0;
DeguNaoto 57:3fbd487e055e 211 short edge_r2 = 0;
DeguNaoto 57:3fbd487e055e 212 short edge_l2 = 0;
DeguNaoto 18:526124eef0d1 213 short edge_l_up = 0;
DeguNaoto 18:526124eef0d1 214 short edge_l_down = 0;
DeguNaoto 18:526124eef0d1 215 short edge_r_up = 0;
DeguNaoto 18:526124eef0d1 216 short edge_r_down = 0;
DeguNaoto 18:526124eef0d1 217 short edge_right = 0;
DeguNaoto 18:526124eef0d1 218 short edge_left = 0;
DeguNaoto 18:526124eef0d1 219 short edge_up = 0;
DeguNaoto 84:919a335ac81e 220 short edge_down = 0;
DeguNaoto 114:325e4c158141 221 short edge_cross = 0;
DeguNaoto 18:526124eef0d1 222 short square = 0;
DeguNaoto 18:526124eef0d1 223 short triangle = 0;
DeguNaoto 18:526124eef0d1 224 short circle = 0;
DeguNaoto 18:526124eef0d1 225 short cross = 0;
DeguNaoto 18:526124eef0d1 226 short up = 0;
DeguNaoto 18:526124eef0d1 227 short down = 0;
DeguNaoto 18:526124eef0d1 228 short right = 0;
DeguNaoto 18:526124eef0d1 229 short left = 0;
DeguNaoto 18:526124eef0d1 230 short l1 = 0;
DeguNaoto 18:526124eef0d1 231 short l2 = 0;
DeguNaoto 18:526124eef0d1 232 short r1 = 0;
DeguNaoto 18:526124eef0d1 233 short r2 = 0;
DeguNaoto 18:526124eef0d1 234 signed int analog_lx = 0;
DeguNaoto 18:526124eef0d1 235 signed int analog_ly = 0;
DeguNaoto 18:526124eef0d1 236 signed int analog_rx = 0;
DeguNaoto 18:526124eef0d1 237 signed int analog_ry = 0;
DeguNaoto 18:526124eef0d1 238 int count = 0;
DeguNaoto 18:526124eef0d1 239 int sample = 0;
DeguNaoto 0:bd4719e15f7e 240 int ps3_data[7];
DeguNaoto 18:526124eef0d1 241 inline void data_clear();
DeguNaoto 18:526124eef0d1 242 inline void data_check();
DeguNaoto 18:526124eef0d1 243 inline void SBDBT_interrupt();
DeguNaoto 18:526124eef0d1 244 inline void initializeSBDBT();
DeguNaoto 18:526124eef0d1 245
DeguNaoto 2:cf8ca6742db9 246 inline void data_clear()
DeguNaoto 2:cf8ca6742db9 247 {
DeguNaoto 2:cf8ca6742db9 248 for(int i=0; i<7; i++) ps3_data[i]=0;
DeguNaoto 0:bd4719e15f7e 249 }
DeguNaoto 2:cf8ca6742db9 250 inline void data_check()
DeguNaoto 2:cf8ca6742db9 251 {
DeguNaoto 0:bd4719e15f7e 252 square=0,triangle=0,circle=0,cross=0,up=0,down=0,right=0,left=0,l1=0,l2=0,r1=0,r2=0;
DeguNaoto 0:bd4719e15f7e 253 analog_lx=0,analog_ly=0,analog_rx=0,analog_ry=0;
DeguNaoto 0:bd4719e15f7e 254 if((ps3_data[0]==0x00)&&(ps3_data[1]==0x01)) up=1;
DeguNaoto 0:bd4719e15f7e 255 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x02)) down=1;
DeguNaoto 0:bd4719e15f7e 256 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x04)) right=1;
DeguNaoto 0:bd4719e15f7e 257 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x08)) left=1;
DeguNaoto 0:bd4719e15f7e 258 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x10)) triangle=1;
DeguNaoto 0:bd4719e15f7e 259 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x20)) cross=1;
DeguNaoto 0:bd4719e15f7e 260 else if((ps3_data[0]==0x00)&&(ps3_data[1]==0x40)) circle=1;
DeguNaoto 0:bd4719e15f7e 261 else if((ps3_data[0]==0x01)&&(ps3_data[1]==0x00)) square=1;
DeguNaoto 0:bd4719e15f7e 262 else if((ps3_data[0]==0x02)&&(ps3_data[1]==0x00)) l1=1;
DeguNaoto 0:bd4719e15f7e 263 else if((ps3_data[0]==0x04)&&(ps3_data[1]==0x00)) l2=1;
DeguNaoto 0:bd4719e15f7e 264 else if((ps3_data[0]==0x08)&&(ps3_data[1]==0x00)) r1=1;
DeguNaoto 0:bd4719e15f7e 265 else if((ps3_data[0]==0x10)&&(ps3_data[1]==0x00)) r2=1;
DeguNaoto 8:1638e8c8ca93 266 analog_lx=64-(signed int)ps3_data[2];
DeguNaoto 8:1638e8c8ca93 267 analog_ly=64-(signed int)ps3_data[3];
DeguNaoto 8:1638e8c8ca93 268 analog_rx=64-(signed int)ps3_data[4];
DeguNaoto 8:1638e8c8ca93 269 analog_ry=64-(signed int)ps3_data[5];
DeguNaoto 4:51d87d2b698c 270 if(!circle) edge_circle=1;
DeguNaoto 4:51d87d2b698c 271 if(!triangle) edge_triangle=1;
DeguNaoto 4:51d87d2b698c 272 if(!r1) edge_r1=1;
DeguNaoto 4:51d87d2b698c 273 if(!l1) edge_l1=1;
DeguNaoto 57:3fbd487e055e 274 if(!r2) edge_r2=1;
DeguNaoto 57:3fbd487e055e 275 if(!l2) edge_l2=1;
DeguNaoto 25:e591b9fa5796 276 if(!right) edge_right=1;
DeguNaoto 25:e591b9fa5796 277 if(!left) edge_left=1;
DeguNaoto 25:e591b9fa5796 278 if(!up) edge_up=1;
DeguNaoto 25:e591b9fa5796 279 if(!square) edge_square=1;
DeguNaoto 84:919a335ac81e 280 if(!down) edge_down=1;
DeguNaoto 114:325e4c158141 281 if(!cross) edge_cross=1;
DeguNaoto 0:bd4719e15f7e 282 }
DeguNaoto 0:bd4719e15f7e 283 ///interrupt SBDBT RX.
DeguNaoto 2:cf8ca6742db9 284 inline void SBDBT_interrupt()
DeguNaoto 2:cf8ca6742db9 285 {
DeguNaoto 0:bd4719e15f7e 286 sample=SBDBT.getc();
DeguNaoto 0:bd4719e15f7e 287 if(count==7) data_clear();
DeguNaoto 0:bd4719e15f7e 288 if(sample==ps3_start) count=0;
DeguNaoto 2:cf8ca6742db9 289 else {
DeguNaoto 0:bd4719e15f7e 290 ps3_data[count]=sample;
DeguNaoto 0:bd4719e15f7e 291 count++;
DeguNaoto 0:bd4719e15f7e 292 }
DeguNaoto 0:bd4719e15f7e 293 if(count==6) data_check();
DeguNaoto 0:bd4719e15f7e 294 }
DeguNaoto 2:cf8ca6742db9 295 inline void initializeSBDBT()
DeguNaoto 2:cf8ca6742db9 296 {
DeguNaoto 22:3996c3f41922 297 wait(0.1);
DeguNaoto 22:3996c3f41922 298 while(analog_ly==-64)
DeguNaoto 2:cf8ca6742db9 299 for(int i=0; i<7; i++) ps3_data[i]=0;
DeguNaoto 0:bd4719e15f7e 300 SBDBT.baud(2400);
DeguNaoto 0:bd4719e15f7e 301 SBDBT.format(8, Serial::None, 1);
DeguNaoto 0:bd4719e15f7e 302 SBDBT.attach(SBDBT_interrupt, Serial::RxIrq);
DeguNaoto 57:3fbd487e055e 303 }
DeguNaoto 114:325e4c158141 304 #endif