|
| 1 | +/** |
| 2 | + ******************************************************************************** |
| 3 | + * @file stm8l15x_aes.h |
| 4 | + * @author MCD Application Team |
| 5 | + * @version V1.6.1 |
| 6 | + * @date 30-September-2014 |
| 7 | + * @brief This file contains all the functions prototypes for the AES firmware |
| 8 | + * library. |
| 9 | + ****************************************************************************** |
| 10 | + * @attention |
| 11 | + * |
| 12 | + * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> |
| 13 | + * |
| 14 | + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
| 15 | + * You may not use this file except in compliance with the License. |
| 16 | + * You may obtain a copy of the License at: |
| 17 | + * |
| 18 | + * http://www.st.com/software_license_agreement_liberty_v2 |
| 19 | + * |
| 20 | + * Unless required by applicable law or agreed to in writing, software |
| 21 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 22 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 23 | + * See the License for the specific language governing permissions and |
| 24 | + * limitations under the License. |
| 25 | + * |
| 26 | + ****************************************************************************** |
| 27 | + */ |
| 28 | + |
| 29 | +/* Define to prevent recursive inclusion -------------------------------------*/ |
| 30 | +#ifndef __STM8L15x_AES_H |
| 31 | +#define __STM8L15x_AES_H |
| 32 | + |
| 33 | +/* Includes ------------------------------------------------------------------*/ |
| 34 | +#include "stm8l15x.h" |
| 35 | + |
| 36 | +/** @addtogroup STM8L15x_StdPeriph_Driver |
| 37 | + * @{ |
| 38 | + */ |
| 39 | + |
| 40 | +/** @addtogroup AES |
| 41 | + * @{ |
| 42 | + */ |
| 43 | + |
| 44 | +/* Exported types ------------------------------------------------------------*/ |
| 45 | + |
| 46 | +/** @defgroup AES_Exported_Types |
| 47 | + * @{ |
| 48 | + */ |
| 49 | + |
| 50 | +/** @defgroup AES_Operation_Mode |
| 51 | + * @{ |
| 52 | + */ |
| 53 | +typedef enum |
| 54 | +{ |
| 55 | + AES_Operation_Encryp = (uint8_t)0x00, /*!< AES in Encryption mode */ |
| 56 | + AES_Operation_KeyDeriv = (uint8_t)0x02, /*!< AES in Key Derivation mode */ |
| 57 | + AES_Operation_Decryp = (uint8_t)0x04, /*!< AES in Decryption mode */ |
| 58 | + AES_Operation_KeyDerivAndDecryp = (uint8_t)0x06 /*!< AES in Key Derivation and Decryption mode */ |
| 59 | +} AES_Operation_TypeDef; |
| 60 | + |
| 61 | +#define IS_AES_MODE(Operation) (((Operation) == AES_Operation_Encryp) || \ |
| 62 | + ((Operation) == AES_Operation_KeyDeriv) || \ |
| 63 | + ((Operation) == AES_Operation_Decryp) || \ |
| 64 | + ((Operation) == AES_Operation_KeyDerivAndDecryp)) |
| 65 | +/** |
| 66 | + * @} |
| 67 | + */ |
| 68 | + |
| 69 | +/** @defgroup AES_Flags |
| 70 | + * @{ |
| 71 | + */ |
| 72 | +typedef enum |
| 73 | +{ |
| 74 | + AES_FLAG_CCF = (uint8_t)0x01, /*!< Computation Complete Flag */ |
| 75 | + AES_FLAG_RDERR = (uint8_t)0x02, /*!< Read Error Flag */ |
| 76 | + AES_FLAG_WRERR = (uint8_t)0x04 /*!< Write Error Flag */ |
| 77 | +}AES_FLAG_TypeDef; |
| 78 | + |
| 79 | +#define IS_AES_FLAG(Flag) (((Flag) == AES_FLAG_CCF) || \ |
| 80 | + ((Flag) == AES_FLAG_RDERR) || \ |
| 81 | + ((Flag) == AES_FLAG_WRERR)) |
| 82 | + |
| 83 | +/** |
| 84 | + * @} |
| 85 | + */ |
| 86 | + |
| 87 | +/** @defgroup AES_Interrupts |
| 88 | + * @{ |
| 89 | + */ |
| 90 | +typedef enum |
| 91 | +{ |
| 92 | + AES_IT_CCIE = (uint16_t)0x20, /*!< Computation Complete interrupt enable */ |
| 93 | + AES_IT_ERRIE = (uint16_t)0x40 /*!< Error interrupt enable */ |
| 94 | +}AES_IT_TypeDef; |
| 95 | + |
| 96 | +#define IS_AES_IT(IT) (((IT) == AES_IT_CCIE) || \ |
| 97 | + ((IT) == AES_IT_ERRIE)) |
| 98 | + |
| 99 | +/** |
| 100 | + * @} |
| 101 | + */ |
| 102 | + |
| 103 | +/** @defgroup AES_DMA_Transfer_Direction |
| 104 | + * @{ |
| 105 | + */ |
| 106 | +typedef enum |
| 107 | +{ |
| 108 | + AES_DMATransfer_InOut = (uint8_t) 0x80 /*!< DMA requests enabled for input transfer phase |
| 109 | + as well as for the output transfer phase */ |
| 110 | +} |
| 111 | +AES_DMATransfer_TypeDef; |
| 112 | + |
| 113 | +#define IS_AES_DMATRANSFER(Transfer) ((Transfer) == AES_DMATransfer_InOut) |
| 114 | +/** |
| 115 | + * @} |
| 116 | + */ |
| 117 | + |
| 118 | +/** |
| 119 | + * @} |
| 120 | + */ |
| 121 | + |
| 122 | +/* Exported constants --------------------------------------------------------*/ |
| 123 | +/* Exported macros -----------------------------------------------------------*/ |
| 124 | +/* Exported functions ------------------------------------------------------- */ |
| 125 | +/* Function used to set the AES configuration to the default reset state *****/ |
| 126 | +void AES_DeInit(void); |
| 127 | + |
| 128 | +/* AES Configuration **********************************************************/ |
| 129 | +void AES_OperationModeConfig(AES_Operation_TypeDef AES_Operation); |
| 130 | +void AES_Cmd(FunctionalState NewState); |
| 131 | + |
| 132 | +/* AES Read and Write operations **********************************************/ |
| 133 | +void AES_WriteSubData(uint8_t Data); |
| 134 | +void AES_WriteSubKey(uint8_t Key); |
| 135 | +uint8_t AES_ReadSubData(void); |
| 136 | +uint8_t AES_ReadSubKey(void); |
| 137 | + |
| 138 | +/* DMA transfers management function ******************************************/ |
| 139 | +void AES_DMAConfig(AES_DMATransfer_TypeDef AES_DMATransfer, FunctionalState NewState); |
| 140 | + |
| 141 | +/* Interrupts and flags management functions **********************************/ |
| 142 | +void AES_ITConfig(AES_IT_TypeDef AES_IT, FunctionalState NewState); |
| 143 | +FlagStatus AES_GetFlagStatus(AES_FLAG_TypeDef AES_FLAG); |
| 144 | +void AES_ClearFlag(AES_FLAG_TypeDef AES_FLAG); |
| 145 | +ITStatus AES_GetITStatus(AES_IT_TypeDef AES_IT); |
| 146 | +void AES_ClearITPendingBit(AES_IT_TypeDef AES_IT); |
| 147 | + |
| 148 | +#endif /* __STM8L15x_AES_H */ |
| 149 | + |
| 150 | +/** |
| 151 | + * @} |
| 152 | + */ |
| 153 | + |
| 154 | +/** |
| 155 | + * @} |
| 156 | + */ |
| 157 | + |
| 158 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
0 commit comments