diff --git a/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/dcmi.pio b/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/dcmi.pio new file mode 100644 index 000000000..135f47404 --- /dev/null +++ b/src/omv/boards/ARDUINO_NANO_RP2040_CONNECT/dcmi.pio @@ -0,0 +1,110 @@ +; This file is part of the OpenMV project. +; +; Copyright (c) 2013-2021 Ibrahim Abdelkader +; Copyright (c) 2013-2021 Kwabena W. Agyeman +; +; This work is licensed under the MIT license, see the file LICENSE for details. +; Image Sensor PIO program. + +.define public PXCLK 29 +.define public HSYNC 12 +.define public VSYNC 13 + +.program dcmi_default +.wrap_target + pull block ; Read number of lines in OSR + mov y, osr ; Copy OSR to Y + pull block ; Read line width in bytes in OSR + + wait 1 gpio VSYNC ; Wait for VSYNC to go low + wait 0 gpio VSYNC + +HSYNC_LOOP: + mov x, osr ; Copy line width from OSR to X + wait 0 gpio HSYNC ; Wait for HSYNC to go high + wait 1 gpio HSYNC + +PIXEL_LOOP: + wait 0 gpio PXCLK + wait 1 gpio PXCLK + + in pins 7 ; Workaround for NANO noncontiguous data bus. + jmp pin SET_MSB + in null, 1 + jmp DONE + SET_MSB: + in osr, 1 ; OSR always has an odd value (width - 1) + DONE: + + jmp x-- PIXEL_LOOP ; Keep reading pixels while x != 0 + jmp y-- HSYNC_LOOP ; Keep reading lines while y != 0 +.wrap + +.program dcmi_odd_byte +.wrap_target + pull block ; Read number of lines in OSR + mov y, osr ; Copy OSR to Y + pull block ; Read line width in bytes in OSR + + wait 1 gpio VSYNC ; Wait for VSYNC to go low + wait 0 gpio VSYNC + +HSYNC_LOOP: + mov x, osr ; Copy line width from OSR to X + wait 0 gpio HSYNC ; Wait for HSYNC to go high + wait 1 gpio HSYNC + +PIXEL_LOOP: + wait 0 gpio PXCLK + wait 1 gpio PXCLK + + in pins 7 ; Workaround for NANO noncontiguous data bus. + jmp pin SET_MSB + in null, 1 + jmp DONE + SET_MSB: + in osr, 1 ; OSR always has an odd value (width - 1) + DONE: + + wait 0 gpio PXCLK + wait 1 gpio PXCLK + jmp x-- PIXEL_LOOP ; Keep reading pixels while x != 0 + jmp y-- HSYNC_LOOP ; Keep reading lines while y != 0 +.wrap + +% c-sdk { +static inline int dcmi_config(uint32_t pixformat) +{ + uint offset; + pio_sm_config config; + + pio_sm_set_enabled(DCMI_PIO, DCMI_SM, false); + pio_sm_clear_fifos(DCMI_PIO, DCMI_SM); + + for(uint i=DCMI_D0_PIN; i