update credits
[librepilot.git] / flight / targets / boards / nucleof303re / pios_usb_board_data.c
blob21f0be4d359dfb12f1354fb0e934948206c67b1c
1 /**
2 ******************************************************************************
3 * @addtogroup PIOS PIOS Core hardware abstraction layer
4 * @{
5 * @addtogroup PIOS_USB_BOARD Board specific USB definitions
6 * @brief Board specific USB definitions
7 * @{
9 * @file pios_usb_board_data.c
10 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
11 * @brief Board specific USB definitions
12 * @see The GNU Public License (GPL) Version 3
14 *****************************************************************************/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "inc/pios_usb_board_data.h" /* struct usb_*, USB_* */
32 #include <pios_sys.h> /* PIOS_SYS_SerialNumberGet */
33 #include <pios_usbhook.h> /* PIOS_USBHOOK_* */
34 #include <pios_usb_util.h> /* PIOS_USB_UTIL_AsciiToUtf8 */
36 static const uint8_t usb_product_id[28] = {
37 sizeof(usb_product_id),
38 USB_DESC_TYPE_STRING,
39 'N', 0,
40 'u', 0,
41 'c', 0,
42 'l', 0,
43 'e', 0,
44 'o', 0,
45 ' ', 0,
46 'F', 0,
47 '3', 0,
48 '0', 0,
49 '3', 0,
50 'R', 0,
51 'E', 0,
54 static uint8_t usb_serial_number[2 + PIOS_SYS_SERIAL_NUM_ASCII_LEN * 2 + (sizeof(PIOS_USB_BOARD_SN_SUFFIX) - 1) * 2] = {
55 sizeof(usb_serial_number),
56 USB_DESC_TYPE_STRING,
59 static const struct usb_string_langid usb_lang_id = {
60 .bLength = sizeof(usb_lang_id),
61 .bDescriptorType = USB_DESC_TYPE_STRING,
62 .bLangID = htousbs(USB_LANGID_ENGLISH_US),
65 static const uint8_t usb_vendor_id[28] = {
66 sizeof(usb_vendor_id),
67 USB_DESC_TYPE_STRING,
68 'o', 0,
69 'p', 0,
70 'e', 0,
71 'n', 0,
72 'p', 0,
73 'i', 0,
74 'l', 0,
75 'o', 0,
76 't', 0,
77 '.', 0,
78 'o', 0,
79 'r', 0,
80 'g', 0
83 int32_t PIOS_USB_BOARD_DATA_Init(void)
85 /* Load device serial number into serial number string */
86 uint8_t sn[PIOS_SYS_SERIAL_NUM_ASCII_LEN + 1];
88 PIOS_SYS_SerialNumberGet((char *)sn);
90 /* Concatenate the device serial number and the appropriate suffix ("+BL" or "+FW") into the USB serial number */
91 uint8_t *utf8 = &(usb_serial_number[2]);
92 utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, sn, PIOS_SYS_SERIAL_NUM_ASCII_LEN);
93 utf8 = PIOS_USB_UTIL_AsciiToUtf8(utf8, (uint8_t *)PIOS_USB_BOARD_SN_SUFFIX, sizeof(PIOS_USB_BOARD_SN_SUFFIX) - 1);
95 PIOS_USBHOOK_RegisterString(USB_STRING_DESC_PRODUCT, (uint8_t *)&usb_product_id, sizeof(usb_product_id));
96 PIOS_USBHOOK_RegisterString(USB_STRING_DESC_SERIAL, (uint8_t *)&usb_serial_number, sizeof(usb_serial_number));
98 PIOS_USBHOOK_RegisterString(USB_STRING_DESC_LANG, (uint8_t *)&usb_lang_id, sizeof(usb_lang_id));
99 PIOS_USBHOOK_RegisterString(USB_STRING_DESC_VENDOR, (uint8_t *)&usb_vendor_id, sizeof(usb_vendor_id));
101 return 0;