Dude, this DMA thing is killing me!!! I can write to the display at blistering speeds, but there are errors in the picture and I can't figure out why! <pulls all hair out!>
This commit is contained in:
parent
ce58e273f6
commit
457c2702ce
7 changed files with 4191 additions and 4133 deletions
|
@ -5,7 +5,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1375559853858667485" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-236853274004868024" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1394511230632125255" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-217901897231410254" id="ilg.gnuarmeclipse.managedbuild.cross.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT GCC Built-in Compiler Settings Cross ARM" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,6 +29,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <Adafruit_GFX.h>
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <main.h>
|
||||||
|
|
||||||
#define ILI9340_TFTWIDTH 240
|
#define ILI9340_TFTWIDTH 240
|
||||||
#define ILI9340_TFTHEIGHT 320
|
#define ILI9340_TFTHEIGHT 320
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "stm32f746xx.h"
|
#include "stm32f746xx.h"
|
||||||
#include <stm32f7xx_hal_gpio.h>
|
#include <stm32f7xx_hal_gpio.h>
|
||||||
#include "stm32f7xx_hal_dma.h"
|
#include "stm32f7xx_hal_dma.h"
|
||||||
|
#include "stm32f7xx_hal_dma2d.h"
|
||||||
|
#include "stm32f7xx_hal_dma_ex.h"
|
||||||
#include "stm32f7xx_hal_usart.h"
|
#include "stm32f7xx_hal_usart.h"
|
||||||
#include "stm32f7xx_hal_i2c.h"
|
#include "stm32f7xx_hal_i2c.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -101,6 +101,7 @@ TIM_HandleTypeDef TimHandle4;
|
||||||
#define MASKBLACK 0b0000000000000000
|
#define MASKBLACK 0b0000000000000000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* DMA */
|
/* DMA */
|
||||||
|
|
||||||
static DMA_HandleTypeDef hdma_tx;
|
static DMA_HandleTypeDef hdma_tx;
|
||||||
|
|
|
@ -579,15 +579,34 @@ void Adafruit_ILI9340_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
//txBuf[1] = lo;
|
//txBuf[1] = lo;
|
||||||
uint32_t totalPixels = h * w;
|
uint32_t totalPixels = h * w;
|
||||||
uint8_t txBuf2[totalPixels * 2];
|
uint8_t txBuf2[totalPixels * 2];
|
||||||
|
//uint16_t txBuf2[totalPixels];
|
||||||
|
|
||||||
//while(SpiHandle.State != HAL_SPI_STATE_READY);
|
//while(SpiHandle.State != HAL_SPI_STATE_READY);
|
||||||
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
|
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
|
||||||
{
|
{
|
||||||
//txBuf2[i] = color;
|
//txBuf2[i] = color;
|
||||||
txBuf2[i] = color >> 8;
|
txBuf2[i] = (color & 0xFF00) >> 8;
|
||||||
txBuf2[i + 1] = color & 0xFF;
|
txBuf2[i + 1] = color & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int errors = 0;
|
||||||
|
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
|
||||||
|
{
|
||||||
|
//txBuf2[i] = color;
|
||||||
|
if (txBuf2[i] != ((color & 0xFF00) >> 8) || txBuf2[i + 1] != (color & 0xFF))
|
||||||
|
errors++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// for(uint32_t i = totalPixels; i > 0; i--)
|
||||||
|
// {
|
||||||
|
// //txBuf2[i] = color;
|
||||||
|
// txBuf2[i] = color; // & 0xFF00) >> 8;
|
||||||
|
// //txBuf2[i + 1] = color & 0xFF;
|
||||||
|
// }
|
||||||
|
|
||||||
// for(uint32_t i = (totalPixels * 2); i > 0; i--)
|
// for(uint32_t i = (totalPixels * 2); i > 0; i--)
|
||||||
// {
|
// {
|
||||||
// if txBuf2[i] != color
|
// if txBuf2[i] != color
|
||||||
|
@ -608,20 +627,48 @@ void Adafruit_ILI9340_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||||
|
|
||||||
//uint32_t pixelsWritten = 0;
|
//uint32_t pixelsWritten = 0;
|
||||||
//utin16_t pixelsInBurst = 0;
|
//utin16_t pixelsInBurst = 0;
|
||||||
uint16_t fullPasses = (totalPixels * 2) / 0xFFFF;
|
//uint16_t fullPasses = (totalPixels * 2) / 0xFFFF;
|
||||||
uint16_t partialPass = (totalPixels * 2) % 0xFFFF;
|
//uint16_t partialPass = (totalPixels * 2) % 0xFFFF;
|
||||||
|
uint16_t fullPasses = sizeof(txBuf2) / 0xFFFF;
|
||||||
|
uint16_t partialPass = sizeof(txBuf2) % 0xFFFF;
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
while(fullPasses > 0)
|
while(fullPasses > 0)
|
||||||
{
|
{
|
||||||
|
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
|
||||||
|
{
|
||||||
|
//txBuf2[i] = color;
|
||||||
|
if (txBuf2[i] != ((color & 0xFF00) >> 8) || txBuf2[i + 1] != (color & 0xFF))
|
||||||
|
errors++;
|
||||||
|
|
||||||
|
}
|
||||||
|
while(HAL_SPI_GetState(&SpiHandle) != HAL_SPI_STATE_READY);
|
||||||
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf2 + offset, 0xFFFF); //txBuf2 or &txBuf2 doesn't seem to make a difference
|
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf2 + offset, 0xFFFF); //txBuf2 or &txBuf2 doesn't seem to make a difference
|
||||||
fullPasses--;
|
fullPasses--;
|
||||||
offset+=0xFFFF;
|
offset+=0xFFFF;
|
||||||
while(SpiHandle.State != HAL_SPI_STATE_READY);
|
//__IO HAL_DMA_StateTypeDef dmaState = HAL_DMA_GetState(&hdma_tx);
|
||||||
|
//if(dmaState = 0x01) dmaState++;
|
||||||
|
//while(HAL_DMA_GetState(&SpiHandle) !=
|
||||||
|
|
||||||
|
|
||||||
|
//while(SpiHandle.State != HAL_SPI_STATE_READY);
|
||||||
|
//hal_delay_ms(1000);
|
||||||
|
// int temp = millis;
|
||||||
|
// while (millis < temp + 1000);
|
||||||
}
|
}
|
||||||
if(partialPass > 0)
|
if(partialPass > 0)
|
||||||
{
|
{
|
||||||
|
while(SpiHandle.State != HAL_SPI_STATE_READY);
|
||||||
|
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
|
||||||
|
{
|
||||||
|
//txBuf2[i] = color;
|
||||||
|
if (txBuf2[i] != ((color & 0xFF00) >> 8) || txBuf2[i + 1] != (color & 0xFF))
|
||||||
|
errors++;
|
||||||
|
|
||||||
|
}
|
||||||
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf2 + offset, partialPass); //txBuf2 or &txBuf2 doesn't seem to make a difference
|
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf2 + offset, partialPass); //txBuf2 or &txBuf2 doesn't seem to make a difference
|
||||||
while(SpiHandle.State != HAL_SPI_STATE_READY);
|
while(SpiHandle.State != HAL_SPI_STATE_READY);
|
||||||
|
// int temp = millis;
|
||||||
|
// while (millis < temp + 1000);
|
||||||
}
|
}
|
||||||
//HAL_Delay(1000);
|
//HAL_Delay(1000);
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,8 @@ void dac2SetValue(uint16_t value);
|
||||||
//void sendToDds(uint16_t data1, uint16_t data2);
|
//void sendToDds(uint16_t data1, uint16_t data2);
|
||||||
#define FFT_SIZE 256 //supported sizes are 16, 64, 256, 1024
|
#define FFT_SIZE 256 //supported sizes are 16, 64, 256, 1024
|
||||||
#define FFT_BUFFER_SIZE 512 //double the FFT_SIZE above.
|
#define FFT_BUFFER_SIZE 512 //double the FFT_SIZE above.
|
||||||
__IO long long millis = 0;
|
|
||||||
|
|
||||||
|
__IO long long millis = 0;
|
||||||
|
|
||||||
float afGain = 1.0;
|
float afGain = 1.0;
|
||||||
float afGainLast = 2.0;
|
float afGainLast = 2.0;
|
||||||
|
@ -309,38 +309,39 @@ void configDMA(SPI_HandleTypeDef *hspi)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /* Configure the DMA handler for Transmission process */
|
||||||
|
// hdma_rx.Instance = SPIx_RX_DMA_STREAM;
|
||||||
|
//
|
||||||
|
// hdma_rx.Init.Channel = SPIx_RX_DMA_CHANNEL;
|
||||||
|
// hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||||
|
// hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
// hdma_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
// hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
// hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
// hdma_rx.Init.Mode = DMA_NORMAL;
|
||||||
|
// hdma_rx.Init.Priority = DMA_PRIORITY_HIGH;
|
||||||
|
// hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
// hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||||
|
// hdma_rx.Init.MemBurst = DMA_MBURST_INC4;
|
||||||
|
// hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4;
|
||||||
|
//
|
||||||
|
// HAL_DMA_Init(&hdma_rx);
|
||||||
|
//
|
||||||
|
// /* Associate the initialized DMA handle to the the SPI handle */
|
||||||
|
// __HAL_LINKDMA(hspi, hdmarx, hdma_rx);
|
||||||
|
|
||||||
hdma_tx.Instance = SPIx_TX_DMA_STREAM;
|
hdma_tx.Instance = SPIx_TX_DMA_STREAM;
|
||||||
|
|
||||||
/* Configure the DMA handler for Transmission process */
|
|
||||||
hdma_rx.Instance = SPIx_RX_DMA_STREAM;
|
|
||||||
|
|
||||||
hdma_rx.Init.Channel = SPIx_RX_DMA_CHANNEL;
|
|
||||||
hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
|
||||||
hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
|
||||||
hdma_rx.Init.MemInc = DMA_MINC_ENABLE;
|
|
||||||
hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
|
||||||
hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
|
||||||
hdma_rx.Init.Mode = DMA_NORMAL;
|
|
||||||
hdma_rx.Init.Priority = DMA_PRIORITY_HIGH;
|
|
||||||
hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
|
||||||
hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
|
||||||
hdma_rx.Init.MemBurst = DMA_MBURST_INC4;
|
|
||||||
hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4;
|
|
||||||
|
|
||||||
HAL_DMA_Init(&hdma_rx);
|
|
||||||
|
|
||||||
/* Associate the initialized DMA handle to the the SPI handle */
|
|
||||||
__HAL_LINKDMA(hspi, hdmarx, hdma_rx);
|
|
||||||
|
|
||||||
|
|
||||||
hdma_tx.Init.Channel = SPIx_TX_DMA_CHANNEL;
|
hdma_tx.Init.Channel = SPIx_TX_DMA_CHANNEL;
|
||||||
hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||||
hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
|
hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_BYTE;
|
||||||
hdma_tx.Init.Mode = DMA_NORMAL;
|
hdma_tx.Init.Mode = DMA_NORMAL;
|
||||||
hdma_tx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
|
hdma_tx.Init.Priority = DMA_PRIORITY_HIGH; //DMA_PRIORITY_VERY_HIGH;
|
||||||
hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
|
||||||
hdma_tx.Init.MemBurst = DMA_MBURST_INC4;
|
hdma_tx.Init.MemBurst = DMA_MBURST_INC4;
|
||||||
|
@ -355,15 +356,17 @@ void configDMA(SPI_HandleTypeDef *hspi)
|
||||||
|
|
||||||
/*##-4- Configure the NVIC for DMA #########################################*/
|
/*##-4- Configure the NVIC for DMA #########################################*/
|
||||||
/* NVIC configuration for DMA transfer complete interrupt (SPI3_TX) */
|
/* NVIC configuration for DMA transfer complete interrupt (SPI3_TX) */
|
||||||
HAL_NVIC_SetPriority(15/*SPIx_DMA_TX_IRQn*/, 0, 1);
|
HAL_NVIC_SetPriority(15/*SPIx_DMA_TX_IRQn*/, 4, 4);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
|
HAL_NVIC_EnableIRQ(SPIx_DMA_TX_IRQn);
|
||||||
|
|
||||||
/* NVIC configuration for DMA transfer complete interrupt (SPI3_RX) */
|
// /* NVIC configuration for DMA transfer complete interrupt (SPI3_RX) */
|
||||||
HAL_NVIC_SetPriority(SPIx_DMA_RX_IRQn, 0, 0);
|
// HAL_NVIC_SetPriority(SPIx_DMA_RX_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(SPIx_DMA_RX_IRQn);
|
// HAL_NVIC_EnableIRQ(SPIx_DMA_RX_IRQn);
|
||||||
|
|
||||||
|
|
||||||
//HAL_DMA_Start();
|
//HAL_DMA_Start();
|
||||||
|
|
||||||
|
//DMA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1074,12 +1077,14 @@ setFreq(vfoAFrequency);
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
drawNumber('3', 0,0, 0xFFFF);
|
// drawNumber('3', 0,0, 0xFFFF);
|
||||||
//Adafruit_GFX_fillScreen(ILI9340_GREEN);
|
//Adafruit_GFX_fillScreen(ILI9340_GREEN);
|
||||||
//drawNumber('3', 5,5, 0xFFFF);
|
//drawNumber('3', 5,5, 0xFFFF);
|
||||||
Adafruit_GFX_fillScreen(ILI9340_BLACK);
|
Adafruit_GFX_fillScreen(ILI9340_BLACK);
|
||||||
//Adafruit_GFX_fillScreen(ILI9340_RED);
|
//Adafruit_GFX_fillScreen(ILI9340_RED);
|
||||||
Adafruit_GFX_fillScreen(ILI9340_BLUE);
|
Adafruit_GFX_fillScreen(ILI9340_BLUE);
|
||||||
|
// Adafruit_GFX_fillScreen(ILI9340_RED);
|
||||||
|
// Adafruit_GFX_fillScreen(ILI9340_GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
Adafruit_GFX_setTextSize(3);
|
Adafruit_GFX_setTextSize(3);
|
||||||
|
@ -2042,12 +2047,12 @@ HAL_NVIC_EnableIRQ(TIM4_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA2_Stream2_IRQHandler(void)
|
//void DMA2_Stream2_IRQHandler(void)
|
||||||
{
|
//{
|
||||||
//doNothing();
|
// //doNothing();
|
||||||
HAL_DMA_IRQHandler(&hdma_rx);
|
// HAL_DMA_IRQHandler(&hdma_rx);
|
||||||
//HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1);
|
// //HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1);
|
||||||
}
|
//}
|
||||||
|
|
||||||
void DMA2_Stream3_IRQHandler(void)
|
void DMA2_Stream3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue