Skip to content

Commit

Permalink
chg: Remove negative signal in qemu dir updated callback !minor
Browse files Browse the repository at this point in the history
  • Loading branch information
lcgamboa committed Sep 30, 2023
1 parent 824cdb7 commit eb697b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
20 changes: 11 additions & 9 deletions src/boards/board_C3_DevKitC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/boards/bsim_qemu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
10 changes: 10 additions & 0 deletions src/boards/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit eb697b4

Please sign in to comment.