Further progress on DMA. The radio is now "usable" with it turned on. There is a whole lot of weird corruption to the graphics... anyway, it's progress and I want to make sure it's saved.

This commit is contained in:
Michael Colton 2017-06-26 22:43:16 -06:00
parent 14d70c8afd
commit c9e7284a9f
5 changed files with 6066 additions and 4776 deletions

File diff suppressed because it is too large Load diff

View file

@ -412,16 +412,32 @@ void Adafruit_GFX_drawColorBitmap(int16_t x, int16_t y, uint16_t *bitmap, int16_
uint8_t txBuf[10]; uint8_t txBuf[10];
//HAL_SPI_Transmit(&SpiHandle, bitmap, 1 /*cnt * 2*/, 1); //HAL_SPI_Transmit(&SpiHandle, bitmap, 1 /*cnt * 2*/, 1);
//Using DMA is going to mean that I can't alter the image, so for now we'll
//use different code when using the tintMask
if(tintMask == 0xFFFF)
{
HAL_SPI_Transmit_DMA(&SpiHandle, bitmap, w*h*2);
while(SpiHandle.State != HAL_SPI_STATE_READY);
}
else
{
for(i = 0; i < w*h; i++) for(i = 0; i < w*h; i++)
{ {
txBuf[0] = (bitmap[i] & tintMask ) >> 8; txBuf[0] = (bitmap[i] & tintMask ) >> 8;
txBuf[1] = (bitmap[i] & tintMask ) & 0xFF; txBuf[1] = (bitmap[i] & tintMask ) & 0xFF;
//spi_readWrite(SpiHandle, rxBuf, bitmap, w*h); //spi_readWrite(SpiHandle, rxBuf, bitmap, w*h);
HAL_SPI_Transmit(&SpiHandle, txBuf, 2 /*cnt * 2*/, 1); //HAL_SPI_Transmit(&SpiHandle, txBuf, 2 /*cnt * 2*/, 1);
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf, 2);
//HAL_SPI_Transmit(&SpiHandle, bitmap[i+1], 1 /*cnt * 2*/, 1); //HAL_SPI_Transmit(&SpiHandle, bitmap[i+1], 1 /*cnt * 2*/, 1);
//} //}
//SET_BIT(csport, cspinmask); //SET_BIT(csport, cspinmask);
} }
}
} }
HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1); HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1);

View file

@ -65,7 +65,7 @@
// int _height = ILI9340_TFTHEIGHT; //320 // int _height = ILI9340_TFTHEIGHT; //320
uint16_t rxBuf[10]; uint16_t rxBuf[10];
uint16_t txBuf[2]; uint16_t txBuf[2];
uint8_t txBuf2[320 * 240 * 2]; //uint8_t txBuf2[320 * 240 * 2];
// Constructor when using hardware SPI. Faster, but must use SPI pins // Constructor when using hardware SPI. Faster, but must use SPI pins
// specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.) // specific to each board type (e.g. 11,13 for Uno, 51,52 for Mega, etc.)
@ -570,9 +570,10 @@ void Adafruit_ILI9340_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
//txBuf[0] = hi; //txBuf[0] = hi;
//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];
for(uint32_t i = 0; i < totalPixels; i+=2) //while(SpiHandle.State != HAL_SPI_STATE_READY);
for(uint32_t i = (totalPixels * 2); i > 0; i-=2)
{ {
//txBuf2[i] = color; //txBuf2[i] = color;
txBuf2[i] = color >> 8; txBuf2[i] = color >> 8;
@ -580,20 +581,36 @@ void Adafruit_ILI9340_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
} }
//uint32_t txBuf2Address = &txBuf2;
//uint32_t txBuf2AddressEnd = txBuf2Address + (320 * 240* 2);
//for()= color; //for()= color;
//txBuf2[153000] = 0xFF;
//txBuf2[150000] = 0xFF;
//spi_readWrite(SpiHandle, rxBuf, txBuf, 1); //spi_readWrite(SpiHandle, rxBuf, txBuf, 1);
//hdma_tx.Init.MemInc = DMA_MINC_DISABLE; //hdma_tx.Init.MemInc = DMA_MINC_DISABLE;
//HAL_DMA_Init(&hdma_tx); //HAL_DMA_Init(&hdma_tx);
//uint32_t pixelsWritten = 0;
HAL_SPI_Transmit_DMA(&SpiHandle, &txBuf2, 0xFFFF); //utin16_t pixelsInBurst = 0;
while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX); uint16_t fullPasses = (totalPixels * 2) / 0xFFFF;
//HAL_SPI_Transmit_DMA(&SpiHandle, &txBuf2, 0xFFFF); uint16_t partialPass = (totalPixels * 2) % 0xFFFF;
//while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX); uint32_t offset = 0;
while(fullPasses > 0)
{
HAL_SPI_Transmit_DMA(&SpiHandle, txBuf2 + offset, 0xFFFF); //txBuf2 or &txBuf2 doesn't seem to make a difference
fullPasses--;
offset+=0xFFFF;
while(SpiHandle.State != HAL_SPI_STATE_READY);
}
if(partialPass > 0)
{
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);
}
//HAL_Delay(1000); //HAL_Delay(1000);

View file

@ -1068,13 +1068,15 @@ setFreq(vfoAFrequency);
drawNumber('3', 0,0, 0xFFFF); drawNumber('3', 0,0, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_BLACK); Adafruit_GFX_fillScreen(ILI9340_BLACK);
while(1) //while(1)
{ // {
// drawNumber('3', 0,0, 0xFFFF); // drawNumber('3', 0,0, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_BLUE); // Adafruit_GFX_fillScreen(ILI9340_GREEN);
// drawNumber('3', 5,5, 0xFFFF); // drawNumber('3', 5,5, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_RED); // //Adafruit_GFX_fillScreen(ILI9340_BLACK);
} // Adafruit_GFX_fillScreen(ILI9340_RED);
// Adafruit_GFX_fillScreen(ILI9340_BLUE);
// }
Adafruit_GFX_setTextSize(3); Adafruit_GFX_setTextSize(3);
Adafruit_GFX_setTextWrap(1); Adafruit_GFX_setTextWrap(1);

View file

@ -150,7 +150,8 @@ void spi_readWrite(SPI_HandleTypeDef SpiH, uint16_t* rxBuf, uint16_t* txBuf, uin
//HAL_SPI_TransmitReceive(&SpiHandle, txBuf, rxBuf, cnt, 1000); //HAL_SPI_TransmitReceive(&SpiHandle, txBuf, rxBuf, cnt, 1000);
//HAL_SPI_Transmit(&SpiHandle, txTmp, 2 /*cnt * 2*/, 1); //HAL_SPI_Transmit(&SpiHandle, txTmp, 2 /*cnt * 2*/, 1);
//while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY); //while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY);
HAL_SPI_Transmit_DMA(&SpiHandle, txTmp, cnt); HAL_SPI_Transmit_DMA(&SpiHandle, txTmp, 2/*cnt*/);
while(SpiHandle.State != HAL_SPI_STATE_READY);
//while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY); //while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY);
// //High, second edge // //High, second edge