Update repo
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
% var module = system.modules['/driverlib/pmbus.js'];
|
||||
% let Common = system.getScript("/driverlib/Common.js");
|
||||
% var nameOfModule = "pmbus";
|
||||
% var nameOfPeripheral = module.peripheralName;
|
||||
% var stat = module.$static
|
||||
% var sysclk_Hz = stat.sysClock * 1000000;
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PMBUS 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(){
|
||||
uint32_t moduleFreq = 0U;
|
||||
% if (instance.busClock == "PMBUS_CLOCKMODE_FAST_PLUS")
|
||||
% {
|
||||
uint32_t sclGpioEnumValue = 0U, sdaGpioEnumValue = 0U;
|
||||
% }
|
||||
PMBus_disableModule(`instance.$name`_BASE);
|
||||
% if (instance.enableI2CMode)
|
||||
% {
|
||||
PMBus_enableI2CMode(`instance.$name`_BASE);
|
||||
% }
|
||||
% else
|
||||
% {
|
||||
PMBus_disableI2CMode(`instance.$name`_BASE);
|
||||
% }
|
||||
% if(instance.zeroHoldSupport)
|
||||
% {
|
||||
% if(instance.useZeroHoldSupport)
|
||||
% {
|
||||
PMBus_enableZeroHoldTime(`instance.$name`_BASE);
|
||||
%}
|
||||
% else
|
||||
%{
|
||||
PMBus_disableZeroHoldTime(`instance.$name`_BASE);
|
||||
%}
|
||||
% }
|
||||
% if(instance.ALERT_EN)
|
||||
% {
|
||||
PMBus_assertAlertLine(`instance.$name`_BASE);
|
||||
%}
|
||||
% else
|
||||
%{
|
||||
PMBus_deassertAlertLine(`instance.$name`_BASE);
|
||||
%}
|
||||
PMBus_setOwnAddress(`instance.$name`_BASE, `instance.$name`_OWN_ADDRESS);
|
||||
% var moduleFreq = "";
|
||||
moduleFreq = PMBus_configModuleClock(`instance.$name`_BASE, `instance.$name`_BAUDRATE, DEVICE_SYSCLK_FREQ);
|
||||
PMBus_configBusClock(`instance.$name`_BASE, `instance.$name`_CLOCKMODE, moduleFreq);
|
||||
% if (instance.busClock == "PMBUS_CLOCKMODE_FAST_PLUS")
|
||||
% {
|
||||
// configure the GPIO pins for SDA
|
||||
`instance.$name`_GPIO_MAP(`instance.$name`_PMBUSSDA_GPIO, sdaGpioEnumValue);
|
||||
AsysCtl_setDriveStrength((AsysCtl_IO_Drvsel_GPIO)sdaGpioEnumValue);
|
||||
AsysCtl_setDriveMode((AsysCtl_IO_Modesel_GPIO)sdaGpioEnumValue);
|
||||
|
||||
// configure the GPIO pins for SCL
|
||||
`instance.$name`_GPIO_MAP(`instance.$name`_PMBUSSCL_GPIO, sclGpioEnumValue);
|
||||
AsysCtl_setDriveStrength((AsysCtl_IO_Drvsel_GPIO)sclGpioEnumValue);
|
||||
AsysCtl_setDriveMode((AsysCtl_IO_Modesel_GPIO)sclGpioEnumValue);
|
||||
% }
|
||||
|
||||
% if (instance.mode == "Controller")
|
||||
%{
|
||||
PMBus_initControllerMode(`instance.$name`_BASE);
|
||||
//
|
||||
// config target address
|
||||
//
|
||||
PMBus_setTargetAddress(`instance.$name`_BASE, `instance.$name`_TARGET_ADDRESS);
|
||||
%}
|
||||
% else
|
||||
%{
|
||||
PMBus_initTargetMode(`instance.$name`_BASE, `instance.$name`_TARGET_ADDRESS, `instance.$name`_TARGET_ADDRESS_MASK);
|
||||
% var configWord_target = "";
|
||||
% for (var int_index in instance.configTarget)
|
||||
% {
|
||||
% configWord_target += ((configWord_target == "")?"":" | ") + instance.configTarget[int_index];
|
||||
% }
|
||||
% if (configWord_target !=""){
|
||||
PMBus_configTarget(`instance.$name`_BASE, `configWord_target`);
|
||||
%}
|
||||
%}
|
||||
% if (instance.useInterrupts)
|
||||
%{
|
||||
% var interrupts = "";
|
||||
% for (var int_index in instance.enabledInterrupts)
|
||||
% {
|
||||
% interrupts += ((interrupts == "")?"":" | ") + instance.enabledInterrupts[int_index];
|
||||
% }
|
||||
% if (interrupts != "")
|
||||
% {
|
||||
PMBus_disableInterrupt(`instance.$name`_BASE, `interrupts`);
|
||||
% }
|
||||
% if (interrupts != "")
|
||||
%{
|
||||
PMBus_enableInterrupt(`instance.$name`_BASE, `interrupts`);
|
||||
% }
|
||||
% }
|
||||
% if(instance.enablePMBus)
|
||||
% {
|
||||
PMBus_enableModule(`instance.$name`_BASE);
|
||||
%}
|
||||
}
|
||||
%}
|
||||
%}
|
||||
@@ -0,0 +1,32 @@
|
||||
% var module = system.modules['/driverlib/pmbus.js'];
|
||||
%if (module != null)
|
||||
%{
|
||||
//*****************************************************************************
|
||||
//
|
||||
// PMBUS Configurations
|
||||
//
|
||||
//*****************************************************************************
|
||||
% for(var i = 0; i < module.$instances.length; i++) {
|
||||
% var instance = module.$instances[i];
|
||||
% let pmbus = instance.pmbus;
|
||||
% let solution = pmbus.$solution;
|
||||
%let peripheral = system.deviceData.peripherals[solution.peripheralName];
|
||||
#define `instance.$name`_BASE `peripheral.name`_BASE
|
||||
#define `instance.$name`_BAUDRATE `parseInt(instance.BaudRate)`
|
||||
#define `instance.$name`_TARGET_ADDRESS `instance.TargetAddress`
|
||||
#define `instance.$name`_TARGET_ADDRESS_MASK `instance.TargetAddressMask`
|
||||
#define `instance.$name`_OWN_ADDRESS `instance.OwnAddress`
|
||||
#define `instance.$name`_ENABLE_I2C_MODE `instance.enableI2CMode`
|
||||
#define `instance.$name`_CLOCKMODE `instance.busClock`
|
||||
#define `instance.$name`_GPIO_MAP(gpioNumber, enumValue) do { \
|
||||
switch((gpioNumber)) { \
|
||||
case 2: (enumValue) = 0; break; \
|
||||
case 3: (enumValue) = 1; break; \
|
||||
case 9: (enumValue) = 2; break; \
|
||||
case 32: (enumValue) = 3; break; \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
void `instance.$name`_init();
|
||||
% }
|
||||
%}
|
||||
Reference in New Issue
Block a user