2010-11-02 01:02:21 +00:00
|
|
|
/*
|
2010-12-30 12:19:25 +00:00
|
|
|
* This file is part of the libopencm3 project.
|
2010-11-02 01:02:21 +00:00
|
|
|
*
|
2010-12-29 15:43:26 +00:00
|
|
|
* Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
|
2010-11-02 01:02:21 +00:00
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2010-12-29 15:43:26 +00:00
|
|
|
|
2010-11-02 01:02:21 +00:00
|
|
|
#ifndef __USBD_H
|
|
|
|
#define __USBD_H
|
|
|
|
|
2010-12-29 16:02:36 +00:00
|
|
|
#include <usb/usbstd.h>
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
/* Static buffer for control transactions:
|
|
|
|
* This is defined as weak in the library, applicaiton
|
|
|
|
* may provide if a larger buffer is requred. */
|
2010-12-29 16:28:06 +00:00
|
|
|
extern u8 usbd_control_buffer[];
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
/* <usb.c> */
|
|
|
|
extern int usbd_init(const struct usb_device_descriptor *dev,
|
|
|
|
const struct usb_config_descriptor *conf,
|
|
|
|
const char **strings);
|
2010-12-29 16:28:06 +00:00
|
|
|
extern void usbd_set_control_buffer_size(u16 size);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
extern void usbd_register_reset_callback(void (*callback)(void));
|
|
|
|
extern void usbd_register_suspend_callback(void (*callback)(void));
|
|
|
|
extern void usbd_register_resume_callback(void (*callback)(void));
|
|
|
|
|
2010-12-29 16:28:06 +00:00
|
|
|
typedef int (*usbd_control_callback)(struct usb_setup_data *req, u8 **buf,
|
|
|
|
u16 *len, void (**complete)(struct usb_setup_data *req));
|
2010-11-05 23:21:46 +00:00
|
|
|
|
2010-11-02 01:02:21 +00:00
|
|
|
/* <usb_control.c> */
|
2010-12-29 16:28:06 +00:00
|
|
|
extern int usbd_register_control_callback(u8 type, u8 type_mask,
|
2010-11-05 23:21:46 +00:00
|
|
|
usbd_control_callback callback);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
/* <usb_standard.c> */
|
2010-12-29 16:28:06 +00:00
|
|
|
extern void usbd_register_set_config_callback(void (*callback)(u16 wValue));
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
/* Functions to be provided by the hardware abstraction layer */
|
|
|
|
extern void usbd_poll(void);
|
|
|
|
|
2010-12-29 16:28:06 +00:00
|
|
|
extern void usbd_ep_setup(u8 addr, u8 type, u16 max_size,
|
|
|
|
void (*callback)(u8 ep));
|
2010-11-02 01:02:21 +00:00
|
|
|
|
2010-12-29 16:28:06 +00:00
|
|
|
extern u16 usbd_ep_write_packet(u8 addr, const void *buf, u16 len);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
2010-12-29 16:28:06 +00:00
|
|
|
extern u16 usbd_ep_read_packet(u8 addr, void *buf, u16 len);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
2010-12-29 16:28:06 +00:00
|
|
|
extern void usbd_ep_stall_set(u8 addr, u8 stall);
|
|
|
|
extern u8 usbd_ep_stall_get(u8 addr);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
/* Optional */
|
2010-12-29 16:28:06 +00:00
|
|
|
extern void usbd_cable_connect(u8 on);
|
2010-11-02 01:02:21 +00:00
|
|
|
|
|
|
|
#endif
|