dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_usbhook.h
Go to the documentation of this file.
1 
16 /*
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful, but
23  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25  * for more details.
26  *
27  * You should have received a copy of the GNU General Public License along
28  * with this program; if not, see <http://www.gnu.org/licenses/>
29  */
30 
31 #ifndef PIOS_USBHOOK_H
32 #define PIOS_USBHOOK_H
33 
34 #include <stdbool.h>
35 #include <stdint.h>
36 #include "pios_usb_defs.h" /* usb_setup_request */
37 
39  const uint8_t * descriptor;
40  uint16_t length;
41 };
42 
48 } __attribute__((packed));
49 
50 extern void PIOS_USBHOOK_RegisterDevice(const uint8_t * desc, uint16_t desc_size);
51 extern void PIOS_USBHOOK_RegisterConfig(uint8_t config_id, const uint8_t * desc, uint16_t desc_size);
52 extern void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t * desc, uint16_t desc_size);
53 
55  void (*init)(uintptr_t context);
56  void (*deinit)(uintptr_t context);
57  bool (*setup)(uintptr_t context, struct usb_setup_request * req);
58  void (*ctrl_data_out)(uintptr_t context, const struct usb_setup_request * req);
59 };
60 
61 extern void PIOS_USBHOOK_RegisterIfOps(uint8_t ifnum, struct pios_usb_ifops * ifops, uintptr_t context);
62 
63 typedef bool (*pios_usbhook_epcb)(uintptr_t context, uint8_t epnum, uint16_t len);
64 
65 extern void PIOS_USBHOOK_RegisterEpInCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uintptr_t context);
66 extern void PIOS_USBHOOK_RegisterEpOutCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uintptr_t context);
67 extern void PIOS_USBHOOK_DeRegisterEpInCallback(uint8_t epnum);
68 extern void PIOS_USBHOOK_DeRegisterEpOutCallback(uint8_t epnum);
69 
70 extern void PIOS_USBHOOK_CtrlTx(const uint8_t *buf, uint16_t len);
71 extern void PIOS_USBHOOK_CtrlRx(uint8_t *buf, uint16_t len);
72 extern void PIOS_USBHOOK_EndpointTx(uint8_t epnum, const uint8_t *buf, uint16_t len);
73 extern void PIOS_USBHOOK_EndpointRx(uint8_t epnum, uint8_t *buf, uint16_t len);
74 extern void PIOS_USBHOOK_Activate(void);
75 extern void PIOS_USBHOOK_Deactivate(void);
76 
77 #endif /* PIOS_USBHOOK_H */
78 
void PIOS_USBHOOK_CtrlTx(const uint8_t *buf, uint16_t len)
Definition: pios_usbhook.c:197
uint32_t desc_size
void PIOS_USBHOOK_CtrlRx(uint8_t *buf, uint16_t len)
Definition: pios_usbhook.c:202
void PIOS_USBHOOK_Deactivate(void)
Definition: pios_usbhook.c:84
tuple desc
Definition: px_mkfw.py:82
struct pios_usb_ifops __attribute__
USB_STRING_DESC_VENDOR
Definition: pios_usbhook.h:37
USB_STRING_DESC_SERIAL
Definition: pios_usbhook.h:39
void(* init)(uintptr_t context)
Definition: pios_usbhook.h:55
void(* deinit)(uintptr_t context)
Definition: pios_usbhook.h:56
bool(* pios_usbhook_epcb)(uintptr_t context, uint8_t epnum, uint16_t len)
Definition: pios_usbhook.h:63
USB_STRING_DESC_LANG
Definition: pios_usbhook.h:36
void(* ctrl_data_out)(uintptr_t context, const struct usb_setup_request *req)
Definition: pios_usbhook.h:58
void PIOS_USBHOOK_EndpointRx(uint8_t epnum, uint8_t *buf, uint16_t len)
Definition: pios_usbhook.c:214
usb_string_desc
Definition: pios_usbhook.h:43
void PIOS_USBHOOK_RegisterEpInCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uintptr_t context)
Definition: pios_usbhook.c:128
void PIOS_USBHOOK_RegisterConfig(uint8_t config_id, const uint8_t *desc, uint16_t desc_size)
Definition: pios_usbhook.c:52
USB_STRING_DESC_PRODUCT
Definition: pios_usbhook.h:38
void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t *desc, uint16_t desc_size)
Definition: pios_usbhook.c:60
const uint8_t * descriptor
Definition: pios_usbhook.h:39
void PIOS_USBHOOK_RegisterDevice(const uint8_t *desc, uint16_t desc_size)
Definition: pios_usbhook.c:44
void PIOS_USBHOOK_Activate(void)
Definition: pios_usbhook.c:80
void PIOS_USBHOOK_EndpointTx(uint8_t epnum, const uint8_t *buf, uint16_t len)
Definition: pios_usbhook.c:207
void PIOS_USBHOOK_DeRegisterEpInCallback(uint8_t epnum)
Definition: pios_usbhook.c:146
void PIOS_USBHOOK_RegisterEpOutCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uintptr_t context)
Definition: pios_usbhook.c:156
void PIOS_USBHOOK_DeRegisterEpOutCallback(uint8_t epnum)
Definition: pios_usbhook.c:188
void PIOS_USBHOOK_RegisterIfOps(uint8_t ifnum, struct pios_usb_ifops *ifops, uintptr_t context)
Definition: pios_usbhook.c:113
bool(* setup)(uintptr_t context, struct usb_setup_request *req)
Definition: pios_usbhook.h:57