FormazioneSitael / Mbed 2 deprecated TestNI

Dependencies:   mbed

Committer:
jjantoine
Date:
Tue Dec 11 13:54:23 2018 +0000
Revision:
0:399c0fbd595c
TestNI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jjantoine 0:399c0fbd595c 1 #include "mbed.h"
jjantoine 0:399c0fbd595c 2
jjantoine 0:399c0fbd595c 3 Serial pc(USBTX, USBRX); // tx, rx
jjantoine 0:399c0fbd595c 4
jjantoine 0:399c0fbd595c 5 DigitalIn mybutton(USER_BUTTON);
jjantoine 0:399c0fbd595c 6
jjantoine 0:399c0fbd595c 7
jjantoine 0:399c0fbd595c 8 DigitalOut Porta0_7 (PA_0);
jjantoine 0:399c0fbd595c 9 DigitalOut Porta0_6 (PA_1);
jjantoine 0:399c0fbd595c 10 DigitalOut Porta0_5 (PA_4);
jjantoine 0:399c0fbd595c 11 DigitalOut Porta0_4 (PA_6);
jjantoine 0:399c0fbd595c 12 DigitalOut Porta0_3 (PA_7);
jjantoine 0:399c0fbd595c 13 DigitalOut Porta0_2 (PA_8);
jjantoine 0:399c0fbd595c 14 DigitalOut Porta0_1 (PA_9);
jjantoine 0:399c0fbd595c 15 DigitalOut Porta0_0 (PA_12);
jjantoine 0:399c0fbd595c 16
jjantoine 0:399c0fbd595c 17 DigitalOut Porta1_7 (PB_0);
jjantoine 0:399c0fbd595c 18 DigitalOut Porta1_6 (PB_1);
jjantoine 0:399c0fbd595c 19 DigitalOut Porta1_5 (PB_3);
jjantoine 0:399c0fbd595c 20 DigitalOut Porta1_4 (PB_4);
jjantoine 0:399c0fbd595c 21 DigitalOut Porta1_3 (PB_5);
jjantoine 0:399c0fbd595c 22 DigitalOut Porta1_2 (PB_6);
jjantoine 0:399c0fbd595c 23 DigitalOut Porta1_1 (PB_7);
jjantoine 0:399c0fbd595c 24 DigitalOut Porta1_0 (PB_10);
jjantoine 0:399c0fbd595c 25
jjantoine 0:399c0fbd595c 26 DigitalOut Porta2_7 (PC_0);
jjantoine 0:399c0fbd595c 27 DigitalOut Porta2_6 (PC_1);
jjantoine 0:399c0fbd595c 28 DigitalOut Porta2_5 (PC_2);
jjantoine 0:399c0fbd595c 29 DigitalOut Porta2_4 (PC_3);
jjantoine 0:399c0fbd595c 30 DigitalOut Porta2_3 (PC_5);
jjantoine 0:399c0fbd595c 31 DigitalOut Porta2_2 (PC_6);
jjantoine 0:399c0fbd595c 32 DigitalOut Porta2_1 (PC_7);
jjantoine 0:399c0fbd595c 33 DigitalOut Porta2_0 (PC_8);
jjantoine 0:399c0fbd595c 34
jjantoine 0:399c0fbd595c 35 DigitalOut Porta3_7 (PA_13);
jjantoine 0:399c0fbd595c 36 DigitalOut Porta3_6 (PA_14);
jjantoine 0:399c0fbd595c 37 DigitalOut Porta3_5 (PA_15);
jjantoine 0:399c0fbd595c 38 DigitalOut Porta3_4 (PC_14);
jjantoine 0:399c0fbd595c 39 DigitalOut Porta3_3 (PC_15);
jjantoine 0:399c0fbd595c 40 DigitalOut Porta3_2 (PA_11);
jjantoine 0:399c0fbd595c 41 DigitalOut Porta3_1 (PB_12);
jjantoine 0:399c0fbd595c 42 DigitalOut Porta3_0 (PC_4);
jjantoine 0:399c0fbd595c 43
jjantoine 0:399c0fbd595c 44
jjantoine 0:399c0fbd595c 45 void TGP_SET_GPO_CMD();
jjantoine 0:399c0fbd595c 46 void TGP_SET_GPO_ACK(char*, char*, char*, char*, char*);
jjantoine 0:399c0fbd595c 47 void GPIO_SET(char*,char*,char*,char*,char*,char*,char*,char*);
jjantoine 0:399c0fbd595c 48 int* charbit(char*,char*);
jjantoine 0:399c0fbd595c 49
jjantoine 0:399c0fbd595c 50 int main()
jjantoine 0:399c0fbd595c 51 {
jjantoine 0:399c0fbd595c 52 while(1)
jjantoine 0:399c0fbd595c 53 {
jjantoine 0:399c0fbd595c 54 TGP_SET_GPO_CMD();
jjantoine 0:399c0fbd595c 55 }
jjantoine 0:399c0fbd595c 56
jjantoine 0:399c0fbd595c 57
jjantoine 0:399c0fbd595c 58 }
jjantoine 0:399c0fbd595c 59
jjantoine 0:399c0fbd595c 60
jjantoine 0:399c0fbd595c 61
jjantoine 0:399c0fbd595c 62 void TGP_SET_GPO_CMD()
jjantoine 0:399c0fbd595c 63 {
jjantoine 0:399c0fbd595c 64 unsigned int i;
jjantoine 0:399c0fbd595c 65
jjantoine 0:399c0fbd595c 66 char UINT32_PacketSize [4];
jjantoine 0:399c0fbd595c 67 char ENUM_Packet_ID;
jjantoine 0:399c0fbd595c 68 char UINT16_PacketCounter [2];
jjantoine 0:399c0fbd595c 69 char UINT32_Timestamp [4];
jjantoine 0:399c0fbd595c 70 char UINT32_Port0Value [4];
jjantoine 0:399c0fbd595c 71 char UINT32_Port0Mask [4];
jjantoine 0:399c0fbd595c 72 char UINT32_Port1Value [4];
jjantoine 0:399c0fbd595c 73 char UINT32_Port1Mask [4];
jjantoine 0:399c0fbd595c 74 char UINT32_Port2Value [4];
jjantoine 0:399c0fbd595c 75 char UINT32_Port2Mask [4];
jjantoine 0:399c0fbd595c 76 char UINT32_Port3Value [4];
jjantoine 0:399c0fbd595c 77 char UINT32_Port3Mask [4];
jjantoine 0:399c0fbd595c 78 char UINT32_CRC [4];
jjantoine 0:399c0fbd595c 79
jjantoine 0:399c0fbd595c 80 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 81 pc.scanf("%c",&UINT32_PacketSize[i]);
jjantoine 0:399c0fbd595c 82 }
jjantoine 0:399c0fbd595c 83
jjantoine 0:399c0fbd595c 84 pc.scanf("%c",&ENUM_Packet_ID);
jjantoine 0:399c0fbd595c 85
jjantoine 0:399c0fbd595c 86 for(i=0; i<2; i++){
jjantoine 0:399c0fbd595c 87 pc.scanf("%c",&UINT16_PacketCounter[i]);
jjantoine 0:399c0fbd595c 88 }
jjantoine 0:399c0fbd595c 89
jjantoine 0:399c0fbd595c 90 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 91 pc.scanf("%c",&UINT32_Timestamp[i]);
jjantoine 0:399c0fbd595c 92 }
jjantoine 0:399c0fbd595c 93
jjantoine 0:399c0fbd595c 94 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 95 pc.scanf("%c",&UINT32_Port0Value[i]);
jjantoine 0:399c0fbd595c 96 }
jjantoine 0:399c0fbd595c 97
jjantoine 0:399c0fbd595c 98 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 99 pc.scanf("%c",&UINT32_Port0Mask[i]);
jjantoine 0:399c0fbd595c 100 }
jjantoine 0:399c0fbd595c 101
jjantoine 0:399c0fbd595c 102 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 103 pc.scanf("%c",&UINT32_Port1Value[i]);
jjantoine 0:399c0fbd595c 104 }
jjantoine 0:399c0fbd595c 105
jjantoine 0:399c0fbd595c 106 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 107 pc.scanf("%c",&UINT32_Port1Mask[i]);
jjantoine 0:399c0fbd595c 108 }
jjantoine 0:399c0fbd595c 109
jjantoine 0:399c0fbd595c 110 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 111 pc.scanf("%c",&UINT32_Port2Value[i]);
jjantoine 0:399c0fbd595c 112 }
jjantoine 0:399c0fbd595c 113
jjantoine 0:399c0fbd595c 114 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 115 pc.scanf("%c",&UINT32_Port2Mask[i]);
jjantoine 0:399c0fbd595c 116 }
jjantoine 0:399c0fbd595c 117
jjantoine 0:399c0fbd595c 118 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 119 pc.scanf("%c",&UINT32_Port3Value[i]);
jjantoine 0:399c0fbd595c 120 }
jjantoine 0:399c0fbd595c 121
jjantoine 0:399c0fbd595c 122 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 123 pc.scanf("%c",&UINT32_Port3Mask[i]);
jjantoine 0:399c0fbd595c 124 }
jjantoine 0:399c0fbd595c 125
jjantoine 0:399c0fbd595c 126 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 127 pc.scanf("%c",&UINT32_CRC[i]);
jjantoine 0:399c0fbd595c 128 }
jjantoine 0:399c0fbd595c 129
jjantoine 0:399c0fbd595c 130 TGP_SET_GPO_ACK(UINT32_PacketSize,&ENUM_Packet_ID,UINT16_PacketCounter,UINT32_Timestamp,UINT32_CRC);
jjantoine 0:399c0fbd595c 131 GPIO_SET(UINT32_Port0Value,UINT32_Port0Mask,UINT32_Port1Value,UINT32_Port1Mask,UINT32_Port2Value,UINT32_Port2Mask,UINT32_Port3Value,UINT32_Port3Mask);
jjantoine 0:399c0fbd595c 132
jjantoine 0:399c0fbd595c 133 }
jjantoine 0:399c0fbd595c 134
jjantoine 0:399c0fbd595c 135 void TGP_SET_GPO_ACK(char*A, char*B, char*C, char*D, char*E)
jjantoine 0:399c0fbd595c 136 {
jjantoine 0:399c0fbd595c 137 char UINT32_PacketSize [4];
jjantoine 0:399c0fbd595c 138 char ENUM_Packet_ID;
jjantoine 0:399c0fbd595c 139 char UINT16_PacketCounter [2];
jjantoine 0:399c0fbd595c 140 char UINT32_Timestamp [4];
jjantoine 0:399c0fbd595c 141 char UINT32_CRC [4];
jjantoine 0:399c0fbd595c 142
jjantoine 0:399c0fbd595c 143 unsigned int i;
jjantoine 0:399c0fbd595c 144
jjantoine 0:399c0fbd595c 145 strcpy(UINT32_PacketSize,A);
jjantoine 0:399c0fbd595c 146 ENUM_Packet_ID = B[0];
jjantoine 0:399c0fbd595c 147 strcpy(UINT16_PacketCounter,C);
jjantoine 0:399c0fbd595c 148 strcpy(UINT32_Timestamp,D);
jjantoine 0:399c0fbd595c 149 strcpy(UINT32_CRC,E);
jjantoine 0:399c0fbd595c 150
jjantoine 0:399c0fbd595c 151 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 152 pc.printf("%c",&UINT32_PacketSize[i]);
jjantoine 0:399c0fbd595c 153 }
jjantoine 0:399c0fbd595c 154
jjantoine 0:399c0fbd595c 155 pc.printf("%c",&ENUM_Packet_ID);
jjantoine 0:399c0fbd595c 156
jjantoine 0:399c0fbd595c 157 for(i=0; i<2; i++){
jjantoine 0:399c0fbd595c 158 pc.printf("%c",&UINT16_PacketCounter[i]);
jjantoine 0:399c0fbd595c 159 }
jjantoine 0:399c0fbd595c 160
jjantoine 0:399c0fbd595c 161 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 162 pc.printf("%c",&UINT32_Timestamp[i]);
jjantoine 0:399c0fbd595c 163 }
jjantoine 0:399c0fbd595c 164
jjantoine 0:399c0fbd595c 165 for(i=0; i<4; i++){
jjantoine 0:399c0fbd595c 166 pc.printf("%c",&UINT32_CRC[i]);
jjantoine 0:399c0fbd595c 167 }
jjantoine 0:399c0fbd595c 168
jjantoine 0:399c0fbd595c 169 }
jjantoine 0:399c0fbd595c 170
jjantoine 0:399c0fbd595c 171 void GPIO_SET(char*A,char*B,char*C,char*D,char*E,char*F,char*G,char*H)
jjantoine 0:399c0fbd595c 172 {
jjantoine 0:399c0fbd595c 173 unsigned int i,btts;
jjantoine 0:399c0fbd595c 174
jjantoine 0:399c0fbd595c 175 btts=0;
jjantoine 0:399c0fbd595c 176
jjantoine 0:399c0fbd595c 177 char UINT32_Port0Value [4];
jjantoine 0:399c0fbd595c 178 char UINT32_Port0Mask [4];
jjantoine 0:399c0fbd595c 179 char UINT32_Port1Value [4];
jjantoine 0:399c0fbd595c 180 char UINT32_Port1Mask [4];
jjantoine 0:399c0fbd595c 181 char UINT32_Port2Value [4];
jjantoine 0:399c0fbd595c 182 char UINT32_Port2Mask [4];
jjantoine 0:399c0fbd595c 183 char UINT32_Port3Value [4];
jjantoine 0:399c0fbd595c 184 char UINT32_Port3Mask [4];
jjantoine 0:399c0fbd595c 185
jjantoine 0:399c0fbd595c 186 int* porta0;
jjantoine 0:399c0fbd595c 187 int* porta1;
jjantoine 0:399c0fbd595c 188 int* porta2;
jjantoine 0:399c0fbd595c 189 int* porta3;
jjantoine 0:399c0fbd595c 190
jjantoine 0:399c0fbd595c 191 int bit0[32];
jjantoine 0:399c0fbd595c 192 int bit1[32];
jjantoine 0:399c0fbd595c 193 int bit2[32];
jjantoine 0:399c0fbd595c 194 int bit3[32];
jjantoine 0:399c0fbd595c 195
jjantoine 0:399c0fbd595c 196 strcpy(UINT32_Port0Value,A);
jjantoine 0:399c0fbd595c 197 strcpy(UINT32_Port0Mask,B);
jjantoine 0:399c0fbd595c 198 strcpy(UINT32_Port1Value,C);
jjantoine 0:399c0fbd595c 199 strcpy(UINT32_Port1Mask,D);
jjantoine 0:399c0fbd595c 200 strcpy(UINT32_Port2Value,E);
jjantoine 0:399c0fbd595c 201 strcpy(UINT32_Port2Mask,F);
jjantoine 0:399c0fbd595c 202 strcpy(UINT32_Port3Value,G);
jjantoine 0:399c0fbd595c 203 strcpy(UINT32_Port3Mask,H);
jjantoine 0:399c0fbd595c 204
jjantoine 0:399c0fbd595c 205 porta0 = charbit(UINT32_Port0Value,UINT32_Port0Mask);
jjantoine 0:399c0fbd595c 206
jjantoine 0:399c0fbd595c 207 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 208 {
jjantoine 0:399c0fbd595c 209 bit0[i]=porta0[i];
jjantoine 0:399c0fbd595c 210 }
jjantoine 0:399c0fbd595c 211
jjantoine 0:399c0fbd595c 212 porta1 = charbit(UINT32_Port1Value,UINT32_Port1Mask);
jjantoine 0:399c0fbd595c 213
jjantoine 0:399c0fbd595c 214 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 215 {
jjantoine 0:399c0fbd595c 216 bit1[i]=porta1[i];
jjantoine 0:399c0fbd595c 217 }
jjantoine 0:399c0fbd595c 218
jjantoine 0:399c0fbd595c 219 porta2 = charbit(UINT32_Port2Value,UINT32_Port2Mask);
jjantoine 0:399c0fbd595c 220
jjantoine 0:399c0fbd595c 221 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 222 {
jjantoine 0:399c0fbd595c 223 bit2[i]=porta2[i];
jjantoine 0:399c0fbd595c 224 }
jjantoine 0:399c0fbd595c 225
jjantoine 0:399c0fbd595c 226 porta3 = charbit(UINT32_Port3Value,UINT32_Port3Mask);
jjantoine 0:399c0fbd595c 227
jjantoine 0:399c0fbd595c 228 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 229 {
jjantoine 0:399c0fbd595c 230 bit3[i]=porta3[i];
jjantoine 0:399c0fbd595c 231 }
jjantoine 0:399c0fbd595c 232
jjantoine 0:399c0fbd595c 233 while(1)
jjantoine 0:399c0fbd595c 234 {
jjantoine 0:399c0fbd595c 235 if(mybutton == 0 & btts ==0)
jjantoine 0:399c0fbd595c 236 {
jjantoine 0:399c0fbd595c 237 Porta0_7 = bit0[0];
jjantoine 0:399c0fbd595c 238 Porta0_6 = bit0[1];
jjantoine 0:399c0fbd595c 239 Porta0_5 = bit0[2];
jjantoine 0:399c0fbd595c 240 Porta0_4 = bit0[3];
jjantoine 0:399c0fbd595c 241 Porta0_3 = bit0[4];
jjantoine 0:399c0fbd595c 242 Porta0_2 = bit0[5];
jjantoine 0:399c0fbd595c 243 Porta0_1 = bit0[6];
jjantoine 0:399c0fbd595c 244 Porta0_0 = bit0[7];
jjantoine 0:399c0fbd595c 245
jjantoine 0:399c0fbd595c 246 Porta1_7 = bit1[0];
jjantoine 0:399c0fbd595c 247 Porta1_6 = bit1[1];
jjantoine 0:399c0fbd595c 248 Porta1_5 = bit1[2];
jjantoine 0:399c0fbd595c 249 Porta1_4 = bit1[3];
jjantoine 0:399c0fbd595c 250 Porta1_3 = bit1[4];
jjantoine 0:399c0fbd595c 251 Porta1_2 = bit1[5];
jjantoine 0:399c0fbd595c 252 Porta1_1 = bit1[6];
jjantoine 0:399c0fbd595c 253 Porta1_0 = bit1[7];
jjantoine 0:399c0fbd595c 254
jjantoine 0:399c0fbd595c 255 Porta2_7 = bit2[0];
jjantoine 0:399c0fbd595c 256 Porta2_6 = bit2[1];
jjantoine 0:399c0fbd595c 257 Porta2_5 = bit2[2];
jjantoine 0:399c0fbd595c 258 Porta2_4 = bit2[3];
jjantoine 0:399c0fbd595c 259 Porta2_3 = bit2[4];
jjantoine 0:399c0fbd595c 260 Porta2_2 = bit2[5];
jjantoine 0:399c0fbd595c 261 Porta2_1 = bit2[6];
jjantoine 0:399c0fbd595c 262 Porta2_0 = bit2[7];
jjantoine 0:399c0fbd595c 263
jjantoine 0:399c0fbd595c 264 Porta3_7 = bit3[0];
jjantoine 0:399c0fbd595c 265 Porta3_6 = bit3[1];
jjantoine 0:399c0fbd595c 266 Porta3_5 = bit3[2];
jjantoine 0:399c0fbd595c 267 Porta3_4 = bit3[3];
jjantoine 0:399c0fbd595c 268 Porta3_3 = bit3[4];
jjantoine 0:399c0fbd595c 269 Porta3_2 = bit3[5];
jjantoine 0:399c0fbd595c 270 Porta3_1 = bit3[6];
jjantoine 0:399c0fbd595c 271 Porta3_0 = bit3[7];
jjantoine 0:399c0fbd595c 272
jjantoine 0:399c0fbd595c 273 btts = 1;
jjantoine 0:399c0fbd595c 274 } else if (mybutton == 0 & btts == 1) {
jjantoine 0:399c0fbd595c 275
jjantoine 0:399c0fbd595c 276 Porta0_7 = bit0[8];
jjantoine 0:399c0fbd595c 277 Porta0_6 = bit0[9];
jjantoine 0:399c0fbd595c 278 Porta0_5 = bit0[10];
jjantoine 0:399c0fbd595c 279 Porta0_4 = bit0[11];
jjantoine 0:399c0fbd595c 280 Porta0_3 = bit0[12];
jjantoine 0:399c0fbd595c 281 Porta0_2 = bit0[13];
jjantoine 0:399c0fbd595c 282 Porta0_1 = bit0[14];
jjantoine 0:399c0fbd595c 283 Porta0_0 = bit0[15];
jjantoine 0:399c0fbd595c 284
jjantoine 0:399c0fbd595c 285 Porta1_7 = bit1[8];
jjantoine 0:399c0fbd595c 286 Porta1_6 = bit1[9];
jjantoine 0:399c0fbd595c 287 Porta1_5 = bit1[10];
jjantoine 0:399c0fbd595c 288 Porta1_4 = bit1[11];
jjantoine 0:399c0fbd595c 289 Porta1_3 = bit1[12];
jjantoine 0:399c0fbd595c 290 Porta1_2 = bit1[13];
jjantoine 0:399c0fbd595c 291 Porta1_1 = bit1[14];
jjantoine 0:399c0fbd595c 292 Porta1_0 = bit1[15];
jjantoine 0:399c0fbd595c 293
jjantoine 0:399c0fbd595c 294 Porta2_7 = bit2[8];
jjantoine 0:399c0fbd595c 295 Porta2_6 = bit2[9];
jjantoine 0:399c0fbd595c 296 Porta2_5 = bit2[10];
jjantoine 0:399c0fbd595c 297 Porta2_4 = bit2[11];
jjantoine 0:399c0fbd595c 298 Porta2_3 = bit2[12];
jjantoine 0:399c0fbd595c 299 Porta2_2 = bit2[13];
jjantoine 0:399c0fbd595c 300 Porta2_1 = bit2[14];
jjantoine 0:399c0fbd595c 301 Porta2_0 = bit2[15];
jjantoine 0:399c0fbd595c 302
jjantoine 0:399c0fbd595c 303 Porta3_7 = bit3[8];
jjantoine 0:399c0fbd595c 304 Porta3_6 = bit3[9];
jjantoine 0:399c0fbd595c 305 Porta3_5 = bit3[10];
jjantoine 0:399c0fbd595c 306 Porta3_4 = bit3[11];
jjantoine 0:399c0fbd595c 307 Porta3_3 = bit3[12];
jjantoine 0:399c0fbd595c 308 Porta3_2 = bit3[13];
jjantoine 0:399c0fbd595c 309 Porta3_1 = bit3[14];
jjantoine 0:399c0fbd595c 310 Porta3_0 = bit3[15];
jjantoine 0:399c0fbd595c 311
jjantoine 0:399c0fbd595c 312 btts = 2;
jjantoine 0:399c0fbd595c 313 } else if (mybutton == 0 & btts == 2) {
jjantoine 0:399c0fbd595c 314
jjantoine 0:399c0fbd595c 315 Porta0_7 = bit0[16];
jjantoine 0:399c0fbd595c 316 Porta0_6 = bit0[17];
jjantoine 0:399c0fbd595c 317 Porta0_5 = bit0[18];
jjantoine 0:399c0fbd595c 318 Porta0_4 = bit0[19];
jjantoine 0:399c0fbd595c 319 Porta0_3 = bit0[20];
jjantoine 0:399c0fbd595c 320 Porta0_2 = bit0[21];
jjantoine 0:399c0fbd595c 321 Porta0_1 = bit0[22];
jjantoine 0:399c0fbd595c 322 Porta0_0 = bit0[23];
jjantoine 0:399c0fbd595c 323
jjantoine 0:399c0fbd595c 324 Porta1_7 = bit1[16];
jjantoine 0:399c0fbd595c 325 Porta1_6 = bit1[17];
jjantoine 0:399c0fbd595c 326 Porta1_5 = bit1[18];
jjantoine 0:399c0fbd595c 327 Porta1_4 = bit1[19];
jjantoine 0:399c0fbd595c 328 Porta1_3 = bit1[20];
jjantoine 0:399c0fbd595c 329 Porta1_2 = bit1[21];
jjantoine 0:399c0fbd595c 330 Porta1_1 = bit1[22];
jjantoine 0:399c0fbd595c 331 Porta1_0 = bit1[23];
jjantoine 0:399c0fbd595c 332
jjantoine 0:399c0fbd595c 333 Porta2_7 = bit2[16];
jjantoine 0:399c0fbd595c 334 Porta2_6 = bit2[17];
jjantoine 0:399c0fbd595c 335 Porta2_5 = bit2[18];
jjantoine 0:399c0fbd595c 336 Porta2_4 = bit2[19];
jjantoine 0:399c0fbd595c 337 Porta2_3 = bit2[20];
jjantoine 0:399c0fbd595c 338 Porta2_2 = bit2[21];
jjantoine 0:399c0fbd595c 339 Porta2_1 = bit2[22];
jjantoine 0:399c0fbd595c 340 Porta2_0 = bit2[23];
jjantoine 0:399c0fbd595c 341
jjantoine 0:399c0fbd595c 342 Porta3_7 = bit3[16];
jjantoine 0:399c0fbd595c 343 Porta3_6 = bit3[17];
jjantoine 0:399c0fbd595c 344 Porta3_5 = bit3[18];
jjantoine 0:399c0fbd595c 345 Porta3_4 = bit3[19];
jjantoine 0:399c0fbd595c 346 Porta3_3 = bit3[20];
jjantoine 0:399c0fbd595c 347 Porta3_2 = bit3[21];
jjantoine 0:399c0fbd595c 348 Porta3_1 = bit3[22];
jjantoine 0:399c0fbd595c 349 Porta3_0 = bit3[23];
jjantoine 0:399c0fbd595c 350
jjantoine 0:399c0fbd595c 351 btts = 3;
jjantoine 0:399c0fbd595c 352 } else if (mybutton == 0 & btts == 3) {
jjantoine 0:399c0fbd595c 353
jjantoine 0:399c0fbd595c 354 Porta0_7 = bit0[24];
jjantoine 0:399c0fbd595c 355 Porta0_6 = bit0[25];
jjantoine 0:399c0fbd595c 356 Porta0_5 = bit0[26];
jjantoine 0:399c0fbd595c 357 Porta0_4 = bit0[27];
jjantoine 0:399c0fbd595c 358 Porta0_3 = bit0[28];
jjantoine 0:399c0fbd595c 359 Porta0_2 = bit0[29];
jjantoine 0:399c0fbd595c 360 Porta0_1 = bit0[30];
jjantoine 0:399c0fbd595c 361 Porta0_0 = bit0[31];
jjantoine 0:399c0fbd595c 362
jjantoine 0:399c0fbd595c 363 Porta1_7 = bit1[24];
jjantoine 0:399c0fbd595c 364 Porta1_6 = bit1[25];
jjantoine 0:399c0fbd595c 365 Porta1_5 = bit1[26];
jjantoine 0:399c0fbd595c 366 Porta1_4 = bit1[27];
jjantoine 0:399c0fbd595c 367 Porta1_3 = bit1[28];
jjantoine 0:399c0fbd595c 368 Porta1_2 = bit1[29];
jjantoine 0:399c0fbd595c 369 Porta1_1 = bit1[30];
jjantoine 0:399c0fbd595c 370 Porta1_0 = bit1[31];
jjantoine 0:399c0fbd595c 371
jjantoine 0:399c0fbd595c 372 Porta2_7 = bit2[24];
jjantoine 0:399c0fbd595c 373 Porta2_6 = bit2[25];
jjantoine 0:399c0fbd595c 374 Porta2_5 = bit2[26];
jjantoine 0:399c0fbd595c 375 Porta2_4 = bit2[27];
jjantoine 0:399c0fbd595c 376 Porta2_3 = bit2[28];
jjantoine 0:399c0fbd595c 377 Porta2_2 = bit2[29];
jjantoine 0:399c0fbd595c 378 Porta2_1 = bit2[30];
jjantoine 0:399c0fbd595c 379 Porta2_0 = bit2[31];
jjantoine 0:399c0fbd595c 380
jjantoine 0:399c0fbd595c 381 Porta3_7 = bit3[24];
jjantoine 0:399c0fbd595c 382 Porta3_6 = bit3[25];
jjantoine 0:399c0fbd595c 383 Porta3_5 = bit3[26];
jjantoine 0:399c0fbd595c 384 Porta3_4 = bit3[27];
jjantoine 0:399c0fbd595c 385 Porta3_3 = bit3[28];
jjantoine 0:399c0fbd595c 386 Porta3_2 = bit3[29];
jjantoine 0:399c0fbd595c 387 Porta3_1 = bit3[30];
jjantoine 0:399c0fbd595c 388 Porta3_0 = bit3[31];
jjantoine 0:399c0fbd595c 389
jjantoine 0:399c0fbd595c 390 btts = 4;
jjantoine 0:399c0fbd595c 391 } else if (mybutton == 0 & btts == 4)
jjantoine 0:399c0fbd595c 392 {
jjantoine 0:399c0fbd595c 393 break;
jjantoine 0:399c0fbd595c 394 }
jjantoine 0:399c0fbd595c 395 }
jjantoine 0:399c0fbd595c 396
jjantoine 0:399c0fbd595c 397 }
jjantoine 0:399c0fbd595c 398
jjantoine 0:399c0fbd595c 399 int* charbit(char*c,char*d)
jjantoine 0:399c0fbd595c 400 {
jjantoine 0:399c0fbd595c 401 int msb1[32];
jjantoine 0:399c0fbd595c 402 int msb2[32];
jjantoine 0:399c0fbd595c 403 int msb3[32];
jjantoine 0:399c0fbd595c 404 int i;
jjantoine 0:399c0fbd595c 405 char a[4];
jjantoine 0:399c0fbd595c 406 char b[4];
jjantoine 0:399c0fbd595c 407
jjantoine 0:399c0fbd595c 408 strcpy(a,c);
jjantoine 0:399c0fbd595c 409 strcpy(b,d);
jjantoine 0:399c0fbd595c 410
jjantoine 0:399c0fbd595c 411
jjantoine 0:399c0fbd595c 412 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 413 {
jjantoine 0:399c0fbd595c 414 msb1[i] = ( a[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 415 a[0]=a[0]<<1;
jjantoine 0:399c0fbd595c 416
jjantoine 0:399c0fbd595c 417 }
jjantoine 0:399c0fbd595c 418
jjantoine 0:399c0fbd595c 419 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 420 {
jjantoine 0:399c0fbd595c 421 msb1[i] = ( a[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 422 a[1]=a[1]<<1;
jjantoine 0:399c0fbd595c 423
jjantoine 0:399c0fbd595c 424 }
jjantoine 0:399c0fbd595c 425
jjantoine 0:399c0fbd595c 426 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 427 {
jjantoine 0:399c0fbd595c 428 msb1[i] = ( a[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 429 a[2]=a[2]<<1;
jjantoine 0:399c0fbd595c 430
jjantoine 0:399c0fbd595c 431 }
jjantoine 0:399c0fbd595c 432
jjantoine 0:399c0fbd595c 433 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 434 {
jjantoine 0:399c0fbd595c 435 msb1[i] = ( a[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 436 a[3]=a[3]<<1;
jjantoine 0:399c0fbd595c 437
jjantoine 0:399c0fbd595c 438 }
jjantoine 0:399c0fbd595c 439
jjantoine 0:399c0fbd595c 440 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 441 {
jjantoine 0:399c0fbd595c 442 msb2[i] = ( b[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 443 b[0]=b[0]<<1;
jjantoine 0:399c0fbd595c 444
jjantoine 0:399c0fbd595c 445 }
jjantoine 0:399c0fbd595c 446
jjantoine 0:399c0fbd595c 447 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 448 {
jjantoine 0:399c0fbd595c 449 msb2[i] = ( b[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 450 b[1]=b[1]<<1;
jjantoine 0:399c0fbd595c 451
jjantoine 0:399c0fbd595c 452 }
jjantoine 0:399c0fbd595c 453
jjantoine 0:399c0fbd595c 454 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 455 {
jjantoine 0:399c0fbd595c 456 msb2[i] = ( b[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 457 b[2]=b[2]<<1;
jjantoine 0:399c0fbd595c 458
jjantoine 0:399c0fbd595c 459 }
jjantoine 0:399c0fbd595c 460
jjantoine 0:399c0fbd595c 461 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 462 {
jjantoine 0:399c0fbd595c 463 msb2[i] = ( b[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 464 b[3]=b[3]<<1;
jjantoine 0:399c0fbd595c 465
jjantoine 0:399c0fbd595c 466 }
jjantoine 0:399c0fbd595c 467
jjantoine 0:399c0fbd595c 468 for (i=0;i<32;i++)
jjantoine 0:399c0fbd595c 469 {
jjantoine 0:399c0fbd595c 470 msb3[i] = msb1[i] & msb2[i];
jjantoine 0:399c0fbd595c 471 }
jjantoine 0:399c0fbd595c 472
jjantoine 0:399c0fbd595c 473 return &msb3[0];
jjantoine 0:399c0fbd595c 474 }