mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 17:50:04 +01:00
[ion] USB::Device::Calculator::PollAndReset
Change-Id: Ib847b5f8a0fd559f98c1c130c0b0daffaf4c6468
This commit is contained in:
@@ -28,7 +28,7 @@ MEMORY {
|
||||
SECTIONS {
|
||||
.text : {
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.text._ZN3Ion3USB6Device10Calculator4PollEv))
|
||||
KEEP(*(.text._ZN3Ion3USB6Device10Calculator12PollAndResetEv))
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
} >RAM_BUFFER
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Ion {
|
||||
namespace USB {
|
||||
namespace Device {
|
||||
|
||||
void Calculator::Poll() {
|
||||
bool Calculator::PollAndReset() {
|
||||
Calculator c;
|
||||
|
||||
/* Leave DFU mode if the Back key is pressed, the calculator unplugged or the
|
||||
@@ -24,6 +24,8 @@ void Calculator::Poll() {
|
||||
if (!c.isSoftDisconnected()) {
|
||||
c.detach();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Descriptor * Calculator::descriptor(uint8_t type, uint8_t index) {
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Device {
|
||||
|
||||
class Calculator : public Device {
|
||||
public:
|
||||
static void Poll();
|
||||
static bool PollAndReset(); // Return true if reset is needed
|
||||
Calculator() :
|
||||
Device(&m_dfuInterface),
|
||||
m_deviceDescriptor(
|
||||
|
||||
@@ -10,7 +10,7 @@ extern char _dfu_bootloader_flash_end;
|
||||
namespace Ion {
|
||||
namespace USB {
|
||||
|
||||
typedef void (*FunctionPointer)();
|
||||
typedef bool (*PollFunctionPointer)(void);
|
||||
|
||||
void DFU() {
|
||||
|
||||
@@ -51,7 +51,7 @@ void DFU() {
|
||||
/* 4- Jump to DFU bootloader code. We made sure in the linker script that the
|
||||
* first function we want to call is at the beginning of the DFU code. */
|
||||
|
||||
FunctionPointer dfu_bootloader_entry = reinterpret_cast<FunctionPointer>(dfu_bootloader_ram_start);
|
||||
PollFunctionPointer dfu_bootloader_entry = reinterpret_cast<PollFunctionPointer>(dfu_bootloader_ram_start);
|
||||
|
||||
/* To have the right debug symbols for the reallocated code, break here and:
|
||||
* - Get the address of the new .text section
|
||||
@@ -62,7 +62,14 @@ void DFU() {
|
||||
* add-symbol-file ion/src/device/usb/dfu.elf 0x20038000
|
||||
*/
|
||||
|
||||
dfu_bootloader_entry();
|
||||
if (dfu_bootloader_entry()) {
|
||||
/* We don't perform a core reset because at this point in time the USB cable
|
||||
* is most likely plugged in. Doing a full core reset would be the clean
|
||||
* thing to do but would therefore result in the device entering the ROMed
|
||||
* DFU bootloader, which we want to avoid. By performing a jump-reset, we
|
||||
* will enter the newly flashed firmware. */
|
||||
Ion::Device::jumpReset();
|
||||
}
|
||||
|
||||
/* 5- That's all. The DFU bootloader on the stack is now dead code that will
|
||||
* be overwritten when the stack grows. */
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
#include "usb/calculator.h"
|
||||
#include <ion.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace USB {
|
||||
|
||||
void DFU() {
|
||||
Ion::USB::Device::Calculator::Poll();
|
||||
if (Ion::USB::Device::Calculator::PollAndReset()) {
|
||||
Ion::Device::jumpReset();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user