Damien George | 04b9147 | 2014-05-03 23:27:38 +0100 | [diff] [blame^] | 1 | /* |
| 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 George | b30c02a | 2014-03-14 00:30:37 +0000 | [diff] [blame] | 27 | #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 George | 3996611 | 2014-04-03 23:30:24 +0100 | [diff] [blame] | 32 | #define VCP_CHAR_CTRL_E (5) |
Damien George | b30c02a | 2014-03-14 00:30:37 +0000 | [diff] [blame] | 33 | |
Damien George | 8913c04 | 2014-03-21 23:32:01 +0000 | [diff] [blame] | 34 | typedef enum { |
Damien George | 038df43 | 2014-03-30 00:00:15 +0000 | [diff] [blame] | 35 | USB_DEVICE_MODE_CDC_MSC, |
| 36 | USB_DEVICE_MODE_CDC_HID, |
| 37 | } usb_device_mode_t; |
Damien George | b30c02a | 2014-03-14 00:30:37 +0000 | [diff] [blame] | 38 | |
Damien George | 8913c04 | 2014-03-21 23:32:01 +0000 | [diff] [blame] | 39 | typedef enum { |
Damien George | 038df43 | 2014-03-30 00:00:15 +0000 | [diff] [blame] | 40 | USB_STORAGE_MEDIUM_FLASH, |
| 41 | USB_STORAGE_MEDIUM_SDCARD, |
| 42 | } usb_storage_medium_t; |
Damien George | 8913c04 | 2014-03-21 23:32:01 +0000 | [diff] [blame] | 43 | |
Damien George | 038df43 | 2014-03-30 00:00:15 +0000 | [diff] [blame] | 44 | void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium); |
Damien George | b30c02a | 2014-03-14 00:30:37 +0000 | [diff] [blame] | 45 | bool usb_vcp_is_enabled(void); |
| 46 | bool usb_vcp_is_connected(void); |
| 47 | void usb_vcp_set_interrupt_char(int c); |
Damien George | 07174c6 | 2014-03-15 12:53:51 +0000 | [diff] [blame] | 48 | int usb_vcp_rx_num(void); |
Damien George | b30c02a | 2014-03-14 00:30:37 +0000 | [diff] [blame] | 49 | char usb_vcp_rx_get(void); |
| 50 | void usb_vcp_send_str(const char* str); |
| 51 | void usb_vcp_send_strn(const char* str, int len); |
| 52 | void usb_vcp_send_strn_cooked(const char *str, int len); |
| 53 | void usb_hid_send_report(uint8_t *buf); // 4 bytes for mouse: ?, x, y, ? |
| 54 | |
| 55 | void pyb_usb_host_init(void); |
| 56 | void pyb_usb_host_process(void); |
| 57 | uint pyb_usb_host_get_keyboard(void); |