diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-03-30 17:00:05 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-03-30 17:00:05 +0200 |
commit | fa296fbc6fe1c423932189116bd0cb949de0beef (patch) | |
tree | fc7de2beb8c06e1e244caf0ca201d03c690b657e | |
parent | 6292c1101121bc8ba2db752cab3cbe41469b29d0 (diff) |
spi not working on hardware
-rw-r--r-- | basys3/basys3.srcs/.gitignore | 1 | ||||
-rw-r--r-- | basys3/basys3.srcs/makefile | 5 | ||||
-rw-r--r-- | basys3/basys3.srcs/ppu_tb.vhd.m4 | 3 | ||||
-rw-r--r-- | basys3/basys3.srcs/spi_tb.vhd | 607 | ||||
-rw-r--r-- | basys3/basys3.srcs/spi_tb.vhd.m4 | 47 | ||||
-rw-r--r-- | basys3/basys3.xpr | 2 | ||||
-rw-r--r-- | src/main.c | 25 | ||||
-rw-r--r-- | src/ppu/stm.c | 2 | ||||
-rw-r--r-- | src/stm32/setup.c | 2 | ||||
-rw-r--r-- | test/ppu-stm-integration-demo/data.h | 4 | ||||
-rwxr-xr-x | test/ppu-stm-integration-demo/data2pputb.awk (renamed from test/ppu-stm-integration-demo/data2vhdltb.awk) | 0 | ||||
-rwxr-xr-x | test/ppu-stm-integration-demo/data2spitb.awk | 20 | ||||
-rw-r--r-- | test/ppu-stm-integration-demo/makefile | 9 |
13 files changed, 498 insertions, 229 deletions
diff --git a/basys3/basys3.srcs/.gitignore b/basys3/basys3.srcs/.gitignore index dd85c9b..e541866 100644 --- a/basys3/basys3.srcs/.gitignore +++ b/basys3/basys3.srcs/.gitignore @@ -1 +1,2 @@ ppu_tb.vhd +spi_tb.vhd diff --git a/basys3/basys3.srcs/makefile b/basys3/basys3.srcs/makefile index 61fab40..d37593c 100644 --- a/basys3/basys3.srcs/makefile +++ b/basys3/basys3.srcs/makefile @@ -1,4 +1,7 @@ -ppu_tb.vhd: ppu_tb.vhd.m4 ../../test/ppu-stm-integration-demo/test-image.tb.vhd +all: ppu_tb.vhd spi_tb.vhd + +ppu_tb.vhd: ppu_tb.vhd.m4 ../../test/ppu-stm-integration-demo/test-image-ppu.tb.vhd +spi_tb.vhd: spi_tb.vhd.m4 ../../test/ppu-stm-integration-demo/test-image-spi.tb.vhd %.vhd: %.vhd.m4 m4 -I../../test/ppu-stm-integration-demo/ $< > $@ diff --git a/basys3/basys3.srcs/ppu_tb.vhd.m4 b/basys3/basys3.srcs/ppu_tb.vhd.m4 index 0797c9f..97f0aef 100644 --- a/basys3/basys3.srcs/ppu_tb.vhd.m4 +++ b/basys3/basys3.srcs/ppu_tb.vhd.m4 @@ -1,3 +1,4 @@ +-- vim: ft=vhdl library ieee; library unisim; use ieee.std_logic_1164.all; @@ -48,7 +49,7 @@ begin process begin - -- undivert(`test-image.tb.vhd') -- m4 macro expansion (see makefile) + -- undivert(`test-image-ppu.tb.vhd') -- m4 macro expansion (see makefile) wait; -- stop after one loop (process loops in simulator) end process; end Behavioral; diff --git a/basys3/basys3.srcs/spi_tb.vhd b/basys3/basys3.srcs/spi_tb.vhd index 8e4b8aa..255f38b 100644 --- a/basys3/basys3.srcs/spi_tb.vhd +++ b/basys3/basys3.srcs/spi_tb.vhd @@ -1,3 +1,4 @@ +-- vim: ft=vhdl library ieee; library unisim; @@ -25,7 +26,7 @@ begin process begin - for i in 0 to 10000 loop + while true loop wait for 5 ns; SYSCLK <= '1'; wait for 5 ns; @@ -36,227 +37,397 @@ begin process begin - for i in 0 to 2 loop - -- data = 0b01010110010100001001110011111111 (0x56509cff) - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - - SPI_DATA <= '1'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - end loop; + -- -- 0xdc00: 0f0f +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; +-- +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '0'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +-- 0xffff: ffff +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; +-- +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + +SPI_DATA <= '1'; +wait for 50 ns; +SPI_CLK <= '1'; +wait for 50 ns; +SPI_CLK <= '0'; + + -- m4 macro expansion (see makefile) - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - wait for 50 ns; - SPI_CLK <= '1'; - wait for 50 ns; - SPI_CLK <= '0'; - wait for 50 ns; RESET <= '1'; wait for 50 ns; RESET <= '0'; - - wait; -- stop for simulator end process; end; diff --git a/basys3/basys3.srcs/spi_tb.vhd.m4 b/basys3/basys3.srcs/spi_tb.vhd.m4 new file mode 100644 index 0000000..cf76b2c --- /dev/null +++ b/basys3/basys3.srcs/spi_tb.vhd.m4 @@ -0,0 +1,47 @@ +-- vim: ft=vhdl +library ieee; +library unisim; + +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; +use unisim.vcomponents.all; +use work.ppu_consts.all; + +entity spi_tb is +end spi_tb; + +architecture behavioral of spi_tb is + signal SYSCLK : std_logic := '0'; + signal SPI_CLK : std_logic := '0'; + signal SPI_DATA : std_logic := '0'; + signal RESET : std_logic := '0'; +begin + uut : entity work.spi port map( + SYSCLK => SYSCLK, + RESET => RESET, + DO => open, + DI => SPI_DATA, + DCK => SPI_CLK, + WEN => open); + + process + begin + while true loop + wait for 5 ns; + SYSCLK <= '1'; + wait for 5 ns; + SYSCLK <= '0'; + end loop; + wait; -- stop for simulator + end process; + + process + begin + -- undivert(`test-background-color-spi.tb.vhd') -- m4 macro expansion (see makefile) + + RESET <= '1'; + wait for 50 ns; + RESET <= '0'; + wait; -- stop for simulator + end process; +end; diff --git a/basys3/basys3.xpr b/basys3/basys3.xpr index 19bbeec..f90ecdb 100644 --- a/basys3/basys3.xpr +++ b/basys3/basys3.xpr @@ -60,7 +60,7 @@ <Option Name="IPStaticSourceDir" Val="$PIPUSERFILESDIR/ipstatic"/> <Option Name="EnableBDX" Val="FALSE"/> <Option Name="DSABoardId" Val="basys3"/> - <Option Name="WTXSimLaunchSim" Val="108"/> + <Option Name="WTXSimLaunchSim" Val="118"/> <Option Name="WTModelSimLaunchSim" Val="0"/> <Option Name="WTQuestaLaunchSim" Val="0"/> <Option Name="WTIesLaunchSim" Val="0"/> @@ -12,7 +12,30 @@ void hh_ppu_vblank_interrupt() { #ifdef HH_TARGET_DESKTOP if (g_hh_test_complete) return; #endif - hh_ppu_vram_dwrite((uint8_t*) HH_PPUINTDEMO_ARR, HH_PPUINTDEMO_LENGTH); + // // uint8_t test[4] = { 0x0f, 0x0f, 0xf0, 0xf0 }; + // uint8_t* test = malloc(4); + // test[0] = 0x00; + // test[1] = 0x00; + // test[2] = 0x00; + // test[3] = 0x00; + // while (1) + // hh_ppu_vram_dwrite(test, 4); + // return; + if (1) { + hh_ppu_vram_dwrite((uint8_t*) HH_PPUINTDEMO_ARR, HH_PPUINTDEMO_LENGTH); + } + if (0) { + for (size_t i = 0; i < HH_PPUINTDEMO_LENGTH; i += 4) { + if (i+4 > HH_PPUINTDEMO_LENGTH) break; + uint8_t test[4] = { + HH_PPUINTDEMO_ARR[i+0], + HH_PPUINTDEMO_ARR[i+1], + HH_PPUINTDEMO_ARR[i+2], + HH_PPUINTDEMO_ARR[i+3], + }; + hh_ppu_vram_dwrite(test, 4); + } + } g_hh_test_complete = true; } diff --git a/src/ppu/stm.c b/src/ppu/stm.c index 18811cf..8292d3c 100644 --- a/src/ppu/stm.c +++ b/src/ppu/stm.c @@ -9,7 +9,7 @@ void hh_ppu_deinit() {} void hh_ppu_vram_dwrite(uint8_t* data, size_t size) { HAL_SPI_Transmit(&hspi1, data, size, HAL_MAX_DELAY); - HAL_SPI_Transmit(&hspi1, (uint8_t[4]) { 0xff, 0xff, 0xff, 0xff }, 4, HAL_MAX_DELAY); + // reset SPI HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, true); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, false); } diff --git a/src/stm32/setup.c b/src/stm32/setup.c index b4112d3..b0abe7a 100644 --- a/src/stm32/setup.c +++ b/src/stm32/setup.c @@ -133,7 +133,6 @@ void hh_io_gpio_setup() { __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET); HAL_GPIO_Init(GPIOA, &(GPIO_InitTypeDef) { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_OUTPUT_PP, @@ -165,6 +164,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi) { if(hspi->Instance != SPI1) return; __HAL_RCC_SPI1_CLK_DISABLE(); + __HAL_RCC_GPIOA_CLK_DISABLE(); HAL_GPIO_DeInit(HH_IO_SPI_PORT, HH_IO_SPI_PINS); } diff --git a/test/ppu-stm-integration-demo/data.h b/test/ppu-stm-integration-demo/data.h index ac73e66..cdca4a5 100644 --- a/test/ppu-stm-integration-demo/data.h +++ b/test/ppu-stm-integration-demo/data.h @@ -1,5 +1,5 @@ #pragma once -// #include "test-image.h" -#include "test-background-color.h" +#include "test-image.h" +// #include "test-background-color.h" diff --git a/test/ppu-stm-integration-demo/data2vhdltb.awk b/test/ppu-stm-integration-demo/data2pputb.awk index db4b53f..db4b53f 100755 --- a/test/ppu-stm-integration-demo/data2vhdltb.awk +++ b/test/ppu-stm-integration-demo/data2pputb.awk diff --git a/test/ppu-stm-integration-demo/data2spitb.awk b/test/ppu-stm-integration-demo/data2spitb.awk new file mode 100755 index 0000000..6caf9a3 --- /dev/null +++ b/test/ppu-stm-integration-demo/data2spitb.awk @@ -0,0 +1,20 @@ +#!/bin/awk -f +BEGIN { } + +{ + data = strtonum("0x"$1$2) + print "-- 0x"$1": "$2 + + for (i = 0; i < 32; i++) { + print "SPI_DATA <= '"and(rshift(data, 31), 1)"';" + print "wait for 50 ns;" + print "SPI_CLK <= '1';" + print "wait for 50 ns;" + print "SPI_CLK <= '0';" + if (i == 15) print "--" + else print "" + data = lshift(data, 1) + } +} + +END { } diff --git a/test/ppu-stm-integration-demo/makefile b/test/ppu-stm-integration-demo/makefile index 2f4b6f4..853dd31 100644 --- a/test/ppu-stm-integration-demo/makefile +++ b/test/ppu-stm-integration-demo/makefile @@ -1,14 +1,17 @@ .PHONY: all clean -TARGETS := test-background-color.h test-image.h test-image.tb.vhd +TARGETS := test-background-color.h test-image.h test-image-spi.tb.vhd test-image-ppu.tb.vhd test-background-color-spi.tb.vhd all: $(TARGETS) %.h: %.txt ./data2test.awk tr -d ':' < $< | ./data2test.awk > $@ -test-%.tb.vhd: test-%.txt ./data2vhdltb.awk - tr -d ':' < $< | ./data2vhdltb.awk > $@ +test-%-ppu.tb.vhd: test-%.txt ./data2pputb.awk + tr -d ':' < $< | ./data2pputb.awk > $@ + +test-%-spi.tb.vhd: test-%.txt ./data2spitb.awk + (tr -d ':' < $<; echo "ffff ffff") | ./data2spitb.awk > $@ clean: $(RM) $(TARGETS) |