Tesi Sitael / Mbed 2 deprecated TGP_SET_GPO_CMD_PASSED

Dependencies:   mbed

Committer:
jjantoine
Date:
Tue Dec 11 15:37:47 2018 +0000
Revision:
3:7ae2366ce74c
Parent:
2:ac809f724f60
Child:
4:a5b5809ee14f
ultimated;

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 1:c578c87f2be7 145
jjantoine 1:c578c87f2be7 146
jjantoine 1:c578c87f2be7 147 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 148 {
jjantoine 1:c578c87f2be7 149 UINT32_PacketSize[i] = A[i];
jjantoine 1:c578c87f2be7 150 }
jjantoine 1:c578c87f2be7 151
jjantoine 3:7ae2366ce74c 152
jjantoine 3:7ae2366ce74c 153 ENUM_Packet_ID = *B;
jjantoine 1:c578c87f2be7 154
jjantoine 1:c578c87f2be7 155 for(i=0;i<2;i++)
jjantoine 1:c578c87f2be7 156 {
jjantoine 1:c578c87f2be7 157 UINT16_PacketCounter[i] = C[i];
jjantoine 1:c578c87f2be7 158 }
jjantoine 1:c578c87f2be7 159
jjantoine 1:c578c87f2be7 160 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 161 {
jjantoine 1:c578c87f2be7 162 UINT32_Timestamp[i] = D[i];
jjantoine 1:c578c87f2be7 163 }
jjantoine 1:c578c87f2be7 164
jjantoine 1:c578c87f2be7 165 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 166 {
jjantoine 1:c578c87f2be7 167 UINT32_CRC[i] = E[i];
jjantoine 1:c578c87f2be7 168 }
jjantoine 1:c578c87f2be7 169
jjantoine 0:399c0fbd595c 170
jjantoine 0:399c0fbd595c 171 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 172 pc.printf("%c",UINT32_PacketSize[i]);
jjantoine 0:399c0fbd595c 173 }
jjantoine 0:399c0fbd595c 174
jjantoine 3:7ae2366ce74c 175 pc.printf("%c",ENUM_Packet_ID);
jjantoine 0:399c0fbd595c 176
jjantoine 0:399c0fbd595c 177 for(i=0; i<2; i++){
jjantoine 2:ac809f724f60 178 pc.printf("%c",UINT16_PacketCounter[i]);
jjantoine 0:399c0fbd595c 179 }
jjantoine 0:399c0fbd595c 180
jjantoine 0:399c0fbd595c 181 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 182 pc.printf("%c",UINT32_Timestamp[i]);
jjantoine 0:399c0fbd595c 183 }
jjantoine 0:399c0fbd595c 184
jjantoine 0:399c0fbd595c 185 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 186 pc.printf("%c",UINT32_CRC[i]);
jjantoine 0:399c0fbd595c 187 }
jjantoine 0:399c0fbd595c 188
jjantoine 0:399c0fbd595c 189 }
jjantoine 0:399c0fbd595c 190
jjantoine 0:399c0fbd595c 191 void GPIO_SET(char*A,char*B,char*C,char*D,char*E,char*F,char*G,char*H)
jjantoine 0:399c0fbd595c 192 {
jjantoine 0:399c0fbd595c 193 unsigned int i,btts;
jjantoine 0:399c0fbd595c 194
jjantoine 0:399c0fbd595c 195 btts=0;
jjantoine 0:399c0fbd595c 196
jjantoine 0:399c0fbd595c 197 char UINT32_Port0Value [4];
jjantoine 0:399c0fbd595c 198 char UINT32_Port0Mask [4];
jjantoine 0:399c0fbd595c 199 char UINT32_Port1Value [4];
jjantoine 0:399c0fbd595c 200 char UINT32_Port1Mask [4];
jjantoine 0:399c0fbd595c 201 char UINT32_Port2Value [4];
jjantoine 0:399c0fbd595c 202 char UINT32_Port2Mask [4];
jjantoine 0:399c0fbd595c 203 char UINT32_Port3Value [4];
jjantoine 0:399c0fbd595c 204 char UINT32_Port3Mask [4];
jjantoine 0:399c0fbd595c 205
jjantoine 0:399c0fbd595c 206 int* porta0;
jjantoine 0:399c0fbd595c 207 int* porta1;
jjantoine 0:399c0fbd595c 208 int* porta2;
jjantoine 0:399c0fbd595c 209 int* porta3;
jjantoine 0:399c0fbd595c 210
jjantoine 0:399c0fbd595c 211 int bit0[32];
jjantoine 0:399c0fbd595c 212 int bit1[32];
jjantoine 0:399c0fbd595c 213 int bit2[32];
jjantoine 0:399c0fbd595c 214 int bit3[32];
jjantoine 0:399c0fbd595c 215
jjantoine 1:c578c87f2be7 216 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 217 {
jjantoine 1:c578c87f2be7 218 UINT32_Port0Value[i] = A[i];
jjantoine 1:c578c87f2be7 219 }
jjantoine 1:c578c87f2be7 220
jjantoine 1:c578c87f2be7 221 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 222 {
jjantoine 1:c578c87f2be7 223 UINT32_Port0Mask[i] = B[i];
jjantoine 1:c578c87f2be7 224 }
jjantoine 1:c578c87f2be7 225
jjantoine 1:c578c87f2be7 226 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 227 {
jjantoine 1:c578c87f2be7 228 UINT32_Port1Value[i] = C[i];
jjantoine 1:c578c87f2be7 229 }
jjantoine 1:c578c87f2be7 230
jjantoine 1:c578c87f2be7 231 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 232 {
jjantoine 1:c578c87f2be7 233 UINT32_Port1Mask[i] = D[i];
jjantoine 1:c578c87f2be7 234 }
jjantoine 1:c578c87f2be7 235
jjantoine 1:c578c87f2be7 236 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 237 {
jjantoine 1:c578c87f2be7 238 UINT32_Port2Value[i] = E[i];
jjantoine 1:c578c87f2be7 239 }
jjantoine 1:c578c87f2be7 240
jjantoine 1:c578c87f2be7 241 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 242 {
jjantoine 1:c578c87f2be7 243 UINT32_Port2Mask[i] = F[i];
jjantoine 1:c578c87f2be7 244 }
jjantoine 1:c578c87f2be7 245
jjantoine 1:c578c87f2be7 246 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 247 {
jjantoine 1:c578c87f2be7 248 UINT32_Port3Value[i] = G[i];
jjantoine 1:c578c87f2be7 249 }
jjantoine 1:c578c87f2be7 250
jjantoine 1:c578c87f2be7 251 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 252 {
jjantoine 1:c578c87f2be7 253 UINT32_Port3Mask[i] = H[i];
jjantoine 1:c578c87f2be7 254 }
jjantoine 1:c578c87f2be7 255
jjantoine 0:399c0fbd595c 256
jjantoine 0:399c0fbd595c 257 porta0 = charbit(UINT32_Port0Value,UINT32_Port0Mask);
jjantoine 0:399c0fbd595c 258
jjantoine 0:399c0fbd595c 259 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 260 {
jjantoine 0:399c0fbd595c 261 bit0[i]=porta0[i];
jjantoine 0:399c0fbd595c 262 }
jjantoine 0:399c0fbd595c 263
jjantoine 0:399c0fbd595c 264 porta1 = charbit(UINT32_Port1Value,UINT32_Port1Mask);
jjantoine 0:399c0fbd595c 265
jjantoine 0:399c0fbd595c 266 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 267 {
jjantoine 0:399c0fbd595c 268 bit1[i]=porta1[i];
jjantoine 0:399c0fbd595c 269 }
jjantoine 0:399c0fbd595c 270
jjantoine 0:399c0fbd595c 271 porta2 = charbit(UINT32_Port2Value,UINT32_Port2Mask);
jjantoine 0:399c0fbd595c 272
jjantoine 0:399c0fbd595c 273 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 274 {
jjantoine 0:399c0fbd595c 275 bit2[i]=porta2[i];
jjantoine 0:399c0fbd595c 276 }
jjantoine 0:399c0fbd595c 277
jjantoine 0:399c0fbd595c 278 porta3 = charbit(UINT32_Port3Value,UINT32_Port3Mask);
jjantoine 0:399c0fbd595c 279
jjantoine 0:399c0fbd595c 280 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 281 {
jjantoine 0:399c0fbd595c 282 bit3[i]=porta3[i];
jjantoine 0:399c0fbd595c 283 }
jjantoine 0:399c0fbd595c 284
jjantoine 0:399c0fbd595c 285 while(1)
jjantoine 0:399c0fbd595c 286 {
jjantoine 0:399c0fbd595c 287 if(mybutton == 0 & btts ==0)
jjantoine 0:399c0fbd595c 288 {
jjantoine 0:399c0fbd595c 289 Porta0_7 = bit0[0];
jjantoine 0:399c0fbd595c 290 Porta0_6 = bit0[1];
jjantoine 0:399c0fbd595c 291 Porta0_5 = bit0[2];
jjantoine 0:399c0fbd595c 292 Porta0_4 = bit0[3];
jjantoine 0:399c0fbd595c 293 Porta0_3 = bit0[4];
jjantoine 0:399c0fbd595c 294 Porta0_2 = bit0[5];
jjantoine 0:399c0fbd595c 295 Porta0_1 = bit0[6];
jjantoine 0:399c0fbd595c 296 Porta0_0 = bit0[7];
jjantoine 0:399c0fbd595c 297
jjantoine 0:399c0fbd595c 298 Porta1_7 = bit1[0];
jjantoine 0:399c0fbd595c 299 Porta1_6 = bit1[1];
jjantoine 0:399c0fbd595c 300 Porta1_5 = bit1[2];
jjantoine 0:399c0fbd595c 301 Porta1_4 = bit1[3];
jjantoine 0:399c0fbd595c 302 Porta1_3 = bit1[4];
jjantoine 0:399c0fbd595c 303 Porta1_2 = bit1[5];
jjantoine 0:399c0fbd595c 304 Porta1_1 = bit1[6];
jjantoine 0:399c0fbd595c 305 Porta1_0 = bit1[7];
jjantoine 0:399c0fbd595c 306
jjantoine 0:399c0fbd595c 307 Porta2_7 = bit2[0];
jjantoine 0:399c0fbd595c 308 Porta2_6 = bit2[1];
jjantoine 0:399c0fbd595c 309 Porta2_5 = bit2[2];
jjantoine 0:399c0fbd595c 310 Porta2_4 = bit2[3];
jjantoine 0:399c0fbd595c 311 Porta2_3 = bit2[4];
jjantoine 0:399c0fbd595c 312 Porta2_2 = bit2[5];
jjantoine 0:399c0fbd595c 313 Porta2_1 = bit2[6];
jjantoine 0:399c0fbd595c 314 Porta2_0 = bit2[7];
jjantoine 0:399c0fbd595c 315
jjantoine 0:399c0fbd595c 316 Porta3_7 = bit3[0];
jjantoine 0:399c0fbd595c 317 Porta3_6 = bit3[1];
jjantoine 0:399c0fbd595c 318 Porta3_5 = bit3[2];
jjantoine 0:399c0fbd595c 319 Porta3_4 = bit3[3];
jjantoine 0:399c0fbd595c 320 Porta3_3 = bit3[4];
jjantoine 0:399c0fbd595c 321 Porta3_2 = bit3[5];
jjantoine 0:399c0fbd595c 322 Porta3_1 = bit3[6];
jjantoine 0:399c0fbd595c 323 Porta3_0 = bit3[7];
jjantoine 0:399c0fbd595c 324
jjantoine 0:399c0fbd595c 325 btts = 1;
jjantoine 0:399c0fbd595c 326 } else if (mybutton == 0 & btts == 1) {
jjantoine 0:399c0fbd595c 327
jjantoine 0:399c0fbd595c 328 Porta0_7 = bit0[8];
jjantoine 0:399c0fbd595c 329 Porta0_6 = bit0[9];
jjantoine 0:399c0fbd595c 330 Porta0_5 = bit0[10];
jjantoine 0:399c0fbd595c 331 Porta0_4 = bit0[11];
jjantoine 0:399c0fbd595c 332 Porta0_3 = bit0[12];
jjantoine 0:399c0fbd595c 333 Porta0_2 = bit0[13];
jjantoine 0:399c0fbd595c 334 Porta0_1 = bit0[14];
jjantoine 0:399c0fbd595c 335 Porta0_0 = bit0[15];
jjantoine 0:399c0fbd595c 336
jjantoine 0:399c0fbd595c 337 Porta1_7 = bit1[8];
jjantoine 0:399c0fbd595c 338 Porta1_6 = bit1[9];
jjantoine 0:399c0fbd595c 339 Porta1_5 = bit1[10];
jjantoine 0:399c0fbd595c 340 Porta1_4 = bit1[11];
jjantoine 0:399c0fbd595c 341 Porta1_3 = bit1[12];
jjantoine 0:399c0fbd595c 342 Porta1_2 = bit1[13];
jjantoine 0:399c0fbd595c 343 Porta1_1 = bit1[14];
jjantoine 0:399c0fbd595c 344 Porta1_0 = bit1[15];
jjantoine 0:399c0fbd595c 345
jjantoine 0:399c0fbd595c 346 Porta2_7 = bit2[8];
jjantoine 0:399c0fbd595c 347 Porta2_6 = bit2[9];
jjantoine 0:399c0fbd595c 348 Porta2_5 = bit2[10];
jjantoine 0:399c0fbd595c 349 Porta2_4 = bit2[11];
jjantoine 0:399c0fbd595c 350 Porta2_3 = bit2[12];
jjantoine 0:399c0fbd595c 351 Porta2_2 = bit2[13];
jjantoine 0:399c0fbd595c 352 Porta2_1 = bit2[14];
jjantoine 0:399c0fbd595c 353 Porta2_0 = bit2[15];
jjantoine 0:399c0fbd595c 354
jjantoine 0:399c0fbd595c 355 Porta3_7 = bit3[8];
jjantoine 0:399c0fbd595c 356 Porta3_6 = bit3[9];
jjantoine 0:399c0fbd595c 357 Porta3_5 = bit3[10];
jjantoine 0:399c0fbd595c 358 Porta3_4 = bit3[11];
jjantoine 0:399c0fbd595c 359 Porta3_3 = bit3[12];
jjantoine 0:399c0fbd595c 360 Porta3_2 = bit3[13];
jjantoine 0:399c0fbd595c 361 Porta3_1 = bit3[14];
jjantoine 0:399c0fbd595c 362 Porta3_0 = bit3[15];
jjantoine 0:399c0fbd595c 363
jjantoine 0:399c0fbd595c 364 btts = 2;
jjantoine 0:399c0fbd595c 365 } else if (mybutton == 0 & btts == 2) {
jjantoine 0:399c0fbd595c 366
jjantoine 0:399c0fbd595c 367 Porta0_7 = bit0[16];
jjantoine 0:399c0fbd595c 368 Porta0_6 = bit0[17];
jjantoine 0:399c0fbd595c 369 Porta0_5 = bit0[18];
jjantoine 0:399c0fbd595c 370 Porta0_4 = bit0[19];
jjantoine 0:399c0fbd595c 371 Porta0_3 = bit0[20];
jjantoine 0:399c0fbd595c 372 Porta0_2 = bit0[21];
jjantoine 0:399c0fbd595c 373 Porta0_1 = bit0[22];
jjantoine 0:399c0fbd595c 374 Porta0_0 = bit0[23];
jjantoine 0:399c0fbd595c 375
jjantoine 0:399c0fbd595c 376 Porta1_7 = bit1[16];
jjantoine 0:399c0fbd595c 377 Porta1_6 = bit1[17];
jjantoine 0:399c0fbd595c 378 Porta1_5 = bit1[18];
jjantoine 0:399c0fbd595c 379 Porta1_4 = bit1[19];
jjantoine 0:399c0fbd595c 380 Porta1_3 = bit1[20];
jjantoine 0:399c0fbd595c 381 Porta1_2 = bit1[21];
jjantoine 0:399c0fbd595c 382 Porta1_1 = bit1[22];
jjantoine 0:399c0fbd595c 383 Porta1_0 = bit1[23];
jjantoine 0:399c0fbd595c 384
jjantoine 0:399c0fbd595c 385 Porta2_7 = bit2[16];
jjantoine 0:399c0fbd595c 386 Porta2_6 = bit2[17];
jjantoine 0:399c0fbd595c 387 Porta2_5 = bit2[18];
jjantoine 0:399c0fbd595c 388 Porta2_4 = bit2[19];
jjantoine 0:399c0fbd595c 389 Porta2_3 = bit2[20];
jjantoine 0:399c0fbd595c 390 Porta2_2 = bit2[21];
jjantoine 0:399c0fbd595c 391 Porta2_1 = bit2[22];
jjantoine 0:399c0fbd595c 392 Porta2_0 = bit2[23];
jjantoine 0:399c0fbd595c 393
jjantoine 0:399c0fbd595c 394 Porta3_7 = bit3[16];
jjantoine 0:399c0fbd595c 395 Porta3_6 = bit3[17];
jjantoine 0:399c0fbd595c 396 Porta3_5 = bit3[18];
jjantoine 0:399c0fbd595c 397 Porta3_4 = bit3[19];
jjantoine 0:399c0fbd595c 398 Porta3_3 = bit3[20];
jjantoine 0:399c0fbd595c 399 Porta3_2 = bit3[21];
jjantoine 0:399c0fbd595c 400 Porta3_1 = bit3[22];
jjantoine 0:399c0fbd595c 401 Porta3_0 = bit3[23];
jjantoine 0:399c0fbd595c 402
jjantoine 0:399c0fbd595c 403 btts = 3;
jjantoine 0:399c0fbd595c 404 } else if (mybutton == 0 & btts == 3) {
jjantoine 0:399c0fbd595c 405
jjantoine 0:399c0fbd595c 406 Porta0_7 = bit0[24];
jjantoine 0:399c0fbd595c 407 Porta0_6 = bit0[25];
jjantoine 0:399c0fbd595c 408 Porta0_5 = bit0[26];
jjantoine 0:399c0fbd595c 409 Porta0_4 = bit0[27];
jjantoine 0:399c0fbd595c 410 Porta0_3 = bit0[28];
jjantoine 0:399c0fbd595c 411 Porta0_2 = bit0[29];
jjantoine 0:399c0fbd595c 412 Porta0_1 = bit0[30];
jjantoine 0:399c0fbd595c 413 Porta0_0 = bit0[31];
jjantoine 0:399c0fbd595c 414
jjantoine 0:399c0fbd595c 415 Porta1_7 = bit1[24];
jjantoine 0:399c0fbd595c 416 Porta1_6 = bit1[25];
jjantoine 0:399c0fbd595c 417 Porta1_5 = bit1[26];
jjantoine 0:399c0fbd595c 418 Porta1_4 = bit1[27];
jjantoine 0:399c0fbd595c 419 Porta1_3 = bit1[28];
jjantoine 0:399c0fbd595c 420 Porta1_2 = bit1[29];
jjantoine 0:399c0fbd595c 421 Porta1_1 = bit1[30];
jjantoine 0:399c0fbd595c 422 Porta1_0 = bit1[31];
jjantoine 0:399c0fbd595c 423
jjantoine 0:399c0fbd595c 424 Porta2_7 = bit2[24];
jjantoine 0:399c0fbd595c 425 Porta2_6 = bit2[25];
jjantoine 0:399c0fbd595c 426 Porta2_5 = bit2[26];
jjantoine 0:399c0fbd595c 427 Porta2_4 = bit2[27];
jjantoine 0:399c0fbd595c 428 Porta2_3 = bit2[28];
jjantoine 0:399c0fbd595c 429 Porta2_2 = bit2[29];
jjantoine 0:399c0fbd595c 430 Porta2_1 = bit2[30];
jjantoine 0:399c0fbd595c 431 Porta2_0 = bit2[31];
jjantoine 0:399c0fbd595c 432
jjantoine 0:399c0fbd595c 433 Porta3_7 = bit3[24];
jjantoine 0:399c0fbd595c 434 Porta3_6 = bit3[25];
jjantoine 0:399c0fbd595c 435 Porta3_5 = bit3[26];
jjantoine 0:399c0fbd595c 436 Porta3_4 = bit3[27];
jjantoine 0:399c0fbd595c 437 Porta3_3 = bit3[28];
jjantoine 0:399c0fbd595c 438 Porta3_2 = bit3[29];
jjantoine 0:399c0fbd595c 439 Porta3_1 = bit3[30];
jjantoine 0:399c0fbd595c 440 Porta3_0 = bit3[31];
jjantoine 0:399c0fbd595c 441
jjantoine 0:399c0fbd595c 442 btts = 4;
jjantoine 0:399c0fbd595c 443 } else if (mybutton == 0 & btts == 4)
jjantoine 0:399c0fbd595c 444 {
jjantoine 0:399c0fbd595c 445 break;
jjantoine 0:399c0fbd595c 446 }
jjantoine 0:399c0fbd595c 447 }
jjantoine 0:399c0fbd595c 448
jjantoine 0:399c0fbd595c 449 }
jjantoine 0:399c0fbd595c 450
jjantoine 0:399c0fbd595c 451 int* charbit(char*c,char*d)
jjantoine 0:399c0fbd595c 452 {
jjantoine 0:399c0fbd595c 453 int msb1[32];
jjantoine 0:399c0fbd595c 454 int msb2[32];
jjantoine 0:399c0fbd595c 455 int msb3[32];
jjantoine 0:399c0fbd595c 456 int i;
jjantoine 0:399c0fbd595c 457 char a[4];
jjantoine 0:399c0fbd595c 458 char b[4];
jjantoine 0:399c0fbd595c 459
jjantoine 1:c578c87f2be7 460
jjantoine 1:c578c87f2be7 461 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 462 {
jjantoine 1:c578c87f2be7 463 a[i] = c[i];
jjantoine 1:c578c87f2be7 464 }
jjantoine 1:c578c87f2be7 465
jjantoine 1:c578c87f2be7 466 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 467 {
jjantoine 1:c578c87f2be7 468 b[i] = d[i];
jjantoine 1:c578c87f2be7 469 }
jjantoine 0:399c0fbd595c 470
jjantoine 0:399c0fbd595c 471
jjantoine 0:399c0fbd595c 472 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 473 {
jjantoine 0:399c0fbd595c 474 msb1[i] = ( a[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 475 a[0]=a[0]<<1;
jjantoine 0:399c0fbd595c 476
jjantoine 0:399c0fbd595c 477 }
jjantoine 0:399c0fbd595c 478
jjantoine 0:399c0fbd595c 479 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 480 {
jjantoine 0:399c0fbd595c 481 msb1[i] = ( a[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 482 a[1]=a[1]<<1;
jjantoine 0:399c0fbd595c 483
jjantoine 0:399c0fbd595c 484 }
jjantoine 0:399c0fbd595c 485
jjantoine 0:399c0fbd595c 486 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 487 {
jjantoine 0:399c0fbd595c 488 msb1[i] = ( a[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 489 a[2]=a[2]<<1;
jjantoine 0:399c0fbd595c 490
jjantoine 0:399c0fbd595c 491 }
jjantoine 0:399c0fbd595c 492
jjantoine 0:399c0fbd595c 493 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 494 {
jjantoine 0:399c0fbd595c 495 msb1[i] = ( a[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 496 a[3]=a[3]<<1;
jjantoine 0:399c0fbd595c 497
jjantoine 0:399c0fbd595c 498 }
jjantoine 0:399c0fbd595c 499
jjantoine 0:399c0fbd595c 500 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 501 {
jjantoine 0:399c0fbd595c 502 msb2[i] = ( b[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 503 b[0]=b[0]<<1;
jjantoine 0:399c0fbd595c 504
jjantoine 0:399c0fbd595c 505 }
jjantoine 0:399c0fbd595c 506
jjantoine 0:399c0fbd595c 507 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 508 {
jjantoine 0:399c0fbd595c 509 msb2[i] = ( b[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 510 b[1]=b[1]<<1;
jjantoine 0:399c0fbd595c 511
jjantoine 0:399c0fbd595c 512 }
jjantoine 0:399c0fbd595c 513
jjantoine 0:399c0fbd595c 514 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 515 {
jjantoine 0:399c0fbd595c 516 msb2[i] = ( b[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 517 b[2]=b[2]<<1;
jjantoine 0:399c0fbd595c 518
jjantoine 0:399c0fbd595c 519 }
jjantoine 0:399c0fbd595c 520
jjantoine 0:399c0fbd595c 521 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 522 {
jjantoine 0:399c0fbd595c 523 msb2[i] = ( b[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 524 b[3]=b[3]<<1;
jjantoine 0:399c0fbd595c 525
jjantoine 0:399c0fbd595c 526 }
jjantoine 0:399c0fbd595c 527
jjantoine 0:399c0fbd595c 528 for (i=0;i<32;i++)
jjantoine 0:399c0fbd595c 529 {
jjantoine 0:399c0fbd595c 530 msb3[i] = msb1[i] & msb2[i];
jjantoine 0:399c0fbd595c 531 }
jjantoine 0:399c0fbd595c 532
jjantoine 0:399c0fbd595c 533 return &msb3[0];
jjantoine 0:399c0fbd595c 534 }