2012-01-03 05:28:53 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
* @addtogroup PIOS PIOS Core hardware abstraction layer
|
|
|
|
* @{
|
|
|
|
* @addtogroup PIOS_USBHOOK USB glue code
|
|
|
|
* @brief Glue between PiOS and STM32 libs
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file pios_usbhook.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief APIs for PIOS_USBHOOK layer
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2011-09-10 05:26:19 +02:00
|
|
|
#ifndef PIOS_USBHOOK_H
|
|
|
|
#define PIOS_USBHOOK_H
|
2010-09-27 09:28:45 +02:00
|
|
|
|
2012-02-07 08:12:55 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2013-05-18 14:17:26 +02:00
|
|
|
#include "pios_usb_defs.h" /* usb_setup_request */
|
2010-09-27 09:28:45 +02:00
|
|
|
|
2012-02-07 08:12:55 +01:00
|
|
|
struct pios_usbhook_descriptor {
|
2013-05-18 14:17:26 +02:00
|
|
|
const uint8_t *descriptor;
|
|
|
|
uint16_t length;
|
2012-02-07 08:12:55 +01:00
|
|
|
};
|
2011-09-08 03:39:56 +02:00
|
|
|
|
2012-01-14 20:17:06 +01:00
|
|
|
enum usb_string_desc {
|
2013-05-18 14:17:26 +02:00
|
|
|
USB_STRING_DESC_LANG = 0,
|
|
|
|
USB_STRING_DESC_VENDOR = 1,
|
|
|
|
USB_STRING_DESC_PRODUCT = 2,
|
|
|
|
USB_STRING_DESC_SERIAL = 3,
|
2012-01-14 20:17:06 +01:00
|
|
|
} __attribute__((packed));
|
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
extern void PIOS_USBHOOK_RegisterDevice(const uint8_t *desc, uint16_t desc_size);
|
|
|
|
extern void PIOS_USBHOOK_RegisterConfig(uint8_t config_id, const uint8_t *desc, uint16_t desc_size);
|
|
|
|
extern void PIOS_USBHOOK_RegisterString(enum usb_string_desc string_id, const uint8_t *desc, uint16_t desc_size);
|
2012-02-07 08:12:55 +01:00
|
|
|
|
|
|
|
struct pios_usb_ifops {
|
2013-05-18 14:17:26 +02:00
|
|
|
void (*init)(uint32_t context);
|
|
|
|
void (*deinit)(uint32_t context);
|
|
|
|
bool (*setup)(uint32_t context, struct usb_setup_request *req);
|
|
|
|
void (*ctrl_data_out)(uint32_t context, struct usb_setup_request *req);
|
2012-02-07 08:12:55 +01:00
|
|
|
};
|
|
|
|
|
2013-05-18 14:17:26 +02:00
|
|
|
extern void PIOS_USBHOOK_RegisterIfOps(uint8_t ifnum, struct pios_usb_ifops *ifops, uint32_t context);
|
2012-02-07 08:12:55 +01:00
|
|
|
|
|
|
|
typedef bool (*pios_usbhook_epcb)(uint32_t context, uint8_t epnum, uint16_t len);
|
|
|
|
|
|
|
|
extern void PIOS_USBHOOK_RegisterEpInCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uint32_t context);
|
|
|
|
extern void PIOS_USBHOOK_RegisterEpOutCallback(uint8_t epnum, uint16_t max_len, pios_usbhook_epcb cb, uint32_t context);
|
|
|
|
extern void PIOS_USBHOOK_DeRegisterEpInCallback(uint8_t epnum);
|
|
|
|
extern void PIOS_USBHOOK_DeRegisterEpOutCallback(uint8_t epnum);
|
|
|
|
|
|
|
|
extern void PIOS_USBHOOK_CtrlTx(const uint8_t *buf, uint16_t len);
|
|
|
|
extern void PIOS_USBHOOK_CtrlRx(uint8_t *buf, uint16_t len);
|
|
|
|
extern void PIOS_USBHOOK_EndpointTx(uint8_t epnum, const uint8_t *buf, uint16_t len);
|
|
|
|
extern void PIOS_USBHOOK_EndpointRx(uint8_t epnum, uint8_t *buf, uint16_t len);
|
|
|
|
extern void PIOS_USBHOOK_Activate(void);
|
2012-03-06 03:53:32 +01:00
|
|
|
extern void PIOS_USBHOOK_Deactivate(void);
|
2012-01-14 20:17:06 +01:00
|
|
|
|
2011-09-10 05:26:19 +02:00
|
|
|
#endif /* PIOS_USBHOOK_H */
|