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

Shared SCCB (I2C) access layer. More...

#include <stdint.h>
Include dependency graph for sccb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int sccb_init (int i2c_port, int pin_sda, int pin_scl, uint32_t freq_hz)
 Initialize the SCCB bus.
void sccb_deinit (void)
int sccb_write8 (uint8_t slave_addr, uint8_t reg, uint8_t value)
int sccb_read8 (uint8_t slave_addr, uint8_t reg, uint8_t *value)
int sccb_write16 (uint8_t slave_addr, uint16_t reg, uint8_t value)
int sccb_read16 (uint8_t slave_addr, uint16_t reg, uint8_t *value)
void sccb_write_list8 (uint8_t slave_addr, const uint8_t(*regs)[2])
void sccb_write_list16 (uint8_t slave_addr, const uint16_t(*regs)[2])

Detailed Description

Shared SCCB (I2C) access layer.

Sensors differ in register address width (OV2640: 8-bit, OV3660: 16-bit); both variants are provided here so sensor modules stay pure register logic.

Function Documentation

◆ sccb_deinit()

void sccb_deinit ( void )

Release the SCCB bus. A shared bus (pin_sda == -1) is left untouched.

◆ sccb_init()

int sccb_init ( int i2c_port,
int pin_sda,
int pin_scl,
uint32_t freq_hz )

Initialize the SCCB bus.

Parameters
i2c_portRP2040 I2C peripheral number: 0 or 1
pin_sdaSDA GPIO, or -1 to reuse an already initialized I2C bus (esp32-camera parity); the caller must have set up the bus beforehand and keeps owning it. Real pins are hard-muxed: SDA must be an even GPIO routing to the requested port, i.e. (pin / 2) % 2 == i2c_port
pin_sclSCL GPIO (ignored when pin_sda is -1)
freq_hzBus frequency (100000 is a safe default)
Returns
0 on success

◆ sccb_write16()

int sccb_write16 ( uint8_t slave_addr,
uint16_t reg,
uint8_t value )

16-bit register address access (e.g. OV3660). Return 0 on success.

◆ sccb_write8()

int sccb_write8 ( uint8_t slave_addr,
uint8_t reg,
uint8_t value )

8-bit register address access (e.g. OV2640). Return 0 on success.

◆ sccb_write_list16()

void sccb_write_list16 ( uint8_t slave_addr,
const uint16_t(*) regs[2] )

Write a {reg, value} list terminated by reg == 0xFFFF (16-bit addresses). reg == 0xFFFE is a delay marker, value gives milliseconds.

◆ sccb_write_list8()

void sccb_write_list8 ( uint8_t slave_addr,
const uint8_t(*) regs[2] )

Write a {reg, value} list terminated by {0xFF, 0xFF} (8-bit addresses).

中文文档