blob: 8b8562ce6d156aca8537df7312d1c9dccef75073 [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013, 2014 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
Damien Georgeb30c02a2014-03-14 00:30:37 +000027#define VCP_CHAR_NONE (0)
28#define VCP_CHAR_CTRL_A (1)
29#define VCP_CHAR_CTRL_B (2)
30#define VCP_CHAR_CTRL_C (3)
31#define VCP_CHAR_CTRL_D (4)
Damien George39966112014-04-03 23:30:24 +010032#define VCP_CHAR_CTRL_E (5)
Damien Georgeb30c02a2014-03-14 00:30:37 +000033
Damien George8913c042014-03-21 23:32:01 +000034typedef enum {
Damien George038df432014-03-30 00:00:15 +000035 USB_DEVICE_MODE_CDC_MSC,
36 USB_DEVICE_MODE_CDC_HID,
37} usb_device_mode_t;
Damien Georgeb30c02a2014-03-14 00:30:37 +000038
Damien George8913c042014-03-21 23:32:01 +000039typedef enum {
Damien George038df432014-03-30 00:00:15 +000040 USB_STORAGE_MEDIUM_FLASH,
41 USB_STORAGE_MEDIUM_SDCARD,
42} usb_storage_medium_t;
Damien George8913c042014-03-21 23:32:01 +000043
Damien George038df432014-03-30 00:00:15 +000044void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium);
Damien Georgeb30c02a2014-03-14 00:30:37 +000045bool usb_vcp_is_enabled(void);
46bool usb_vcp_is_connected(void);
47void usb_vcp_set_interrupt_char(int c);
Damien George07174c62014-03-15 12:53:51 +000048int usb_vcp_rx_num(void);
Damien Georgeb30c02a2014-03-14 00:30:37 +000049char usb_vcp_rx_get(void);
50void usb_vcp_send_str(const char* str);
51void usb_vcp_send_strn(const char* str, int len);
52void usb_vcp_send_strn_cooked(const char *str, int len);
53void usb_hid_send_report(uint8_t *buf); // 4 bytes for mouse: ?, x, y, ?
54
55void pyb_usb_host_init(void);
56void pyb_usb_host_process(void);
57uint pyb_usb_host_get_keyboard(void);