mirror of
https://github.com/hrvach/deskhop.git
synced 2024-11-21 23:33:33 +01:00
Minor updates and bugfixes
- Mouse movements should be smoother on the other Pico - Reworked CMakeLists with foreach to avoid duplication - Increased WDT timeout
This commit is contained in:
parent
15da60bd95
commit
098aabfc57
@ -1,16 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(PICO_SDK_FETCH_FROM_GIT off)
|
||||
set(PICO_BOARD=pico)
|
||||
|
||||
include(pico_sdk_import.cmake)
|
||||
set(CMAKE_CXX_FLAGS "-Ofast -Wall -mcpu=cortex-m0plus -mtune=cortex-m0plus")
|
||||
set(CMAKE_C_FLAGS "-Ofast -Wall -mcpu=cortex-m0plus -mtune=cortex-m0plus -funroll-loops")
|
||||
|
||||
set(PICO_COPY_TO_RAM 1)
|
||||
|
||||
project(deskhop_project C CXX ASM)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
set(PICO_PIO_USB_DIR ${CMAKE_CURRENT_LIST_DIR}/Pico-PIO-USB)
|
||||
@ -66,38 +67,29 @@ set(COMMON_LINK_LIBRARIES
|
||||
Pico-PIO-USB
|
||||
)
|
||||
|
||||
# Pico A - Keyboard
|
||||
add_executable(board_A)
|
||||
# Pico A - Keyboard (board_role = 0)
|
||||
# B - Mouse (board_role = 1)
|
||||
|
||||
target_sources(board_A PUBLIC ${COMMON_SOURCES})
|
||||
target_compile_definitions(board_A PRIVATE BOARD_ROLE=0 PIO_USB_USE_TINYUSB=1 PIO_USB_DP_PIN_DEFAULT=14)
|
||||
target_include_directories(board_A PUBLIC ${COMMON_INCLUDES})
|
||||
target_link_libraries(board_A PUBLIC ${COMMON_LINK_LIBRARIES})
|
||||
set(binaries board_A board_B)
|
||||
|
||||
pico_enable_stdio_usb(board_A 0)
|
||||
pico_add_extra_outputs(board_A)
|
||||
foreach(board_role RANGE 0 1)
|
||||
list (GET binaries ${board_role} binary)
|
||||
|
||||
add_executable(${binary})
|
||||
|
||||
# Pico B - Mouse
|
||||
add_executable(board_B)
|
||||
target_sources(${binary} PUBLIC ${COMMON_SOURCES})
|
||||
target_compile_definitions(${binary} PRIVATE BOARD_ROLE=${board_role} PIO_USB_USE_TINYUSB=1 PIO_USB_DP_PIN_DEFAULT=14)
|
||||
target_include_directories(${binary} PUBLIC ${COMMON_INCLUDES})
|
||||
target_link_libraries(${binary} PUBLIC ${COMMON_LINK_LIBRARIES})
|
||||
|
||||
target_compile_definitions(board_B PRIVATE BOARD_ROLE=1 PIO_USB_USE_TINYUSB=1 PIO_USB_DP_PIN_DEFAULT=14)
|
||||
target_sources(board_B PUBLIC ${COMMON_SOURCES})
|
||||
target_include_directories(board_B PUBLIC ${COMMON_INCLUDES})
|
||||
target_link_libraries(board_B PUBLIC ${COMMON_LINK_LIBRARIES})
|
||||
pico_enable_stdio_usb(${binary} 0)
|
||||
pico_add_extra_outputs(${binary})
|
||||
|
||||
pico_enable_stdio_usb(board_B 0)
|
||||
pico_add_extra_outputs(board_B)
|
||||
target_link_options(${binary} PRIVATE
|
||||
-Xlinker
|
||||
--print-memory-usage
|
||||
)
|
||||
|
||||
target_link_options(board_A PRIVATE
|
||||
-Xlinker
|
||||
--print-memory-usage
|
||||
)
|
||||
pico_set_linker_script(${binary} ${CMAKE_SOURCE_DIR}/memory_map.ld)
|
||||
|
||||
target_link_options(board_B PRIVATE
|
||||
-Xlinker
|
||||
--print-memory-usage
|
||||
)
|
||||
|
||||
pico_set_linker_script(board_A ${CMAKE_SOURCE_DIR}/memory_map.ld)
|
||||
pico_set_linker_script(board_B ${CMAKE_SOURCE_DIR}/memory_map.ld)
|
||||
endforeach()
|
||||
|
Binary file not shown.
Binary file not shown.
@ -25,7 +25,7 @@ device_t *device = &global_state;
|
||||
* ============== Main Program Loops ============== *
|
||||
* ================================================== */
|
||||
|
||||
void main(void) {
|
||||
int main(void) {
|
||||
// Wait for the board to settle
|
||||
sleep_ms(10);
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
#define NUM_SCREENS 2 // Will be more in the future
|
||||
#define MOUSE_ZOOM_SCALING_FACTOR 2
|
||||
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#define CURRENT_BOARD_IS_ACTIVE_OUTPUT (global_state.active_output == BOARD_ROLE)
|
||||
|
||||
/********* Pinout definitions **********/
|
||||
@ -77,9 +77,9 @@
|
||||
#define SERIAL_PARITY UART_PARITY_NONE
|
||||
|
||||
/********* Watchdog definitions **********/
|
||||
#define WATCHDOG_TIMEOUT 500 // In milliseconds => needs to be reset every 500 ms
|
||||
#define WATCHDOG_PAUSE_ON_DEBUG 1 // When using a debugger, disable watchdog
|
||||
#define CORE1_HANG_TIMEOUT_US 500000 // In microseconds, wait up to 0.5s to declare core1 dead
|
||||
#define WATCHDOG_TIMEOUT 1000 // In milliseconds => needs to be reset every second
|
||||
#define WATCHDOG_PAUSE_ON_DEBUG 1 // When using a debugger, disable watchdog
|
||||
#define CORE1_HANG_TIMEOUT_US WATCHDOG_TIMEOUT * 1000 // Convert to microseconds
|
||||
|
||||
/********* Protocol definitions *********
|
||||
*
|
||||
|
@ -41,8 +41,7 @@ void serial_init() {
|
||||
/* We do want FIFO, will help us have fewer interruptions */
|
||||
uart_set_fifo_enabled(SERIAL_UART, true);
|
||||
|
||||
/* Set the RX/TX pins, they differ based on the device role (A or B, check
|
||||
/* schematics) */
|
||||
/* Set the RX/TX pins, they differ based on the device role (A or B, check schematics) */
|
||||
gpio_set_function(SERIAL_TX_PIN, GPIO_FUNC_UART);
|
||||
gpio_set_function(SERIAL_RX_PIN, GPIO_FUNC_UART);
|
||||
}
|
||||
|
@ -91,13 +91,11 @@ void handle_idle_state(uint8_t *raw_packet, device_t *state) {
|
||||
|
||||
/* Read a character off the line until we reach fixed packet length */
|
||||
void handle_reading_state(uint8_t *raw_packet, device_t *state, int *count) {
|
||||
if (!uart_is_readable(SERIAL_UART)) {
|
||||
return;
|
||||
while (uart_is_readable(SERIAL_UART) && *count < PACKET_LENGTH) {
|
||||
/* Read and store the incoming byte */
|
||||
raw_packet[(*count)++] = uart_getc(SERIAL_UART);
|
||||
}
|
||||
|
||||
/* Read and store the incoming byte */
|
||||
raw_packet[(*count)++] = uart_getc(SERIAL_UART);
|
||||
|
||||
/* Check if a complete packet is received */
|
||||
if (*count >= PACKET_LENGTH) {
|
||||
state->receiver_state = PROCESSING_PACKET;
|
||||
|
Loading…
Reference in New Issue
Block a user