initial commit
This commit is contained in:
BIN
e-502_users_guide.pdf
Normal file
BIN
e-502_users_guide.pdf
Normal file
Binary file not shown.
BIN
e502_guide_extracted.txt
Normal file
BIN
e502_guide_extracted.txt
Normal file
Binary file not shown.
1040
gate_capture.cpp
Normal file
1040
gate_capture.cpp
Normal file
File diff suppressed because it is too large
Load Diff
68
gate_capture_wiring.md
Normal file
68
gate_capture_wiring.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# E-502 Wiring For `gate_capture.exe`
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
This program captures two differential analog signals on `E-502` while:
|
||||||
|
|
||||||
|
- `DI_SYN1` provides the external ADC clock
|
||||||
|
- `START_IN` provides the repeating gate
|
||||||
|
- data goes to the PC over the built-in `USB 2.0`
|
||||||
|
|
||||||
|
The program does not use any digital output.
|
||||||
|
|
||||||
|
## Analog Inputs
|
||||||
|
|
||||||
|
- `Signal 1 +` -> `X3`
|
||||||
|
- `Signal 1 -` -> `Y3`
|
||||||
|
- `Signal 2 +` -> `X4`
|
||||||
|
- `Signal 2 -` -> `Y4`
|
||||||
|
|
||||||
|
These pairs correspond to:
|
||||||
|
|
||||||
|
- `ch1:2` -> `X3-Y3`
|
||||||
|
- `ch2:3` -> `X4-Y4`
|
||||||
|
|
||||||
|
## Sync Inputs
|
||||||
|
|
||||||
|
- `2 MHz clock` from generator -> `DI_SYN1`
|
||||||
|
- `20 kHz gate` from generator -> `START_IN`
|
||||||
|
|
||||||
|
Behavior in software:
|
||||||
|
|
||||||
|
- every clock edge on `DI_SYN1` advances ADC sampling
|
||||||
|
- rising edge of `START_IN` starts a capture window
|
||||||
|
- falling edge of `START_IN` closes the current window
|
||||||
|
|
||||||
|
The stream itself starts immediately after `X502_StreamsStart()`. Windowing is done in software from the sampled state of `START_IN`.
|
||||||
|
|
||||||
|
## Ground
|
||||||
|
|
||||||
|
- generator common / reference ground -> `GND` of `E-502`
|
||||||
|
|
||||||
|
Even with differential analog channels, the sync inputs still need a valid common reference with the generator.
|
||||||
|
|
||||||
|
## USB
|
||||||
|
|
||||||
|
- `E-502 USB 2.0` -> PC
|
||||||
|
|
||||||
|
## ASCII Diagram
|
||||||
|
|
||||||
|
```text
|
||||||
|
Signal source #1 (+) --------------------------> E-502 X3
|
||||||
|
Signal source #1 (-) --------------------------> E-502 Y3
|
||||||
|
|
||||||
|
Signal source #2 (+) --------------------------> E-502 X4
|
||||||
|
Signal source #2 (-) --------------------------> E-502 Y4
|
||||||
|
|
||||||
|
2 MHz generator output ------------------------> E-502 DI_SYN1
|
||||||
|
20 kHz gate output ----------------------------> E-502 START_IN
|
||||||
|
Generator common / GND ------------------------> E-502 GND
|
||||||
|
|
||||||
|
E-502 USB 2.0 ---------------------------------> PC
|
||||||
|
```
|
||||||
|
|
||||||
|
## Recommended Run Command
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\gate_capture.exe clock:di_syn1_rise clock_hz:2000000 gate_hz:20000 windows:1000 csv:gate_capture.csv svg:gate_capture.svg
|
||||||
|
```
|
||||||
162
l502api.h
Normal file
162
l502api.h
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/***************************************************************************//**
|
||||||
|
@file l502api.h
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@date 11.03.2012
|
||||||
|
@author Borisov Alexey <borisov@lcard.ru>
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef L502_API_H
|
||||||
|
#define L502_API_H
|
||||||
|
|
||||||
|
#include "l502api_compat.h"
|
||||||
|
#include "x502api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@addtogroup func_open
|
||||||
|
@{
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||||
|
<20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD>.
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>), <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> #X502_GETDEVS_FLAGS_ONLY_NOT_OPENED.
|
||||||
|
|
||||||
|
@param[in] serials <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size*#X502_SERIAL_SIZE <20><><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NULL, <20><><EFBFBD><EFBFBD> size=0, <20> devcnt!=NULL, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[in] size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> serial. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> 0, <20><><EFBFBD><EFBFBD> serials=NULL
|
||||||
|
@param[in] flags <20><><EFBFBD><EFBFBD><EFBFBD> <20><> #t_x502_getdevs_flags, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[out] devcnt <20><><EFBFBD><EFBFBD> devcnt!=NULL, <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L502
|
||||||
|
(<28><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size).
|
||||||
|
@return <20><><EFBFBD><EFBFBD> <0 - <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> serials (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <= size)
|
||||||
|
*******************************************************************************/
|
||||||
|
X502_EXPORT(int32_t) L502_GetSerialList(char serials[][X502_SERIAL_SIZE], uint32_t size,
|
||||||
|
uint32_t flags, uint32_t *devcnt);
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502 <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502 <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
X502_Close() <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
(<28><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #X502_ERR_DEVICE_ACCESS_DENIED).
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#X502_ERR_DEVICE_NOT_FOUND. <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502, <20><>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> X502_Close().
|
||||||
|
|
||||||
|
@param[in] hnd <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[in] serial <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> NULL.
|
||||||
|
@return <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
*******************************************************************************/
|
||||||
|
X502_EXPORT(int32_t) L502_Open(t_x502_hnd hnd, const char *serial);
|
||||||
|
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@addtogroup func_devrec
|
||||||
|
@{
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L502
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502 <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
(<28><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>).
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> X502_FreeDevRecordList() (<28><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> L502_GetDevRecordsList() <20> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>).
|
||||||
|
|
||||||
|
@param[in] list <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> NULL, <20><><EFBFBD><EFBFBD> size=0, <20> devcnt!=NULL, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[in] size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> list. <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[in] flags <20><><EFBFBD><EFBFBD><EFBFBD> <20><> #t_x502_getdevs_flags, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[out] devcnt <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502 (<28><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> size).
|
||||||
|
@return <20><><EFBFBD><EFBFBD> <0 --- <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <= size).
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
X502_FreeDevRecordList() <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
******************************************************************************/
|
||||||
|
X502_EXPORT(int32_t) L502_GetDevRecordsList(t_x502_devrec *list, uint32_t size,
|
||||||
|
uint32_t flags, uint32_t *devcnt) ;
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@addtogroup func_misc
|
||||||
|
@{
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/**************************************************************************//**
|
||||||
|
@brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> L-502
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> 32-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0).
|
||||||
|
|
||||||
|
<20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> Windows <20><><EFBFBD>
|
||||||
|
<20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> modinfo <20> Linux.
|
||||||
|
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PCI/PCI-Express (L502)
|
||||||
|
|
||||||
|
@param[in] hnd <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
@param[out] ver 32-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
@return <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
*****************************************************************************/
|
||||||
|
X502_EXPORT(int32_t) L502_GetDriverVersion(t_x502_hnd hnd, uint32_t* ver);
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
1834
l502api_compat.h
Normal file
1834
l502api_compat.h
Normal file
File diff suppressed because it is too large
Load Diff
810
lcard_pstdint.h
Normal file
810
lcard_pstdint.h
Normal file
@ -0,0 +1,810 @@
|
|||||||
|
/* A portable stdint.h
|
||||||
|
****************************************************************************
|
||||||
|
* BSD License:
|
||||||
|
****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2005-2011 Paul Hsieh
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************
|
||||||
|
*
|
||||||
|
* Version 0.1.12
|
||||||
|
*
|
||||||
|
* The ANSI C standard committee, for the C99 standard, specified the
|
||||||
|
* inclusion of a new standard include file called stdint.h. This is
|
||||||
|
* a very useful and long desired include file which contains several
|
||||||
|
* very precise definitions for integer scalar types that is
|
||||||
|
* critically important for making portable several classes of
|
||||||
|
* applications including cryptography, hashing, variable length
|
||||||
|
* integer libraries and so on. But for most developers its likely
|
||||||
|
* useful just for programming sanity.
|
||||||
|
*
|
||||||
|
* The problem is that most compiler vendors have decided not to
|
||||||
|
* implement the C99 standard, and the next C++ language standard
|
||||||
|
* (which has a lot more mindshare these days) will be a long time in
|
||||||
|
* coming and its unknown whether or not it will include stdint.h or
|
||||||
|
* how much adoption it will have. Either way, it will be a long time
|
||||||
|
* before all compilers come with a stdint.h and it also does nothing
|
||||||
|
* for the extremely large number of compilers available today which
|
||||||
|
* do not include this file, or anything comparable to it.
|
||||||
|
*
|
||||||
|
* So that's what this file is all about. Its an attempt to build a
|
||||||
|
* single universal include file that works on as many platforms as
|
||||||
|
* possible to deliver what stdint.h is supposed to. A few things
|
||||||
|
* that should be noted about this file:
|
||||||
|
*
|
||||||
|
* 1) It is not guaranteed to be portable and/or present an identical
|
||||||
|
* interface on all platforms. The extreme variability of the
|
||||||
|
* ANSI C standard makes this an impossibility right from the
|
||||||
|
* very get go. Its really only meant to be useful for the vast
|
||||||
|
* majority of platforms that possess the capability of
|
||||||
|
* implementing usefully and precisely defined, standard sized
|
||||||
|
* integer scalars. Systems which are not intrinsically 2s
|
||||||
|
* complement may produce invalid constants.
|
||||||
|
*
|
||||||
|
* 2) There is an unavoidable use of non-reserved symbols.
|
||||||
|
*
|
||||||
|
* 3) Other standard include files are invoked.
|
||||||
|
*
|
||||||
|
* 4) This file may come in conflict with future platforms that do
|
||||||
|
* include stdint.h. The hope is that one or the other can be
|
||||||
|
* used with no real difference.
|
||||||
|
*
|
||||||
|
* 5) In the current verison, if your platform can't represent
|
||||||
|
* int32_t, int16_t and int8_t, it just dumps out with a compiler
|
||||||
|
* error.
|
||||||
|
*
|
||||||
|
* 6) 64 bit integers may or may not be defined. Test for their
|
||||||
|
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
|
||||||
|
* Note that this is different from the C99 specification which
|
||||||
|
* requires the existence of 64 bit support in the compiler. If
|
||||||
|
* this is not defined for your platform, yet it is capable of
|
||||||
|
* dealing with 64 bits then it is because this file has not yet
|
||||||
|
* been extended to cover all of your system's capabilities.
|
||||||
|
*
|
||||||
|
* 7) (u)intptr_t may or may not be defined. Test for its presence
|
||||||
|
* with the test: #ifdef PTRDIFF_MAX. If this is not defined
|
||||||
|
* for your platform, then it is because this file has not yet
|
||||||
|
* been extended to cover all of your system's capabilities, not
|
||||||
|
* because its optional.
|
||||||
|
*
|
||||||
|
* 8) The following might not been defined even if your platform is
|
||||||
|
* capable of defining it:
|
||||||
|
*
|
||||||
|
* WCHAR_MIN
|
||||||
|
* WCHAR_MAX
|
||||||
|
* (u)int64_t
|
||||||
|
* PTRDIFF_MIN
|
||||||
|
* PTRDIFF_MAX
|
||||||
|
* (u)intptr_t
|
||||||
|
*
|
||||||
|
* 9) The following have not been defined:
|
||||||
|
*
|
||||||
|
* WINT_MIN
|
||||||
|
* WINT_MAX
|
||||||
|
*
|
||||||
|
* 10) The criteria for defining (u)int_least(*)_t isn't clear,
|
||||||
|
* except for systems which don't have a type that precisely
|
||||||
|
* defined 8, 16, or 32 bit types (which this include file does
|
||||||
|
* not support anyways). Default definitions have been given.
|
||||||
|
*
|
||||||
|
* 11) The criteria for defining (u)int_fast(*)_t isn't something I
|
||||||
|
* would trust to any particular compiler vendor or the ANSI C
|
||||||
|
* committee. It is well known that "compatible systems" are
|
||||||
|
* commonly created that have very different performance
|
||||||
|
* characteristics from the systems they are compatible with,
|
||||||
|
* especially those whose vendors make both the compiler and the
|
||||||
|
* system. Default definitions have been given, but its strongly
|
||||||
|
* recommended that users never use these definitions for any
|
||||||
|
* reason (they do *NOT* deliver any serious guarantee of
|
||||||
|
* improved performance -- not in this file, nor any vendor's
|
||||||
|
* stdint.h).
|
||||||
|
*
|
||||||
|
* 12) The following macros:
|
||||||
|
*
|
||||||
|
* PRINTF_INTMAX_MODIFIER
|
||||||
|
* PRINTF_INT64_MODIFIER
|
||||||
|
* PRINTF_INT32_MODIFIER
|
||||||
|
* PRINTF_INT16_MODIFIER
|
||||||
|
* PRINTF_LEAST64_MODIFIER
|
||||||
|
* PRINTF_LEAST32_MODIFIER
|
||||||
|
* PRINTF_LEAST16_MODIFIER
|
||||||
|
* PRINTF_INTPTR_MODIFIER
|
||||||
|
*
|
||||||
|
* are strings which have been defined as the modifiers required
|
||||||
|
* for the "d", "u" and "x" printf formats to correctly output
|
||||||
|
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
|
||||||
|
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
|
||||||
|
* PRINTF_INTPTR_MODIFIER is not defined for some systems which
|
||||||
|
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not
|
||||||
|
* defined if INT64_MAX is not defined. These are an extension
|
||||||
|
* beyond what C99 specifies must be in stdint.h.
|
||||||
|
*
|
||||||
|
* In addition, the following macros are defined:
|
||||||
|
*
|
||||||
|
* PRINTF_INTMAX_HEX_WIDTH
|
||||||
|
* PRINTF_INT64_HEX_WIDTH
|
||||||
|
* PRINTF_INT32_HEX_WIDTH
|
||||||
|
* PRINTF_INT16_HEX_WIDTH
|
||||||
|
* PRINTF_INT8_HEX_WIDTH
|
||||||
|
* PRINTF_INTMAX_DEC_WIDTH
|
||||||
|
* PRINTF_INT64_DEC_WIDTH
|
||||||
|
* PRINTF_INT32_DEC_WIDTH
|
||||||
|
* PRINTF_INT16_DEC_WIDTH
|
||||||
|
* PRINTF_INT8_DEC_WIDTH
|
||||||
|
*
|
||||||
|
* Which specifies the maximum number of characters required to
|
||||||
|
* print the number of that type in either hexadecimal or decimal.
|
||||||
|
* These are an extension beyond what C99 specifies must be in
|
||||||
|
* stdint.h.
|
||||||
|
*
|
||||||
|
* Compilers tested (all with 0 warnings at their highest respective
|
||||||
|
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
|
||||||
|
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
|
||||||
|
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
|
||||||
|
*
|
||||||
|
* This file should be considered a work in progress. Suggestions for
|
||||||
|
* improvements, especially those which increase coverage are strongly
|
||||||
|
* encouraged.
|
||||||
|
*
|
||||||
|
* Acknowledgements
|
||||||
|
*
|
||||||
|
* The following people have made significant contributions to the
|
||||||
|
* development and testing of this file:
|
||||||
|
*
|
||||||
|
* Chris Howie
|
||||||
|
* John Steele Scott
|
||||||
|
* Dave Thorup
|
||||||
|
* John Dill
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LCARD_PSTDINT
|
||||||
|
#define LCARD_PSTDINT
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
|
||||||
|
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if ((defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
|
||||||
|
|| (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || (__WATCOMC__ >= 1250))) \
|
||||||
|
|| (defined(__GNUC__)) \
|
||||||
|
|| (defined (_MSC_VER) && (_MSC_VER >= 1600)) \
|
||||||
|
|| (defined (__BORLANDC__) && (__BORLANDC__ >= 0x560))) && !defined (_PSTDINT_H_INCLUDED)
|
||||||
|
#include <stdint.h>
|
||||||
|
#define _PSTDINT_H_INCLUDED
|
||||||
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
|
# define PRINTF_INT64_MODIFIER "ll"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER "l"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT16_MODIFIER
|
||||||
|
# define PRINTF_INT16_MODIFIER "h"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_MODIFIER
|
||||||
|
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT64_HEX_WIDTH
|
||||||
|
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT32_HEX_WIDTH
|
||||||
|
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT16_HEX_WIDTH
|
||||||
|
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT8_HEX_WIDTH
|
||||||
|
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT64_DEC_WIDTH
|
||||||
|
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT32_DEC_WIDTH
|
||||||
|
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT16_DEC_WIDTH
|
||||||
|
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INT8_DEC_WIDTH
|
||||||
|
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||||
|
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||||
|
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||||
|
# endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Something really weird is going on with Open Watcom. Just pull some of
|
||||||
|
* these duplicated definitions from Open Watcom's stdint.h file for now.
|
||||||
|
*/
|
||||||
|
|
||||||
|
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
|
||||||
|
# if !defined (INT64_C)
|
||||||
|
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT64_C)
|
||||||
|
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
|
||||||
|
# endif
|
||||||
|
# if !defined (INT32_C)
|
||||||
|
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT32_C)
|
||||||
|
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
|
||||||
|
# endif
|
||||||
|
# if !defined (INT16_C)
|
||||||
|
# define INT16_C(x) (x)
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT16_C)
|
||||||
|
# define UINT16_C(x) (x)
|
||||||
|
# endif
|
||||||
|
# if !defined (INT8_C)
|
||||||
|
# define INT8_C(x) (x)
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT8_C)
|
||||||
|
# define UINT8_C(x) (x)
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT64_MAX)
|
||||||
|
# define UINT64_MAX 18446744073709551615ULL
|
||||||
|
# endif
|
||||||
|
# if !defined (INT64_MAX)
|
||||||
|
# define INT64_MAX 9223372036854775807LL
|
||||||
|
# endif
|
||||||
|
# if !defined (UINT32_MAX)
|
||||||
|
# define UINT32_MAX 4294967295UL
|
||||||
|
# endif
|
||||||
|
# if !defined (INT32_MAX)
|
||||||
|
# define INT32_MAX 2147483647L
|
||||||
|
# endif
|
||||||
|
# if !defined (INTMAX_MAX)
|
||||||
|
# define INTMAX_MAX INT64_MAX
|
||||||
|
# endif
|
||||||
|
# if !defined (INTMAX_MIN)
|
||||||
|
# define INTMAX_MIN INT64_MIN
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _PSTDINT_H_INCLUDED
|
||||||
|
#define _PSTDINT_H_INCLUDED
|
||||||
|
|
||||||
|
#ifndef SIZE_MAX
|
||||||
|
# define SIZE_MAX (~(size_t)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deduce the type assignments from limits.h under the assumption that
|
||||||
|
* integer sizes in bits are powers of 2, and follow the ANSI
|
||||||
|
* definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UINT8_MAX
|
||||||
|
# define UINT8_MAX 0xff
|
||||||
|
#endif
|
||||||
|
#ifndef uint8_t
|
||||||
|
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
# define UINT8_C(v) ((uint8_t) v)
|
||||||
|
# else
|
||||||
|
# error "Platform not supported"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT8_MAX
|
||||||
|
# define INT8_MAX 0x7f
|
||||||
|
#endif
|
||||||
|
#ifndef INT8_MIN
|
||||||
|
# define INT8_MIN INT8_C(0x80)
|
||||||
|
#endif
|
||||||
|
#ifndef int8_t
|
||||||
|
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef signed char int8_t;
|
||||||
|
# define INT8_C(v) ((int8_t) v)
|
||||||
|
# else
|
||||||
|
# error "Platform not supported"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UINT16_MAX
|
||||||
|
# define UINT16_MAX 0xffff
|
||||||
|
#endif
|
||||||
|
#ifndef uint16_t
|
||||||
|
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef unsigned int uint16_t;
|
||||||
|
# ifndef PRINTF_INT16_MODIFIER
|
||||||
|
# define PRINTF_INT16_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
# define UINT16_C(v) ((uint16_t) (v))
|
||||||
|
#elif (USHRT_MAX == UINT16_MAX)
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
# define UINT16_C(v) ((uint16_t) (v))
|
||||||
|
# ifndef PRINTF_INT16_MODIFIER
|
||||||
|
# define PRINTF_INT16_MODIFIER "h"
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#error "Platform not supported"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT16_MAX
|
||||||
|
# define INT16_MAX 0x7fff
|
||||||
|
#endif
|
||||||
|
#ifndef INT16_MIN
|
||||||
|
# define INT16_MIN INT16_C(0x8000)
|
||||||
|
#endif
|
||||||
|
#ifndef int16_t
|
||||||
|
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef signed int int16_t;
|
||||||
|
# define INT16_C(v) ((int16_t) (v))
|
||||||
|
# ifndef PRINTF_INT16_MODIFIER
|
||||||
|
# define PRINTF_INT16_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
#elif (SHRT_MAX == INT16_MAX)
|
||||||
|
typedef signed short int16_t;
|
||||||
|
# define INT16_C(v) ((int16_t) (v))
|
||||||
|
# ifndef PRINTF_INT16_MODIFIER
|
||||||
|
# define PRINTF_INT16_MODIFIER "h"
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#error "Platform not supported"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UINT32_MAX
|
||||||
|
# define UINT32_MAX (0xffffffffUL)
|
||||||
|
#endif
|
||||||
|
#ifndef uint32_t
|
||||||
|
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef unsigned long uint32_t;
|
||||||
|
# define UINT32_C(v) v ## UL
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER "l"
|
||||||
|
# endif
|
||||||
|
#elif (UINT_MAX == UINT32_MAX)
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
# define UINT32_C(v) v ## U
|
||||||
|
#elif (USHRT_MAX == UINT32_MAX)
|
||||||
|
typedef unsigned short uint32_t;
|
||||||
|
# define UINT32_C(v) ((unsigned short) (v))
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#error "Platform not supported"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT32_MAX
|
||||||
|
# define INT32_MAX (0x7fffffffL)
|
||||||
|
#endif
|
||||||
|
#ifndef INT32_MIN
|
||||||
|
# define INT32_MIN INT32_C(0x80000000)
|
||||||
|
#endif
|
||||||
|
#ifndef int32_t
|
||||||
|
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
|
||||||
|
typedef signed long int32_t;
|
||||||
|
# define INT32_C(v) v ## L
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER "l"
|
||||||
|
# endif
|
||||||
|
#elif (INT_MAX == INT32_MAX)
|
||||||
|
typedef signed int int32_t;
|
||||||
|
# define INT32_C(v) v
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
#elif (SHRT_MAX == INT32_MAX)
|
||||||
|
typedef signed short int32_t;
|
||||||
|
# define INT32_C(v) ((short) (v))
|
||||||
|
# ifndef PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_INT32_MODIFIER ""
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#error "Platform not supported"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The macro stdint_int64_defined is temporarily used to record
|
||||||
|
* whether or not 64 integer support is available. It must be
|
||||||
|
* defined for any 64 integer extensions for new platforms that are
|
||||||
|
* added.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef stdint_int64_defined
|
||||||
|
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
|
||||||
|
# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
|
||||||
|
# define stdint_int64_defined
|
||||||
|
typedef long long int64_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
# define UINT64_C(v) v ## ULL
|
||||||
|
# define INT64_C(v) v ## LL
|
||||||
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
|
# define PRINTF_INT64_MODIFIER "ll"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined (stdint_int64_defined)
|
||||||
|
# if defined(__GNUC__)
|
||||||
|
# define stdint_int64_defined
|
||||||
|
__extension__ typedef long long int64_t;
|
||||||
|
__extension__ typedef unsigned long long uint64_t;
|
||||||
|
# define UINT64_C(v) v ## ULL
|
||||||
|
# define INT64_C(v) v ## LL
|
||||||
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
|
# define PRINTF_INT64_MODIFIER "ll"
|
||||||
|
# endif
|
||||||
|
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
|
||||||
|
# define stdint_int64_defined
|
||||||
|
typedef long long int64_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
# define UINT64_C(v) v ## ULL
|
||||||
|
# define INT64_C(v) v ## LL
|
||||||
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
|
# define PRINTF_INT64_MODIFIER "ll"
|
||||||
|
# endif
|
||||||
|
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
|
||||||
|
# define stdint_int64_defined
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
# define UINT64_C(v) v ## UI64
|
||||||
|
# define INT64_C(v) v ## I64
|
||||||
|
# ifndef PRINTF_INT64_MODIFIER
|
||||||
|
# define PRINTF_INT64_MODIFIER "I64"
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined (LONG_LONG_MAX) && defined (INT64_C)
|
||||||
|
# define LONG_LONG_MAX INT64_C (9223372036854775807)
|
||||||
|
#endif
|
||||||
|
#ifndef ULONG_LONG_MAX
|
||||||
|
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined (INT64_MAX) && defined (INT64_C)
|
||||||
|
# define INT64_MAX INT64_C (9223372036854775807)
|
||||||
|
#endif
|
||||||
|
#if !defined (INT64_MIN) && defined (INT64_C)
|
||||||
|
# define INT64_MIN INT64_C (-9223372036854775808)
|
||||||
|
#endif
|
||||||
|
#if !defined (UINT64_MAX) && defined (INT64_C)
|
||||||
|
# define UINT64_MAX UINT64_C (18446744073709551615)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Width of hexadecimal for number field.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PRINTF_INT64_HEX_WIDTH
|
||||||
|
# define PRINTF_INT64_HEX_WIDTH "16"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT32_HEX_WIDTH
|
||||||
|
# define PRINTF_INT32_HEX_WIDTH "8"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT16_HEX_WIDTH
|
||||||
|
# define PRINTF_INT16_HEX_WIDTH "4"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT8_HEX_WIDTH
|
||||||
|
# define PRINTF_INT8_HEX_WIDTH "2"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PRINTF_INT64_DEC_WIDTH
|
||||||
|
# define PRINTF_INT64_DEC_WIDTH "20"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT32_DEC_WIDTH
|
||||||
|
# define PRINTF_INT32_DEC_WIDTH "10"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT16_DEC_WIDTH
|
||||||
|
# define PRINTF_INT16_DEC_WIDTH "5"
|
||||||
|
#endif
|
||||||
|
#ifndef PRINTF_INT8_DEC_WIDTH
|
||||||
|
# define PRINTF_INT8_DEC_WIDTH "3"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ok, lets not worry about 128 bit integers for now. Moore's law says
|
||||||
|
* we don't need to worry about that until about 2040 at which point
|
||||||
|
* we'll have bigger things to worry about.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef stdint_int64_defined
|
||||||
|
typedef int64_t intmax_t;
|
||||||
|
typedef uint64_t uintmax_t;
|
||||||
|
# define INTMAX_MAX INT64_MAX
|
||||||
|
# define INTMAX_MIN INT64_MIN
|
||||||
|
# define UINTMAX_MAX UINT64_MAX
|
||||||
|
# define UINTMAX_C(v) UINT64_C(v)
|
||||||
|
# define INTMAX_C(v) INT64_C(v)
|
||||||
|
# ifndef PRINTF_INTMAX_MODIFIER
|
||||||
|
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||||
|
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||||
|
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
typedef int32_t intmax_t;
|
||||||
|
typedef uint32_t uintmax_t;
|
||||||
|
# define INTMAX_MAX INT32_MAX
|
||||||
|
# define UINTMAX_MAX UINT32_MAX
|
||||||
|
# define UINTMAX_C(v) UINT32_C(v)
|
||||||
|
# define INTMAX_C(v) INT32_C(v)
|
||||||
|
# ifndef PRINTF_INTMAX_MODIFIER
|
||||||
|
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_HEX_WIDTH
|
||||||
|
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
|
||||||
|
# endif
|
||||||
|
# ifndef PRINTF_INTMAX_DEC_WIDTH
|
||||||
|
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because this file currently only supports platforms which have
|
||||||
|
* precise powers of 2 as bit sizes for the default integers, the
|
||||||
|
* least definitions are all trivial. Its possible that a future
|
||||||
|
* version of this file could have different definitions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef stdint_least_defined
|
||||||
|
typedef int8_t int_least8_t;
|
||||||
|
typedef uint8_t uint_least8_t;
|
||||||
|
typedef int16_t int_least16_t;
|
||||||
|
typedef uint16_t uint_least16_t;
|
||||||
|
typedef int32_t int_least32_t;
|
||||||
|
typedef uint32_t uint_least32_t;
|
||||||
|
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
|
||||||
|
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
|
||||||
|
# define UINT_LEAST8_MAX UINT8_MAX
|
||||||
|
# define INT_LEAST8_MAX INT8_MAX
|
||||||
|
# define UINT_LEAST16_MAX UINT16_MAX
|
||||||
|
# define INT_LEAST16_MAX INT16_MAX
|
||||||
|
# define UINT_LEAST32_MAX UINT32_MAX
|
||||||
|
# define INT_LEAST32_MAX INT32_MAX
|
||||||
|
# define INT_LEAST8_MIN INT8_MIN
|
||||||
|
# define INT_LEAST16_MIN INT16_MIN
|
||||||
|
# define INT_LEAST32_MIN INT32_MIN
|
||||||
|
# ifdef stdint_int64_defined
|
||||||
|
typedef int64_t int_least64_t;
|
||||||
|
typedef uint64_t uint_least64_t;
|
||||||
|
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
|
||||||
|
# define UINT_LEAST64_MAX UINT64_MAX
|
||||||
|
# define INT_LEAST64_MAX INT64_MAX
|
||||||
|
# define INT_LEAST64_MIN INT64_MIN
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#undef stdint_least_defined
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The ANSI C committee pretending to know or specify anything about
|
||||||
|
* performance is the epitome of misguided arrogance. The mandate of
|
||||||
|
* this file is to *ONLY* ever support that absolute minimum
|
||||||
|
* definition of the fast integer types, for compatibility purposes.
|
||||||
|
* No extensions, and no attempt to suggest what may or may not be a
|
||||||
|
* faster integer type will ever be made in this file. Developers are
|
||||||
|
* warned to stay away from these types when using this or any other
|
||||||
|
* stdint.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int_least8_t int_fast8_t;
|
||||||
|
typedef uint_least8_t uint_fast8_t;
|
||||||
|
typedef int_least16_t int_fast16_t;
|
||||||
|
typedef uint_least16_t uint_fast16_t;
|
||||||
|
typedef int_least32_t int_fast32_t;
|
||||||
|
typedef uint_least32_t uint_fast32_t;
|
||||||
|
#define UINT_FAST8_MAX UINT_LEAST8_MAX
|
||||||
|
#define INT_FAST8_MAX INT_LEAST8_MAX
|
||||||
|
#define UINT_FAST16_MAX UINT_LEAST16_MAX
|
||||||
|
#define INT_FAST16_MAX INT_LEAST16_MAX
|
||||||
|
#define UINT_FAST32_MAX UINT_LEAST32_MAX
|
||||||
|
#define INT_FAST32_MAX INT_LEAST32_MAX
|
||||||
|
#define INT_FAST8_MIN INT_LEAST8_MIN
|
||||||
|
#define INT_FAST16_MIN INT_LEAST16_MIN
|
||||||
|
#define INT_FAST32_MIN INT_LEAST32_MIN
|
||||||
|
#ifdef stdint_int64_defined
|
||||||
|
typedef int_least64_t int_fast64_t;
|
||||||
|
typedef uint_least64_t uint_fast64_t;
|
||||||
|
# define UINT_FAST64_MAX UINT_LEAST64_MAX
|
||||||
|
# define INT_FAST64_MAX INT_LEAST64_MAX
|
||||||
|
# define INT_FAST64_MIN INT_LEAST64_MIN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef stdint_int64_defined
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Whatever piecemeal, per compiler thing we can do about the wchar_t
|
||||||
|
* type limits.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
|
||||||
|
# include <wchar.h>
|
||||||
|
# ifndef WCHAR_MIN
|
||||||
|
# define WCHAR_MIN 0
|
||||||
|
# endif
|
||||||
|
# ifndef WCHAR_MAX
|
||||||
|
# define WCHAR_MAX ((wchar_t)-1)
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Whatever piecemeal, per compiler/platform thing we can do about the
|
||||||
|
* (u)intptr_t types and limits.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
|
||||||
|
# define STDINT_H_UINTPTR_T_DEFINED
|
||||||
|
#elif defined (_CVI_)
|
||||||
|
# define STDINT_H_UINTPTR_T_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef STDINT_H_UINTPTR_T_DEFINED
|
||||||
|
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
|
||||||
|
# define stdint_intptr_bits 64
|
||||||
|
# elif defined (__WATCOMC__) || defined (__TURBOC__)
|
||||||
|
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
|
||||||
|
# define stdint_intptr_bits 16
|
||||||
|
# else
|
||||||
|
# define stdint_intptr_bits 32
|
||||||
|
# endif
|
||||||
|
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
|
||||||
|
# define stdint_intptr_bits 32
|
||||||
|
# elif defined (__INTEL_COMPILER)
|
||||||
|
/* TODO -- what did Intel do about x86-64? */
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef stdint_intptr_bits
|
||||||
|
# define stdint_intptr_glue3_i(a,b,c) a##b##c
|
||||||
|
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
|
||||||
|
# ifndef PRINTF_INTPTR_MODIFIER
|
||||||
|
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
|
||||||
|
# endif
|
||||||
|
# ifndef PTRDIFF_MAX
|
||||||
|
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||||
|
# endif
|
||||||
|
# ifndef PTRDIFF_MIN
|
||||||
|
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||||
|
# endif
|
||||||
|
# ifndef UINTPTR_MAX
|
||||||
|
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
|
||||||
|
# endif
|
||||||
|
# ifndef INTPTR_MAX
|
||||||
|
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
|
||||||
|
# endif
|
||||||
|
# ifndef INTPTR_MIN
|
||||||
|
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
|
||||||
|
# endif
|
||||||
|
# ifndef INTPTR_C
|
||||||
|
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
|
||||||
|
# endif
|
||||||
|
# ifndef UINTPTR_C
|
||||||
|
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
|
||||||
|
# endif
|
||||||
|
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
|
||||||
|
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
|
||||||
|
# else
|
||||||
|
/* TODO -- This following is likely wrong for some platforms, and does
|
||||||
|
nothing for the definition of uintptr_t. */
|
||||||
|
typedef ptrdiff_t intptr_t;
|
||||||
|
# endif
|
||||||
|
# define STDINT_H_UINTPTR_T_DEFINED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assumes sig_atomic_t is signed and we have a 2s complement machine.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SIG_ATOMIC_MAX
|
||||||
|
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Please compile with the maximum warning settings to make sure macros are not
|
||||||
|
* defined more than once.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define glue3_aux(x,y,z) x ## y ## z
|
||||||
|
#define glue3(x,y,z) glue3_aux(x,y,z)
|
||||||
|
|
||||||
|
#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,=) glue3(UINT,bits,_C) (0);
|
||||||
|
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,=) glue3(INT,bits,_C) (0);
|
||||||
|
|
||||||
|
#define DECL(us,bits) glue3(DECL,us,) (bits)
|
||||||
|
|
||||||
|
#define TESTUMAX(bits) glue3(u,bits,=) glue3(~,u,bits); if (glue3(UINT,bits,_MAX) glue3(!=,u,bits)) printf ("Something wrong with UINT%d_MAX\n", bits)
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
DECL(I,8)
|
||||||
|
DECL(U,8)
|
||||||
|
DECL(I,16)
|
||||||
|
DECL(U,16)
|
||||||
|
DECL(I,32)
|
||||||
|
DECL(U,32)
|
||||||
|
#ifdef INT64_MAX
|
||||||
|
DECL(I,64)
|
||||||
|
DECL(U,64)
|
||||||
|
#endif
|
||||||
|
intmax_t imax = INTMAX_C(0);
|
||||||
|
uintmax_t umax = UINTMAX_C(0);
|
||||||
|
char str0[256], str1[256];
|
||||||
|
|
||||||
|
sprintf (str0, "%d %x\n", 0, ~0);
|
||||||
|
|
||||||
|
sprintf (str1, "%d %x\n", i8, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with i8 : %s\n", str1);
|
||||||
|
sprintf (str1, "%u %x\n", u8, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with u8 : %s\n", str1);
|
||||||
|
sprintf (str1, "%d %x\n", i16, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with i16 : %s\n", str1);
|
||||||
|
sprintf (str1, "%u %x\n", u16, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with u16 : %s\n", str1);
|
||||||
|
sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with i32 : %s\n", str1);
|
||||||
|
sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with u32 : %s\n", str1);
|
||||||
|
#ifdef INT64_MAX
|
||||||
|
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with i64 : %s\n", str1);
|
||||||
|
#endif
|
||||||
|
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with imax : %s\n", str1);
|
||||||
|
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
|
||||||
|
if (0 != strcmp (str0, str1)) printf ("Something wrong with umax : %s\n", str1);
|
||||||
|
|
||||||
|
TESTUMAX(8);
|
||||||
|
TESTUMAX(16);
|
||||||
|
TESTUMAX(32);
|
||||||
|
#ifdef INT64_MAX
|
||||||
|
TESTUMAX(64);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
422
main.c
Normal file
422
main.c
Normal file
@ -0,0 +1,422 @@
|
|||||||
|
/*
|
||||||
|
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||||
|
* <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> E16 / LTA37 / E502 / L502 (<28><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>).
|
||||||
|
*
|
||||||
|
* <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
||||||
|
* <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
|
||||||
|
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "l502api.h"
|
||||||
|
#include "e502api.h"
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "dev_funcs.h"
|
||||||
|
#include "timespec_funcs.h"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <signal.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define DEBUG
|
||||||
|
#ifdef DEBUG
|
||||||
|
#define dbg_printf(...) fprintf(stderr, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define dbg_printf(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
static volatile int f_out = 0;
|
||||||
|
|
||||||
|
#define DAC_BUF_SIZE (1024 * 1024)
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> (<28><>) */
|
||||||
|
#define SEND_TOUT 500
|
||||||
|
|
||||||
|
double dac_freq = 200000;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
double cycle_delay;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int cycle_mode = 1;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> Linux */
|
||||||
|
static void f_abort_handler(int sig) {
|
||||||
|
f_out = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int32_t f_setup_params(t_x502_hnd hnd) {
|
||||||
|
int32_t err;
|
||||||
|
|
||||||
|
X502_SetSyncMode(hnd, X502_SYNC_INTERNAL);
|
||||||
|
X502_StreamsStop(hnd);
|
||||||
|
X502_StreamsDisable(hnd, X502_STREAM_ALL_IN|X502_STREAM_ALL_OUT);
|
||||||
|
|
||||||
|
err = X502_SetOutFreq(hnd, &dac_freq);
|
||||||
|
if (err) {
|
||||||
|
fprintf(stderr, "X502_SetOutFreq err=%d dout_freq = %.1f\n", err, dac_freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
if (err == X502_ERR_OK) {
|
||||||
|
err = X502_Configure(hnd, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err == X502_ERR_OK) {
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
fprintf(stderr, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>: %0.0f Hz\n", dac_freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void parse_params(int argc, char **argv) {
|
||||||
|
for (int i = 1; (int)i < argc - 1; i++) {
|
||||||
|
if (sscanf(argv[i], "dac_freq:%lf", &dac_freq) == 1) {
|
||||||
|
fprintf(stderr, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>: %0.0f Hz\n", dac_freq);
|
||||||
|
} else
|
||||||
|
if (sscanf(argv[i], "cycle_delay:%lf", &cycle_delay) == 1) {
|
||||||
|
fprintf(stderr, "cycle_delay=%lf sec\n", cycle_delay);
|
||||||
|
} else
|
||||||
|
if (strcmp(argv[i], "once") == 0) {
|
||||||
|
cycle_mode = 0;
|
||||||
|
fprintf(stderr, "cycle_mode=0\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BUF_SIZE (64 * 1024)
|
||||||
|
|
||||||
|
#define CH_ENABLED 2
|
||||||
|
|
||||||
|
void show_help(char *name) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage: %s [dac_freq:500000] [cycle_delay:0.0001] [once] input.file\n"
|
||||||
|
"\tdac_freq: DAC freq in Hz\n"
|
||||||
|
"\tcycle_delay: delay DAC output in seconds before new cycle start\n"
|
||||||
|
"Select module by ip: %s [E16:192.168.0.1] [dac_freq:500000] [once] input.file\n"
|
||||||
|
"\nTest input file (2 DAC):\n"
|
||||||
|
"\t0.000000; -5.000000\n"
|
||||||
|
"\t1.000000; -4.000000\n"
|
||||||
|
"\t2.000000; -3.000000\n"
|
||||||
|
"\t3.000000; -2.000000\n"
|
||||||
|
"\t4.000000; -1.000000\n"
|
||||||
|
"\t5.000000; -0.000000\n"
|
||||||
|
"\t4.000000; -1.000000\n"
|
||||||
|
"\t3.000000; -2.000000\n"
|
||||||
|
"\t2.000000; -3.000000\n"
|
||||||
|
"\t1.000000; -4.000000\n"
|
||||||
|
, name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_dac_from_file(t_x502_hnd hnd, FILE* f);
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int32_t err = 0;
|
||||||
|
uint32_t ver;
|
||||||
|
t_x502_hnd hnd = NULL;
|
||||||
|
FILE* f;
|
||||||
|
#ifndef _WIN32
|
||||||
|
struct sigaction sa;
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
/* <20> <20><> Linux <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
sa.sa_handler = f_abort_handler;
|
||||||
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
sigaction(SIGABRT, &sa, NULL);
|
||||||
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> CP1251 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> OEM */
|
||||||
|
setlocale(LC_CTYPE, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (argc == 1) {
|
||||||
|
show_help(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ******************/
|
||||||
|
hnd = select_dev_from_list(argc, argv, 0);
|
||||||
|
|
||||||
|
if (hnd == NULL) {
|
||||||
|
fprintf(stderr, "Error! Device not found!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_params(argc, argv);
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
|
||||||
|
err = f_setup_params(hnd);
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************** <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> **************************/
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>), <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> L502_PrepareData */
|
||||||
|
err = X502_StreamsEnable(hnd, X502_STREAM_ALL_OUT);
|
||||||
|
if (err != X502_ERR_OK) {
|
||||||
|
fprintf(stderr, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (%d): %s!", err,
|
||||||
|
X502_GetErrorString(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fopen(argv[argc - 1], "rb");
|
||||||
|
if (!f) {
|
||||||
|
fprintf(stderr, "Could not open file '%s' error %d\n", argv[argc - 1], errno);
|
||||||
|
show_help(argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = out_dac_from_file(hnd, f);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
X502_Close(hnd);
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
X502_Free(hnd);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct timespec start_time;
|
||||||
|
static uint32_t* out_buf;
|
||||||
|
static int dac_size;
|
||||||
|
static double *dac_data[CH_ENABLED];
|
||||||
|
|
||||||
|
int send_data(t_x502_hnd hnd, uint32_t *send_ptr, uint32_t send_size) {
|
||||||
|
static int started = 0;
|
||||||
|
static uint32_t g_snd_cnt = 0;
|
||||||
|
struct timespec cur_time;
|
||||||
|
double spent_secs;
|
||||||
|
struct timespec spent_time;
|
||||||
|
|
||||||
|
while (send_size && !f_out) {
|
||||||
|
int32_t sent;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
if (_kbhit()) {
|
||||||
|
f_out = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sent = X502_Send(hnd, send_ptr, send_size, SEND_TOUT);
|
||||||
|
if (sent < 0) {
|
||||||
|
fprintf(stderr, "Errror: X502_Send ret = %d\n", sent);
|
||||||
|
return sent;
|
||||||
|
}
|
||||||
|
if (f_out) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
g_snd_cnt += sent;
|
||||||
|
send_size -= sent;
|
||||||
|
send_ptr += sent;
|
||||||
|
|
||||||
|
if (started == 0) {
|
||||||
|
int err;
|
||||||
|
|
||||||
|
started = 1;
|
||||||
|
err = X502_StreamsStart(hnd);
|
||||||
|
if (err) {
|
||||||
|
fprintf(stderr, "Error: X502_StreamsStart ret = %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &cur_time);
|
||||||
|
|
||||||
|
timespec_diff(&cur_time, &start_time, &spent_time);
|
||||||
|
spent_secs = timespec_to_double(&spent_time);
|
||||||
|
|
||||||
|
if (spent_secs > 5) {
|
||||||
|
fprintf(stderr, "snd speed=%f wrds/sec\n", (g_snd_cnt) / (spent_secs));
|
||||||
|
g_snd_cnt = 0;
|
||||||
|
start_time = cur_time;
|
||||||
|
}
|
||||||
|
return send_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int send_dac_data(t_x502_hnd hnd) {
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (dac_size != DAC_BUF_SIZE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (int i = 0; i < dac_size; i++){
|
||||||
|
fprintf(stderr, "[%d] %f; %f\n", i, dac_data[0][i], dac_data[1][i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// TODO: <20><><EFBFBD> LTA37 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PrepareData2()
|
||||||
|
err = X502_PrepareData(hnd,
|
||||||
|
dac_data[0],
|
||||||
|
dac_data[1],
|
||||||
|
NULL,
|
||||||
|
dac_size, X502_DAC_FLAGS_VOLT | X502_DAC_FLAGS_CALIBR,
|
||||||
|
out_buf);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
fprintf(stderr, "Error: X502_PrepareData ret = %d\n", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = send_data(hnd, out_buf, dac_size * CH_ENABLED);
|
||||||
|
|
||||||
|
dac_size = 0;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_dac_from_file(t_x502_hnd hnd, FILE* f) {
|
||||||
|
int32_t err;
|
||||||
|
char *buf;
|
||||||
|
int items_read;
|
||||||
|
double dac_val;
|
||||||
|
char *read_start;
|
||||||
|
int cntr = 0;
|
||||||
|
int dac_ch = 0;
|
||||||
|
bool newline = false;
|
||||||
|
bool comment_start = false;
|
||||||
|
bool data_added = false;
|
||||||
|
char *last_endptr;
|
||||||
|
double last_dac_data[CH_ENABLED];
|
||||||
|
|
||||||
|
for (int ch = 0; ch < CH_ENABLED; ch++) {
|
||||||
|
dac_data[ch] = (double*)malloc(sizeof(double) * DAC_BUF_SIZE);
|
||||||
|
if (!dac_data[ch]) {
|
||||||
|
fprintf(stderr, "Out of memory\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out_buf = (uint32_t*)malloc(sizeof(uint32_t) * DAC_BUF_SIZE * CH_ENABLED);
|
||||||
|
buf = (char*)malloc(BUF_SIZE);
|
||||||
|
if (!out_buf || !buf) {
|
||||||
|
fprintf(stderr, "Out of memory\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
read_start = buf;
|
||||||
|
last_endptr = &buf[BUF_SIZE];
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &start_time);
|
||||||
|
|
||||||
|
while (!f_out) {
|
||||||
|
size_t buf_ready = (read_start - buf);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
if (_kbhit()) {
|
||||||
|
f_out = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (feof(f) && cycle_mode) {
|
||||||
|
int delay_cntr = cycle_delay * dac_freq;
|
||||||
|
do {
|
||||||
|
for (; (dac_size != DAC_BUF_SIZE) && delay_cntr; dac_size++, delay_cntr--) {
|
||||||
|
for (int ch = 0; ch < CH_ENABLED; ch++) {
|
||||||
|
dac_data[ch][dac_size] = last_dac_data[ch];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((err = send_dac_data(hnd)) < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
} while(delay_cntr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (feof(f)) {
|
||||||
|
if (cycle_mode) {
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items_read = fread(read_start, 1, BUF_SIZE - buf_ready, f);
|
||||||
|
dbg_printf("read_start=::::%.*s::::\n", (int)buf_ready, buf);
|
||||||
|
dbg_printf("read=%d '''''%.*s'''''\n", items_read, items_read, read_start);
|
||||||
|
|
||||||
|
for (char *ptr = buf, *endptr = buf; ; ptr = endptr) {
|
||||||
|
char *buf_end = &buf[buf_ready + items_read];
|
||||||
|
|
||||||
|
dac_val = strtod(ptr, &endptr);
|
||||||
|
if (endptr >= buf_end) {
|
||||||
|
memmove(buf, last_endptr, buf_end - last_endptr);
|
||||||
|
read_start = buf + (buf_end - last_endptr);
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
if (endptr == ptr) {
|
||||||
|
endptr++;
|
||||||
|
if (*ptr == '\n') {
|
||||||
|
newline = true;
|
||||||
|
comment_start = false;
|
||||||
|
}
|
||||||
|
if (*ptr == '#') {
|
||||||
|
comment_start = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
last_endptr = endptr;
|
||||||
|
for (char *n_ptr = ptr; n_ptr < endptr; n_ptr++) {
|
||||||
|
if (*n_ptr == '\n') {
|
||||||
|
newline = true;
|
||||||
|
comment_start = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (comment_start) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (newline) {
|
||||||
|
dac_ch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dac_ch >= CH_ENABLED) {
|
||||||
|
fprintf(stderr, "dac_ch = %d >= %d (CH_ENABLED)\n", dac_ch, CH_ENABLED);
|
||||||
|
dac_ch %= CH_ENABLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newline && data_added) {
|
||||||
|
data_added = false;
|
||||||
|
dac_size++;
|
||||||
|
for (int ch = 0; ch < CH_ENABLED; ch++) {
|
||||||
|
dac_data[ch][dac_size] = dac_data[ch][dac_size - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data_added = true;
|
||||||
|
newline = false;
|
||||||
|
|
||||||
|
dbg_printf("dac_val=%lf cntr=%d\n", dac_val, cntr);
|
||||||
|
|
||||||
|
if ((err = send_dac_data(hnd)) < 0) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
dac_data[dac_ch][dac_size] = dac_val;
|
||||||
|
last_dac_data[dac_ch] = dac_val;
|
||||||
|
dac_ch++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
x502&e16api.pdf
Normal file
BIN
x502&e16api.pdf
Normal file
Binary file not shown.
347
x502_api_extracted.txt
Normal file
347
x502_api_extracted.txt
Normal file
File diff suppressed because one or more lines are too long
167
x502tstp.h
Normal file
167
x502tstp.h
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
#ifndef E502TSTP_H
|
||||||
|
#define E502TSTP_H
|
||||||
|
|
||||||
|
#include "x502api.h"
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @addtogroup tstpfunc_list Функции для работы с метками времени
|
||||||
|
@{ **/
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@addtogroup tstptype_list Константы и перечисления
|
||||||
|
@{
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
/** Тип данных для хранения времени
|
||||||
|
* Время хранится в секундах прошедшее с начала этой эпохи (00:00:00 UTC, 1 Января 1970 года)
|
||||||
|
* Дробный формат хранения 32.31: 32 целых бит, 31 дробных бит,
|
||||||
|
* старшие 32 бита - секунды, младшие 31 бит - доли секунды (SubSecond) = 1 / (1<<31) секунд
|
||||||
|
*/
|
||||||
|
typedef uint64_t t_x502_tstptime;
|
||||||
|
|
||||||
|
|
||||||
|
#define TSP_NSEC_PER_SEC (1000000000)
|
||||||
|
|
||||||
|
/** длина в битах для SubSecond в WRD1 слове метки времени */
|
||||||
|
#define TSP_WRD1_SSEC_LEN (24)
|
||||||
|
/** длина в битах для SubSecond в WRD2 слове метки времени */
|
||||||
|
#define TSP_WRD2_SSEC_LEN (7)
|
||||||
|
/** длина в битах для Second в WRD2 слове метки времени */
|
||||||
|
#define TSP_WRD2_SEC_LEN (19)
|
||||||
|
/** длина в битах для Second в WRD3 слове метки времени */
|
||||||
|
#define TSP_WRD3_SEC_LEN (13)
|
||||||
|
/** общая длина в битах для SubSecond в t_x502_tstptime (дробный формат 32.31) */
|
||||||
|
#define TSP_SSEC_WIDTH (TSP_WRD1_SSEC_LEN + TSP_WRD2_SSEC_LEN)
|
||||||
|
|
||||||
|
|
||||||
|
/** Номер слова с меткой времени 0..3 */
|
||||||
|
#define TSP_WRD_NUM(wrd) (((wrd) >> 26) & 3)
|
||||||
|
/** Счетчик преобразования АЦП в WRD0 слове с меткой времени */
|
||||||
|
#define TSP_WRD0_ADC_CLK_NUM_MASK (0x3ffffff)
|
||||||
|
|
||||||
|
/** Признак захвата времени от PTP сервера */
|
||||||
|
#define TSP_WRD1_LOCK_MASK (1 << 25)
|
||||||
|
|
||||||
|
/** Признак первой метки после перехода GO в активное состояние */
|
||||||
|
#define TSP_WRD1_FMARK_MASK (1 << 24)
|
||||||
|
/** битовая маска для SubSecond в WRD1 */
|
||||||
|
#define TSP_WRD1_SSEC_MASK ((1 << TSP_WRD1_SSEC_LEN) - 1)
|
||||||
|
/** битовая маска для Second в WRD2 */
|
||||||
|
#define TSP_WRD2_SEC_MASK (0x3ffff80)
|
||||||
|
/** битовая маска для SubSecond в WRD2 */
|
||||||
|
#define TSP_WRD2_SSEC_MASK ((1 << TSP_WRD2_SSEC_LEN) - 1)
|
||||||
|
/** битовая маска для Second + SubSecond в WRD2 */
|
||||||
|
#define TSP_WRD2_SECSSEC_MASK ((1 << (TSP_WRD2_SEC_LEN + TSP_WRD2_SSEC_LEN)) - 1)
|
||||||
|
/** битовая маска для Second в WRD3 */
|
||||||
|
#define TSP_WRD3_SEC_MASK ((1 << TSP_WRD3_SEC_LEN) - 1)
|
||||||
|
|
||||||
|
/** макрос для проверки выставлен ли признак первой метки для слова WRD1 */
|
||||||
|
#define TSP_WRD1_IS_FMARK(wrd) (!!((wrd) & TSP_WRD1_FMARK_MASK))
|
||||||
|
/** макрос для проверки выставлен ли признак lock для слова WRD1 */
|
||||||
|
#define TSP_WRD1_IS_LOCK(wrd) (!!((wrd) & TSP_WRD1_LOCK_MASK))
|
||||||
|
/** макрос для получения SubSecond из слова WRD1 */
|
||||||
|
#define TSP_WRD1_GET_SSEC(wrd) ((wrd) & TSP_WRD1_SSEC_MASK)
|
||||||
|
/** макрос для получения Second + SubSecond из слова WRD2 */
|
||||||
|
#define TSP_WRD2_GET_SECSSEC(wrd) ((uint64_t)((wrd) & TSP_WRD2_SECSSEC_MASK) << TSP_WRD1_SSEC_LEN)
|
||||||
|
/** макрос для получения SubSecond из слова WRD2 */
|
||||||
|
#define TSP_WRD2_GET_SSEC(wrd) ((wrd) & TSP_WRD2_SSEC_MASK)
|
||||||
|
/** макрос для получения Second из слова WRD3 */
|
||||||
|
#define TSP_WRD3_GET_SEC(wrd) ((uint64_t)((wrd) & TSP_WRD3_SEC_MASK) << (TSP_WRD1_SSEC_LEN + TSP_WRD2_SSEC_LEN + TSP_WRD2_SEC_LEN))
|
||||||
|
/** максимально возможное значение SubSecond */
|
||||||
|
#define SSEC_MAX (0x7fffffff)
|
||||||
|
/** перевод SubSecond в наносекунды */
|
||||||
|
#define TSTP_SSEC_TO_NSEC(time) (time > 0 ? ((uint32_t)((((double)((time) & SSEC_MAX)) / (1U << TSP_SSEC_WIDTH)) * TSP_NSEC_PER_SEC)) : ((uint32_t)((((double)((time*(-1)) & SSEC_MAX)) / (1U << TSP_SSEC_WIDTH)) * TSP_NSEC_PER_SEC)))
|
||||||
|
/** получение целых секунд из t_x502_tstptime */
|
||||||
|
#define TSTP_SECSSEC_TO_SEC(time) (time > 0 ? (uint32_t)((time) >> TSP_SSEC_WIDTH) : (uint32_t)((time * -1) >> TSP_SSEC_WIDTH))
|
||||||
|
/** перевод в секунды с плавающей запятой из t_x502_tstptime */
|
||||||
|
#define TSTP_SECSSEC_TO_SEC_DOUBLE(time) (((double)(time)) / (1U << TSP_SSEC_WIDTH))
|
||||||
|
/** перевод секунд в t_x502_tstptime */
|
||||||
|
#define TSTP_SEC_TO_SSEC(time) (((uint64_t)(time)) << TSP_SSEC_WIDTH)
|
||||||
|
|
||||||
|
/** Структура для хранения контекста при обработке потока слов "на ввод" с включенными метками времени */
|
||||||
|
typedef struct {
|
||||||
|
/** значение слов последней метки времени */
|
||||||
|
uint32_t wrd[4];
|
||||||
|
/** частота АЦП */
|
||||||
|
uint32_t adc_freq;
|
||||||
|
/** частота DIN */
|
||||||
|
uint32_t din_freq;
|
||||||
|
/** время первой метки времени */
|
||||||
|
t_x502_tstptime tstp_start_time;
|
||||||
|
/** признак, что первая метка времени получена */
|
||||||
|
bool tstp_mark_rcvd;
|
||||||
|
/** значение текущего обрабатываемого слова */
|
||||||
|
uint32_t cur_wrd;
|
||||||
|
/** кол-во обработанных слов из потока */
|
||||||
|
uint32_t processed_wrds;
|
||||||
|
/** кол-во слов АЦП после последней метки времени */
|
||||||
|
uint32_t adcwrds_after_tstp;
|
||||||
|
/** кол-во слов DIN после последней метки времени */
|
||||||
|
uint32_t dinwrds_after_tstp;
|
||||||
|
/** общее кол-во слов после последней метки времени */
|
||||||
|
uint32_t wrds_after_tstp;
|
||||||
|
/** время последней метки времени */
|
||||||
|
t_x502_tstptime last_tstp_time;
|
||||||
|
} t_x502_tstp_state;
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@addtogroup func_tstp Функции для работы с метками времени
|
||||||
|
@{
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************//**
|
||||||
|
@brief Инициализация tstp_state, в нем хранится текущий контекст для операций с метками времени из потока "на ввод"
|
||||||
|
|
||||||
|
Данная функция инициализирует структуру в которой хранится контекст для работы с метками времени
|
||||||
|
Необходимо указывать на частоту АЦП и DIN т.к. время для слов между двумя метками
|
||||||
|
будет считаться в зависимости от частоты.
|
||||||
|
|
||||||
|
@param[in] tstp_state Указатель на существующую струтуру t_x502_tstp_state
|
||||||
|
@param[in] adc_freq Частота АЦП
|
||||||
|
@param[in] din_freq Частота DIN
|
||||||
|
*******************************************************************************/
|
||||||
|
X502_EXPORT(void) X502_tstp_init(t_x502_tstp_state *tstp_state, uint32_t adc_freq, uint32_t din_freq);
|
||||||
|
|
||||||
|
/** @brief Обработать очередное слово wrd из потока "на ввод"
|
||||||
|
*
|
||||||
|
* Функция должна быть вызвана только один раз и последовательно для каждого слова полученного из X502_Recv
|
||||||
|
*
|
||||||
|
* @param[in] tstp_state Указатель на струтуру t_x502_tstp_state предварительно инициализированную через tstp_init()
|
||||||
|
* @param[in] wrd Слово из потока "на ввод"
|
||||||
|
*/
|
||||||
|
X502_EXPORT(void) X502_tstp_process_wrd(t_x502_tstp_state *tstp_state, uint32_t wrd);
|
||||||
|
|
||||||
|
/** @brief Узнать время текущего обработанного слова
|
||||||
|
*
|
||||||
|
* Узнать время текущего слова которое до этого было обработано функцией tstp_process_wrd()
|
||||||
|
* Формат времени: 32бита - секунды, 31 бит сабсекунды = 1 / (1<<31) секунд
|
||||||
|
*
|
||||||
|
* @param[in] tstp_state Указатель на струтуру t_x502_tstp_state предварительно инициализированную через tstp_init()
|
||||||
|
* @param[in] ret Указатель на t_x502_tstptime по которому будет сохранено расчитанное значение времени для текущего слова
|
||||||
|
*/
|
||||||
|
X502_EXPORT(void) X502_tstp_get_curwrd_time(t_x502_tstp_state *tstp_state, t_x502_tstptime *ret);
|
||||||
|
|
||||||
|
/** @brief Возвращает признак того что часы синхронизированы
|
||||||
|
*
|
||||||
|
* Возвращает признак "захват PTP" для текущего обработанного слова
|
||||||
|
*
|
||||||
|
* @param[in] tstp_state Указатель на струтуру t_x502_tstp_state предварительно инициализированную через tstp_init()
|
||||||
|
*
|
||||||
|
* @return true: присутствует признак "захват PTP" для текущего обработанного слова, false: признак "захват PTP" отсутствует
|
||||||
|
*/
|
||||||
|
X502_EXPORT(bool) X502_tstp_get_lock(t_x502_tstp_state *tstp_state);
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //E502TSTP_H
|
||||||
Reference in New Issue
Block a user