mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion] Reset: add a method Reset::coreWhilePlugged implemented
differently for N0100 & N0110
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
ion_device_src += $(addprefix ion/src/device/n0100/drivers/, \
|
||||
board.cpp \
|
||||
power.cpp \
|
||||
reset.cpp \
|
||||
)
|
||||
|
||||
ion_device_src += ion/src/device/n0100/usb/stack/device.cpp
|
||||
|
||||
LDSCRIPT ?= ion/src/device/n0100/flash.ld
|
||||
|
||||
18
ion/src/device/n0100/drivers/reset.cpp
Normal file
18
ion/src/device/n0100/drivers/reset.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <drivers/reset.h>
|
||||
#include "config/flash.h"
|
||||
|
||||
namespace Ion {
|
||||
namespace Device {
|
||||
namespace Reset {
|
||||
|
||||
void coreWhilePlugged() {
|
||||
/* We don't perform a core reset because at this point in time the USB cable
|
||||
* might be plugged in. Doing a full core reset would result in the device
|
||||
* entering the ST DFU bootloader. By performing a jump-reset, we mimic the
|
||||
* core reset without entering ST bootloader.*/
|
||||
jump(Flash::Config::StartAddress);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#include <usb/stack/device.h>
|
||||
#include <drivers/reset.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Device {
|
||||
namespace USB {
|
||||
|
||||
void Device::leave(uint32_t leaveAddress) {
|
||||
/* 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::Reset::jump(leaveAddress);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ ion_device_src += $(addprefix ion/src/device/n0110/drivers/, \
|
||||
board.cpp \
|
||||
cache.cpp \
|
||||
power.cpp \
|
||||
reset.cpp \
|
||||
)
|
||||
|
||||
ion_device_src += ion/src/device/n0110/usb/stack/device.cpp
|
||||
|
||||
LDSCRIPT ?= ion/src/device/n0110/flash.ld
|
||||
|
||||
13
ion/src/device/n0110/drivers/reset.cpp
Normal file
13
ion/src/device/n0110/drivers/reset.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <drivers/reset.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Device {
|
||||
namespace Reset {
|
||||
|
||||
void coreWhilePlugged() {
|
||||
core();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#include <usb/stack/device.h>
|
||||
#include <drivers/reset.h>
|
||||
#include <drivers/config/flash.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Device {
|
||||
namespace USB {
|
||||
|
||||
void Device::leave(uint32_t leaveAddress) {
|
||||
if (leaveAddress == Ion::Device::Flash::Config::StartAddress) {
|
||||
Ion::Device::Reset::core();
|
||||
} else {
|
||||
Ion::Device::Reset::jump(leaveAddress);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Device {
|
||||
namespace Reset {
|
||||
|
||||
void core();
|
||||
void coreWhilePlugged();
|
||||
|
||||
/* jump takes as parameter the address of the isr vector to jump to: the data at
|
||||
* jumpIsrVectorAddress must the stack_pointer address, and the data at
|
||||
|
||||
@@ -51,7 +51,7 @@ dfu_src += libaxx/src/cxxabi/pure_virtual.cpp
|
||||
dfu_src += ion/src/device/shared/usb/boot.cpp
|
||||
dfu_src += ion/src/device/$(MODEL)/drivers/board.cpp
|
||||
dfu_src += ion/src/device/$(MODEL)/drivers/cache.cpp
|
||||
dfu_src += ion/src/device/$(MODEL)/usb/stack/device.cpp
|
||||
dfu_src += ion/src/device/$(MODEL)/drivers/reset.cpp
|
||||
dfu_src += $(addprefix ion/src/device/shared/drivers/, \
|
||||
backlight.cpp \
|
||||
battery.cpp \
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "device.h"
|
||||
#include <drivers/config/flash.h>
|
||||
#include <drivers/reset.h>
|
||||
#include <regs/regs.h>
|
||||
|
||||
namespace Ion {
|
||||
@@ -89,6 +91,14 @@ void Device::detach() {
|
||||
OTG.DCTL()->setSDIS(true);
|
||||
}
|
||||
|
||||
void Device::leave(uint32_t leaveAddress) {
|
||||
if (leaveAddress == Ion::Device::Flash::Config::StartAddress) {
|
||||
Ion::Device::Reset::coreWhilePlugged();
|
||||
} else {
|
||||
Ion::Device::Reset::jump(leaveAddress);
|
||||
}
|
||||
}
|
||||
|
||||
bool Device::processSetupInRequest(SetupPacket * request, uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength) {
|
||||
// Device only handles standard requests.
|
||||
if (request->requestType() != SetupPacket::RequestType::Standard) {
|
||||
|
||||
Reference in New Issue
Block a user