STM32F1 EP with USB_COMPOSITE (#19281)

2.0.x
Victor Oliveira 4 years ago committed by GitHub
parent 5ea7a8373a
commit a4bc9e669c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@
#define PRODUCT_ID 0x29
USBMassStorage MarlinMSC;
USBCompositeSerial MarlinCompositeSerial;
MarlinUSBCompositeSerial MarlinCompositeSerial;
#include "../../inc/MarlinConfig.h"
@ -38,6 +38,17 @@ USBCompositeSerial MarlinCompositeSerial;
#endif
#if ENABLED(EMERGENCY_PARSER)
void (*real_rx_callback)(void);
void my_rx_callback(void) {
real_rx_callback();
int len = MarlinCompositeSerial.available();
while (len-- > 0) // >0 because available() may return a negative value
emergency_parser.update(MarlinCompositeSerial.emergency_state, MarlinCompositeSerial.peek());
}
#endif
void MSC_SD_init() {
USBComposite.setProductId(PRODUCT_ID);
// Just set MarlinCompositeSerial enabled to true
@ -59,6 +70,11 @@ void MSC_SD_init() {
// Register composite Serial
MarlinCompositeSerial.registerComponent();
USBComposite.begin();
#if ENABLED(EMERGENCY_PARSER)
//rx is usbSerialPart.endpoints[2]
real_rx_callback = usbSerialPart.endpoints[2].callback;
usbSerialPart.endpoints[2].callback = my_rx_callback;
#endif
}
#endif // USE_USB_COMPOSITE

@ -17,7 +17,25 @@
#include <USBComposite.h>
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(EMERGENCY_PARSER)
#include "../../feature/e_parser.h"
#endif
class MarlinUSBCompositeSerial : public USBCompositeSerial {
public:
MarlinUSBCompositeSerial() : USBCompositeSerial()
#if ENABLED(EMERGENCY_PARSER)
, emergency_state(EmergencyParser::State::EP_RESET)
#endif
{ }
#if ENABLED(EMERGENCY_PARSER)
EmergencyParser::State emergency_state;
#endif
};
extern USBMassStorage MarlinMSC;
extern USBCompositeSerial MarlinCompositeSerial;
extern MarlinUSBCompositeSerial MarlinCompositeSerial;
void MSC_SD_init();

Loading…
Cancel
Save