STM32F1 EP with USB_COMPOSITE (#19281)
This commit is contained in:
parent
5ea7a8373a
commit
a4bc9e669c
@ -21,7 +21,7 @@
|
|||||||
#define PRODUCT_ID 0x29
|
#define PRODUCT_ID 0x29
|
||||||
|
|
||||||
USBMassStorage MarlinMSC;
|
USBMassStorage MarlinMSC;
|
||||||
USBCompositeSerial MarlinCompositeSerial;
|
MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||||
|
|
||||||
#include "../../inc/MarlinConfig.h"
|
#include "../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
@ -38,6 +38,17 @@ USBCompositeSerial MarlinCompositeSerial;
|
|||||||
|
|
||||||
#endif
|
#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() {
|
void MSC_SD_init() {
|
||||||
USBComposite.setProductId(PRODUCT_ID);
|
USBComposite.setProductId(PRODUCT_ID);
|
||||||
// Just set MarlinCompositeSerial enabled to true
|
// Just set MarlinCompositeSerial enabled to true
|
||||||
@ -59,6 +70,11 @@ void MSC_SD_init() {
|
|||||||
// Register composite Serial
|
// Register composite Serial
|
||||||
MarlinCompositeSerial.registerComponent();
|
MarlinCompositeSerial.registerComponent();
|
||||||
USBComposite.begin();
|
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
|
#endif // USE_USB_COMPOSITE
|
||||||
|
@ -17,7 +17,25 @@
|
|||||||
|
|
||||||
#include <USBComposite.h>
|
#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 USBMassStorage MarlinMSC;
|
||||||
extern USBCompositeSerial MarlinCompositeSerial;
|
extern MarlinUSBCompositeSerial MarlinCompositeSerial;
|
||||||
|
|
||||||
void MSC_SD_init();
|
void MSC_SD_init();
|
||||||
|
Loading…
Reference in New Issue
Block a user