format slsdetectorservers .c

This commit is contained in:
2020-05-05 15:30:44 +02:00
parent 671cf45fd7
commit 7d94ad51ab
43 changed files with 20315 additions and 18726 deletions

36
slsDetectorServers/slsDetectorServer/src/MAX1932.c Executable file → Normal file
View File

@@ -1,19 +1,19 @@
#include "MAX1932.h"
#include "commonServerFunctions.h" // blackfin.h, ansi.h
#include "blackfin.h"
#include "clogger.h"
#include "common.h"
#include "commonServerFunctions.h" // blackfin.h, ansi.h
#include "sls_detector_defs.h"
/* MAX1932 HV DEFINES */
#define MAX1932_HV_NUMBITS (8)
#define MAX1932_HV_DATA_OFST (0)
#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST)
#define MAX1932_HV_NUMBITS (8)
#define MAX1932_HV_DATA_OFST (0)
#define MAX1932_HV_DATA_MSK (0x000000FF << MAX1932_HV_DATA_OFST)
// higher voltage requires lower dac value, 0 is off
#define MAX1932_MIN_DAC_VAL (0xFF)
#define MAX1932_MAX_DAC_VAL (0x1)
#define MAX1932_POWER_OFF_DAC_VAL (0x0)
#define MAX1932_MIN_DAC_VAL (0xFF)
#define MAX1932_MAX_DAC_VAL (0x1)
#define MAX1932_POWER_OFF_DAC_VAL (0x0)
// defines from the fpga
uint32_t MAX1932_Reg = 0x0;
@@ -24,8 +24,8 @@ int MAX1932_DigOffset = 0x0;
int MAX1932_MinVoltage = 0;
int MAX1932_MaxVoltage = 0;
void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t dmsk, int dofst,
int minMV, int maxMV) {
void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk,
uint32_t dmsk, int dofst, int minMV, int maxMV) {
LOG(logINFOBLUE, ("Configuring High Voltage\n"));
MAX1932_Reg = reg;
MAX1932_CsMask = cmsk;
@@ -37,13 +37,11 @@ void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t d
}
void MAX1932_Disable() {
bus_w(MAX1932_Reg, (bus_r(MAX1932_Reg)
| MAX1932_CsMask
| MAX1932_ClkMask)
& ~(MAX1932_DigMask));
bus_w(MAX1932_Reg, (bus_r(MAX1932_Reg) | MAX1932_CsMask | MAX1932_ClkMask) &
~(MAX1932_DigMask));
}
int MAX1932_Set (int* val) {
int MAX1932_Set(int *val) {
LOG(logDEBUG1, ("Setting high voltage to %d\n", *val));
if (*val < 0)
return FAIL;
@@ -64,17 +62,13 @@ int MAX1932_Set (int* val) {
else {
// no failure in conversion as limits handled (range from 0x1 to 0xFF)
ConvertToDifferentRange(MAX1932_MinVoltage, MAX1932_MaxVoltage,
MAX1932_MIN_DAC_VAL, MAX1932_MAX_DAC_VAL,
*val, &dacvalue);
MAX1932_MIN_DAC_VAL, MAX1932_MAX_DAC_VAL, *val,
&dacvalue);
dacvalue &= MAX1932_HV_DATA_MSK;
}
LOG(logINFO, ("\t%dV (dacval %d)\n", *val, dacvalue));
serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS,
MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
return OK;
}