diff --git a/halconf.h b/halconf.h index af6c283..0b48487 100644 --- a/halconf.h +++ b/halconf.h @@ -41,8 +41,12 @@ * @brief Enables the ADC subsystem. */ #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#if defined(TINYSA_F303) +#define HAL_USE_ADC TRUE +#else #define HAL_USE_ADC FALSE #endif +#endif /** * @brief Enables the CAN subsystem. @@ -132,7 +136,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL TRUE +#define HAL_USE_SERIAL FALSE #endif /** @@ -187,7 +191,7 @@ * @note Disabling this option saves both code and data space. */ #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE +#define ADC_USE_MUTUAL_EXCLUSION FALSE #endif /*===========================================================================*/ @@ -209,7 +213,7 @@ * @brief Enables the mutual exclusion APIs on the I2C bus. */ #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE +#define I2C_USE_MUTUAL_EXCLUSION FALSE #endif /*===========================================================================*/ @@ -227,7 +231,7 @@ * @brief Enables an event sources for incoming packets. */ #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE +#define MAC_USE_EVENTS FALSE #endif /*===========================================================================*/ @@ -333,7 +337,7 @@ * @note Disabling this option saves both code and data space. */ #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE +#define SPI_USE_WAIT FALSE #endif /** @@ -341,7 +345,7 @@ * @note Disabling this option saves both code and data space. */ #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE +#define SPI_USE_MUTUAL_EXCLUSION FALSE #endif /** diff --git a/ili9341.c b/ili9341.c index 30af869..44bd04b 100644 --- a/ili9341.c +++ b/ili9341.c @@ -21,6 +21,9 @@ #include "hal.h" #include "nanovna.h" +// Allow enable DMA for read display data (some problem vs use in ST7796 in fast mode) +#define __USE_DISPLAY_DMA_RX__ + uint16_t spi_buffer[SPI_BUFFER_SIZE]; // Default foreground & background colors uint16_t foreground_color = 0; @@ -195,6 +198,7 @@ static void spi_lld_serve_tx_interrupt(SPIDriver *spip, uint32_t flags) (void)flags; } +#ifdef __USE_DISPLAY_DMA_RX__ static const stm32_dma_stream_t *dmarx = STM32_DMA_STREAM(STM32_SPI_SPI1_RX_DMA_STREAM); static uint32_t rxdmamode = STM32_DMA_CR_CHSEL(SPI1_RX_DMA_CHANNEL) | STM32_DMA_CR_PL(STM32_SPI_SPI1_DMA_PRIORITY) @@ -208,6 +212,7 @@ static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) (void)spip; (void)flags; } +#endif static void dmaStreamFlush(uint32_t len) { @@ -239,12 +244,14 @@ static void spi_init(void) // Tx DMA init dmaStreamAllocate(dmatx, STM32_SPI_SPI1_IRQ_PRIORITY, (stm32_dmaisr_t)spi_lld_serve_tx_interrupt, NULL); dmaStreamSetPeripheral(dmatx, &SPI1->DR); + SPI1->CR2|= SPI_CR2_TXDMAEN; // Tx DMA enable +#ifdef __USE_DISPLAY_DMA_RX__ // Rx DMA init dmaStreamAllocate(dmarx, STM32_SPI_SPI1_IRQ_PRIORITY, (stm32_dmaisr_t)spi_lld_serve_rx_interrupt, NULL); dmaStreamSetPeripheral(dmarx, &SPI1->DR); // Enable DMA on SPI - SPI1->CR2|= SPI_CR2_TXDMAEN // Tx DMA enable - | SPI_CR2_RXDMAEN; // Rx DMA enable + SPI1->CR2|= SPI_CR2_RXDMAEN; // Rx DMA enable +#endif #endif SPI1->CR1|= SPI_CR1_SPE; //SPI enable } @@ -369,7 +376,7 @@ void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette) } #ifndef __USE_DISPLAY_DMA__ -void ili9341_fill(int x, int y, int w, int h, int color) +void ili9341_fill(int x, int y, int w, int h, uint16_t color) { //uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; //uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; @@ -404,13 +411,11 @@ void ili9341_bulk(int x, int y, int w, int h) } } #else - // // Use DMA for send data // - // Fill region by some color -void ili9341_fill(int x, int y, int w, int h, int color) +void ili9341_fill(int x, int y, int w, int h, uint16_t color) { uint32_t xx = __REV16(x | ((x + w - 1) << 16)); uint32_t yy = __REV16(y | ((y + h - 1) << 16)); @@ -438,7 +443,9 @@ void ili9341_bulk(int x, int y, int w, int h) STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC); dmaStreamFlush(w * h); } -#if 0 // If read DMA hangs +#endif + +#ifndef __USE_DISPLAY_DMA_RX__ static uint8_t ssp_sendrecvdata(void) { // Start RX clock (by sending data) @@ -531,7 +538,6 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) } } #endif -#endif void ili9341_clear_screen(void) { diff --git a/mcuconf.h b/mcuconf.h index 241b42d..ab7b855 100644 --- a/mcuconf.h +++ b/mcuconf.h @@ -14,6 +14,9 @@ limitations under the License. */ +#ifdef TINYSA_F303 +#include "mcuconf_F303.h" +#else #ifndef MCUCONF_H #define MCUCONF_H @@ -226,3 +229,4 @@ #define STM32_WDG_USE_IWDG FALSE #endif /* MCUCONF_H */ +#endif diff --git a/nanovna.h b/nanovna.h index bbe79c2..5a7da8a 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,6 +18,9 @@ */ #include "ch.h" +#ifdef TINYSA_F303 +#include "adc_F303.h" +#endif // Need enable HAL_USE_SPI in halconf.h #define __USE_DISPLAY_DMA__ @@ -533,7 +536,7 @@ extern uint16_t spi_buffer[SPI_BUFFER_SIZE]; void ili9341_init(void); void ili9341_test(int mode); void ili9341_bulk(int x, int y, int w, int h); -void ili9341_fill(int x, int y, int w, int h, int color); +void ili9341_fill(int x, int y, int w, int h, uint16_t color); #if 0 void ili9341_set_foreground(uint16_t fg); void ili9341_set_background(uint16_t fg);