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 /src | |
parent | 6292c1101121bc8ba2db752cab3cbe41469b29d0 (diff) |
spi not working on hardware
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 25 | ||||
-rw-r--r-- | src/ppu/stm.c | 2 | ||||
-rw-r--r-- | src/stm32/setup.c | 2 |
3 files changed, 26 insertions, 3 deletions
@@ -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); } |