WIP No debug
This commit is contained in:
parent
e7224c13d2
commit
a6ad93d184
2 changed files with 5 additions and 22 deletions
|
|
@ -36,7 +36,6 @@ static bool is_report_queued = false;
|
||||||
static bool report_sent = false;
|
static bool report_sent = false;
|
||||||
static uint8_t queued_report_id = 0;
|
static uint8_t queued_report_id = 0;
|
||||||
static bool forced_ready = false;
|
static bool forced_ready = false;
|
||||||
static bool host_sent_out = false;
|
|
||||||
static uint8_t handshake_counter = 0;
|
static uint8_t handshake_counter = 0;
|
||||||
|
|
||||||
static SwitchDeviceInfo device_info{};
|
static SwitchDeviceInfo device_info{};
|
||||||
|
|
@ -208,7 +207,6 @@ static void read_spi_flash(uint8_t* dest, uint32_t address, uint8_t size) {
|
||||||
static void handle_config_report(uint8_t switchReportID, uint8_t switchReportSubID, const uint8_t *reportData, uint16_t reportLength) {
|
static void handle_config_report(uint8_t switchReportID, uint8_t switchReportSubID, const uint8_t *reportData, uint16_t reportLength) {
|
||||||
bool canSend = false;
|
bool canSend = false;
|
||||||
last_host_activity_ms = to_ms_since_boot(get_absolute_time());
|
last_host_activity_ms = to_ms_since_boot(get_absolute_time());
|
||||||
host_sent_out = true;
|
|
||||||
|
|
||||||
switch (switchReportSubID) {
|
switch (switchReportSubID) {
|
||||||
case IDENTIFY:
|
case IDENTIFY:
|
||||||
|
|
@ -262,7 +260,6 @@ static void handle_feature_report(uint8_t switchReportID, uint8_t switchReportSu
|
||||||
uint8_t spiReadSize = 0;
|
uint8_t spiReadSize = 0;
|
||||||
bool canSend = false;
|
bool canSend = false;
|
||||||
last_host_activity_ms = to_ms_since_boot(get_absolute_time());
|
last_host_activity_ms = to_ms_since_boot(get_absolute_time());
|
||||||
host_sent_out = true;
|
|
||||||
|
|
||||||
report_buffer[0] = REPORT_OUTPUT_21;
|
report_buffer[0] = REPORT_OUTPUT_21;
|
||||||
report_buffer[1] = last_report_counter;
|
report_buffer[1] = last_report_counter;
|
||||||
|
|
@ -464,7 +461,10 @@ void switch_pro_init() {
|
||||||
is_report_queued = false;
|
is_report_queued = false;
|
||||||
report_sent = false;
|
report_sent = false;
|
||||||
forced_ready = false;
|
forced_ready = false;
|
||||||
host_sent_out = false;
|
forced_ready = true;
|
||||||
|
is_ready = true;
|
||||||
|
is_initialized = true;
|
||||||
|
last_report_timer = 0;
|
||||||
|
|
||||||
device_info = {
|
device_info = {
|
||||||
.majorVersion = 0x04,
|
.majorVersion = 0x04,
|
||||||
|
|
@ -553,13 +553,7 @@ void switch_pro_task() {
|
||||||
report_sent = true;
|
report_sent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start sending full reports only after the host has talked to us on OUT.
|
if (is_ready && !report_sent) {
|
||||||
if (!is_ready && host_sent_out) {
|
|
||||||
is_ready = true;
|
|
||||||
LOG_PRINTF("[HID] ready because host sent OUT traffic\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_ready && !report_sent && host_sent_out) {
|
|
||||||
if ((now - last_report_timer) > SWITCH_PRO_KEEPALIVE_TIMER) {
|
if ((now - last_report_timer) > SWITCH_PRO_KEEPALIVE_TIMER) {
|
||||||
switch_report.timestamp = last_report_counter;
|
switch_report.timestamp = last_report_counter;
|
||||||
void * inputReport = &switch_report;
|
void * inputReport = &switch_report;
|
||||||
|
|
@ -650,10 +644,6 @@ bool switch_pro_is_ready() {
|
||||||
return is_ready;
|
return is_ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
void switch_pro_mark_host_active() {
|
|
||||||
host_sent_out = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// HID callbacks
|
// HID callbacks
|
||||||
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) {
|
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) {
|
||||||
(void)instance;
|
(void)instance;
|
||||||
|
|
@ -677,7 +667,6 @@ void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_
|
||||||
uint8_t switchReportSubID = buffer[1];
|
uint8_t switchReportSubID = buffer[1];
|
||||||
LOG_PRINTF("[HID] set_report type=%d id=%u switchRID=0x%02x sub=0x%02x len=%u\n",
|
LOG_PRINTF("[HID] set_report type=%d id=%u switchRID=0x%02x sub=0x%02x len=%u\n",
|
||||||
report_type, report_id, switchReportID, switchReportSubID, bufsize);
|
report_type, report_id, switchReportID, switchReportSubID, bufsize);
|
||||||
host_sent_out = true;
|
|
||||||
if (switchReportID == REPORT_OUTPUT_00) {
|
if (switchReportID == REPORT_OUTPUT_00) {
|
||||||
// No-op, just acknowledge to clear any stalls.
|
// No-op, just acknowledge to clear any stalls.
|
||||||
return;
|
return;
|
||||||
|
|
@ -699,7 +688,6 @@ void tud_hid_report_received_cb(uint8_t instance, uint8_t report_id, uint8_t con
|
||||||
uint8_t switchReportSubID = buffer[1];
|
uint8_t switchReportSubID = buffer[1];
|
||||||
LOG_PRINTF("[HID] report_received id=%u switchRID=0x%02x sub=0x%02x len=%u\n",
|
LOG_PRINTF("[HID] report_received id=%u switchRID=0x%02x sub=0x%02x len=%u\n",
|
||||||
report_id, switchReportID, switchReportSubID, bufsize);
|
report_id, switchReportID, switchReportSubID, bufsize);
|
||||||
host_sent_out = true;
|
|
||||||
if (switchReportID == REPORT_OUTPUT_00) {
|
if (switchReportID == REPORT_OUTPUT_00) {
|
||||||
return;
|
return;
|
||||||
} else if (switchReportID == REPORT_FEATURE) {
|
} else if (switchReportID == REPORT_FEATURE) {
|
||||||
|
|
@ -738,7 +726,6 @@ void tud_mount_cb(void) {
|
||||||
forced_ready = false;
|
forced_ready = false;
|
||||||
is_ready = false;
|
is_ready = false;
|
||||||
is_initialized = false;
|
is_initialized = false;
|
||||||
host_sent_out = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tud_umount_cb(void) {
|
void tud_umount_cb(void) {
|
||||||
|
|
@ -746,7 +733,6 @@ void tud_umount_cb(void) {
|
||||||
forced_ready = false;
|
forced_ready = false;
|
||||||
is_ready = false;
|
is_ready = false;
|
||||||
is_initialized = false;
|
is_initialized = false;
|
||||||
host_sent_out = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t desc_str[32];
|
static uint16_t desc_str[32];
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,3 @@ bool switch_pro_apply_uart_packet(const uint8_t* packet, uint8_t length, SwitchI
|
||||||
|
|
||||||
// Driver state helpers
|
// Driver state helpers
|
||||||
bool switch_pro_is_ready();
|
bool switch_pro_is_ready();
|
||||||
|
|
||||||
// Mark that the host has sent any OUT traffic (allows starting IN reports).
|
|
||||||
void switch_pro_mark_host_active();
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue