Prechádzať zdrojové kódy

move some shared structs to pof_usb.h

Sanjay Govind 11 mesiacov pred
rodič
commit
5803f80079
3 zmenil súbory, kde vykonal 40 pridanie a 76 odobranie
  1. 0 38
      helpers/pof_usb.c
  2. 40 0
      helpers/pof_usb.h
  3. 0 38
      helpers/pof_usb_xbox360.c

+ 0 - 38
helpers/pof_usb.c

@@ -12,12 +12,6 @@
 #define POF_USB_EP_IN  (0x81)
 #define POF_USB_EP_IN  (0x81)
 #define POF_USB_EP_OUT (0x02)
 #define POF_USB_EP_OUT (0x02)
 
 
-#define POF_USB_EP_IN_SIZE  (64UL)
-#define POF_USB_EP_OUT_SIZE (64UL)
-
-#define POF_USB_RX_MAX_SIZE (POF_USB_EP_OUT_SIZE)
-#define POF_USB_TX_MAX_SIZE (POF_USB_EP_IN_SIZE)
-
 #define POF_USB_ACTUAL_OUTPUT_SIZE 0x20
 #define POF_USB_ACTUAL_OUTPUT_SIZE 0x20
 
 
 static const struct usb_string_descriptor dev_manuf_desc =
 static const struct usb_string_descriptor dev_manuf_desc =
@@ -36,38 +30,6 @@ static usbd_respond
 static void pof_usb_send(usbd_device* dev, uint8_t* buf, uint16_t len);
 static void pof_usb_send(usbd_device* dev, uint8_t* buf, uint16_t len);
 static int32_t pof_usb_receive(usbd_device* dev, uint8_t* buf, uint16_t max_len);
 static int32_t pof_usb_receive(usbd_device* dev, uint8_t* buf, uint16_t max_len);
 
 
-typedef enum {
-    EventExit = (1 << 0),
-    EventReset = (1 << 1),
-    EventRx = (1 << 2),
-    EventTx = (1 << 3),
-    EventTxComplete = (1 << 4),
-    EventResetSio = (1 << 5),
-    EventTxImmediate = (1 << 6),
-
-    EventAll = EventExit | EventReset | EventRx | EventTx | EventTxComplete | EventResetSio |
-               EventTxImmediate,
-} PoFEvent;
-
-struct PoFUsb {
-    FuriHalUsbInterface usb;
-    FuriHalUsbInterface* usb_prev;
-
-    FuriThread* thread;
-    usbd_device* dev;
-    VirtualPortal* virtual_portal;
-    uint8_t data_recvest[8];
-    uint16_t data_recvest_len;
-
-    bool tx_complete;
-    bool tx_immediate;
-
-    uint8_t dataAvailable;
-    uint8_t data[POF_USB_RX_MAX_SIZE];
-
-    uint8_t tx_data[POF_USB_TX_MAX_SIZE];
-};
-
 static PoFUsb* pof_cur = NULL;
 static PoFUsb* pof_cur = NULL;
 
 
 static int32_t pof_thread_worker(void* context) {
 static int32_t pof_thread_worker(void* context) {

+ 40 - 0
helpers/pof_usb.h

@@ -13,6 +13,13 @@
 #define HID_REPORT_TYPE_OUTPUT  2
 #define HID_REPORT_TYPE_OUTPUT  2
 #define HID_REPORT_TYPE_FEATURE 3
 #define HID_REPORT_TYPE_FEATURE 3
 
 
+
+#define POF_USB_EP_IN_SIZE  (64UL)
+#define POF_USB_EP_OUT_SIZE (64UL)
+
+#define POF_USB_RX_MAX_SIZE (POF_USB_EP_OUT_SIZE)
+#define POF_USB_TX_MAX_SIZE (POF_USB_EP_IN_SIZE)
+
 typedef struct PoFUsb PoFUsb;
 typedef struct PoFUsb PoFUsb;
 
 
 PoFUsb* pof_usb_start(VirtualPortal* virtual_portal);
 PoFUsb* pof_usb_start(VirtualPortal* virtual_portal);
@@ -79,3 +86,36 @@ typedef enum {
     PoFControlRequestsOut = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlOut),
     PoFControlRequestsOut = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlOut),
     PoFControlRequestsIn = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlIn),
     PoFControlRequestsIn = (PoFControlTypeVendor | PoFControlRecipientDevice | PoFControlIn),
 } PoFControlRequests;
 } PoFControlRequests;
+
+
+typedef enum {
+    EventExit = (1 << 0),
+    EventReset = (1 << 1),
+    EventRx = (1 << 2),
+    EventTx = (1 << 3),
+    EventTxComplete = (1 << 4),
+    EventResetSio = (1 << 5),
+    EventTxImmediate = (1 << 6),
+
+    EventAll = EventExit | EventReset | EventRx | EventTx | EventTxComplete | EventResetSio |
+               EventTxImmediate,
+} PoFEvent;
+
+struct PoFUsb {
+    FuriHalUsbInterface usb;
+    FuriHalUsbInterface* usb_prev;
+
+    FuriThread* thread;
+    usbd_device* dev;
+    VirtualPortal* virtual_portal;
+    uint8_t data_recvest[8];
+    uint16_t data_recvest_len;
+
+    bool tx_complete;
+    bool tx_immediate;
+
+    uint8_t dataAvailable;
+    uint8_t data[POF_USB_RX_MAX_SIZE];
+
+    uint8_t tx_data[POF_USB_TX_MAX_SIZE];
+};

+ 0 - 38
helpers/pof_usb_xbox360.c

@@ -17,12 +17,6 @@
 #define POF_USB_X360_AUDIO_EP_OUT2  (0x06)
 #define POF_USB_X360_AUDIO_EP_OUT2  (0x06)
 #define POF_USB_X360_PLUGIN_MODULE_EP_IN  (0x87)
 #define POF_USB_X360_PLUGIN_MODULE_EP_IN  (0x87)
 
 
-#define POF_USB_EP_IN_SIZE  (64UL)
-#define POF_USB_EP_OUT_SIZE (64UL)
-
-#define POF_USB_RX_MAX_SIZE (POF_USB_EP_OUT_SIZE)
-#define POF_USB_TX_MAX_SIZE (POF_USB_EP_IN_SIZE)
-
 #define POF_USB_ACTUAL_OUTPUT_SIZE 0x20
 #define POF_USB_ACTUAL_OUTPUT_SIZE 0x20
 
 
 static const struct usb_string_descriptor dev_manuf_desc =
 static const struct usb_string_descriptor dev_manuf_desc =
@@ -45,38 +39,6 @@ static usbd_respond
 static void pof_usb_send(usbd_device* dev, uint8_t* buf, uint16_t len);
 static void pof_usb_send(usbd_device* dev, uint8_t* buf, uint16_t len);
 static int32_t pof_usb_receive(usbd_device* dev, uint8_t* buf, uint16_t max_len);
 static int32_t pof_usb_receive(usbd_device* dev, uint8_t* buf, uint16_t max_len);
 
 
-typedef enum {
-    EventExit = (1 << 0),
-    EventReset = (1 << 1),
-    EventRx = (1 << 2),
-    EventTx = (1 << 3),
-    EventTxComplete = (1 << 4),
-    EventResetSio = (1 << 5),
-    EventTxImmediate = (1 << 6),
-
-    EventAll = EventExit | EventReset | EventRx | EventTx | EventTxComplete | EventResetSio |
-               EventTxImmediate,
-} PoFEvent;
-
-struct PoFUsb {
-    FuriHalUsbInterface usb;
-    FuriHalUsbInterface* usb_prev;
-
-    FuriThread* thread;
-    usbd_device* dev;
-    VirtualPortal* virtual_portal;
-    uint8_t data_recvest[8];
-    uint16_t data_recvest_len;
-
-    bool tx_complete;
-    bool tx_immediate;
-
-    uint8_t dataAvailable;
-    uint8_t data[POF_USB_RX_MAX_SIZE];
-
-    uint8_t tx_data[POF_USB_TX_MAX_SIZE];
-};
-
 static PoFUsb* pof_cur = NULL;
 static PoFUsb* pof_cur = NULL;
 
 
 static int32_t pof_thread_worker(void* context) {
 static int32_t pof_thread_worker(void* context) {