diff --git a/source/.meta/current_sense/sdfm.syscfg.js b/source/.meta/current_sense/sdfm.syscfg.js new file mode 100644 index 0000000..81eece1 --- /dev/null +++ b/source/.meta/current_sense/sdfm.syscfg.js @@ -0,0 +1,132 @@ +let common = system.getScript("/common"); +let sdfm_pins = system.getScript("/current_sense/sdfm_pins.js"); +let device = common.getDeviceName(); +let is_am243x_lp_device = (device === "am243x-lp") ? true : false; + +let sdfm_module_name = "/current_sense/sdfm"; + +/*function onValidate(inst, validation) { + for (let instance_index in inst.$module.$instances) + { + let instance = inst.$module.$instances[instance_index]; + //if ((!instance.channel_0)&&(!instance.channel_1)&&(!instance.channel_2)&&(!instance.channel_3)&&(!instance.channel_4)&&(!instance.channel_5)&&(!instance.channel_6)&&(!instance.channel_7)&&(!instance.channel_8)) + // validation.logError("Select atleast one channel",inst,"channel_0" + //) + } +}*/ + +let sdfm_module = { + displayName: "SDFM", + templates: { + "/drivers/system/system_config.h.xdt": { + driver_config:"/.meta/current_sense/templates/sdfm_template.h.xdt", + moduleName: sdfm_module_name, + }, + "/drivers/pinmux/pinmux_config.c.xdt": { + moduleName: sdfm_module_name, + }, + }, + defaultInstanceName: "CONFIG_SDFM", + config: [ + { + name: "instance", + displayName: "Instance", + default: "ICSSG0", + options: [ + { + name: "ICSSG0", + }, + { + name: "ICSSG1", + } + ], + }, + { + name: "Channel_0", + displayName: "Enable Channel 0", + description: "Channel 0 Selection", + default: true, + }, + { + name: "Channel_1", + displayName: "Enable Channel 1", + description: "Channel 1 Selection ", + default: true, + }, + { + name: "Channel_2", + displayName: "Enable Channel 2", + description: "Channel 2 Selection ", + default: true, + }, + + { + name: "Channel_3", + displayName: "Enable Channel 3", + description: "Channel 3 Selection", + default: false, + }, + { + name: "Channel_4", + displayName: "Enable Channel 4", + description: "Channel 4 Selection ", + default: false, + }, + { + name: "Channel_5", + displayName: "Enable Channel 5", + description: "Channel 5 Selection ", + default: false, + }, + { + name: "Channel_6", + displayName: "Enable Channel 6", + description: "Channel 6 Selection", + default: false, + }, + { + name: "Channel_7", + displayName: "Enable Channel 7", + description: "Channel 7 Selection ", + default: false, + }, + { + name: "Channel_8", + displayName: "Enable Channel 8", + description: "Channel 8 Selection ", + default: false, + }, + + ], + moduleStatic: { + modules: function(inst) { + return [{ + name: "system_common", + moduleName: "/system_common", + }] + }, + }, + pinmuxRequirements: sdfm_pins.pinmuxRequirements, + getInterfaceName: sdfm_pins.getInterfaceName, + getPeripheralPinNames: sdfm_pins.getPeripheralPinNames, + sharedModuleInstances: sharedModuleInstances, + /*validate: onValidate,*/ + +}; + +function sharedModuleInstances(instance) { + let modInstances = new Array(); + + modInstances.push({ + name: "pru", + displayName: "PRU ICSS Configuration", + moduleName: '/drivers/pruicss/pruicss', + requiredArgs: { + instance: instance.instance, + + }, + }); + return (modInstances); +} + +exports = sdfm_module; \ No newline at end of file diff --git a/source/.meta/current_sense/sdfm_pins.js b/source/.meta/current_sense/sdfm_pins.js new file mode 100644 index 0000000..395a88d --- /dev/null +++ b/source/.meta/current_sense/sdfm_pins.js @@ -0,0 +1,175 @@ +let common = system.getScript("/common"); +let pinmux = system.getScript("/drivers/pinmux/pinmux"); + + +function getInterfaceName(inst) +{ + return `PRU_${inst.instance}_PRU`; +} + +function getInterfacePinList(inst) +{ + let pinList = []; + + /*SDFM SD8_CLK clock*/ + pinList.push({ pinName: "GPI16", displayName: "SD_CLK8", rx: true}); + + /*SD0_D*/ + pinList.push({ pinName: "GPI1", displayName: "SD_CHANNEL0_DATA", rx: true}); + + /*SD1_D*/ + pinList.push({ pinName: "GPI3", displayName: "SD_CHANNEL1_DATA", rx: true}); + + /*SD2_D*/ + pinList.push({ pinName: "GPI5", displayName: "SD_CHANNEL2_DATA", rx: true}); + + /*SD3_D*/ + pinList.push({ pinName: "GPI7", displayName: "SD_CHANNEL3_DATA", rx: true}); + + /*SD4_D*/ + pinList.push({ pinName: "GPI18", displayName: "SD_CHANNEL4_DATA", rx: true}); + + /*SD5_D*/ + pinList.push({ pinName: "GPI11", displayName: "SD_CHANNEL5_DATA", rx: true}); + + /*SD6_D*/ + pinList.push({ pinName: "GPI13", displayName: "SD_CHANNEL6_DATA", rx: true}); + + /*SD7_D*/ + pinList.push({ pinName: "GPI15", displayName: "SD_CHANNEL7_DATA", rx: true}); + + /*SD8_D*/ + pinList.push({ pinName: "GPI17", displayName: "SD_CHANNEL8_DATA", rx: true}); + + return pinList; +} + +function pinmuxRequirements(inst) { + + let interfaceName = getInterfaceName(inst); + let pinList = getInterfacePinList(inst); + let resources = []; + + for(let pin of pinList) + { + let pinResource = pinmux.getPinRequirements(interfaceName, pin.pinName, pin.displayName); + + pinmux.setConfigurableDefault( pinResource, "rx", pin.rx ); + + if(inst["Channel_0"] == true){ + if((pin.pinName == "GPI1")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI1")){ + pinResource.used = false; + } + } + if(inst["Channel_1"] == true){ + if((pin.pinName == "GPI3")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI3")){ + pinResource.used = false; + } + } + if(inst["Channel_2"]==true){ + if((pin.pinName == "GPI5")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI5")){ + pinResource.used = false; + } + } + if(inst["Channel_3"]==true){ + if((pin.pinName == "GPI7")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI7")){ + pinResource.used = false; + } + } + if(inst["Channel_4"]==true){ + if((pin.pinName == "GPI18")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI18")){ + pinResource.used = false; + } + } + if(inst["Channel_5"]==true){ + if((pin.pinName == "GPI11")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI11")){ + pinResource.used = false; + } + } + if(inst["Channel_6"]==true){ + if((pin.pinName == "GPI13")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI13")){ + pinResource.used = false; + } + } + if(inst["Channel_7"]==true){ + if((pin.pinName == "GPI15")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI15")){ + pinResource.used = false; + } + } + if(inst["Channel_8"]==true){ + if((pin.pinName == "GPI17")){ + pinResource.used = true; + } + }else{ + if( (pin.pinName == "GPI17")){ + pinResource.used = false; + } + } + + resources.push( pinResource ); + } + + let peripheralRequirements = { + name: interfaceName, + displayName: interfaceName, + interfaceName: interfaceName, + resources: resources, + }; + + return [peripheralRequirements]; +} + +function getPeripheralPinNames(inst) +{ + let pinList = []; + let pinNameList = []; + + pinList = getInterfacePinList(inst); + + for(let pin of pinList) + { + pinNameList.push( pin.pinName ); + } + + return pinNameList; +} + + +exports = { + + pinmuxRequirements, + getInterfaceName, + getPeripheralPinNames, +}; diff --git a/source/.meta/current_sense/templates/sdfm_template.h.xdt b/source/.meta/current_sense/templates/sdfm_template.h.xdt new file mode 100644 index 0000000..17ef358 --- /dev/null +++ b/source/.meta/current_sense/templates/sdfm_template.h.xdt @@ -0,0 +1,41 @@ +%%{ + let module = system.modules[args[0]]; +%%} +/* + * SDFM + */ + +/* SDFM Instance Macros */ +#define CONFIG_SDFM_NUM_INSTANCES `module.$instances.length` +%for(let i = 0; i < module.$instances.length; i++) { + % let instance = module.$instances[i]; + % let Slice = 0 ; + %if(instance.instance === "ICSSG1") + %{ + % if(instance.PRU_ICSSG1_PRU.$assign === "PRU_ICSSG1_PRU1") + %{ + % Slice = 1; + %} + + %} + %else + %{ + %if(instance.PRU_ICSSG0_PRU.$assign === "PRU_ICSSG0_PRU1") + %{ + % Slice = 1; + %} + + %} + +#define `instance.$name` `i` +#define `instance.$name`_CHANNEL0 `instance.Channel_0 & 1` +#define `instance.$name`_CHANNEL1 `instance.Channel_1 & 1` +#define `instance.$name`_CHANNEL2 `instance.Channel_2 & 1` +#define `instance.$name`_CHANNEL3 `instance.Channel_3 & 1` +#define `instance.$name`_CHANNEL4 `instance.Channel_4 & 1` +#define `instance.$name`_CHANNEL5 `instance.Channel_5 & 1` +#define `instance.$name`_CHANNEL6 `instance.Channel_6 & 1` +#define `instance.$name`_CHANNEL7 `instance.Channel_7 & 1` +#define `instance.$name`_CHANNEL8 `instance.Channel_8 & 1` +#define PRU_ICSSGx_PRU_SLICE `Slice` +% } diff --git a/source/.meta/soc/motor_control_am243x.syscfg.js b/source/.meta/soc/motor_control_am243x.syscfg.js index 77e8ab4..5fc93e0 100644 --- a/source/.meta/soc/motor_control_am243x.syscfg.js +++ b/source/.meta/soc/motor_control_am243x.syscfg.js @@ -6,6 +6,7 @@ const topModules_main = [ "/position_sense/hdsl", "/position_sense/tamagawa", "/position_sense/bissc", + "/current_sense/sdfm", ];