mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-16 06:47:14 +02:00
ctb server: removed unnecessary prints, resulting in a bug fix for slow adc temp
This commit is contained in:
@ -1,16 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "blackfin.h"
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask) {
|
||||
FILE_LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x\n",
|
||||
*valw, addr, csmask, clkmask, digoutmask));
|
||||
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",
|
||||
*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)
|
||||
if (convBit)
|
||||
usleep(20);
|
||||
|
||||
// start point
|
||||
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
||||
bus_w (addr, (*valw));
|
||||
FILE_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)
|
||||
usleep(10);
|
||||
|
||||
// chip sel bar down
|
||||
(*valw) &= ~csmask;
|
||||
bus_w (addr, (*valw));
|
||||
@ -19,14 +28,22 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
||||
|
||||
|
||||
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\n",
|
||||
*valw, addr, csmask, clkmask));
|
||||
FILE_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)
|
||||
if (convBit)
|
||||
usleep(20);
|
||||
|
||||
// chip sel bar up
|
||||
(*valw) |= csmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_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)
|
||||
usleep(10);
|
||||
|
||||
//clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
@ -34,6 +51,7 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
|
||||
// stop point = start point of course
|
||||
(*valw) &= ~digoutmask;
|
||||
// slow adcs use convBit (has to go high and then low) instead of csmask
|
||||
if (convBit) {
|
||||
(*valw) &= ~csmask;
|
||||
} else {
|
||||
@ -101,7 +119,7 @@ void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstos
|
||||
}
|
||||
uint32_t valw;
|
||||
|
||||
SPIChipSelect (&valw, addr, csmask, clkmask, digoutmask);
|
||||
SPIChipSelect (&valw, addr, csmask, clkmask, digoutmask, convBit);
|
||||
|
||||
sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
|
||||
|
||||
@ -112,7 +130,7 @@ uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive,
|
||||
|
||||
uint32_t valw;
|
||||
|
||||
SPIChipSelect (&valw, addr, csmask, clkmask, digoutmask);
|
||||
SPIChipSelect (&valw, addr, csmask, clkmask, digoutmask, convBit);
|
||||
|
||||
uint32_t retval = receiveDataFromSPI(&valw, addr, numbitstoreceive, clkmask, readaddr);
|
||||
|
||||
|
Reference in New Issue
Block a user