#ifndef USBLISMPI26_H
#define USBLISMPI26_H

/*
 * USB LISM-PI26xx V2.0 - Qt/C++ import header
 *
 * Supported targets:
 *   Windows 32-bit : USBLISMPI2632.dll
 *   Windows 64-bit : USBLISMPI2664.dll
 *   Linux 32-bit / ARM32 : libusblismpi2632.so
 *   Linux 64-bit / x86_64 / AArch64 : libusblismpi2664.so
 *
 * This header uses Qt fixed-width integer types. The legacy API remains
 * platform-specific for compatibility with the former Windows and Linux/ARM
 * V1 APIs. The handle-based *_ex API has one portable signature on all
 * supported platforms.
 *
 */

#include <QtCore/qglobal.h>

#if !defined(Q_OS_WIN) && !defined(Q_OS_LINUX)
#  error "USB LISM-PI26xx supports only Windows and Linux targets."
#endif

#if defined(Q_OS_WIN)
#  define LS_QT_API Q_DECL_IMPORT
#  define LS_QT_CALL __stdcall
#else
#  define LS_QT_API
#  define LS_QT_CALL
#endif

#if QT_POINTER_SIZE == 8
#  if defined(Q_OS_WIN)
#    define LS_LIBRARY_FILE "USBLISMPI2664.dll"
#  else
#    define LS_LIBRARY_FILE "libusblismpi2664.so"
#  endif
#else
#  if defined(Q_OS_WIN)
#    define LS_LIBRARY_FILE "USBLISMPI2632.dll"
#  else
#    define LS_LIBRARY_FILE "libusblismpi2632.so"
#  endif
#endif

/* Compatibility constants used by existing Qt applications. */
#define LISM_ADDR                      0xFEu
#define LC_I2C_ADDR                    LISM_ADDR
#define RET_OK                         0
#define LS_INFINITE                    0xFFFFFFFFu

#define _512                           512u
#define _1kB                           (_512 * 2u)
#define _2kB                           (_1kB * 2u)
#define _4kB                           (_2kB * 2u)
#define _8kB                           (_4kB * 2u)
#define _16kB                          (_8kB * 2u)
#define _32kB                          (_16kB * 2u)
#define _64kB                          (_32kB * 2u)
#define _128kB                         (_64kB * 2u)
#define _256kB                         (_128kB * 2u)
#define _512kB                         (_256kB * 2u)
#define _1MB                           (_512kB * 2u)
#define _2MB                           (_1MB * 2u)
#define _4MB                           (_2MB * 2u)
#define _8MB                           (_4MB * 2u)
#define _16MB                          (_8MB * 2u)
#define _32MB                          (_16MB * 2u)
#define _64MB                          (_32MB * 2u)
#define _128MB                         (_64MB * 2u)
#define _256MB                         (_128MB * 2u)

#define _1ms                           1u
#define _1s                            (1000u * _1ms)

#define MODE_FREE_RUNNING              0x00u
#define MODE_EXT_RISING_EDGE_SL        0x01u
#define MODE_EXT_HIGH_LEVEL            0x02u
#define MODE_INT_SOFT_TRIGGER          0x03u
#define MODE_QUAD_ENC_TRIGGER          0x04u
#define MODE_EXT_RISING_EDGE_ML        0x05u
#define MODE_ENCODER_DIR_CW            0x00u
#define MODE_ENCODER_DIR_CCW           0x10u
#define MODE_ENCODER_CNT_DISABLE       0x00u
#define MODE_ENCODER_CNT_ENABLE        0x20u

#define IF_DCLK_400KHZ                 0x00u
#define IF_DCLK_500KHZ                 0x01u
#define IF_DCLK_800KHZ                 0x02u
#define IF_DCLK_1MHZ                   0x03u
#define IF_DCLK_2MHZ                   0x04u
#define IF_DCLK_4MHZ                   0x05u
#define IF_DCLK_10MHZ                  0x06u
#define IF_DCLK_20MHZ                  0x07u
#define IF_DCLK_POL_RISING_EDGE        0x00u
#define IF_DCLK_POL_FALLING_EDGE       0x08u
#define IF_LINE_VALID_HIGH             0x00u
#define IF_LINE_VALID_LOW              0x10u
#define IF_FRAME_VALID_HIGH            0x00u
#define IF_FRAME_VALID_LOW             0x20u
#define IF_TRIGGER_OUTPUT_HIGH         0x00u
#define IF_TRIGGER_OUTPUT_LOW          0x40u

#define ADC_VREF_1V6                   0x00u
#define ADC_VREF_2V0                   0x01u

using LSHandle = void*;
#if defined(Q_OS_WIN)
using LSResult = quint32;
#else
using LSResult = qint32;
#endif

#define LS_THREAD_PRIORITY_NORMAL       0
#define LS_THREAD_PRIORITY_ABOVE_NORMAL 1
#define LS_THREAD_PRIORITY_HIGH         2

/* BEGIN GENERATED LS ERROR CODES */
#if defined(Q_OS_WIN)
#define LS_OK                                  ((LSResult)0)
#define LS_ERR_NO_DEVICES_ATTACHED             ((LSResult)0x20000001)
#define LS_ERR_DEVICE_INDEX_OUT_OF_RANGE       ((LSResult)0x20000002)
#define LS_ERR_SERIAL_NUM_NOT_FOUND            ((LSResult)0x20000003)
#define LS_ERR_INVALID_HANDLE                  ((LSResult)6)
#define LS_ERR_DEVICE_ACTIVE                   ((LSResult)0x20000011)
#define LS_ERR_CONTROL_TRANSFER                ((LSResult)0x20000015)
#define LS_ERR_TIMEOUT                         ((LSResult)1460)
#define LS_ERR_DEVICE_ALREADY_OPEN             ((LSResult)0x20000013)
#define LS_ERR_NOT_IMPLEMENTED                 ((LSResult)0x20000014)
#define LS_ERR_ALLOCATE_THREADPARAM_MEM        ((LSResult)0x20000004)
#define LS_ERR_PATH_INVALID_HANDLE             ((LSResult)0x20000006)
#define LS_ERR_INVALID_DATALEN                 ((LSResult)0x21000001)
#define LS_ERR_I2C_NACK                        ((LSResult)0x21000004)
#define LS_ERR_I2C_ERROR                       ((LSResult)0x21000005)
#define LS_ERR_I2C_UNKNOWN                     ((LSResult)0x21000006)
#define LS_ERR_I2C_MUX_DISABLED                ((LSResult)0x21000007)
#define LS_ERR_INVALID_PACKETLENGTH            ((LSResult)0x21000002)
#define LS_ERR_CMD_NOT_SUPPORTED               ((LSResult)0x21000003)
#define LS_ERR_PIPE_CANCELLED                  ((LSResult)109)
#define LS_ERR_INVALID_TIMEOUT                 ((LSResult)0x21000008)
#define LS_ERR_INVALID_THREAD_PRIORITY         ((LSResult)0x21000009)
#define LS_ERR_THREAD_PRIORITY_FAILED          ((LSResult)0x2100000A)
#else
#define LS_OK                                  ((LSResult)0)
#define LS_ERR_NO_DEVICES_ATTACHED             ((LSResult)-10001)
#define LS_ERR_DEVICE_INDEX_OUT_OF_RANGE       ((LSResult)-10002)
#define LS_ERR_SERIAL_NUM_NOT_FOUND            ((LSResult)-10003)
#define LS_ERR_INVALID_HANDLE                  ((LSResult)-10004)
#define LS_ERR_DEVICE_ACTIVE                   ((LSResult)-10005)
#define LS_ERR_CONTROL_TRANSFER                ((LSResult)-10006)
#define LS_ERR_TIMEOUT                         ((LSResult)-10007)
#define LS_ERR_DEVICE_ALREADY_OPEN             ((LSResult)-10008)
#define LS_ERR_NOT_IMPLEMENTED                 ((LSResult)-10009)
#define LS_ERR_ALLOCATE_THREADPARAM_MEM        ((LSResult)-10010)
#define LS_ERR_PATH_INVALID_HANDLE             ((LSResult)-10012)
#define LS_ERR_INVALID_DATALEN                 ((LSResult)-10051)
#define LS_ERR_I2C_NACK                        ((LSResult)-10052)
#define LS_ERR_I2C_ERROR                       ((LSResult)-10053)
#define LS_ERR_I2C_UNKNOWN                     ((LSResult)-10054)
#define LS_ERR_I2C_MUX_DISABLED                ((LSResult)-10055)
#define LS_ERR_INVALID_PACKETLENGTH            ((LSResult)-10056)
#define LS_ERR_CMD_NOT_SUPPORTED               ((LSResult)-10057)
#define LS_ERR_PIPE_CANCELLED                  ((LSResult)-10058)
#define LS_ERR_INVALID_TIMEOUT                 ((LSResult)-10059)
#define LS_ERR_INVALID_THREAD_PRIORITY         ((LSResult)-10060)
#define LS_ERR_THREAD_PRIORITY_FAILED          ((LSResult)-10061)
#endif
/* END GENERATED LS ERROR CODES */

static_assert(sizeof(qint8) == 1, "qint8 must be 8 bit");
static_assert(sizeof(quint16) == 2, "quint16 must be 16 bit");
static_assert(sizeof(qint32) == 4, "qint32 must be 32 bit");
static_assert(sizeof(quint32) == 4, "quint32 must be 32 bit");

namespace UsbLismPi26xx
{
constexpr LSResult Ok = 0;
constexpr quint8 DefaultI2cAddress = 0xFEu;
constexpr quint32 Infinite = 0xFFFFFFFFu;

constexpr quint32 Size512B = 512u;
constexpr quint32 Size1KB = 1024u;
constexpr quint32 Size2KB = 2u * Size1KB;
constexpr quint32 Size4KB = 4u * Size1KB;
constexpr quint32 Size8KB = 8u * Size1KB;
constexpr quint32 Size16KB = 16u * Size1KB;
constexpr quint32 Size32KB = 32u * Size1KB;
constexpr quint32 Size64KB = 64u * Size1KB;
constexpr quint32 Size128KB = 128u * Size1KB;
constexpr quint32 Size256KB = 256u * Size1KB;
constexpr quint32 Size512KB = 512u * Size1KB;
constexpr quint32 Size1MB = 1024u * Size1KB;
constexpr quint32 Size2MB = 2u * Size1MB;
constexpr quint32 Size4MB = 4u * Size1MB;
constexpr quint32 Size8MB = 8u * Size1MB;
constexpr quint32 Size16MB = 16u * Size1MB;
constexpr quint32 Size32MB = 32u * Size1MB;
constexpr quint32 Size64MB = 64u * Size1MB;
constexpr quint32 Size128MB = 128u * Size1MB;
constexpr quint32 Size256MB = 256u * Size1MB;

constexpr quint32 Millisecond = 1u;
constexpr quint32 Second = 1000u * Millisecond;
} // namespace UsbLismPi26xx

extern "C" {


#if defined(Q_OS_WIN)

/* Windows legacy API */

LS_QT_API quint16 LS_QT_CALL ls_libversion(void);
LS_QT_API quint32 LS_QT_CALL ls_initialize(quint32 pipe_size, quint32 packet_length,
    quint32 thread_class, qint32 thread_priority, const char* message_id);
LS_QT_API qint32 LS_QT_CALL ls_enumdevices(void);
LS_QT_API quint16 LS_QT_CALL ls_getfwversion(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getvendorname(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getproductname(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getserialnumber(qint32 index);
LS_QT_API quint8 LS_QT_CALL ls_devicecount(void);
LS_QT_API qint32 LS_QT_CALL ls_currentdeviceindex(void);
LS_QT_API quint32 LS_QT_CALL ls_opendevicebyindex(qint32 index);
LS_QT_API quint32 LS_QT_CALL ls_opendevicebyserial(const char* serial_num);
LS_QT_API quint32 LS_QT_CALL ls_closedevice(void);
LS_QT_API quint32 LS_QT_CALL ls_waitforpipe(quint32 timeout_ms);
LS_QT_API quint32 LS_QT_CALL ls_waitforpipecount(qint32 count, qint32& available,
    quint32 timeout_ms);
LS_QT_API quint32 LS_QT_CALL ls_getpipe(void* buffer, quint32 to_read, quint32& read_count);
LS_QT_API quint32 LS_QT_CALL ls_setpacketlength(quint32 packet_length);
LS_QT_API quint32 LS_QT_CALL ls_seteptimeout(quint32 timeout_ms);
LS_QT_API quint32 LS_QT_CALL ls_geteptimeout(void);
LS_QT_API quint32 LS_QT_CALL ls_getfps(void);
LS_QT_API const char* LS_QT_CALL ls_geterrorstring(quint32 error_code);
LS_QT_API quint32 LS_QT_CALL ls_customfirmware(quint32& custom_firmware);
LS_QT_API quint32 LS_QT_CALL ls_setcfg1(quint8 cfg1);
LS_QT_API quint32 LS_QT_CALL ls_getcfg1(quint8& cfg1);
LS_QT_API quint32 LS_QT_CALL ls_getpacketlength(quint32& packet_length);
LS_QT_API quint32 LS_QT_CALL ls_setmuxchannel(quint8 mux);
LS_QT_API quint32 LS_QT_CALL ls_getmuxchannel(qint8& mux);
LS_QT_API quint32 LS_QT_CALL ls_readi2c_ext(quint8 i2c_address, void* buffer, quint16& length);
LS_QT_API quint32 LS_QT_CALL ls_writei2c_ext(quint8 i2c_address, const void* buffer,
    quint16 length);
LS_QT_API quint32 LS_QT_CALL ls_readi2c(quint8 i2c_address, void* buffer, quint16& length);
LS_QT_API quint32 LS_QT_CALL ls_writei2c(quint8 i2c_address, const void* buffer, quint16 length);
LS_QT_API quint32 LS_QT_CALL ls_i2cread1byte(quint8 i2c_address, quint8 i2c_register,
    quint8& value);
LS_QT_API quint32 LS_QT_CALL ls_i2cread2bytes(quint8 i2c_address, quint8 i2c_register,
    quint16& value);
LS_QT_API quint32 LS_QT_CALL ls_i2cread4bytes(quint8 i2c_address, quint8 i2c_register,
    quint32& value);
LS_QT_API quint32 LS_QT_CALL ls_i2cwrite1byte(quint8 i2c_address, quint8 i2c_register,
    quint8 value);
LS_QT_API quint32 LS_QT_CALL ls_i2cwrite2bytes(quint8 i2c_address, quint8 i2c_register,
    quint16 value);
LS_QT_API quint32 LS_QT_CALL ls_i2cwrite4bytes(quint8 i2c_address, quint8 i2c_register,
    quint32 value);
LS_QT_API quint32 LS_QT_CALL ls_i2cwritecmd(quint8 i2c_address, quint8 i2c_command);
LS_QT_API quint32 LS_QT_CALL ls_hw_reset(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_suspend(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_resume(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_updateparam(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_setstate(quint8 address, quint8 state);
LS_QT_API quint32 LS_QT_CALL ls_setmodeconfig(quint8 address, quint8 mode);
LS_QT_API quint32 LS_QT_CALL ls_setifconfig(quint8 address, quint8 config);
LS_QT_API quint32 LS_QT_CALL ls_setstpulse(quint8 address, quint32 high_value, quint32 low_value);
LS_QT_API quint32 LS_QT_CALL ls_setsthigh(quint8 address, quint32 high_value);
LS_QT_API quint32 LS_QT_CALL ls_setstlow(quint8 address, quint32 low_value);
LS_QT_API quint32 LS_QT_CALL ls_setlinesperframe(quint8 address, quint16 lines);
LS_QT_API quint32 LS_QT_CALL ls_setquadcount(quint8 address, quint32 count);
LS_QT_API quint32 LS_QT_CALL ls_setsofttriggertime(quint8 address, quint32 time_value);
LS_QT_API quint32 LS_QT_CALL ls_settriggerdelay(quint8 address, quint32 delay_value);
LS_QT_API quint32 LS_QT_CALL ls_settriggerwidth(quint8 address, quint32 width_value);
LS_QT_API quint32 LS_QT_CALL ls_setpixelcount(quint8 address, quint16 pixel_count);
LS_QT_API quint32 LS_QT_CALL ls_setedgedelay(quint8 address, quint8 edge_delay);
LS_QT_API quint32 LS_QT_CALL ls_setadcvref(quint8 address, quint8 vref);
LS_QT_API quint32 LS_QT_CALL ls_setadcgain(quint8 address, quint8 gain);
LS_QT_API quint32 LS_QT_CALL ls_setadcoffset(quint8 address, quint16 offset);
LS_QT_API quint32 LS_QT_CALL ls_setadcbias(quint8 address, quint16 bias);
LS_QT_API quint32 LS_QT_CALL ls_setslaveaddress(quint8 address, quint8 new_address);
LS_QT_API quint32 LS_QT_CALL ls_saveslaveaddress(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_savesettings(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_reloadsettings(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_resetsettings(quint8 address);
LS_QT_API quint32 LS_QT_CALL ls_getmcuversion(quint8 address, quint16& version);
LS_QT_API quint32 LS_QT_CALL ls_getctgversion(quint8 address, quint16& version);
LS_QT_API quint32 LS_QT_CALL ls_getctgstate(quint8 address, quint8& state);
LS_QT_API quint32 LS_QT_CALL ls_getstate(quint8 address, quint8& state);
LS_QT_API quint32 LS_QT_CALL ls_getmodeconfig(quint8 address, quint8& mode);
LS_QT_API quint32 LS_QT_CALL ls_getifconfig(quint8 address, quint8& config);
LS_QT_API quint32 LS_QT_CALL ls_getstpulse(quint8 address, quint32& high_value, quint32& low_value);
LS_QT_API quint32 LS_QT_CALL ls_getsthigh(quint8 address, quint32& high_value);
LS_QT_API quint32 LS_QT_CALL ls_getstlow(quint8 address, quint32& low_value);
LS_QT_API quint32 LS_QT_CALL ls_getlinesperframe(quint8 address, quint16& lines);
LS_QT_API quint32 LS_QT_CALL ls_getquadcount(quint8 address, quint32& count);
LS_QT_API quint32 LS_QT_CALL ls_getsofttriggertime(quint8 address, quint32& time_value);
LS_QT_API quint32 LS_QT_CALL ls_gettriggerdelay(quint8 address, quint32& delay_value);
LS_QT_API quint32 LS_QT_CALL ls_gettriggerwidth(quint8 address, quint32& width_value);
LS_QT_API quint32 LS_QT_CALL ls_getpixelcount(quint8 address, quint16& pixel_count);
LS_QT_API quint32 LS_QT_CALL ls_getedgedelay(quint8 address, quint8& edge_delay);
LS_QT_API quint32 LS_QT_CALL ls_getadcvref(quint8 address, quint8& vref);
LS_QT_API quint32 LS_QT_CALL ls_getadcgain(quint8 address, quint8& gain);
LS_QT_API quint32 LS_QT_CALL ls_getadcoffset(quint8 address, quint16& offset);
LS_QT_API quint32 LS_QT_CALL ls_getadcbias(quint8 address, quint16& bias);
LS_QT_API quint32 LS_QT_CALL ls_getslaveaddress(quint8 address, quint8& new_address);
LS_QT_API quint32 LS_QT_CALL ls_gethw1id(quint8 address, quint16& hardware_id);
LS_QT_API quint32 LS_QT_CALL ls_gethw1version(quint8 address, quint16& version);
LS_QT_API quint32 LS_QT_CALL ls_gethw2version(quint8 address, quint16& version);
LS_QT_API quint32 LS_QT_CALL ls_getgainmult(quint8 address, quint16& multiplier);
LS_QT_API quint32 LS_QT_CALL ls_getgaindiv(quint8 address, quint16& divisor);
LS_QT_API quint32 LS_QT_CALL ls_getinitstatus(quint8 address, quint8& status);
LS_QT_API quint32 LS_QT_CALL ls_getcomresult(quint8 address, quint8& result_value);
LS_QT_API quint32 LS_QT_CALL ls_shutdown(void);

#elif defined(Q_OS_LINUX)

/* Linux legacy API */

LS_QT_API quint16 LS_QT_CALL ls_libversion(void);
LS_QT_API void LS_QT_CALL ls_initialize(qint32 pipe_size, qint32 packet_length);
LS_QT_API qint32 LS_QT_CALL ls_enumdevices(void);
LS_QT_API quint16 LS_QT_CALL ls_getfwversion(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getvendorname(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getproductname(qint32 index);
LS_QT_API const char* LS_QT_CALL ls_getserialnumber(qint32 index);
LS_QT_API quint8 LS_QT_CALL ls_devicecount(void);
LS_QT_API qint32 LS_QT_CALL ls_currentdeviceindex(void);
LS_QT_API qint32 LS_QT_CALL ls_closedevice(void);
LS_QT_API qint32 LS_QT_CALL ls_opendevicebyindex(qint32 index);
LS_QT_API qint32 LS_QT_CALL ls_opendevicebyserial(const char* serial_num);
LS_QT_API qint32 LS_QT_CALL ls_getpipe(void* buffer, quint32 to_read);
LS_QT_API qint32 LS_QT_CALL ls_waitforpipe(quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_waitforpipecount(qint32 count, qint32& available,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setpacketlength(qint32 packet_length);
LS_QT_API qint32 LS_QT_CALL ls_seteptimeout(quint32 timeout_ms);
LS_QT_API quint32 LS_QT_CALL ls_geteptimeout(void);
LS_QT_API quint32 LS_QT_CALL ls_getfps(void);
LS_QT_API const char* LS_QT_CALL ls_geterrorstring(qint32 error_code);
LS_QT_API qint32 LS_QT_CALL ls_customfirmware(quint32& custom_firmware, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setmuxchannel(quint8 mux, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getmuxchannel(qint8& mux, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_readi2c_ext(quint8 i2c_address, void* buffer, quint16& length,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_writei2c_ext(quint8 i2c_address, const void* buffer, quint16 length,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_readi2c(quint8 i2c_address, void* buffer, quint16& length,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_writei2c(quint8 i2c_address, const void* buffer, quint16 length,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cread1byte(quint8 i2c_address, quint8 i2c_register, quint8& value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cread2bytes(quint8 i2c_address, quint8 i2c_register, quint16& value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cread4bytes(quint8 i2c_address, quint8 i2c_register, quint32& value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cwrite1byte(quint8 i2c_address, quint8 i2c_register, quint8 value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cwrite2bytes(quint8 i2c_address, quint8 i2c_register, quint16 value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cwrite4bytes(quint8 i2c_address, quint8 i2c_register, quint32 value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_i2cwritecmd(quint8 i2c_address, quint8 i2c_command, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setadcbias(quint8 address, quint16 bias, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getadcbias(quint8 address, quint16& bias, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getadcvref(quint8 address, quint8& vref, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getadcgain(quint8 address, quint8& gain, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getadcoffset(quint8 address, quint16& offset, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setadcvref(quint8 address, quint8 vref, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setadcgain(quint8 address, quint8 gain, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setadcoffset(quint8 address, quint16 offset, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_gethw1id(quint8 address, quint16& hardware_id, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_gethw1version(quint8 address, quint16& version, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_gethw2version(quint8 address, quint16& version, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getgainmult(quint8 address, quint16& multiplier, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getgaindiv(quint8 address,quint16& divisor, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_hw_reset(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_suspend(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_resume(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_updateparam(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setstate(quint8 address, quint8 state, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setmodeconfig(quint8 address, quint8 mode, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setifconfig(quint8 address, quint8 config, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setstpulse(quint8 address, quint32 high_value, quint32 low_value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setsthigh(quint8 address, quint32 high_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setstlow(quint8 address, quint32 low_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setlinesperframe(quint8 address, quint16 lines, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setquadcount(quint8 address, quint32 count, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setsofttriggertime(quint8 address, quint32 time_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_settriggerdelay(quint8 address, quint32 delay_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_settriggerwidth(quint8 address, quint32 width_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setpixelcount(quint8 address, quint16 pixel_count, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setedgedelay(quint8 address, quint8 edge_delay, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setslaveaddress(quint8 address, quint8 new_address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_saveslaveaddress(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_savesettings(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_reloadsettings(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_resetsettings(quint8 address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getctgversion(quint8 address, quint16& version, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getmcuversion(quint8 address, quint16& version, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getctgstate(quint8 address, quint8& state, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getstate(quint8 address, quint8& state, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getmodeconfig(quint8 address, quint8& mode, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getifconfig(quint8 address, quint8& config, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getstpulse(quint8 address, quint32& high_value, quint32& low_value,
    quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getsthigh(quint8 address, quint32& high_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getstlow(quint8 address, quint32& low_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getlinesperframe(quint8 address, quint16& lines, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getquadcount(quint8 address, quint32& count, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getsofttriggertime(quint8 address, quint32& time_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_gettriggerdelay(quint8 address, quint32& delay_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_gettriggerwidth(quint8 address, quint32& width_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getpixelcount(quint8 address, quint16& pixel_count, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getedgedelay(quint8 address, quint8& edge_delay, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getslaveaddress(quint8 address, quint8& new_address, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getinitstatus(quint8 address, quint8& status, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getcomresult(quint8 address, quint8& result_value, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_setcfg1(quint8 cfg1, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getcfg1(quint8& cfg1, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_getpacketlength(qint32& packet_length, quint32 timeout_ms);
LS_QT_API qint32 LS_QT_CALL ls_shutdown(void);

#endif

/* Portable handle-based API */

LS_QT_API LSResult LS_QT_CALL ls_seteptimeout_ex(LSHandle handle, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_geteptimeout_ex(LSHandle handle, quint32& timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setthreadpriority_ex(LSHandle handle, qint32 priority);
LS_QT_API LSResult LS_QT_CALL ls_getthreadpriority_ex(LSHandle handle, qint32& priority);
LS_QT_API LSResult LS_QT_CALL ls_opendevicebyindex_ex(qint32 index, quint32 pipe_size,
    quint32 packet_length, LSHandle& handle);
LS_QT_API LSResult LS_QT_CALL ls_opendevicebyserial_ex(const char* serial_num, quint32 pipe_size,
    quint32 packet_length, LSHandle& handle);
LS_QT_API LSResult LS_QT_CALL ls_closedevice_ex(LSHandle handle);
LS_QT_API LSResult LS_QT_CALL ls_getpipe_ex(LSHandle handle, void* buffer, quint32 to_read,
    quint32& read_count);
LS_QT_API LSResult LS_QT_CALL ls_waitforpipe_ex(LSHandle handle, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_waitforpipecount_ex(LSHandle handle, qint32 count,
    qint32& available, quint32 timeout_ms);
LS_QT_API quint32 LS_QT_CALL ls_getfps_ex(LSHandle handle);
LS_QT_API LSResult LS_QT_CALL ls_getpacketlength_ex(LSHandle handle, quint32& packet_length,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_customfirmware_ex(LSHandle handle, quint32& custom_firmware, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setcfg1_ex(LSHandle handle, quint8 cfg1, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getcfg1_ex(LSHandle handle, quint8& cfg1, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setslaveaddress_ex(LSHandle handle, quint8 address,
    quint8 new_address, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getslaveaddress_ex(LSHandle handle, quint8 address,
    quint8& new_address, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_saveslaveaddress_ex(LSHandle handle, quint8 address,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setmuxchannel_ex(LSHandle handle, quint8 mux, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getmuxchannel_ex(LSHandle handle, qint8& mux, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_readi2c_ex(LSHandle handle, quint8 i2c_address, void* buffer,
    quint16& length, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_writei2c_ex(LSHandle handle, quint8 i2c_address,
    const void* buffer, quint16 length, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_readi2c_ext_ex(LSHandle handle, quint8 i2c_address, void* buffer,
    quint16& length, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_writei2c_ext_ex(LSHandle handle, quint8 i2c_address,
    const void* buffer, quint16 length, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cread1byte_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint8& value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cread2bytes_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint16& value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cread4bytes_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint32& value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cwrite1byte_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint8 value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cwrite2bytes_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint16 value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cwrite4bytes_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_register, quint32 value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_i2cwritecmd_ex(LSHandle handle, quint8 i2c_address,
    quint8 i2c_command, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_hw_reset_ex(LSHandle handle, quint8 address, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_resume_ex(LSHandle handle, quint8 address, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_suspend_ex(LSHandle handle, quint8 address, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_updateparam_ex(LSHandle handle, quint8 address,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setstate_ex(LSHandle handle, quint8 address, quint8 state,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setmodeconfig_ex(LSHandle handle, quint8 address, quint8 mode,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setifconfig_ex(LSHandle handle, quint8 address, quint8 config,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setsthigh_ex(LSHandle handle, quint8 address, quint32 high_value,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setstlow_ex(LSHandle handle, quint8 address, quint32 low_value,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setstpulse_ex(LSHandle handle, quint8 address, quint32 high_value,
    quint32 low_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setlinesperframe_ex(LSHandle handle, quint8 address, quint16 lines,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setquadcount_ex(LSHandle handle, quint8 address, quint32 count,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setsofttriggertime_ex(LSHandle handle, quint8 address,
    quint32 time_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_settriggerdelay_ex(LSHandle handle, quint8 address,
    quint32 delay_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_settriggerwidth_ex(LSHandle handle, quint8 address,
    quint32 width_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setpixelcount_ex(LSHandle handle, quint8 address,
    quint16 pixel_count, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setedgedelay_ex(LSHandle handle, quint8 address, quint8 edge_delay,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setadcvref_ex(LSHandle handle, quint8 address, quint8 vref,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setadcgain_ex(LSHandle handle, quint8 address, quint8 gain,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setadcoffset_ex(LSHandle handle, quint8 address, quint16 offset,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_setadcbias_ex(LSHandle handle, quint8 address, quint16 bias,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getctgstate_ex(LSHandle handle, quint8 address, quint8& state,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getstate_ex(LSHandle handle, quint8 address, quint8& state,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getmodeconfig_ex(LSHandle handle, quint8 address, quint8& mode,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getifconfig_ex(LSHandle handle, quint8 address, quint8& config,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getsthigh_ex(LSHandle handle, quint8 address, quint32& high_value,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getstlow_ex(LSHandle handle, quint8 address, quint32& low_value,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getstpulse_ex(LSHandle handle, quint8 address, quint32& high_value,
    quint32& low_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getlinesperframe_ex(LSHandle handle, quint8 address,
    quint16& lines, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getquadcount_ex(LSHandle handle, quint8 address, quint32& count,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getsofttriggertime_ex(LSHandle handle, quint8 address,
    quint32& time_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_gettriggerdelay_ex(LSHandle handle, quint8 address,
    quint32& delay_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_gettriggerwidth_ex(LSHandle handle, quint8 address,
    quint32& width_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getpixelcount_ex(LSHandle handle, quint8 address,
    quint16& pixel_count, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getedgedelay_ex(LSHandle handle, quint8 address,
    quint8& edge_delay, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getadcvref_ex(LSHandle handle, quint8 address, quint8& vref,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getadcgain_ex(LSHandle handle, quint8 address, quint8& gain,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getgainmult_ex(LSHandle handle, quint8 address,
    quint16& multiplier, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getgaindiv_ex(LSHandle handle, quint8 address, quint16& divisor,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getadcoffset_ex(LSHandle handle, quint8 address, quint16& offset,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getadcbias_ex(LSHandle handle, quint8 address, quint16& bias,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_savesettings_ex(LSHandle handle, quint8 address,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_reloadsettings_ex(LSHandle handle, quint8 address,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_resetsettings_ex(LSHandle handle, quint8 address,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getinitstatus_ex(LSHandle handle, quint8 address, quint8& status,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getcomresult_ex(LSHandle handle, quint8 address,
    quint8& result_value, quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getmcuversion_ex(LSHandle handle, quint8 address, quint16& version,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_getctgversion_ex(LSHandle handle, quint8 address, quint16& version,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_gethw1id_ex(LSHandle handle, quint8 address, quint16& hardware_id,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_gethw1version_ex(LSHandle handle, quint8 address, quint16& version,
    quint32 timeout_ms);
LS_QT_API LSResult LS_QT_CALL ls_gethw2version_ex(LSHandle handle, quint8 address, quint16& version,
    quint32 timeout_ms);


} // extern "C"

#undef LS_QT_API
#undef LS_QT_CALL

#endif // USBLISMPI26_H
