2019-12-02 05:58:26 +01:00
|
|
|
/// <reference path="../node_modules/pxt-core/localtypings/pxtarget.d.ts" />
|
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts" />
|
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxtcompiler.d.ts" />
|
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxtlib.d.ts" />
|
|
|
|
/// <reference path="../node_modules/pxt-core/built/pxteditor.d.ts" />
|
|
|
|
/// <reference path="dapjs.d.ts" />
|
2020-08-19 22:03:58 +02:00
|
|
|
import * as dialogs from "./dialogs";
|
|
|
|
import * as flash from "./flash";
|
|
|
|
import * as patch from "./patch";
|
2019-12-02 05:58:26 +01:00
|
|
|
|
|
|
|
pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
2021-11-25 17:27:39 +01:00
|
|
|
pxt.debug('loading calliope mini target extensions...')
|
2019-12-02 05:58:26 +01:00
|
|
|
|
|
|
|
const manyAny = Math as any;
|
|
|
|
if (!manyAny.imul)
|
|
|
|
manyAny.imul = function (a: number, b: number): number {
|
|
|
|
const ah = (a >>> 16) & 0xffff;
|
|
|
|
const al = a & 0xffff;
|
|
|
|
const bh = (b >>> 16) & 0xffff;
|
|
|
|
const bl = b & 0xffff;
|
|
|
|
// the shift by 0 fixes the sign on the high part
|
|
|
|
// the final |0 converts the unsigned value into a signed value
|
|
|
|
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0) | 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
const res: pxt.editor.ExtensionResult = {
|
2021-11-25 17:27:39 +01:00
|
|
|
hexFileImporters: []
|
2019-12-02 05:58:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
pxt.usb.setFilters([{
|
|
|
|
vendorId: 0x0D28,
|
2021-11-25 17:27:39 +01:00
|
|
|
productId: 0x0204,
|
|
|
|
classCode: 0xff,
|
|
|
|
subclassCode: 0x03 // the ctrl pipe endpoint
|
|
|
|
}, {
|
|
|
|
vendorId: 0x0D28,
|
|
|
|
productId: 0x0204,
|
|
|
|
classCode: 0xff,
|
|
|
|
subclassCode: 0x00 // the custom CMSIS2 endpoint
|
2019-12-02 05:58:26 +01:00
|
|
|
}])
|
|
|
|
|
2020-08-19 22:03:58 +02:00
|
|
|
res.mkPacketIOWrapper = flash.mkDAPLinkPacketIOWrapper;
|
|
|
|
res.blocklyPatch = patch.patchBlocks;
|
2019-12-02 05:58:26 +01:00
|
|
|
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
|
|
|
}
|