mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-02 14:44:55 +01:00
format slsdetectorservers .c
This commit is contained in:
32
slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c
Executable file → Normal file
32
slsDetectorServers/slsDetectorServer/src/ASIC_Driver.c
Executable file → Normal file
@@ -3,36 +3,36 @@
|
||||
#include "common.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spi/spidev.h>
|
||||
#include <linux/types.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// defines from the fpga
|
||||
char ASIC_Driver_DriverFileName[MAX_STR_LENGTH];
|
||||
|
||||
|
||||
void ASIC_Driver_SetDefines(char* driverfname) {
|
||||
void ASIC_Driver_SetDefines(char *driverfname) {
|
||||
LOG(logINFOBLUE, ("Configuring ASIC Driver to %s\n", driverfname));
|
||||
memset(ASIC_Driver_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(ASIC_Driver_DriverFileName, driverfname);
|
||||
}
|
||||
|
||||
int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
int ASIC_Driver_Set(int index, int length, char *buffer) {
|
||||
char temp[20];
|
||||
memset(temp, 0, sizeof(temp));
|
||||
sprintf(temp, "%d", index + 1);
|
||||
char fname[MAX_STR_LENGTH];
|
||||
strcpy(fname, ASIC_Driver_DriverFileName);
|
||||
strcat(fname, temp);
|
||||
LOG(logDEBUG2, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
LOG(logDEBUG2,
|
||||
("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
{
|
||||
LOG(logDEBUG2, ("\t[values: \n"));
|
||||
int i;
|
||||
@@ -41,19 +41,21 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
}
|
||||
LOG(logDEBUG2, ("\t]\n"));
|
||||
}
|
||||
|
||||
|
||||
#ifndef VIRTUAL
|
||||
int fd=open(fname, O_RDWR);
|
||||
int fd = open(fname, O_RDWR);
|
||||
if (fd == -1) {
|
||||
LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
||||
LOG(logERROR,
|
||||
("Could not open file %s for writing to control ASIC (%d)\n", fname,
|
||||
index));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
struct spi_ioc_transfer transfer;
|
||||
memset(&transfer, 0, sizeof(transfer));
|
||||
transfer.tx_buf = (unsigned long) buffer;
|
||||
transfer.tx_buf = (unsigned long)buffer;
|
||||
transfer.len = length;
|
||||
transfer.cs_change = 0;
|
||||
transfer.cs_change = 0;
|
||||
|
||||
// transfer command
|
||||
int status = ioctl(fd, SPI_IOC_MESSAGE(1), &transfer);
|
||||
@@ -65,6 +67,6 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
}
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user