From 25c594611b35dcc6b4991178e454cb73eb58cc61 Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Sun, 15 Dec 2024 04:09:15 +0200 Subject: [PATCH 1/7] Add USB terminal functionality --- rv003usb/rv003usb.c | 74 +++++++++++++++++++++++++++---- rv003usb/rv003usb.h | 4 ++ rv003usb/swio.h | 103 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 rv003usb/swio.h diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index 1ad9fdc..9887265 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -9,6 +9,10 @@ #include "ch32v003fun.h" +#if RV003USB_USB_TERMINAL +#include "swio.h" +#endif + #define ENDPOINT0_SIZE 8 //Fixed for USB 1.1, Low Speed. #if RV003USB_EVENT_DEBUGGING @@ -156,12 +160,22 @@ void usb_pid_handle_in( uint32_t addr, uint8_t * data, uint32_t endp, uint32_t u } #endif - tosend = 0; - // Handle IN (sending data back to PC) // Do this down here. // We do this because we are required to have an in-endpoint. We don't // have to do anything with it, though. +#if RV003USB_USB_TERMINAL + if( e->opaque == DMDATA0 ) + { + usb_send_data( DMDATA0, ENDPOINT0_SIZE, 0, sendtok ); + *DMDATA0 = 0; + *DMDATA1 = 0; + e->opaque = 0; + return; + } +#endif + + uint8_t * tsend = e->opaque; int offset = (e->count)<<3; @@ -195,6 +209,10 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da length -= 3; uint8_t * data_in = __builtin_assume_aligned( data, 4 ); +#if RV003USB_USB_TERMINAL + int send_to_terminal = 0; +#endif + // Already received this packet. if( e->toggle_out != which_data ) { @@ -204,7 +222,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da e->toggle_out = !e->toggle_out; -#if RV003USB_HANDLE_USER_DATA || RV003USB_USE_REBOOT_FEATURE_REPORT +#if RV003USB_HANDLE_USER_DATA || RV003USB_USE_REBOOT_FEATURE_REPORT || RV003USB_USB_TERMINAL if( epno || ( !ist->setup_request && length > 3 ) ) { #if RV003USB_USE_REBOOT_FEATURE_REPORT @@ -223,7 +241,28 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da } } #endif +#if RV003USB_USB_TERMINAL + if( epno == 0 && data_in[0] == 0xfd ) + { + uint32_t *base = __builtin_assume_aligned( data_in, 4 ); + + *DMDATA0 = base[0]; + *DMDATA1 = base[1]; + *DMDATA0 &= ~( 0xFF ); + + int i; + for( i = 1; i < 8; i++ ) + { + if( data_in[i] == 0 ) + { + *DMDATA0 |= i + 3; + break; + } + } + goto just_ack; + } +#endif #if RV003USB_HANDLE_USER_DATA usb_handle_user_data( e, epno, data_in, length, ist ); @@ -291,17 +330,34 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da usb_handle_hid_set_report_start( e, wLength, wvi ); #endif } - else -#if RV003USB_HID_FEATURES - if( reqShl == (0x01a1>>1) ) + else if( reqShl == (0x01a1>>1) ) { // Class read request. // The host wants to read back from us. hid_get_feature_report + e->max_len = 1; +#if RV003USB_HID_FEATURES usb_handle_hid_get_report_start( e, wLength, wvi ); - } - else #endif - if( reqShl == (0x0680>>1) ) // GET_DESCRIPTOR = 6 (msb) +#if RV003USB_USB_TERMINAL + if( ( wvi & 0xff ) == 0xfd ) + { + if( !*DMSTATUS_SENTINEL ) + { + if( ( *DMDATA0 & 0x80 ) && ( ( *DMDATA0 & 0xf ) - 4 ) ) + { + e->opaque = DMDATA0; + e->max_len = ( *DMDATA0 & 0xf ) - 4; + // e->max_len = 8; + } + } + else + { + attempt_unlock( 2 ); + } + } +#endif + } + else if( reqShl == (0x0680>>1) ) // GET_DESCRIPTOR = 6 (msb) { int i; const struct descriptor_list_struct * dl; diff --git a/rv003usb/rv003usb.h b/rv003usb/rv003usb.h index f0d32e9..119e549 100644 --- a/rv003usb/rv003usb.h +++ b/rv003usb/rv003usb.h @@ -52,6 +52,10 @@ */ #endif +#ifndef RV003USB_USB_TERMINAL +#define RV003USB_USB_TERMINAL 0 +#endif + #ifndef __ASSEMBLER__ diff --git a/rv003usb/swio.h b/rv003usb/swio.h new file mode 100644 index 0000000..57fd6d7 --- /dev/null +++ b/rv003usb/swio.h @@ -0,0 +1,103 @@ +#ifndef SWIOH +#define SWIOH +// #include +#define T1COEFF 2 + +#define DMCONTROL 0x10 +#define DMSTATUS 0x11 +#define DMHARTINFO 0x12 +#define DMABSTRACTCS 0x16 +#define DMCOMMAND 0x17 +#define DMABSTRACTAUTO 0x18 +#define DMPROGBUF0 0x20 +#define DMPROGBUF1 0x21 +#define DMPROGBUF2 0x22 +#define DMPROGBUF3 0x23 +#define DMPROGBUF4 0x24 +#define DMPROGBUF5 0x25 +#define DMPROGBUF6 0x26 +#define DMPROGBUF7 0x27 + +#define DMCPBR 0x7C +#define DMCFGR 0x7D +#define DMSHDWCFGR 0x7E + +static inline void PrecDelay( int delay ) +{ + asm volatile( +"1: addi %[delay], %[delay], -1\n" +"bne %[delay], x0, 1b\n" :[delay]"+r"(delay) ); +} + +static inline void Send1Bit(uint8_t t1coeff) +{ + // Low for a nominal period of time. + // High for a nominal period of time. + + AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; + funDigitalWrite(PD1, 0); + AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); + PrecDelay(t1coeff); + + AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; + funDigitalWrite(PD1, 1); + AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); + PrecDelay(t1coeff); +} + +static inline void Send0Bit(uint8_t t1coeff) +{ + // Low for a LONG period of time. + // High for a nominal period of time. + AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; + funDigitalWrite(PD1, 0); + AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); + PrecDelay(t1coeff*4); + AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; + funDigitalWrite(PD1, 1); + AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); + PrecDelay(t1coeff); +} + +static void MCFWriteReg32(uint8_t command, uint32_t value, uint8_t t1coeff) +{ + + funDigitalWrite(PD1, 1); + // funPinMode(PD1, GPIO_Speed_50MHz | GPIO_CNF_OUT_PP); + + __disable_irq(); + Send1Bit(t1coeff); + uint32_t mask; + for( mask = 1<<6; mask; mask >>= 1 ) + { + if( command & mask ) + Send1Bit(t1coeff); + else + Send0Bit(t1coeff); + } + Send1Bit(t1coeff); + for( mask = 1<<31; mask; mask >>= 1 ) + { + if( value & mask ) + Send1Bit(t1coeff); + else + Send0Bit(t1coeff); + } + __enable_irq(); + Delay_Ms(8); // Sometimes 2 is too short. +} + +void attempt_unlock(uint8_t t1coeff) { + if (*DMSTATUS_SENTINEL) { + RCC->APB2PCENR |= RCC_APB2Periph_GPIOD; + AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG); + funPinMode(PD1, GPIO_Speed_50MHz | GPIO_CNF_OUT_PP); + MCFWriteReg32(DMSHDWCFGR, 0x5aa50000 | (1<<10), t1coeff); + MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); + MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); + MCFWriteReg32(DMABSTRACTAUTO, 0x00000000, t1coeff); + MCFWriteReg32(DMCONTROL, 0x80000001 | (1<<10), t1coeff); + MCFWriteReg32(DMCONTROL, 0x40000001 | (1<<10), t1coeff); + } +} +#endif \ No newline at end of file From 9763396ae39ff772c1a43575df0cf9d7b437e28e Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:14:10 +0200 Subject: [PATCH 2/7] Fix DM unlock procedure --- lib/swio_self.h | 92 +++++++++++++++++++++++++++++++++++++++ rv003usb/rv003usb.c | 20 +++++---- rv003usb/swio.h | 103 -------------------------------------------- 3 files changed, 104 insertions(+), 111 deletions(-) create mode 100644 lib/swio_self.h delete mode 100644 rv003usb/swio.h diff --git a/lib/swio_self.h b/lib/swio_self.h new file mode 100644 index 0000000..7250417 --- /dev/null +++ b/lib/swio_self.h @@ -0,0 +1,92 @@ +#ifndef SWIOSELFH +#define SWIOSELFH +#define T1COEFF 2 + +#define DMCONTROL 0x10 +#define DMSTATUS 0x11 +#define DMHARTINFO 0x12 +#define DMABSTRACTCS 0x16 +#define DMCOMMAND 0x17 +#define DMABSTRACTAUTO 0x18 +#define DMPROGBUF0 0x20 +#define DMPROGBUF1 0x21 +#define DMPROGBUF2 0x22 +#define DMPROGBUF3 0x23 +#define DMPROGBUF4 0x24 +#define DMPROGBUF5 0x25 +#define DMPROGBUF6 0x26 +#define DMPROGBUF7 0x27 +#define DMCPBR 0x7C +#define DMCFGR 0x7D +#define DMSHDWCFGR 0x7E + +#define DISABLE_SWIO AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE +#define ENABLE_SWIO AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE) + +static inline void PrecDelay(int delay) { + asm volatile( +"1: addi %[delay], %[delay], -1\n" +"bne %[delay], x0, 1b\n" :[delay]"+r"(delay) ); +} + +static inline void Send1Bit(uint8_t t1coeff) { + // Low for a nominal period of time. + // High for a nominal period of time. + DISABLE_SWIO; + funDigitalWrite(PD1, 0); + ENABLE_SWIO; + PrecDelay(t1coeff); + + DISABLE_SWIO; + funDigitalWrite(PD1, 1); + ENABLE_SWIO; + PrecDelay(t1coeff); +} + +static inline void Send0Bit(uint8_t t1coeff) { + // Low for a LONG period of time. + // High for a nominal period of time. + DISABLE_SWIO; + funDigitalWrite(PD1, 0); + ENABLE_SWIO; + PrecDelay(t1coeff*4); + + DISABLE_SWIO; + funDigitalWrite(PD1, 1); + ENABLE_SWIO; + PrecDelay(t1coeff); +} + +static void MCFWriteReg32(uint8_t command, uint32_t value, uint8_t t1coeff) { + + __disable_irq(); + Send1Bit(t1coeff); + uint32_t mask; + for (mask = 1<<6; mask; mask >>= 1){ + if (command & mask) Send1Bit(t1coeff); + else Send0Bit(t1coeff); + } + Send1Bit(t1coeff); + for (mask = 1<<31; mask; mask >>= 1) { + if (value & mask) Send1Bit(t1coeff); + else Send0Bit(t1coeff); + } + __enable_irq(); + Delay_Ms(8); +} + +void attempt_unlock(uint8_t t1coeff) { + if (*DMSTATUS_SENTINEL) { + RCC->APB2PCENR |= RCC_APB2Periph_GPIOD; + funPinMode(PD1, GPIO_Speed_10MHz | GPIO_CNF_OUT_PP); + MCFWriteReg32(DMSHDWCFGR, 0x5aa50000 | (1<<10), t1coeff); + MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); + *DMDATA0 = 0; // Clear garbage before using it for prints + // The next steps seems unneeded for the purpose + // MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); + // MCFWriteReg32(DMABSTRACTAUTO, 0x00000000, t1coeff); + // MCFWriteReg32(DMCONTROL, 0x80000001 | (1<<10), t1coeff); + // MCFWriteReg32(DMCONTROL, 0x40000001 | (1<<10), t1coeff); + } +} +#endif \ No newline at end of file diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index 9887265..d2f0aa8 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -10,7 +10,11 @@ #include "ch32v003fun.h" #if RV003USB_USB_TERMINAL -#include "swio.h" +#if FUNCONF_USE_DEBUGPRINTF +#include "../lib/swio_self.h" // Needed for unlocking DM +#else +#define RV003USB_USB_TERMINAL 0 +#endif #endif #define ENDPOINT0_SIZE 8 //Fixed for USB 1.1, Low Speed. @@ -165,9 +169,9 @@ void usb_pid_handle_in( uint32_t addr, uint8_t * data, uint32_t endp, uint32_t u // We do this because we are required to have an in-endpoint. We don't // have to do anything with it, though. #if RV003USB_USB_TERMINAL - if( e->opaque == DMDATA0 ) + if( e->opaque == (uint8_t *)DMDATA0 ) { - usb_send_data( DMDATA0, ENDPOINT0_SIZE, 0, sendtok ); + usb_send_data( (void *)DMDATA0, ENDPOINT0_SIZE, 0, sendtok ); *DMDATA0 = 0; *DMDATA1 = 0; e->opaque = 0; @@ -209,10 +213,6 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da length -= 3; uint8_t * data_in = __builtin_assume_aligned( data, 4 ); -#if RV003USB_USB_TERMINAL - int send_to_terminal = 0; -#endif - // Already received this packet. if( e->toggle_out != which_data ) { @@ -345,10 +345,14 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da { if( ( *DMDATA0 & 0x80 ) && ( ( *DMDATA0 & 0xf ) - 4 ) ) { - e->opaque = DMDATA0; + e->opaque = (uint8_t *)DMDATA0; e->max_len = ( *DMDATA0 & 0xf ) - 4; // e->max_len = 8; } + else if( ( *DMDATA0 & 0xc0 ) == 0xc0 ) + { + *DMDATA0 = 0; + } } else { diff --git a/rv003usb/swio.h b/rv003usb/swio.h deleted file mode 100644 index 57fd6d7..0000000 --- a/rv003usb/swio.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef SWIOH -#define SWIOH -// #include -#define T1COEFF 2 - -#define DMCONTROL 0x10 -#define DMSTATUS 0x11 -#define DMHARTINFO 0x12 -#define DMABSTRACTCS 0x16 -#define DMCOMMAND 0x17 -#define DMABSTRACTAUTO 0x18 -#define DMPROGBUF0 0x20 -#define DMPROGBUF1 0x21 -#define DMPROGBUF2 0x22 -#define DMPROGBUF3 0x23 -#define DMPROGBUF4 0x24 -#define DMPROGBUF5 0x25 -#define DMPROGBUF6 0x26 -#define DMPROGBUF7 0x27 - -#define DMCPBR 0x7C -#define DMCFGR 0x7D -#define DMSHDWCFGR 0x7E - -static inline void PrecDelay( int delay ) -{ - asm volatile( -"1: addi %[delay], %[delay], -1\n" -"bne %[delay], x0, 1b\n" :[delay]"+r"(delay) ); -} - -static inline void Send1Bit(uint8_t t1coeff) -{ - // Low for a nominal period of time. - // High for a nominal period of time. - - AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; - funDigitalWrite(PD1, 0); - AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); - PrecDelay(t1coeff); - - AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; - funDigitalWrite(PD1, 1); - AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); - PrecDelay(t1coeff); -} - -static inline void Send0Bit(uint8_t t1coeff) -{ - // Low for a LONG period of time. - // High for a nominal period of time. - AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; - funDigitalWrite(PD1, 0); - AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); - PrecDelay(t1coeff*4); - AFIO->PCFR1 |= AFIO_PCFR1_SWJ_CFG_DISABLE; - funDigitalWrite(PD1, 1); - AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG_DISABLE); - PrecDelay(t1coeff); -} - -static void MCFWriteReg32(uint8_t command, uint32_t value, uint8_t t1coeff) -{ - - funDigitalWrite(PD1, 1); - // funPinMode(PD1, GPIO_Speed_50MHz | GPIO_CNF_OUT_PP); - - __disable_irq(); - Send1Bit(t1coeff); - uint32_t mask; - for( mask = 1<<6; mask; mask >>= 1 ) - { - if( command & mask ) - Send1Bit(t1coeff); - else - Send0Bit(t1coeff); - } - Send1Bit(t1coeff); - for( mask = 1<<31; mask; mask >>= 1 ) - { - if( value & mask ) - Send1Bit(t1coeff); - else - Send0Bit(t1coeff); - } - __enable_irq(); - Delay_Ms(8); // Sometimes 2 is too short. -} - -void attempt_unlock(uint8_t t1coeff) { - if (*DMSTATUS_SENTINEL) { - RCC->APB2PCENR |= RCC_APB2Periph_GPIOD; - AFIO->PCFR1 &= ~(AFIO_PCFR1_SWJ_CFG); - funPinMode(PD1, GPIO_Speed_50MHz | GPIO_CNF_OUT_PP); - MCFWriteReg32(DMSHDWCFGR, 0x5aa50000 | (1<<10), t1coeff); - MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); - MCFWriteReg32(DMCFGR, 0x5aa50000 | (1<<10), t1coeff); - MCFWriteReg32(DMABSTRACTAUTO, 0x00000000, t1coeff); - MCFWriteReg32(DMCONTROL, 0x80000001 | (1<<10), t1coeff); - MCFWriteReg32(DMCONTROL, 0x40000001 | (1<<10), t1coeff); - } -} -#endif \ No newline at end of file From 3556981f71b6fa77d2aef93f42137557ad67f6be Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:39:51 +0200 Subject: [PATCH 3/7] Fix flags --- rv003usb/rv003usb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index 981f81b..be5b767 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -330,15 +330,16 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da usb_handle_hid_set_report_start( e, wLength, wvi ); #endif } - else if( reqShl == (0x01a1>>1) ) + else +#if RV003USB_HID_FEATURES || RV003USB_USB_TERMINAL + if( reqShl == (0x01a1>>1) ) { // Class read request. // The host wants to read back from us. hid_get_feature_report - e->max_len = 1; + e->max_len = 1; // If 0 - terminal is sent to the stratosphere #if RV003USB_HID_FEATURES usb_handle_hid_get_report_start( e, wLength, wvi ); #endif -#if RV003USB_USB_TERMINAL if( ( wvi & 0xff ) == 0xfd ) { if( !*DMSTATUS_SENTINEL ) From 5963978174175a1b2007ab3a24132899e1487ded Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:47:54 +0200 Subject: [PATCH 4/7] Fix formatting --- rv003usb/rv003usb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index be5b767..85cf60e 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -330,9 +330,9 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da usb_handle_hid_set_report_start( e, wLength, wvi ); #endif } - else + else #if RV003USB_HID_FEATURES || RV003USB_USB_TERMINAL - if( reqShl == (0x01a1>>1) ) + if( reqShl == ( 0x01a1 >> 1 ) ) { // Class read request. // The host wants to read back from us. hid_get_feature_report @@ -360,9 +360,11 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da attempt_unlock( 2 ); } } -#endif + } - else if( reqShl == (0x0680>>1) ) // GET_DESCRIPTOR = 6 (msb) + else +#endif + if( reqShl == ( 0x0680 >> 1 ) ) // GET_DESCRIPTOR = 6 (msb) { int i; const struct descriptor_list_struct * dl; From 8627d2751616f829683d6935fc7beb0cf8924195 Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 20:50:24 +0200 Subject: [PATCH 5/7] Fix formatting --- rv003usb/rv003usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index 85cf60e..a7f5e0a 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -332,7 +332,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da } else #if RV003USB_HID_FEATURES || RV003USB_USB_TERMINAL - if( reqShl == ( 0x01a1 >> 1 ) ) + if( reqShl == (0x01a1>>1) ) { // Class read request. // The host wants to read back from us. hid_get_feature_report @@ -364,7 +364,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da } else #endif - if( reqShl == ( 0x0680 >> 1 ) ) // GET_DESCRIPTOR = 6 (msb) + if( reqShl == (0x0680>>1) ) // GET_DESCRIPTOR = 6 (msb) { int i; const struct descriptor_list_struct * dl; From 5e37a849bc44ede3f56ed0a98cce821f8e5d1b0b Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 21:09:31 +0200 Subject: [PATCH 6/7] Forgot #if --- rv003usb/rv003usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index a7f5e0a..fbf56f8 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -340,6 +340,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da #if RV003USB_HID_FEATURES usb_handle_hid_get_report_start( e, wLength, wvi ); #endif +#if RV003USB_USB_TERMINAL if( ( wvi & 0xff ) == 0xfd ) { if( !*DMSTATUS_SENTINEL ) @@ -360,7 +361,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da attempt_unlock( 2 ); } } - +#endif } else #endif From f3e3f40803a180b8bdd579260c500ee6d6463a65 Mon Sep 17 00:00:00 2001 From: monte-monte <6649967+monte-monte@users.noreply.github.com> Date: Wed, 19 Feb 2025 23:56:51 +0200 Subject: [PATCH 7/7] Fix issue with poll_input --- rv003usb/rv003usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rv003usb/rv003usb.c b/rv003usb/rv003usb.c index fbf56f8..0a1b1f6 100644 --- a/rv003usb/rv003usb.c +++ b/rv003usb/rv003usb.c @@ -345,7 +345,7 @@ void usb_pid_handle_data( uint32_t this_token, uint8_t * data, uint32_t which_da { if( !*DMSTATUS_SENTINEL ) { - if( ( *DMDATA0 & 0x80 ) && ( ( *DMDATA0 & 0xf ) - 4 ) ) + if( ( *DMDATA0 & 0x80 ) ) { e->opaque = (uint8_t *)DMDATA0; e->max_len = ( *DMDATA0 & 0xf ) - 4;