aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-03-31 16:28:17 +0200
committerlonkaars <loek@pipeframe.xyz>2023-03-31 16:28:17 +0200
commit46bf4306575fa31fccaff19f0a592f8b40dd46cb (patch)
tree0f317374e4d81af5862804d588ca05f44c7fb325 /src
parentfa296fbc6fe1c423932189116bd0cb949de0beef (diff)
it's working
Diffstat (limited to 'src')
-rw-r--r--src/main.c25
-rw-r--r--src/ppu/stm.c13
-rw-r--r--src/stm32/setup.c3
3 files changed, 13 insertions, 28 deletions
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() {