PicoCamera 0.2.0
Camera library for RP2040 with an esp32-camera compatible API
GitHub
Loading...
Searching...
No Matches
pio_capture.h File Reference

PIO + DMA frame capture engine. More...

#include <stddef.h>
#include <stdint.h>
Include dependency graph for pio_capture.h:

Go to the source code of this file.

Data Structures

struct  pio_capture_pins_t

Functions

int pio_capture_init (const pio_capture_pins_t *pins)
 Claim a PIO state machine and DMA channel, load the capture program.
void pio_capture_deinit (void)
int pio_capture_frame (uint8_t *buf, size_t len, uint32_t timeout_ms)
 Capture exactly len bytes (one frame) into buf, blocking.
int pio_capture_frame_variable (uint8_t *buf, size_t capacity, size_t *out_len, uint32_t timeout_ms)
 Capture one variable-length frame (JPEG) into buf.

Detailed Description

PIO + DMA frame capture engine.

The PIO program is assembled at runtime with pio_encode_*(), so all pins come from camera_config_t - there is no .pio file and no pioasm build step (which also keeps the library Arduino-IDE friendly).

Function Documentation

◆ pio_capture_deinit()

void pio_capture_deinit ( void )

Release PIO state machine and DMA channel.

◆ pio_capture_frame()

int pio_capture_frame ( uint8_t * buf,
size_t len,
uint32_t timeout_ms )

Capture exactly len bytes (one frame) into buf, blocking.

Waits for the next VSYNC rising edge, then captures while HREF is high, clocked by PCLK, until len bytes are in the buffer.

Parameters
timeout_msabort and return PICO timeout error after this long
Returns
0 on success, negative on timeout/error

◆ pio_capture_frame_variable()

int pio_capture_frame_variable ( uint8_t * buf,
size_t capacity,
size_t * out_len,
uint32_t timeout_ms )

Capture one variable-length frame (JPEG) into buf.

Uses the continuous capture program: streams from a VSYNC rising edge until VSYNC falls again (frame end), then trims the buffer at the JPEG EOI marker (0xFFD9).

Parameters
bufdestination buffer
capacitybuffer capacity in bytes; a frame larger than this is truncated
out_lenreceives the actual frame length in bytes
timeout_msabort and return error after this long
Returns
0 on success, negative on timeout/error

◆ pio_capture_init()

int pio_capture_init ( const pio_capture_pins_t * pins)

Claim a PIO state machine and DMA channel, load the capture program.

Returns
0 on success
中文文档