diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ec6564..96c861b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,8 +45,8 @@ jobs: - name: Build busk run: | # Backup and modify memmap_default.ld for busk build - cp $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld.bak - sed -i 's/RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k/RAM(rwx) : ORIGIN = 0x20038000, LENGTH = 32k/g' $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld + cp $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld.bak + sed -i 's/RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k/RAM(rwx) : ORIGIN = 0x20038000, LENGTH = 32k/g' $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld mkdir -p $GITHUB_WORKSPACE/build/busk cd $GITHUB_WORKSPACE/build/busk cmake $GITHUB_WORKSPACE/busk @@ -54,8 +54,8 @@ jobs: make clean cd $GITHUB_WORKSPACE # Restore original memmap_default.ld from backup - rm -f $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld - mv $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld.bak $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_standard_link/memmap_default.ld + rm -f $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld + mv $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld.bak $GITHUB_WORKSPACE/pico-sdk/src/rp2_common/pico_crt0/rp2040/memmap_default.ld - name: Build usk run: | diff --git a/board_detect.c b/board_detect.c index 923585c..811479f 100644 --- a/board_detect.c +++ b/board_detect.c @@ -14,12 +14,13 @@ enum board_type { BOARD_XO, BOARD_IB, BOARD_PI, - BOARD_SQ + BOARD_SQ, + BOARD_WT }; enum board_type cur_board = BOARD_WS; -bool detect_by_pull_up(int frc_pin, int det_pin) +bool detect_by_pull(int frc_pin, int det_pin, bool up) { bool result = false; if (frc_pin >= 0) @@ -27,9 +28,9 @@ bool detect_by_pull_up(int frc_pin, int det_pin) gpio_init(det_pin); if (frc_pin >= 0) gpio_set_dir(frc_pin, true); - gpio_pull_up(det_pin); + gpio_set_pulls(det_pin, up, !up); sleep_us(15); - result = !gpio_get(det_pin); + result = gpio_get(det_pin) ^ up; gpio_deinit(det_pin); if (frc_pin >= 0) gpio_deinit(frc_pin); @@ -39,27 +40,32 @@ bool detect_by_pull_up(int frc_pin, int det_pin) bool test_xiao() { - return detect_by_pull_up(1, 2); + return detect_by_pull(1, 2, 1); } bool test_itsy() { - return detect_by_pull_up(3, 2); + return detect_by_pull(3, 2, 1); } bool test_pico() { - return detect_by_pull_up(-1, 22); + return detect_by_pull(-1, 22, 1); } bool test_ws() { - return detect_by_pull_up(-1, 25); + return detect_by_pull(-1, 25, 1); +} + +bool test_wt() +{ + return detect_by_pull(-1, 16, 0); } bool test_sqc() { - return detect_by_pull_up(-1, 17); + return detect_by_pull(-1, 17, 1); } void detect_board() @@ -79,6 +85,8 @@ void detect_board() cur_board = BOARD_PI; } else if (test_sqc()) { cur_board = BOARD_SQ; + } else if (test_wt()) { + cur_board = BOARD_WT; } else { cur_board = BOARD_WS; } @@ -95,7 +103,7 @@ int led_pin() return PIN_LED_ITSY; default: return PIN_LED_WS; - }; + }; } int pwr_pin() @@ -107,7 +115,7 @@ int pwr_pin() return PIN_LED_PWR_ITSY; default: return 31; - }; + }; } int scl_pin() @@ -123,7 +131,7 @@ int scl_pin() return PIN_SCL_SQC; default: return PIN_SCL_WS; - }; + }; } int sda_pin() @@ -139,7 +147,7 @@ int sda_pin() return PIN_SDA_SQC; default: return PIN_SDA_WS; - }; + }; } int gli_pin() @@ -153,10 +161,15 @@ int gli_pin() return PIN_GLI_PICO; default: return PIN_GLI_WS; - }; + }; } bool is_pico() { return cur_board == BOARD_PI; } + +bool is_tiny() +{ + return cur_board == BOARD_WT; +} diff --git a/board_detect.h b/board_detect.h index 637a29c..1310c33 100644 --- a/board_detect.h +++ b/board_detect.h @@ -1,11 +1,12 @@ #include "stdbool.h" -bool detect_by_pull_up(int frc_pin, int det_pin); +bool detect_by_pull(int frc_pin, int det_pin, bool up); void detect_board(); int gli_pin(); int pwr_pin(); int led_pin(); bool is_pico(); +bool is_tiny(); int scl_pin(); -int sda_pin(); \ No newline at end of file +int sda_pin(); diff --git a/config.h b/config.h index 3fc3313..77186fc 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ #define OFFSET_MAX 6950 #define VER_HI 2 -#define VER_LO 77 +#define VER_LO 78 bool is_configured(); void init_config(); diff --git a/main.c b/main.c index 9813277..ea06642 100644 --- a/main.c +++ b/main.c @@ -94,13 +94,20 @@ int main() init_fuses(); // LED & glitch & emmc PIO upload_pio(); + if (is_tiny()) + { + gpio_put(led_pin(), 0); + sleep_us(100); + put_pixel(0); + sleep_us(100); + } // check if this is the very first start if (watchdog_caused_reboot() && boot_try == 0) { halt_with_error(1, 1); } // is chip reset required - bool force_button = detect_by_pull_up(1, 0); + bool force_button = detect_by_pull(1, 0, 1); // start LED put_pixel(PIX_gre); // test pins diff --git a/misc.c b/misc.c index a9e4bc3..4ae8a85 100644 --- a/misc.c +++ b/misc.c @@ -52,7 +52,10 @@ void finish_pins_except_leds() { } void finish_pins_leds() { - gpio_disable_input_output(led_pin()); + if (!is_tiny()) + { + gpio_disable_input_output(led_pin()); + } gpio_disable_input_output(pwr_pin()); } @@ -125,7 +128,10 @@ void put_pixel(uint32_t pixel_rgb) pio_sm_put_blocking(pio0, 3, pixel_grb << 8u); sleep_us(50); pio_sm_set_enabled(pio0, 3, false); - gpio_init(led_pin()); + if (!is_tiny()) + { + gpio_init(led_pin()); + } } void gpio_disable_input_output(int pin)