/* param base IEE peripheral address. param region Selection of the IEE region to be configured. param keyNum Selection of AES KEY1 or KEY2. param key AES key. param keySize Size of AES key.  */
status_t IEE_SetRegionKey(IEE_Type *base, iee_region_t region, iee_aes_key_num_t keyNum, const uint8_t *key, size_t keySize)
/* param base IEE peripheral address. param region Selection of the IEE region to be configured. param keyNum Selection of AES KEY1 or KEY2. param key AES key. param keySize Size of AES key.  */
status_t IEE_SetRegionKey(IEE_Type *base, iee_region_t region, iee_aes_key_num_t keyNum, const uint8_t *key, size_t keySize)
{
    register const uint32_t *from32  = (const uint32_t *)(uintptr_t)key;
    register volatile uint32_t *to32 = NULL;
    if (keyNum == kIEE_AesKey1)
    {
        to32 = &base->REGX[region].REGKEY1[0];
    }
    else if (keyNum == kIEE_AesKey2)
    {
        to32 = &base->REGX[region].REGKEY2[0];
    }
    else
    {
        return kStatus_InvalidArgument;
    }
    while (keySize >= sizeof(uint32_t))
    {
        *to32 = *from32;
        keySize -= sizeof(uint32_t);
        from32++;
        to32++;
    }
    return kStatus_Success;
}