Skip to content

Commit

Permalink
Merge branch 'main' into feature/common-file-update
Browse files Browse the repository at this point in the history
  • Loading branch information
morio authored Dec 2, 2024
2 parents 35bc338 + 071572c commit 8c83ae4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 13 deletions.
9 changes: 7 additions & 2 deletions lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ bool g_moved_select_in = false;
// hw_config.cpp c functions
#include "platform_hw_config.h"

// usb_log_poll() is called through function pointer to
// avoid including USB in SD card bootloader.
static void (*g_usb_log_poll_func)(void);
static void usb_log_poll();


/*************************/
Expand Down Expand Up @@ -396,6 +400,7 @@ void platform_late_init()

// Initialize usb for CDC serial output
usb_serial_init();
g_usb_log_poll_func = &usb_log_poll;

logmsg("Platform: ", g_platform_name);
logmsg("FW Version: ", g_log_firmwareversion);
Expand Down Expand Up @@ -617,7 +622,7 @@ void show_hardfault(uint32_t *sp)

while (1)
{
usb_log_poll();
if (g_usb_log_poll_func) g_usb_log_poll_func();
// Flash the crash address on the LED
// Short pulse means 0, long pulse means 1
int base_delay = 1000;
Expand Down Expand Up @@ -690,7 +695,7 @@ void __assert_func(const char *file, int line, const char *func, const char *exp

while(1)
{
usb_log_poll();
if (g_usb_log_poll_func) g_usb_log_poll_func();
LED_OFF();
for (int j = 0; j < 1000; j++) delay_ns(100000);
LED_ON();
Expand Down
25 changes: 21 additions & 4 deletions lib/ZuluSCSI_platform_GD32F205/gd32_cdc_acm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,32 @@ static const usb_desc_str product_string =
.unicode_string = {'Z', 'u', 'l', 'u', 'S', 'C', 'S', 'I'}
};

/* USBD serial string */
#ifdef USB_ENABLE_SERIALNUMBER
/* USBD serial string
* This gets set by serial_string_get() in GD32 SPL usbd_enum.c */
static usb_desc_str serial_string =
{
.header =
{
.bLength = USB_STRING_LEN(12U),
.bDescriptorType = USB_DESCTYPE_STR,
}
};
#else
/* Save some RAM by disabling the serial number.
* Note that contents must not have null bytes or Windows gets confused
* Having non-empty fake serial number avoids Windows recreating the
* device every time it moves between USB ports. */
static const usb_desc_str serial_string =
{
.header =
{
.bLength = USB_STRING_LEN(12),
.bLength = USB_STRING_LEN(4U),
.bDescriptorType = USB_DESCTYPE_STR,
}
},
.unicode_string = {'1', '2', '3', '4'}
};
#endif

/* USB string descriptor set */
void *const gd32_usbd_cdc_strings[] =
Expand Down Expand Up @@ -452,7 +469,7 @@ static uint8_t cdc_acm_req (usb_dev *udev, usb_req *req)
break;

default:
break;
return REQ_NOTSUPP;
}

return USBD_OK;
Expand Down
9 changes: 9 additions & 0 deletions lib/ZuluSCSI_platform_GD32F205/usb_serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ bool usb_serial_ready(void)
// check that (our) serial is the currently active class
if ((USBD_CONFIGURED == cdc_acm.dev.cur_status) && (cdc_acm.dev.desc == &gd32_cdc_desc))
{
gd32_usb_cdc_handler *cdc = (gd32_usb_cdc_handler *)cdc_acm.dev.class_data[CDC_COM_INTERFACE];
if (cdc->packet_receive)
{
// Discard any received data.
// Otherwise it queues up on the host side and can cause the port to hang.
cdc->packet_receive = 0;
gd32_cdc_acm_data_receive(&cdc_acm);
}

if (1U == gd32_cdc_acm_check_ready(&cdc_acm))
{
return true;
Expand Down
30 changes: 24 additions & 6 deletions lib/ZuluSCSI_platform_GD32F205/usbd_msc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,32 @@ static __ALIGN_BEGIN const usb_desc_str product_string __ALIGN_END = {
.unicode_string = {'G', 'D', '3', '2', '-', 'U', 'S', 'B', '_', 'M', 'S', 'C'}
};

/* USBD serial string */
static __ALIGN_BEGIN const usb_desc_str serial_string __ALIGN_END = {
#ifdef USB_ENABLE_SERIALNUMBER
/* USBD serial string
* This gets set by serial_string_get() in GD32 SPL usbd_enum.c */
static usb_desc_str serial_string =
{
.header =
{
.bLength = USB_STRING_LEN(12U),
.bDescriptorType = USB_DESCTYPE_STR,
}
{
.bLength = USB_STRING_LEN(12U),
.bDescriptorType = USB_DESCTYPE_STR,
}
};
#else
/* Save some RAM by disabling the serial number.
* Note that contents must not have null bytes or Windows gets confused
* Having non-empty fake serial number avoids Windows recreating the
* device every time it moves between USB ports. */
static const usb_desc_str serial_string =
{
.header =
{
.bLength = USB_STRING_LEN(4U),
.bDescriptorType = USB_DESCTYPE_STR,
},
.unicode_string = {'1', '2', '3', '4'}
};
#endif

/* USB string descriptor */
void *const usbd_msc_strings[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/ZuluSCSI_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <ZuluSCSI_platform_config.h>

// Use variables for version number
#define FW_VER_NUM "24.11.29"
#define FW_VER_NUM "24.12.02"
#define FW_VER_SUFFIX "devel"

#define DEF_STRINGFY(DEF) STRINGFY(DEF)
Expand Down

0 comments on commit 8c83ae4

Please sign in to comment.