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