5 #include "sw/device/examples/demos.h"
14 #include "sw/device/lib/testing/test_framework/check.h"
16 void demo_gpio_startup(dif_gpio_t *gpio) {
32 static const uint32_t kGpioMask = 0x400f00;
37 static const uint32_t kFtdiMask = 0x400000;
39 uint32_t demo_gpio_to_log_echo(dif_gpio_t *gpio, uint32_t prev_gpio_state) {
42 gpio_state &= kGpioMask;
44 uint32_t state_delta = prev_gpio_state ^ gpio_state;
45 for (
int bit_idx = 0; bit_idx < 8; ++bit_idx) {
46 bool changed = ((state_delta >> bit_idx) & 0x1) != 0;
47 bool is_currently_set = ((gpio_state >> bit_idx) & 0x1) != 0;
49 LOG_INFO(
"GPIO switch #%d changed to %d", bit_idx, is_currently_set);
53 if ((state_delta & kFtdiMask) != 0) {
54 if ((gpio_state & kFtdiMask) != 0) {
55 LOG_INFO(
"FTDI control changed. Enable JTAG.");
57 LOG_INFO(
"FTDI control changed. Enable JTAG.");
64 void demo_uart_to_uart_and_gpio_echo(dif_uart_t *uart, dif_gpio_t *gpio) {
66 size_t chars_available;
68 chars_available == 0) {