123 lines
4.5 KiB
Plaintext
123 lines
4.5 KiB
Plaintext
% var nameOfModule = "pga";
|
|
% var module = system.modules['/driverlib/' + nameOfModule + '.js'];
|
|
% let Common = system.getScript("/driverlib/Common.js");
|
|
% var nameOfPeripheral = module.peripheralName;
|
|
//*****************************************************************************
|
|
//
|
|
// PGA Configurations
|
|
//
|
|
//*****************************************************************************
|
|
void `nameOfPeripheral`_init(){
|
|
% for(var i = 0; i < module.$instances.length; i++)
|
|
% {
|
|
% var instance = module.$instances[i];
|
|
`instance.$name`_init();
|
|
% }
|
|
}
|
|
|
|
%if (module != null)
|
|
%{
|
|
% for(var i = 0; i < module.$instances.length; i++) {
|
|
% var instance = module.$instances[i];
|
|
void `instance.$name`_init(){
|
|
% let instancePinmux = instance[nameOfModule];
|
|
%
|
|
%if (["F28004x"].includes(Common.getDeviceName())){
|
|
PGA_setGain(`instance.$name`_BASE, `instance.gainMode`);
|
|
%
|
|
% if (instance.enableFilter) {
|
|
PGA_setFilterResistor(`instance.$name`_BASE, `instance.filterMode`);
|
|
% } else {
|
|
PGA_setFilterResistor(`instance.$name`_BASE, PGA_LOW_PASS_FILTER_DISABLED);
|
|
% }
|
|
% }
|
|
%if (["F28P55x"].includes(Common.getDeviceName())){
|
|
% if (instance.enableFilterMode)
|
|
% {
|
|
PGA_selectPMUXInput(`instance.$name`_BASE, PGA_PMUX_VSSA);
|
|
PGA_selectNMUXInput(`instance.$name`_BASE, PGA_NMUX_RTAP);
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_NON_INVERTING_GAIN_VSSA);
|
|
PGA_setGain(`instance.$name`_BASE, `instance.gainMode`);
|
|
PGA_configurefeedbackOnPin(`instance.$name`_BASE);
|
|
% }
|
|
% if (!instance.enableFilterMode) {
|
|
% if (instance.modeSelection == "BufferMode")
|
|
% {
|
|
PGA_selectPMUXInput(`instance.$name`_BASE, PGA_PMUX_POS);
|
|
PGA_selectNMUXInput(`instance.$name`_BASE, PGA_NMUX_RTOP);
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_NAKED_OPAMP);
|
|
% }
|
|
% else if (instance.modeSelection == "StandaloneMode")
|
|
% {
|
|
PGA_selectPMUXInput(`instance.$name`_BASE, PGA_PMUX_POS);
|
|
PGA_selectNMUXInput(`instance.$name`_BASE, PGA_NMUX_NEG);
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_NAKED_OPAMP);
|
|
% }
|
|
% else if (instance.modeSelection == "Non-invertingMode")
|
|
% {
|
|
PGA_selectPMUXInput(`instance.$name`_BASE, PGA_PMUX_POS);
|
|
PGA_selectNMUXInput(`instance.$name`_BASE, PGA_NMUX_RTAP);
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_NON_INVERTING_GAIN_VSSA);
|
|
PGA_setGain(`instance.$name`_BASE, `instance.gainMode`);
|
|
% }
|
|
% else if (instance.modeSelection == "SubtractorMode")
|
|
% {
|
|
PGA_selectPMUXInput(`instance.$name`_BASE, PGA_PMUX_POS);
|
|
PGA_selectNMUXInput(`instance.$name`_BASE, PGA_NMUX_RTAP);
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_INVERTING_GAIN_NEG);
|
|
PGA_setGain(`instance.$name`_BASE, `instance.gainMode`);
|
|
% }
|
|
% if (instance.enableNEGShared) {
|
|
PGA_selectMMUXInput(`instance.$name`_BASE, PGA_MMUX_INVERTING_GAIN_NEG_SHARED);
|
|
% }
|
|
% if (instance.enableFilter) {
|
|
PGA_setFilterResistor(`instance.$name`_BASE, `instance.filterMode`);
|
|
% } else {
|
|
PGA_setFilterResistor(`instance.$name`_BASE, PGA_LOW_PASS_FILTER_DISABLED);
|
|
% }
|
|
% if (instance.enableChopper) {
|
|
PGA_enableExternalChop(`instance.$name`_BASE);
|
|
PGA_chop(`instance.$name`_BASE, `instance.enableChopperMode`);
|
|
% } else {
|
|
PGA_disableExternalChop(`instance.$name`_BASE);
|
|
% }
|
|
%}
|
|
%}
|
|
%
|
|
% // preparing `registersToLockOR` for PGA_lockRegisters()
|
|
% if (instance.lockedRegisters.length>0)
|
|
%{
|
|
%%{
|
|
var regCount = 0
|
|
var registersToLockOR = "("
|
|
for (var registerToLock in instance.lockedRegisters)
|
|
{
|
|
if (regCount == 0)
|
|
{
|
|
registersToLockOR += instance.lockedRegisters[regCount]
|
|
}
|
|
else
|
|
{
|
|
registersToLockOR += " | " + instance.lockedRegisters[regCount]
|
|
}
|
|
regCount++
|
|
}
|
|
registersToLockOR += ")"
|
|
%%}
|
|
//
|
|
// Lock write-access to PGA Registers
|
|
//
|
|
PGA_lockRegisters(`instance.$name`_BASE, `registersToLockOR`);
|
|
% }
|
|
% if (instance.pgaEnable) {
|
|
PGA_enable(`instance.$name`_BASE);
|
|
% } else {
|
|
PGA_disable(`instance.$name`_BASE);
|
|
% }
|
|
//
|
|
// Delay for PGA to power up.
|
|
//
|
|
DEVICE_DELAY_US(500);
|
|
}
|
|
%}
|
|
%} |