EBST_CAM
|
All the low level platform specific implementations for interacting with the Stresing PCIe board. More...
#include "../Board_ll.h"
#include <stdint.h>
#include "../Board.h"
#include <process.h>
#include <io.h>
#include "../../version.h"
#include "../Direct2dViewer_c.h"
Macros | |
#define | LSCPCIEJ_STRESING_DRIVER_NAME "lscpciej" |
#define | DIV 1024 |
#define | WIDTH 7 |
Functions | |
es_status_codes | CleanupDma (uint32_t drvno) |
void | isr (uint32_t drvno) |
This interrupt routine copies data from the DMA buffer to the user buffer. If write to disk is true, the data is also written to disc. | |
void DLLCALLCONV | interrupt_handler0 () |
void DLLCALLCONV | interrupt_handler1 () |
void DLLCALLCONV | interrupt_handler2 () |
void DLLCALLCONV | interrupt_handler3 () |
void DLLCALLCONV | interrupt_handler4 () |
es_status_codes | readRegister_32 (uint32_t drvno, uint32_t *data, uint32_t address) |
Reads 4 bytes on DMA area. | |
es_status_codes | readRegister_16 (uint32_t drvno, uint16_t *data, uint32_t address) |
Reads long on DMA area. | |
es_status_codes | readRegister_8 (uint32_t drvno, uint8_t *data, uint32_t address) |
Read byte (8 bit) from register of PCIe board, except r10-r1f. | |
es_status_codes | writeRegister_32 (uint32_t drvno, uint32_t data, uint32_t address) |
Writes 32 bits (4 bytes) to register. | |
es_status_codes | writeRegister_16 (uint32_t drvno, uint16_t data, uint32_t address) |
Writes 16 bits (2 bytes) to register. | |
es_status_codes | writeRegister_8 (uint32_t drvno, uint8_t data, uint32_t address) |
Write byte (8 bit) to register in space0 of PCIe board, except r10-r1f. | |
es_status_codes | checkDriverHandle (uint32_t drvno) |
uint64_t | getPhysicalDmaAddress (uint32_t drvno) |
es_status_codes | SetupDma (uint32_t drvno) |
Allocate DMA buffer - should only be called once. | |
es_status_codes | enableInterrupt (uint32_t drvno) |
es_status_codes | disableInterrupt (uint32_t drvno) |
Disable interrupt. | |
void | ResetBufferWritePos (uint32_t drvno) |
Reset the buffer write pointers and software ISR counter. | |
void | copyRestData (uint32_t drvno, size_t rest_in_bytes) |
DMA copies in blocks of dmaBufferSizeInWords/DMA_BUFFER_PARTS - the rest is copied here. | |
es_status_codes | _InitBoard (uint32_t drvno) |
Initializes PCIe board on a platform specific way. | |
es_status_codes | _InitDriver () |
Windows specific function for initializing driver. | |
es_status_codes | CleanupDriver (uint32_t drvno) |
Cleanup driver. Call this before Exit driver. | |
es_status_codes | _ExitDriver () |
Exit driver. Call this after Cleanup driver. | |
es_status_codes | readConfig_32 (uint32_t drvno, uint32_t *data, uint32_t address) |
Read long (32 bit) from runtime register of PCIe board. | |
es_status_codes | writeConfig_32 (uint32_t drvno, uint32_t data, uint32_t address) |
Write long (32 bit) to register in space0 of PCIe board. | |
void | FreeMemInfo (uint64_t *pmemory_all, uint64_t *pmemory_free) |
Get the free and installed memory info. | |
es_status_codes | StartCopyDataToUserBufferThread (uint32_t drvno) |
es_status_codes | InitMutex (uint32_t drvno) |
void | initPerformanceCounter () |
int64_t | GetTimestampInTicks () |
Reads system timer. | |
int64_t | GetTimestampInMicroseconds () |
int64_t | GetTimestampInMilliseconds () |
int64_t | ConvertTicksToMicroseconds (int64_t ticks) |
Translate ticks to microseconds. | |
uint8_t | WaitforTelapsed (int64_t microseconds) |
This functions returns after a time given in microseconds. The time is measured in CPU ticks. The function is escapable by pressing ESC. | |
uint16_t | checkEscapeKeyState () |
uint16_t | checkSpaceKeyState () |
es_status_codes | SetPriority () |
Set thread to high priority level. | |
es_status_codes | ResetPriority () |
Reset thread priority to normal. | |
uint16_t * | getVirtualDmaAddress (uint32_t drvno) |
uint32_t | getDmaBufferSizeInBytes (uint32_t drvno) |
int64_t | getCurrentInterruptCounter (uint32_t drvno) |
es_status_codes | SaveMeasurementDataToFileBIN (const char *filename) |
Export the measurement data to a binary file. | |
es_status_codes | CopyFromFileToUserBufferBIN (const char *filename) |
void | openFile (uint32_t drvno) |
void | closeFile (uint32_t drvno) |
void | setTimestamp () |
void | writeFileHeaderToFile (uint32_t drvno) |
Creates a file at filename_full and writes struct file_header to it. | |
void | writeToDisc (uint32_t *drvno_ptr) |
void | startWriteToDiscThead (uint32_t drvno) |
void | VerifyData (struct verify_data_parameter *vd) |
Check a file for its data consistency. | |
void | getFileHeaderFromFile (struct file_header *fh, const char *filename_full) |
Open the file at filename_full and write the header to fh. | |
void | WaitForAllInterruptsDone () |
es_status_codes | About (uint32_t board_sel) |
Display information about registers and settings in pop up windows. | |
es_status_codes | AboutDrv (uint32_t drvno) |
Shows window with infos about the PCIe board. | |
es_status_codes | AboutGPX (uint32_t drvno) |
Reads registers 0 to 12 of TDC-GPX chip. Time delay counter option. | |
es_status_codes | AboutS0 (uint32_t drvno) |
Read registers of space0. Space0 are the control registers of the PCIe board. | |
es_status_codes | AboutTLPs (uint32_t drvno) |
es_status_codes | AboutPCI (uint32_t drvno) |
es_status_codes | AboutMeasurementSettings () |
es_status_codes | AboutCameraSettings (uint32_t drvno) |
void | ErrMsgBoxOn () |
Switch on error message boxes of our software. Default is On. | |
void | ErrMsgBoxOff () |
Disable error message boxes, if not needed. | |
void | ErrorMsg (char ErrMsg[100]) |
Display error message. If ErrMsgBoxOn is set. | |
void | ValMsg (uint64_t val) |
Simple display of unsigned integer as error message for test purpose. | |
void | Start2dViewer (uint32_t drvno, uint32_t block, uint16_t camera, uint16_t pixel, uint32_t nos) |
Start 2d viewer. | |
void | ShowNewBitmap (uint32_t drvno, uint32_t block, uint16_t camera, uint16_t pixel, uint32_t nos) |
Update the displayed bitmap. | |
void | Deinit2dViewer () |
Call when closing 2d viewer or at least before opening a new 2d viewer. | |
void | SetGammaValue (uint16_t white, uint16_t black) |
Set gamma value. | |
uint16_t | GetGammaWhite () |
return gamma value white | |
uint16_t | GetGammaBlack () |
return gamma value black | |
void | LockHighLevelMutex (uint32_t drvno) |
void | UnlockHighLevelMutex (uint32_t drvno) |
Variables | |
WDC_DEVICE_HANDLE | hDev_tmp [MAXPCIECARDS] |
WDC_DEVICE_HANDLE * | hDev = (WDC_DEVICE_HANDLE *)&hDev_tmp |
volatile DWORD | dmaBufferSizeInBytes [MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
uint16_t * | dmaBuffer [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
volatile uint64_t | IsrCounter [MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
volatile UINT8 | dmaBufferPartReadPos [MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
WD_DMA * | dmaBufferInfos [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
WDC_PCI_SCAN_RESULT | scanResult |
WD_PCI_CARD_INFO | deviceInfo [MAXPCIECARDS] |
bool | _SHOW_MSG = TRUE |
HANDLE | ghMutex [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
HANDLE | registerReadWriteMutex [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
HANDLE | registerReadWriteMutexHighLevel [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
HANDLE | mutexUserBuffer [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
FILE * | file_stream [MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
void * | Direct2dViewer = NULL |
uint16_t * | greyscale_data = NULL |
LARGE_INTEGER | freq |
void(* | interrupt_handler_array [MAXPCIECARDS])() = { &interrupt_handler0, &interrupt_handler1, &interrupt_handler2, &interrupt_handler3, &interrupt_handler4 } |
All the low level platform specific implementations for interacting with the Stresing PCIe board.
#define DIV 1024 |
#define LSCPCIEJ_STRESING_DRIVER_NAME "lscpciej" |
#define WIDTH 7 |
es_status_codes _ExitDriver | ( | ) |
Exit driver. Call this after Cleanup driver.
es_status_codes _InitBoard | ( | uint32_t | drvno | ) |
Initializes PCIe board on a platform specific way.
drvno | PCIe board identifier. |
es_status_codes _InitDriver | ( | ) |
Windows specific function for initializing driver.
es_status_codes About | ( | uint32_t | board_sel | ) |
Display information about registers and settings in pop up windows.
es_status_codes AboutCameraSettings | ( | uint32_t | drvno | ) |
es_status_codes AboutDrv | ( | uint32_t | drvno | ) |
Shows window with infos about the PCIe board.
drvno | board number (=1 if one PCI board) |
es_status_codes AboutGPX | ( | uint32_t | drvno | ) |
Reads registers 0 to 12 of TDC-GPX chip. Time delay counter option.
drvno | PCIe board identifier |
es_status_codes AboutMeasurementSettings | ( | ) |
es_status_codes AboutPCI | ( | uint32_t | drvno | ) |
drvno | PCIe board identifier. |
es_status_codes AboutS0 | ( | uint32_t | drvno | ) |
Read registers of space0. Space0 are the control registers of the PCIe board.
drvno | PCIe board identifier |
es_status_codes AboutTLPs | ( | uint32_t | drvno | ) |
drvno | PCIe board identifier. |
es_status_codes checkDriverHandle | ( | uint32_t | drvno | ) |
uint16_t checkEscapeKeyState | ( | ) |
uint16_t checkSpaceKeyState | ( | ) |
es_status_codes CleanupDma | ( | uint32_t | drvno | ) |
drvno | PCIe board identifier. |
es_status_codes CleanupDriver | ( | uint32_t | drvno | ) |
Cleanup driver. Call this before Exit driver.
drvno | PCIe board identifier. |
void closeFile | ( | uint32_t | drvno | ) |
int64_t ConvertTicksToMicroseconds | ( | int64_t | ticks | ) |
Translate ticks to microseconds.
ticks | ticks of system timer |
es_status_codes CopyFromFileToUserBufferBIN | ( | const char * | filename | ) |
void copyRestData | ( | uint32_t | drvno, |
size_t | rest_in_bytes ) |
DMA copies in blocks of dmaBufferSizeInWords/DMA_BUFFER_PARTS - the rest is copied here.
drvno | PCIe board identifier. |
rest_in_bytes | bytes which were not copied by INTR. |
void Deinit2dViewer | ( | ) |
Call when closing 2d viewer or at least before opening a new 2d viewer.
es_status_codes disableInterrupt | ( | uint32_t | drvno | ) |
es_status_codes enableInterrupt | ( | uint32_t | drvno | ) |
void ErrMsgBoxOff | ( | ) |
Disable error message boxes, if not needed.
void ErrMsgBoxOn | ( | ) |
Switch on error message boxes of our software. Default is On.
void ErrorMsg | ( | char | ErrMsg[100] | ) |
Display error message. If ErrMsgBoxOn is set.
[in] | ErrMsg | Message. Buffer size: 100. |
void FreeMemInfo | ( | uint64_t * | pmemory_all, |
uint64_t * | pmemory_free ) |
Get the free and installed memory info.
[out] | pmemory_all | how much is installed |
[out] | pmemory_free | how much is free |
int64_t getCurrentInterruptCounter | ( | uint32_t | drvno | ) |
uint32_t getDmaBufferSizeInBytes | ( | uint32_t | drvno | ) |
void getFileHeaderFromFile | ( | struct file_header * | fh, |
const char * | filename_full ) |
Open the file at filename_full and write the header to fh.
fh | struct file_header* |
filename_full | Path and file name to the file. |
uint16_t GetGammaBlack | ( | ) |
return gamma value black
uint16_t GetGammaWhite | ( | ) |
return gamma value white
uint64_t getPhysicalDmaAddress | ( | uint32_t | drvno | ) |
int64_t GetTimestampInMicroseconds | ( | ) |
int64_t GetTimestampInMilliseconds | ( | ) |
int64_t GetTimestampInTicks | ( | ) |
Reads system timer.
Read 2x ticks and calculate the difference between the calls in microseconds with DLLTickstous, init timer by calling DLLInitSysTimer before use.
uint16_t * getVirtualDmaAddress | ( | uint32_t | drvno | ) |
es_status_codes InitMutex | ( | uint32_t | drvno | ) |
void initPerformanceCounter | ( | ) |
void DLLCALLCONV interrupt_handler0 | ( | ) |
void DLLCALLCONV interrupt_handler1 | ( | ) |
void DLLCALLCONV interrupt_handler2 | ( | ) |
void DLLCALLCONV interrupt_handler3 | ( | ) |
void DLLCALLCONV interrupt_handler4 | ( | ) |
void isr | ( | uint32_t | drvno | ) |
This interrupt routine copies data from the DMA buffer to the user buffer. If write to disk is true, the data is also written to disc.
This routine is called every DMASPERINTR=500 scans. The size of a drivers contiguous memory is limited, so we must copy the data from a small buffer to a bigger buffer. The copy process is split in lower/upper half blocks.
drvno | PCIe board identifier. |
void LockHighLevelMutex | ( | uint32_t | drvno | ) |
void openFile | ( | uint32_t | drvno | ) |
es_status_codes readConfig_32 | ( | uint32_t | drvno, |
uint32_t * | data, | ||
uint32_t | address ) |
Read long (32 bit) from runtime register of PCIe board.
This function reads the memory mapped data , not the I/O Data. Reads data from PCIe config space.
drvno | board number (=1 if one PCI board) |
data | pointer to where data is stored |
address | offset of register (count in bytes) |
es_status_codes readRegister_16 | ( | uint32_t | drvno, |
uint16_t * | data, | ||
uint32_t | address ) |
Reads long on DMA area.
drvno | PCIe board identifier |
data | buffer for data |
address | Offset from BaseAdress - in Bytes ! 0..3= Regs of Board. |
es_status_codes readRegister_32 | ( | uint32_t | drvno, |
uint32_t * | data, | ||
uint32_t | address ) |
Reads 4 bytes on DMA area.
drvno | PCIe board identifier |
data | buffer for data |
address | Offset from BaseAdress - in Bytes ! 0..3= Regs of Board. |
es_status_codes readRegister_8 | ( | uint32_t | drvno, |
uint8_t * | data, | ||
uint32_t | address ) |
Read byte (8 bit) from register of PCIe board, except r10-r1f.
drvno | board number (=1 if one PCI board) |
data | pointer to where data is stored |
address | offset of register from base address (count in bytes) |
void ResetBufferWritePos | ( | uint32_t | drvno | ) |
Reset the buffer write pointers and software ISR counter.
drvno | PCIe board identifier. |
es_status_codes ResetPriority | ( | ) |
Reset thread priority to normal.
es_status_codes SaveMeasurementDataToFileBIN | ( | const char * | filename | ) |
Export the measurement data to a binary file.
filename | Filename with complete absolute path. |
void SetGammaValue | ( | uint16_t | white, |
uint16_t | black ) |
Set gamma value.
[in] | white | set value for maximum brightness. Default: 0xFFFF (16 bit), 0x3FFF (14 bit) |
[in] | black | set value for minimum brightness. Default: 0 |
es_status_codes SetPriority | ( | ) |
Set thread to high priority level.
void setTimestamp | ( | ) |
es_status_codes SetupDma | ( | uint32_t | drvno | ) |
Allocate DMA buffer - should only be called once.
Gets address of DMASubBuf from driver and copy it later to our pDMABigBuf.
drvno | PCIe board identifier. |
void ShowNewBitmap | ( | uint32_t | drvno, |
uint32_t | block, | ||
uint16_t | camera, | ||
uint16_t | pixel, | ||
uint32_t | nos ) |
Update the displayed bitmap.
[in] | drvno | board number |
[in] | block | current number of blocks |
[in] | camera | which camera to display (when camcnt is >1) |
[in] | pixel | count of pixel of one line |
[in] | nos | samples in one block |
void Start2dViewer | ( | uint32_t | drvno, |
uint32_t | block, | ||
uint16_t | camera, | ||
uint16_t | pixel, | ||
uint32_t | nos ) |
Start 2d viewer.
[in] | drvno | board number |
[in] | block | current number of block |
[in] | camera | which camera to display (when camcnt is >1) |
[in] | pixel | count of pixel of one line |
[in] | nos | samples in one block |
es_status_codes StartCopyDataToUserBufferThread | ( | uint32_t | drvno | ) |
void startWriteToDiscThead | ( | uint32_t | drvno | ) |
void UnlockHighLevelMutex | ( | uint32_t | drvno | ) |
void ValMsg | ( | uint64_t | val | ) |
Simple display of unsigned integer as error message for test purpose.
val | unsigned integer 64 bit |
void VerifyData | ( | struct verify_data_parameter * | vd | ) |
Check a file for its data consistency.
vd | see struct verify_data_parameter in globals.h for details |
void WaitForAllInterruptsDone | ( | ) |
uint8_t WaitforTelapsed | ( | int64_t | microseconds | ) |
This functions returns after a time given in microseconds. The time is measured in CPU ticks. The function is escapable by pressing ESC.
microseconds | Time to wait in microseconds. |
es_status_codes writeConfig_32 | ( | uint32_t | drvno, |
uint32_t | data, | ||
uint32_t | address ) |
Write long (32 bit) to register in space0 of PCIe board.
drvno | board number (=1 if one PCI board) |
data | long value to write |
address | offset from base address of register (count in bytes) |
void writeFileHeaderToFile | ( | uint32_t | drvno | ) |
Creates a file at filename_full and writes struct file_header to it.
drvno | PCIe board identifier. |
es_status_codes writeRegister_16 | ( | uint32_t | drvno, |
uint16_t | data, | ||
uint32_t | address ) |
Writes 16 bits (2 bytes) to register.
drvno | PCIe board identifier. |
data | data to write |
address | Register offset from BaseAdress - in bytes |
es_status_codes writeRegister_32 | ( | uint32_t | drvno, |
uint32_t | data, | ||
uint32_t | address ) |
Writes 32 bits (4 bytes) to register.
drvno | PCIe board identifier. |
data | data to write |
address | Register offset from BaseAdress - in bytes |
es_status_codes writeRegister_8 | ( | uint32_t | drvno, |
uint8_t | data, | ||
uint32_t | address ) |
Write byte (8 bit) to register in space0 of PCIe board, except r10-r1f.
drvno | board number (=1 if one PCI board) |
data | byte value to write |
address | Offset from BaseAdress of register (count in bytes) |
void writeToDisc | ( | uint32_t * | drvno_ptr | ) |
bool _SHOW_MSG = TRUE |
WD_PCI_CARD_INFO deviceInfo[MAXPCIECARDS] |
void* Direct2dViewer = NULL |
uint16_t* dmaBuffer[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
WD_DMA* dmaBufferInfos[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
volatile UINT8 dmaBufferPartReadPos[MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
volatile DWORD dmaBufferSizeInBytes[MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
FILE* file_stream[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
LARGE_INTEGER freq |
HANDLE ghMutex[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
uint16_t* greyscale_data = NULL |
WDC_DEVICE_HANDLE* hDev = (WDC_DEVICE_HANDLE *)&hDev_tmp |
WDC_DEVICE_HANDLE hDev_tmp[MAXPCIECARDS] |
void(* interrupt_handler_array[MAXPCIECARDS])() | ( | ) | = { &interrupt_handler0, &interrupt_handler1, &interrupt_handler2, &interrupt_handler3, &interrupt_handler4 } |
volatile uint64_t IsrCounter[MAXPCIECARDS] = { 0, 0, 0, 0, 0 } |
HANDLE mutexUserBuffer[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
HANDLE registerReadWriteMutex[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
HANDLE registerReadWriteMutexHighLevel[MAXPCIECARDS] = { NULL, NULL, NULL, NULL, NULL } |
WDC_PCI_SCAN_RESULT scanResult |