Tesi Sitael / Mbed 2 deprecated TGP_SET_GPO_CMD_PASSED

Dependencies:   mbed

Committer:
jjantoine
Date:
Fri Dec 21 15:39:53 2018 +0000
Revision:
5:851e7afdc4fe
Parent:
4:a5b5809ee14f
GPO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jjantoine 0:399c0fbd595c 1 #include "mbed.h"
jjantoine 5:851e7afdc4fe 2 #include "TYPE_Def.h"
jjantoine 5:851e7afdc4fe 3 #include "CRC32BIT_LOOKUP_Ext.h"
jjantoine 5:851e7afdc4fe 4
jjantoine 0:399c0fbd595c 5
jjantoine 0:399c0fbd595c 6 Serial pc(USBTX, USBRX); // tx, rx
jjantoine 0:399c0fbd595c 7
jjantoine 5:851e7afdc4fe 8 UINT32_T crc;
jjantoine 5:851e7afdc4fe 9 ERROR_T ERROR_Value;
jjantoine 5:851e7afdc4fe 10 CRC32BIT_LOOKUP_TS _Crc32Table_TGP_DUT;
jjantoine 5:851e7afdc4fe 11 BYTE_T vettore[11];
jjantoine 5:851e7afdc4fe 12 char crcchar[4];
jjantoine 5:851e7afdc4fe 13 unsigned int j;
jjantoine 5:851e7afdc4fe 14
jjantoine 5:851e7afdc4fe 15 //char crc[4] = {0xBD ,0x5A , 0x97 , 0xDD};
jjantoine 5:851e7afdc4fe 16 char packetsize[4] = {0x00 ,0x00 , 0x00 , 0x0F};
jjantoine 5:851e7afdc4fe 17
jjantoine 5:851e7afdc4fe 18
jjantoine 5:851e7afdc4fe 19
jjantoine 0:399c0fbd595c 20 DigitalIn mybutton(USER_BUTTON);
jjantoine 4:a5b5809ee14f 21 DigitalOut myled(LED2);
jjantoine 0:399c0fbd595c 22
jjantoine 0:399c0fbd595c 23
jjantoine 0:399c0fbd595c 24 DigitalOut Porta0_7 (PA_0);
jjantoine 0:399c0fbd595c 25 DigitalOut Porta0_6 (PA_1);
jjantoine 0:399c0fbd595c 26 DigitalOut Porta0_5 (PA_4);
jjantoine 0:399c0fbd595c 27 DigitalOut Porta0_4 (PA_6);
jjantoine 0:399c0fbd595c 28 DigitalOut Porta0_3 (PA_7);
jjantoine 0:399c0fbd595c 29 DigitalOut Porta0_2 (PA_8);
jjantoine 0:399c0fbd595c 30 DigitalOut Porta0_1 (PA_9);
jjantoine 0:399c0fbd595c 31 DigitalOut Porta0_0 (PA_12);
jjantoine 0:399c0fbd595c 32
jjantoine 0:399c0fbd595c 33 DigitalOut Porta1_7 (PB_0);
jjantoine 0:399c0fbd595c 34 DigitalOut Porta1_6 (PB_1);
jjantoine 0:399c0fbd595c 35 DigitalOut Porta1_5 (PB_3);
jjantoine 0:399c0fbd595c 36 DigitalOut Porta1_4 (PB_4);
jjantoine 0:399c0fbd595c 37 DigitalOut Porta1_3 (PB_5);
jjantoine 0:399c0fbd595c 38 DigitalOut Porta1_2 (PB_6);
jjantoine 0:399c0fbd595c 39 DigitalOut Porta1_1 (PB_7);
jjantoine 0:399c0fbd595c 40 DigitalOut Porta1_0 (PB_10);
jjantoine 0:399c0fbd595c 41
jjantoine 0:399c0fbd595c 42 DigitalOut Porta2_7 (PC_0);
jjantoine 0:399c0fbd595c 43 DigitalOut Porta2_6 (PC_1);
jjantoine 0:399c0fbd595c 44 DigitalOut Porta2_5 (PC_2);
jjantoine 0:399c0fbd595c 45 DigitalOut Porta2_4 (PC_3);
jjantoine 0:399c0fbd595c 46 DigitalOut Porta2_3 (PC_5);
jjantoine 0:399c0fbd595c 47 DigitalOut Porta2_2 (PC_6);
jjantoine 0:399c0fbd595c 48 DigitalOut Porta2_1 (PC_7);
jjantoine 0:399c0fbd595c 49 DigitalOut Porta2_0 (PC_8);
jjantoine 0:399c0fbd595c 50
jjantoine 0:399c0fbd595c 51 DigitalOut Porta3_7 (PA_13);
jjantoine 0:399c0fbd595c 52 DigitalOut Porta3_6 (PA_14);
jjantoine 0:399c0fbd595c 53 DigitalOut Porta3_5 (PA_15);
jjantoine 0:399c0fbd595c 54 DigitalOut Porta3_4 (PC_14);
jjantoine 0:399c0fbd595c 55 DigitalOut Porta3_3 (PC_15);
jjantoine 0:399c0fbd595c 56 DigitalOut Porta3_2 (PA_11);
jjantoine 0:399c0fbd595c 57 DigitalOut Porta3_1 (PB_12);
jjantoine 0:399c0fbd595c 58 DigitalOut Porta3_0 (PC_4);
jjantoine 0:399c0fbd595c 59
jjantoine 5:851e7afdc4fe 60 void crc_cal();
jjantoine 0:399c0fbd595c 61 void TGP_SET_GPO_CMD();
jjantoine 0:399c0fbd595c 62 void TGP_SET_GPO_ACK(char*, char*, char*, char*, char*);
jjantoine 0:399c0fbd595c 63 void GPIO_SET(char*,char*,char*,char*,char*,char*,char*,char*);
jjantoine 0:399c0fbd595c 64 int* charbit(char*,char*);
jjantoine 0:399c0fbd595c 65
jjantoine 0:399c0fbd595c 66 int main()
jjantoine 0:399c0fbd595c 67 {
jjantoine 5:851e7afdc4fe 68
jjantoine 5:851e7afdc4fe 69 pc.baud(9600);
jjantoine 5:851e7afdc4fe 70
jjantoine 0:399c0fbd595c 71 while(1)
jjantoine 0:399c0fbd595c 72 {
jjantoine 5:851e7afdc4fe 73 pc.attach(&TGP_SET_GPO_CMD,Serial::RxIrq);
jjantoine 0:399c0fbd595c 74 }
jjantoine 0:399c0fbd595c 75
jjantoine 0:399c0fbd595c 76
jjantoine 0:399c0fbd595c 77 }
jjantoine 0:399c0fbd595c 78
jjantoine 0:399c0fbd595c 79
jjantoine 0:399c0fbd595c 80
jjantoine 0:399c0fbd595c 81 void TGP_SET_GPO_CMD()
jjantoine 0:399c0fbd595c 82 {
jjantoine 0:399c0fbd595c 83 unsigned int i;
jjantoine 0:399c0fbd595c 84
jjantoine 0:399c0fbd595c 85 char UINT32_PacketSize [4];
jjantoine 0:399c0fbd595c 86 char ENUM_Packet_ID;
jjantoine 0:399c0fbd595c 87 char UINT16_PacketCounter [2];
jjantoine 0:399c0fbd595c 88 char UINT32_Timestamp [4];
jjantoine 0:399c0fbd595c 89 char UINT32_Port0Value [4];
jjantoine 0:399c0fbd595c 90 char UINT32_Port0Mask [4];
jjantoine 0:399c0fbd595c 91 char UINT32_Port1Value [4];
jjantoine 0:399c0fbd595c 92 char UINT32_Port1Mask [4];
jjantoine 0:399c0fbd595c 93 char UINT32_Port2Value [4];
jjantoine 0:399c0fbd595c 94 char UINT32_Port2Mask [4];
jjantoine 0:399c0fbd595c 95 char UINT32_Port3Value [4];
jjantoine 0:399c0fbd595c 96 char UINT32_Port3Mask [4];
jjantoine 0:399c0fbd595c 97 char UINT32_CRC [4];
jjantoine 0:399c0fbd595c 98
jjantoine 5:851e7afdc4fe 99 myled = 0;
jjantoine 5:851e7afdc4fe 100
jjantoine 0:399c0fbd595c 101 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 102 UINT32_PacketSize[i] = pc.getc();
jjantoine 0:399c0fbd595c 103 }
jjantoine 0:399c0fbd595c 104
jjantoine 5:851e7afdc4fe 105 ENUM_Packet_ID=pc.getc();
jjantoine 0:399c0fbd595c 106
jjantoine 0:399c0fbd595c 107 for(i=0; i<2; i++){
jjantoine 5:851e7afdc4fe 108 UINT16_PacketCounter[i]=pc.getc();
jjantoine 0:399c0fbd595c 109 }
jjantoine 0:399c0fbd595c 110
jjantoine 0:399c0fbd595c 111 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 112 UINT32_Timestamp[i]=pc.getc();
jjantoine 0:399c0fbd595c 113 }
jjantoine 0:399c0fbd595c 114
jjantoine 0:399c0fbd595c 115 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 116 UINT32_Port0Value[i]=pc.getc();
jjantoine 0:399c0fbd595c 117 }
jjantoine 0:399c0fbd595c 118
jjantoine 0:399c0fbd595c 119 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 120 UINT32_Port0Mask[i]=pc.getc();
jjantoine 0:399c0fbd595c 121 }
jjantoine 0:399c0fbd595c 122
jjantoine 0:399c0fbd595c 123 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 124 UINT32_Port1Value[i]=pc.getc();
jjantoine 0:399c0fbd595c 125 }
jjantoine 0:399c0fbd595c 126
jjantoine 0:399c0fbd595c 127 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 128 UINT32_Port1Mask[i]=pc.getc();
jjantoine 0:399c0fbd595c 129 }
jjantoine 0:399c0fbd595c 130
jjantoine 0:399c0fbd595c 131 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 132 UINT32_Port2Value[i]=pc.getc();
jjantoine 0:399c0fbd595c 133 }
jjantoine 0:399c0fbd595c 134
jjantoine 0:399c0fbd595c 135 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 136 UINT32_Port2Mask[i]=pc.getc();
jjantoine 5:851e7afdc4fe 137 }
jjantoine 5:851e7afdc4fe 138
jjantoine 5:851e7afdc4fe 139 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 140 UINT32_Port3Value[i]=pc.getc();
jjantoine 0:399c0fbd595c 141 }
jjantoine 0:399c0fbd595c 142
jjantoine 0:399c0fbd595c 143 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 144 UINT32_Port3Mask[i]=pc.getc();
jjantoine 0:399c0fbd595c 145 }
jjantoine 0:399c0fbd595c 146
jjantoine 0:399c0fbd595c 147 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 148 UINT32_CRC[i]=pc.getc();
jjantoine 0:399c0fbd595c 149 }
jjantoine 0:399c0fbd595c 150
jjantoine 5:851e7afdc4fe 151 myled = 1;
jjantoine 0:399c0fbd595c 152
jjantoine 0:399c0fbd595c 153 TGP_SET_GPO_ACK(UINT32_PacketSize,&ENUM_Packet_ID,UINT16_PacketCounter,UINT32_Timestamp,UINT32_CRC);
jjantoine 0:399c0fbd595c 154 GPIO_SET(UINT32_Port0Value,UINT32_Port0Mask,UINT32_Port1Value,UINT32_Port1Mask,UINT32_Port2Value,UINT32_Port2Mask,UINT32_Port3Value,UINT32_Port3Mask);
jjantoine 0:399c0fbd595c 155
jjantoine 0:399c0fbd595c 156 }
jjantoine 0:399c0fbd595c 157
jjantoine 0:399c0fbd595c 158 void TGP_SET_GPO_ACK(char*A, char*B, char*C, char*D, char*E)
jjantoine 0:399c0fbd595c 159 {
jjantoine 0:399c0fbd595c 160 char UINT32_PacketSize [4];
jjantoine 0:399c0fbd595c 161 char ENUM_Packet_ID;
jjantoine 0:399c0fbd595c 162 char UINT16_PacketCounter [2];
jjantoine 0:399c0fbd595c 163 char UINT32_Timestamp [4];
jjantoine 0:399c0fbd595c 164 char UINT32_CRC [4];
jjantoine 0:399c0fbd595c 165
jjantoine 0:399c0fbd595c 166 unsigned int i;
jjantoine 0:399c0fbd595c 167
jjantoine 1:c578c87f2be7 168
jjantoine 1:c578c87f2be7 169
jjantoine 1:c578c87f2be7 170 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 171 {
jjantoine 1:c578c87f2be7 172 UINT32_PacketSize[i] = A[i];
jjantoine 1:c578c87f2be7 173 }
jjantoine 1:c578c87f2be7 174
jjantoine 3:7ae2366ce74c 175
jjantoine 3:7ae2366ce74c 176 ENUM_Packet_ID = *B;
jjantoine 1:c578c87f2be7 177
jjantoine 1:c578c87f2be7 178 for(i=0;i<2;i++)
jjantoine 1:c578c87f2be7 179 {
jjantoine 1:c578c87f2be7 180 UINT16_PacketCounter[i] = C[i];
jjantoine 1:c578c87f2be7 181 }
jjantoine 1:c578c87f2be7 182
jjantoine 1:c578c87f2be7 183 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 184 {
jjantoine 1:c578c87f2be7 185 UINT32_Timestamp[i] = D[i];
jjantoine 1:c578c87f2be7 186 }
jjantoine 1:c578c87f2be7 187
jjantoine 1:c578c87f2be7 188 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 189 {
jjantoine 1:c578c87f2be7 190 UINT32_CRC[i] = E[i];
jjantoine 1:c578c87f2be7 191 }
jjantoine 1:c578c87f2be7 192
jjantoine 5:851e7afdc4fe 193 //def vettore
jjantoine 5:851e7afdc4fe 194 j=0;
jjantoine 5:851e7afdc4fe 195 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 196 vettore[j] = packetsize[i];
jjantoine 5:851e7afdc4fe 197 j++;
jjantoine 5:851e7afdc4fe 198 }
jjantoine 0:399c0fbd595c 199
jjantoine 5:851e7afdc4fe 200 vettore[j] = ENUM_Packet_ID+1;
jjantoine 5:851e7afdc4fe 201 j++;
jjantoine 5:851e7afdc4fe 202
jjantoine 5:851e7afdc4fe 203 for(i=0; i<2; i++){
jjantoine 5:851e7afdc4fe 204 vettore[j] = UINT16_PacketCounter[i];
jjantoine 5:851e7afdc4fe 205 j++;
jjantoine 5:851e7afdc4fe 206 }
jjantoine 5:851e7afdc4fe 207
jjantoine 5:851e7afdc4fe 208 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 209 vettore[j] = UINT32_Timestamp[i];
jjantoine 5:851e7afdc4fe 210 j++;
jjantoine 5:851e7afdc4fe 211 }
jjantoine 5:851e7afdc4fe 212
jjantoine 5:851e7afdc4fe 213 /*
jjantoine 0:399c0fbd595c 214 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 215 pc.printf("%c",UINT32_PacketSize[i]);
jjantoine 0:399c0fbd595c 216 }
jjantoine 5:851e7afdc4fe 217 */
jjantoine 5:851e7afdc4fe 218 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 219 pc.printf("%c",packetsize[i]);
jjantoine 5:851e7afdc4fe 220 }
jjantoine 0:399c0fbd595c 221
jjantoine 5:851e7afdc4fe 222 pc.printf("%c",ENUM_Packet_ID+1);
jjantoine 0:399c0fbd595c 223
jjantoine 0:399c0fbd595c 224 for(i=0; i<2; i++){
jjantoine 2:ac809f724f60 225 pc.printf("%c",UINT16_PacketCounter[i]);
jjantoine 0:399c0fbd595c 226 }
jjantoine 0:399c0fbd595c 227
jjantoine 0:399c0fbd595c 228 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 229 pc.printf("%c",UINT32_Timestamp[i]);
jjantoine 0:399c0fbd595c 230 }
jjantoine 5:851e7afdc4fe 231
jjantoine 5:851e7afdc4fe 232 /*
jjantoine 0:399c0fbd595c 233 for(i=0; i<4; i++){
jjantoine 2:ac809f724f60 234 pc.printf("%c",UINT32_CRC[i]);
jjantoine 0:399c0fbd595c 235 }
jjantoine 5:851e7afdc4fe 236 */
jjantoine 5:851e7afdc4fe 237
jjantoine 5:851e7afdc4fe 238 crc_cal();
jjantoine 5:851e7afdc4fe 239
jjantoine 5:851e7afdc4fe 240 for(i=0; i<4; i++){
jjantoine 5:851e7afdc4fe 241 pc.printf("%c",crcchar[i]);
jjantoine 5:851e7afdc4fe 242 }
jjantoine 5:851e7afdc4fe 243
jjantoine 5:851e7afdc4fe 244 myled = 0;
jjantoine 0:399c0fbd595c 245
jjantoine 0:399c0fbd595c 246 }
jjantoine 0:399c0fbd595c 247
jjantoine 0:399c0fbd595c 248 void GPIO_SET(char*A,char*B,char*C,char*D,char*E,char*F,char*G,char*H)
jjantoine 0:399c0fbd595c 249 {
jjantoine 0:399c0fbd595c 250 unsigned int i,btts;
jjantoine 0:399c0fbd595c 251
jjantoine 0:399c0fbd595c 252 btts=0;
jjantoine 0:399c0fbd595c 253
jjantoine 0:399c0fbd595c 254 char UINT32_Port0Value [4];
jjantoine 0:399c0fbd595c 255 char UINT32_Port0Mask [4];
jjantoine 0:399c0fbd595c 256 char UINT32_Port1Value [4];
jjantoine 0:399c0fbd595c 257 char UINT32_Port1Mask [4];
jjantoine 0:399c0fbd595c 258 char UINT32_Port2Value [4];
jjantoine 0:399c0fbd595c 259 char UINT32_Port2Mask [4];
jjantoine 0:399c0fbd595c 260 char UINT32_Port3Value [4];
jjantoine 0:399c0fbd595c 261 char UINT32_Port3Mask [4];
jjantoine 0:399c0fbd595c 262
jjantoine 0:399c0fbd595c 263 int* porta0;
jjantoine 0:399c0fbd595c 264 int* porta1;
jjantoine 0:399c0fbd595c 265 int* porta2;
jjantoine 0:399c0fbd595c 266 int* porta3;
jjantoine 0:399c0fbd595c 267
jjantoine 0:399c0fbd595c 268 int bit0[32];
jjantoine 0:399c0fbd595c 269 int bit1[32];
jjantoine 0:399c0fbd595c 270 int bit2[32];
jjantoine 0:399c0fbd595c 271 int bit3[32];
jjantoine 0:399c0fbd595c 272
jjantoine 1:c578c87f2be7 273 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 274 {
jjantoine 1:c578c87f2be7 275 UINT32_Port0Value[i] = A[i];
jjantoine 1:c578c87f2be7 276 }
jjantoine 1:c578c87f2be7 277
jjantoine 1:c578c87f2be7 278 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 279 {
jjantoine 1:c578c87f2be7 280 UINT32_Port0Mask[i] = B[i];
jjantoine 1:c578c87f2be7 281 }
jjantoine 1:c578c87f2be7 282
jjantoine 1:c578c87f2be7 283 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 284 {
jjantoine 1:c578c87f2be7 285 UINT32_Port1Value[i] = C[i];
jjantoine 1:c578c87f2be7 286 }
jjantoine 1:c578c87f2be7 287
jjantoine 1:c578c87f2be7 288 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 289 {
jjantoine 1:c578c87f2be7 290 UINT32_Port1Mask[i] = D[i];
jjantoine 1:c578c87f2be7 291 }
jjantoine 1:c578c87f2be7 292
jjantoine 1:c578c87f2be7 293 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 294 {
jjantoine 1:c578c87f2be7 295 UINT32_Port2Value[i] = E[i];
jjantoine 1:c578c87f2be7 296 }
jjantoine 1:c578c87f2be7 297
jjantoine 1:c578c87f2be7 298 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 299 {
jjantoine 1:c578c87f2be7 300 UINT32_Port2Mask[i] = F[i];
jjantoine 1:c578c87f2be7 301 }
jjantoine 1:c578c87f2be7 302
jjantoine 1:c578c87f2be7 303 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 304 {
jjantoine 1:c578c87f2be7 305 UINT32_Port3Value[i] = G[i];
jjantoine 1:c578c87f2be7 306 }
jjantoine 1:c578c87f2be7 307
jjantoine 1:c578c87f2be7 308 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 309 {
jjantoine 1:c578c87f2be7 310 UINT32_Port3Mask[i] = H[i];
jjantoine 1:c578c87f2be7 311 }
jjantoine 1:c578c87f2be7 312
jjantoine 0:399c0fbd595c 313
jjantoine 0:399c0fbd595c 314 porta0 = charbit(UINT32_Port0Value,UINT32_Port0Mask);
jjantoine 0:399c0fbd595c 315
jjantoine 0:399c0fbd595c 316 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 317 {
jjantoine 0:399c0fbd595c 318 bit0[i]=porta0[i];
jjantoine 0:399c0fbd595c 319 }
jjantoine 0:399c0fbd595c 320
jjantoine 0:399c0fbd595c 321 porta1 = charbit(UINT32_Port1Value,UINT32_Port1Mask);
jjantoine 0:399c0fbd595c 322
jjantoine 0:399c0fbd595c 323 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 324 {
jjantoine 0:399c0fbd595c 325 bit1[i]=porta1[i];
jjantoine 0:399c0fbd595c 326 }
jjantoine 0:399c0fbd595c 327
jjantoine 0:399c0fbd595c 328 porta2 = charbit(UINT32_Port2Value,UINT32_Port2Mask);
jjantoine 0:399c0fbd595c 329
jjantoine 0:399c0fbd595c 330 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 331 {
jjantoine 0:399c0fbd595c 332 bit2[i]=porta2[i];
jjantoine 0:399c0fbd595c 333 }
jjantoine 0:399c0fbd595c 334
jjantoine 0:399c0fbd595c 335 porta3 = charbit(UINT32_Port3Value,UINT32_Port3Mask);
jjantoine 0:399c0fbd595c 336
jjantoine 0:399c0fbd595c 337 for(i=0;i<32;i++)
jjantoine 0:399c0fbd595c 338 {
jjantoine 0:399c0fbd595c 339 bit3[i]=porta3[i];
jjantoine 0:399c0fbd595c 340 }
jjantoine 0:399c0fbd595c 341
jjantoine 5:851e7afdc4fe 342 //while(1)
jjantoine 5:851e7afdc4fe 343 //{
jjantoine 4:a5b5809ee14f 344
jjantoine 5:851e7afdc4fe 345 //if(mybutton == 0 & btts ==0)
jjantoine 5:851e7afdc4fe 346 //{
jjantoine 0:399c0fbd595c 347 Porta0_7 = bit0[0];
jjantoine 0:399c0fbd595c 348 Porta0_6 = bit0[1];
jjantoine 0:399c0fbd595c 349 Porta0_5 = bit0[2];
jjantoine 0:399c0fbd595c 350 Porta0_4 = bit0[3];
jjantoine 0:399c0fbd595c 351 Porta0_3 = bit0[4];
jjantoine 0:399c0fbd595c 352 Porta0_2 = bit0[5];
jjantoine 0:399c0fbd595c 353 Porta0_1 = bit0[6];
jjantoine 0:399c0fbd595c 354 Porta0_0 = bit0[7];
jjantoine 0:399c0fbd595c 355
jjantoine 0:399c0fbd595c 356 Porta1_7 = bit1[0];
jjantoine 0:399c0fbd595c 357 Porta1_6 = bit1[1];
jjantoine 0:399c0fbd595c 358 Porta1_5 = bit1[2];
jjantoine 0:399c0fbd595c 359 Porta1_4 = bit1[3];
jjantoine 0:399c0fbd595c 360 Porta1_3 = bit1[4];
jjantoine 0:399c0fbd595c 361 Porta1_2 = bit1[5];
jjantoine 0:399c0fbd595c 362 Porta1_1 = bit1[6];
jjantoine 0:399c0fbd595c 363 Porta1_0 = bit1[7];
jjantoine 0:399c0fbd595c 364
jjantoine 0:399c0fbd595c 365 Porta2_7 = bit2[0];
jjantoine 0:399c0fbd595c 366 Porta2_6 = bit2[1];
jjantoine 0:399c0fbd595c 367 Porta2_5 = bit2[2];
jjantoine 0:399c0fbd595c 368 Porta2_4 = bit2[3];
jjantoine 0:399c0fbd595c 369 Porta2_3 = bit2[4];
jjantoine 0:399c0fbd595c 370 Porta2_2 = bit2[5];
jjantoine 0:399c0fbd595c 371 Porta2_1 = bit2[6];
jjantoine 0:399c0fbd595c 372 Porta2_0 = bit2[7];
jjantoine 0:399c0fbd595c 373
jjantoine 0:399c0fbd595c 374 Porta3_7 = bit3[0];
jjantoine 0:399c0fbd595c 375 Porta3_6 = bit3[1];
jjantoine 0:399c0fbd595c 376 Porta3_5 = bit3[2];
jjantoine 0:399c0fbd595c 377 Porta3_4 = bit3[3];
jjantoine 0:399c0fbd595c 378 Porta3_3 = bit3[4];
jjantoine 0:399c0fbd595c 379 Porta3_2 = bit3[5];
jjantoine 0:399c0fbd595c 380 Porta3_1 = bit3[6];
jjantoine 0:399c0fbd595c 381 Porta3_0 = bit3[7];
jjantoine 0:399c0fbd595c 382
jjantoine 5:851e7afdc4fe 383 // wait(1);
jjantoine 5:851e7afdc4fe 384 // btts = 1;
jjantoine 5:851e7afdc4fe 385 //} else if (mybutton == 0 & btts == 1) {
jjantoine 0:399c0fbd595c 386
jjantoine 0:399c0fbd595c 387 Porta0_7 = bit0[8];
jjantoine 0:399c0fbd595c 388 Porta0_6 = bit0[9];
jjantoine 0:399c0fbd595c 389 Porta0_5 = bit0[10];
jjantoine 0:399c0fbd595c 390 Porta0_4 = bit0[11];
jjantoine 0:399c0fbd595c 391 Porta0_3 = bit0[12];
jjantoine 0:399c0fbd595c 392 Porta0_2 = bit0[13];
jjantoine 0:399c0fbd595c 393 Porta0_1 = bit0[14];
jjantoine 0:399c0fbd595c 394 Porta0_0 = bit0[15];
jjantoine 0:399c0fbd595c 395
jjantoine 0:399c0fbd595c 396 Porta1_7 = bit1[8];
jjantoine 0:399c0fbd595c 397 Porta1_6 = bit1[9];
jjantoine 0:399c0fbd595c 398 Porta1_5 = bit1[10];
jjantoine 0:399c0fbd595c 399 Porta1_4 = bit1[11];
jjantoine 0:399c0fbd595c 400 Porta1_3 = bit1[12];
jjantoine 0:399c0fbd595c 401 Porta1_2 = bit1[13];
jjantoine 0:399c0fbd595c 402 Porta1_1 = bit1[14];
jjantoine 0:399c0fbd595c 403 Porta1_0 = bit1[15];
jjantoine 0:399c0fbd595c 404
jjantoine 0:399c0fbd595c 405 Porta2_7 = bit2[8];
jjantoine 0:399c0fbd595c 406 Porta2_6 = bit2[9];
jjantoine 0:399c0fbd595c 407 Porta2_5 = bit2[10];
jjantoine 0:399c0fbd595c 408 Porta2_4 = bit2[11];
jjantoine 0:399c0fbd595c 409 Porta2_3 = bit2[12];
jjantoine 0:399c0fbd595c 410 Porta2_2 = bit2[13];
jjantoine 0:399c0fbd595c 411 Porta2_1 = bit2[14];
jjantoine 0:399c0fbd595c 412 Porta2_0 = bit2[15];
jjantoine 0:399c0fbd595c 413
jjantoine 0:399c0fbd595c 414 Porta3_7 = bit3[8];
jjantoine 0:399c0fbd595c 415 Porta3_6 = bit3[9];
jjantoine 0:399c0fbd595c 416 Porta3_5 = bit3[10];
jjantoine 0:399c0fbd595c 417 Porta3_4 = bit3[11];
jjantoine 0:399c0fbd595c 418 Porta3_3 = bit3[12];
jjantoine 0:399c0fbd595c 419 Porta3_2 = bit3[13];
jjantoine 0:399c0fbd595c 420 Porta3_1 = bit3[14];
jjantoine 0:399c0fbd595c 421 Porta3_0 = bit3[15];
jjantoine 0:399c0fbd595c 422
jjantoine 5:851e7afdc4fe 423 // wait(1);
jjantoine 5:851e7afdc4fe 424 // btts = 2;
jjantoine 5:851e7afdc4fe 425 //} else if (mybutton == 0 & btts == 2) {
jjantoine 0:399c0fbd595c 426
jjantoine 0:399c0fbd595c 427 Porta0_7 = bit0[16];
jjantoine 0:399c0fbd595c 428 Porta0_6 = bit0[17];
jjantoine 0:399c0fbd595c 429 Porta0_5 = bit0[18];
jjantoine 0:399c0fbd595c 430 Porta0_4 = bit0[19];
jjantoine 0:399c0fbd595c 431 Porta0_3 = bit0[20];
jjantoine 0:399c0fbd595c 432 Porta0_2 = bit0[21];
jjantoine 0:399c0fbd595c 433 Porta0_1 = bit0[22];
jjantoine 0:399c0fbd595c 434 Porta0_0 = bit0[23];
jjantoine 0:399c0fbd595c 435
jjantoine 0:399c0fbd595c 436 Porta1_7 = bit1[16];
jjantoine 0:399c0fbd595c 437 Porta1_6 = bit1[17];
jjantoine 0:399c0fbd595c 438 Porta1_5 = bit1[18];
jjantoine 0:399c0fbd595c 439 Porta1_4 = bit1[19];
jjantoine 0:399c0fbd595c 440 Porta1_3 = bit1[20];
jjantoine 0:399c0fbd595c 441 Porta1_2 = bit1[21];
jjantoine 0:399c0fbd595c 442 Porta1_1 = bit1[22];
jjantoine 0:399c0fbd595c 443 Porta1_0 = bit1[23];
jjantoine 0:399c0fbd595c 444
jjantoine 0:399c0fbd595c 445 Porta2_7 = bit2[16];
jjantoine 0:399c0fbd595c 446 Porta2_6 = bit2[17];
jjantoine 0:399c0fbd595c 447 Porta2_5 = bit2[18];
jjantoine 0:399c0fbd595c 448 Porta2_4 = bit2[19];
jjantoine 0:399c0fbd595c 449 Porta2_3 = bit2[20];
jjantoine 0:399c0fbd595c 450 Porta2_2 = bit2[21];
jjantoine 0:399c0fbd595c 451 Porta2_1 = bit2[22];
jjantoine 0:399c0fbd595c 452 Porta2_0 = bit2[23];
jjantoine 0:399c0fbd595c 453
jjantoine 0:399c0fbd595c 454 Porta3_7 = bit3[16];
jjantoine 0:399c0fbd595c 455 Porta3_6 = bit3[17];
jjantoine 0:399c0fbd595c 456 Porta3_5 = bit3[18];
jjantoine 0:399c0fbd595c 457 Porta3_4 = bit3[19];
jjantoine 0:399c0fbd595c 458 Porta3_3 = bit3[20];
jjantoine 0:399c0fbd595c 459 Porta3_2 = bit3[21];
jjantoine 0:399c0fbd595c 460 Porta3_1 = bit3[22];
jjantoine 0:399c0fbd595c 461 Porta3_0 = bit3[23];
jjantoine 0:399c0fbd595c 462
jjantoine 5:851e7afdc4fe 463 // wait(1);
jjantoine 5:851e7afdc4fe 464 // btts = 3;
jjantoine 5:851e7afdc4fe 465 //} else if (mybutton == 0 & btts == 3) {
jjantoine 0:399c0fbd595c 466
jjantoine 0:399c0fbd595c 467 Porta0_7 = bit0[24];
jjantoine 0:399c0fbd595c 468 Porta0_6 = bit0[25];
jjantoine 0:399c0fbd595c 469 Porta0_5 = bit0[26];
jjantoine 0:399c0fbd595c 470 Porta0_4 = bit0[27];
jjantoine 0:399c0fbd595c 471 Porta0_3 = bit0[28];
jjantoine 0:399c0fbd595c 472 Porta0_2 = bit0[29];
jjantoine 0:399c0fbd595c 473 Porta0_1 = bit0[30];
jjantoine 0:399c0fbd595c 474 Porta0_0 = bit0[31];
jjantoine 0:399c0fbd595c 475
jjantoine 0:399c0fbd595c 476 Porta1_7 = bit1[24];
jjantoine 0:399c0fbd595c 477 Porta1_6 = bit1[25];
jjantoine 0:399c0fbd595c 478 Porta1_5 = bit1[26];
jjantoine 0:399c0fbd595c 479 Porta1_4 = bit1[27];
jjantoine 0:399c0fbd595c 480 Porta1_3 = bit1[28];
jjantoine 0:399c0fbd595c 481 Porta1_2 = bit1[29];
jjantoine 0:399c0fbd595c 482 Porta1_1 = bit1[30];
jjantoine 0:399c0fbd595c 483 Porta1_0 = bit1[31];
jjantoine 0:399c0fbd595c 484
jjantoine 0:399c0fbd595c 485 Porta2_7 = bit2[24];
jjantoine 0:399c0fbd595c 486 Porta2_6 = bit2[25];
jjantoine 0:399c0fbd595c 487 Porta2_5 = bit2[26];
jjantoine 0:399c0fbd595c 488 Porta2_4 = bit2[27];
jjantoine 0:399c0fbd595c 489 Porta2_3 = bit2[28];
jjantoine 0:399c0fbd595c 490 Porta2_2 = bit2[29];
jjantoine 0:399c0fbd595c 491 Porta2_1 = bit2[30];
jjantoine 0:399c0fbd595c 492 Porta2_0 = bit2[31];
jjantoine 0:399c0fbd595c 493
jjantoine 0:399c0fbd595c 494 Porta3_7 = bit3[24];
jjantoine 0:399c0fbd595c 495 Porta3_6 = bit3[25];
jjantoine 0:399c0fbd595c 496 Porta3_5 = bit3[26];
jjantoine 0:399c0fbd595c 497 Porta3_4 = bit3[27];
jjantoine 0:399c0fbd595c 498 Porta3_3 = bit3[28];
jjantoine 0:399c0fbd595c 499 Porta3_2 = bit3[29];
jjantoine 0:399c0fbd595c 500 Porta3_1 = bit3[30];
jjantoine 0:399c0fbd595c 501 Porta3_0 = bit3[31];
jjantoine 0:399c0fbd595c 502
jjantoine 5:851e7afdc4fe 503 // wait(1);
jjantoine 5:851e7afdc4fe 504 // btts = 4;
jjantoine 5:851e7afdc4fe 505 //} else if (mybutton == 0 & btts == 4)
jjantoine 5:851e7afdc4fe 506 // {
jjantoine 5:851e7afdc4fe 507 // break;
jjantoine 5:851e7afdc4fe 508 // }
jjantoine 5:851e7afdc4fe 509 // }
jjantoine 0:399c0fbd595c 510
jjantoine 0:399c0fbd595c 511 }
jjantoine 0:399c0fbd595c 512
jjantoine 0:399c0fbd595c 513 int* charbit(char*c,char*d)
jjantoine 0:399c0fbd595c 514 {
jjantoine 0:399c0fbd595c 515 int msb1[32];
jjantoine 0:399c0fbd595c 516 int msb2[32];
jjantoine 0:399c0fbd595c 517 int msb3[32];
jjantoine 0:399c0fbd595c 518 int i;
jjantoine 0:399c0fbd595c 519 char a[4];
jjantoine 0:399c0fbd595c 520 char b[4];
jjantoine 0:399c0fbd595c 521
jjantoine 1:c578c87f2be7 522
jjantoine 1:c578c87f2be7 523 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 524 {
jjantoine 1:c578c87f2be7 525 a[i] = c[i];
jjantoine 1:c578c87f2be7 526 }
jjantoine 1:c578c87f2be7 527
jjantoine 1:c578c87f2be7 528 for(i=0;i<4;i++)
jjantoine 1:c578c87f2be7 529 {
jjantoine 1:c578c87f2be7 530 b[i] = d[i];
jjantoine 1:c578c87f2be7 531 }
jjantoine 0:399c0fbd595c 532
jjantoine 0:399c0fbd595c 533
jjantoine 0:399c0fbd595c 534 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 535 {
jjantoine 0:399c0fbd595c 536 msb1[i] = ( a[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 537 a[0]=a[0]<<1;
jjantoine 0:399c0fbd595c 538
jjantoine 0:399c0fbd595c 539 }
jjantoine 0:399c0fbd595c 540
jjantoine 0:399c0fbd595c 541 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 542 {
jjantoine 0:399c0fbd595c 543 msb1[i] = ( a[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 544 a[1]=a[1]<<1;
jjantoine 0:399c0fbd595c 545
jjantoine 0:399c0fbd595c 546 }
jjantoine 0:399c0fbd595c 547
jjantoine 0:399c0fbd595c 548 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 549 {
jjantoine 0:399c0fbd595c 550 msb1[i] = ( a[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 551 a[2]=a[2]<<1;
jjantoine 0:399c0fbd595c 552
jjantoine 0:399c0fbd595c 553 }
jjantoine 0:399c0fbd595c 554
jjantoine 0:399c0fbd595c 555 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 556 {
jjantoine 0:399c0fbd595c 557 msb1[i] = ( a[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 558 a[3]=a[3]<<1;
jjantoine 0:399c0fbd595c 559
jjantoine 0:399c0fbd595c 560 }
jjantoine 0:399c0fbd595c 561
jjantoine 0:399c0fbd595c 562 for (i=0;i<8;i++)
jjantoine 0:399c0fbd595c 563 {
jjantoine 0:399c0fbd595c 564 msb2[i] = ( b[0] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 565 b[0]=b[0]<<1;
jjantoine 0:399c0fbd595c 566
jjantoine 0:399c0fbd595c 567 }
jjantoine 0:399c0fbd595c 568
jjantoine 0:399c0fbd595c 569 for (i=8;i<16;i++)
jjantoine 0:399c0fbd595c 570 {
jjantoine 0:399c0fbd595c 571 msb2[i] = ( b[1] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 572 b[1]=b[1]<<1;
jjantoine 0:399c0fbd595c 573
jjantoine 0:399c0fbd595c 574 }
jjantoine 0:399c0fbd595c 575
jjantoine 0:399c0fbd595c 576 for (i=16;i<24;i++)
jjantoine 0:399c0fbd595c 577 {
jjantoine 0:399c0fbd595c 578 msb2[i] = ( b[2] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 579 b[2]=b[2]<<1;
jjantoine 0:399c0fbd595c 580
jjantoine 0:399c0fbd595c 581 }
jjantoine 0:399c0fbd595c 582
jjantoine 0:399c0fbd595c 583 for (i=24;i<32;i++)
jjantoine 0:399c0fbd595c 584 {
jjantoine 0:399c0fbd595c 585 msb2[i] = ( b[3] & 0x80 ) != 0x00;
jjantoine 0:399c0fbd595c 586 b[3]=b[3]<<1;
jjantoine 0:399c0fbd595c 587
jjantoine 0:399c0fbd595c 588 }
jjantoine 0:399c0fbd595c 589
jjantoine 0:399c0fbd595c 590 for (i=0;i<32;i++)
jjantoine 0:399c0fbd595c 591 {
jjantoine 0:399c0fbd595c 592 msb3[i] = msb1[i] & msb2[i];
jjantoine 0:399c0fbd595c 593 }
jjantoine 0:399c0fbd595c 594
jjantoine 0:399c0fbd595c 595 return &msb3[0];
jjantoine 5:851e7afdc4fe 596 }
jjantoine 5:851e7afdc4fe 597
jjantoine 5:851e7afdc4fe 598 void crc_cal()
jjantoine 5:851e7afdc4fe 599 {
jjantoine 5:851e7afdc4fe 600
jjantoine 5:851e7afdc4fe 601
jjantoine 5:851e7afdc4fe 602
jjantoine 5:851e7afdc4fe 603
jjantoine 5:851e7afdc4fe 604 _Crc32Table_TGP_DUT.UINT32_Poly = 0xE7994FEB;
jjantoine 5:851e7afdc4fe 605 _Crc32Table_TGP_DUT.UINT32_Init = 0xFFFFFFFF;
jjantoine 5:851e7afdc4fe 606 _Crc32Table_TGP_DUT.BOOL_RefIn = FALSE;
jjantoine 5:851e7afdc4fe 607 _Crc32Table_TGP_DUT.BOOL_RefOut = FALSE;
jjantoine 5:851e7afdc4fe 608 _Crc32Table_TGP_DUT.UINT32_XorOut = 0x00000000;
jjantoine 5:851e7afdc4fe 609
jjantoine 5:851e7afdc4fe 610 /* Inizializzazione della tabella */
jjantoine 5:851e7afdc4fe 611 ERROR_Value = CRC32BIT_LOOKUP_Init(&_Crc32Table_TGP_DUT);
jjantoine 5:851e7afdc4fe 612
jjantoine 5:851e7afdc4fe 613 crc = CRC32BIT_LOOKUP_Compute(vettore,11,&_Crc32Table_TGP_DUT);
jjantoine 5:851e7afdc4fe 614
jjantoine 5:851e7afdc4fe 615 crcchar[0] = (crc >> 24) & 0xFF;
jjantoine 5:851e7afdc4fe 616 crcchar[1] = (crc >> 16) & 0xFF;
jjantoine 5:851e7afdc4fe 617 crcchar[2] = (crc >> 8) & 0xFF;
jjantoine 5:851e7afdc4fe 618 crcchar[3] = crc & 0xFF;
jjantoine 5:851e7afdc4fe 619
jjantoine 0:399c0fbd595c 620 }