Hi @PavelL
The below is the code which create a Dynamic entry for CB_Sequence Generation and Recovery Table can you check whether the entry is in a Correct order if at all any changes in the order of CB_SGIR_ENtry[0],[1],[2],[3],[4] can you provide me the changes of the order because its not mentioned cb_sg_ir.py
And one more thing cb_sg_ir.py file there is not order for creating a entry its like a parsing of data getentry, setentry can you confirm me the order of array which I have created to make a dynamic entry
what are the changes need to be mentioned in below code can you provide me the valid changes that would be more helpful
int WriteCB_SG_IR(uint32_t index) {
int cs = 0;
uint32_t CBSGIR_OFFSET = 142;
uint32_t CBSGIR_CTRL_OFFSET = 147;
const uint32_t SWREG_BASE = 0;
uint32_t CB_SG_IR_ADDRESS = SWREG_BASE + CBSGIR_OFFSET;
uint32_t CB_SG_IR_ADDRESS_CTL = SWREG_BASE + CBSGIR_CTRL_OFFSET;
if (index >= 64) {
return -1;
}
uint32_t RTAGOFFSET_0 = 0;
uint32_t RTAGOFFSET_1 = 0;
uint32_t RTAGOFFSET_2 = 0;
uint32_t RTAGOFFSET_3 = 0;
uint32_t RTAGOFFSET_4 = 0;
uint32_t RTAGOFFSET_5 = 0;
uint32_t RTAGOFFSET_6 = 0;
uint32_t RTAGOFFSET_7 = 0;
uint32_t RTAGOFFSET_8 = 0;
uint32_t RTAGOFFSET_9 = 0;
uint32_t RTAGOFFSET_10 = 0;
uint32_t REPLACE_PORTS = 0;
uint32_t TAG_PORTS = 0x006;
uint32_t SEQ_REC_PORTS = 0;
uint32_t IND_REC_PORTS = 0;
uint32_t IND_REC_TIMEOUT = 0;
uint32_t SEQRECOFFSET = 0;
uint32_t GENSEQNUM = 0x1;
uint32_t SEQGENRST = 0;
uint32_t VALID = 1U;
uint32_t RDWRSET = 1U;
uint32_t TARGETEDTBL = 0;
uint32_t CB_SG_IR_Entry[CB_SGIR_ADDR_RANGE] = {0};
CB_SG_IR_Entry[0] =(((GENSEQNUM & 0x1) << (1 % 32)) +
((SEQRECOFFSET & 0x1F) << (2 % 32)) +
((IND_REC_TIMEOUT & 0xFFFF) << (7 % 32)));
CB_SG_IR_Entry[1] =
((SEQ_REC_PORTS & 0x7FF) << 0) |
((IND_REC_PORTS & 0x7FF) << 11);
CB_SG_IR_Entry[2] =
(((TAG_PORTS & 0x7FF) << (0 % 32)) +
((REPLACE_PORTS & 0x7FF) << (11 % 32)));
CB_SG_IR_Entry[3] =
(((RTAGOFFSET_0 & 0x3F) << (0 % 32)) +
((RTAGOFFSET_1 & 0x3F) << (6 % 32)) +
((RTAGOFFSET_2 & 0x3F) << (12 % 32)) +
((RTAGOFFSET_3 & 0x3F) << (18 % 32)) +
((RTAGOFFSET_4 & 0x3F) << (24 % 32)));
CB_SG_IR_Entry[4] =
(((RTAGOFFSET_5 & 0x3F) << (0 % 32)) +
((RTAGOFFSET_6 & 0x3F) << (6 % 32)) +
((RTAGOFFSET_7 & 0x3F) << (12 % 32)) +
((RTAGOFFSET_8 & 0x3F) << (18 % 32)) +
((RTAGOFFSET_9 & 0x3F) << (24 % 32)) +
((RTAGOFFSET_10 & 0x3F) << (30 % 32)));
uint32_t status = 0;
status = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, cs);
uint8_t counter = 0;
while ((status & (1 << 31)) != 0){
counter++;
status = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, cs);
}
for (int i = 0; i < CB_SGIR_ADDR_RANGE; i++) {
Std_ReturnType ret = spi_write_DynamicEntry(CB_SG_IR_ADDRESS + i, CB_SG_IR_Entry[i]);
if (ret != E_OK) {
return -2;
}
uint32_t readBack = 0;
ret = spi_read_DynamicEntry(CB_SG_IR_ADDRESS + i, &readBack);
if (ret != E_OK || readBack != CB_SG_IR_Entry[i]) {
return -3;
}
}
uint32_t CTRL_VALUE = (VALID << 31) |
(RDWRSET << 30) |
(SEQGENRST << 9) |
(TARGETEDTBL << 6) |
(index & 0x3F);
Std_ReturnType ret = spi_write_DynamicEntry(CB_SG_IR_ADDRESS_CTL, CTRL_VALUE);
if (ret != E_OK) {
return -4;
}
do {
ret = spi_read_DynamicEntry(CB_SG_IR_ADDRESS_CTL, &status);
if (ret != E_OK) {
return -5;
}
} while ((status >> 31) & 1U);
return 0; // Success
}