Fix lepton driver on m4 and m7 (#1138)

* Fix lepton driver on F4 and F7
* Increase clock rate for F4/F7 since they can't hit 10 MHz correctly
This commit is contained in:
Kwabena W. Agyeman 2021-01-25 09:38:18 -08:00 committed by GitHub
parent ab34219695
commit 3d7c2bd48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,7 +55,11 @@ static DMA_HandleTypeDef fir_lepton_spi_rx_dma = {};
#define VOSPI_SEG_SIZE_PIXELS (VOSPI_PIDS_PER_SEG * VOSPI_PID_SIZE_PIXELS) // 16-bits
#define VOSPI_BUFFER_SIZE (VOSPI_PACKET_SIZE * 2) // 16-bits
#if defined(MCU_SERIES_H7)
#define VOSPI_CLOCK_SPEED 10000000 // hz
#else
#define VOSPI_CLOCK_SPEED 20000000 // hz
#endif
#define VOSPI_SYNC_MS 200 // ms
static soft_timer_entry_t flir_lepton_spi_rx_timer = {};
@ -469,17 +473,35 @@ int fir_lepton_init(cambus_t *bus, int *w, int *h, int *refresh, int *resolution
OMV_FIR_LEPTON_CONTROLLER->spi->hdmatx = NULL;
OMV_FIR_LEPTON_CONTROLLER->spi->hdmarx = &fir_lepton_spi_rx_dma;
#if defined(MCU_SERIES_H7)
fir_lepton_spi_rx_dma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
#else
fir_lepton_spi_rx_dma.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
#endif
#if defined(MCU_SERIES_H7)
fir_lepton_spi_rx_dma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
#else
fir_lepton_spi_rx_dma.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
#endif
fir_lepton_spi_rx_dma.Init.Mode = DMA_CIRCULAR;
((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR =
(((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR & ~DMA_SxCR_PSIZE_Msk) |
#if defined(MCU_SERIES_H7)
DMA_PDATAALIGN_WORD;
#else
DMA_PDATAALIGN_HALFWORD;
#endif
((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR =
(((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR & ~DMA_SxCR_MSIZE_Msk) |
#if defined(MCU_SERIES_H7)
DMA_MDATAALIGN_WORD;
#else
DMA_MDATAALIGN_HALFWORD;
#endif
((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR =
(((DMA_Stream_TypeDef *) fir_lepton_spi_rx_dma.Instance)->CR & ~DMA_SxCR_CIRC_Msk) |