|
| 1 | +/* |
| 2 | + * The MIT License (MIT) |
| 3 | + * |
| 4 | + * Copyright (c) 2019 Ha Thach for Adafruit Industries |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +#ifndef ADAFRUIT_TINYUSB_API_H_ |
| 26 | +#define ADAFRUIT_TINYUSB_API_H_ |
| 27 | + |
| 28 | +#include <stdint.h> |
| 29 | +#include <stdbool.h> |
| 30 | + |
| 31 | +//--------------------------------------------------------------------+ |
| 32 | +// Core API |
| 33 | +// Should be called by BSP Core to initialize, process task |
| 34 | +// Weak function allow compile arduino core before linking with this library |
| 35 | +//--------------------------------------------------------------------+ |
| 36 | +#ifdef __cplusplus |
| 37 | + extern "C" { |
| 38 | +#endif |
| 39 | + |
| 40 | +// Called by core/sketch to initialize usb device hardware and stack |
| 41 | +// This also initialize Serial as CDC device |
| 42 | +void TinyUSB_Device_Init(uint8_t rhport) __attribute__((weak)); |
| 43 | + |
| 44 | +// Called by core/sketch to handle device event |
| 45 | +void TinyUSB_Device_Task(void) __attribute__((weak)); |
| 46 | + |
| 47 | +// Called by core/sketch to flush write on CDC |
| 48 | +void TinyUSB_Device_FlushCDC(void) __attribute__((weak)); |
| 49 | + |
| 50 | +#ifdef __cplusplus |
| 51 | + } |
| 52 | +#endif |
| 53 | + |
| 54 | +//--------------------------------------------------------------------+ |
| 55 | +// Port API |
| 56 | +// Must be implemented by each BSP core/platform |
| 57 | +//--------------------------------------------------------------------+ |
| 58 | + |
| 59 | +// To enter/reboot to bootloader |
| 60 | +// usually when host disconnects cdc at baud 1200 (touch 1200) |
| 61 | +void TinyUSB_Port_EnterDFU(void); |
| 62 | + |
| 63 | +// Init device hardware. |
| 64 | +// Called by TinyUSB_Device_Init() |
| 65 | +void TinyUSB_Port_InitDevice(uint8_t rhport); |
| 66 | + |
| 67 | +// Get unique serial number, needed for Serial String Descriptor |
| 68 | +// Fill serial_id (raw bytes) and return its length (limit to 16 bytes) |
| 69 | +// Note: Serial descriptor can be overwritten by user API |
| 70 | +uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]); |
| 71 | + |
| 72 | +#endif |
0 commit comments