Hardware Abstraction Layer (HAL)

Overview

The ESPROS Hardware Abstraction Layer (HAL) provides platform-independent, low-level C APIs for ESPROS ToF sensors. It encapsulates sensor register access behind a small set of device-specific functions that can be integrated into custom applications, embedded firmware, or Linux drivers.

From the integration side, only a platform-specific I2C interface must be provided by the user. This allows the HAL to be reused across different operating systems and hardware platforms while keeping the sensor control logic consistent.

Architecture

HAL Scope

Most image sensors use two communication paths:

  1. A bidirectional control interface for sensor configuration and status access, such as I2C or SPI.

  2. A high-speed unidirectional data interface for image transfer, such as MIPI CSI or a parallel video bus.

The HAL focuses on the control path. It provides access to configuration, status and shutter control while frame acquisition and transport remain the responsibility of the surrounding driver or application.

Setup Guide

The ESPROS HAL defines one epcxxx_ll structure per supported sensor. The following example uses epc670, but the same pattern applies to the other supported devices.

Sensor context structure
#include "epc670_ll.h"

struct epc670_ll {
    const struct i2cdevice *i2c_device;
    i2c_read_reg_t i2c_read;
    i2c_write_reg_t i2c_write;
};

To integrate the HAL, implement the platform-specific I2C callbacks and assign them to the sensor instance:

Initialization example
static int i2c_read_reg(const struct i2cdevice *i2c_device, u8 reg, u8 *data)
{
    /* platform-specific I2C register read implementation */
}

static int i2c_write_reg(const struct i2cdevice *i2c_device, u8 reg, const u8 *data, u8 num_bytes)
{
    /* platform-specific I2C register write implementation */
}

struct epc670_ll sensor;

sensor.i2c_device = (const struct i2cdevice *)i2cDevice;
sensor.i2c_read = i2c_read_reg;
sensor.i2c_write = i2c_write_reg;

The i2c_device object can be used to pass a platform-specific I2C handle to the callback functions. If no such handle is needed, it can be set to NULL.

Once initialized, the HAL API can be used directly:

Example API usage
struct epc670_ll_ic_information info;
epc670_ll_ic_informations_get(&sensor, &info);
printf("IC-Type %d, IC-Version %d\n", info.ic_type, info.ic_version);

API Reference