epc660_ll

The following API has been generated from the header file epc660_ll.h. It contains the low level API for the epc660 sensor.

enum epc660_ll_sequencer

Updatable sequencers.

Values:

enumerator EPC660_LL_SEQUENCER_PIXEL
enumerator EPC660_LL_SEQUENCER_TCMI
enum epc660_ll_mod_clk_source

Modulation clock source.

Values:

enumerator EPC660_LL_MOD_CLK_INTERN
enumerator EPC660_LL_MOD_CLK_EXTERN
enum epc660_ll_led_ctrl_set_flags

Configuration one-hot encoded flags used in epc660_ll_led_ctrl_set()

Values:

enumerator EPC660_LL_LED_ENABLE

Enable the LED control output.

enumerator EPC660_LL_LED2_ENABLE

Enable the LED2 control output.

enumerator EPC660_LL_LED_FORCE_ON

Force the led control outputs, permanently active outputs.

enumerator EPC660_LL_LED_INVERTED

Sets LED outputs to active low.

enum epc660_ll_temp_sensor

Temperature Sensors present on the corners of the pixel field.

Values:

enumerator EPC660_LL_TEMP_TL
enumerator EPC660_LL_TEMP_TR
enumerator EPC660_LL_TEMP_BL
enumerator EPC660_LL_TEMP_BR
enum epc660_ll_tcmi_format

TCMI data transmission format. Uset epc660_ll_tcmi_format_set()

Values:

enumerator EPC660_LL_TCMI_FORMAT_12BIT
enumerator EPC660_LL_TCMI_FORMAT_8BIT
enumerator EPC660_LL_TCMI_FORMAT_12BIT_lsb_msb

8-Bit x2 per 2 DCLK cycle (LSB, MSB): 1st DCLK: sample[7..0] -> DATA[7..0] 2nd DCLK:: sample[11..8] -> DATA[3..0]

enumerator EPC660_LL_TCMI_FORMAT_12BIT_msb_lsb

8-Bit x2 per 2 DCLK cycle (MSB, LSB): 1st DCLK:: sample[11..8] -> DATA[3..0] 2nd DCLK: sample[7..0] -> DATA[7..0]

enum epc660_ll_tcmi_sync_output

One-hot encoded configurable TCMI synchronisation outputs.

Values:

enumerator EPC660_LL_TCMI_OUTPUT_HSYNC
enumerator EPC660_LL_TCMI_OUTPUT_VSYNC
enumerator EPC660_LL_TCMI_OUTPUT_XSYNC
enum epc660_ll_modulation_mode

Modulation modes used in epc660_ll_modulation_mode_set()

Values:

enumerator EPC660_LL_MODULATION_MODE_CWTOF
enumerator EPC660_LL_MODULATION_MODE_GRAYSCALE
enum epc660_ll_sensing_mode

ADC sensing mode. Use epc660_ll_sensing_mode_set()

Values:

enumerator EPC660_LL_SENSING_MODE_NORMAL
enumerator EPC660_LL_SENSING_MODE_TEMPERATURE
enum epc660_ll_dcs_sel

Number of frames triggered by a shutter.

Values:

enumerator EPC660_LL_DCS_SEL_1X
enumerator EPC660_LL_DCS_SEL_2X
enumerator EPC660_LL_DCS_SEL_4X
enum epc660_ll_modulation_gate

Configurable modulation gates.

Values:

enumerator EPC660_LL_MOD_GATE_0

Default modulation gate in use

enumerator EPC660_LL_MOD_GATE_1

Alternative modulation gate only applied for dual modulation and dual integration

enum epc660_ll_modulation_phase

Supported demodulation phases relative to the modulation.

Values:

enumerator EPC660_LL_MOD_PHASE_000

Phase used for DCS0

enumerator EPC660_LL_MOD_PHASE_090

Phase used for DCS1

enumerator EPC660_LL_MOD_PHASE_180

Phase used for DCS2

enumerator EPC660_LL_MOD_PHASE_270

Phase used for DCS3

enum epc660_ll_frame

Configurable frames/DCS.

Values:

enumerator EPC660_LL_FRAME_1ST
enumerator EPC660_LL_FRAME_2ND
enumerator EPC660_LL_FRAME_3RD
enumerator EPC660_LL_FRAME_4TH
enumerator EPC660_LL_FRAME_GRAYSCALE
enum epc660_ll_led_modulation

By frame/DCS configurable LED modulations during integration.

Values:

enumerator EPC660_LL_LED_MODULATED
enumerator EPC660_LL_LED_OFF
enumerator EPC660_LL_LED_ON
enum epc660_ll_readout_mode

By frame configurable pixel readout mode.

Values:

enumerator EPC660_LL_READOUT_DIFFERENTIAL_WO_ABS
enumerator EPC660_LL_READOUT_SINGLE_ENDED_SGA
enumerator EPC660_LL_READOUT_DIFFERENTIAL_W_ABS
enum epc660_ll_dll_ctrl

Settings for delay locked loop used to delay the LED modulation.

Values:

enumerator EPC660_LL_DLL_BYPASS
enumerator EPC660_LL_DLL_MANUAL
int epc660_ll_video_start(const struct epc660_ll *epc660, bool continuous)

Sends a shutter signal to the sensor over I2C.

Parameters:
  • epc660 – [in] epc660 instance

  • continuous – [in] if set to true, the sensor will start continuous video mode, otherwise single shutter mode

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_video_stop(const struct epc660_ll *epc660)

Stops continuous shutter signal to the sensor over I2C.

Parameters:

epc660 – [in] epc660 instance

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_sensing_mode_set(const struct epc660_ll *epc660, enum epc660_ll_sensing_mode mode)

Set the epc660 sensing mode.

Parameters:
Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_modulation_mode_set(const struct epc660_ll *epc660, enum epc660_ll_modulation_mode mode)

Set the modulation mode of the epc660.

Parameters:
Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_video_dcs_sel_set(const struct epc660_ll *epc660, enum epc660_ll_dcs_sel dcs_sel)

Set the number of dcs triggered by a single shutter.

Parameters:
  • epc660 – [in] epc660 instance

  • dcs_sel – [in] Number of DCS triggered by a shutter

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_frame_cfg_modulation_phase_set(const struct epc660_ll *epc660, uint16_t frames, enum epc660_ll_modulation_gate gate, enum epc660_ll_modulation_phase phase)

Set the demodulation phase shift of a gate.

Parameters:
  • epc660 – [in] epc660 instance

  • frames – [in] combination of epc660_ll_frame to be configured excluding EPC660_LL_FRAME_GRAYSCALE

  • gate – [in] demodulation gate to be configured

  • phase – [in] demodulation phase shift to modulation

Returns:

int

int epc660_ll_frame_cfg_readout_mode_set(const struct epc660_ll *epc660, uint16_t frames, enum epc660_ll_readout_mode ro_mode)

Set the readout mode.

Parameters:
  • epc660 – [in] epc660 instance

  • frames – [in] combination of epc660_ll_frame to be configured

  • ro_mode – [in] pixel readout mode.

Returns:

int

int epc660_ll_frame_cfg_led_modulation_set(const struct epc660_ll *epc660, uint16_t frames, enum epc660_ll_led_modulation led_mod)

Set the LED modulation mode.

Parameters:
  • epc660 – [in] epc660 instance

  • frames – [in] combination of epc660_ll_frame to be configured

  • led_mod – [in] LED modulation

Returns:

int

int epc660_ll_roi_set(const struct epc660_ll *epc660, uint16_t x0, uint8_t y0, uint16_t x1, uint8_t y1)

Set the region of interest of the top pixel field half.

E.g valid : x0 - 36, y0 - 16, x1 = 77, y1 = 105

For more information refer to datasheet.

Parameters:
  • epc660 – [in] epc660 instance

  • x0 – [in] lowest column idx in roi. See details

  • y0 – [in] lowest row idx in roi. See details

  • x1 – [in] highest column idx in roi. See details

  • y1 – [in] highest pixel idx in roi. See details

Returns:

int

  • -EPC_ERR_OUT_OF_BOUNDS

    • x0 is not in [4,318] or

    • y0 is not in [6,124] or

    • x1 is not in [9,323] or

    • y1 is not in [7,125]

  • -EPC_ERR_RESULTS_IN_ILLEGAL_STATE

    • x0 is not even or

    • y0 is not even or

    • x1 is not odd or

    • y1 is not odd or

    • x0 is greater x1 or

    • y0 is greater y1 or

    • Horizontal range does not respect divisibility rule. See details or

    • Vertical range does not respect divisibility rule. See details

  • Otherwise

The ROI allows to reduce the amount of pixel which are read out and transmitted, increasing frame rate or focusing if needed. Because of the architechture the ROI is only set for the top half of the QVGA resolution. The bottom ROI will be symmetric to the top ROI. Additionally the possible ROI’s are restricted by the architecture:
  • Vertical ROI can only be read in fixed groups of 2 with the start value being even and end value being odd. For normal operations the height requires to be divisible by 2

  • Horizontal ROI can only be read in fixed groups of 6 with the start value being even and end value being odd. For normal operations the width requires to be divisible by 6

int epc660_ll_temp_sensor_calib_get(const struct epc660_ll *epc660, enum epc660_ll_temp_sensor sensor, struct epc660_ll_temp_sensor_calib *calib)

Get the epc660 temperature sensor calibration data from specified sensor.

Parameters:
  • epc660 – [in] epc660 instance

  • sensor – [in] Index of the sensor from which to grab the calibration data

  • calib – [out] pointer to calibration data of temperature sensor

    • 1 Offset is not calibrated therfore a default value is used

Returns:

int

Additional info at epc660_ll_temp_sensor_calib struct and epc660_ll_temp_sensor_get()

int epc660_ll_temp_sensor_get(const struct epc660_ll *epc660, enum epc660_ll_temp_sensor sensor, const struct epc660_ll_temp_sensor_calib *calib, int16_t *temp_sensor_cC)

Get the epc660 temperature from specified sensor.

Parameters:
  • epc660 – [in] epc660 instance

  • sensor – [in] temperature sensor from which to grab the data

  • calib – [in] pointer to calibration data of temperature sensor aquired by epc660_ll_temp_sensor_calib_get

  • temp_sensor_cC – [out] Latest temperature reading in centi-degrees Celsius (°C × 100). Divide by 100 to obtain the temperature in °C.

Returns:

int

int epc660_ll_update_sequencer(const struct epc660_ll *epc660, const struct epc660_ll_sequencer_program *sequencer_program)

update readout sequencer with the given entries

Parameters:
  • epc660 – [in] epc660 instance

  • sequencer_program – [in] epc660 sequencer program struct

Returns:

int

int epc660_ll_demodulation_delay_set(const struct epc660_ll *epc660, uint8_t delay_clk)

Set the demodulation delay applied to pixel control signals(mg0, mg1, …)

Parameters:
  • epc660 – [in] epc660 instance

  • delay_clk – [in] delay in number of pll_clk cycles

Returns:

int

int epc660_ll_modulation_clk_src_set(const struct epc660_ll *epc660, enum epc660_ll_mod_clk_source clk_src)

Set the modulation clock source.

Parameters:
  • epc660 – [in] epc660 instance

  • clk_src – [in] Clock source

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_modulation_clk_div_set(const struct epc660_ll *epc660, uint8_t clk_div)

Set the modulation clock divider.

Parameters:
  • epc660 – [in] epc660 instance

  • clk_div – [in] Clock divider

Returns:

int

int epc660_ll_modulation_clk_div_get(const struct epc660_ll *epc660, uint8_t *clk_div)

Get the modulation clock divider.

Parameters:
  • epc660 – [in] epc660 instance

  • clk_div – [out] Current clock divider

Returns:

int

int epc660_ll_tcmi_clk_div_set(const struct epc660_ll *epc660, uint8_t clk_div)

Set the tcmi clock divider.

Parameters:
  • epc660 – [in] epc660 instance

  • clk_div – [in] Clock divider

Returns:

int

int epc660_ll_integration_time_set(const struct epc660_ll *epc660, uint32_t mod_freq_hz, uint32_t int_us)

Set total integration length.

The passed integration time is converted to a total period count which, in turn, is divded into the two factors. The repetition count is minimized to reduce noise related to the repetition. Therefore the register values are conditionally calculated:

\[\begin{split} \begin{array}{rrl} N_T &= &t_{int}*f_{mod}\\ INT_M &:= &\text{Repetitions}\\ INT_N &:= &\text{Base Length}\\ INT_M(N_T)&=&\left\{\begin{array}{ll} INT_M=\left\lfloor\frac{N_T}{0x10000}\right\rfloor+1 &: \ N_T \gt 0x10000 \\ INT_M=1 &: \ N_T \leq 0x10000 \\ \end{array}\right .\\ INT_N(N_T)&=&\left\{\begin{array}{ll} INT_N=\left\lfloor\frac{N_T}{INT_M}\right\rfloor-1 &: \ N_T \gt 0x10000 \\ INT_N=N_T - 1 &: \ N_T \leq 0x10000 \end{array}\right . \end{array} \end{split}\]

Parameters:
  • epc660 – [in] epc660 instance

  • mod_freq_hz – [in] modulation frequency used for calulcation in Hz

  • int_us – [in] integration length in us

Returns:

int

int epc660_ll_integration_time_get(const struct epc660_ll *epc660, uint32_t mod_freq_hz, uint32_t *int_us)

Get total integration length.

Parameters:
  • epc660 – [in] epc660 instance

  • mod_freq_hz – [in] modulation frequency used for calulcation in Hz

  • int_us – [out] integration length in us

Returns:

int

int epc660_ll_tcmi_format_set(const struct epc660_ll *epc660, enum epc660_ll_tcmi_format format)

Select the TCMI transmission format.

Parameters:
  • epc660 – [in] epc660 instance

  • format – [in] TCMI output format

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_tcmi_polarity_set(const struct epc660_ll *epc660, uint8_t tcmi_outputs)

Select the TCMI sync-signals active polarity.

Parameters:
  • epc660 – [in] epc660 instance

  • tcmi_outputs – [in] Combination of epc660_ll_tcmi_sync_output enum to be set to active high. Others will be set active low.

Returns:

int

int epc660_ll_tcmi_polarity_get(const struct epc660_ll *epc660, uint8_t *tcmi_outputs)

Get the current TCMI sync-signals polarity.

Parameters:
Returns:

int

int epc660_ll_tcmi_sample_edge_set(const struct epc660_ll *epc660, bool rising)

Select the TCMI data clock edge at which the outputs are aligned.

Parameters:
  • epc660 – [in] epc660 instance

  • rising – [in] true - Align on rising edge; false - Align on falling edge

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_dll_ctrl_set(const struct epc660_ll *epc660, enum epc660_ll_dll_ctrl ctrl)

Select delay locked loop operation.

Parameters:
  • epc660 – [in] epc660 instance.

  • ctrl – [in] DLL operation

Returns:

int — See epc660_ll::i2c_write()

int epc660_ll_dll_coarse_set(const struct epc660_ll *epc660, uint8_t coarse_step)

Set the manual DLL coarse delay steps.

Parameters:
  • epc660 – [in] epc660 instance

  • coarse_step – [in] Coarse delay steps to be applied on LED output signal(s)

Returns:

int

int epc660_ll_led_ctrl_set(const struct epc660_ll *epc660, uint8_t ctrl_flags)

Set the LED configuration.

Parameters:
Returns:

int

int epc660_ll_led_ctrl_get(const struct epc660_ll *epc660, uint8_t *ctrl_flags)

Get the current led configuration.

Parameters:
Returns:

int — See epc660_ll::i2c_read()

int epc660_ll_ic_informations_get(const struct epc660_ll *epc660, struct epc660_ll_ic_information *info)

Get the information stored on sensor chip.

Parameters:
  • epc660 – [in] epc660 instance

  • info – [out] buffer for IC information

Returns:

int

static int epc660_ll_calc_int_time_reg(uint32_t int_us, uint32_t mod_freq_hz, uint8_t *reg_values)

private helper function used to convert an integration time to register values

Since the epc660 chip does not feature an internal measurement of the modulation clock frequency it only stores an amount of steps to do. The resulting integration times are dependend on the modulation clock frequency and the two integration time register. The integration lenght gets repated as many times as set in the integration time multiplier.

\[\begin{split} \begin{array}{rll} M & = M_{Hi}*2^8+M_{Lo} & := \text{Integration Multiplier} \\ N & = N_{Hi}*2^8+N_{Lo} + 1 & := \text{Integration Length} \\ t_{int} & = \dfrac{M*N}{f_{mod}} & \\ \end{array} \end{split}\]

Following limit of integration time in dependence or modulation frequency:

\[\begin{split} \begin{array}{rll} t_{int,MIN}(f_{mod}) & = \dfrac{M_{MIN}*N_{MIN}}{f_{mod}} & = \dfrac{0001_{16}*0008_{16}}{f_{mod}} \\ t_{int,MAX}(f_{mod}) & = \dfrac{M_{MAX}*N_{MAX}}{f_{mod}} & = \dfrac{3FF_{16}*10000_{16}}{f_{mod}} \\ \end{array} \end{split}\]

Parameters:
  • int_us – [in] integration time in us

  • mod_freq_hz – [in] modulation frequency used for calulcation

  • reg_values – [out] buffer for register values:

    • reg_values[0] : M_Hi

    • reg_values[1] : M_Lo

    • reg_values[2] : L_Hi

    • reg_values[3] : L_Lo

Returns:

int

static int epc660_ll_calc_reg_int_time(const uint8_t *reg_values, uint32_t mod_freq_hz, uint32_t *int_us)

private helper function to convert the register values to integration time

Computes the integration time in us from the register values. The reverse computation of epc660_ll_calc_int_time_reg(). For values of \(f_{mod} < 15.6\ kHz\) the resulting integration time may exceed \(2^{32}-1\ \mu s\) which would lead to an overflow. Therefore error is returned rather than a nonsensical value.

Parameters:
  • reg_values – [in] Integration Register values.

    • reg_values[0] : M_Hi

    • reg_values[1] : M_Lo

    • reg_values[2] : N_Hi

    • reg_values[3] : N_Lo

  • mod_freq_hz – [in] modulation frequency used for calulcation

  • int_us – [out] integration time in us

Returns:

int

EPC660_LL_ROI_MAX_WIDTH 320
EPC660_LL_ROI_MAX_HEIGHT 240
struct epc660_ll

Structure containing device and functions that need to be provided by user.

Public Members

const struct i2cdevice *i2c_device
i2c_read_reg_t i2c_read
i2c_write_reg_t i2c_write
struct epc660_ll_temp_sensor_calib

Temperature sensor calibration data.

The offset and gain are scaled to be able to prevent floating point arithmetic as it should be avoided in linux kernel drivers.

Public Members

int32_t offset_x1e5

Offset correction in 1e-5 C°

struct epc660_ll_sequence_entry

Structure of a sequencer program line entry.

Public Members

const uint8_t address
const uint8_t values[8]
struct epc660_ll_sequencer_program

Structure of a full sequencer program.

Public Members

enum epc660_ll_sequencer sequencer
const struct epc660_ll_sequence_entry *entries
const size_t num_entries
struct epc660_ll_ic_information

Container for information about sensor chip acquired with epc660_ll_ic_informations_get()

Public Members

uint8_t ic_type
uint8_t ic_version
uint16_t wafer_id
uint16_t chip_id
uint8_t part_type
uint8_t part_version