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
680f399e
Commit
680f399e
authored
11 years ago
by
Micah Elizabeth Scott
Browse files
Options
Downloads
Patches
Plain Diff
Whitespace cleanup
parent
8cd986e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bootloader/bootloader.c
+43
-42
43 additions, 42 deletions
bootloader/bootloader.c
with
43 additions
and
42 deletions
bootloader/bootloader.c
+
43
−
42
View file @
680f399e
...
...
@@ -29,56 +29,56 @@
void
led_on
()
{
// Set the status LED on PC5, as an indication that we're in bootloading mode.
PORTC_PCR5
=
PORT_PCR_MUX
(
1
)
|
PORT_PCR_DSE
|
PORT_PCR_SRE
;
GPIOC_PDDR
=
1
<<
5
;
GPIOC_PDOR
=
1
<<
5
;
// Set the status LED on PC5, as an indication that we're in bootloading mode.
PORTC_PCR5
=
PORT_PCR_MUX
(
1
)
|
PORT_PCR_DSE
|
PORT_PCR_SRE
;
GPIOC_PDDR
=
1
<<
5
;
GPIOC_PDOR
=
1
<<
5
;
}
bool
test_banner_echo
()
{
/*
* At startup we print this banner out to the serial port.
* If we see it echo back to us, we enter bootloader mode no matter what.
* This is intended to be a foolproof way to enter recovery mode, even if other
* circuitry has been connected to the serial port.
*/
static
char
banner
[]
=
"FC-Boot"
;
const
unsigned
bannerLength
=
sizeof
banner
-
1
;
unsigned
matched
=
0
;
// Write banner
serial_begin
(
BAUD2DIV
(
9600
));
serial_write
(
banner
,
sizeof
banner
-
1
);
// Newline is not technically part of the banner, so we can do the RX check
// at a time when we're sure the other characters have arrived in the RX fifo.
serial_putchar
(
'\n'
);
serial_flush
();
while
(
matched
<
bannerLength
)
{
if
(
serial_available
()
&&
serial_getchar
()
==
banner
[
matched
])
{
matched
++
;
}
else
{
break
;
}
}
serial_end
();
return
matched
==
bannerLength
;
/*
* At startup we print this banner out to the serial port.
* If we see it echo back to us, we enter bootloader mode no matter what.
* This is intended to be a foolproof way to enter recovery mode, even if other
* circuitry has been connected to the serial port.
*/
static
char
banner
[]
=
"FC-Boot"
;
const
unsigned
bannerLength
=
sizeof
banner
-
1
;
unsigned
matched
=
0
;
// Write banner
serial_begin
(
BAUD2DIV
(
9600
));
serial_write
(
banner
,
sizeof
banner
-
1
);
// Newline is not technically part of the banner, so we can do the RX check
// at a time when we're sure the other characters have arrived in the RX fifo.
serial_putchar
(
'\n'
);
serial_flush
();
while
(
matched
<
bannerLength
)
{
if
(
serial_available
()
&&
serial_getchar
()
==
banner
[
matched
])
{
matched
++
;
}
else
{
break
;
}
}
serial_end
();
return
matched
==
bannerLength
;
}
uint32_t
debug
;
int
main
()
{
// Say hello!
// Say hello!
//
if (test_banner_echo()) {
led_on
();
//
}
//
if (test_banner_echo()) {
led_on
();
//
}
dfu_init
();
usb_init
();
...
...
@@ -87,10 +87,11 @@ int main()
serial_print
(
"Hello from DFU!
\r\n
"
);
while
(
1
)
{
serial_phex32
(
dfu_getstate
());
serial_putchar
(
' '
);
serial_phex32
(
debug
);
serial_print
(
"
\r\n
"
);
serial_phex32
(
dfu_getstate
());
serial_putchar
(
' '
);
serial_phex32
(
debug
);
serial_print
(
"
\r\n
"
);
watchdog_refresh
();
}
}
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