From cba115f01680b4d675dd64a2605abd404e084b27 Mon Sep 17 00:00:00 2001 From: Aviancer <80006672+Aviancer@users.noreply.github.com> Date: Tue, 22 Mar 2022 23:58:24 +0200 Subject: [PATCH] Linux/Pico: WIP: Makefile, include libs after objects for Raspbian build compatibility (sets --as-needed). --- linux/Makefile | 2 +- pico/amouse.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/linux/Makefile b/linux/Makefile index 28ecf78..eb970cb 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -27,7 +27,7 @@ TARGET = amouse all: serial.o utils.o mouse.o ${TARGET} ${TARGET}: ${SRC_DIR}/${TARGET}.c - ${CC} ${CFLAGS} ${INCLUDES} -o ${BIN_DIR}/${TARGET} ${C_SOURCES} ${C_SHARED} + ${CC} ${CFLAGS} -o ${BIN_DIR}/${TARGET} ${C_SOURCES} ${C_SHARED} ${INCLUDES} utils.o: ${SRC_DIR}/../../shared/utils.c ${SRC_DIR}/../../shared/utils.h ${CC} ${CFLAGS} -c ${SRC_DIR}/../../shared/utils.c -o ${SRC_DIR}/include/utils.o diff --git a/pico/amouse.c b/pico/amouse.c index 372ef9f..012d9e5 100644 --- a/pico/amouse.c +++ b/pico/amouse.c @@ -194,7 +194,7 @@ int main() { // CTS Pin //gpio_init(UART_CTS_PIN); // DEBUG //gpio_set_dir(UART_CTS_PIN, GPIO_IN); // DEBUG - gpio_set_irq_enabled_with_callback(UART_CTS_PIN, GPIO_IRQ_EDGE_FALL, true, &someother_callback); + //gpio_set_irq_enabled_with_callback(UART_CTS_PIN, GPIO_IRQ_EDGE_FALL, true, &someother_callback); // Set initial serial timer targets time_tx_target = time_us_32() + U_SERIALDELAY_3B; @@ -215,17 +215,17 @@ int main() { time_rx_target = time_us_32() + U_FULL_SECOND; } - if(init_req) { // DEBUG + /*if(init_req) { // DEBUG mouse_ident(0, mouse_options.wheel); // TODO mouse_options.wheel. mouse.pc_state = CTS_TOGGLED; gpio_put(LED_PIN, true); led_state = true; init_req = false; - } + }*/ // Mouse handling - //cts_pin = gpio_get(UART_CTS_PIN); + cts_pin = gpio_get(UART_CTS_PIN); // ### Check if mouse driver trying to initialize /*if(cts_pin) { // Computers RTS is low, with MAX3232 this shows reversed as high instead? Check spec. @@ -241,6 +241,17 @@ int main() { led_state = false; }*/ + if(cts_pin) { // Computers RTS low, only pin we care about for MS drivers, etc. + if(mouse.pc_state == CTS_UNINIT) { mouse.pc_state = CTS_LOW_INIT; } + else if(mouse.pc_state == CTS_TOGGLED) { mouse.pc_state = CTS_LOW_RUN; } + } + + // Mouse initiaizing request detected + if(!cts_pin && (mouse.pc_state != CTS_UNINIT && mouse.pc_state != CTS_TOGGLED)) { + mouse.pc_state = CTS_TOGGLED; + mouse_ident(0, mouse_options.wheel); + } + /*** Mouse update loop ***/