Skip to content

Commit

Permalink
network: add flag for networking at build time for platforms that don…
Browse files Browse the repository at this point in the history
…t support it.
  • Loading branch information
erichelgeson committed Nov 17, 2024
1 parent 939fc89 commit ff78647
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 16 deletions.
1 change: 0 additions & 1 deletion lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "hardware/i2c.h"

extern "C" {
#include <pico/cyw43_arch.h>

const char *g_platform_name = PLATFORM_NAME;
static bool g_scsi_initiator = false;
Expand Down
11 changes: 9 additions & 2 deletions lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#pragma once

#include <hardware/gpio.h>
#ifdef BLUESCSI_NETWORK
#include <pico/cyw43_arch.h>
#endif

// SCSI data input/output port.
// The data bus uses external bidirectional buffer, with
Expand Down Expand Up @@ -56,8 +58,13 @@

// Status LED pins
#define LED_PIN 25
#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
#ifdef BLUESCSI_NETWORK
#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
#else
#define LED_ON() sio_hw->gpio_set = 1 << LED_PIN
#define LED_OFF() sio_hw->gpio_clr = 1 << LED_PIN
#endif

// SDIO and SPI block
#define SD_SPI_SCK 10
Expand Down
15 changes: 6 additions & 9 deletions lib/BlueSCSI_platform_RP2040/BlueSCSI_platform_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include <network.h>

extern "C" {

#ifdef BLUESCSI_NETWORK
#include <cyw43.h>
#include <pico/cyw43_arch.h>
#endif

#ifndef CYW43_IOCTL_GET_RSSI
#define CYW43_IOCTL_GET_RSSI (0xfe)
Expand All @@ -34,17 +35,12 @@ static const char defaultMAC[] = { 0x00, 0x80, 0x19, 0xc0, 0xff, 0xee };

static bool network_in_use = false;

bool platform_network_supported()
bool __not_in_flash_func(platform_network_supported)()
{
/* from cores/rp2040/RP2040Support.h */
#if !defined(ARDUINO_RASPBERRY_PI_PICO_W)
return false;
#else
extern bool __isPicoW;
return __isPicoW;
#endif
return rp2040.isPicoW();
}

#ifdef BLUESCSI_NETWORK
int platform_network_init(char *mac)
{
pico_unique_board_id_t board_id;
Expand Down Expand Up @@ -311,4 +307,5 @@ void cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf)
log_f("Successfully connected to Wi-Fi SSID \"%s\"", ssid);
}

#endif
}
3 changes: 2 additions & 1 deletion lib/SCSI2SD/src/firmware/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#ifdef BLUESCSI_NETWORK
#include <string.h>

#include "scsi.h"
Expand Down Expand Up @@ -528,3 +528,4 @@ int scsiNetworkPurge(void)

return sent;
}
#endif
8 changes: 6 additions & 2 deletions lib/SCSI2SD/src/firmware/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,12 @@ static void process_Command()
// write commands. Will fall-through to generic disk handling.
else if (((cfg->deviceType == S2S_CFG_OPTICAL) && scsiCDRomCommand()) ||
((cfg->deviceType == S2S_CFG_SEQUENTIAL) && scsiTapeCommand()) ||
((cfg->deviceType == S2S_CFG_MO) && scsiMOCommand()) ||
((cfg->deviceType == S2S_CFG_NETWORK && scsiNetworkCommand())))
((cfg->deviceType == S2S_CFG_MO) && scsiMOCommand())
#ifdef BLUESCSI_NETWORK
|| ((cfg->deviceType == S2S_CFG_NETWORK && scsiNetworkCommand()))
#endif
)

{
// Already handled.
}
Expand Down
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ build_flags =
-DUSE_ARDUINO=1
-DPICO_DEFAULT_I2C_SDA_PIN=16
-DPICO_DEFAULT_I2C_SCL_PIN=17
-DBLUESCSI_NETWORK=1
; build flags mirroring the framework-arduinopico#v4.1.1-DaynaPORT static library build
-DPICO_CYW43_ARCH_POLL=1
-DCYW43_LWIP=0
Expand Down
5 changes: 4 additions & 1 deletion src/BlueSCSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,13 @@ static void reinitSCSI()
scsiPhyReset();
scsiDiskInit();
scsiInit();

#ifdef BLUESCSI_NETWORK
if (scsiDiskCheckAnyNetworkDevicesConfigured())
{
platform_network_init(scsiDev.boardCfg.wifiMACAddress);
platform_network_wifi_join(scsiDev.boardCfg.wifiSSID, scsiDev.boardCfg.wifiPassword);
}
#endif
}

void check_and_apply_sdio_delay() {
Expand Down Expand Up @@ -714,7 +715,9 @@ extern "C" void bluescsi_main_loop(void)
platform_reset_watchdog();
platform_poll();
diskEjectButtonUpdate(true);
#ifdef BLUESCSI_NETWORK
platform_network_poll();
#endif

#ifdef PLATFORM_HAS_INITIATOR_MODE
if (unlikely(platform_is_initiator_mode_enabled()))
Expand Down

0 comments on commit ff78647

Please sign in to comment.