From 46bf4306575fa31fccaff19f0a592f8b40dd46cb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Fri, 31 Mar 2023 16:28:17 +0200 Subject: it's working --- src/main.c | 25 +------------------------ src/ppu/stm.c | 13 ++++++++++--- src/stm32/setup.c | 3 ++- 3 files changed, 13 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index d8191b6..658fc94 100644 --- a/src/main.c +++ b/src/main.c @@ -12,30 +12,7 @@ void hh_ppu_vblank_interrupt() { #ifdef HH_TARGET_DESKTOP if (g_hh_test_complete) return; #endif - // // 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); - } - } + hh_ppu_vram_dwrite((uint8_t*) HH_PPUINTDEMO_ARR, HH_PPUINTDEMO_LENGTH); g_hh_test_complete = true; } diff --git a/src/ppu/stm.c b/src/ppu/stm.c index 8292d3c..8334090 100644 --- a/src/ppu/stm.c +++ b/src/ppu/stm.c @@ -8,9 +8,16 @@ void hh_ppu_init() {} 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, data, size, HAL_MAX_DELAY); + for (size_t i = 0; i < size; i += 4) { + if (i+4 > size) break; + uint8_t test[4] = { data[i+0], data[i+1], data[i+2], data[i+3], }; + HAL_SPI_Transmit(&hspi1, test, 4, HAL_MAX_DELAY); + // HAL_Delay(100); + } + HAL_SPI_Transmit(&hspi1, (uint8_t[4]){ 0xff }, size, HAL_MAX_DELAY); // reset SPI - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, true); - HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, false); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_SET); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); } diff --git a/src/stm32/setup.c b/src/stm32/setup.c index b0abe7a..4f56535 100644 --- a/src/stm32/setup.c +++ b/src/stm32/setup.c @@ -137,13 +137,14 @@ void hh_io_gpio_setup() { .Pin = GPIO_PIN_9, .Mode = GPIO_MODE_OUTPUT_PP, .Pull = GPIO_NOPULL, - .Speed = GPIO_SPEED_FREQ_LOW, + .Speed = GPIO_SPEED_FREQ_HIGH, }); HAL_GPIO_Init(GPIOA, &(GPIO_InitTypeDef) { .Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_8, .Mode = GPIO_MODE_INPUT, .Pull = GPIO_PULLDOWN, }); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_9, GPIO_PIN_RESET); } void HAL_MspInit() { -- cgit v1.2.3