diff --git a/src/boards/board_C3_DevKitC.cc b/src/boards/board_C3_DevKitC.cc index 6ae06509..23e76aad 100644 --- a/src/boards/board_C3_DevKitC.cc +++ b/src/boards/board_C3_DevKitC.cc @@ -320,7 +320,7 @@ void cboard_C3_DevKitC::Reset(void) { if (qemu_started != 1) { return; } - uint32_t* strap_mode = qemu_picsimlab_get_internals(0); + uint32_t* strap_mode = qemu_picsimlab_get_internals(QEMU_INTERNAL_STRAP); if (p_BOOT) { *strap_mode = 0x08; // SPI_FAST_FLASH_BOOT @@ -564,6 +564,8 @@ void cboard_C3_DevKitC::Run_CPU_ns(uint64_t time) { const float RNSTEP = 200.0 * pinc * inc_ns / TTIMEOUT; + MSetPin(IO0, p_BOOT); + for (uint64_t c = 0; c < time; c += inc_ns) { if (ns_count < inc_ns) { // reset pins mean value @@ -648,7 +650,7 @@ void cboard_C3_DevKitC::Run_CPU(void) { } if (!(status & CHR_TIOCM_CTS) && (status & CHR_TIOCM_DSR)) { - uint32_t* strap_mode = qemu_picsimlab_get_internals(0); + uint32_t* strap_mode = qemu_picsimlab_get_internals(QEMU_INTERNAL_STRAP); *strap_mode = 0x02; // UART_BOOT(UART0) MReset(1); } @@ -789,8 +791,8 @@ void cboard_C3_DevKitC::board_ButtonEvent(CControl* control, uint button, uint x void cboard_C3_DevKitC::PinsExtraConfig(int cfg) { switch ((cfg & 0xf000) >> 12) { - case 1: { // Peripheral Signal input - uint32_t* gpio_in_sel = qemu_picsimlab_get_internals(1); + case QEMU_EXTRA_PIN_IN_CFG: { // Peripheral Signal input + uint32_t* gpio_in_sel = qemu_picsimlab_get_internals(QEMU_INTERNAL_GPIO_IN_SEL); int function = cfg & 0x1ff; int gpio = gpio_in_sel[cfg & 0x1ff] & 0x1F; @@ -843,9 +845,9 @@ void cboard_C3_DevKitC::PinsExtraConfig(int cfg) { } } break; - case 2: { // Peripheral Signal output - uint32_t* gpio_out_sel = qemu_picsimlab_get_internals(2); - // uint32_t* muxgpios = qemu_picsimlab_get_internals(3); + case QEMU_EXTRA_PIN_OUT_CFG: { // Peripheral Signal output + uint32_t* gpio_out_sel = qemu_picsimlab_get_internals(QEMU_INTERNAL_GPIO_OUT_SEL); + // uint32_t* muxgpios = qemu_picsimlab_get_internals(QEMU_INTERNAL_IOMUX_GPIOS); int function = gpio_out_sel[cfg & 0xff] & 0xFF; int gpio = cfg & 0xff; @@ -939,8 +941,8 @@ void cboard_C3_DevKitC::PinsExtraConfig(int cfg) { } } break; - case 4: { // IO MUX Functions - uint32_t* muxgpios = qemu_picsimlab_get_internals(3); + case QEMU_EXTRA_PIN_IOMUX_CFG: { // IO MUX Functions + uint32_t* muxgpios = qemu_picsimlab_get_internals(QEMU_INTERNAL_IOMUX_GPIOS); int function = (muxgpios[cfg & 0xff] & 0x7000) >> 12; int gpio = cfg & 0xff; diff --git a/src/boards/bsim_qemu.cc b/src/boards/bsim_qemu.cc index bb624f2d..16e4b14f 100644 --- a/src/boards/bsim_qemu.cc +++ b/src/boards/bsim_qemu.cc @@ -113,7 +113,7 @@ static void picsimlab_dir_pins(int pin, int dir) { ioupdated = 1; g_board->Run_CPU_ns(GotoNow()); } else { // especial pin cfg - g_board->PinsExtraConfig(-dir); + g_board->PinsExtraConfig(dir); } // printf("pin[%i]=%s\n", pin, (!dir == PD_IN) ? "PD_IN" : "PD_OUT"); } diff --git a/src/boards/qemu.h b/src/boards/qemu.h index 90bedafb..8938fbc9 100644 --- a/src/boards/qemu.h +++ b/src/boards/qemu.h @@ -108,4 +108,14 @@ enum i2c_event { I2C_WRITE, I2C_READ }; + +#define QEMU_INTERNAL_STRAP 0 +#define QEMU_INTERNAL_GPIO_IN_SEL 1 +#define QEMU_INTERNAL_GPIO_OUT_SEL 2 +#define QEMU_INTERNAL_IOMUX_GPIOS 3 + +#define QEMU_EXTRA_PIN_IN_CFG 1 +#define QEMU_EXTRA_PIN_OUT_CFG 2 +#define QEMU_EXTRA_PIN_IOMUX_CFG 4 +#define QEMU_EXTRA_PIN_LEDC_CFG 5 } \ No newline at end of file