update credits
[librepilot.git] / flight / pios / inc / pios_usbhook.h
blob0bf154a246ae2f81c1012fef6e165771eb17b525
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_USBHOOK USB glue code
6 * @brief Glue between PiOS and STM32 libs
7 * @{
9 * @file pios_usbhook.h
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
11 * @brief APIs for PIOS_USBHOOK layer
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #ifndef PIOS_USBHOOK_H
32 #define PIOS_USBHOOK_H
34 #include <stdbool.h>
35 #include <stdint.h>
36 #include "pios_usb_defs.h" /* usb_setup_request */
38 struct pios_usbhook_descriptor {
39 const uint8_t *descriptor;
40 uint16_t length;
43 enum usb_string_desc {
44 USB_STRING_DESC_LANG = 0,
45 USB_STRING_DESC_VENDOR = 1,
46 USB_STRING_DESC_PRODUCT = 2,
47 USB_STRING_DESC_SERIAL = 3,
48 } __attribute__((packed));
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);
54 struct pios_usb_ifops {
55 void (*init)(uint32_t context);
56 void (*deinit)(uint32_t context);
57 bool (*setup)(uint32_t context, struct usb_setup_request *req);
58 void (*ctrl_data_out)(uint32_t context, const struct usb_setup_request *req);
61 extern void PIOS_USBHOOK_RegisterIfOps(uint8_t ifnum, struct pios_usb_ifops *ifops, uint32_t context);
63 typedef bool (*pios_usbhook_epcb)(uint32_t context, uint8_t epnum, uint16_t len);
65 extern void PIOS_USBHOOK_RegisterEpInCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uint32_t context);
66 extern void PIOS_USBHOOK_RegisterEpOutCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uint32_t context);
67 extern void PIOS_USBHOOK_DeRegisterEpInCallback(uint8_t epnum);
68 extern void PIOS_USBHOOK_DeRegisterEpOutCallback(uint8_t epnum);
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);
77 extern uint32_t PIOS_USBHOOK_EndpointGetStatus(uint8_t epnum);
80 #endif /* PIOS_USBHOOK_H */