forked from arti/vt1200
Distils public docs into reference/keyboard-mouse/PROTOCOL.md for the level-1 Keyboard (27) / Mouse (26) device tests: - keyboard: 4800 8N1 RS-423, self-test via FD -> 01 00 00 00 (errors 3D/3E) - mouse: 4800 8O1 RS-232, self-test via 'T' -> 4-byte report (errors 3D/3E, >=0x20 fatal) - separate ports: DUART2 A=keyboard, B=mouse (NOT daisy-chained) MAME already has an LK201 device (src/mame/dec/lk201.cpp/.h) but no DEC mouse.
47 lines
906 B
C
47 lines
906 B
C
#include <zephyr/drivers/gpio.h>
|
|
#include <zephyr/logging/log.h>
|
|
|
|
#include "leds.h"
|
|
|
|
LOG_MODULE_REGISTER(leds, CONFIG_LOG_DEFAULT_LEVEL);
|
|
|
|
static const struct gpio_dt_spec leds[NUM_LEDS] = {
|
|
GPIO_DT_SPEC_GET_OR(DT_NODELABEL(led0), gpios, {0}),
|
|
GPIO_DT_SPEC_GET_OR(DT_NODELABEL(led1), gpios, {0}),
|
|
GPIO_DT_SPEC_GET_OR(DT_NODELABEL(led2), gpios, {0}),
|
|
GPIO_DT_SPEC_GET_OR(DT_NODELABEL(led3), gpios, {0}),
|
|
};
|
|
|
|
int
|
|
leds_init(void)
|
|
{
|
|
int ret;
|
|
for (int i = 0; i < NUM_LEDS; i++) {
|
|
if (!gpio_is_ready_dt(&leds[i])) {
|
|
LOG_ERR("led%d pin GPIO port is not ready.", i);
|
|
return -1;
|
|
}
|
|
|
|
ret = gpio_pin_configure_dt(&leds[i], GPIO_OUTPUT_INACTIVE);
|
|
if (ret != 0) {
|
|
LOG_ERR("Configuring led%d GPIO pin failed: %d",
|
|
i, ret);
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void
|
|
leds_on(int which)
|
|
{
|
|
gpio_pin_set_dt(&leds[which], 1);
|
|
}
|
|
|
|
void
|
|
leds_off(int which)
|
|
{
|
|
gpio_pin_set_dt(&leds[which], 0);
|
|
}
|