IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
Source at commit c6e776e714b6cb8c7a5ea1f2767ee6bab682298e created 7 years 11 months ago. By Stefan Schmidt, atusb: fw: make the ifdefs in mac handling transceiver specific and not board specific | |
---|---|
1 | /* |
2 | * fw/sernum.c - ATUSB serial number |
3 | * |
4 | * Written 2008-2011, 2013 by Werner Almesberger |
5 | * Copyright 2008-2011, 2013 Werner Almesberger |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | */ |
12 | |
13 | |
14 | #include <stdbool.h> |
15 | #include <stdint.h> |
16 | |
17 | #include "usb.h" |
18 | |
19 | #include "board.h" |
20 | #include "sernum.h" |
21 | |
22 | |
23 | static const uint8_t string_descriptor_0[] = { |
24 | 4, /* blength */ |
25 | USB_DT_STRING, /* bDescriptorType */ |
26 | LE(USB_LANGID_ENGLISH_US) /* wLANGID[0] */ |
27 | }; |
28 | |
29 | |
30 | bool sernum_get_descr(uint8_t type, uint8_t index, const uint8_t **reply, |
31 | uint8_t *size) |
32 | { |
33 | if (type != USB_DT_STRING) |
34 | return 0; |
35 | switch (index) { |
36 | case 0: |
37 | *reply = string_descriptor_0; |
38 | *size = sizeof(string_descriptor_0); |
39 | return 1; |
40 | case 1: |
41 | *reply = board_sernum; |
42 | *size = sizeof(board_sernum); |
43 | return 1; |
44 | default: |
45 | return 0; |
46 | } |
47 | } |
48 |