Program Listing for File davis.h

Return to documentation for file (include/libcaer/devices/davis.h)

#ifndef LIBCAER_DEVICES_DAVIS_H_
#define LIBCAER_DEVICES_DAVIS_H_

#include "../events/frame.h"
#include "../events/imu6.h"
#include "../events/polarity.h"
#include "../events/special.h"

#include "imu_support.h"
#include "usb.h"

#ifdef __cplusplus
extern "C" {
#endif

#define CAER_DEVICE_DAVIS_FX2 1
#define CAER_DEVICE_DAVIS_FX3 2
#define CAER_DEVICE_DAVIS 4
#define CAER_DEVICE_DAVIS_RPI 6

#define DAVIS_CHIP_DAVIS240A 0
#define DAVIS_CHIP_DAVIS240B 1
#define DAVIS_CHIP_DAVIS240C 2
#define DAVIS_CHIP_DAVIS128 3
#define DAVIS_CHIP_DAVIS346A 4
#define DAVIS_CHIP_DAVIS346B 5
#define DAVIS_CHIP_DAVIS640 6
#define DAVIS_CHIP_DAVIS640H 7
#define DAVIS_CHIP_DAVIS208 8
#define DAVIS_CHIP_DAVIS346C 9


#define IS_DAVIS128(chipID)  ((chipID) == DAVIS_CHIP_DAVIS128)
#define IS_DAVIS208(chipID)  ((chipID) == DAVIS_CHIP_DAVIS208)
#define IS_DAVIS240A(chipID) ((chipID) == DAVIS_CHIP_DAVIS240A)
#define IS_DAVIS240B(chipID) ((chipID) == DAVIS_CHIP_DAVIS240B)
#define IS_DAVIS240C(chipID) ((chipID) == DAVIS_CHIP_DAVIS240C)
#define IS_DAVIS240(chipID)  (IS_DAVIS240A(chipID) || IS_DAVIS240B(chipID) || IS_DAVIS240C(chipID))
#define IS_DAVIS346A(chipID) ((chipID) == DAVIS_CHIP_DAVIS346A)
#define IS_DAVIS346B(chipID) ((chipID) == DAVIS_CHIP_DAVIS346B)
#define IS_DAVIS346C(chipID) ((chipID) == DAVIS_CHIP_DAVIS346C)
#define IS_DAVIS346(chipID)  (IS_DAVIS346A(chipID) || IS_DAVIS346B(chipID) || IS_DAVIS346C(chipID))
#define IS_DAVIS640(chipID)  ((chipID) == DAVIS_CHIP_DAVIS640)
#define IS_DAVIS640H(chipID) ((chipID) == DAVIS_CHIP_DAVIS640H)

#define DAVIS_CONFIG_MUX 0
#define DAVIS_CONFIG_DVS 1
#define DAVIS_CONFIG_APS 2
#define DAVIS_CONFIG_IMU 3
#define DAVIS_CONFIG_EXTINPUT 4
#define DAVIS_CONFIG_BIAS 5
#define DAVIS_CONFIG_CHIP 5
#define DAVIS_CONFIG_SYSINFO 6
#define DAVIS_CONFIG_USB 9
#define DAVIS_CONFIG_DDRAER 9

#define DAVIS_CONFIG_MUX_RUN 0
#define DAVIS_CONFIG_MUX_TIMESTAMP_RUN 1
#define DAVIS_CONFIG_MUX_TIMESTAMP_RESET 2
#define DAVIS_CONFIG_MUX_RUN_CHIP 3
#define DAVIS_CONFIG_MUX_DROP_EXTINPUT_ON_TRANSFER_STALL 4
#define DAVIS_CONFIG_MUX_DROP_DVS_ON_TRANSFER_STALL 5
#define DAVIS_CONFIG_MUX_HAS_STATISTICS 80
#define DAVIS_CONFIG_MUX_STATISTICS_EXTINPUT_DROPPED 81
#define DAVIS_CONFIG_MUX_STATISTICS_DVS_DROPPED 83

#define DAVIS_CONFIG_DVS_SIZE_COLUMNS 0
#define DAVIS_CONFIG_DVS_SIZE_ROWS 1
#define DAVIS_CONFIG_DVS_ORIENTATION_INFO 2
#define DAVIS_CONFIG_DVS_RUN 3
#define DAVIS_CONFIG_DVS_WAIT_ON_TRANSFER_STALL 4
#define DAVIS_CONFIG_DVS_EXTERNAL_AER_CONTROL 5
#define DAVIS_CONFIG_DVS_HAS_PIXEL_FILTER 10
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_0_ROW 11
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_0_COLUMN 12
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_1_ROW 13
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_1_COLUMN 14
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_2_ROW 15
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_2_COLUMN 16
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_3_ROW 17
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_3_COLUMN 18
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_4_ROW 19
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_4_COLUMN 20
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_5_ROW 21
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_5_COLUMN 22
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_6_ROW 23
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_6_COLUMN 24
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_7_ROW 25
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_7_COLUMN 26
#define DAVIS_CONFIG_DVS_HAS_BACKGROUND_ACTIVITY_FILTER 30
#define DAVIS_CONFIG_DVS_FILTER_BACKGROUND_ACTIVITY 31
#define DAVIS_CONFIG_DVS_FILTER_BACKGROUND_ACTIVITY_TIME 32
#define DAVIS_CONFIG_DVS_FILTER_REFRACTORY_PERIOD 33
#define DAVIS_CONFIG_DVS_FILTER_REFRACTORY_PERIOD_TIME 34
#define DAVIS_CONFIG_DVS_HAS_ROI_FILTER 40
#define DAVIS_CONFIG_DVS_FILTER_ROI_START_COLUMN 41
#define DAVIS_CONFIG_DVS_FILTER_ROI_START_ROW 42
#define DAVIS_CONFIG_DVS_FILTER_ROI_END_COLUMN 43
#define DAVIS_CONFIG_DVS_FILTER_ROI_END_ROW 44
#define DAVIS_CONFIG_DVS_HAS_SKIP_FILTER 50
#define DAVIS_CONFIG_DVS_FILTER_SKIP_EVENTS 51
#define DAVIS_CONFIG_DVS_FILTER_SKIP_EVENTS_EVERY 52
#define DAVIS_CONFIG_DVS_HAS_POLARITY_FILTER 60
#define DAVIS_CONFIG_DVS_FILTER_POLARITY_FLATTEN 61
#define DAVIS_CONFIG_DVS_FILTER_POLARITY_SUPPRESS 62
#define DAVIS_CONFIG_DVS_FILTER_POLARITY_SUPPRESS_TYPE 63
#define DAVIS_CONFIG_DVS_HAS_STATISTICS 80
#define DAVIS_CONFIG_DVS_STATISTICS_EVENTS_ROW 81
#define DAVIS_CONFIG_DVS_STATISTICS_EVENTS_COLUMN 83
#define DAVIS_CONFIG_DVS_STATISTICS_EVENTS_DROPPED 85
#define DAVIS_CONFIG_DVS_STATISTICS_FILTERED_PIXELS 87
#define DAVIS_CONFIG_DVS_STATISTICS_FILTERED_BACKGROUND_ACTIVITY 89
#define DAVIS_CONFIG_DVS_STATISTICS_FILTERED_REFRACTORY_PERIOD 91
#define DAVIS_CONFIG_DVS_FILTER_PIXEL_AUTO_TRAIN 100

#define DAVIS_CONFIG_APS_SIZE_COLUMNS 0
#define DAVIS_CONFIG_APS_SIZE_ROWS 1
#define DAVIS_CONFIG_APS_ORIENTATION_INFO 2
#define DAVIS_CONFIG_APS_COLOR_FILTER 3
#define DAVIS_CONFIG_APS_RUN 4
#define DAVIS_CONFIG_APS_WAIT_ON_TRANSFER_STALL 5
#define DAVIS_CONFIG_APS_HAS_GLOBAL_SHUTTER 6
#define DAVIS_CONFIG_APS_GLOBAL_SHUTTER 7
#define DAVIS_CONFIG_APS_START_COLUMN_0 8
#define DAVIS_CONFIG_APS_START_ROW_0 9
#define DAVIS_CONFIG_APS_END_COLUMN_0 10
#define DAVIS_CONFIG_APS_END_ROW_0 11
#define DAVIS_CONFIG_APS_EXPOSURE 12
#define DAVIS_CONFIG_APS_FRAME_INTERVAL 13

// Extra timing settings for DAVIS640H APS module.
#define DAVIS640H_CONFIG_APS_TRANSFER 14
#define DAVIS640H_CONFIG_APS_RSFDSETTLE 15
#define DAVIS640H_CONFIG_APS_GSPDRESET 16
#define DAVIS640H_CONFIG_APS_GSRESETFALL 17
#define DAVIS640H_CONFIG_APS_GSTXFALL 18
#define DAVIS640H_CONFIG_APS_GSFDRESET 19

#define DAVIS_CONFIG_APS_SNAPSHOT 100

#define DAVIS_CONFIG_APS_AUTOEXPOSURE 101

enum caer_davis_aps_frame_modes {
    APS_FRAME_DEFAULT   = 0,
    APS_FRAME_GRAYSCALE = 1,
    APS_FRAME_ORIGINAL  = 2,
};

#define DAVIS_CONFIG_APS_FRAME_MODE 102

#define DAVIS_CONFIG_IMU_TYPE 0
#define DAVIS_CONFIG_IMU_ORIENTATION_INFO 1
#define DAVIS_CONFIG_IMU_RUN_ACCELEROMETER 2
#define DAVIS_CONFIG_IMU_RUN_GYROSCOPE 3
#define DAVIS_CONFIG_IMU_RUN_TEMPERATURE 4
#define DAVIS_CONFIG_IMU_SAMPLE_RATE_DIVIDER 5
#define DAVIS_CONFIG_IMU_ACCEL_DLPF              6
#define DAVIS_CONFIG_IMU_DIGITAL_LOW_PASS_FILTER DAVIS_CONFIG_IMU_ACCEL_DLPF
#define DAVIS_CONFIG_IMU_ACCEL_FULL_SCALE 7
#define DAVIS_CONFIG_IMU_GYRO_DLPF 9
#define DAVIS_CONFIG_IMU_GYRO_FULL_SCALE 10

#define DAVIS_CONFIG_EXTINPUT_RUN_DETECTOR 0
#define DAVIS_CONFIG_EXTINPUT_DETECT_RISING_EDGES 1
#define DAVIS_CONFIG_EXTINPUT_DETECT_FALLING_EDGES 2
#define DAVIS_CONFIG_EXTINPUT_DETECT_PULSES 3
#define DAVIS_CONFIG_EXTINPUT_DETECT_PULSE_POLARITY 4
#define DAVIS_CONFIG_EXTINPUT_DETECT_PULSE_LENGTH 5
#define DAVIS_CONFIG_EXTINPUT_HAS_GENERATOR 10
#define DAVIS_CONFIG_EXTINPUT_RUN_GENERATOR 11
#define DAVIS_CONFIG_EXTINPUT_GENERATE_PULSE_POLARITY 12
#define DAVIS_CONFIG_EXTINPUT_GENERATE_PULSE_INTERVAL 13
#define DAVIS_CONFIG_EXTINPUT_GENERATE_PULSE_LENGTH 14
#define DAVIS_CONFIG_EXTINPUT_GENERATE_INJECT_ON_RISING_EDGE 15
#define DAVIS_CONFIG_EXTINPUT_GENERATE_INJECT_ON_FALLING_EDGE 16

#define DAVIS_CONFIG_SYSINFO_LOGIC_VERSION 0
#define DAVIS_CONFIG_SYSINFO_CHIP_IDENTIFIER 1
#define DAVIS_CONFIG_SYSINFO_DEVICE_IS_MASTER 2
#define DAVIS_CONFIG_SYSINFO_LOGIC_CLOCK 3
#define DAVIS_CONFIG_SYSINFO_ADC_CLOCK 4
#define DAVIS_CONFIG_SYSINFO_USB_CLOCK 5
#define DAVIS_CONFIG_SYSINFO_CLOCK_DEVIATION 6
#define DAVIS_CONFIG_SYSINFO_LOGIC_PATCH 7

#define DAVIS_CONFIG_USB_RUN 0
#define DAVIS_CONFIG_USB_EARLY_PACKET_DELAY 1

#define DAVIS_CONFIG_DDRAER_RUN 0


#define DAVIS128_CONFIG_BIAS_APSOVERFLOWLEVEL 0
#define DAVIS128_CONFIG_BIAS_APSCAS           1
#define DAVIS128_CONFIG_BIAS_ADCREFHIGH       2
#define DAVIS128_CONFIG_BIAS_ADCREFLOW        3
#define DAVIS128_CONFIG_BIAS_LOCALBUFBN       8
#define DAVIS128_CONFIG_BIAS_PADFOLLBN        9
#define DAVIS128_CONFIG_BIAS_DIFFBN           10
#define DAVIS128_CONFIG_BIAS_ONBN             11
#define DAVIS128_CONFIG_BIAS_OFFBN            12
#define DAVIS128_CONFIG_BIAS_PIXINVBN         13
#define DAVIS128_CONFIG_BIAS_PRBP             14
#define DAVIS128_CONFIG_BIAS_PRSFBP           15
#define DAVIS128_CONFIG_BIAS_REFRBP           16
#define DAVIS128_CONFIG_BIAS_READOUTBUFBP     17
#define DAVIS128_CONFIG_BIAS_APSROSFBN        18
#define DAVIS128_CONFIG_BIAS_ADCCOMPBP        19
#define DAVIS128_CONFIG_BIAS_COLSELLOWBN      20
#define DAVIS128_CONFIG_BIAS_DACBUFBP         21
#define DAVIS128_CONFIG_BIAS_LCOLTIMEOUTBN    22
#define DAVIS128_CONFIG_BIAS_AEPDBN           23
#define DAVIS128_CONFIG_BIAS_AEPUXBP          24
#define DAVIS128_CONFIG_BIAS_AEPUYBP          25
#define DAVIS128_CONFIG_BIAS_IFREFRBN         26
#define DAVIS128_CONFIG_BIAS_IFTHRBN          27
#define DAVIS128_CONFIG_BIAS_BIASBUFFER       34
#define DAVIS128_CONFIG_BIAS_SSP              35
#define DAVIS128_CONFIG_BIAS_SSN              36


#define DAVIS128_CONFIG_CHIP_DIGITALMUX0       128
#define DAVIS128_CONFIG_CHIP_DIGITALMUX1       129
#define DAVIS128_CONFIG_CHIP_DIGITALMUX2       130
#define DAVIS128_CONFIG_CHIP_DIGITALMUX3       131
#define DAVIS128_CONFIG_CHIP_ANALOGMUX0        132
#define DAVIS128_CONFIG_CHIP_ANALOGMUX1        133
#define DAVIS128_CONFIG_CHIP_ANALOGMUX2        134
#define DAVIS128_CONFIG_CHIP_BIASMUX0          135
#define DAVIS128_CONFIG_CHIP_RESETCALIBNEURON  136
#define DAVIS128_CONFIG_CHIP_TYPENCALIBNEURON  137
#define DAVIS128_CONFIG_CHIP_RESETTESTPIXEL    138
#define DAVIS128_CONFIG_CHIP_AERNAROW          140
#define DAVIS128_CONFIG_CHIP_USEAOUT           141
#define DAVIS128_CONFIG_CHIP_GLOBAL_SHUTTER    142
#define DAVIS128_CONFIG_CHIP_SELECTGRAYCOUNTER 143


#define DAVIS208_CONFIG_BIAS_APSOVERFLOWLEVEL 0
#define DAVIS208_CONFIG_BIAS_APSCAS           1
#define DAVIS208_CONFIG_BIAS_ADCREFHIGH       2
#define DAVIS208_CONFIG_BIAS_ADCREFLOW        3
#define DAVIS208_CONFIG_BIAS_RESETHIGHPASS    6
#define DAVIS208_CONFIG_BIAS_REFSS            7
#define DAVIS208_CONFIG_BIAS_LOCALBUFBN       8
#define DAVIS208_CONFIG_BIAS_PADFOLLBN        9
#define DAVIS208_CONFIG_BIAS_DIFFBN           10
#define DAVIS208_CONFIG_BIAS_ONBN             11
#define DAVIS208_CONFIG_BIAS_OFFBN            12
#define DAVIS208_CONFIG_BIAS_PIXINVBN         13
#define DAVIS208_CONFIG_BIAS_PRBP             14
#define DAVIS208_CONFIG_BIAS_PRSFBP           15
#define DAVIS208_CONFIG_BIAS_REFRBP           16
#define DAVIS208_CONFIG_BIAS_READOUTBUFBP     17
#define DAVIS208_CONFIG_BIAS_APSROSFBN        18
#define DAVIS208_CONFIG_BIAS_ADCCOMPBP        19
#define DAVIS208_CONFIG_BIAS_COLSELLOWBN      20
#define DAVIS208_CONFIG_BIAS_DACBUFBP         21
#define DAVIS208_CONFIG_BIAS_LCOLTIMEOUTBN    22
#define DAVIS208_CONFIG_BIAS_AEPDBN           23
#define DAVIS208_CONFIG_BIAS_AEPUXBP          24
#define DAVIS208_CONFIG_BIAS_AEPUYBP          25
#define DAVIS208_CONFIG_BIAS_IFREFRBN         26
#define DAVIS208_CONFIG_BIAS_IFTHRBN          27
#define DAVIS208_CONFIG_BIAS_REGBIASBP        28
#define DAVIS208_CONFIG_BIAS_REFSSBN          30
#define DAVIS208_CONFIG_BIAS_BIASBUFFER       34
#define DAVIS208_CONFIG_BIAS_SSP              35
#define DAVIS208_CONFIG_BIAS_SSN              36


#define DAVIS208_CONFIG_CHIP_DIGITALMUX0       128
#define DAVIS208_CONFIG_CHIP_DIGITALMUX1       129
#define DAVIS208_CONFIG_CHIP_DIGITALMUX2       130
#define DAVIS208_CONFIG_CHIP_DIGITALMUX3       131
#define DAVIS208_CONFIG_CHIP_ANALOGMUX0        132
#define DAVIS208_CONFIG_CHIP_ANALOGMUX1        133
#define DAVIS208_CONFIG_CHIP_ANALOGMUX2        134
#define DAVIS208_CONFIG_CHIP_BIASMUX0          135
#define DAVIS208_CONFIG_CHIP_RESETCALIBNEURON  136
#define DAVIS208_CONFIG_CHIP_TYPENCALIBNEURON  137
#define DAVIS208_CONFIG_CHIP_RESETTESTPIXEL    138
#define DAVIS208_CONFIG_CHIP_AERNAROW          140
#define DAVIS208_CONFIG_CHIP_USEAOUT           141
#define DAVIS208_CONFIG_CHIP_GLOBAL_SHUTTER    142
#define DAVIS208_CONFIG_CHIP_SELECTGRAYCOUNTER 143
#define DAVIS208_CONFIG_CHIP_SELECTPREAMPAVG   145
#define DAVIS208_CONFIG_CHIP_SELECTBIASREFSS   146
#define DAVIS208_CONFIG_CHIP_SELECTSENSE       147
#define DAVIS208_CONFIG_CHIP_SELECTPOSFB       148
#define DAVIS208_CONFIG_CHIP_SELECTHIGHPASS    149


#define DAVIS240_CONFIG_BIAS_DIFFBN             0
#define DAVIS240_CONFIG_BIAS_ONBN               1
#define DAVIS240_CONFIG_BIAS_OFFBN              2
#define DAVIS240_CONFIG_BIAS_APSCASEPC          3
#define DAVIS240_CONFIG_BIAS_DIFFCASBNC         4
#define DAVIS240_CONFIG_BIAS_APSROSFBN          5
#define DAVIS240_CONFIG_BIAS_LOCALBUFBN         6
#define DAVIS240_CONFIG_BIAS_PIXINVBN           7
#define DAVIS240_CONFIG_BIAS_PRBP               8
#define DAVIS240_CONFIG_BIAS_PRSFBP             9
#define DAVIS240_CONFIG_BIAS_REFRBP             10
#define DAVIS240_CONFIG_BIAS_AEPDBN             11
#define DAVIS240_CONFIG_BIAS_LCOLTIMEOUTBN      12
#define DAVIS240_CONFIG_BIAS_AEPUXBP            13
#define DAVIS240_CONFIG_BIAS_AEPUYBP            14
#define DAVIS240_CONFIG_BIAS_IFTHRBN            15
#define DAVIS240_CONFIG_BIAS_IFREFRBN           16
#define DAVIS240_CONFIG_BIAS_PADFOLLBN          17
#define DAVIS240_CONFIG_BIAS_APSOVERFLOWLEVELBN 18
#define DAVIS240_CONFIG_BIAS_BIASBUFFER         19
#define DAVIS240_CONFIG_BIAS_SSP                20
#define DAVIS240_CONFIG_BIAS_SSN                21


#define DAVIS240_CONFIG_CHIP_DIGITALMUX0         128
#define DAVIS240_CONFIG_CHIP_DIGITALMUX1         129
#define DAVIS240_CONFIG_CHIP_DIGITALMUX2         130
#define DAVIS240_CONFIG_CHIP_DIGITALMUX3         131
#define DAVIS240_CONFIG_CHIP_ANALOGMUX0          132
#define DAVIS240_CONFIG_CHIP_ANALOGMUX1          133
#define DAVIS240_CONFIG_CHIP_ANALOGMUX2          134
#define DAVIS240_CONFIG_CHIP_BIASMUX0            135
#define DAVIS240_CONFIG_CHIP_RESETCALIBNEURON    136
#define DAVIS240_CONFIG_CHIP_TYPENCALIBNEURON    137
#define DAVIS240_CONFIG_CHIP_RESETTESTPIXEL      138
#define DAVIS240_CONFIG_CHIP_SPECIALPIXELCONTROL 139
#define DAVIS240_CONFIG_CHIP_AERNAROW            140
#define DAVIS240_CONFIG_CHIP_USEAOUT             141
#define DAVIS240_CONFIG_CHIP_GLOBAL_SHUTTER      142


#define DAVIS346_CONFIG_BIAS_APSOVERFLOWLEVEL 0
#define DAVIS346_CONFIG_BIAS_APSCAS           1
#define DAVIS346_CONFIG_BIAS_ADCREFHIGH       2
#define DAVIS346_CONFIG_BIAS_ADCREFLOW        3
#define DAVIS346_CONFIG_BIAS_ADCTESTVOLTAGE   4
#define DAVIS346_CONFIG_BIAS_LOCALBUFBN       8
#define DAVIS346_CONFIG_BIAS_PADFOLLBN        9
#define DAVIS346_CONFIG_BIAS_DIFFBN           10
#define DAVIS346_CONFIG_BIAS_ONBN             11
#define DAVIS346_CONFIG_BIAS_OFFBN            12
#define DAVIS346_CONFIG_BIAS_PIXINVBN         13
#define DAVIS346_CONFIG_BIAS_PRBP             14
#define DAVIS346_CONFIG_BIAS_PRSFBP           15
#define DAVIS346_CONFIG_BIAS_REFRBP           16
#define DAVIS346_CONFIG_BIAS_READOUTBUFBP     17
#define DAVIS346_CONFIG_BIAS_APSROSFBN        18
#define DAVIS346_CONFIG_BIAS_ADCCOMPBP        19
#define DAVIS346_CONFIG_BIAS_COLSELLOWBN      20
#define DAVIS346_CONFIG_BIAS_DACBUFBP         21
#define DAVIS346_CONFIG_BIAS_LCOLTIMEOUTBN    22
#define DAVIS346_CONFIG_BIAS_AEPDBN           23
#define DAVIS346_CONFIG_BIAS_AEPUXBP          24
#define DAVIS346_CONFIG_BIAS_AEPUYBP          25
#define DAVIS346_CONFIG_BIAS_IFREFRBN         26
#define DAVIS346_CONFIG_BIAS_IFTHRBN          27
#define DAVIS346_CONFIG_BIAS_BIASBUFFER       34
#define DAVIS346_CONFIG_BIAS_SSP              35
#define DAVIS346_CONFIG_BIAS_SSN              36


#define DAVIS346_CONFIG_CHIP_DIGITALMUX0       128
#define DAVIS346_CONFIG_CHIP_DIGITALMUX1       129
#define DAVIS346_CONFIG_CHIP_DIGITALMUX2       130
#define DAVIS346_CONFIG_CHIP_DIGITALMUX3       131
#define DAVIS346_CONFIG_CHIP_ANALOGMUX0        132
#define DAVIS346_CONFIG_CHIP_ANALOGMUX1        133
#define DAVIS346_CONFIG_CHIP_ANALOGMUX2        134
#define DAVIS346_CONFIG_CHIP_BIASMUX0          135
#define DAVIS346_CONFIG_CHIP_RESETCALIBNEURON  136
#define DAVIS346_CONFIG_CHIP_TYPENCALIBNEURON  137
#define DAVIS346_CONFIG_CHIP_RESETTESTPIXEL    138
#define DAVIS346_CONFIG_CHIP_AERNAROW          140
#define DAVIS346_CONFIG_CHIP_USEAOUT           141
#define DAVIS346_CONFIG_CHIP_GLOBAL_SHUTTER    142
#define DAVIS346_CONFIG_CHIP_SELECTGRAYCOUNTER 143
#define DAVIS346_CONFIG_CHIP_TESTADC           144


#define DAVIS640_CONFIG_BIAS_APSOVERFLOWLEVEL 0
#define DAVIS640_CONFIG_BIAS_APSCAS           1
#define DAVIS640_CONFIG_BIAS_ADCREFHIGH       2
#define DAVIS640_CONFIG_BIAS_ADCREFLOW        3
#define DAVIS640_CONFIG_BIAS_ADCTESTVOLTAGE   4
#define DAVIS640_CONFIG_BIAS_LOCALBUFBN       8
#define DAVIS640_CONFIG_BIAS_PADFOLLBN        9
#define DAVIS640_CONFIG_BIAS_DIFFBN           10
#define DAVIS640_CONFIG_BIAS_ONBN             11
#define DAVIS640_CONFIG_BIAS_OFFBN            12
#define DAVIS640_CONFIG_BIAS_PIXINVBN         13
#define DAVIS640_CONFIG_BIAS_PRBP             14
#define DAVIS640_CONFIG_BIAS_PRSFBP           15
#define DAVIS640_CONFIG_BIAS_REFRBP           16
#define DAVIS640_CONFIG_BIAS_READOUTBUFBP     17
#define DAVIS640_CONFIG_BIAS_APSROSFBN        18
#define DAVIS640_CONFIG_BIAS_ADCCOMPBP        19
#define DAVIS640_CONFIG_BIAS_COLSELLOWBN      20
#define DAVIS640_CONFIG_BIAS_DACBUFBP         21
#define DAVIS640_CONFIG_BIAS_LCOLTIMEOUTBN    22
#define DAVIS640_CONFIG_BIAS_AEPDBN           23
#define DAVIS640_CONFIG_BIAS_AEPUXBP          24
#define DAVIS640_CONFIG_BIAS_AEPUYBP          25
#define DAVIS640_CONFIG_BIAS_IFREFRBN         26
#define DAVIS640_CONFIG_BIAS_IFTHRBN          27
#define DAVIS640_CONFIG_BIAS_BIASBUFFER       34
#define DAVIS640_CONFIG_BIAS_SSP              35
#define DAVIS640_CONFIG_BIAS_SSN              36


#define DAVIS640_CONFIG_CHIP_DIGITALMUX0       128
#define DAVIS640_CONFIG_CHIP_DIGITALMUX1       129
#define DAVIS640_CONFIG_CHIP_DIGITALMUX2       130
#define DAVIS640_CONFIG_CHIP_DIGITALMUX3       131
#define DAVIS640_CONFIG_CHIP_ANALOGMUX0        132
#define DAVIS640_CONFIG_CHIP_ANALOGMUX1        133
#define DAVIS640_CONFIG_CHIP_ANALOGMUX2        134
#define DAVIS640_CONFIG_CHIP_BIASMUX0          135
#define DAVIS640_CONFIG_CHIP_RESETCALIBNEURON  136
#define DAVIS640_CONFIG_CHIP_TYPENCALIBNEURON  137
#define DAVIS640_CONFIG_CHIP_RESETTESTPIXEL    138
#define DAVIS640_CONFIG_CHIP_AERNAROW          140
#define DAVIS640_CONFIG_CHIP_USEAOUT           141
#define DAVIS640_CONFIG_CHIP_GLOBAL_SHUTTER    142
#define DAVIS640_CONFIG_CHIP_SELECTGRAYCOUNTER 143
#define DAVIS640_CONFIG_CHIP_TESTADC           144


#define DAVIS640H_CONFIG_BIAS_APSCAS             0
#define DAVIS640H_CONFIG_BIAS_OVG1LO             1
#define DAVIS640H_CONFIG_BIAS_OVG2LO             2
#define DAVIS640H_CONFIG_BIAS_TX2OVG2HI          3
#define DAVIS640H_CONFIG_BIAS_GND07              4
#define DAVIS640H_CONFIG_BIAS_ADCTESTVOLTAGE     5
#define DAVIS640H_CONFIG_BIAS_ADCREFHIGH         6
#define DAVIS640H_CONFIG_BIAS_ADCREFLOW          7
#define DAVIS640H_CONFIG_BIAS_IFREFRBN           8
#define DAVIS640H_CONFIG_BIAS_IFTHRBN            9
#define DAVIS640H_CONFIG_BIAS_LOCALBUFBN         10
#define DAVIS640H_CONFIG_BIAS_PADFOLLBN          11
#define DAVIS640H_CONFIG_BIAS_PIXINVBN           13
#define DAVIS640H_CONFIG_BIAS_DIFFBN             14
#define DAVIS640H_CONFIG_BIAS_ONBN               15
#define DAVIS640H_CONFIG_BIAS_OFFBN              16
#define DAVIS640H_CONFIG_BIAS_PRBP               17
#define DAVIS640H_CONFIG_BIAS_PRSFBP             18
#define DAVIS640H_CONFIG_BIAS_REFRBP             19
#define DAVIS640H_CONFIG_BIAS_ARRAYBIASBUFFERBN  20
#define DAVIS640H_CONFIG_BIAS_ARRAYLOGICBUFFERBN 22
#define DAVIS640H_CONFIG_BIAS_FALLTIMEBN         23
#define DAVIS640H_CONFIG_BIAS_RISETIMEBP         24
#define DAVIS640H_CONFIG_BIAS_READOUTBUFBP       25
#define DAVIS640H_CONFIG_BIAS_APSROSFBN          26
#define DAVIS640H_CONFIG_BIAS_ADCCOMPBP          27
#define DAVIS640H_CONFIG_BIAS_DACBUFBP           28
#define DAVIS640H_CONFIG_BIAS_LCOLTIMEOUTBN      30
#define DAVIS640H_CONFIG_BIAS_AEPDBN             31
#define DAVIS640H_CONFIG_BIAS_AEPUXBP            32
#define DAVIS640H_CONFIG_BIAS_AEPUYBP            33
#define DAVIS640H_CONFIG_BIAS_BIASBUFFER         34
#define DAVIS640H_CONFIG_BIAS_SSP                35
#define DAVIS640H_CONFIG_BIAS_SSN                36


#define DAVIS640H_CONFIG_CHIP_DIGITALMUX0       128
#define DAVIS640H_CONFIG_CHIP_DIGITALMUX1       129
#define DAVIS640H_CONFIG_CHIP_DIGITALMUX2       130
#define DAVIS640H_CONFIG_CHIP_DIGITALMUX3       131
#define DAVIS640H_CONFIG_CHIP_ANALOGMUX0        132
#define DAVIS640H_CONFIG_CHIP_ANALOGMUX1        133
#define DAVIS640H_CONFIG_CHIP_ANALOGMUX2        134
#define DAVIS640H_CONFIG_CHIP_BIASMUX0          135
#define DAVIS640H_CONFIG_CHIP_RESETCALIBNEURON  136
#define DAVIS640H_CONFIG_CHIP_TYPENCALIBNEURON  137
#define DAVIS640H_CONFIG_CHIP_RESETTESTPIXEL    138
#define DAVIS640H_CONFIG_CHIP_AERNAROW          140
#define DAVIS640H_CONFIG_CHIP_USEAOUT           141
#define DAVIS640H_CONFIG_CHIP_SELECTGRAYCOUNTER 143
#define DAVIS640H_CONFIG_CHIP_TESTADC           144
#define DAVIS640H_CONFIG_CHIP_ADJUSTOVG1LO      145
#define DAVIS640H_CONFIG_CHIP_ADJUSTOVG2LO      146
#define DAVIS640H_CONFIG_CHIP_ADJUSTTX2OVG2HI   147

struct caer_davis_info {
    int16_t deviceID;
    char deviceSerialNumber[8 + 1];
    uint8_t deviceUSBBusNumber;
    uint8_t deviceUSBDeviceAddress;
    char *deviceString;
    int16_t firmwareVersion;
    int16_t logicVersion;
    int16_t chipID;
    bool deviceIsMaster;
    bool muxHasStatistics;
    int16_t dvsSizeX;
    int16_t dvsSizeY;
    bool dvsHasPixelFilter;
    bool dvsHasBackgroundActivityFilter;
    bool dvsHasROIFilter;
    bool dvsHasSkipFilter;
    bool dvsHasPolarityFilter;
    bool dvsHasStatistics;
    int16_t apsSizeX;
    int16_t apsSizeY;
    enum caer_frame_event_color_filter apsColorFilter;
    bool apsHasGlobalShutter;
    enum caer_imu_types imuType;
    bool extInputHasGenerator;
};

LIBRARY_PUBLIC_VISIBILITY struct caer_davis_info caerDavisInfoGet(caerDeviceHandle handle);

struct caer_bias_vdac {
    uint8_t voltageValue;
    uint8_t currentValue;
};

LIBRARY_PUBLIC_VISIBILITY uint16_t caerBiasVDACGenerate(const struct caer_bias_vdac vdacBias);

LIBRARY_PUBLIC_VISIBILITY struct caer_bias_vdac caerBiasVDACParse(const uint16_t vdacBias);

struct caer_bias_coarsefine {
    uint8_t coarseValue;
    uint8_t fineValue;
    bool enabled;
    bool sexN;
    bool typeNormal;
    bool currentLevelNormal;
};

LIBRARY_PUBLIC_VISIBILITY uint16_t caerBiasCoarseFineGenerate(const struct caer_bias_coarsefine coarseFineBias);

LIBRARY_PUBLIC_VISIBILITY struct caer_bias_coarsefine caerBiasCoarseFineParse(const uint16_t coarseFineBias);

LIBRARY_PUBLIC_VISIBILITY struct caer_bias_coarsefine caerBiasCoarseFineFromCurrent(uint32_t picoAmps);

LIBRARY_PUBLIC_VISIBILITY uint32_t caerBiasCoarseFineToCurrent(struct caer_bias_coarsefine coarseFineBias);

enum caer_bias_shiftedsource_operating_mode {
    SHIFTED_SOURCE = 0,
    HI_Z = 1,
    TIED_TO_RAIL = 2,
};

enum caer_bias_shiftedsource_voltage_level {
    SPLIT_GATE = 0,
    SINGLE_DIODE = 1,
    DOUBLE_DIODE = 2,
};

struct caer_bias_shiftedsource {
    uint8_t refValue;
    uint8_t regValue;
    enum caer_bias_shiftedsource_operating_mode operatingMode;
    enum caer_bias_shiftedsource_voltage_level voltageLevel;
};

LIBRARY_PUBLIC_VISIBILITY uint16_t caerBiasShiftedSourceGenerate(
    const struct caer_bias_shiftedsource shiftedSourceBias);

LIBRARY_PUBLIC_VISIBILITY struct caer_bias_shiftedsource caerBiasShiftedSourceParse(const uint16_t shiftedSourceBias);

LIBRARY_PUBLIC_VISIBILITY bool caerDavisROIConfigure(
    caerDeviceHandle handle, uint16_t startX, uint16_t startY, uint16_t endX, uint16_t endY);

#ifdef __cplusplus
}
#endif

#endif /* LIBCAER_DEVICES_DAVIS_H_ */