mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-22 09:37:59 +02:00
replaced old logger
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask, int convBit) {
|
||||
FILE_LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
||||
|
||||
// start point
|
||||
@ -18,7 +18,7 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
||||
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
||||
}
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
||||
|
||||
// needed for the slow adcs for apprx 10 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
if (convBit)
|
||||
@ -27,12 +27,12 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
||||
// chip sel bar down
|
||||
(*valw) &= ~csmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("chip sel bar down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("chip sel bar down. valw:0x%08x\n", *valw));
|
||||
}
|
||||
|
||||
|
||||
void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask, int convBit) {
|
||||
FILE_LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
||||
|
||||
// needed for the slow adcs for apprx 20 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
@ -42,7 +42,7 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
// chip sel bar up
|
||||
(*valw) |= csmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("chip sel bar up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("chip sel bar up. valw:0x%08x\n", *valw));
|
||||
|
||||
// needed for the slow adcs for apprx 10 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
if (convBit)
|
||||
@ -51,7 +51,7 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
//clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// stop point = start point of course
|
||||
(*valw) &= ~digoutmask;
|
||||
@ -62,11 +62,11 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
(*valw) |= csmask;
|
||||
}
|
||||
bus_w (addr, (*valw)); //FIXME: for ctb slow adcs, might need to set it to low again
|
||||
FILE_LOG(logDEBUG2, ("stop point. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("stop point. valw:0x%08x\n", *valw));
|
||||
}
|
||||
|
||||
void sendDataToSPI (uint32_t* valw, uint32_t addr, uint32_t val, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset) {
|
||||
FILE_LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x val:0x%x, numbitstosend:%d, clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x val:0x%x, numbitstosend:%d, clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
*valw, addr, val, numbitstosend, clkmask, digoutmask, digofset));
|
||||
|
||||
int i = 0;
|
||||
@ -75,23 +75,23 @@ void sendDataToSPI (uint32_t* valw, uint32_t addr, uint32_t val, int numbitstose
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// write data (i)
|
||||
(*valw) = (((*valw) & ~digoutmask) + // unset bit
|
||||
(((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("write data %d. valw:0x%08x\n", i, *valw));
|
||||
LOG(logDEBUG2, ("write data %d. valw:0x%08x\n", i, *valw));
|
||||
|
||||
// clk up
|
||||
(*valw) |= clkmask ;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive, uint32_t clkmask, uint32_t readaddr) {
|
||||
FILE_LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x numbitstoreceive:%d, clkmask:0x%x readaddr:0x%x \n",
|
||||
LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x numbitstoreceive:%d, clkmask:0x%x readaddr:0x%x \n",
|
||||
*valw, addr, numbitstoreceive, clkmask, readaddr));
|
||||
|
||||
uint32_t retval = 0;
|
||||
@ -102,18 +102,18 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// read data (i)
|
||||
retval |= ((bus_r(readaddr) & 0x1) << (numbitstoreceive - 1 - i));
|
||||
FILE_LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
||||
LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
||||
|
||||
usleep(20);
|
||||
|
||||
// clk up
|
||||
(*valw) |= clkmask ;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
|
||||
usleep(20);
|
||||
}
|
||||
@ -123,9 +123,9 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
||||
|
||||
void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset, int convBit) {
|
||||
if (numbitstosend == 16) {
|
||||
FILE_LOG(logDEBUG2, ("Writing to SPI Register: 0x%04x\n", val));
|
||||
LOG(logDEBUG2, ("Writing to SPI Register: 0x%04x\n", val));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("Writing to SPI Register: 0x%08x\n", val));
|
||||
LOG(logDEBUG2, ("Writing to SPI Register: 0x%08x\n", val));
|
||||
}
|
||||
uint32_t valw;
|
||||
|
||||
@ -148,9 +148,9 @@ uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive,
|
||||
//SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit); // moving this before bringin up earlier changes temp of slow adc
|
||||
|
||||
if (numbitstoreceive == 16) {
|
||||
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
||||
LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%08x\n", retval));
|
||||
LOG(logDEBUG2, ("Read From SPI Register: 0x%08x\n", retval));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
Reference in New Issue
Block a user