parent
ca12a1c660
commit
387fd681dd
|
@ -25,6 +25,8 @@ USB_Setup_TypeDef;
|
|||
|
||||
#define MAX_CAN_MSGS_PER_BULK_TRANSFER 4U
|
||||
|
||||
bool usb_eopf_detected = false;
|
||||
|
||||
void usb_init(void);
|
||||
int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp, bool hardwired);
|
||||
int usb_cb_ep1_in(void *usbdata, int len, bool hardwired);
|
||||
|
@ -696,6 +698,10 @@ void usb_irqhandler(void) {
|
|||
puts("ESUSP detected\n");
|
||||
}
|
||||
|
||||
if ((gintsts & USB_OTG_GINTSTS_EOPF) != 0) {
|
||||
usb_eopf_detected = true;
|
||||
}
|
||||
|
||||
if ((gintsts & USB_OTG_GINTSTS_USBRST) != 0) {
|
||||
puts("USB reset\n");
|
||||
usb_reset();
|
||||
|
@ -958,8 +964,15 @@ void OTG_FS_IRQ_Handler(void) {
|
|||
}
|
||||
|
||||
bool usb_enumerated(void) {
|
||||
// This relies on the USB being suspended after no activity for 3ms. Seems pretty stable
|
||||
return (!(USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS));
|
||||
// This relies on the USB being suspended after no activity for 3ms.
|
||||
// Seems pretty stable in combination with the EOPF to reject noise.
|
||||
bool ret = false;
|
||||
if(!(USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS)){
|
||||
// Check to see if an end of periodic frame is detected
|
||||
ret = usb_eopf_detected;
|
||||
}
|
||||
usb_eopf_detected = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// ***************************** USB init *****************************
|
||||
|
@ -1026,7 +1039,7 @@ void usb_init(void) {
|
|||
USBx->GINTMSK = USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_OTGINT |
|
||||
USB_OTG_GINTMSK_RXFLVLM | USB_OTG_GINTMSK_GONAKEFFM | USB_OTG_GINTMSK_GINAKEFFM |
|
||||
USB_OTG_GINTMSK_OEPINT | USB_OTG_GINTMSK_IEPINT | USB_OTG_GINTMSK_USBSUSPM |
|
||||
USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM;
|
||||
USB_OTG_GINTMSK_CIDSCHGM | USB_OTG_GINTMSK_SRQIM | USB_OTG_GINTMSK_MMISM | USB_OTG_GINTMSK_EOPFM;
|
||||
|
||||
USBx->GAHBCFG = USB_OTG_GAHBCFG_GINT;
|
||||
|
||||
|
|
|
@ -705,7 +705,7 @@ void TIM1_BRK_TIM9_IRQ_Handler(void) {
|
|||
puth(can_tx2_q.r_ptr); puts(" "); puth(can_tx2_q.w_ptr); puts("\n");
|
||||
#endif
|
||||
|
||||
// Tick fan driver
|
||||
// Tick drivers
|
||||
fan_tick();
|
||||
|
||||
// set green LED to be controls allowed
|
||||
|
|
Loading…
Reference in New Issue