Semi working DMA code for the display driver! So excited! Now to work out the bugs :)

This commit is contained in:
Michael Colton 2017-06-24 23:42:12 -06:00
parent 26b7ef6f6d
commit 14d70c8afd
8 changed files with 4921 additions and 6040 deletions

View file

@ -179,13 +179,13 @@
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.594279191.1661284885" name="Enable extra warnings (-Wextra)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.594279191"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.594279191.1661284885" name="Enable extra warnings (-Wextra)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.warnings.extrawarn.594279191"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding.2010758088.550463969" name="Assume freestanding environment (-ffreestanding)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding.2010758088"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding.2010758088.550463969" name="Assume freestanding environment (-ffreestanding)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.freestanding.2010758088"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants.519889803.937775351" name="Disable loop invariant move (-fno-move-loop-invariants)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants.519889803"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants.519889803.937775351" name="Disable loop invariant move (-fno-move-loop-invariants)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.nomoveloopinvariants.519889803"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.821521074" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.821521074" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.none" valueType="enumerated"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.1868926411" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength.1868926411" name="Message length (-fmessage-length=0)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.messagelength" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.1998882563" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar.1998882563" name="'char' is signed (-fsigned-char)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.signedchar" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.28294102" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections.28294102" name="Function sections (-ffunction-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.functionsections" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.1579665519" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" value="true" valueType="boolean"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections.1579665519" name="Data sections (-fdata-sections)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.datasections" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.1545950493" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.max" valueType="enumerated"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.1545950493" name="Debug level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level" value="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.level.max" valueType="enumerated"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.1995605794" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format.1995605794" name="Debug format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.debugging.format"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
<tool errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GCCErrorParser" id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.238834628" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.916452879"> <tool errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GCCErrorParser" id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.238834628" name="Cross ARM GNU Assembler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.916452879">
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.963042472" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/> <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.963042472" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
@ -229,7 +229,7 @@
<sourceEntries> <sourceEntries>
<entry excluding="Examples" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="DSP_Lib"/> <entry excluding="Examples" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="DSP_Lib"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="src/stm32f7-hal/stm32f7xx_ll_usb.c|src/stm32f7-hal/stm32f7xx_ll_sdmmc.c|src/stm32f7-hal/stm32f7xx_ll_fmc.c|src/stm32f7-hal/stm32f7xx_hal_wwdg.c|src/stm32f7-hal/stm32f7xx_hal_sram.c|src/stm32f7-hal/stm32f7xx_hal_spdifrx.c|src/stm32f7-hal/stm32f7xx_hal_smartcard.c|src/stm32f7-hal/stm32f7xx_hal_sdram.c|src/stm32f7-hal/stm32f7xx_hal_sd.c|src/stm32f7-hal/stm32f7xx_hal_sai_ex.c|src/stm32f7-hal/stm32f7xx_hal_sai.c|src/stm32f7-hal/stm32f7xx_hal_rtc_ex.c|src/stm32f7-hal/stm32f7xx_hal_rtc.c|src/stm32f7-hal/stm32f7xx_hal_rng.c|src/stm32f7-hal/stm32f7xx_hal_qspi.c|src/stm32f7-hal/stm32f7xx_hal_pcd_ex.c|src/stm32f7-hal/stm32f7xx_hal_pcd.c|src/stm32f7-hal/stm32f7xx_hal_nor.c|src/stm32f7-hal/stm32f7xx_hal_nand.c|src/stm32f7-hal/stm32f7xx_hal_ltdc.c|src/stm32f7-hal/stm32f7xx_hal_lptim.c|src/stm32f7-hal/stm32f7xx_hal_irda.c|src/stm32f7-hal/stm32f7xx_hal_i2s.c|src/stm32f7-hal/stm32f7xx_hal_i2c_ex.c|src/stm32f7-hal/stm32f7xx_hal_hcd.c|src/stm32f7-hal/stm32f7xx_hal_hash_ex.c|src/stm32f7-hal/stm32f7xx_hal_hash.c|src/stm32f7-hal/stm32f7xx_hal_flash_ex.c|src/stm32f7-hal/stm32f7xx_hal_eth.c|src/stm32f7-hal/stm32f7xx_hal_dma_ex.c|src/stm32f7-hal/stm32f7xx_hal_dma2d.c|src/stm32f7-hal/stm32f7xx_hal_dma.c|src/stm32f7-hal/stm32f7xx_hal_dcmi_ex.c|src/stm32f7-hal/stm32f7xx_hal_dcmi.c|src/stm32f7-hal/stm32f7xx_hal_dac_ex.c|src/stm32f7-hal/stm32f7xx_hal_cryp_ex.c|src/stm32f7-hal/stm32f7xx_hal_cryp.c|src/stm32f7-hal/stm32f7xx_hal_crc.c|src/stm32f7-hal/stm32f7xx_hal_cec.c|src/stm32f7-hal/stm32f7xx_hal_can.c|src/stm32f7-hal/stm32f7xx_hal_adc_ex.c|src/stm32f7-hal/stm32f7xx_hal_msp_template.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/> <entry excluding="src/stm32f7-hal/stm32f7xx_ll_usb.c|src/stm32f7-hal/stm32f7xx_ll_sdmmc.c|src/stm32f7-hal/stm32f7xx_ll_fmc.c|src/stm32f7-hal/stm32f7xx_hal_wwdg.c|src/stm32f7-hal/stm32f7xx_hal_sram.c|src/stm32f7-hal/stm32f7xx_hal_spdifrx.c|src/stm32f7-hal/stm32f7xx_hal_smartcard.c|src/stm32f7-hal/stm32f7xx_hal_sdram.c|src/stm32f7-hal/stm32f7xx_hal_sd.c|src/stm32f7-hal/stm32f7xx_hal_sai_ex.c|src/stm32f7-hal/stm32f7xx_hal_sai.c|src/stm32f7-hal/stm32f7xx_hal_rtc_ex.c|src/stm32f7-hal/stm32f7xx_hal_rtc.c|src/stm32f7-hal/stm32f7xx_hal_rng.c|src/stm32f7-hal/stm32f7xx_hal_qspi.c|src/stm32f7-hal/stm32f7xx_hal_pcd_ex.c|src/stm32f7-hal/stm32f7xx_hal_pcd.c|src/stm32f7-hal/stm32f7xx_hal_nor.c|src/stm32f7-hal/stm32f7xx_hal_nand.c|src/stm32f7-hal/stm32f7xx_hal_ltdc.c|src/stm32f7-hal/stm32f7xx_hal_lptim.c|src/stm32f7-hal/stm32f7xx_hal_irda.c|src/stm32f7-hal/stm32f7xx_hal_i2s.c|src/stm32f7-hal/stm32f7xx_hal_i2c_ex.c|src/stm32f7-hal/stm32f7xx_hal_hcd.c|src/stm32f7-hal/stm32f7xx_hal_hash_ex.c|src/stm32f7-hal/stm32f7xx_hal_hash.c|src/stm32f7-hal/stm32f7xx_hal_flash_ex.c|src/stm32f7-hal/stm32f7xx_hal_eth.c|src/stm32f7-hal/stm32f7xx_hal_dma_ex.c|src/stm32f7-hal/stm32f7xx_hal_dma2d.c|src/stm32f7-hal/stm32f7xx_hal_dcmi_ex.c|src/stm32f7-hal/stm32f7xx_hal_dcmi.c|src/stm32f7-hal/stm32f7xx_hal_dac_ex.c|src/stm32f7-hal/stm32f7xx_hal_cryp_ex.c|src/stm32f7-hal/stm32f7xx_hal_cryp.c|src/stm32f7-hal/stm32f7xx_hal_crc.c|src/stm32f7-hal/stm32f7xx_hal_cec.c|src/stm32f7-hal/stm32f7xx_hal_can.c|src/stm32f7-hal/stm32f7xx_hal_adc_ex.c|src/stm32f7-hal/stm32f7xx_hal_msp_template.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="system"/>
</sourceEntries> </sourceEntries>
</configuration> </configuration>
</storageModule> </storageModule>

View file

@ -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="-1667007537446145964" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1402290119274807089" 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 &quot;${INPUTS}&quot;" 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="-1648056160672688194" 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 &quot;${INPUTS}&quot;" prefer-non-shared="true"> <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1421241496048264859" 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 &quot;${INPUTS}&quot;" 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

View file

@ -100,17 +100,23 @@ TIM_HandleTypeDef TimHandle4;
#define MASKWHITE 0b1111111111111111 #define MASKWHITE 0b1111111111111111
#define MASKBLACK 0b0000000000000000 #define MASKBLACK 0b0000000000000000
/* DMA */
static DMA_HandleTypeDef hdma_tx;
static DMA_HandleTypeDef hdma_rx;
/* Definition for SPIx's DMA */ /* Definition for SPIx's DMA */
#define SPIx_TX_DMA_CHANNEL DMA_CHANNEL_3 #define SPIx_TX_DMA_CHANNEL DMA_CHANNEL_3
#define SPIx_TX_DMA_STREAM DMA2_Stream5 #define SPIx_TX_DMA_STREAM DMA2_Stream3
#define SPIx_RX_DMA_CHANNEL DMA_CHANNEL_3 #define SPIx_RX_DMA_CHANNEL DMA_CHANNEL_3
#define SPIx_RX_DMA_STREAM DMA2_Stream2 #define SPIx_RX_DMA_STREAM DMA2_Stream2
/* Definition for SPIx's NVIC */ /* Definition for SPIx's NVIC */
#define SPIx_DMA_TX_IRQn DMA2_Stream3_IRQn #define SPIx_DMA_TX_IRQn DMA2_Stream3_IRQn
#define SPIx_DMA_RX_IRQn DMA2_Stream0_IRQn #define SPIx_DMA_RX_IRQn DMA2_Stream2_IRQn
#define SPIx_DMA_TX_IRQHandler DMA2_Stream3_IRQHandler #define SPIx_DMA_TX_IRQHandler DMA2_Stream3_IRQHandler
#define SPIx_DMA_RX_IRQHandler DMA2_Stream0_IRQHandler #define SPIx_DMA_RX_IRQHandler DMA2_Stream2_IRQHandler
SPI_HandleTypeDef SpiHandle; SPI_HandleTypeDef SpiHandle;
UART_HandleTypeDef UartHandle; UART_HandleTypeDef UartHandle;

View file

@ -241,9 +241,11 @@ void Adafruit_GFX_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
uint16_t color) { uint16_t color) {
// Update in subclasses if desired! // Update in subclasses if desired!
int16_t i; int16_t i;
for ( i=x; i<x+w; i++) { // for ( i=x; i<x+w; i++) {
Adafruit_ILI9340_drawFastVLine(i, y, h, color); // Adafruit_ILI9340_drawFastVLine(i, y, h, color);
} // }
Adafruit_ILI9340_fillRect(x, y, w, h, color);
} }
void Adafruit_GFX_fillScreen(uint16_t color) { void Adafruit_GFX_fillScreen(uint16_t color) {

View file

@ -65,6 +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];
// 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.)
@ -127,8 +128,8 @@ void Adafruit_ILI9340_writecommand(uint16_t c) {
txBuf[0] = c; // & 0xFF; txBuf[0] = c; // & 0xFF;
//spi_readWrite(SpiHandle, rxBuf, txBuf, 1); //spi_readWrite(SpiHandle, rxBuf, txBuf, 1);
HAL_SPI_Transmit(&SpiHandle, txBuf, 1 /*cnt * 2*/, 1); HAL_SPI_Transmit(&SpiHandle, txBuf, 1 /*cnt * 2*/, 1);
//HAL_SPI_Transmit_DMA(&SpiHandle, txBuf, 1);
//HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)txBuf, (uint8_t *)rxBuf, 1, 1000); //while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX);
//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);
@ -151,7 +152,8 @@ void Adafruit_ILI9340_writedata(uint16_t c) {
txBuf[0] = c; // & 0xFF; txBuf[0] = c; // & 0xFF;
//spi_readWrite(SpiHandle, rxBuf, txBuf, 1); //spi_readWrite(SpiHandle, rxBuf, txBuf, 1);
HAL_SPI_Transmit(&SpiHandle, txBuf, 1 /*cnt * 2*/, 1); HAL_SPI_Transmit(&SpiHandle, txBuf, 1 /*cnt * 2*/, 1);
//HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)txBuf, (uint8_t *)rxBuf, 1, 1000); //HAL_SPI_Transmit_DMA(&SpiHandle, txBuf, 1);
//while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX);
//digitalWrite(_cs, HIGH); //digitalWrite(_cs, HIGH);
//SET_BIT(csport, cspinmask); //SET_BIT(csport, cspinmask);
@ -561,18 +563,44 @@ void Adafruit_ILI9340_fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 0); HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 0);
//digitalWrite(_cs, LOW); //digitalWrite(_cs, LOW);
for(y=h; y>0; y--) { //for(y=h; y>0; y--) {
for(x=w; x>0; x--) { // for(x=w; x>0; x--) {
//spiwrite(hi); //spiwrite(hi);
//spiwrite(lo); //spiwrite(lo);
//txBuf[0] = hi; //txBuf[0] = hi;
//txBuf[1] = lo; //txBuf[1] = lo;
txBuf[0] = color; uint32_t totalPixels = h * w;
//uint8_t txBuf2[totalPixels * 2];
spi_readWrite(SpiHandle, rxBuf, txBuf, 1); for(uint32_t i = 0; i < totalPixels; i+=2)
//HAL_SPI_TransmitReceive(&SpiHandle, (uint8_t*)txBuf, (uint8_t*)rxBuf, 2, 1000); {
} //txBuf2[i] = color;
} txBuf2[i] = color >> 8;
txBuf2[i + 1] = color & 0xFF;
}
//for()= color;
//spi_readWrite(SpiHandle, rxBuf, txBuf, 1);
//hdma_tx.Init.MemInc = DMA_MINC_DISABLE;
//HAL_DMA_Init(&hdma_tx);
HAL_SPI_Transmit_DMA(&SpiHandle, &txBuf2, 0xFFFF);
while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX);
//HAL_SPI_Transmit_DMA(&SpiHandle, &txBuf2, 0xFFFF);
//while(SpiHandle.State == HAL_SPI_STATE_BUSY_TX);
//HAL_Delay(1000);
//hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
//HAL_DMA_Init(&hdma_tx);
//}
//}
//digitalWrite(_cs, HIGH); //digitalWrite(_cs, HIGH);
//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

@ -306,62 +306,61 @@ void teardownPeripheralPower()
void configDMA(SPI_HandleTypeDef *hspi) void configDMA(SPI_HandleTypeDef *hspi)
{ {
// static DMA_HandleTypeDef hdma_tx;
// static DMA_HandleTypeDef hdma_rx;
//
// hdma_tx.Instance = SPIx_TX_DMA_STREAM;
// hdma_tx.Instance = SPIx_TX_DMA_STREAM;
// 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; hdma_tx.Init.Mode = DMA_NORMAL;
// hdma_tx.Init.Mode = DMA_NORMAL; hdma_tx.Init.Priority = DMA_PRIORITY_LOW;
// hdma_tx.Init.Priority = DMA_PRIORITY_LOW; 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; hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4;
// hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4;
// HAL_DMA_Init(&hdma_tx);
// HAL_DMA_Init(&hdma_tx);
// /* Associate the initialized DMA handle to the the SPI handle */
// /* Associate the initialized DMA handle to the the SPI handle */ __HAL_LINKDMA(hspi, hdmatx, hdma_tx);
// __HAL_LINKDMA(hspi, hdmatx, hdma_tx);
// /* Configure the DMA handler for Transmission process */
// /* Configure the DMA handler for Transmission process */ hdma_rx.Instance = SPIx_RX_DMA_STREAM;
// hdma_rx.Instance = SPIx_RX_DMA_STREAM;
// hdma_rx.Init.Channel = SPIx_RX_DMA_CHANNEL;
// hdma_rx.Init.Channel = SPIx_RX_DMA_CHANNEL; hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
// hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE;
// hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_rx.Init.MemInc = DMA_MINC_ENABLE;
// hdma_rx.Init.MemInc = DMA_MINC_ENABLE; hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
// hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
// hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; hdma_rx.Init.Mode = DMA_NORMAL;
// hdma_rx.Init.Mode = DMA_NORMAL; hdma_rx.Init.Priority = DMA_PRIORITY_HIGH;
// hdma_rx.Init.Priority = DMA_PRIORITY_HIGH; hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
// hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
// hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_rx.Init.MemBurst = DMA_MBURST_INC4;
// hdma_rx.Init.MemBurst = DMA_MBURST_INC4; hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4;
// hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4;
// HAL_DMA_Init(&hdma_rx);
// HAL_DMA_Init(&hdma_rx);
// /* Associate the initialized DMA handle to the the SPI handle */
// /* Associate the initialized DMA handle to the the SPI handle */ __HAL_LINKDMA(hspi, hdmarx, hdma_rx);
// __HAL_LINKDMA(hspi, hdmarx, hdma_rx);
// /*##-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*/, 0, 1); 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();
} }
@ -987,7 +986,7 @@ main(int argc, char* argv[])
hal_setupPins(); hal_setupPins();
spi_init(); spi_init();
// configDMA(&SpiHandle ); configDMA(&SpiHandle );
//I2C_HandleTypeDef hi2c; //I2C_HandleTypeDef hi2c;
@ -1065,8 +1064,18 @@ setFreq(vfoAFrequency);
Adafruit_ILI9340_begin(); Adafruit_ILI9340_begin();
Adafruit_ILI9340_setRotation(1); Adafruit_ILI9340_setRotation(1);
//Adafruit_GFX_fillScreen(ILI9340_BLACK); //Adafruit_GFX_fillScreen(ILI9340_BLACK);
drawNumber('3', 0,0, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_BLACK); Adafruit_GFX_fillScreen(ILI9340_BLACK);
while(1)
{
// drawNumber('3', 0,0, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_BLUE);
// drawNumber('3', 5,5, 0xFFFF);
Adafruit_GFX_fillScreen(ILI9340_RED);
}
Adafruit_GFX_setTextSize(3); Adafruit_GFX_setTextSize(3);
Adafruit_GFX_setTextWrap(1); Adafruit_GFX_setTextWrap(1);
Adafruit_GFX_setTextColor(ILI9340_WHITE, ILI9340_BLACK); Adafruit_GFX_setTextColor(ILI9340_WHITE, ILI9340_BLACK);
@ -2027,6 +2036,20 @@ HAL_NVIC_EnableIRQ(TIM4_IRQn);
} }
void DMA2_Stream2_IRQHandler(void)
{
//doNothing();
HAL_DMA_IRQHandler(&hdma_rx);
//HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1);
}
void DMA2_Stream3_IRQHandler(void)
{
//doNothing();
HAL_DMA_IRQHandler(&hdma_tx);
//HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1);
}
void TIM3_IRQHandler(void) void TIM3_IRQHandler(void)
{ {
HAL_TIM_IRQHandler(&TimHandle); HAL_TIM_IRQHandler(&TimHandle);

View file

@ -18,6 +18,7 @@
#include <stm32f7xx_hal_spi.h> #include <stm32f7xx_hal_spi.h>
#include <stm32f7xx_hal_gpio.h> #include <stm32f7xx_hal_gpio.h>
#include <stm32f7xx_hal.h> #include <stm32f7xx_hal.h>
#include <stm32f7xx_hal_rcc.h>
#endif #endif
void spi_init(void) void spi_init(void)
@ -25,7 +26,7 @@ void spi_init(void)
//SPI_InitTypeDef spiInitStructure; //SPI_InitTypeDef spiInitStructure;
GPIO_InitTypeDef gpioInitStructure; GPIO_InitTypeDef gpioInitStructure;
HAL_SPI_MspInit(&SpiHandle);
__SPI1_CLK_ENABLE(); __SPI1_CLK_ENABLE();
@ -70,6 +71,27 @@ void spi_init(void)
// HAL_GPIO_Init(LCD_NSS.port, &gpioInitStructure); // HAL_GPIO_Init(LCD_NSS.port, &gpioInitStructure);
// //HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1); // TBD - should this be before init? // //HAL_GPIO_WritePin(LCD_NSS.port, LCD_NSS.pin, 1); // TBD - should this be before init?
//Configure NVIC if needed.
//Configure DMA
// DMA_HandleTypeDef DmaHandle;
// DMA_InitTypeDef dmaInitStructure;
//
// HAL_DMA_DeInit(DMA2_Stream3);
//
// dmaInitStructure.Channel = DMA_CHANNEL_3;
// dmaInitStructure.Direction =
//Already enabled in the peripheral power function.....
//__DMA1_CLK_ENABLE;
//__DMA2_CLK_ENABLE; //
//__HAL_RCC_DMA1_CLK_ENABLE;
//__HAL_RCC_DMA2_CLK_ENABLE;
//DmaHandle.Init.
//HAL_SPI_MspInit(&SpiHandle);
SpiHandle.Instance = SPI1; SpiHandle.Instance = SPI1;
SpiHandle.Init.Direction = SPI_DIRECTION_2LINES; SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
@ -78,12 +100,14 @@ void spi_init(void)
SpiHandle.Init.CLKPolarity = SPI_POLARITY_HIGH; SpiHandle.Init.CLKPolarity = SPI_POLARITY_HIGH;
SpiHandle.Init.CLKPhase = SPI_PHASE_2EDGE; SpiHandle.Init.CLKPhase = SPI_PHASE_2EDGE;
SpiHandle.Init.NSS = SPI_NSS_SOFT; //SPI_NSS_SOFT; SpiHandle.Init.NSS = SPI_NSS_SOFT; //SPI_NSS_SOFT;
SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; //SPI_BAUDRATEPRESCALER_2;
SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB; SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED; SpiHandle.Init.TIMode = SPI_TIMODE_DISABLED;
SpiHandle.Init.CRCPolynomial = 7; SpiHandle.Init.CRCPolynomial = 7;
if(HAL_SPI_Init(&SpiHandle) != HAL_OK) if(HAL_SPI_Init(&SpiHandle) != HAL_OK)
{ {
/* Initialization Error */ /* Initialization Error */
@ -124,9 +148,9 @@ void spi_readWrite(SPI_HandleTypeDef SpiH, uint16_t* rxBuf, uint16_t* txBuf, uin
txTmp[1] = txBuf[0] & 0xFF; txTmp[1] = txBuf[0] & 0xFF;
//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(&SpiH, txBuf, cnt); HAL_SPI_Transmit_DMA(&SpiHandle, txTmp, cnt);
//while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY); //while(HAL_SPI_GetState(&SpiH) != HAL_SPI_STATE_READY);
// //High, second edge // //High, second edge