aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2023-03-11 11:42:05 +0000
committerMarc Zyngier <maz@kernel.org>2023-03-11 11:42:05 +0000
commit40fee32f3b5f22c3336667c6d39dd11c0782c536 (patch)
tree5299f972dd2620c474897af89bba6436d3d34655
parent9428c1798b13eaaa45ea082274d654d0dc71df55 (diff)
downloadcs-sw-40fee32f3b5f22c3336667c6d39dd11c0782c536.tar.gz
Blinky activity LED
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r--vdmtool.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/vdmtool.c b/vdmtool.c
index ed67c13..f6a01a9 100644
--- a/vdmtool.c
+++ b/vdmtool.c
@@ -647,6 +647,12 @@ static bool m1_pd_bmc_run_one(struct vdm_context *cxt)
return serial_handler(cxt) || cxt->pending;
}
+#define for_each_cxt(___c) \
+ for (struct vdm_context *___c = &vdm_contexts[0]; \
+ (___c - vdm_contexts) < CONFIG_USB_PD_PORT_COUNT; \
+ ___c++) \
+ if (___c->hw)
+
void m1_pd_bmc_run(void)
{
int i;
@@ -654,24 +660,23 @@ void m1_pd_bmc_run(void)
while (1) {
bool busy = false;
- for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
- if (!vdm_contexts[i].hw)
- continue;
-
- busy |= m1_pd_bmc_run_one(&vdm_contexts[i]);
- irq_set_enabled(vdm_contexts[i].hw->uart_irq, false);
+ for_each_cxt(cxt) {
+ gpio_put(PIN(cxt, LED_G), HIGH);
+ busy |= m1_pd_bmc_run_one(cxt);
+ irq_set_enabled(cxt->hw->uart_irq, false);
}
tud_task();
- for (i = 0; i < CONFIG_USB_PD_PORT_COUNT; i++) {
- if (!vdm_contexts[i].hw)
- continue;
+ for_each_cxt(cxt)
+ irq_set_enabled(cxt->hw->uart_irq, true);
- irq_set_enabled(vdm_contexts[i].hw->uart_irq, true);
- }
+ if (busy)
+ continue;
+
+ for_each_cxt(cxt)
+ gpio_put(PIN(cxt, LED_G), LOW);
- if (!busy)
- __wfe();
+ __wfe();
}
}