changed CIC initialization to be non blocking regardless of RTC init status

This commit is contained in:
Mateusz Faderewski 2023-12-12 15:08:42 +01:00
parent e1d9a8def3
commit fd8395fcc0
3 changed files with 19 additions and 7 deletions

View File

@ -26,7 +26,7 @@ void init (init_tv_type_t tv_type, init_reset_type_t reset_type) {
exception_enable_interrupts();
if ((error = sc64_set_config(CFG_ID_BOOTLOADER_SWITCH, false)) != SC64_OK) {
error_display("Command SET_CONFIG [BOOTLOADER_SWITCH] failed: %d", error);
error_display("Command CONFIG_SET [BOOTLOADER_SWITCH] failed: %d", error);
}
if (test_check()) {
@ -36,7 +36,8 @@ void init (init_tv_type_t tv_type, init_reset_type_t reset_type) {
}
void deinit (void) {
sc64_lock();
exception_disable_interrupts();
exception_disable_watchdog();
sc64_lock();
}

View File

@ -12,6 +12,9 @@ typedef enum {
} cic_region_t;
static bool cic_initialized = false;
static void cic_irq_reset_falling (void) {
led_clear_error(LED_ERROR_CIC);
}
@ -65,18 +68,26 @@ void cic_set_dd_mode (bool enabled) {
void cic_init (void) {
while (!rtc_is_initialized());
cic_reset_parameters();
hw_gpio_irq_setup(GPIO_ID_N64_RESET, GPIO_IRQ_FALLING, cic_irq_reset_falling);
}
void cic_process (void) {
if (!cic_initialized) {
if (rtc_is_initialized()) {
cic_reset_parameters();
cic_initialized = true;
} else {
return;
}
}
uint32_t cic_config_0 = fpga_reg_get(REG_CIC_0);
if (cic_config_0 & CIC_INVALID_REGION_DETECTED) {
cic_config_0 ^= CIC_REGION;
fpga_reg_set(REG_CIC_0, (cic_config_0 | CIC_INVALID_REGION_RESET));
cic_config_0 |= CIC_INVALID_REGION_RESET;
fpga_reg_set(REG_CIC_0, cic_config_0);
if (cic_config_0 & CIC_REGION) {
rtc_set_region(REGION_PAL);

View File

@ -200,8 +200,6 @@ static void rtc_init (void) {
rtc_write(RTC_ADDRESS_SRAM_VERSION, (uint8_t *) (&settings_version), 4);
rtc_write_settings();
}
rtc_initialized = true;
}
@ -275,6 +273,8 @@ void rtc_task (void) {
rtc_read_region();
rtc_read_settings();
rtc_initialized = true;
while (1) {
if (rtc_time_pending) {
rtc_time_pending = false;