105 lines
2.4 KiB
JavaScript
105 lines
2.4 KiB
JavaScript
|
|
let common = system.getScript("/common");
|
||
|
|
let pinmux = system.getScript("/drivers/pinmux/pinmux");
|
||
|
|
|
||
|
|
function getInterfaceName(inst, peripheralName)
|
||
|
|
{
|
||
|
|
return `PRU_${inst.instance}_${peripheralName}`;
|
||
|
|
}
|
||
|
|
|
||
|
|
function getInterfacePinList(inst, peripheralName)
|
||
|
|
{
|
||
|
|
let interfaceName = getInterfaceName(inst, peripheralName);
|
||
|
|
let pinList = [];
|
||
|
|
|
||
|
|
pinList = pinmux.getInterfacePinList(interfaceName);
|
||
|
|
|
||
|
|
return pinList;
|
||
|
|
}
|
||
|
|
|
||
|
|
function getPeripheralRequirements(inst, peripheralName)
|
||
|
|
{
|
||
|
|
let interfaceName = getInterfaceName(inst, peripheralName);
|
||
|
|
let pinList = getInterfacePinList(inst, peripheralName);
|
||
|
|
let resources = [];
|
||
|
|
|
||
|
|
for(let pin of pinList)
|
||
|
|
{
|
||
|
|
let pinResource = pinmux.getPinRequirements(interfaceName, pin);
|
||
|
|
|
||
|
|
/* make all pins as "rx" and then override to make "rx" as false as needed */
|
||
|
|
pinmux.setConfigurableDefault( pinResource, "rx", false );
|
||
|
|
|
||
|
|
/* Disable all the pins. */
|
||
|
|
pinResource.used=false;
|
||
|
|
|
||
|
|
resources.push( pinResource );
|
||
|
|
}
|
||
|
|
|
||
|
|
let peripheralRequirements = {
|
||
|
|
name: interfaceName,
|
||
|
|
displayName: interfaceName,
|
||
|
|
interfaceName: interfaceName,
|
||
|
|
resources: resources,
|
||
|
|
};
|
||
|
|
|
||
|
|
return peripheralRequirements;
|
||
|
|
}
|
||
|
|
|
||
|
|
function pinmuxRequirements(inst) {
|
||
|
|
|
||
|
|
let pwm = getPeripheralRequirements(inst, "PWM");
|
||
|
|
return [pwm];
|
||
|
|
}
|
||
|
|
|
||
|
|
function getInterfaceNameList(inst) {
|
||
|
|
|
||
|
|
return [
|
||
|
|
getInterfaceName(inst, "PWM"),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
function getPeripheralPinNames(inst)
|
||
|
|
{
|
||
|
|
let pinList = [];
|
||
|
|
|
||
|
|
pinList = pinList.concat(getInterfacePinList(inst, "PWM"));
|
||
|
|
return pinList;
|
||
|
|
}
|
||
|
|
|
||
|
|
let pruicss_top_module_name = "/pru_icssg/pwm";
|
||
|
|
|
||
|
|
let pruicss_top_module = {
|
||
|
|
displayName: "PRU (ICSS) PWM",
|
||
|
|
|
||
|
|
templates: {
|
||
|
|
"/drivers/pinmux/pinmux_config.c.xdt": {
|
||
|
|
moduleName: pruicss_top_module_name,
|
||
|
|
},
|
||
|
|
},
|
||
|
|
|
||
|
|
defaultInstanceName: "CONFIG_PRU_ICSS_PWM",
|
||
|
|
config: [
|
||
|
|
{
|
||
|
|
name: "instance",
|
||
|
|
displayName: "Instance",
|
||
|
|
default: "ICSSG0",
|
||
|
|
options: [
|
||
|
|
{
|
||
|
|
name: "ICSSG0",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "ICSSG1",
|
||
|
|
}
|
||
|
|
],
|
||
|
|
},
|
||
|
|
],
|
||
|
|
pinmuxRequirements,
|
||
|
|
getInterfaceNameList,
|
||
|
|
getPeripheralPinNames,
|
||
|
|
};
|
||
|
|
|
||
|
|
function validate(inst, report) {
|
||
|
|
common.validate.checkSameInstanceName(inst, report);
|
||
|
|
}
|
||
|
|
|
||
|
|
exports = pruicss_top_module;
|