Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fadecandy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scanlime
Fadecandy
Commits
3bbb3bd3
Commit
3bbb3bd3
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Use the entire 128-bit CPU serial number
parent
aa7839e7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
firmware/Makefile
+0
-1
0 additions, 1 deletion
firmware/Makefile
firmware/nonstd.c
+0
-74
0 additions, 74 deletions
firmware/nonstd.c
firmware/usb_desc.c
+21
-20
21 additions, 20 deletions
firmware/usb_desc.c
with
21 additions
and
95 deletions
firmware/Makefile
+
0
−
1
View file @
3bbb3bd3
...
@@ -22,7 +22,6 @@ OPTIONS = -DF_CPU=48000000
...
@@ -22,7 +22,6 @@ OPTIONS = -DF_CPU=48000000
# Sources
# Sources
C_FILES
=
\
C_FILES
=
\
mk20dx128.c
\
mk20dx128.c
\
nonstd.c
\
pins_teensy.c
\
pins_teensy.c
\
usb_desc.c
\
usb_desc.c
\
usb_dev.c
\
usb_dev.c
\
...
...
This diff is collapsed.
Click to expand it.
firmware/nonstd.c
deleted
100644 → 0
+
0
−
74
View file @
aa7839e7
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include
<string.h>
#include
<stdio.h>
size_t
strlen
(
const
char
*
s
)
{
size_t
n
=
0
;
while
(
*
s
++
)
n
++
;
return
n
;
}
char
*
ultoa
(
unsigned
long
val
,
char
*
buf
,
int
radix
)
{
unsigned
digit
;
int
i
=
0
,
j
;
char
t
;
while
(
1
)
{
digit
=
val
%
radix
;
buf
[
i
]
=
((
digit
<
10
)
?
'0'
+
digit
:
'A'
+
digit
-
10
);
val
/=
radix
;
if
(
val
==
0
)
break
;
i
++
;
}
buf
[
i
+
1
]
=
0
;
for
(
j
=
0
;
j
<
i
;
j
++
,
i
--
)
{
t
=
buf
[
j
];
buf
[
j
]
=
buf
[
i
];
buf
[
i
]
=
t
;
}
return
buf
;
}
char
*
ltoa
(
long
val
,
char
*
buf
,
int
radix
)
{
if
(
val
>=
0
)
{
return
ultoa
(
val
,
buf
,
radix
);
}
else
{
buf
[
0
]
=
'-'
;
ultoa
(
-
val
,
buf
+
1
,
radix
);
return
buf
;
}
}
This diff is collapsed.
Click to expand it.
firmware/usb_desc.c
+
21
−
20
View file @
3bbb3bd3
...
@@ -174,32 +174,33 @@ struct usb_string_descriptor_struct usb_string_product_name_default = {
...
@@ -174,32 +174,33 @@ struct usb_string_descriptor_struct usb_string_product_name_default = {
3
,
3
,
PRODUCT_NAME
PRODUCT_NAME
};
};
// 32-digit hex string, corresponding to the MK20DX128's built-in unique 128-bit ID.
struct
usb_string_descriptor_struct
usb_string_serial_number_default
=
{
struct
usb_string_descriptor_struct
usb_string_serial_number_default
=
{
1
2
,
2
+
32
*
2
,
3
,
3
,
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
};
};
static
void
toHexWide
(
uint32_t
value
,
uint16_t
*
buffer
)
{
static
const
uint8_t
digits
[]
=
"0123456789ABCDEF"
;
unsigned
i
;
for
(
i
=
0
;
i
<
8
;
i
++
)
{
buffer
[
i
]
=
digits
[
value
>>
28
];
value
<<=
4
;
}
}
void
usb_init_serialnumber
(
void
)
void
usb_init_serialnumber
(
void
)
{
{
char
buf
[
11
];
toHexWide
(
SIM_UIDH
,
usb_string_serial_number_default
.
wString
+
8
*
0
);
uint32_t
i
,
num
;
toHexWide
(
SIM_UIDMH
,
usb_string_serial_number_default
.
wString
+
8
*
1
);
toHexWide
(
SIM_UIDML
,
usb_string_serial_number_default
.
wString
+
8
*
2
);
__disable_irq
();
toHexWide
(
SIM_UIDL
,
usb_string_serial_number_default
.
wString
+
8
*
3
);
FTFL_FSTAT
=
FTFL_FSTAT_RDCOLERR
|
FTFL_FSTAT_ACCERR
|
FTFL_FSTAT_FPVIOL
;
FTFL_FCCOB0
=
0x41
;
FTFL_FCCOB1
=
15
;
FTFL_FSTAT
=
FTFL_FSTAT_CCIF
;
while
(
!
(
FTFL_FSTAT
&
FTFL_FSTAT_CCIF
))
;
// wait
num
=
*
(
uint32_t
*
)
&
FTFL_FCCOB7
;
__enable_irq
();
ultoa
(
num
,
buf
,
10
);
for
(
i
=
0
;
i
<
10
;
i
++
)
{
char
c
=
buf
[
i
];
if
(
!
c
)
break
;
usb_string_serial_number_default
.
wString
[
i
]
=
c
;
}
usb_string_serial_number_default
.
bLength
=
i
*
2
+
2
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment