Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | #include "jz_adc_peripheral.h" |
| 2 | #include "jz_fpga_init.h" |
| 3 | #include <stdio.h> |
| 4 | #include <unistd.h> |
| 5 | |
| 6 | extern "C" |
| 7 | { |
| 8 | #include "fbutils.h" |
| 9 | } |
| 10 | |
| 11 | |
| 12 | JZ_REG * FPGA_ADDR; |
| 13 | JZ_REG * ADCBuffer; |
| 14 | bool frameBufferOpened = 0; |
| 15 | bool firstLoop = 1; |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | void FB_Print_Line38 () |
| 21 | { |
| 22 | |
| 23 | if(1) |
| 24 | { |
| 25 | put_string_center (160,210,"By Juan64Bits", 1); |
| 26 | } |
| 27 | else |
| 28 | { |
| 29 | put_string (160,210,"By Juan64Bits", 1%5); |
| 30 | } |
| 31 | |
| 32 | } |
| 33 | |
| 34 | void FB_Print_Line37 () |
| 35 | { |
| 36 | |
| 37 | if(1) |
| 38 | { |
| 39 | put_string_center (160,200,"Segundo Semestre de 2010", 1); |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | put_string (160,200,"Segundo Semestre de 2010", 1%5); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |
| 48 | void FB_Print_Line36 () |
| 49 | { |
| 50 | |
| 51 | if(1) |
| 52 | { |
| 53 | put_string_center (160,190,"Universidad Nacional de Colombia", 1); |
| 54 | } |
| 55 | else |
| 56 | { |
| 57 | put_string (160,190,"Universidad Nacional de Colombia", 1%5); |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | void FB_Print_Line35 () |
| 63 | { |
| 64 | |
| 65 | if(0) |
| 66 | { |
| 67 | put_string_center (0,156,"CHA [7]", 4); |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | put_string (0,156,"CHA [7]", 4%5); |
| 72 | } |
| 73 | |
| 74 | } |
| 75 | |
| 76 | void FB_Print_Line10 () |
| 77 | { |
| 78 | |
| 79 | if(0) |
| 80 | { |
| 81 | put_string_center (0,16,"CHA [0]", 4); |
| 82 | } |
| 83 | else |
| 84 | { |
| 85 | put_string (0,16,"CHA [0]", 4%5); |
| 86 | } |
| 87 | |
| 88 | } |
| 89 | |
| 90 | void Constant_Bool1 ( bool &out_3) |
| 91 | { |
| 92 | |
| 93 | out_3=1; |
| 94 | |
| 95 | } |
| 96 | |
| 97 | void FB_Print_Line2 () |
| 98 | { |
| 99 | |
| 100 | if(1) |
| 101 | { |
| 102 | put_string_center (160,0,"Wellcome to SIE {Executing Code...}", 1); |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | put_string (160,0,"Wellcome to SIE {Executing Code...}", 1%5); |
| 107 | } |
| 108 | |
| 109 | } |
| 110 | |
| 111 | void ADC_Eight7 ( unsigned short int &out_8, unsigned short int &out_7, unsigned short int &out_6, unsigned short int &out_5, unsigned short int &out_4, unsigned short int &out_3, unsigned short int &out_2, unsigned short int &out_1) |
| 112 | { |
| 113 | |
| 114 | JZ_REG * ADC_DATA = ADCTakeSamples(ADCBuffer,0); |
| 115 | unsigned int sampleData = ADC_DATA[0]; |
| 116 | out_1 = (sampleData>>16)&0xFFFF; |
| 117 | out_2 = sampleData&0xFFFF; |
| 118 | sampleData = ADC_DATA[1]; |
| 119 | out_3 = (sampleData>>16)&0xFFFF; |
| 120 | out_4 = sampleData&0xFFFF; |
| 121 | sampleData = ADC_DATA[2]; |
| 122 | out_5 = (sampleData>>16)&0xFFFF; |
| 123 | out_6 = sampleData&0xFFFF; |
| 124 | sampleData = ADC_DATA[3]; |
| 125 | out_7 = (sampleData>>16)&0xFFFF; |
| 126 | out_8 = sampleData&0xFFFF; |
| 127 | |
| 128 | } |
| 129 | |
| 130 | void Right_Shift25 ( int in_0, int &out_1) |
| 131 | { |
| 132 | |
| 133 | out_1 = in_0 >> 2; |
| 134 | } |
| 135 | |
| 136 | void FB_Draw_HLine11 ( unsigned short int in_3) |
| 137 | { |
| 138 | if(!firstLoop) // do nothing in first loop |
| 139 | { |
| 140 | fillrect(64,96,64+255,96+16,0); //Black Rect |
| 141 | rect(64,96,64+255,96+16,3); //Extern Rect |
| 142 | fillrect(64,96,64+(in_3%(255+1)),96+16,3); |
| 143 | } |
| 144 | |
| 145 | } |
| 146 | |
| 147 | void FB_Put_Int18 ( int in_1) |
| 148 | { |
| 149 | |
| 150 | put_int(16,104,in_1,2); |
| 151 | |
| 152 | } |
| 153 | |
| 154 | void Right_Shift24 ( int in_0, int &out_1) |
| 155 | { |
| 156 | |
| 157 | out_1 = in_0 >> 2; |
| 158 | } |
| 159 | |
| 160 | void FB_Draw_HLine6 ( unsigned short int in_3) |
| 161 | { |
| 162 | if(!firstLoop) // do nothing in first loop |
| 163 | { |
| 164 | fillrect(64,76,64+255,76+16,0); //Black Rect |
| 165 | rect(64,76,64+255,76+16,3); //Extern Rect |
| 166 | fillrect(64,76,64+(in_3%(255+1)),76+16,3); |
| 167 | } |
| 168 | |
| 169 | } |
| 170 | |
| 171 | void FB_Put_Int17 ( int in_1) |
| 172 | { |
| 173 | |
| 174 | put_int(16,84,in_1,2); |
| 175 | |
| 176 | } |
| 177 | |
| 178 | void Right_Shift23 ( int in_0, int &out_1) |
| 179 | { |
| 180 | |
| 181 | out_1 = in_0 >> 2; |
| 182 | } |
| 183 | |
| 184 | void FB_Draw_HLine4 ( unsigned short int in_3) |
| 185 | { |
| 186 | if(!firstLoop) // do nothing in first loop |
| 187 | { |
| 188 | fillrect(64,56,64+255,56+16,0); //Black Rect |
| 189 | rect(64,56,64+255,56+16,3); //Extern Rect |
| 190 | fillrect(64,56,64+(in_3%(255+1)),56+16,3); |
| 191 | } |
| 192 | |
| 193 | } |
| 194 | |
| 195 | void FB_Put_Int16 ( int in_1) |
| 196 | { |
| 197 | |
| 198 | put_int(16,64,in_1,2); |
| 199 | |
| 200 | } |
| 201 | |
| 202 | void Right_Shift22 ( int in_0, int &out_1) |
| 203 | { |
| 204 | |
| 205 | out_1 = in_0 >> 2; |
| 206 | } |
| 207 | |
| 208 | void FB_Draw_HLine0 ( unsigned short int in_3) |
| 209 | { |
| 210 | if(!firstLoop) // do nothing in first loop |
| 211 | { |
| 212 | fillrect(64,36,64+255,36+16,0); //Black Rect |
| 213 | rect(64,36,64+255,36+16,3); //Extern Rect |
| 214 | fillrect(64,36,64+(in_3%(255+1)),36+16,3); |
| 215 | } |
| 216 | |
| 217 | } |
| 218 | |
| 219 | void FB_Put_Int15 ( int in_1) |
| 220 | { |
| 221 | |
| 222 | put_int(16,44,in_1,2); |
| 223 | |
| 224 | } |
| 225 | |
| 226 | void Right_Shift8 ( int in_0, int &out_1) |
| 227 | { |
| 228 | |
| 229 | out_1 = in_0 >> 2; |
| 230 | } |
| 231 | |
| 232 | void FB_Draw_HLine3 ( unsigned short int in_3) |
| 233 | { |
| 234 | if(!firstLoop) // do nothing in first loop |
| 235 | { |
| 236 | fillrect(64,16,64+255,16+16,0); //Black Rect |
| 237 | rect(64,16,64+255,16+16,3); //Extern Rect |
| 238 | fillrect(64,16,64+(in_3%(255+1)),16+16,3); |
| 239 | } |
| 240 | |
| 241 | } |
| 242 | |
| 243 | void FB_Put_Int9 ( int in_1) |
| 244 | { |
| 245 | |
| 246 | put_int(16,24,in_1,2); |
| 247 | |
| 248 | } |
| 249 | |
| 250 | void FB_Put_Int19 ( int in_1) |
| 251 | { |
| 252 | |
| 253 | put_int(16,124,in_1,2); |
| 254 | |
| 255 | } |
| 256 | |
| 257 | void Right_Shift26 ( int in_0, int &out_1) |
| 258 | { |
| 259 | |
| 260 | out_1 = in_0 >> 2; |
| 261 | } |
| 262 | |
| 263 | void FB_Draw_HLine12 ( unsigned short int in_3) |
| 264 | { |
| 265 | if(!firstLoop) // do nothing in first loop |
| 266 | { |
| 267 | fillrect(64,116,64+255,116+16,0); //Black Rect |
| 268 | rect(64,116,64+255,116+16,3); //Extern Rect |
| 269 | fillrect(64,116,64+(in_3%(255+1)),116+16,3); |
| 270 | } |
| 271 | |
| 272 | } |
| 273 | |
| 274 | void FB_Put_Int20 ( int in_1) |
| 275 | { |
| 276 | |
| 277 | put_int(16,144,in_1,2); |
| 278 | |
| 279 | } |
| 280 | |
| 281 | void Right_Shift27 ( int in_0, int &out_1) |
| 282 | { |
| 283 | |
| 284 | out_1 = in_0 >> 2; |
| 285 | } |
| 286 | |
| 287 | void FB_Draw_HLine13 ( unsigned short int in_3) |
| 288 | { |
| 289 | if(!firstLoop) // do nothing in first loop |
| 290 | { |
| 291 | fillrect(64,136,64+255,136+16,0); //Black Rect |
| 292 | rect(64,136,64+255,136+16,3); //Extern Rect |
| 293 | fillrect(64,136,64+(in_3%(255+1)),136+16,3); |
| 294 | } |
| 295 | |
| 296 | } |
| 297 | |
| 298 | void FB_Put_Int21 ( int in_1) |
| 299 | { |
| 300 | |
| 301 | put_int(16,164,in_1,2); |
| 302 | |
| 303 | } |
| 304 | |
| 305 | void Right_Shift28 ( int in_0, int &out_1) |
| 306 | { |
| 307 | |
| 308 | out_1 = in_0 >> 2; |
| 309 | } |
| 310 | |
| 311 | void FB_Draw_HLine14 ( unsigned short int in_3) |
| 312 | { |
| 313 | if(!firstLoop) // do nothing in first loop |
| 314 | { |
| 315 | fillrect(64,156,64+255,156+16,0); //Black Rect |
| 316 | rect(64,156,64+255,156+16,3); //Extern Rect |
| 317 | fillrect(64,156,64+(in_3%(255+1)),156+16,3); |
| 318 | } |
| 319 | |
| 320 | } |
| 321 | |
| 322 | void FB_Print_Line29 () |
| 323 | { |
| 324 | |
| 325 | if(0) |
| 326 | { |
| 327 | put_string_center (0,36,"CHA [1]", 4); |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | put_string (0,36,"CHA [1]", 4%5); |
| 332 | } |
| 333 | |
| 334 | } |
| 335 | |
| 336 | void FB_Print_Line30 () |
| 337 | { |
| 338 | |
| 339 | if(0) |
| 340 | { |
| 341 | put_string_center (0,56,"CHA [2]", 4); |
| 342 | } |
| 343 | else |
| 344 | { |
| 345 | put_string (0,56,"CHA [2]", 4%5); |
| 346 | } |
| 347 | |
| 348 | } |
| 349 | |
| 350 | void FB_Print_Line31 () |
| 351 | { |
| 352 | |
| 353 | if(0) |
| 354 | { |
| 355 | put_string_center (0,76,"CHA [3]", 4); |
| 356 | } |
| 357 | else |
| 358 | { |
| 359 | put_string (0,76,"CHA [3]", 4%5); |
| 360 | } |
| 361 | |
| 362 | } |
| 363 | |
| 364 | void FB_Print_Line32 () |
| 365 | { |
| 366 | |
| 367 | if(0) |
| 368 | { |
| 369 | put_string_center (0,96,"CHA [4]", 4); |
| 370 | } |
| 371 | else |
| 372 | { |
| 373 | put_string (0,96,"CHA [4]", 4%5); |
| 374 | } |
| 375 | |
| 376 | } |
| 377 | |
| 378 | void FB_Print_Line33 () |
| 379 | { |
| 380 | |
| 381 | if(0) |
| 382 | { |
| 383 | put_string_center (0,116,"CHA [5]", 4); |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | put_string (0,116,"CHA [5]", 4%5); |
| 388 | } |
| 389 | |
| 390 | } |
| 391 | |
| 392 | void FB_Print_Line34 () |
| 393 | { |
| 394 | |
| 395 | if(0) |
| 396 | { |
| 397 | put_string_center (0,136,"CHA [6]", 4); |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | put_string (0,136,"CHA [6]", 4%5); |
| 402 | } |
| 403 | |
| 404 | } |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | int main() |
| 410 | { |
| 411 | /* OPEN FRAME BUFFER */ |
| 412 | printf("Opening framebuffer...\n\n"); |
| 413 | |
| 414 | if (open_framebuffer()) { |
| 415 | close_framebuffer(); |
| 416 | printf("Could not open framebuffer!!\n\n"); |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | setColorsFromDefaultPallet(); |
| 421 | rect(0,0,xres,yres,0); //Extern Rect |
| 422 | } |
| 423 | |
| 424 | /* MAPING FPGA MEMORY */ |
| 425 | FPGA_ADDR=jz_cs2_init(); |
| 426 | ADCBuffer = FPGA_ADDR; |
| 427 | ADCTest(ADCBuffer); |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | |
| 443 | ADC_SPI_CLKDIV=255; |
| 444 | ADC_BUFFER_LEN=8; |
| 445 | ADC_MUX_CHANNELS=7; |
| 446 | |
| 447 | |
| 448 | |
| 449 | |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | //Inputs/Outputs: Block: <FB Print Line> with ID[38] |
| 461 | //Inputs/Outputs: Block: <FB Print Line> with ID[37] |
| 462 | //Inputs/Outputs: Block: <FB Print Line> with ID[36] |
| 463 | //Inputs/Outputs: Block: <FB Print Line> with ID[35] |
| 464 | //Inputs/Outputs: Block: <FB Print Line> with ID[10] |
| 465 | //Inputs/Outputs: Block: <Constant Bool> with ID[1] |
| 466 | bool out_3_1=0; |
| 467 | //Inputs/Outputs: Block: <System While> with ID[5] |
| 468 | bool in_6_5=0; |
| 469 | //Inputs/Outputs: Block: <FB Print Line> with ID[2] |
| 470 | //Inputs/Outputs: Block: <ADC Eight> with ID[7] |
| 471 | unsigned short int out_8_7=0; |
| 472 | unsigned short int out_7_7=0; |
| 473 | unsigned short int out_6_7=0; |
| 474 | unsigned short int out_5_7=0; |
| 475 | unsigned short int out_4_7=0; |
| 476 | unsigned short int out_3_7=0; |
| 477 | unsigned short int out_2_7=0; |
| 478 | unsigned short int out_1_7=0; |
| 479 | //Inputs/Outputs: Block: <Right Shift> with ID[25] |
| 480 | int in_0_25=0; |
| 481 | int out_1_25=0; |
| 482 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[11] |
| 483 | unsigned short int in_3_11=0; |
| 484 | //Inputs/Outputs: Block: <FB Put Int> with ID[18] |
| 485 | int in_1_18=0; |
| 486 | //Inputs/Outputs: Block: <Right Shift> with ID[24] |
| 487 | int in_0_24=0; |
| 488 | int out_1_24=0; |
| 489 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[6] |
| 490 | unsigned short int in_3_6=0; |
| 491 | //Inputs/Outputs: Block: <FB Put Int> with ID[17] |
| 492 | int in_1_17=0; |
| 493 | //Inputs/Outputs: Block: <Right Shift> with ID[23] |
| 494 | int in_0_23=0; |
| 495 | int out_1_23=0; |
| 496 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[4] |
| 497 | unsigned short int in_3_4=0; |
| 498 | //Inputs/Outputs: Block: <FB Put Int> with ID[16] |
| 499 | int in_1_16=0; |
| 500 | //Inputs/Outputs: Block: <Right Shift> with ID[22] |
| 501 | int in_0_22=0; |
| 502 | int out_1_22=0; |
| 503 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[0] |
| 504 | unsigned short int in_3_0=0; |
| 505 | //Inputs/Outputs: Block: <FB Put Int> with ID[15] |
| 506 | int in_1_15=0; |
| 507 | //Inputs/Outputs: Block: <Right Shift> with ID[8] |
| 508 | int in_0_8=0; |
| 509 | int out_1_8=0; |
| 510 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[3] |
| 511 | unsigned short int in_3_3=0; |
| 512 | //Inputs/Outputs: Block: <FB Put Int> with ID[9] |
| 513 | int in_1_9=0; |
| 514 | //Inputs/Outputs: Block: <FB Put Int> with ID[19] |
| 515 | int in_1_19=0; |
| 516 | //Inputs/Outputs: Block: <Right Shift> with ID[26] |
| 517 | int in_0_26=0; |
| 518 | int out_1_26=0; |
| 519 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[12] |
| 520 | unsigned short int in_3_12=0; |
| 521 | //Inputs/Outputs: Block: <FB Put Int> with ID[20] |
| 522 | int in_1_20=0; |
| 523 | //Inputs/Outputs: Block: <Right Shift> with ID[27] |
| 524 | int in_0_27=0; |
| 525 | int out_1_27=0; |
| 526 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[13] |
| 527 | unsigned short int in_3_13=0; |
| 528 | //Inputs/Outputs: Block: <FB Put Int> with ID[21] |
| 529 | int in_1_21=0; |
| 530 | //Inputs/Outputs: Block: <Right Shift> with ID[28] |
| 531 | int in_0_28=0; |
| 532 | int out_1_28=0; |
| 533 | //Inputs/Outputs: Block: <FB Draw HLine> with ID[14] |
| 534 | unsigned short int in_3_14=0; |
| 535 | //Inputs/Outputs: Block: <FB Print Line> with ID[29] |
| 536 | //Inputs/Outputs: Block: <FB Print Line> with ID[30] |
| 537 | //Inputs/Outputs: Block: <FB Print Line> with ID[31] |
| 538 | //Inputs/Outputs: Block: <FB Print Line> with ID[32] |
| 539 | //Inputs/Outputs: Block: <FB Print Line> with ID[33] |
| 540 | //Inputs/Outputs: Block: <FB Print Line> with ID[34] |
| 541 | |
| 542 | |
| 543 | |
| 544 | do |
| 545 | { |
| 546 | FB_Print_Line38 (); |
| 547 | FB_Print_Line37 (); |
| 548 | FB_Print_Line36 (); |
| 549 | FB_Print_Line35 (); |
| 550 | FB_Print_Line10 (); |
| 551 | Constant_Bool1 ( out_3_1); |
| 552 | in_6_5 = out_3_1; |
| 553 | FB_Print_Line2 (); |
| 554 | ADC_Eight7 ( out_8_7, out_7_7, out_6_7, out_5_7, out_4_7, out_3_7, out_2_7, out_1_7); |
| 555 | in_0_25 = out_5_7; |
| 556 | Right_Shift25 ( in_0_25, out_1_25); |
| 557 | in_3_11 = out_1_25; |
| 558 | FB_Draw_HLine11 ( in_3_11); |
| 559 | in_1_18 = out_5_7; |
| 560 | FB_Put_Int18 ( in_1_18); |
| 561 | in_0_24 = out_4_7; |
| 562 | Right_Shift24 ( in_0_24, out_1_24); |
| 563 | in_3_6 = out_1_24; |
| 564 | FB_Draw_HLine6 ( in_3_6); |
| 565 | in_1_17 = out_4_7; |
| 566 | FB_Put_Int17 ( in_1_17); |
| 567 | in_0_23 = out_3_7; |
| 568 | Right_Shift23 ( in_0_23, out_1_23); |
| 569 | in_3_4 = out_1_23; |
| 570 | FB_Draw_HLine4 ( in_3_4); |
| 571 | in_1_16 = out_3_7; |
| 572 | FB_Put_Int16 ( in_1_16); |
| 573 | in_0_22 = out_2_7; |
| 574 | Right_Shift22 ( in_0_22, out_1_22); |
| 575 | in_3_0 = out_1_22; |
| 576 | FB_Draw_HLine0 ( in_3_0); |
| 577 | in_1_15 = out_2_7; |
| 578 | FB_Put_Int15 ( in_1_15); |
| 579 | in_0_8 = out_1_7; |
| 580 | Right_Shift8 ( in_0_8, out_1_8); |
| 581 | in_3_3 = out_1_8; |
| 582 | FB_Draw_HLine3 ( in_3_3); |
| 583 | in_1_9 = out_1_7; |
| 584 | FB_Put_Int9 ( in_1_9); |
| 585 | in_1_19 = out_6_7; |
| 586 | FB_Put_Int19 ( in_1_19); |
| 587 | in_0_26 = out_6_7; |
| 588 | Right_Shift26 ( in_0_26, out_1_26); |
| 589 | in_3_12 = out_1_26; |
| 590 | FB_Draw_HLine12 ( in_3_12); |
| 591 | in_1_20 = out_7_7; |
| 592 | FB_Put_Int20 ( in_1_20); |
| 593 | in_0_27 = out_7_7; |
| 594 | Right_Shift27 ( in_0_27, out_1_27); |
| 595 | in_3_13 = out_1_27; |
| 596 | FB_Draw_HLine13 ( in_3_13); |
| 597 | in_1_21 = out_8_7; |
| 598 | FB_Put_Int21 ( in_1_21); |
| 599 | in_0_28 = out_8_7; |
| 600 | Right_Shift28 ( in_0_28, out_1_28); |
| 601 | in_3_14 = out_1_28; |
| 602 | FB_Draw_HLine14 ( in_3_14); |
| 603 | FB_Print_Line29 (); |
| 604 | FB_Print_Line30 (); |
| 605 | FB_Print_Line31 (); |
| 606 | FB_Print_Line32 (); |
| 607 | FB_Print_Line33 (); |
| 608 | FB_Print_Line34 (); |
| 609 | |
| 610 | firstLoop=0; |
| 611 | }while(in_6_5); |
| 612 | |
| 613 | return 0; |
| 614 | } |
| 615 | |
| 616 | |
| 617 |
Branches:
master
