Skip to content

Commit

Permalink
[NPISO] Init all data pin regardless of config
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Nov 3, 2023
1 parent a1c7fc3 commit f603757
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions main/wired/npiso_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,32 +623,6 @@ void npiso_init(uint32_t package)
}
}

/* Famicom port only detect */
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.pin_bit_mask = 1ULL << FC_ONLY_MODE_PIN;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config_iram(&io_conf);
if (!(GPIO.in1.val & (1U << (FC_ONLY_MODE_PIN - 32)))) {
if (dev_type[0] == DEV_FC_KB) {
gpio_pins[0][NPISO_CLK] = P2_CLK_PIN;
gpio_mask[0][NPISO_CLK] = P2_CLK_MASK;
gpio_pins[0][NPISO_D0] = P2_D0_PIN;
gpio_mask[0][NPISO_D0] = P2_D0_MASK;
gpio_pins[1][NPISO_CLK] = P1_CLK_PIN;
gpio_mask[1][NPISO_CLK] = P1_CLK_MASK;
gpio_pins[1][NPISO_D0] = P1_D1_PIN;
gpio_mask[1][NPISO_D0] = P1_D1_MASK;
}
else {
gpio_pins[0][NPISO_D0] = P1_D1_PIN;
gpio_mask[0][NPISO_D0] = P1_D1_MASK;
gpio_pins[1][NPISO_D0] = P2_D1_PIN;
gpio_mask[1][NPISO_D0] = P2_D1_MASK;
}
}

/* Latch */
io_conf.intr_type = GPIO_INTR_POSEDGE;
io_conf.pin_bit_mask = 1ULL << NPISO_LATCH_PIN;
Expand Down Expand Up @@ -676,16 +650,15 @@ void npiso_init(uint32_t package)
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config_iram(&io_conf);
set_data(i, j & 0x1, 1);
set_data(i, j & 0x1, 1);
}
}

/* D2, D3, D4 */
if (dev_type[0] == DEV_FC_KB) {
for (uint32_t i = 0; i < sizeof(kb_gpio_pins); i++) {
io_conf.pin_bit_mask = 1ULL << kb_gpio_pins[i];
gpio_config_iram(&io_conf);
}
for (uint32_t i = 0; i < sizeof(kb_gpio_pins); i++) {
io_conf.pin_bit_mask = 1ULL << kb_gpio_pins[i];
gpio_config_iram(&io_conf);
GPIO.out_w1ts = 1U << kb_gpio_pins[i];
}

/* P1 Select */
Expand Down Expand Up @@ -722,6 +695,32 @@ void npiso_init(uint32_t package)
gpio_set_level_iram(VTAP_MODE_PIN, 1);
}

/* Famicom port only detect */
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.pin_bit_mask = 1ULL << FC_ONLY_MODE_PIN;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config_iram(&io_conf);
if (!(GPIO.in1.val & (1U << (FC_ONLY_MODE_PIN - 32)))) {
if (dev_type[0] == DEV_FC_KB) {
gpio_pins[0][NPISO_CLK] = P2_CLK_PIN;
gpio_mask[0][NPISO_CLK] = P2_CLK_MASK;
gpio_pins[0][NPISO_D0] = P2_D0_PIN;
gpio_mask[0][NPISO_D0] = P2_D0_MASK;
gpio_pins[1][NPISO_CLK] = P1_CLK_PIN;
gpio_mask[1][NPISO_CLK] = P1_CLK_MASK;
gpio_pins[1][NPISO_D0] = P1_D1_PIN;
gpio_mask[1][NPISO_D0] = P1_D1_MASK;
}
else {
gpio_pins[0][NPISO_D0] = P1_D1_PIN;
gpio_mask[0][NPISO_D0] = P1_D1_MASK;
gpio_pins[1][NPISO_D0] = P2_D1_PIN;
gpio_mask[1][NPISO_D0] = P2_D1_MASK;
}
}

if (dev_type[1] == DEV_SFC_SNES_MULTITAP) {
intexc_alloc_iram(ETS_GPIO_INTR_SOURCE, 19, npiso_sfc_snes_5p_isr);
}
Expand Down

0 comments on commit f603757

Please sign in to comment.