Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiator Mode: Disable LED on Pico W, it's causing issues for an unk… #97

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
#define LED_ON() platform_network_supported() ? cyw43_gpio_set(&cyw43_state, 0, true) : sio_hw->gpio_set = 1 << LED_PIN
#define LED_OFF() platform_network_supported() ? cyw43_gpio_set(&cyw43_state, 0, false) : sio_hw->gpio_clr = 1 << LED_PIN

#define STANDARD_LED_ON sio_hw->gpio_set = 1 << LED_PIN
#define STANDARD_LED_OFF sio_hw->gpio_clr = 1 << LED_PIN

#define W_LED_ON cyw43_gpio_set(&cyw43_state, 0, true)
#define W_LED_OFF cyw43_gpio_set(&cyw43_state, 0, false)

// SDIO and SPI block
#define SD_SPI_SCK 10
#define SDIO_CLK 10
Expand Down
2 changes: 1 addition & 1 deletion src/BlueSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ extern "C" void bluescsi_main_loop(void)
platform_network_poll();

#ifdef PLATFORM_HAS_INITIATOR_MODE
if (platform_is_initiator_mode_enabled())
if (unlikely(platform_is_initiator_mode_enabled()))
{
scsiInitiatorMainLoop();
save_logfile();
Expand Down
23 changes: 18 additions & 5 deletions src/BlueSCSI_initiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,15 @@ static void scsiInitiatorUpdateLed()

if (phase <= duty)
{
LED_ON();
if (!platform_network_supported()) {
STANDARD_LED_ON;
}
}
else
{
LED_OFF();
if (!platform_network_supported()) {
STANDARD_LED_OFF;
}
}
}

Expand Down Expand Up @@ -143,7 +147,10 @@ void scsiInitiatorMainLoop()

uint8_t inquiry_data[36];

LED_ON();
if (!platform_network_supported()) {
STANDARD_LED_ON;
}

bool startstopok =
scsiTestUnitReady(g_initiator_state.target_id) &&
scsiStartStopUnit(g_initiator_state.target_id, true);
Expand All @@ -155,7 +162,10 @@ void scsiInitiatorMainLoop()

bool inquiryok = startstopok &&
scsiInquiry(g_initiator_state.target_id, inquiry_data);
LED_OFF();

if (!platform_network_supported()) {
STANDARD_LED_OFF;
}

uint64_t total_bytes = 0;
if (readcapok)
Expand Down Expand Up @@ -252,7 +262,10 @@ void scsiInitiatorMainLoop()
{
scsiStartStopUnit(g_initiator_state.target_id, false);
log("Finished imaging drive with id ", g_initiator_state.target_id);
LED_OFF();

if (!platform_network_supported()) {
STANDARD_LED_OFF;
}

if (g_initiator_state.sectorcount != g_initiator_state.sectorcount_all)
{
Expand Down