]> git.scottworley.com Git - tattlekey/commitdiff
client: Switch to pico_w blink example
authorScott Worley <scottworley@scottworley.com>
Fri, 29 Sep 2023 19:20:53 +0000 (12:20 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 11 Oct 2023 01:47:17 +0000 (18:47 -0700)
client/CMakeLists.txt
client/default.nix
client/tattlekey.c

index d07ff630922f778bac7a55e7f16eb62339a5bdde..84361f433f6c6a8858701af21c0011d935c4128d 100644 (file)
@@ -11,6 +11,9 @@ add_executable(tattlekey tattlekey.c)
 
 pico_add_extra_outputs(tattlekey)
 
-target_link_libraries(tattlekey pico_stdlib)
+target_link_libraries(tattlekey
+  pico_stdlib
+  pico_cyw43_arch_none
+  )
 
 install(TARGETS tattlekey RUNTIME LIBRARY ARCHIVE)
index 37fc8f117dfa64d2783815326764e348919cbe0e..ed65ca2379f283b6a59983a7c902f89fdc0f61bb 100644 (file)
@@ -10,6 +10,7 @@ let
       cmakeFlags = [
         "-DCMAKE_C_COMPILER=${cc}/bin/arm-none-eabi-cc"
         "-DCMAKE_CXX_COMPILER=${cc}/bin/arm-none-eabi-c++"
+        "-DPICO_BOARD=pico_w"
         "-DPICO_SDK_PATH=${pico-sdk.override { minimal = false; }}/lib/pico-sdk"
         "-DPICO_TOOLCHAIN_PATH=${cc}/bin"
       ];
index f34552bb58c8e48d2e642bb1f6c9c73f53c8669d..910f6963b15ba10a647a2d42c1242398bb8d0d0d 100644 (file)
@@ -1,23 +1,22 @@
 /**
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include "pico/cyw43_arch.h"
 #include "pico/stdlib.h"
 
 int main() {
-#ifndef PICO_DEFAULT_LED_PIN
-#warning blink example requires a board with a regular LED
-#else
-  const uint LED_PIN = PICO_DEFAULT_LED_PIN;
-  gpio_init(LED_PIN);
-  gpio_set_dir(LED_PIN, GPIO_OUT);
+  stdio_init_all();
+  if (cyw43_arch_init()) {
+    printf("Wi-Fi init failed");
+    return -1;
+  }
   while (true) {
-    gpio_put(LED_PIN, 1);
+    cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
     sleep_ms(250);
-    gpio_put(LED_PIN, 0);
+    cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
     sleep_ms(250);
   }
-#endif
 }