Crate arducam_legacy
source ·Expand description
This library aims to provide support for older legacy Arducam cameras such as ArduCAM Mini 2MP Plus
It provides embedded-hal
compatible API
Example
#![no_std]
#![no_main]
use stm32_hal2::{pac, gpio::{Pin, Port, PinMode, OutputType}, spi::{Spi, BaudRate}, i2c::I2c, timer::Timer};
use cortex_m::delay::Delay;
use arducam_legacy::Arducam;
fn main() -> ! {
let cp = cortex_m::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();
// Clocks setup
let clock_cfg = stm32_hal2::clocks::Clocks::default();
clock_cfg.setup().unwrap();
let mut delay = Delay::new(cp.SYST, clock_cfg.systick());
let mut mono_timer = Timer::new_tim2(dp.TIM2, 100.0, Default::default(), &clock_cfg);
// Example pinout configuration
// Adapt to your HAL crate
let _arducam_spi_mosi = Pin::new(Port::D, 4, PinMode::Alt(5));
let _arducam_spi_miso = Pin::new(Port::D, 3, PinMode::Alt(5));
let _arducam_spi_sck = Pin::new(Port::D, 1, PinMode::Alt(5));
let arducam_cs = Pin::new(Port::D, 0, PinMode::Output);
let arducam_spi = Spi::new(dp.SPI2, Default::default(), BaudRate::Div32);
let mut arducam_i2c_sda = Pin::new(Port::F, 0, PinMode::Alt(4));
arducam_i2c_sda.output_type(OutputType::OpenDrain);
let mut arducam_i2c_scl = Pin::new(Port::F, 1, PinMode::Alt(4));
arducam_i2c_scl.output_type(OutputType::OpenDrain);
let arducam_i2c = I2c::new(dp.I2C2, Default::default(), &clock_cfg);
let mut arducam = Arducam::new(
arducam_spi,
arducam_i2c,
arducam_cs,
arducam_legacy::Resolution::Res320x240, arducam_legacy::ImageFormat::JPEG
);
arducam.init(&mut delay).unwrap();
arducam.start_capture().unwrap();
while !arducam.is_capture_done().unwrap() { delay.delay_ms(1) }
let mut image = [0; 8192];
let length = arducam.get_fifo_length().unwrap();
let final_length = arducam.read_captured_image(&mut image).unwrap();
loop {}
}
Structs
- Main struct responsible for communicating with Arducam
Enums
- Possible errors which can happen during communication
- Image formats which Arducam can handle