|
@@ -78,6 +78,7 @@ static void update_state(NRF51GPIOState *s)
|
|
int pull;
|
|
int pull;
|
|
size_t i;
|
|
size_t i;
|
|
bool connected_out, dir, connected_in, out, in, input;
|
|
bool connected_out, dir, connected_in, out, in, input;
|
|
|
|
+ bool assert_detect = false;
|
|
|
|
|
|
for (i = 0; i < NRF51_GPIO_PINS; i++) {
|
|
for (i = 0; i < NRF51_GPIO_PINS; i++) {
|
|
pull = pull_value(s->cnf[i]);
|
|
pull = pull_value(s->cnf[i]);
|
|
@@ -99,7 +100,15 @@ static void update_state(NRF51GPIOState *s)
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
"GPIO pin %zu short circuited\n", i);
|
|
"GPIO pin %zu short circuited\n", i);
|
|
}
|
|
}
|
|
- if (!connected_in) {
|
|
|
|
|
|
+ if (connected_in) {
|
|
|
|
+ uint32_t detect_config = extract32(s->cnf[i], 16, 2);
|
|
|
|
+ if ((detect_config == 2) && (in == 1)) {
|
|
|
|
+ assert_detect = true;
|
|
|
|
+ }
|
|
|
|
+ if ((detect_config == 3) && (in == 0)) {
|
|
|
|
+ assert_detect = true;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
/*
|
|
/*
|
|
* Floating input: the output stimulates IN if connected,
|
|
* Floating input: the output stimulates IN if connected,
|
|
* otherwise pull-up/pull-down resistors put a value on both
|
|
* otherwise pull-up/pull-down resistors put a value on both
|
|
@@ -116,6 +125,8 @@ static void update_state(NRF51GPIOState *s)
|
|
}
|
|
}
|
|
update_output_irq(s, i, connected_out, out);
|
|
update_output_irq(s, i, connected_out, out);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ qemu_set_irq(s->detect, assert_detect);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -291,6 +302,7 @@ static void nrf51_gpio_init(Object *obj)
|
|
|
|
|
|
qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS);
|
|
qdev_init_gpio_in(DEVICE(s), nrf51_gpio_set, NRF51_GPIO_PINS);
|
|
qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS);
|
|
qdev_init_gpio_out(DEVICE(s), s->output, NRF51_GPIO_PINS);
|
|
|
|
+ qdev_init_gpio_out_named(DEVICE(s), &s->detect, "detect", 1);
|
|
}
|
|
}
|
|
|
|
|
|
static void nrf51_gpio_class_init(ObjectClass *klass, void *data)
|
|
static void nrf51_gpio_class_init(ObjectClass *klass, void *data)
|