Adding initial dfu-upload code and debugging for Bootloader.

This commit is contained in:
Jacob Alexander 2015-04-27 00:57:34 -07:00
parent 26b0a7e10d
commit 1acbc97e98
9 changed files with 125 additions and 96 deletions

View file

@ -53,11 +53,13 @@
#define TX_TIMEOUT_MSEC 50
#if F_CPU == 96000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#elif F_CPU == 72000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) // XXX Correct?
#elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)
#elif F_CPU == 24000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262)
#endif

View file

@ -1,7 +1,7 @@
/* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2013 PJRC.COM, LLC.
* Modified by Jacob Alexander 2013-2014
* Modified by Jacob Alexander 2013-2015
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -56,11 +56,13 @@
#define TX_TIMEOUT_MSEC 70
#if F_CPU == 96000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596)
#elif F_CPU == 72000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) // XXX Correct?
#elif F_CPU == 48000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428)
#elif F_CPU == 24000000
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262)
#define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262)
#endif

View file

@ -192,14 +192,14 @@ void uart_serial_setup()
#elif defined(_mk20dx256vlh7_) // UART2 Debug
// Setup baud rate - 115200 Baud
// Uses Bus Clock
// 24 MHz / ( 16 * Baud ) = BDH/L
// Baud: 115200 -> 24 MHz / ( 16 * 115200 ) = 13.021
// Thus baud setting = 13
// 36 MHz / ( 16 * Baud ) = BDH/L
// Baud: 115200 -> 36 MHz / ( 16 * 115200 ) = 19.53125
// Thus baud setting = 19
// NOTE: If finer baud adjustment is needed see UARTx_C4 -> BRFA in the datasheet
uint16_t baud = 13; // Max setting of 8191
uint16_t baud = 19; // Max setting of 8191
UART_BDH = (uint8_t)(baud >> 8);
UART_BDL = (uint8_t)baud;
UART_C4 = 0x01;
UART_C4 = 0x11;
#endif