diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 21:03:04 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-10-29 21:03:04 -0600 |
commit | 26361be59c08917c47718bcd4114b8028aaf7810 (patch) | |
tree | b05dfad7baa755da4592a3d47412f1e062560a5e /libhw | |
parent | 3c3e9e2c62ad9a83ab9b0e1255204d57894c20ff (diff) |
libhw: Tidy
Diffstat (limited to 'libhw')
-rw-r--r-- | libhw/CMakeLists.txt | 8 | ||||
-rw-r--r-- | libhw/common_alarmclock.c (renamed from libhw/alarmclock.c) | 2 | ||||
-rw-r--r-- | libhw/host_alarmclock.c | 2 | ||||
-rw-r--r-- | libhw/host_net.c | 2 | ||||
-rw-r--r-- | libhw/host_util.c (renamed from libhw/host_sigrt.c) | 4 | ||||
-rw-r--r-- | libhw/host_util.h (renamed from libhw/host_sigrt.h) | 2 | ||||
-rw-r--r-- | libhw/w5500.c | 10 |
7 files changed, 19 insertions, 11 deletions
diff --git a/libhw/CMakeLists.txt b/libhw/CMakeLists.txt index 1baeee8..3627641 100644 --- a/libhw/CMakeLists.txt +++ b/libhw/CMakeLists.txt @@ -6,9 +6,15 @@ add_library(libhw INTERFACE) target_include_directories(libhw SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/common_include) target_link_libraries(libhw INTERFACE + libcr + libcr_ipc libmisc ) +target_sources(libhw INTERFACE + common_alarmclock.c +) + if (PICO_PLATFORM STREQUAL "rp2040") target_include_directories(libhw SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/rp2040_include) target_sources(libhw INTERFACE @@ -27,7 +33,7 @@ endif() if (PICO_PLATFORM STREQUAL "host") target_include_directories(libhw SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/host_include) target_sources(libhw INTERFACE - host_sigrt.c + host_util.c host_alarmclock.c host_net.c ) diff --git a/libhw/alarmclock.c b/libhw/common_alarmclock.c index 7b311c0..9812d44 100644 --- a/libhw/alarmclock.c +++ b/libhw/common_alarmclock.c @@ -1,4 +1,4 @@ -/* libhw/alarmclock.c - Device-independent <libhw/generic/alarmclock.h> utilities +/* libhw/common_alarmclock.c - Device-independent <libhw/generic/alarmclock.h> utilities * * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/libhw/host_alarmclock.c b/libhw/host_alarmclock.c index 26aca94..141927c 100644 --- a/libhw/host_alarmclock.c +++ b/libhw/host_alarmclock.c @@ -16,7 +16,7 @@ #define IMPLEMENTATION_FOR_LIBHW_GENERIC_ALARMCLOCK_H YES #include <libhw/generic/alarmclock.h> -#include "host_sigrt.h" +#include "host_util.h" /* for host_sigrt_alloc(), ns_to_host_ns_time() */ /* Types **********************************************************************/ diff --git a/libhw/host_net.c b/libhw/host_net.c index 9d1ffcf..20b72f1 100644 --- a/libhw/host_net.c +++ b/libhw/host_net.c @@ -27,7 +27,7 @@ #define IMPLEMENTATION_FOR_LIBHW_HOST_NET_H YES #include <libhw/host_net.h> -#include "host_sigrt.h" /* for host_sigrt_alloc(), ns_to_host_us_time() */ +#include "host_util.h" /* for host_sigrt_alloc(), ns_to_host_us_time() */ /* common *********************************************************************/ diff --git a/libhw/host_sigrt.c b/libhw/host_util.c index 6dcb963..b862e39 100644 --- a/libhw/host_sigrt.c +++ b/libhw/host_util.c @@ -1,4 +1,4 @@ -/* libhw/host_sigrt.c - Manage glibc realtime signals +/* libhw/host_util.c - Utilities for GNU/Linux hosts * * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later @@ -7,7 +7,7 @@ #include <error.h> /* for error(3gnu) */ #include <signal.h> /* for SIGRTMIN, SIGRTMAX */ -#include "host_sigrt.h" +#include "host_util.h" int host_sigrt_alloc(void) { static int next = 0; diff --git a/libhw/host_sigrt.h b/libhw/host_util.h index e8be26a..edb6da4 100644 --- a/libhw/host_sigrt.h +++ b/libhw/host_util.h @@ -1,4 +1,4 @@ -/* libhw/host_sigrt.h - Manage glibc realtime signals +/* libhw/host_util.h - Utilities for GNU/Linux hosts * * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com> * SPDX-License-Identifier: AGPL-3.0-or-later diff --git a/libhw/w5500.c b/libhw/w5500.c index 0d9cd01..603863a 100644 --- a/libhw/w5500.c +++ b/libhw/w5500.c @@ -67,12 +67,15 @@ * SPDX-License-Identifier: MIT */ -#include <pico/time.h> /* for sleep_ms() */ +/* TODO: Write a <libhw/generic/gpio.h> to avoid w5500.c being + * pico-sdk-specific. */ #include <hardware/gpio.h> /* pico-sdk:hardware_gpio */ #include <libcr/coroutine.h> /* for cr_yield() */ #include <libmisc/vcall.h> /* for VCALL_SELF() */ +#include <libhw/generic/alarmclock.h> /* for sleep_*() */ + #define IMPLEMENTATION_FOR_LIBHW_W5500_H YES #include <libhw/w5500.h> @@ -265,11 +268,10 @@ static inline void w5500_post_reset(struct w5500 *chip) { } void w5500_hard_reset(struct w5500 *chip) { - /* TODO: Replace blocking sleep_ms() with something libcr-friendly. */ gpio_put(chip->pin_reset, 0); - sleep_ms(1); /* minimum of 500us */ + sleep_for_ms(1); /* minimum of 500us */ gpio_put(chip->pin_reset, 1); - sleep_ms(2); /* minimum of 1ms */ + sleep_for_ms(2); /* minimum of 1ms */ w5500_post_reset(chip); } |