]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A5_SAMA5D2x_Xplained_IAR/AtmelFiles/drivers/peripherals/tdes.h
Add SAMA5D2 Xplained IAR demo.
[freertos] / FreeRTOS / Demo / CORTEX_A5_SAMA5D2x_Xplained_IAR / AtmelFiles / drivers / peripherals / tdes.h
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License\r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2015, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\r
8  * Redistribution and use in source and binary forms, with or without\r
9  * modification, are permitted provided that the following conditions are met:\r
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\r
14  * Atmel's name may not be used to endorse or promote products derived from\r
15  * this software without specific prior written permission.\r
16  *\r
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
27  * ----------------------------------------------------------------------------\r
28  */\r
29 \r
30 #ifndef _TDES_\r
31 #define _TDES_\r
32 \r
33 /*----------------------------------------------------------------------------\r
34  *         Headers\r
35  *----------------------------------------------------------------------------*/\r
36 \r
37 #include "chip.h"\r
38 \r
39 /*----------------------------------------------------------------------------\r
40  *         Definitions\r
41  *----------------------------------------------------------------------------*/\r
42 \r
43 #define MODE_SINGLE_DES              0x00\r
44 #define MODE_TRIPLE_DES              0x01\r
45 #define MODE_XTEA                    0x02\r
46 \r
47 /*----------------------------------------------------------------------------\r
48  *         Exported functions\r
49  *----------------------------------------------------------------------------*/\r
50 \r
51 /**\r
52  * \brief Starts Manual encryption/decryption process.\r
53  */\r
54 void tdes_start(void);\r
55 \r
56 /**\r
57  * \brief Resets the TDES.\r
58  * A software triggered hardware reset of the TDES interface is performed.\r
59  */\r
60 void tdes_soft_reset(void);\r
61 \r
62 /**\r
63  * \brief Configures an TDES peripheral with the specified parameters.\r
64  * \param mode  Desired value for the TDES_MR mode register (see the datasheet).\r
65  */\r
66 void tdes_configure(uint32_t mode);\r
67 \r
68 /**\r
69  * \brief Enables the selected interrupts sources on a TDES peripheral.\r
70  * \param sources  Bitwise OR of selected interrupt sources.\r
71  */\r
72 void tdes_enable_it(uint32_t sources);\r
73 \r
74 /**\r
75  * \brief Disables the selected interrupts sources on a TDES peripheral.\r
76  * \param sources  Bitwise OR of selected interrupt sources.\r
77  */\r
78 void tdes_disable_it(uint32_t sources);\r
79 \r
80 /**\r
81  * \brief Get the current status register of the given TDES peripheral.\r
82  * \return  TDES status register.\r
83  */\r
84 extern uint32_t tdes_get_status(void);\r
85 \r
86 /**\r
87  * \brief Set KEY 1/2/3.\r
88  * \param key_word0  Key x, word 0\r
89  * \param key_word1  Key x, word 1\r
90  */\r
91 void tdes_write_key1(uint32_t key_word0, uint32_t key_word1);\r
92 void tdes_write_key2(uint32_t key_word0, uint32_t key_word1);\r
93 void tdes_write_key3(uint32_t key_word0, uint32_t key_word1);\r
94 \r
95 /**\r
96  * \brief Set the two 32-bit input data registers. Allows to set the 64-bit data\r
97  * block used for encryption/decryption.\r
98  * \param data0  Corresponds to the first word of the data to be processed.\r
99  * \param data1  Corresponds to the last word of the data to be processed.\r
100  */\r
101 void tdes_set_input(uint32_t data0, uint32_t data1);\r
102 \r
103 /**\r
104  * \brief Read from the two 32-bit data registers containing the 64-bit data\r
105  * block which has been encrypted/decrypted.\r
106  * \param data0  Points to the first word.\r
107  * \param data1  Points to the second word.\r
108  */\r
109 void tdes_get_output(uint32_t *data0, uint32_t *data1);\r
110 \r
111 /**\r
112  * \brief Set the 64-bit initialization vector data block, which is used by\r
113  * specific modes of operation as an additional initial input.\r
114  * \param v0  Corresponds to the first word of the initialization vector.\r
115  * \param v1  Corresponds to the second word of the initialization vector.\r
116  */\r
117 void tdes_set_vector(uint32_t v0, uint32_t v1);\r
118 \r
119 /**\r
120  * \brief Set the 6-bit complete rounds.\r
121  * \param rounds  Corresponds to rounds+1 complete round.\r
122  */\r
123 void tdes_set_xtea_rounds(uint32_t rounds);\r
124 \r
125 #endif                          /* #ifndef _TDES_ */\r