-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from HydraDancer/add_naks_rethink_events
Pass Facedancer stress test, adding NAK support
- Loading branch information
Showing
30 changed files
with
421 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
#include "definitions.h" | ||
#include "wch-ch56x-lib/USBDevice/usb20.h" | ||
|
||
uint8_t endpoint_mapping_reverse[MAX_ENDPOINTS_SUPPORTED]; //endpoint_mapping_reverse[PC_Endpoint] = Target_Endpoint | ||
uint8_t endpoint_mapping[MAX_ENDPOINTS_SUPPORTED]; //endpoint_mapping[Target_Endpoint] = PC_Endpoint | ||
|
||
__attribute__((aligned(16))) volatile hydradancer_status_t hydradancer_status __attribute__((section(".DMADATA"))) = { .ep_in_nak = 0, .ep_in_status = 0, .ep_out_status = 0, .other_events = 0 }; | ||
__attribute__((aligned(16))) volatile uint8_t boards_ready __attribute__((section(".DMADATA"))) = 0; | ||
__attribute__((aligned(16))) volatile bool event_transfer_finished = true; | ||
__attribute__((aligned(16))) volatile bool start_polling = false; | ||
__attribute__((aligned(16))) volatile hydradancer_event_t _events_buffer[EVENT_QUEUE_SIZE] __attribute__((section(".DMADATA"))); | ||
uint64_t MAX_BUSY_WAIT_CYCLES = 1234567899; //set to a lower value in main, after bsp_init | ||
|
||
void send_hydradancer_status(void) | ||
HYDRA_POOL_DEF(ep_queue, ep_queue_member_t, 100); | ||
|
||
void _ep_queue_cleanup(uint8_t* data) | ||
{ | ||
endp_tx_set_new_buffer(&usb_device_1, 1, (uint8_t*)&hydradancer_status, sizeof(hydradancer_status)); | ||
hydra_pool_free(&ep_queue, data); | ||
} | ||
|
||
HYDRA_POOL_DEF(ep0_queue, ep0_queue_member_t, 20); | ||
HYDRA_FIFO_DEF(event_queue, hydradancer_event_t, EVENT_QUEUE_SIZE); | ||
|
||
void _ep0_queue_cleanup(uint8_t* data) | ||
void hydradancer_send_event(void) | ||
{ | ||
hydra_pool_free(&ep0_queue, data); | ||
if (event_transfer_finished) | ||
{ | ||
uint16_t events_count = fifo_count(&event_queue); | ||
if (events_count > 0) | ||
{ | ||
event_transfer_finished = false; | ||
uint16_t count_read = fifo_read_n(&event_queue, (void*)_events_buffer, events_count); | ||
endp_tx_set_new_buffer(&usb_device_1, 1, (uint8_t*)_events_buffer, count_read * sizeof(hydradancer_event_t)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.