IMX500 MCU SDK
API reference for the Arducam IMX500 MCU SDK
Loading...
Searching...
No Matches
ArducamIMX500SDK.h File Reference

Public API for integrating IMX500 modules on MCU platforms. More...

#include "ai_regs.h"
#include "common_regs.h"
#include "ai_driver.h"
#include "stdint.h"
#include "stdbool.h"
#include "stdlib.h"
#include "ApParams.h"

Go to the source code of this file.

Data Structures

struct  BBox
 Detection bounding box in absolute image coordinates. More...
struct  DetectionResult
struct  imx500_ae_config_t
 Auto-exposure configuration to be applied to the sensor. More...
struct  imx500_crop_rect_t
 Crop rectangle in absolute sensor coordinates, using [xmin, xmax) and [ymin, ymax). More...
struct  imx500_roi_t
struct  imx500_white_balance_config_t
 White balance configuration to be applied to the sensor. More...
struct  IMX500OutputHeader
 Decoded 12-byte metadata header emitted by the IMX500 output stream. More...
 Parsed metadata payload with JPEG and output tensor offsets. More...
struct  IMX500ParsedNetwork
 Parsed network description including input and output tensors. More...
struct  IMX500ParsedTensor
 Parsed tensor descriptor plus bound tensor payload pointer. More...
struct  IMX500TensorDimension
struct  QuantParam
struct  sc_dnn_nw_info_t
struct  sc_input_tensor_rgb_norm_info_t
struct  sc_output_tensor_size_info_t
struct  spi_flash_status_t
 Summary of a model or network-info flash write request. More...

Macros

#define IMX500_FW_TYPE_LOADER   0
#define IMX500_FW_TYPE_MAIN   1
#define IMX500_FW_TYPE_NETWORK_WEIGHTS   2
#define IMX500_HEADER_LEN   12
#define IMX500_MAX_INPUT_TENSORS   8
#define IMX500_MAX_NETWORKS   MAX_NUM_OF_NETWORKS
#define IMX500_MAX_OUTPUT_TENSORS   MAX_OUTPUT_TENSOR_NUM
#define IMX500_MAX_TENSOR_DIMS   8
#define MAX_DETECT_ITEM_NUM   10
#define MAX_DNN_HEADER_SIZE   (4096)
#define MAX_NUM_OF_NETWORKS   (3)
#define MAX_OUTPUT_TENSOR_NUM   (30)
#define SC_DNN_MAX_NETWORK_ID   (0x999999)
#define SC_DNN_MAX_NETWORK_ID_DEC   (999999)
#define VALID_DATA_OFFSET   0

Enumerations

enum  dnn_input_format_t { DNN_INPUT_FORMAT_RGB = 0 , DNN_INPUT_FORMAT_BGR , DNN_INPUT_FORMAT_Y , DNN_INPUT_FORMAT_BAYER_RGB }
enum  E_BAYER_CH {
  BAYER_CH_R = 0 , BAYER_CH_GR , BAYER_CH_GB , BAYER_CH_B ,
  BAYER_CH_MAX
}
enum  imx500_white_balance_mode_t { IMX500_WB_MODE_AUTO = 0 , IMX500_WB_MODE_ONE_PUSH = 1 , IMX500_WB_MODE_PRESET = 2 }
enum  imx500_white_balance_preset_t { IMX500_WB_PRESET_3200 = 0 , IMX500_WB_PRESET_4300 = 1 , IMX500_WB_PRESET_5600 = 2 , IMX500_WB_PRESET_6500 = 3 }
enum  mipi_data_format_t { MIPI_DATA_IMAGE = 0 , MIPI_DATA_METADATA_INPUT_TENSOR_OUTPUT_TENSOR , MIPI_DATA_IMAGE_METADATA_INPUT_TENSOR_OUTPUT_TENSOR , MIPI_DATA_NONE }
 MIPI output layout requested from imx500_open. More...
enum  module_boot_mode_t {
  MODULE_WAIT_BOOT = 0 , MODULE_SELF_BOOT , MODULE_I2C_LOAD_NN_BOOT , MODULE_RPI_PRIVATE_PROTOCOL_LOAD_NN_BOOT ,
  MODULE_SPI_LOAD_NN_BOOT
}
enum  spi_data_format_t {
  SPI_METADATA_OUTPUT_TENSOR = 0 , SPI_METADATA_INPUT_TENSOR , SPI_METADATA_JPEG_INPUT_TENSOR , SPI_METADATA_INPUT_TENSOR_OUTPUT_TENSOR ,
  SPI_METADATA_JPEG_INPUT_TENSOR_OUTPUT_TENSOR , SPI_METADATA_NONE
}
 SPI metadata layout requested from imx500_open. More...
enum  spi_data_forwarding_mode_t {
  SPI_DATA_FORWARDING_NONE = 0 , SPI_SLAVE_FROM_IMX500_MSPI , SPI_MASTER_FROM_IMX500_MSPI , SPI_SLAVE_FROM_IMX500_SSPI ,
  SPI_MASTER_FROM_IMX500_SSPI , SPI_SLAVE_TO_IMX500_SSPI , SPI_SLAVE_WRITE_MODEL_TO_FLASH , SPI_SLAVE_WRITE_NN_INFO_TO_FLASH ,
  SPI_LOAD_NN_INFO_TO_MEMORY , SPI_FORWORDING_MODE_SWITCHING
}
 SPI bridge forwarding path selected inside the module. More...
enum  spi_flash_op_result_t {
  SPI_FLASH_RESULT_NONE = 0 , SPI_FLASH_RESULT_OK = 1 , SPI_FLASH_RESULT_TIMEOUT = 2 , SPI_FLASH_RESULT_BAD_HEADER = 3 ,
  SPI_FLASH_RESULT_BAD_SIZE = 4 , SPI_FLASH_RESULT_WRITE_FAIL = 5 , SPI_FLASH_RESULT_CRC_MISMATCH = 6 , SPI_FLASH_RESULT_PARSE_FAIL = 7 ,
  SPI_FLASH_RESULT_FLASH_BLOB_MISSING = 8 , SPI_FLASH_RESULT_BUSY = 9 , SPI_FLASH_RESULT_BAD_OPERATION = 10 , SPI_FLASH_RESULT_NOT_SUPPORTED = 11 ,
  SPI_FLASH_RESULT_NO_MEMORY = 12 , SPI_FLASH_RESULT_IMX500_DOWNLOAD_FAIL = 13
}
enum  spi_flash_op_status_t {
  SPI_FLASH_OP_IDLE = 0 , SPI_FLASH_OP_WAIT_HEADER = 1 , SPI_FLASH_OP_RECEIVING = 2 , SPI_FLASH_OP_PARSING = 3 ,
  SPI_FLASH_OP_SUCCESS = 4 , SPI_FLASH_OP_FAILED = 5
}

Functions

Dequant APIs

Helpers that parse tensor metadata and bind output payloads so host code can inspect quantization parameters and run dequant or post-processing.

bool parse_metadata (const uint8_t *data, uint32_t data_len, spi_data_format_t spi_format, IMX500ParsedMetadata *parsed_metadata)
 Parse one raw SPI metadata buffer using the selected SPI metadata layout.
ROI Helper APIs

Helpers for crop control and coordinate mapping.

int apply_dnn_input_tensor_mapping (uint32_t width, uint32_t height)
 Apply the DNN input-tensor mapping to the current IMX500 12MP active area.
uint32_t bbox_coordinate_x_scale_map (float x, uint32_t s_w, uint32_t t_w)
 Scale an X coordinate from source width to target width.
uint32_t bbox_coordinate_y_scale_map (float y, uint32_t s_h, uint32_t t_h)
 Scale a Y coordinate from source height to target height.
int dnn_crop_xyxy_absolute (uint32_t xmin, uint32_t ymin, uint32_t xmax, uint32_t ymax)
 Apply a crop rectangle in absolute sensor coordinates.
int imx500_calculate_center_crop_xyxy (uint32_t source_width, uint32_t source_height, uint32_t target_width, uint32_t target_height, imx500_crop_rect_t *crop)
 Calculate a centered crop rectangle that matches a target output aspect ratio.
ISP and Sensor Tuning APIs

Helpers for auto-exposure and white-balance configuration.

int imx500_apply_ae_config (void)
 Apply the staged auto-exposure configuration to the sensor.
int imx500_apply_white_balance_config (void)
 Apply the staged white balance configuration to the sensor.
void imx500_get_default_ae_config (imx500_ae_config_t *config)
 Fill an AE config structure with SDK defaults.
void imx500_get_default_white_balance_config (imx500_white_balance_config_t *config)
 Fill a white balance config structure with SDK defaults.
int imx500_set_ae_config (const imx500_ae_config_t *config)
 Stage a new auto-exposure configuration in the sensor control block.
int imx500_set_white_balance_config (const imx500_white_balance_config_t *config)
 Stage a new white balance configuration in the sensor control block.
IMX500 Control, Metadata, and Asset-Management APIs

Helpers for module lifecycle control, metadata transport, and asset loading.

bool abort_i2c_payload_operation (void)
 Abort any active I2C payload import session and wait until it returns to idle.
void dump_network_info_list (void)
 Print the cached network list through the registered logger.
void get_fw_ver (uint32_t *v)
 Read the module firmware version register.
uint32_t get_metadata_size (void)
 Read the size of the next metadata payload exposed by the module.
void get_pid (uint32_t *v)
 Read the module product/device ID register.
int get_sensor_device_id (char *out, size_t out_size)
 Read the sensor device ID used by imx500_dump_basic_info().
bool get_spi_flash_status (spi_flash_status_t *status)
 Read the current flash write progress from module firmware.
bool imx500_open (const uint8_t *nn_fw, uint32_t nn_fw_size, const uint8_t *nn_info, uint32_t nn_info_size, mipi_data_format_t mipi_format, spi_data_format_t spi_format, uint32_t fps)
 Reset the module, load the model, and configure stream formats.
int load_imx500_fw (const uint8_t *fw, uint32_t size, uint32_t fw_type)
 Transfer one firmware blob to the module.
bool load_model_to_cam_memory_i2c (const uint8_t *model, uint32_t model_size)
 Load a model blob into module memory over the I2C payload path.
bool load_nn_info_to_cam_memory (const uint8_t *nn_info, uint32_t nn_info_size)
 Load a network-info blob directly into module memory.
bool load_nn_info_to_cam_memory_i2c (const uint8_t *nn_info, uint32_t nn_info_size)
 Load a network-info blob into module memory over the I2C payload path.
int load_nn_info_to_sdk_cache (const uint8_t *cfg, size_t cfg_len)
 Parse and cache a network-info blob in the SDK host-side cache.
bool probe_imx500_module (uint32_t *device_id, uint32_t *boot_status)
 Probe the module and read device ID plus boot status.
int32_t read_metadata (uint8_t *rx_buf, uint32_t buf_size)
 Read one metadata frame over SPI.
bool reset_imx500_module (void)
 Reset the IMX500 module and wait until loader/main firmware is ready.
int sensor_i2c_read_16_16 (uint16_t reg_addr, uint16_t *data)
 Read one 16-bit sensor register addressed by a 16-bit register address.
int sensor_i2c_read_16_32 (uint16_t reg_addr, uint32_t *data)
 Read one 32-bit sensor register addressed by a 16-bit register address.
int sensor_i2c_read_16_8 (uint16_t reg_addr, uint8_t *data)
 Read one 8-bit sensor register addressed by a 16-bit register address.
int sensor_i2c_write_16_16 (uint16_t reg_addr, uint16_t data)
 Write one 16-bit sensor register addressed by a 16-bit register address.
int sensor_i2c_write_16_32 (uint16_t reg_addr, uint32_t data)
 Write one 32-bit sensor register addressed by a 16-bit register address.
int sensor_i2c_write_16_8 (uint16_t reg_addr, uint8_t data)
 Write one 8-bit sensor register addressed by a 16-bit register address.
void stream_on (void)
 Start inference/video streaming after imx500_open succeeds.
bool switch_spi_data_forward_mode (spi_data_forwarding_mode_t m)
 Switch the module SPI bridge to a different data forwarding mode.
void unpack_imx500_output_header (const uint8_t *data, IMX500OutputHeader *header)
 Decode a raw IMX500 metadata header into a typed structure.
bool write_model_to_cam_flash (const uint8_t *model, uint32_t model_size)
 Stream a model blob to module flash over SPI.
bool write_model_to_cam_flash_i2c (const uint8_t *model, uint32_t model_size)
 Stream a model blob to module flash over PiVariety I2C payload.
bool write_nn_info_to_cam_flash (const uint8_t *nn_info, uint32_t nn_info_size)
 Stream a network-info blob to module flash over SPI.
bool write_nn_info_to_cam_flash_i2c (const uint8_t *nn_info, uint32_t nn_info_size)
 Stream a network-info blob to module flash over PiVariety I2C payload.

Data Injection and Host Preprocessing APIs

Helpers for host-driven input injection and input tensor preprocessing.

typedef uint32_t(* data_provider_t) (uint8_t *buf, uint32_t max_len, uint32_t offset)
 Callback used by do_data_injection_stream to stream image bytes lazily.
void do_data_injection (const uint8_t *data, uint32_t size, bool first_time)
 Inject one complete input buffer directly.
void do_data_injection_stream (data_provider_t provider, uint32_t total_size, bool first_time)
 Inject input data through a pull-based provider callback.
void stop_data_injection (void)
 Exit data injection mode.

Detailed Description

Public API for integrating IMX500 modules on MCU platforms.

Definition in file ArducamIMX500SDK.h.

Macro Definition Documentation

◆ IMX500_FW_TYPE_LOADER

#define IMX500_FW_TYPE_LOADER   0

Definition at line 19 of file ArducamIMX500SDK.h.

◆ IMX500_FW_TYPE_MAIN

#define IMX500_FW_TYPE_MAIN   1

Definition at line 20 of file ArducamIMX500SDK.h.

◆ IMX500_FW_TYPE_NETWORK_WEIGHTS

#define IMX500_FW_TYPE_NETWORK_WEIGHTS   2

Definition at line 21 of file ArducamIMX500SDK.h.

◆ IMX500_HEADER_LEN

#define IMX500_HEADER_LEN   12

Definition at line 17 of file ArducamIMX500SDK.h.

◆ IMX500_MAX_INPUT_TENSORS

#define IMX500_MAX_INPUT_TENSORS   8

Definition at line 47 of file ArducamIMX500SDK.h.

◆ IMX500_MAX_NETWORKS

#define IMX500_MAX_NETWORKS   MAX_NUM_OF_NETWORKS

Definition at line 45 of file ArducamIMX500SDK.h.

◆ IMX500_MAX_OUTPUT_TENSORS

#define IMX500_MAX_OUTPUT_TENSORS   MAX_OUTPUT_TENSOR_NUM

Definition at line 48 of file ArducamIMX500SDK.h.

◆ IMX500_MAX_TENSOR_DIMS

#define IMX500_MAX_TENSOR_DIMS   8

Definition at line 46 of file ArducamIMX500SDK.h.

◆ MAX_DETECT_ITEM_NUM

#define MAX_DETECT_ITEM_NUM   10

Definition at line 18 of file ArducamIMX500SDK.h.

◆ MAX_DNN_HEADER_SIZE

#define MAX_DNN_HEADER_SIZE   (4096)

Definition at line 41 of file ArducamIMX500SDK.h.

◆ MAX_NUM_OF_NETWORKS

#define MAX_NUM_OF_NETWORKS   (3)

Definition at line 42 of file ArducamIMX500SDK.h.

◆ MAX_OUTPUT_TENSOR_NUM

#define MAX_OUTPUT_TENSOR_NUM   (30)

Definition at line 43 of file ArducamIMX500SDK.h.

◆ SC_DNN_MAX_NETWORK_ID

#define SC_DNN_MAX_NETWORK_ID   (0x999999)

Definition at line 40 of file ArducamIMX500SDK.h.

◆ SC_DNN_MAX_NETWORK_ID_DEC

#define SC_DNN_MAX_NETWORK_ID_DEC   (999999)

Definition at line 39 of file ArducamIMX500SDK.h.

◆ VALID_DATA_OFFSET

#define VALID_DATA_OFFSET   0

Definition at line 16 of file ArducamIMX500SDK.h.

Typedef Documentation

◆ data_provider_t

typedef uint32_t(* data_provider_t) (uint8_t *buf, uint32_t max_len, uint32_t offset)

Callback used by do_data_injection_stream to stream image bytes lazily.

Definition at line 430 of file ArducamIMX500SDK.h.

Enumeration Type Documentation

◆ dnn_input_format_t

Enumerator
DNN_INPUT_FORMAT_RGB 
DNN_INPUT_FORMAT_BGR 
DNN_INPUT_FORMAT_Y 
DNN_INPUT_FORMAT_BAYER_RGB 

Definition at line 122 of file ArducamIMX500SDK.h.

◆ E_BAYER_CH

enum E_BAYER_CH
Enumerator
BAYER_CH_R 
BAYER_CH_GR 
BAYER_CH_GB 
BAYER_CH_B 
BAYER_CH_MAX 

Definition at line 129 of file ArducamIMX500SDK.h.

◆ imx500_white_balance_mode_t

Enumerator
IMX500_WB_MODE_AUTO 
IMX500_WB_MODE_ONE_PUSH 
IMX500_WB_MODE_PRESET 

Definition at line 297 of file ArducamIMX500SDK.h.

◆ imx500_white_balance_preset_t

Enumerator
IMX500_WB_PRESET_3200 
IMX500_WB_PRESET_4300 
IMX500_WB_PRESET_5600 
IMX500_WB_PRESET_6500 

Definition at line 303 of file ArducamIMX500SDK.h.

◆ mipi_data_format_t

MIPI output layout requested from imx500_open.

Enumerator
MIPI_DATA_IMAGE 

Image stream only.

MIPI_DATA_METADATA_INPUT_TENSOR_OUTPUT_TENSOR 

Metadata and tensors without image data.

MIPI_DATA_IMAGE_METADATA_INPUT_TENSOR_OUTPUT_TENSOR 

Image, metadata, and tensors.

MIPI_DATA_NONE 

Disable MIPI output.

Definition at line 222 of file ArducamIMX500SDK.h.

◆ module_boot_mode_t

Enumerator
MODULE_WAIT_BOOT 
MODULE_SELF_BOOT 
MODULE_I2C_LOAD_NN_BOOT 
MODULE_RPI_PRIVATE_PROTOCOL_LOAD_NN_BOOT 
MODULE_SPI_LOAD_NN_BOOT 

Definition at line 230 of file ArducamIMX500SDK.h.

◆ spi_data_format_t

SPI metadata layout requested from imx500_open.

The current implementation configures SPI_METADATA_OUTPUT_TENSOR, SPI_METADATA_JPEG_INPUT_TENSOR_OUTPUT_TENSOR, and SPI_METADATA_NONE. The other values are reserved by the interface but are not currently enabled by imx500_open.

Enumerator
SPI_METADATA_OUTPUT_TENSOR 

Output tensors only; supported.

SPI_METADATA_INPUT_TENSOR 

Reserved; not currently enabled.

SPI_METADATA_JPEG_INPUT_TENSOR 

Reserved; not currently enabled.

SPI_METADATA_INPUT_TENSOR_OUTPUT_TENSOR 

Reserved; not currently enabled.

SPI_METADATA_JPEG_INPUT_TENSOR_OUTPUT_TENSOR 

JPEG/input data plus output tensors; supported.

SPI_METADATA_NONE 

Disable SPI metadata output; supported.

Definition at line 212 of file ArducamIMX500SDK.h.

◆ spi_data_forwarding_mode_t

SPI bridge forwarding path selected inside the module.

Enumerator
SPI_DATA_FORWARDING_NONE 
SPI_SLAVE_FROM_IMX500_MSPI 
SPI_MASTER_FROM_IMX500_MSPI 
SPI_SLAVE_FROM_IMX500_SSPI 
SPI_MASTER_FROM_IMX500_SSPI 
SPI_SLAVE_TO_IMX500_SSPI 
SPI_SLAVE_WRITE_MODEL_TO_FLASH 
SPI_SLAVE_WRITE_NN_INFO_TO_FLASH 
SPI_LOAD_NN_INFO_TO_MEMORY 
SPI_FORWORDING_MODE_SWITCHING 

Definition at line 191 of file ArducamIMX500SDK.h.

◆ spi_flash_op_result_t

Enumerator
SPI_FLASH_RESULT_NONE 
SPI_FLASH_RESULT_OK 
SPI_FLASH_RESULT_TIMEOUT 
SPI_FLASH_RESULT_BAD_HEADER 
SPI_FLASH_RESULT_BAD_SIZE 
SPI_FLASH_RESULT_WRITE_FAIL 
SPI_FLASH_RESULT_CRC_MISMATCH 
SPI_FLASH_RESULT_PARSE_FAIL 
SPI_FLASH_RESULT_FLASH_BLOB_MISSING 
SPI_FLASH_RESULT_BUSY 
SPI_FLASH_RESULT_BAD_OPERATION 
SPI_FLASH_RESULT_NOT_SUPPORTED 
SPI_FLASH_RESULT_NO_MEMORY 
SPI_FLASH_RESULT_IMX500_DOWNLOAD_FAIL 

Definition at line 247 of file ArducamIMX500SDK.h.

◆ spi_flash_op_status_t

Enumerator
SPI_FLASH_OP_IDLE 
SPI_FLASH_OP_WAIT_HEADER 
SPI_FLASH_OP_RECEIVING 
SPI_FLASH_OP_PARSING 
SPI_FLASH_OP_SUCCESS 
SPI_FLASH_OP_FAILED 

Definition at line 238 of file ArducamIMX500SDK.h.

Function Documentation

◆ abort_i2c_payload_operation()

bool abort_i2c_payload_operation ( void )

Abort any active I2C payload import session and wait until it returns to idle.

Returns
true if the module acknowledged the abort and the payload state is idle.

◆ apply_dnn_input_tensor_mapping()

int apply_dnn_input_tensor_mapping ( uint32_t width,
uint32_t height )

Apply the DNN input-tensor mapping to the current IMX500 12MP active area.

This keeps the full IMX500 active area before crop (4056x3040) as the source coordinate system, calculates a centered crop matching the width x height aspect ratio, then applies it through dnn_crop_xyxy_absolute.

Parameters
widthTarget mapping width used to calculate the crop aspect ratio.
heightTarget mapping height used to calculate the crop aspect ratio.
Returns
0 on success, negative on invalid arguments or command failure.

◆ bbox_coordinate_x_scale_map()

uint32_t bbox_coordinate_x_scale_map ( float x,
uint32_t s_w,
uint32_t t_w )

Scale an X coordinate from source width to target width.

◆ bbox_coordinate_y_scale_map()

uint32_t bbox_coordinate_y_scale_map ( float y,
uint32_t s_h,
uint32_t t_h )

Scale a Y coordinate from source height to target height.

◆ dnn_crop_xyxy_absolute()

int dnn_crop_xyxy_absolute ( uint32_t xmin,
uint32_t ymin,
uint32_t xmax,
uint32_t ymax )

Apply a crop rectangle in absolute sensor coordinates.

Returns
0 on success, negative on invalid arguments or command failure.

◆ do_data_injection()

void do_data_injection ( const uint8_t * data,
uint32_t size,
bool first_time )

Inject one complete input buffer directly.

Parameters
dataPointer to source bytes.
sizeNumber of bytes to inject.
first_timeSet to true before the first injected frame.

◆ do_data_injection_stream()

void do_data_injection_stream ( data_provider_t provider,
uint32_t total_size,
bool first_time )

Inject input data through a pull-based provider callback.

Parameters
providerCallback that fills the next chunk.
total_sizeTotal input size in bytes.
first_timeSet to true before the first injected frame.

◆ dump_network_info_list()

void dump_network_info_list ( void )

Print the cached network list through the registered logger.

◆ get_fw_ver()

void get_fw_ver ( uint32_t * v)

Read the module firmware version register.

Parameters
vOutput value. The function logs and returns without writing when this pointer or the registered I2C read callback is null.

◆ get_metadata_size()

uint32_t get_metadata_size ( void )

Read the size of the next metadata payload exposed by the module.

Returns
Payload size in bytes, or 0 if no frame is available or the I2C read fails.

◆ get_pid()

void get_pid ( uint32_t * v)

Read the module product/device ID register.

Parameters
vOutput value. The function logs and returns without writing when this pointer or the registered I2C read callback is null.

◆ get_sensor_device_id()

int get_sensor_device_id ( char * out,
size_t out_size )

Read the sensor device ID used by imx500_dump_basic_info().

Parameters
outDestination buffer for the formatted ID string.
out_sizeSize of out in bytes. Must be at least 36.
Returns
0 on success, negative on command or argument failure.

The formatted ID matches imx500_dump_basic_info(): XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX

◆ get_spi_flash_status()

bool get_spi_flash_status ( spi_flash_status_t * status)

Read the current flash write progress from module firmware.

Parameters
statusOutput status structure.
Returns
true on success.

◆ imx500_apply_ae_config()

int imx500_apply_ae_config ( void )

Apply the staged auto-exposure configuration to the sensor.

◆ imx500_apply_white_balance_config()

int imx500_apply_white_balance_config ( void )

Apply the staged white balance configuration to the sensor.

◆ imx500_calculate_center_crop_xyxy()

int imx500_calculate_center_crop_xyxy ( uint32_t source_width,
uint32_t source_height,
uint32_t target_width,
uint32_t target_height,
imx500_crop_rect_t * crop )

Calculate a centered crop rectangle that matches a target output aspect ratio.

The returned rectangle is expressed in absolute source/sensor coordinates and uses left-closed, right-open coordinates: [xmin, xmax), [ymin, ymax). Dimensions and offsets are rounded down to even values when possible so the rectangle is suitable for Bayer/binning image paths.

Example: source 4056x3040 and target 1024x600 returns xmin=0, ymin=332, xmax=4056, ymax=2708.

Returns
0 on success, negative on invalid arguments.

◆ imx500_get_default_ae_config()

void imx500_get_default_ae_config ( imx500_ae_config_t * config)

Fill an AE config structure with SDK defaults.

◆ imx500_get_default_white_balance_config()

void imx500_get_default_white_balance_config ( imx500_white_balance_config_t * config)

Fill a white balance config structure with SDK defaults.

◆ imx500_open()

bool imx500_open ( const uint8_t * nn_fw,
uint32_t nn_fw_size,
const uint8_t * nn_info,
uint32_t nn_info_size,
mipi_data_format_t mipi_format,
spi_data_format_t spi_format,
uint32_t fps )

Reset the module, load the model, and configure stream formats.

Parameters
nn_fwNetwork weights blob. Pass NULL or a zero size for flash boot.
nn_fw_sizeSize of nn_fw in bytes.
nn_infoNetwork-info blob associated with a directly loaded model.
nn_info_sizeSize of nn_info in bytes.
mipi_formatRequested MIPI output format.
spi_formatRequested SPI metadata format.
fpsTarget frame rate.
Returns
true if initialization completed successfully.

A non-null nn_fw with a non-zero size selects direct SPI loading and requires matching network-info data. Otherwise the function requests the model and network-info already stored in module flash.

◆ imx500_set_ae_config()

int imx500_set_ae_config ( const imx500_ae_config_t * config)

Stage a new auto-exposure configuration in the sensor control block.

◆ imx500_set_white_balance_config()

int imx500_set_white_balance_config ( const imx500_white_balance_config_t * config)

Stage a new white balance configuration in the sensor control block.

◆ load_imx500_fw()

int load_imx500_fw ( const uint8_t * fw,
uint32_t size,
uint32_t fw_type )

Transfer one firmware blob to the module.

Parameters
fwPointer to the firmware image.
sizeFirmware size in bytes.
fw_typeOne of IMX500_FW_TYPE_*.
Returns
0 on success, negative on failure.

◆ load_model_to_cam_memory_i2c()

bool load_model_to_cam_memory_i2c ( const uint8_t * model,
uint32_t model_size )

Load a model blob into module memory over the I2C payload path.

Parameters
modelPointer to the model payload.
model_sizeModel size in bytes.
Returns
true if the module accepted the payload.

◆ load_nn_info_to_cam_memory()

bool load_nn_info_to_cam_memory ( const uint8_t * nn_info,
uint32_t nn_info_size )

Load a network-info blob directly into module memory.

Parameters
nn_infoPointer to the network-info payload.
nn_info_sizeNetwork-info size in bytes.
Returns
true if the module accepted the blob.

◆ load_nn_info_to_cam_memory_i2c()

bool load_nn_info_to_cam_memory_i2c ( const uint8_t * nn_info,
uint32_t nn_info_size )

Load a network-info blob into module memory over the I2C payload path.

Parameters
nn_infoPointer to the network-info payload.
nn_info_sizeNetwork-info size in bytes.
Returns
true if the module accepted the payload.

◆ load_nn_info_to_sdk_cache()

int load_nn_info_to_sdk_cache ( const uint8_t * cfg,
size_t cfg_len )

Parse and cache a network-info blob in the SDK host-side cache.

◆ parse_metadata()

bool parse_metadata ( const uint8_t * data,
uint32_t data_len,
spi_data_format_t spi_format,
IMX500ParsedMetadata * parsed_metadata )

Parse one raw SPI metadata buffer using the selected SPI metadata layout.

Parameters
dataRaw metadata buffer from read_metadata.
data_lenNumber of valid bytes in data.
spi_formatSPI metadata layout passed to imx500_open.
parsed_metadataOutput structure filled with parsed offsets and tensors.
Returns
true on success, false if the payload format is invalid.

◆ probe_imx500_module()

bool probe_imx500_module ( uint32_t * device_id,
uint32_t * boot_status )

Probe the module and read device ID plus boot status.

Parameters
device_idOptional output for the module product/device ID.
boot_statusOptional output for the current boot status.
Returns
true if both registers were read successfully.

◆ read_metadata()

int32_t read_metadata ( uint8_t * rx_buf,
uint32_t buf_size )

Read one metadata frame over SPI.

Parameters
rx_bufDestination buffer.
buf_sizeCapacity of rx_buf in bytes.
Returns
Number of bytes written to rx_buf, or 0 on failure.

◆ reset_imx500_module()

bool reset_imx500_module ( void )

Reset the IMX500 module and wait until loader/main firmware is ready.

Returns
true if reset completed and boot status returned to 1.

This is the reset-only part shared by imx500_open. It does not load a model from SPI or flash.

◆ sensor_i2c_read_16_16()

int sensor_i2c_read_16_16 ( uint16_t reg_addr,
uint16_t * data )

Read one 16-bit sensor register addressed by a 16-bit register address.

◆ sensor_i2c_read_16_32()

int sensor_i2c_read_16_32 ( uint16_t reg_addr,
uint32_t * data )

Read one 32-bit sensor register addressed by a 16-bit register address.

◆ sensor_i2c_read_16_8()

int sensor_i2c_read_16_8 ( uint16_t reg_addr,
uint8_t * data )

Read one 8-bit sensor register addressed by a 16-bit register address.

◆ sensor_i2c_write_16_16()

int sensor_i2c_write_16_16 ( uint16_t reg_addr,
uint16_t data )

Write one 16-bit sensor register addressed by a 16-bit register address.

◆ sensor_i2c_write_16_32()

int sensor_i2c_write_16_32 ( uint16_t reg_addr,
uint32_t data )

Write one 32-bit sensor register addressed by a 16-bit register address.

◆ sensor_i2c_write_16_8()

int sensor_i2c_write_16_8 ( uint16_t reg_addr,
uint8_t data )

Write one 8-bit sensor register addressed by a 16-bit register address.

◆ stop_data_injection()

void stop_data_injection ( void )

Exit data injection mode.

◆ stream_on()

void stream_on ( void )

Start inference/video streaming after imx500_open succeeds.

◆ switch_spi_data_forward_mode()

bool switch_spi_data_forward_mode ( spi_data_forwarding_mode_t m)

Switch the module SPI bridge to a different data forwarding mode.

Parameters
mRequested SPI forwarding mode.
Returns
true if the switch succeeded.

◆ unpack_imx500_output_header()

void unpack_imx500_output_header ( const uint8_t * data,
IMX500OutputHeader * header )

Decode a raw IMX500 metadata header into a typed structure.

Parameters
dataSource buffer containing at least IMX500_HEADER_LEN bytes.
headerOutput header structure.

◆ write_model_to_cam_flash()

bool write_model_to_cam_flash ( const uint8_t * model,
uint32_t model_size )

Stream a model blob to module flash over SPI.

Parameters
modelPointer to the model payload.
model_sizeModel size in bytes.
Returns
true if the transfer and module-side validation succeeded.

◆ write_model_to_cam_flash_i2c()

bool write_model_to_cam_flash_i2c ( const uint8_t * model,
uint32_t model_size )

Stream a model blob to module flash over PiVariety I2C payload.

Parameters
modelPointer to the model payload.
model_sizeModel size in bytes.
Returns
true if the transfer and module-side validation succeeded.

◆ write_nn_info_to_cam_flash()

bool write_nn_info_to_cam_flash ( const uint8_t * nn_info,
uint32_t nn_info_size )

Stream a network-info blob to module flash over SPI.

Parameters
nn_infoPointer to the network-info payload.
nn_info_sizeNetwork-info size in bytes.
Returns
true if the transfer and module-side validation succeeded.

◆ write_nn_info_to_cam_flash_i2c()

bool write_nn_info_to_cam_flash_i2c ( const uint8_t * nn_info,
uint32_t nn_info_size )

Stream a network-info blob to module flash over PiVariety I2C payload.

Parameters
nn_infoPointer to the network-info payload.
nn_info_sizeNetwork-info size in bytes.
Returns
true if the transfer and module-side validation succeeded.