Advertisement
Guest User

cuckymccukcuck

a guest
Feb 24th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. /* ECE354 Lab 2
  2. *
  3. * Andrew LaMarche, alamarche@umass.edu, 29432708
  4. * Brandon Cross, bjcross@umass.edu, 27898706
  5. *
  6. */
  7. // #include "address_map_arm.h"
  8. #include <time.h>
  9.  
  10. #define KEY_BASE 0xFF200050
  11. #define VIDEO_IN_BASE 0xFF203060
  12. #define FPGA_ONCHIP_BASE 0xC8000000
  13. #define CHARACTER_BUFFER_BASE 0xC9000000
  14.  
  15. /* This program demonstrates the use of the D5M camera with the DE1-SoC Board
  16. * It performs the following:
  17. * 1. Capture one frame of video when any key is pressed.
  18. * 2. Display the captured frame when any key is pressed.
  19. */
  20. /* Note: Set the switches SW1 and SW2 to high and rest of the switches to low for correct exposure timing while compiling and the loading the program in the Altera Monitor program.
  21. */
  22.  
  23. void write_character(int x, int y, char c) {
  24. volatile char* buffer = (char *)(CHARACTER_BUFFER_BASE + (y << 7) + x);
  25. *buffer = c;
  26. }
  27.  
  28. void clear_screen() {
  29. int x, y;
  30. for (x = 0; x < 320; x++) {
  31. for (y = 0; y < 240; y++) {
  32. write_character(x,y,0);
  33. }
  34. }
  35. }
  36.  
  37.  
  38. int main(void) {
  39. volatile int * KEY_ptr = (int *) KEY_BASE;
  40. volatile int * Video_In_DMA_ptr = (int *) VIDEO_IN_BASE;
  41. volatile short * Video_Mem_ptr = (short *) FPGA_ONCHIP_BASE;
  42.  
  43. time_t curtime;
  44. struct tm *timeinfo;
  45.  
  46. time (&curtime);
  47. timeinfo = localtime (&curtime);
  48.  
  49. int x, y;
  50.  
  51. *(Video_In_DMA_ptr + 3) = 0x4; // Enable the video
  52.  
  53. while (1) {
  54. if (*KEY_ptr != 0) { // check if any KEY was pressed
  55. *(Video_In_DMA_ptr + 3) = 0x0; // Disable the video to capture one frame
  56. while (*KEY_ptr != 0); // wait for pushbutton KEY release
  57. break;
  58. }
  59. }
  60.  
  61. while (1) {
  62. if (*KEY_ptr != 0) { // check if any KEY was pressed
  63. break;
  64. }
  65. }
  66.  
  67. /* for (y = 0; y < 240; y++) {
  68. for (x = 0; x < 320; x++) {
  69. short temp2 = *(Video_Mem_ptr + (y << 9) + x);
  70. *(Video_Mem_ptr + (y << 9) + x) = temp2;
  71. }
  72. }*/
  73. char *time = "cucky mc. cuck cuck";
  74. x = 1;
  75. while (*time) {
  76. write_character(x, 59, *time);
  77. x++;
  78. time++;
  79. }
  80. clear_screen();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement