BERGSONNE

Sense.CAM.P

Ultra-low-power global-shutter camera driver for Sense.CAM.P (rev a).

Embeds the PixArt PAG7920J3, a 320 x 240 monochrome global-shutter camera module with an integrated lens in a 2.94 x 2.44 x 2.11 mm cube. Registers are configured over I2C; image data comes out over SPI. The tile does not break out the 8-bit parallel bus, so SPI is the only image path.

Datasheet

Examples

Quick start

  #include "core_tiles.h"

  static uint8_t frame[160 * 120];
  tile_t cam;

  sense_cam_p_cfg_t cfg = { .spi_cs = 9, .resolution = SENSE_CAM_P_RES_160x120 };
  tile_sense_cam_p_init(core_tiles_pal(&core_i2c1), 0, &cam, &cfg);
  if (tile_is_ready(&cam))
      tile_sense_cam_p_capture(&cam, frame, sizeof(frame));

API reference

Initialization

tile_sense_cam_p_find

uint8_t tile_sense_cam_p_find(tiles_pal_t* hal, uint8_t instance)

Check whether a PAG7920J3 is present on the I2C bus.

hal
Platform HAL handle
instance
Instance index (0 = default, see mapping table)

Returns 1 if the device ACKs, 0 otherwise

tile_sense_cam_p_init

void tile_sense_cam_p_init(tiles_pal_t* hal, uint8_t instance, tile_t* tile, const sense_cam_p_cfg_t* cfg)

Verifies PartID, applies the vendor init tables verbatim for the requested resolution, then confirms the SPI link by reading CheckID. Pass cfg=NULL for defaults (spi_cs 0, 160x120).

hal
Platform HAL handle
instance
Instance index (0 = default, see mapping table)
tile
Pointer to tile handle (populated by this function)
cfg
Optional config, or NULL for defaults
  • Blocks for ~250 ms. Requires both an I2C bus and an SPI bus on the PAL. Single-instance: the SPI CS and resolution are driver-global.

Lifecycle

tile_sense_cam_p_part_id

Studio
uint16_t tile_sense_cam_p_part_id(tile_t* tile)

Read the 16-bit part identifier over I2C.

Returns 0x7920 for a healthy PAG7920J3, 0 on a bus error.

tile_sense_cam_p_spi_id

Studio
uint16_t tile_sense_cam_p_spi_id(tile_t* tile)

Read the SPI-side identifier, confirming the SPI link is usable.

Returns 0xA55A when the SPI link is up, 0 otherwise.

  • Returns 0x0000 whenever the sensor is stopped — the SPI register interface is only alive while R_TG_En = 1.

tile_sense_cam_p_reset

Studio
void tile_sense_cam_p_reset(tile_t* tile)

Preferred over a power cycle for repeatable tests: the tile carries ~15.7 uF of bulk and at the camera's microamp idle draw that rail can take seconds to fall below the power-on-reset threshold, so an unplug/replug may not reset the part at all.

  • Leaves the sensor unconfigured; call init again afterwards.

Runtime

tile_sense_cam_p_capture

Studio
uint8_t tile_sense_cam_p_capture(tile_t* tile, uint8_t* dst, uint32_t len)

Frame-locks on Frame_Start, then reads the frame in 4800-byte buffers. The caller owns the memory: 19200 bytes at 160x120, 76800 at 320x240. Each buffer must be serviced within roughly 3.4 ms at default timing, or FB_Ovf trips and the frame is void. Anything slow between buffers — a per-byte print, a slow link — will tear the image across several exposures.

dst
Destination buffer.
len
Size of dst; must be >= tile_sense_cam_p_frame_bytes().

Returns 1 on a complete, non-overflowed frame; 0 otherwise.

Config

tile_sense_cam_p_width

Studio
uint16_t tile_sense_cam_p_width(tile_t* tile)

Frame width in pixels for the configured resolution.

Returns 160 or 320.

tile_sense_cam_p_height

Studio
uint16_t tile_sense_cam_p_height(tile_t* tile)

Frame height in pixels for the configured resolution.

Returns 120 or 240.

tile_sense_cam_p_frame_bytes

Studio
uint32_t tile_sense_cam_p_frame_bytes(tile_t* tile)

Number of bytes one frame occupies (width x height, 8-bit RAW).

Returns 19200 or 76800.

Driver gaps · 8

Chip capabilities this driver doesn’t expose yet.

commonMotion detectionThe PAG7920J3 has a proprietary on-chip motion-detection mode running at 80x60 under 100 uW, which is the tile's headline always-on feature. Section 8.1.3.8 gives its init table. Driver-deferred, not a hardware gap, and the highest-value thing to add next.
commonManual exposure and gainAuto-exposure and auto-gain run by default and hold mean brightness constant. Section 9.3 defines manual control, which is needed for any machine-vision use wanting repeatable radiometry. Driver-deferred.
advancedTrigger modeSection 8.4 allows one-frame-on-demand capture, with frame rate set by the host's trigger interval. Note it does NOT relax the per-buffer readout deadline — the frame is still emitted in one output cycle at the sensor's own cadence. Driver-deferred.
advancedWindowing, mirror and flipSection 10 covers WOI, mirror/flip, skip and average. Only the fixed 320x240 and 160x120 (2x skip) modes are exposed. Driver-deferred.
nicheLED strobe controlThe sensor can drive an external LED in sync with exposure via GPIO1 (R_expo_LED_* registers). The tile routes GPIO1 to a pad, so this is driver-deferred rather than hardware-gated.
nicheMulti-sensor frame syncSection 8.7 supports synchronising several sensors to a shared frame clock. Driver-deferred.
nicheExternal clock inputSection 5.5 allows clocking the sensor from GPIO1 instead of its internal oscillator (1/6/12/24/30 MHz). Driver-deferred; the internal clock is used unconditionally.
niche8-bit parallel image outputHARDWARE-GATED. The parallel bus needs PXD0-PXD7 plus PXCLK/HSYNC/VSYNC, and the tile's 10-pad T44 package breaks out only the four SPI signals. Not reachable on this tile at any driver revision.

Enums

sense_cam_p_res_t

@brief Capture resolution.

SENSE_CAM_P_RES_160x120
19200 B/frame, analog 2x skip.
SENSE_CAM_P_RES_320x240
76800 B/frame, full array.

Constants

TILE_SENSE_CAM_P_VERSION_MAJOR0
TILE_SENSE_CAM_P_VERSION_MINOR1
TILE_SENSE_CAM_P_VERSION_PATCH0
PAG7920_I2C_ADDR_FLOAT0x35GPIO2 floating (tile default).
PAG7920_I2C_ADDR_HIGH0x25GPIO2 tied to VDDIO.
PAG7920_I2C_ADDR_GND0x40GPIO2 tied to GND.
PAG7920_I2C_ADDR_BROADCAST0x60Always live, strap-independent.
PAG7920_PART_ID0x7920Expected PartID.
PAG7920_SPI_RD_BIT0x80Bit 7 of byte 0: 1 = read. Addr is 7-bit.
PAG7920_SPI_IMG_RD_EN0x021 = grant access to the output buffer.
PAG7920_SPI_INT_STATUS0x03Interrupt flags, write-to-clear.
PAG7920_SPI_CHECKID_L0x060x5A
PAG7920_SPI_CHECKID_H0x070xA5
PAG7920_SPI_IMG_DATA0x40Image burst source.
PAG7920_SPI_CHECK_ID0xA55AExpected CheckID; 0 unless running.
PAG7920_BUFFER_BYTES4800Output buffer size. A frame is delivered in units of this.