Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**************************************GPMC_TEST.c*************************************/
- //Author: Dhiraj Jadhav
- //Date: 06/05/2012
- //Description: this program configures the gpmc device for beaglebone for an synchronous burst read and //write operation.
- #include<stdio.h>
- #include<stdlib.h>
- #include<sys/types.h>
- #include<sys/io.h>
- #include<sys/mman.h>
- #include<fcntl.h>
- #define GPMC_START 0x50000000
- #define GPMC_MEM_START 0x00000000
- #define GPMC_REVISION 0x00
- #define GPMC_SYSCONFIG 0x10
- #define GPMC_SYSSTATUS 0x14
- #define GPMC_IRQSTATUS 0x18
- #define GPMC_IRQENABLE 0x1C
- #define GPMC_TIMEOUT_CONTROL 0x40
- #define GPMC_ERR_ADDRESS 0x44
- #define GPMC_ERR_TY 0x48
- #define GPMC_CONFIG 0x50
- #define GPMC_STATUS 0x54
- #define GPMC_CONFIG1_i 0x60
- #define GPMC_CONFIG2_i 0x64
- #define GPMC_CONFIG3_i 0x68
- #define GPMC_CONFIG4_i 0x6C
- #define GPMC_CONFIG5_i 0x70
- #define GPMC_CONFIG6_i 0x74
- #define GPMC_CONFIG7_i 0x78
- int main(void)
- {
- int result=0,loop=100;
- ulong *GPMC,*GPMC_MEM;
- int raw_fd = open("/dev/mem", O_RDWR | O_SYNC);
- GPMC = (ulong*) mmap(0,0xFFFF, PROT_READ | PROT_WRITE, MAP_SHARED,raw_fd,GPMC_START);
- GPMC_MEM = (ulong*) mmap(0,0xFFF, PROT_READ | PROT_WRITE, MAP_SHARED,raw_fd,GPMC_MEM_START);
- while(result==0)
- {
- loop=100;
- printf("\nGPMC_REVISION=0x%x", GPMC[GPMC_REVISION/4]);
- printf("\nGPMC_SYSCONFIG=0x%x", GPMC[GPMC_SYSCONFIG/4]);
- printf("\nGPMC_SYSSTATUS =0x%x", GPMC[GPMC_SYSSTATUS/4]);
- printf("\nGPMC_IRQSTATUS =0x%x", GPMC[GPMC_IRQSTATUS/4]);
- printf("\nGPMC_IRQENABLE =0x%x", GPMC[GPMC_IRQENABLE/4]);
- printf("\nGPMC_ERR_ADDRESS =0x%x", GPMC[GPMC_ERR_ADDRESS/4]);
- printf("\nGPMC_ERR_TY =0x%x", GPMC[GPMC_ERR_TY/4]);
- printf("\nGPMC_CONFIG =0x%x", GPMC[GPMC_CONFIG/4]);
- printf("\nGPMC_STATUS =0x%x", GPMC[GPMC_STATUS/4]);
- GPMC[GPMC_CONFIG1_i/4]=0x7A001203;
- printf("\nGPMC_CONFIG1_i =0x%x", GPMC[GPMC_CONFIG1_i/4]);
- GPMC[GPMC_CONFIG2_i/4]=0x00000B00;
- printf("\nGPMC_CONFIG2_i =0x%x", GPMC[GPMC_CONFIG2_i/4]);
- GPMC[GPMC_CONFIG3_i/4]=0x00000200;
- printf("\nGPMC_CONFIG3_i =0x%x", GPMC[GPMC_CONFIG3_i/4]);
- GPMC[GPMC_CONFIG4_i/4]=0x00000B03;
- printf("\nGPMC_CONFIG4_i =0x%x", GPMC[GPMC_CONFIG4_i/4]);
- GPMC[GPMC_CONFIG5_i/4]=0x0100000B0;
- printf("\nGPMC_CONFIG5_i =0x%x", GPMC[GPMC_CONFIG5_i/4]);
- GPMC[GPMC_CONFIG6_i/4]=0x00000000;
- printf("\nGPMC_CONFIG6_i =0x%x", GPMC[GPMC_CONFIG6_i/4]);
- GPMC[GPMC_CONFIG7_i/4]=0x00000F40;
- printf("\nGPMC_CONFIG7_i =0x%x", GPMC[GPMC_CONFIG7_i/4]);
- GPMC_MEM[0x0/4]=0x7A000003;
- printf("\n GPMC read =0x%x", GPMC_MEM[0x0/4]);
- //printf("\n GPMC read =0x%x", GPMC_MEM[0x1]);
- printf("\n continue reading 0:yes 1:no \n enteryour choice:");
- scanf("%d",&result);
- }
- close(raw_fd);
- return(0);
- }
- output:
- root@beaglebone:/home/dhiraj# ./GPMC_test
- GPMC_REVISION=0x60
- GPMC_SYSCONFIG=0x9
- GPMC_SYSSTATUS =0x1
- GPMC_IRQSTATUS =0x0
- GPMC_IRQENABLE =0x200
- GPMC_ERR_ADDRESS =0x0
- GPMC_ERR_TY =0x0
- GPMC_CONFIG =0x12
- GPMC_STATUS =0x101
- GPMC_CONFIG1_i =0x7a001203
- GPMC_CONFIG2_i =0xb00
- GPMC_CONFIG3_i =0x200
- GPMC_CONFIG4_i =0xb03
- GPMC_CONFIG5_i =0x10
- GPMC_CONFIG6_i =0x0
- Bus error
- root@beaglebone:/home/dhiraj#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement