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;

  // One PAL carrying both buses: I2C for configuration, SPI for images.
  // On a Core the SPI bus's own chip-select pad is used, so spi_cs is 0.
  sense_cam_p_cfg_t cfg = { .spi_cs = 0, .resolution = SENSE_CAM_P_RES_160x120 };
  tile_sense_cam_p_init(core_tiles_pal2(&core_i2c1, &core_spi1), 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.
  • Needs a PAL carrying both buses: on a Core, core_tiles_pal2(&i2c, &spi). A plain core_tiles_pal() is I2C-only or SPI-only and fails here with "PAL has no SPI". The SPI link is mode 3, up to 25 MHz.
  • Starts from a software reset rather than a power cycle, which section 8.1.3 asks for when changing resolution: the tile has no way to cut its own power, and the reset path is the one proven on the bench.
  • The vendor tables leave the sensor free-running at 30 fps (R_Frame_Time = 400000 at 12 MHz, datasheet section 9.1).

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 before the next one fills, or FB_Ovf trips and the frame is void: about 3.4 ms at 320x240 and 6.8 ms at 160x120 with the vendor timing (section 7.3.6: 4800 / width x LineTime / 6 MHz). Anything slow between buffers — a per-byte print, a slow link — will tear the image across several exposures. (no Frame_Start within 1 s, no buffer within 500 ms) or an SPI error.

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

Returns 1 on a complete, non-overflowed frame; 0 on overflow, a timeout

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 · 12

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.
common320x240 on a 40 KB CoreA QVGA frame is 76800 bytes and must be read in 4800-byte buffers, each within a few ms. It cannot be buffered in a Core.ST.L4's 40 KB of SRAM and tears if streamed over the Core's USB. Use 160x120 (19200 B) there; 320x240 needs a Core with >= 77 KB free (Core.ST.W5, Core.ST.H5) or DMA to a faster sink. Core-gated, not a driver limit.
commonLow-power standbyR_TG_En = 0 drops the sensor to ~11 uA (Table 4) but also takes the SPI register interface down, and the boost converter has no enable on a pad, so the tile has no true off state. Hardware-gated for the boost; driver-deferred for sensor standby.
advancedGPIO1 frame interruptSection 8.6 can signal each ready buffer on GPIO1 (pad 2). The driver polls CPU_INT0_Status over SPI instead. GPIO1 is also the LED strobe, frame-sync and external-clock pin, so those features exclude each other. Driver-deferred.
advancedFrame-rate controlThe vendor tables fix 30 fps (R_Frame_Time = 400000 at 12 MHz, section 9.1). Slower rates would save power; faster ones are bounded by SPI. Driver-deferred.
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_MAJOR1
TILE_SENSE_CAM_P_VERSION_MINOR0
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_STATUS0x03CPU_INT0_Status: write 0 to a bit to clear it (0xFE clears FB_Rdy).
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.