Hi,
ok thats simple.
have a look to SEMC driver.
void SEMC_GetDefaultConfig(semc_config_t *config)
{
assert(config);
SEMC_AXI_QUEUEWEIGHT_TYPE queueWeight; // AXI queue weight.
SEMC_QUEUEA_WEIGHT_TYPE queueaWeight; // !!! Q0 !!!
SEMC_QUEUEB_WEIGHT_TYPE queuebWeight;
// Get default settings
config->dqsMode = kSEMC_Loopbackinternal;
config->cmdTimeoutCycles = 0;
config->busTimeoutCycles = 0x1F;
memset((void *)&queueWeight, 0, sizeof(SEMC_AXI_QUEUEWEIGHT_TYPE)); // !!! Q1 !!!
queueaWeight.qos = SEMC_BMCR0_TYPICAL_WQOS;
queueaWeight.aging = SEMC_BMCR0_TYPICAL_WAGE;
queueaWeight.slaveHitSwith = SEMC_BMCR0_TYPICAL_WSH;
queueaWeight.slaveHitNoswitch = SEMC_BMCR0_TYPICAL_WRWS;
queuebWeight.qos = SEMC_BMCR1_TYPICAL_WQOS;
queuebWeight.aging = SEMC_BMCR1_TYPICAL_WAGE;
queuebWeight.slaveHitSwith = SEMC_BMCR1_TYPICAL_WRWS;
queuebWeight.weightPagehit = SEMC_BMCR1_TYPICAL_WPH;
queuebWeight.bankRotation = SEMC_BMCR1_TYPICAL_WBR;
config->queueWeight.queueaWeight = &queueaWeight; // !!! Q2 !!!!
config->queueWeight.queuebWeight = &queuebWeight;
}
void SEMC_Init(SEMC_Type *base, SEMC_CONFIG_TYPE *configure)
{
.......
// Configure Queue 0/1 for AXI bus
// !!! Q3 !!!!
if (configure->queueWeight.queueaWeight) base->BMCR0 = (unsigned long)(configure->queueWeight.queueaWeight); if (configure->queueWeight.queuebWeight) base->BMCR1 = (unsigned long)(configure->queueWeight.queuebWeight);
}
ad !!! Q1 !!!
queueWeight is a local variable, where is this var used? I think it is dead code
ad !!! Q2 !!!
config->queueWeight.queueaWeight and config->queueWeight.queuebWeight !!!! are Pointers !!!!
ad !!! Q3 !!!
base->BMCR0 is set with the pointer address and not with the content ???? Why
ad !!! Q0 !!!
SEMC_QUEUEA_WEIGHT_TYPE queueaWeight is a local variable
at !!! Q2 !!! is then assign with the address if this local variable
at !!! Q3 !!! if the content should be used, then think about this.
SEMC_GetDefaultConfig(&config);
MyFunction(); // here the stack memory is used and content of queueaWeight and queuebWeight is being destoryed
SEMC_Init(SEMC, &config);
christian