I have been playing with it and have found that if I set AESACTL0.AESOP to 0 before the call, it gets past the while loop. When I don't call this code from a bootloader, it is 0 already. So that raises the question, is this a bug? bool AES256_setCipherKey(uint32_t moduleInstance, const uint8_t * cipherKey, uint_fast16_t keyLength) { uint_fast8_t i; uint16_t sCipherKey; AES256_CMSIS(moduleInstance)->rCTL0.r |= 0; switch (keyLength) { case AES256_KEYLENGTH_128BIT: AES256_CMSIS(moduleInstance)->rCTL0.r |= AESKL__128BIT; break; case AES256_KEYLENGTH_192BIT: AES256_CMSIS(moduleInstance)->rCTL0.r |= AESKL__192BIT; break; case AES256_KEYLENGTH_256BIT: AES256_CMSIS(moduleInstance)->rCTL0.r |= AESKL__256BIT; break; default: return false; } keyLength = keyLength / 8; for (i = 0; i rKEY.r = sCipherKey; } // Wait until key is written while (!BITBAND_PERI(AES256_CMSIS(moduleInstance)->rSTAT.r, AESKEYWR_OFS)) ; return true; } The line AES256_CMSIS(moduleInstance)->rCTL0.r |= 0; Is this supposed to be AES256_CMSIS(moduleInstance)->rCTL0.r &= (~(AESKL__128BIT + AESKL__192BIT + AESKL__256BIT)); As when I hit the while loop that never progresses, I have a value of 0x02 in the AESOP register before I start setting the key. Even adding a AES256_reset(AES256_BASE); doesn't clear it back to 0. Hope this helps. Josh
↧