pico-ice
RaspberryPi Pico with an iCE40 FPGA
Loading...
Searching...
No Matches
ice_usb.h
1/*
2 * MIT License
3 *
4 * Copyright (c) 2023 tinyVision.ai
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 all
14 * 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 THE
22 * SOFTWARE.
23 */
24
149#pragma once
150#include "tusb.h"
151#include "tusb_config.h"
152#include "pico/unique_id.h"
153
154// Predefined macros to avoid repetitive
155#define USB_VID 0x1209 // https://pid.codes/1209/
156#define USB_PID 0xB1C0 // https://pid.codes/1209/B1C0/
157#define USB_MANUFACTURER "tinyVision.ai Inc."
158#define USB_PRODUCT "pico-ice"
159#define USB_LANG_EN (const char[]){ 0x09, 0x04 }
160#define USB_VENDOR "tinyVision.ai"
161#define EPOUT 0x00
162#define EPIN 0x80
163
164#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN \
165 + CFG_TUD_CDC * TUD_CDC_DESC_LEN \
166 + CFG_TUD_MSC * TUD_MSC_DESC_LEN \
167 + CFG_TUD_HID * TUD_HID_DESC_LEN \
168 + CFG_TUD_MIDI * TUD_MIDI_DESC_LEN \
169 + CFG_TUD_VENDOR * TUD_VENDOR_DESC_LEN \
170 + CFG_TUD_DFU * TUD_DFU_DESC_LEN(CFG_TUD_DFU_ALT))
171
172// Generated at random for the pico-ice as advised by https://github.com/microsoft/uf2/
173#define ICE_UF2_FAMILY_ID 0x792e7263
174
175// Simplify the declaration of string IDs
176enum {
177 STRID_LANGID,
178 STRID_MANUFACTURER,
179 STRID_PRODUCT,
180 STRID_SERIAL_NUMBER,
181 STRID_VENDOR,
182 STRID_CDC = 10,
183 STRID_MSC = 20,
184 STRID_DFU = 30,
185 STRID_NUM_TOTAL = 40
186};
187
188#ifdef __cplusplus
189extern "C" {
190#endif
191
192extern char const *tud_string_desc[STRID_NUM_TOTAL];
193extern char usb_serial_number[PICO_UNIQUE_BOARD_ID_SIZE_BYTES * 2 + 1];
194extern uint8_t const tud_desc_configuration[CONFIG_TOTAL_LEN];
195extern const tusb_desc_device_t tud_desc_device;
196extern void (*tud_cdc_rx_cb_table[CFG_TUD_CDC])(uint8_t);
197
198void ice_usb_init(void);
199void ice_usb_sleep_ms(uint32_t ms);
200
201#ifdef __cplusplus
202}
203#endif
204