mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
set bit and clear bit only verifies that bit (#746)
This commit is contained in:
Binary file not shown.
@ -932,6 +932,59 @@ int readRegister(uint32_t offset, uint32_t *retval) {
|
||||
#endif
|
||||
}
|
||||
|
||||
int setBit(const uint32_t addr, const int nBit) {
|
||||
#ifndef VIRTUAL
|
||||
uint32_t regval = 0;
|
||||
if (readRegister(addr, ®val) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
uint32_t bitmask = (1 << nBit);
|
||||
uint32_t val = regval | bitmask;
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_WriteRegister_BitMask(addr, val, bitmask)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int clearBit(const uint32_t addr, const int nBit) {
|
||||
#ifndef VIRTUAL
|
||||
uint32_t regval = 0;
|
||||
if (readRegister(addr, ®val) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
uint32_t bitmask = (1 << nBit);
|
||||
uint32_t val = regval & ~bitmask;
|
||||
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_WriteRegister_BitMask(addr, val, bitmask)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getBit(const uint32_t addr, const int nBit, int *retval) {
|
||||
#ifndef VIRTUAL
|
||||
uint32_t regval = 0;
|
||||
uint32_t bitmask = (1 << nBit);
|
||||
sharedMemory_lockLocalLink();
|
||||
if (!Feb_Control_ReadRegister_BitMask(addr, ®val, bitmask)) {
|
||||
sharedMemory_unlockLocalLink();
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_unlockLocalLink();
|
||||
*retval = (regval >> nBit);
|
||||
#endif
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* set parameters - dr, roi */
|
||||
|
||||
int setDynamicRange(int dr) {
|
||||
|
Reference in New Issue
Block a user