adds spi and i2c pins

This commit is contained in:
darzu 2016-08-31 21:53:48 -07:00
parent 1f3a2ab6fe
commit 374d8c590d
3 changed files with 82 additions and 8 deletions

View File

@ -1,4 +1,5 @@
# don't check in until OSS request is approved # don't check in until OSS request is approved
sparkfun-* sparkfun-*
raspberrypi-* raspberrypi-*
arduino-* arduino-*
max6675.svg

View File

@ -148,6 +148,16 @@ namespace pxsim {
let idx = <number>location[1]; let idx = <number>location[1];
let pin = opts.cmpGPIOPins[idx]; let pin = opts.cmpGPIOPins[idx];
return {type: "dalboard", pin: pin}; return {type: "dalboard", pin: pin};
} else if (location === "MOSI" || location === "MISO" || location === "SCK") {
if (!this.opts.boardDef.spiPins)
console.debug("No SPI pin mappings found!");
let pin = (<any>this.opts.boardDef.spiPins)[location as string] as string;
return {type: "dalboard", pin: pin};
} else if (location === "SDA" || location === "SCL") {
if (!this.opts.boardDef.i2cPins)
console.debug("No I2C pin mappings found!");
let pin = (<any>this.opts.boardDef.i2cPins)[location as string] as string;
return {type: "dalboard", pin: pin};
} else { } else {
//TODO //TODO
U.assert(false); U.assert(false);
@ -206,7 +216,7 @@ namespace pxsim {
let l = this.allocateLocation(ends[idx], { let l = this.allocateLocation(ends[idx], {
nearestBBPin: locInst.rowCol, nearestBBPin: locInst.rowCol,
startColumn: opts.startColumn, startColumn: opts.startColumn,
cmpGPIOPins: opts.cmpGPIOPins cmpGPIOPins: opts.cmpGPIOPins,
}); });
return l; return l;
}); });
@ -260,6 +270,7 @@ namespace pxsim {
}); });
} else { } else {
// failed to find pin allocation from callsites // failed to find pin allocation from callsites
debugger;
console.debug("Failed to read pin(s) from callsite for: " + fnNm); console.debug("Failed to read pin(s) from callsite for: " + fnNm);
let pinsNeeded = fnPinAlloc.pinArgPositions.length; let pinsNeeded = fnPinAlloc.pinArgPositions.length;
partialCmps.push({ partialCmps.push({

View File

@ -28,6 +28,16 @@ namespace pxsim {
onboardComponents?: string[] onboardComponents?: string[]
useCrocClips?: boolean, useCrocClips?: boolean,
marginWhenBreadboarding?: [number, number, number, number], marginWhenBreadboarding?: [number, number, number, number],
spiPins?: {
MOSI: string,
MISO: string,
SCK: string,
},
i2cPins?: {
SDA: string,
SCL: string,
},
analogInPins?: string[], //TODO: implement allocation
} }
export interface FactoryFunctionPinAlloc { export interface FactoryFunctionPinAlloc {
type: "factoryfunction", type: "factoryfunction",
@ -65,8 +75,15 @@ namespace pxsim {
color: string, color: string,
assemblyStep: number assemblyStep: number
}; };
export type WireLocationDefinition = export type SPIPin = "MOSI" | "MISO" | "SCK";
["breadboard", string, number] | ["GPIO", number] | "ground" | "threeVolt"; export type I2CPin = "SDA" | "SCL";
export type WireLocationDefinition = (
["breadboard", string, number]
| ["GPIO", number]
| SPIPin
| I2CPin
| "ground"
| "threeVolt");
export const MICROBIT_DEF: BoardDefinition = { export const MICROBIT_DEF: BoardDefinition = {
visual: "microbit", visual: "microbit",
@ -75,8 +92,7 @@ namespace pxsim {
["P3"], ["P3"],
["P4", "P5", "P6", "P7"], ["P4", "P5", "P6", "P7"],
["P8", "P9", "P10", "P11", "P12"], ["P8", "P9", "P10", "P11", "P12"],
["P13", "P14", "P15", "P16"], ["P16"],
["P19", "P20"],
], ],
gpioPinMap: { gpioPinMap: {
"P0": "P0", "P0": "P0",
@ -99,6 +115,16 @@ namespace pxsim {
"P19": "P19", "P19": "P19",
"P20": "P20", "P20": "P20",
}, },
spiPins: {
MOSI: "P15",
MISO: "P14",
SCK: "P13",
},
i2cPins: {
SDA: "P20",
SCL: "P19",
},
analogInPins: ["P0", "P1", "P2", "P3", "P10"],
groundPins: ["GND"], groundPins: ["GND"],
threeVoltPins: ["+3v3"], threeVoltPins: ["+3v3"],
attachPowerOnRight: true, attachPowerOnRight: true,
@ -229,6 +255,18 @@ namespace pxsim {
"P19": "~11", "P19": "~11",
"P20": "~12", "P20": "~12",
}, },
//TODO: add SPI pins to Arduino board
// spiPins: {
// ChipSelect: "P16",
// MOSI: "P15",
// MISO: "P14",
// SCK: "P13",
// },
// i2cPins: {
// SDA: "P20",
// SCL: "P19",
// },
analogInPins: ["A0", "A1", "A2", "A3", "A4", "A5"],
groundPins: ["GND0", "GND1", "GND2"], groundPins: ["GND0", "GND1", "GND2"],
threeVoltPins: ["3.3V"], threeVoltPins: ["3.3V"],
marginWhenBreadboarding: [20, 0, 40, 0], marginWhenBreadboarding: [20, 0, 40, 0],
@ -311,6 +349,31 @@ namespace pxsim {
{start: ["breadboard", "j", 3], end: "ground", color: "blue", assemblyStep: 1}, {start: ["breadboard", "j", 3], end: "ground", color: "blue", assemblyStep: 1},
], ],
}, },
"max6675": {
visual: {
image: "/static/hardware/max6675.svg",
width: 58,
height: 64,
firstPin: [11, 5],
pinDist: 7.2,
extraColumnOffset: 2,
},
breadboardColumnsNeeded: 10,
breadboardStartRow: "h",
pinAllocation: {
type: "factoryfunction",
functionName: "max6675.temperature",
pinArgPositions: [0]
},
assemblyStep: 0,
wires: [
{start: ["breadboard", "j", 2], end: "SCK", color: "green", assemblyStep: 1},
{start: ["breadboard", "j", 3], end: ["GPIO", 0], color: "blue", assemblyStep: 1},
{start: ["breadboard", "j", 4], end: "MISO", color: "orange", assemblyStep: 1},
{start: ["breadboard", "j", 5], end: "ground", color: "blue", assemblyStep: 0},
{start: ["breadboard", "j", 6], end: "threeVolt", color: "red", assemblyStep: 1},
],
},
} }
export const builtinComponentSimVisual: Map<() => visuals.IBoardComponent<any>> = { export const builtinComponentSimVisual: Map<() => visuals.IBoardComponent<any>> = {
@ -337,6 +400,5 @@ namespace pxsim {
}; };
//TODO: add multiple board support //TODO: add multiple board support
//export const CURRENT_BOARD = MICROBIT_DEF; export const CURRENT_BOARD = MICROBIT_DEF;
export const CURRENT_BOARD = ARDUINO_ZERO;
} }