1 /**
2     *****************************************************************************
3     * @file     cmem7_efuse.h
4     *
5     * @brief    CMEM7 EFUSE header file
6     *
7     *
8     * @version  V1.0
9     * @date     3. September 2013
10     *
11     * @note
12     *
13     *****************************************************************************
14     * @attention
15     *
16     * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
17     * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
18     * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
19     * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
20     * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
21     * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
22     *
23     * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
24     *****************************************************************************
25     */
26 
27 #ifndef __CMEM7_EFUSE_H
28 #define __CMEM7_EFUSE_H
29 
30 #ifdef __cplusplus
31  extern "C" {
32 #endif
33 
34 #include "cmem7.h"
35 #include "cmem7_conf.h"
36 
37 /** @defgroup EFUSE_TMRF_R
38   * @{
39   */
40 #define EFUSE_TMRF_R_3000                0
41 #define EFUSE_TMRF_R_1200                1
42 #define EFUSE_TMRF_R_750                 2
43 
44 #define IS_EFUSE_TMRF(R)                 (((R) == EFUSE_TMRF_R_3000) || \
45                                           ((R) == EFUSE_TMRF_R_1200) || \
46                                           ((R) == EFUSE_TMRF_R_750))
47 /**
48   * @}
49   */
50 
51 /**
52   * @brief  EFUSE timing structure
53     */
54 typedef struct
55 {
56     uint32_t EFUSE_Tpwph;                  /*!< Nano second                                    */
57   uint32_t EFUSE_Trac;                   /*!< Nano second                                    */
58     uint32_t EFUSE_Trah;                   /*!< Nano second                                    */
59     uint32_t EFUSE_Trpw;                   /*!< Nano second                                    */
60     uint32_t EFUSE_Trc;                    /*!< Nano second                                    */
61     uint32_t EFUSE_Tesr;                   /*!< Nano second                                    */
62     uint32_t EFUSE_Tprs;                   /*!< Nano second                                    */
63     uint32_t EFUSE_Tpi;                    /*!< Nano second                                    */
64     uint32_t EFUSE_Tpp;                    /*!< Nano second                                    */
65     uint32_t EFUSE_Teps;                   /*!< Nano second                                    */
66     uint32_t EFUSE_Tpwps;                  /*!< Nano second                                    */
67 } EFUSE_Timing;
68 
69 /**
70   * @brief  EFUSE initialization structure
71     */
72 typedef struct
73 {
74     uint8_t EFUSE_ClockDividor;              /*!< EFUSE clock dividor, 2 in n times */
75     uint8_t EFUSE_TMRF;                    /*!< EFUSE reference resistor select, @ref EFUSE_TMRF_R */
76   EFUSE_Timing* timing;                  /*!< Timing configuration, null if default           */
77 } EFUSE_InitTypeDef;
78 
79 /**
80   * @brief  EFUSE key structure
81     */
82 typedef struct
83 {
84     uint32_t key0;                         /*!< EFUSE AES key [31:0]                            */
85   uint32_t key1;                         /*!< EFUSE AES key [63:32]                           */
86     uint32_t key2;                         /*!< EFUSE AES key [95:64]                           */
87     uint32_t key3;                         /*!< EFUSE AES key [127:96]                          */
88     uint32_t key4;                         /*!< EFUSE AES key [159:128]                         */
89   uint32_t key5;                         /*!< EFUSE AES key [191:160]                         */
90     uint32_t key6;                         /*!< EFUSE AES key [223:192]                         */
91     uint32_t key7;                         /*!< EFUSE AES key [255:224]                         */
92 } EFUSE_AesKey;
93 
94 /**
95   * @brief  EFUSE initialization
96   * @note   This function should be called at first before any other interfaces.
97     * @param[in] init A pointer to structure EFUSE_InitTypeDef
98   * @retval None
99     */
100 void EFUSE_Init(EFUSE_InitTypeDef* init);
101 
102 /**
103   * @brief  EFUSE initialization
104   * @param[in] key A pointer to EFUSE_AesKey to be compared
105   * @retval BOOL True if equal, or false if different
106     */
107 BOOL EFUSE_Compare(EFUSE_AesKey* key);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* __CMEM7_EFUSE_H */
114 
115