diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-04-06 16:49:36 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-04-06 16:49:36 +0200 |
commit | 892424ba4d0c979e4351f7a866b6fe777783e4d2 (patch) | |
tree | d6688765834be74370038d8662703bd83b1acd40 /src/ppu | |
parent | 4881723cf765fbd7bad2a1f08baf5897a7425401 (diff) |
dma send done and working
Diffstat (limited to 'src/ppu')
-rw-r--r-- | src/ppu/internals.c | 18 | ||||
-rw-r--r-- | src/ppu/stm.c | 3 |
2 files changed, 10 insertions, 11 deletions
diff --git a/src/ppu/internals.c b/src/ppu/internals.c index 2d90665..7fd2eb9 100644 --- a/src/ppu/internals.c +++ b/src/ppu/internals.c @@ -4,8 +4,9 @@ #include "ppu/internals.h" #include "ppu/types.h" -uint8_t g_hh_ppu_vram_buffer[HH_PPU_COMMAND_BUFFER_SIZE * 2] = { 0 }; -uint8_t* g_hh_ppu_vram_buffer_ptr = g_hh_ppu_vram_buffer; +bool g_hh_ppu_vram_buffer_swap = false; +uint8_t g_hh_ppu_vram_buffer_raw[HH_PPU_COMMAND_BUFFER_SIZE * 2] = { 0 }; +uint8_t* g_hh_ppu_vram_buffer_ptr = g_hh_ppu_vram_buffer_raw; size_t g_hh_ppu_vram_buffer_size = 0; bool hh_ppu_vram_valid_address(hh_ppu_addr_t addr) { @@ -96,19 +97,18 @@ hh_s_ppu_vram_data hh_ppu_2nat_color(hh_ppu_rgb_color_t rgb) { void hh_ppu_vram_buffer(uint8_t data[4]) { size_t head = g_hh_ppu_vram_buffer_size; - g_hh_ppu_vram_buffer[head+0] = data[0]; - g_hh_ppu_vram_buffer[head+1] = data[1]; - g_hh_ppu_vram_buffer[head+2] = data[2]; - g_hh_ppu_vram_buffer[head+3] = data[3]; + g_hh_ppu_vram_buffer_ptr[head+0] = data[0]; // NOTE: this only works because sizeof(buffer) is divisible by 4 + g_hh_ppu_vram_buffer_ptr[head+1] = data[1]; + g_hh_ppu_vram_buffer_ptr[head+2] = data[2]; + g_hh_ppu_vram_buffer_ptr[head+3] = data[3]; g_hh_ppu_vram_buffer_size += 4; } void hh_ppu_vram_flush() { - static bool buffer_swap = false; - buffer_swap = !buffer_swap; hh_ppu_vram_buffer((uint8_t[4]){ 0xff, 0xff, 0xff, 0xff }); hh_ppu_vram_dwrite(g_hh_ppu_vram_buffer_ptr, g_hh_ppu_vram_buffer_size); g_hh_ppu_vram_buffer_size = 0; - g_hh_ppu_vram_buffer_ptr = g_hh_ppu_vram_buffer + (buffer_swap * HH_PPU_COMMAND_BUFFER_SIZE); + g_hh_ppu_vram_buffer_ptr = g_hh_ppu_vram_buffer_raw + g_hh_ppu_vram_buffer_swap * HH_PPU_COMMAND_BUFFER_SIZE; + g_hh_ppu_vram_buffer_swap = !g_hh_ppu_vram_buffer_swap; } diff --git a/src/ppu/stm.c b/src/ppu/stm.c index 6bd9f66..ddd62b9 100644 --- a/src/ppu/stm.c +++ b/src/ppu/stm.c @@ -13,7 +13,6 @@ void hh_ppu_deinit() {} void hh_ppu_vram_dwrite(uint8_t* data, size_t size) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); - HAL_SPI_Transmit_IT(&hspi1, data, size); - // HAL_SPI_Transmit_IT(&hspi1, (uint8_t[4]){ 0xff }, 4); + HAL_SPI_Transmit_DMA(&hspi1, data, size); } |