Other Parts Discussed in Thread: BQSTUDIO
I am having an unexpected behavior when I unseal the BQ34110. I have written a test routine where I sequencially seal and unseal BQ and check the status. The unexpected behavior occurrs when I do an unseal (no full access). The status simply returned the sealed status aftwards. Only after I added a long delay (four seconds - line 45 on the excerpt below) I was able to successfully get the status with the unsealed bits.
The funny thing is if I do a full unseal sequence (unseal key followed by full access key), a long delay is not required. Is this the expected behavior? I could not find the information in the TRM.
I noticed though that with BQStudio adds a long delay after clicking on either UNSEAL and UNSEAL_FULL_ACESS buttons.
Below is an excerpt of the test function. I hope the code is sufficiently self expanatory.
static void test_seal_unseal (void) { int res; uint16_t wait = 50; // Force unseal full access { res = bq34110_unseal (&default_keys, true); UTEST_ASSERT (res == 0, ""); wait_ticks (wait); } // Check unsealed status { uint16_t ref = 0xFFFF; uint16_t op_status = ref; res = bq34110_ctrl (CTR_OPERATION_STATUS, READ_OP, &op_status); UTEST_ASSERT (res == 0, ""); UTEST_ASSERT (op_status != ref, ""); UTEST_ASSERT ((op_status & 0x0006) == 0x0002, ""); } // Seal BQ34110 { uint16_t ref = 0xFFFF; uint16_t op_status = ref; res = bq34110_ctrl (CTR_SEAL, WRITE_OP, NULL); UTEST_ASSERT (res == 0, ""); wait_ticks (wait); res = bq34110_ctrl (CTR_OPERATION_STATUS, READ_OP, &op_status); UTEST_ASSERT (res == 0, ""); UTEST_ASSERT (op_status != ref, ""); UTEST_ASSERT ((op_status & 0x0006) == 0x0006, ""); } // Unseal (not full access) { uint16_t ref = 0xFFFF; uint16_t op_status = ref; wait_ticks (wait*80); res = bq34110_unseal (&default_keys, false); UTEST_ASSERT (res == 0, ""); wait_ticks (wait); res = bq34110_cmd (CMD_OPERATION_STATUS, READ_OP, &op_status); UTEST_ASSERT (res == 0, ""); UTEST_ASSERT (op_status != ref, ""); UTEST_ASSERT ((op_status & 0x0006) == 0x0004, ""); } // Seal BQ34110 again { uint16_t ref = 0xFFFF; uint16_t op_status = ref; res = bq34110_ctrl (CTR_SEAL, WRITE_OP, NULL); UTEST_ASSERT (res == 0, ""); wait_ticks (wait); res = bq34110_cmd (CMD_OPERATION_STATUS, READ_OP, &op_status); UTEST_ASSERT (res == 0, ""); UTEST_ASSERT (op_status != ref, ""); UTEST_ASSERT ((op_status & 0x0006) == 0x0006, ""); } // Unseal (full access) { uint16_t ref = 0xFFFF; uint16_t op_status = ref; res = bq34110_unseal (&default_keys, true); UTEST_ASSERT (res == 0, ""); wait_ticks (wait); res = bq34110_cmd (CMD_OPERATION_STATUS, READ_OP, &op_status); UTEST_ASSERT (res == 0, ""); UTEST_ASSERT (op_status != ref, ""); UTEST_ASSERT ((op_status & 0x0006) == 0x0002, ""); } }