3 // extern unsigned long int fullRegister;
7 // not verbose by default
10 // not in debug mode by default
21 void Module::SetVerbosity (int input)
23 verbosityLevel = input;
26 void Module::SetVerbosity (bool input)
28 verbosityLevel = (input ? 1 : 0);
31 void Module::SetDebugMode (int input)
36 void Module::SetDebugMode (bool input)
38 debugLevel = (input ? 1 : 0);
43 int Module::_SetupAddress(unsigned long int blockBaseAddr, unsigned long int blockSize)
49 if ((m_mfd = open("/dev/mem", O_RDWR)) < 0)
51 return EXIT_FAILURE; // maybe return -1
53 regAddress = (unsigned long int*)mmap ( NULL,
61 if (regAddress == MAP_FAILED)
63 return EXIT_FAILURE; // maybe return -2
67 return EXIT_SUCCESS; // regAddress is now populated
70 void Module::_WriteReg(unsigned long int registerOffset, unsigned long int value)
72 if (verbosityLevel > 0) printf("Writing register 0x%08lx with data 0x%08lx \n", (regAddress + registerOffset), value);
74 *(regAddress + registerOffset) = value;
77 unsigned long int Module::_ReadReg(unsigned long int registerOffset)
79 unsigned long int value = 0x0;
81 value = *(regAddress + registerOffset);
83 if (verbosityLevel > 0) printf("Read register 0x%08lx, data: 0x%08lx \n", (regAddress + registerOffset), value);
85 // fullRegister = value;
90 // change the value of a single bit
91 void Module::_SetBit(unsigned long int ®Val, int bitNum, int value)
94 regVal |= (1 << bitNum);
97 regVal &= ~(1 << bitNum);
101 // regVal ^= (-value ^ regVal) & (1 << bitNum);
104 // find the value of a single bit
105 int Module::_GetBit(unsigned long int regVal, int bitNum)
109 // isolate the specific bit
110 value = ((regVal >> bitNum) & 0x1);