Changeset 9276
- Timestamp:
- 04/22/09 14:54:03 (4 years ago)
- Location:
- ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop
- Files:
-
- 1 added
- 3 modified
-
C_Makefile (added)
-
CostasLoop.cpp (modified) (2 diffs)
-
CostasLoopFPGAInterface.c (modified) (3 diffs)
-
CostasLoopFPGAInterface.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoop.cpp
r9265 r9276 125 125 CORBA::UShort I_in_0_length; 126 126 127 128 unsigned long i_data, q_data;129 unsigned long data;130 131 127 // open FPGA interface 132 128 openInterface(); … … 141 137 Q_out_0.length(I_in_0_length); //must define length of output 142 138 143 // get sample from FPGA 144 readFPGA(i_data,q_data); 139 openFPGAInterface(); 145 140 146 // write new data 147 writeFPGA(data); 141 // different methods for transmitting data: 142 // 1) push all data at once over bus into FIFOs on FPGA, and 143 // return all data at once from output FIFOs on FPGA 144 // 2) push data sample by sample to FPGA and recieve sample 145 // by sample 146 147 CostasLoopProcessing(); 148 149 closeFPGAInterface(); 148 150 149 151 dataIn_0->bufferEmptied(); -
ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoopFPGAInterface.c
r9264 r9276 5 5 #include <unistd.h> // using 'close' 6 6 #include <sys/mman.h> // using 'mmap', 'munmap' 7 #include <math.h> 7 8 8 9 #define TXDEMO_BASE_ADDRESS 0xc1a00000 9 10 #define TXDEMO_SLAVE_REG0OFF 0 10 #define TXDEMO_SLAVE_REG1OFF 411 #define TXDEMO_SLAVE_REG1OFF 12 11 12 #define TXDEMO_RESET_REG_OFF 64 12 13 … … 15 16 16 17 void *mapped_base, *mapped_dev_base; 18 unsigned long val; 19 unsigned int maskI = 0xFFFF0000; 20 unsigned int maskQ = 0x0000FFFF; 17 21 int memfd; 18 22 19 void open Interface()23 void openFPGAInterface() 20 24 { 21 // initalize interface to FPGA22 25 23 26 off_t dev_base = TXDEMO_BASE_ADDRESS; … … 42 45 } 43 46 44 void writeFPGA(unsigned long data)47 void CostasLoopProcessing() 45 48 { 46 // write to the FPGA interface 49 char command[10]; 50 while(1) 51 { 52 printf("Enter test/exit: "); 53 scanf("%s", command); 54 if( strcmp( command, "test" ) == 0 ) 55 { 56 // push zeros through to flush system 57 *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 58 *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 59 *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 60 *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 47 61 48 unsigned long val; 62 // perform reads to cycle through undefined bits 63 unsigned int i = 0; 64 for (i = 0; i < 20; i++) 65 { 66 // write zeros to circuit 67 *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = 0x00000000; 49 68 50 // perform write 51 *((unsigned long*)(mapped_dev_base + TXDEMO_SLAVE_REG1OFF)) = val; 69 // read from circuit 70 val = *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG0OFF)); 71 72 printf("Value off bus: #%x", val); 73 74 // get I and Q bits 75 signed long iside = maskI & val; 76 iside = (iside >> 16); 77 signed short qside = maskQ & val; 78 79 // convert from hex to decimal 80 int isideINT = iside; 81 int qsideINT = qside; 82 83 // scale 84 float isideFloat = isideINT / pow(2,15); 85 float qsideFloat = qsideINT / pow(2,15); 86 87 printf(" I: %1.3f", isideFloat); 88 printf(" Q: %1.3f\n", qsideFloat); 89 90 } 91 } 92 else if( strcmp( command, "exit" ) == 0 ) 93 { 94 break; 95 } 96 else 97 { 98 printf("Illegal command.\n"); 99 } 100 } 52 101 } 53 102 54 void readFPGA(unsigned long i_data, unsigned long q_data)103 void closeFPGAInterface() 55 104 { 56 // read from the FPGA interface57 58 unsigned long val;59 60 // perform read61 val = *((unsigned long *) (mapped_dev_base + TXDEMO_SLAVE_REG0OFF));62 }63 64 void closeInterface()65 {66 // close the interface67 105 68 106 if( munmap(mapped_base, MAP_SIZE) == -1 ) -
ossiedev/branches/mcarrick/ossiedev-trunk/components/CostasLoop/CostasLoopFPGAInterface.h
r9264 r9276 1 1 extern "C" { 2 void openInterface(); 3 void writeFPGA(unsigned long data); 4 void readFPGA(unsigned long i_data, unsigned long q_data); 5 void closeInterface(); 2 void openFPGAInterface(); 3 void CostasLoopProcessing(); 4 void closeFPGAInterface(); 6 5 } 7 6