Skip to content

Commit

Permalink
Merge branch 'main' into dns-m2m-esp-hal
Browse files Browse the repository at this point in the history
  • Loading branch information
liebman authored Jul 2, 2024
2 parents 1617152 + fc826ca commit 1dfe1b5
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add new `DmaError::UnsupportedMemoryRegion` - used memory regions are checked when preparing a transfer now (#1670)
- Add DmaTransactionTxOwned, DmaTransactionRxOwned, DmaTransactionTxRxOwned, functions to do owning transfers added to SPI half-duplex (#1672)
- uart: Implement `embedded_io::ReadReady` for `Uart` and `UartRx` (#1702)
- ESP32-S3: Expose optional HSYNC input in LCD_CAM (#1707)
- ESP32-C6: Support lp-core as wake-up source (#1723)
- Add support for GPIO wake-up source (#1724)
- dma: add Mem2Mem to support memory to memory transfer (#1738)
- Add `uart` wake source (#1727)

### Fixed

- ESP32-S3: Fix DMA waiting check in LCD_CAM (#1707)
- TIMG: Fix interrupt handler setup (#1714)
- Fix `sleep_light` for ESP32-C6 (#1720)
- ROM Functions: Fix address of `ets_update_cpu_frequency_rom` (#1722)
Expand Down
70 changes: 56 additions & 14 deletions esp-hal/src/lcd_cam/cam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
//! )
//! // Remove this for slave mode.
//! .with_master_clock(mclk_pin)
//! .with_ctrl_pins(vsync_pin, href_pin, pclk_pin);
//! .with_pixel_clock(pclk_pin)
//! .with_ctrl_pins(vsync_pin, href_pin);
//! # }
//! ```
Expand Down Expand Up @@ -212,14 +213,22 @@ where

impl<'d, RX: Rx> DmaSupport for Camera<'d, RX> {
fn peripheral_wait_dma(&mut self, _is_tx: bool, _is_rx: bool) {
while !
// Wait for IN_SUC_EOF (i.e. VSYNC)
self.rx_channel.is_done() ||
// Or for IN_DSCR_EMPTY (i.e. No more buffer space)
self.rx_channel.has_dscr_empty_error() ||
// Or for IN_DSCR_ERR (i.e. bad descriptor)
self.rx_channel.has_error()
{}
loop {
// Wait for IN_SUC_EOF (i.e. VSYNC)
if self.rx_channel.is_done() {
break;
}

// Or for IN_DSCR_EMPTY (i.e. No more buffer space)
if self.rx_channel.has_dscr_empty_error() {
break;
}

// Or for IN_DSCR_ERR (i.e. bad descriptor)
if self.rx_channel.has_error() {
break;
}
}
}

fn peripheral_dma_stop(&mut self) {
Expand Down Expand Up @@ -288,22 +297,55 @@ impl<'d, RX: Rx> Camera<'d, RX> {
self
}

pub fn with_ctrl_pins<VSYNC: InputPin, HENABLE: InputPin, PCLK: InputPin>(
pub fn with_pixel_clock<PCLK: InputPin>(self, pclk: impl Peripheral<P = PCLK> + 'd) -> Self {
crate::into_ref!(pclk);

pclk.set_to_input(crate::private::Internal);
pclk.connect_input_to_peripheral(InputSignal::CAM_PCLK, crate::private::Internal);

self
}

pub fn with_ctrl_pins<VSYNC: InputPin, HENABLE: InputPin>(
self,
vsync: impl Peripheral<P = VSYNC> + 'd,
h_enable: impl Peripheral<P = HENABLE> + 'd,
pclk: impl Peripheral<P = PCLK> + 'd,
) -> Self {
crate::into_ref!(vsync);
crate::into_ref!(h_enable);
crate::into_ref!(pclk);

vsync.set_to_input(crate::private::Internal);
vsync.connect_input_to_peripheral(InputSignal::CAM_V_SYNC, crate::private::Internal);
h_enable.set_to_input(crate::private::Internal);
h_enable.connect_input_to_peripheral(InputSignal::CAM_H_ENABLE, crate::private::Internal);
pclk.set_to_input(crate::private::Internal);
pclk.connect_input_to_peripheral(InputSignal::CAM_PCLK, crate::private::Internal);

self.lcd_cam
.cam_ctrl1()
.modify(|_, w| w.cam_vh_de_mode_en().clear_bit());

self
}

pub fn with_ctrl_pins_and_de<VSYNC: InputPin, HSYNC: InputPin, HENABLE: InputPin>(
self,
vsync: impl Peripheral<P = VSYNC> + 'd,
hsync: impl Peripheral<P = HSYNC> + 'd,
h_enable: impl Peripheral<P = HENABLE> + 'd,
) -> Self {
crate::into_ref!(vsync);
crate::into_ref!(hsync);
crate::into_ref!(h_enable);

vsync.set_to_input(crate::private::Internal);
vsync.connect_input_to_peripheral(InputSignal::CAM_V_SYNC, crate::private::Internal);
hsync.set_to_input(crate::private::Internal);
hsync.connect_input_to_peripheral(InputSignal::CAM_H_SYNC, crate::private::Internal);
h_enable.set_to_input(crate::private::Internal);
h_enable.connect_input_to_peripheral(InputSignal::CAM_H_ENABLE, crate::private::Internal);

self.lcd_cam
.cam_ctrl1()
.modify(|_, w| w.cam_vh_de_mode_en().set_bit());

self
}
Expand Down
3 changes: 2 additions & 1 deletion examples/src/bin/lcd_cam_ov2640.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ fn main() -> ! {
&clocks,
)
.with_master_clock(cam_xclk)
.with_ctrl_pins(cam_vsync, cam_href, cam_pclk);
.with_pixel_clock(cam_pclk)
.with_ctrl_pins(cam_vsync, cam_href);

let delay = Delay::new(&clocks);

Expand Down

0 comments on commit 1dfe1b5

Please sign in to comment.