Advertisement
dhirajjadhav

gpmctest

Jun 11th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.10 KB | None | 0 0
  1. /**************************************GPMC_TEST.c*************************************/
  2. //Author: Dhiraj Jadhav
  3. //Date: 06/05/2012
  4. //Description: this program configures the gpmc device for beaglebone for an synchronous burst read and //write operation.
  5. #include<stdio.h>
  6. #include<stdlib.h>
  7. #include<sys/types.h>
  8. #include<sys/io.h>
  9. #include<sys/mman.h>
  10. #include<fcntl.h>
  11. #define GPMC_START        0x50000000
  12. #define GPMC_MEM_START     0x00000000
  13.  
  14. #define GPMC_REVISION 0x00
  15. #define GPMC_SYSCONFIG 0x10
  16. #define GPMC_SYSSTATUS 0x14
  17. #define GPMC_IRQSTATUS 0x18
  18. #define GPMC_IRQENABLE 0x1C
  19. #define GPMC_TIMEOUT_CONTROL 0x40
  20. #define GPMC_ERR_ADDRESS  0x44
  21. #define GPMC_ERR_TY   0x48
  22. #define GPMC_CONFIG 0x50
  23. #define GPMC_STATUS 0x54
  24. #define GPMC_CONFIG1_i 0x60
  25. #define GPMC_CONFIG2_i 0x64
  26. #define GPMC_CONFIG3_i 0x68
  27. #define GPMC_CONFIG4_i 0x6C
  28. #define GPMC_CONFIG5_i 0x70
  29. #define GPMC_CONFIG6_i 0x74
  30. #define GPMC_CONFIG7_i 0x78
  31.  
  32.  
  33. int main(void)
  34. {    
  35. int result=0,loop=100;
  36. ulong *GPMC,*GPMC_MEM;
  37. int raw_fd = open("/dev/mem", O_RDWR | O_SYNC);
  38. GPMC = (ulong*) mmap(0,0xFFFF, PROT_READ | PROT_WRITE, MAP_SHARED,raw_fd,GPMC_START);
  39. GPMC_MEM = (ulong*) mmap(0,0xFFF, PROT_READ | PROT_WRITE, MAP_SHARED,raw_fd,GPMC_MEM_START);
  40. while(result==0)
  41. {
  42. loop=100;
  43. printf("\nGPMC_REVISION=0x%x", GPMC[GPMC_REVISION/4]);
  44. printf("\nGPMC_SYSCONFIG=0x%x", GPMC[GPMC_SYSCONFIG/4]);
  45.  
  46. printf("\nGPMC_SYSSTATUS =0x%x", GPMC[GPMC_SYSSTATUS/4]);
  47.  
  48. printf("\nGPMC_IRQSTATUS =0x%x", GPMC[GPMC_IRQSTATUS/4]);
  49.  
  50. printf("\nGPMC_IRQENABLE =0x%x", GPMC[GPMC_IRQENABLE/4]);
  51.  
  52.  
  53. printf("\nGPMC_ERR_ADDRESS =0x%x", GPMC[GPMC_ERR_ADDRESS/4]);
  54. printf("\nGPMC_ERR_TY =0x%x", GPMC[GPMC_ERR_TY/4]);
  55. printf("\nGPMC_CONFIG =0x%x", GPMC[GPMC_CONFIG/4]);
  56. printf("\nGPMC_STATUS =0x%x", GPMC[GPMC_STATUS/4]);
  57.  
  58. GPMC[GPMC_CONFIG1_i/4]=0x7A001203;
  59. printf("\nGPMC_CONFIG1_i =0x%x", GPMC[GPMC_CONFIG1_i/4]);
  60. GPMC[GPMC_CONFIG2_i/4]=0x00000B00;
  61. printf("\nGPMC_CONFIG2_i =0x%x", GPMC[GPMC_CONFIG2_i/4]);
  62. GPMC[GPMC_CONFIG3_i/4]=0x00000200;
  63. printf("\nGPMC_CONFIG3_i =0x%x", GPMC[GPMC_CONFIG3_i/4]);
  64. GPMC[GPMC_CONFIG4_i/4]=0x00000B03;
  65. printf("\nGPMC_CONFIG4_i =0x%x", GPMC[GPMC_CONFIG4_i/4]);
  66. GPMC[GPMC_CONFIG5_i/4]=0x0100000B0;
  67. printf("\nGPMC_CONFIG5_i =0x%x", GPMC[GPMC_CONFIG5_i/4]);
  68. GPMC[GPMC_CONFIG6_i/4]=0x00000000;
  69. printf("\nGPMC_CONFIG6_i =0x%x", GPMC[GPMC_CONFIG6_i/4]);
  70. GPMC[GPMC_CONFIG7_i/4]=0x00000F40;
  71. printf("\nGPMC_CONFIG7_i =0x%x", GPMC[GPMC_CONFIG7_i/4]);
  72.  
  73. GPMC_MEM[0x0/4]=0x7A000003;
  74. printf("\n GPMC read =0x%x", GPMC_MEM[0x0/4]);
  75. //printf("\n GPMC read =0x%x", GPMC_MEM[0x1]);
  76.  
  77. printf("\n continue reading 0:yes 1:no \n enteryour choice:");
  78. scanf("%d",&result);
  79. }
  80. close(raw_fd);
  81.  
  82. return(0);
  83. }
  84.  
  85.  
  86.  
  87. output:
  88.  
  89. root@beaglebone:/home/dhiraj# ./GPMC_test
  90.  
  91. GPMC_REVISION=0x60
  92. GPMC_SYSCONFIG=0x9
  93. GPMC_SYSSTATUS =0x1
  94. GPMC_IRQSTATUS =0x0
  95. GPMC_IRQENABLE =0x200
  96. GPMC_ERR_ADDRESS =0x0
  97. GPMC_ERR_TY =0x0
  98. GPMC_CONFIG =0x12
  99. GPMC_STATUS =0x101
  100. GPMC_CONFIG1_i =0x7a001203
  101. GPMC_CONFIG2_i =0xb00
  102. GPMC_CONFIG3_i =0x200
  103. GPMC_CONFIG4_i =0xb03
  104. GPMC_CONFIG5_i =0x10
  105. GPMC_CONFIG6_i =0x0
  106. Bus error
  107. root@beaglebone:/home/dhiraj#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement