mbed library sources. Supersedes mbed-src. removed serial
Fork of mbed-dev by
targets/TARGET_Maxim/TARGET_MAX32630/mxc/maa.h@157:ff67d9f36b67, 2017-02-02 (annotated)
- Committer:
- <>
- Date:
- Thu Feb 02 17:01:33 2017 +0000
- Revision:
- 157:ff67d9f36b67
This updates the lib to the mbed lib v135
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 157:ff67d9f36b67 | 1 | /** |
<> | 157:ff67d9f36b67 | 2 | * @file |
<> | 157:ff67d9f36b67 | 3 | * @brief Registers, Bit Masks and Bit Positions for the Modular Math |
<> | 157:ff67d9f36b67 | 4 | * Accelerator (MAA) module. |
<> | 157:ff67d9f36b67 | 5 | */ |
<> | 157:ff67d9f36b67 | 6 | /* ***************************************************************************** |
<> | 157:ff67d9f36b67 | 7 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
<> | 157:ff67d9f36b67 | 8 | * |
<> | 157:ff67d9f36b67 | 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
<> | 157:ff67d9f36b67 | 10 | * copy of this software and associated documentation files (the "Software"), |
<> | 157:ff67d9f36b67 | 11 | * to deal in the Software without restriction, including without limitation |
<> | 157:ff67d9f36b67 | 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
<> | 157:ff67d9f36b67 | 13 | * and/or sell copies of the Software, and to permit persons to whom the |
<> | 157:ff67d9f36b67 | 14 | * Software is furnished to do so, subject to the following conditions: |
<> | 157:ff67d9f36b67 | 15 | * |
<> | 157:ff67d9f36b67 | 16 | * The above copyright notice and this permission notice shall be included |
<> | 157:ff67d9f36b67 | 17 | * in all copies or substantial portions of the Software. |
<> | 157:ff67d9f36b67 | 18 | * |
<> | 157:ff67d9f36b67 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
<> | 157:ff67d9f36b67 | 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
<> | 157:ff67d9f36b67 | 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
<> | 157:ff67d9f36b67 | 22 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
<> | 157:ff67d9f36b67 | 23 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
<> | 157:ff67d9f36b67 | 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
<> | 157:ff67d9f36b67 | 25 | * OTHER DEALINGS IN THE SOFTWARE. |
<> | 157:ff67d9f36b67 | 26 | * |
<> | 157:ff67d9f36b67 | 27 | * Except as contained in this notice, the name of Maxim Integrated |
<> | 157:ff67d9f36b67 | 28 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
<> | 157:ff67d9f36b67 | 29 | * Products, Inc. Branding Policy. |
<> | 157:ff67d9f36b67 | 30 | * |
<> | 157:ff67d9f36b67 | 31 | * The mere transfer of this software does not imply any licenses |
<> | 157:ff67d9f36b67 | 32 | * of trade secrets, proprietary technology, copyrights, patents, |
<> | 157:ff67d9f36b67 | 33 | * trademarks, maskwork rights, or any other form of intellectual |
<> | 157:ff67d9f36b67 | 34 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
<> | 157:ff67d9f36b67 | 35 | * ownership rights. |
<> | 157:ff67d9f36b67 | 36 | * |
<> | 157:ff67d9f36b67 | 37 | * $Date: 2016-10-10 19:20:13 -0500 (Mon, 10 Oct 2016) $ |
<> | 157:ff67d9f36b67 | 38 | * $Revision: 24665 $ |
<> | 157:ff67d9f36b67 | 39 | * |
<> | 157:ff67d9f36b67 | 40 | **************************************************************************** */ |
<> | 157:ff67d9f36b67 | 41 | |
<> | 157:ff67d9f36b67 | 42 | /* Define to prevent redundant inclusion */ |
<> | 157:ff67d9f36b67 | 43 | #ifndef _MAA_H |
<> | 157:ff67d9f36b67 | 44 | #define _MAA_H |
<> | 157:ff67d9f36b67 | 45 | |
<> | 157:ff67d9f36b67 | 46 | /* **** Includes **** */ |
<> | 157:ff67d9f36b67 | 47 | #include <stdint.h> |
<> | 157:ff67d9f36b67 | 48 | |
<> | 157:ff67d9f36b67 | 49 | #include "maa_regs.h" |
<> | 157:ff67d9f36b67 | 50 | |
<> | 157:ff67d9f36b67 | 51 | #ifdef __cplusplus |
<> | 157:ff67d9f36b67 | 52 | extern "C" { |
<> | 157:ff67d9f36b67 | 53 | #endif |
<> | 157:ff67d9f36b67 | 54 | |
<> | 157:ff67d9f36b67 | 55 | /** |
<> | 157:ff67d9f36b67 | 56 | * @ingroup periphlibs |
<> | 157:ff67d9f36b67 | 57 | * @defgroup maa MAA |
<> | 157:ff67d9f36b67 | 58 | * @details The API only supports synchronous operations due to the sensitive |
<> | 157:ff67d9f36b67 | 59 | * nature of the input and output data. |
<> | 157:ff67d9f36b67 | 60 | * @{ |
<> | 157:ff67d9f36b67 | 61 | */ |
<> | 157:ff67d9f36b67 | 62 | |
<> | 157:ff67d9f36b67 | 63 | /* **** Definitions **** */ |
<> | 157:ff67d9f36b67 | 64 | |
<> | 157:ff67d9f36b67 | 65 | /** |
<> | 157:ff67d9f36b67 | 66 | * Definition for the maximum MAA register size on this device in bytes, 128. |
<> | 157:ff67d9f36b67 | 67 | */ |
<> | 157:ff67d9f36b67 | 68 | #define MXC_MAA_REG_SIZE 0x80 |
<> | 157:ff67d9f36b67 | 69 | /** |
<> | 157:ff67d9f36b67 | 70 | * Definition for the maximum MAA register size on this device in bits, 1024. |
<> | 157:ff67d9f36b67 | 71 | */ |
<> | 157:ff67d9f36b67 | 72 | #define MXC_MAA_REG_SIZE_BITS (MXC_MAA_REG_SIZE << 3) |
<> | 157:ff67d9f36b67 | 73 | |
<> | 157:ff67d9f36b67 | 74 | /** |
<> | 157:ff67d9f36b67 | 75 | * @def Sub-register ("half size"), allowing 2x more operands in MAA at a time when MAWS <= MAX_SIZE/2 |
<> | 157:ff67d9f36b67 | 76 | */ |
<> | 157:ff67d9f36b67 | 77 | #define MXC_MAA_HALF_SIZE (MXC_MAA_REG_SIZE/2) |
<> | 157:ff67d9f36b67 | 78 | |
<> | 157:ff67d9f36b67 | 79 | /** Flags for MAA_Load() and MAA_Unload() */ |
<> | 157:ff67d9f36b67 | 80 | #define MXC_MAA_F_MEM_VERBATIM 0 |
<> | 157:ff67d9f36b67 | 81 | /** Flags for MAA_Load() and MAA_Unload() */ |
<> | 157:ff67d9f36b67 | 82 | #define MXC_MAA_F_MEM_REVERSE 1 |
<> | 157:ff67d9f36b67 | 83 | |
<> | 157:ff67d9f36b67 | 84 | /** |
<> | 157:ff67d9f36b67 | 85 | * Enumeration type for Segment and Sub-segment selection |
<> | 157:ff67d9f36b67 | 86 | */ |
<> | 157:ff67d9f36b67 | 87 | /* Warning: Do not change the assigned numbers/ordering without associated changes to UMAA_REGFILE_TO_ADDR(x) */ |
<> | 157:ff67d9f36b67 | 88 | typedef enum { |
<> | 157:ff67d9f36b67 | 89 | /* Register names when MAWS > 512 */ |
<> | 157:ff67d9f36b67 | 90 | MXC_E_REG_0 = 0, /**< Register MXC_E_REG_0: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 91 | MXC_E_REG_1 = 2, /**< Register MXC_E_REG_1: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 92 | MXC_E_REG_2 = 4, /**< Register MXC_E_REG_2: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 93 | MXC_E_REG_3 = 6, /**< Register MXC_E_REG_3: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 94 | MXC_E_REG_4 = 8, /**< Register MXC_E_REG_4: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 95 | MXC_E_REG_5 = 10, /**< Register MXC_E_REG_5: If MAA_MAWS > 512 use this register name. */ |
<> | 157:ff67d9f36b67 | 96 | /* Register names when MAWS < 512 */ |
<> | 157:ff67d9f36b67 | 97 | MXC_E_REG_00 = 0, /**< Register MXC_E_REG_00: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 98 | MXC_E_REG_01 = 1, /**< Register MXC_E_REG_01: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 99 | MXC_E_REG_10 = 2, /**< Register MXC_E_REG_10: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 100 | MXC_E_REG_11 = 3, /**< Register MXC_E_REG_11: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 101 | MXC_E_REG_20 = 4, /**< Register MXC_E_REG_20: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 102 | MXC_E_REG_21 = 5, /**< Register MXC_E_REG_21: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 103 | MXC_E_REG_30 = 6, /**< Register MXC_E_REG_30: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 104 | MXC_E_REG_31 = 7, /**< Register MXC_E_REG_31: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 105 | MXC_E_REG_40 = 8, /**< Register MXC_E_REG_40: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 106 | MXC_E_REG_41 = 9, /**< Register MXC_E_REG_41: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 107 | MXC_E_REG_50 = 10, /**< Register MXC_E_REG_50: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 108 | MXC_E_REG_51 = 11 /**< Register MXC_E_REG_51: If MAA_MAWS < 512 this is the register name. */ |
<> | 157:ff67d9f36b67 | 109 | } mxc_maa_reg_select_t; |
<> | 157:ff67d9f36b67 | 110 | |
<> | 157:ff67d9f36b67 | 111 | /** |
<> | 157:ff67d9f36b67 | 112 | * Enumeration type for MAA operation selection. |
<> | 157:ff67d9f36b67 | 113 | */ |
<> | 157:ff67d9f36b67 | 114 | typedef enum { |
<> | 157:ff67d9f36b67 | 115 | MXC_E_MAA_EXP = 0, /**< Exponentiate */ |
<> | 157:ff67d9f36b67 | 116 | MXC_E_MAA_SQR = 1, /**< Square */ |
<> | 157:ff67d9f36b67 | 117 | MXC_E_MAA_MUL = 2, /**< Multiply */ |
<> | 157:ff67d9f36b67 | 118 | MXC_E_MAA_SQRMUL = 3, /**< Square followed by Multiply */ |
<> | 157:ff67d9f36b67 | 119 | MXC_E_MAA_ADD = 4, /**< Addition */ |
<> | 157:ff67d9f36b67 | 120 | MXC_E_MAA_SUB = 5 /**< Subtraction */ |
<> | 157:ff67d9f36b67 | 121 | } mxc_maa_operation_t; |
<> | 157:ff67d9f36b67 | 122 | |
<> | 157:ff67d9f36b67 | 123 | /** |
<> | 157:ff67d9f36b67 | 124 | * Enumeration type to set special flags for loading & unloading data. |
<> | 157:ff67d9f36b67 | 125 | */ |
<> | 157:ff67d9f36b67 | 126 | typedef enum { |
<> | 157:ff67d9f36b67 | 127 | |
<> | 157:ff67d9f36b67 | 128 | MXC_E_MAA_VERBATIM = 0, /**< Copy bytes without reversal and right-justification */ |
<> | 157:ff67d9f36b67 | 129 | MXC_E_MAA_REVERSE /**< Reverse bytes and right-justify (bytes are loaded at the highest address, then descending) */ |
<> | 157:ff67d9f36b67 | 130 | } mxc_maa_endian_select_t; |
<> | 157:ff67d9f36b67 | 131 | |
<> | 157:ff67d9f36b67 | 132 | /** |
<> | 157:ff67d9f36b67 | 133 | * Enumeration type for MAA module specific return codes. |
<> | 157:ff67d9f36b67 | 134 | */ |
<> | 157:ff67d9f36b67 | 135 | typedef enum { |
<> | 157:ff67d9f36b67 | 136 | MXC_E_MAA_ERR = -1, /**< Error */ |
<> | 157:ff67d9f36b67 | 137 | MXC_E_MAA_OK = 0, /**< No Error */ |
<> | 157:ff67d9f36b67 | 138 | MXC_E_MAA_BUSY /**< MAA engine busy, try again later */ |
<> | 157:ff67d9f36b67 | 139 | } mxc_maa_ret_t; |
<> | 157:ff67d9f36b67 | 140 | |
<> | 157:ff67d9f36b67 | 141 | /** |
<> | 157:ff67d9f36b67 | 142 | * @brief Initialize the required clocks and enable the MAA peripheral |
<> | 157:ff67d9f36b67 | 143 | * module. |
<> | 157:ff67d9f36b67 | 144 | * @retval #MXC_E_MAA_ERR on error. |
<> | 157:ff67d9f36b67 | 145 | * @retval #MXC_E_MAA_BUSY if the MAA is busy. |
<> | 157:ff67d9f36b67 | 146 | * @retval #MXC_E_MAA_OK if the MAA is initialized successfully. |
<> | 157:ff67d9f36b67 | 147 | */ |
<> | 157:ff67d9f36b67 | 148 | mxc_maa_ret_t MAA_Init(void); |
<> | 157:ff67d9f36b67 | 149 | |
<> | 157:ff67d9f36b67 | 150 | /** |
<> | 157:ff67d9f36b67 | 151 | * @brief Erase all MAA register RAM |
<> | 157:ff67d9f36b67 | 152 | * @retval #MXC_E_MAA_ERR on error. |
<> | 157:ff67d9f36b67 | 153 | * @retval #MXC_E_MAA_BUSY if the MAA is busy. |
<> | 157:ff67d9f36b67 | 154 | * @retval #MXC_E_MAA_OK if the MAA is initialized successfully. |
<> | 157:ff67d9f36b67 | 155 | */ |
<> | 157:ff67d9f36b67 | 156 | mxc_maa_ret_t MAA_WipeRAM(void); |
<> | 157:ff67d9f36b67 | 157 | |
<> | 157:ff67d9f36b67 | 158 | |
<> | 157:ff67d9f36b67 | 159 | /** |
<> | 157:ff67d9f36b67 | 160 | * @brief Load the selected MAA register. |
<> | 157:ff67d9f36b67 | 161 | * |
<> | 157:ff67d9f36b67 | 162 | * @param regfile Selects the register to load. |
<> | 157:ff67d9f36b67 | 163 | * @param data Pointer to a data buffer to load into the register. |
<> | 157:ff67d9f36b67 | 164 | * @param size Size of the data to load. |
<> | 157:ff67d9f36b67 | 165 | * @param flag Reverse the data so that it will unload properly on |
<> | 157:ff67d9f36b67 | 166 | * little endian machines, see #mxc_maa_endian_select_t. |
<> | 157:ff67d9f36b67 | 167 | * |
<> | 157:ff67d9f36b67 | 168 | * @return #MXC_E_MAA_ERR if any parameter out of range. |
<> | 157:ff67d9f36b67 | 169 | * @return #MXC_E_MAA_BUSY if MAA registers are not currently accessible. |
<> | 157:ff67d9f36b67 | 170 | * @return #MXC_E_MAA_OK if the selected register is loaded correctly. |
<> | 157:ff67d9f36b67 | 171 | */ |
<> | 157:ff67d9f36b67 | 172 | mxc_maa_ret_t MAA_Load(mxc_maa_reg_select_t regfile, const uint8_t *data, unsigned int size, mxc_maa_endian_select_t flag); |
<> | 157:ff67d9f36b67 | 173 | |
<> | 157:ff67d9f36b67 | 174 | /** |
<> | 157:ff67d9f36b67 | 175 | * @brief Unload (copy from) the selected MAA register |
<> | 157:ff67d9f36b67 | 176 | * |
<> | 157:ff67d9f36b67 | 177 | * @param regfile Selects the register to unload. |
<> | 157:ff67d9f36b67 | 178 | * @param data Pointer to a buffer to store the unloaded data. |
<> | 157:ff67d9f36b67 | 179 | * @param size Maximum size of the data to unload. |
<> | 157:ff67d9f36b67 | 180 | * @param flag Reverse the data so that it will unload properly on |
<> | 157:ff67d9f36b67 | 181 | * little endian machines, see #mxc_maa_endian_select_t. |
<> | 157:ff67d9f36b67 | 182 | * @return #MXC_E_MAA_ERR if any parameter out of range. |
<> | 157:ff67d9f36b67 | 183 | * @return #MXC_E_MAA_BUSY if MAA registers are not currently accessible. |
<> | 157:ff67d9f36b67 | 184 | * @return #MXC_E_MAA_OK if the requested register data is copied correctly |
<> | 157:ff67d9f36b67 | 185 | * to @p data. |
<> | 157:ff67d9f36b67 | 186 | */ |
<> | 157:ff67d9f36b67 | 187 | mxc_maa_ret_t MAA_Unload(mxc_maa_reg_select_t regfile, uint8_t *data, unsigned int size, mxc_maa_endian_select_t flag); |
<> | 157:ff67d9f36b67 | 188 | |
<> | 157:ff67d9f36b67 | 189 | /** |
<> | 157:ff67d9f36b67 | 190 | * @brief Execute an MAA operation specified. |
<> | 157:ff67d9f36b67 | 191 | * |
<> | 157:ff67d9f36b67 | 192 | * @param op Operation to perform, see #mxc_maa_operation_t. |
<> | 157:ff67d9f36b67 | 193 | * @param al Segment to use for operand A, see #mxc_maa_reg_select_t. |
<> | 157:ff67d9f36b67 | 194 | * @param bl Segment to use for operand B. |
<> | 157:ff67d9f36b67 | 195 | * @param rl Segment which will hold result R after the operation is |
<> | 157:ff67d9f36b67 | 196 | * complete. |
<> | 157:ff67d9f36b67 | 197 | * @param tl Segment to use for temporary storage T. |
<> | 157:ff67d9f36b67 | 198 | * |
<> | 157:ff67d9f36b67 | 199 | * @return #MXC_E_MAA_ERR if any parameter out of range. |
<> | 157:ff67d9f36b67 | 200 | * @return #MXC_E_MAA_BUSY if MAA registers are not currently accessible. |
<> | 157:ff67d9f36b67 | 201 | * @return #MXC_E_MAA_OK if the operation completed. |
<> | 157:ff67d9f36b67 | 202 | */ |
<> | 157:ff67d9f36b67 | 203 | mxc_maa_ret_t MAA_Run(mxc_maa_operation_t op, \ |
<> | 157:ff67d9f36b67 | 204 | mxc_maa_reg_select_t al, mxc_maa_reg_select_t bl, \ |
<> | 157:ff67d9f36b67 | 205 | mxc_maa_reg_select_t rl, mxc_maa_reg_select_t tl); |
<> | 157:ff67d9f36b67 | 206 | |
<> | 157:ff67d9f36b67 | 207 | /** |
<> | 157:ff67d9f36b67 | 208 | * @brief Set the bit length of the modulus. |
<> | 157:ff67d9f36b67 | 209 | * |
<> | 157:ff67d9f36b67 | 210 | * @param len Modulus size in bits (ie. \f$ ln_2(modulus) \f$ ) |
<> | 157:ff67d9f36b67 | 211 | * |
<> | 157:ff67d9f36b67 | 212 | * @return #MXC_E_MAA_ERR if any parameter out of range. |
<> | 157:ff67d9f36b67 | 213 | * @return #MXC_E_MAA_BUSY if MAA registers are not currently accessible. |
<> | 157:ff67d9f36b67 | 214 | * @return #MXC_E_MAA_OK if the length is set as requested. |
<> | 157:ff67d9f36b67 | 215 | */ |
<> | 157:ff67d9f36b67 | 216 | mxc_maa_ret_t MAA_SetWordSize(unsigned int len); |
<> | 157:ff67d9f36b67 | 217 | |
<> | 157:ff67d9f36b67 | 218 | /**@} end of group maa*/ |
<> | 157:ff67d9f36b67 | 219 | |
<> | 157:ff67d9f36b67 | 220 | #ifdef __cplusplus |
<> | 157:ff67d9f36b67 | 221 | } |
<> | 157:ff67d9f36b67 | 222 | #endif |
<> | 157:ff67d9f36b67 | 223 | |
<> | 157:ff67d9f36b67 | 224 | #endif |