mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 12:25:13 +03:00
initial (header) work on STM32DFU
This commit is contained in:
parent
b09620b6ae
commit
c4e1cf2600
3 changed files with 84 additions and 1 deletions
|
@ -51,7 +51,7 @@ var SENSOR_DATA = {
|
||||||
kinematicsX: 0.0,
|
kinematicsX: 0.0,
|
||||||
kinematicsY: 0.0,
|
kinematicsY: 0.0,
|
||||||
kinematicsZ: 0.0,
|
kinematicsZ: 0.0,
|
||||||
debug: [0, 0, 0, 0]
|
debug: [0, 0, 0, 0]
|
||||||
};
|
};
|
||||||
|
|
||||||
var MOTOR_DATA = new Array(8);
|
var MOTOR_DATA = new Array(8);
|
||||||
|
|
82
js/stm32dfu.js
Normal file
82
js/stm32dfu.js
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
USB DFU uses:
|
||||||
|
control transfers for communicating
|
||||||
|
recipient is interface
|
||||||
|
request type is class
|
||||||
|
*/
|
||||||
|
|
||||||
|
var STM32DFU_protocol = function() {
|
||||||
|
this.hex; // ref
|
||||||
|
this.verify_hex;
|
||||||
|
|
||||||
|
this.handle = null; // connection handle
|
||||||
|
|
||||||
|
this.command = {
|
||||||
|
DETACH: 0x00, // OUT, Requests the device to leave DFU mode and enter the application.
|
||||||
|
DNLOAD: 0x01, // OUT, Requests data transfer from Host to the device in order to load them into device internal Flash. Includes also erase commands
|
||||||
|
UPLOAD: 0x02, // IN, Requests data transfer from device to Host in order to load content of device internal Flash into a Host file.
|
||||||
|
GETSTATUS: 0x03, // IN, Requests device to send status report to the Host (including status resulting from the last request execution and the state the device will enter immediately after this request).
|
||||||
|
CLRSTATUS: 0x04, // OUT, Requests device to clear error status and move to next step
|
||||||
|
GETSTATE: 0x05, // IN, Requests the device to send only the state it will enter immediately after this request.
|
||||||
|
ABORT: 0x06 // OUT, Requests device to exit the current state/operation and enter idle state immediately.
|
||||||
|
};
|
||||||
|
|
||||||
|
this.status = {
|
||||||
|
OK: 0x00, // No error condition is present.
|
||||||
|
errTARGET: 0x01, // File is not targeted for use by this device.
|
||||||
|
errFILE: 0x02, // File is for this device but fails some vendor-specific verification test
|
||||||
|
errWRITE: 0x03, // Device is unable to write memory.
|
||||||
|
errERASE: 0x04, // Memory erase function failed.
|
||||||
|
errCHECK_ERASED: 0x05, // Memory erase check failed.
|
||||||
|
errPROG: 0x06, // Program memory function failed.
|
||||||
|
errVERIFY: 0x07, // Programmed memory failed verification.
|
||||||
|
errADDRESS: 0x08, // Cannot program memory due to received address that is out of range.
|
||||||
|
errNOTDONE: 0x09, // Received DFU_DNLOAD with wLength = 0, but device does not think it has all of the data yet.
|
||||||
|
errFIRMWARE: 0x0A, // Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations.
|
||||||
|
errVENDOR: 0x0B, // iString indicates a vendor-specific error.
|
||||||
|
errUSBR: 0x0C, // Device detected unexpected USB reset signaling.
|
||||||
|
errPOR: 0x0D, // Device detected unexpected power on reset.
|
||||||
|
errUNKNOWN: 0x0E, // Something went wrong, but the device does not know what it was.
|
||||||
|
errSTALLEDPKT: 0x0F // Device stalled an unexpected request.
|
||||||
|
};
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
appIDLE: 0, // Device is running its normal application.
|
||||||
|
appDETACH: 1, // Device is running its normal application, has received the DFU_DETACH request, and is waiting for a USB reset.
|
||||||
|
dfuIDLE: 2, // Device is operating in the DFU mode and is waiting for requests.
|
||||||
|
dfuDNLOAD_SYNC: 3, // Device has received a block and is waiting for the host to solicit the status via DFU_GETSTATUS.
|
||||||
|
dfuDNBUSY: 4, // Device is programming a control-write block into its nonvolatile memories.
|
||||||
|
dfuDNLOAD_IDLE: 5, // Device is processing a download operation. Expecting DFU_DNLOAD requests.
|
||||||
|
dfuMANIFEST_SYNC: 6, // Device has received the final block of firmware from the host and is waiting for receipt of DFU_GETSTATUS to begin the Manifestation phase; or device has completed the Manifestation phase and is waiting for receipt of DFU_GETSTATUS.
|
||||||
|
dfuMANIFEST: 7, // Device is in the Manifestation phase. (Not all devices will be able to respond to DFU_GETSTATUS when in this state.)
|
||||||
|
dfuMANIFEST_WAIT_RESET: 8, // Device has programmed its memories and is waiting for a USB reset or a power on reset. (Devices that must enter this state clear bitManifestationTolerant to 0.)
|
||||||
|
dfuUPLOAD_IDLE: 9, // The device is processing an upload operation. Expecting DFU_UPLOAD requests.
|
||||||
|
dfuERROR: 10 // An error has occurred. Awaiting the DFU_CLRSTATUS request.
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.openDevice = function(callback) {
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.closeDevice = function(callback) {
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.claimInterface = function(callback) {
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.releaseInterface = function(callback) {
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.resetDevice = function(callback) {
|
||||||
|
chrome.usb.resetDevice(this.handle, function(result) {
|
||||||
|
console.log('Reset Device: ' + result);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
STM32DFU_protocol.prototype.controlTransfer = function() {
|
||||||
|
};
|
||||||
|
|
||||||
|
// initialize object
|
||||||
|
var STM32DFU = new STM32DFU_protocol();
|
|
@ -32,6 +32,7 @@
|
||||||
<script type="text/javascript" src="./js/msp.js"></script>
|
<script type="text/javascript" src="./js/msp.js"></script>
|
||||||
<script type="text/javascript" src="./js/backup_restore.js"></script>
|
<script type="text/javascript" src="./js/backup_restore.js"></script>
|
||||||
<script type="text/javascript" src="./js/stm32.js"></script>
|
<script type="text/javascript" src="./js/stm32.js"></script>
|
||||||
|
<script type="text/javascript" src="./js/stm32dfu.js"></script>
|
||||||
<script type="text/javascript" src="./js/localization.js"></script>
|
<script type="text/javascript" src="./js/localization.js"></script>
|
||||||
<script type="text/javascript" src="./main.js"></script>
|
<script type="text/javascript" src="./main.js"></script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue