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

Enhance fsdev #2739

Merged
merged 26 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5d26f57
update fsdev bsp for hil testing
hathach Jul 23, 2024
c0f38eb
fsdev read/write packet use unaligned function
hathach Jul 23, 2024
2f8078f
minor changes
hathach Jul 24, 2024
0eb0bae
fsdev: remove unused _setup_packet
hathach Jul 25, 2024
a5bc043
fix race condition where reset event cleaar setup count
hathach Jul 25, 2024
02caf00
simplify btable rx/tx count/address access
hathach Jul 25, 2024
ef4285c
add flash stlink
hathach Jul 25, 2024
3b8f9a2
refactor btable tx/rx into arr[2]
hathach Jul 25, 2024
75d3a3b
implement btable_set_addr/count
hathach Jul 25, 2024
6771ef3
more btable set/get clean up
hathach Jul 30, 2024
749f092
refactor btable_set_rx_bufsize()
hathach Jul 30, 2024
b15814b
move align buffer to pma_alloc()
hathach Jul 30, 2024
1cf8e34
improve set endpoint
hathach Jul 30, 2024
f4aaad6
add edpt0_open(), slightly update dtog
hathach Jul 30, 2024
0c8d41e
correct ep toggle bit
hathach Jul 31, 2024
1267782
enhance dcd_ep_ctr_rx_handler()
hathach Jul 31, 2024
e60efec
improve using ep_add_status/ep_add_dtog
hathach Jul 31, 2024
76cc721
clean up dcd_edpt_stall/clear_statll
hathach Jul 31, 2024
8139840
fix ep_add_dtog()
hathach Jul 31, 2024
3156f1c
remove all pcd ep read, modify write
hathach Jul 31, 2024
ee831d2
rename to ep_read/write(), drop USBx argument
hathach Jul 31, 2024
ce0fdc5
refactor dcd_ep_ctr_handler
hathach Jul 31, 2024
26b0df2
refactor xfer_ctl_ptr() to take epnum/dir to reduce computation
hathach Jul 31, 2024
7954d9c
rename to fsdev_type.h, use FSDDEV_REG instead of USB
hathach Jul 31, 2024
7d9b399
fix ep type bulk typo
hathach Jul 31, 2024
332f75c
simplify read/write 16-bit packet
hathach Jul 31, 2024
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
11 changes: 11 additions & 0 deletions hw/bsp/ch32v20x/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ uint32_t board_button_read(void) {
return false;
}

size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
volatile uint32_t* ch32_uuid = ((volatile uint32_t*) 0x1FFFF7E8UL);
uint32_t* serial_32 = (uint32_t*) (uintptr_t) id;
serial_32[0] = ch32_uuid[0];
serial_32[1] = ch32_uuid[1];
serial_32[2] = ch32_uuid[2];

return 12;
}

int board_uart_read(uint8_t *buf, int len) {
(void) buf;
(void) len;
Expand Down
13 changes: 13 additions & 0 deletions hw/bsp/stm32f3/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ uint32_t board_button_read(void) {
return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
}

size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
volatile uint32_t * stm32_uuid = (volatile uint32_t *) UID_BASE;
uint32_t* id32 = (uint32_t*) (uintptr_t) id;
uint8_t const len = 12;

id32[0] = stm32_uuid[0];
id32[1] = stm32_uuid[1];
id32[2] = stm32_uuid[2];

return len;
}

int board_uart_read(uint8_t* buf, int len) {
(void) buf;
(void) len;
Expand Down
2 changes: 1 addition & 1 deletion hw/bsp/stm32g4/FreeRTOSConfig/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define configCPU_CLOCK_HZ SystemCoreClock
#define configTICK_RATE_HZ ( 1000 )
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( 128 )
#define configMINIMAL_STACK_SIZE ( 200 )
#define configTOTAL_HEAP_SIZE ( configSUPPORT_DYNAMIC_ALLOCATION*4*1024 )
#define configMAX_TASK_NAME_LEN 16
#define configUSE_16_BIT_TICKS 0
Expand Down
13 changes: 13 additions & 0 deletions hw/bsp/stm32l0/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ uint32_t board_button_read(void) {
return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
}

size_t board_get_unique_id(uint8_t id[], size_t max_len) {
(void) max_len;
volatile uint32_t * stm32_uuid = (volatile uint32_t *) UID_BASE;
uint32_t* id32 = (uint32_t*) (uintptr_t) id;
uint8_t const len = 12;

id32[0] = stm32_uuid[0];
id32[1] = stm32_uuid[1];
id32[2] = stm32_uuid[2];

return len;
}

int board_uart_read(uint8_t* buf, int len) {
(void) buf;
(void) len;
Expand Down
24 changes: 10 additions & 14 deletions src/device/dcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,15 @@
//--------------------------------------------------------------------+

typedef enum {
DCD_EVENT_INVALID = 0,
DCD_EVENT_BUS_RESET,
DCD_EVENT_UNPLUGGED,
DCD_EVENT_SOF,
DCD_EVENT_SUSPEND, // TODO LPM Sleep L1 support
DCD_EVENT_RESUME,

DCD_EVENT_SETUP_RECEIVED,
DCD_EVENT_XFER_COMPLETE,

// Not an DCD event, just a convenient way to defer ISR function
USBD_EVENT_FUNC_CALL,

DCD_EVENT_INVALID = 0, // 0
DCD_EVENT_BUS_RESET, // 1
DCD_EVENT_UNPLUGGED, // 2
DCD_EVENT_SOF, // 3
DCD_EVENT_SUSPEND, // 4 TODO LPM Sleep L1 support
DCD_EVENT_RESUME, // 5
DCD_EVENT_SETUP_RECEIVED, // 6
DCD_EVENT_XFER_COMPLETE, // 7
USBD_EVENT_FUNC_CALL, // 8 Not an DCD event, just a convenient way to defer ISR function
DCD_EVENT_COUNT
} dcd_eventid_t;

Expand Down Expand Up @@ -184,7 +180,7 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
TU_ATTR_WEAK bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);

// Configure and enable an ISO endpoint according to descriptor
TU_ATTR_WEAK bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
TU_ATTR_WEAK bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep);

//--------------------------------------------------------------------+
// Event API (implemented by stack)
Expand Down
11 changes: 7 additions & 4 deletions src/device/usbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
};
volatile uint8_t cfg_num; // current active configuration (0x00 is not configured)
uint8_t speed;
volatile uint8_t setup_count;
volatile uint8_t sof_consumer;

uint8_t itf2drv[CFG_TUD_INTERFACE_MAX]; // map interface number to driver (0xff is invalid)
Expand All @@ -131,6 +130,7 @@
}usbd_device_t;

tu_static usbd_device_t _usbd_dev;
static volatile uint8_t _usbd_queued_setup;

//--------------------------------------------------------------------+
// Class Driver
Expand Down Expand Up @@ -459,6 +459,7 @@
TU_LOG_INT(CFG_TUD_LOG_LEVEL, sizeof(tu_edpt_stream_t));

tu_varclr(&_usbd_dev);
_usbd_queued_setup = 0;

#if OSAL_MUTEX_REQUIRED
// Init device mutex
Expand Down Expand Up @@ -594,9 +595,10 @@
break;

case DCD_EVENT_SETUP_RECEIVED:
_usbd_dev.setup_count--;
TU_ASSERT(_usbd_queued_setup > 0,);
_usbd_queued_setup--;
TU_LOG_BUF(CFG_TUD_LOG_LEVEL, &event.setup_received, 8);
if (_usbd_dev.setup_count) {
if (_usbd_queued_setup) {
TU_LOG_USBD(" Skipped since there is other SETUP in queue\r\n");
break;
}
Expand Down Expand Up @@ -1199,7 +1201,8 @@
break;

case DCD_EVENT_SETUP_RECEIVED:
_usbd_dev.setup_count++;
// TU_ASSERT(event->setup_received.bRequest != 0,);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment for catching ch32v203 issue with windows with -O0/-Og

_usbd_queued_setup++;
send = true;
break;

Expand Down
Loading
Loading