mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
186:707f6e361f3e
before add multi-configuration USB descriptors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 186:707f6e361f3e 1 /**
Anna Bridge 186:707f6e361f3e 2 * @file
Anna Bridge 186:707f6e361f3e 3 * @brief Pseudo-random number generator(PRNG) Peripheral Module.
Anna Bridge 186:707f6e361f3e 4 * @note The PRNG hardware does not produce true random numbers. The
Anna Bridge 186:707f6e361f3e 5 * output should be used as a seed to an approved random-number
Anna Bridge 186:707f6e361f3e 6 * algorithm, per a certifying authority such as NIST or PCI. The
Anna Bridge 186:707f6e361f3e 7 * approved algorithm will output random numbers which are cerfitied
Anna Bridge 186:707f6e361f3e 8 * for use in encryption and authentication algorithms.
Anna Bridge 186:707f6e361f3e 9 */
Anna Bridge 186:707f6e361f3e 10 /* ****************************************************************************
Anna Bridge 186:707f6e361f3e 11 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
Anna Bridge 186:707f6e361f3e 12 *
Anna Bridge 186:707f6e361f3e 13 * Permission is hereby granted, free of charge, to any person obtaining a
Anna Bridge 186:707f6e361f3e 14 * copy of this software and associated documentation files (the "Software"),
Anna Bridge 186:707f6e361f3e 15 * to deal in the Software without restriction, including without limitation
Anna Bridge 186:707f6e361f3e 16 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Anna Bridge 186:707f6e361f3e 17 * and/or sell copies of the Software, and to permit persons to whom the
Anna Bridge 186:707f6e361f3e 18 * Software is furnished to do so, subject to the following conditions:
Anna Bridge 186:707f6e361f3e 19 *
Anna Bridge 186:707f6e361f3e 20 * The above copyright notice and this permission notice shall be included
Anna Bridge 186:707f6e361f3e 21 * in all copies or substantial portions of the Software.
Anna Bridge 186:707f6e361f3e 22 *
Anna Bridge 186:707f6e361f3e 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Anna Bridge 186:707f6e361f3e 24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Anna Bridge 186:707f6e361f3e 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Anna Bridge 186:707f6e361f3e 26 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Anna Bridge 186:707f6e361f3e 27 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Anna Bridge 186:707f6e361f3e 28 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Anna Bridge 186:707f6e361f3e 29 * OTHER DEALINGS IN THE SOFTWARE.
Anna Bridge 186:707f6e361f3e 30 *
Anna Bridge 186:707f6e361f3e 31 * Except as contained in this notice, the name of Maxim Integrated
Anna Bridge 186:707f6e361f3e 32 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Anna Bridge 186:707f6e361f3e 33 * Products, Inc. Branding Policy.
Anna Bridge 186:707f6e361f3e 34 *
Anna Bridge 186:707f6e361f3e 35 * The mere transfer of this software does not imply any licenses
Anna Bridge 186:707f6e361f3e 36 * of trade secrets, proprietary technology, copyrights, patents,
Anna Bridge 186:707f6e361f3e 37 * trademarks, maskwork rights, or any other form of intellectual
Anna Bridge 186:707f6e361f3e 38 * property whatsoever. Maxim Integrated Products, Inc. retains all
Anna Bridge 186:707f6e361f3e 39 * ownership rights.
Anna Bridge 186:707f6e361f3e 40 *
Anna Bridge 186:707f6e361f3e 41 * $Date: 2016-10-10 19:26:15 -0500 (Mon, 10 Oct 2016) $
Anna Bridge 186:707f6e361f3e 42 * $Revision: 24668 $
Anna Bridge 186:707f6e361f3e 43 *
Anna Bridge 186:707f6e361f3e 44 ******************************************************************************/
Anna Bridge 186:707f6e361f3e 45
Anna Bridge 186:707f6e361f3e 46 /* **** Includes **** */
Anna Bridge 186:707f6e361f3e 47 #include "prng_regs.h"
Anna Bridge 186:707f6e361f3e 48
Anna Bridge 186:707f6e361f3e 49 /* Define to prevent redundant inclusion */
Anna Bridge 186:707f6e361f3e 50 #ifndef _PRNG_H_
Anna Bridge 186:707f6e361f3e 51 #define _PRNG_H_
Anna Bridge 186:707f6e361f3e 52
Anna Bridge 186:707f6e361f3e 53 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 54 extern "C" {
Anna Bridge 186:707f6e361f3e 55 #endif
Anna Bridge 186:707f6e361f3e 56
Anna Bridge 186:707f6e361f3e 57 /**
Anna Bridge 186:707f6e361f3e 58 * @ingroup periphlibs
Anna Bridge 186:707f6e361f3e 59 * @defgroup prng Pseudo-Random Number Generator (PRNG)
Anna Bridge 186:707f6e361f3e 60 * @brief Pseudo-random number generator(PRNG) Peripheral Module.
Anna Bridge 186:707f6e361f3e 61 * @note The PRNG hardware does not produce true random numbers. The
Anna Bridge 186:707f6e361f3e 62 * output should be used as a seed to an approved random-number
Anna Bridge 186:707f6e361f3e 63 * algorithm, per a certifying authority such as NIST or PCI. The
Anna Bridge 186:707f6e361f3e 64 * approved algorithm will output random numbers which are cerfitied
Anna Bridge 186:707f6e361f3e 65 * for use in encryption and authentication algorithms.
Anna Bridge 186:707f6e361f3e 66 * @{
Anna Bridge 186:707f6e361f3e 67 */
Anna Bridge 186:707f6e361f3e 68
Anna Bridge 186:707f6e361f3e 69 /* **** Definitions **** */
Anna Bridge 186:707f6e361f3e 70
Anna Bridge 186:707f6e361f3e 71 /* **** Globals **** */
Anna Bridge 186:707f6e361f3e 72
Anna Bridge 186:707f6e361f3e 73 /* **** Function Prototypes **** */
Anna Bridge 186:707f6e361f3e 74
Anna Bridge 186:707f6e361f3e 75 /**
Anna Bridge 186:707f6e361f3e 76 * @brief Initialize required clocks and enable PRNG module
Anna Bridge 186:707f6e361f3e 77 * @note This function will set the clock divisors to divide by 1 if they are disabled.
Anna Bridge 186:707f6e361f3e 78 * Otherwise, the clock divisors are left unchanged.
Anna Bridge 186:707f6e361f3e 79 */
Anna Bridge 186:707f6e361f3e 80 void PRNG_Init(void);
Anna Bridge 186:707f6e361f3e 81
Anna Bridge 186:707f6e361f3e 82 /**
Anna Bridge 186:707f6e361f3e 83 * @brief Returns ready bit to indicates that the PRNG_GetSeed can be
Anna Bridge 186:707f6e361f3e 84 * called without being held off. Only needs to be called one time after a POR event.
Anna Bridge 186:707f6e361f3e 85 *
Anna Bridge 186:707f6e361f3e 86 * @retval 0 PRNG not ready
Anna Bridge 186:707f6e361f3e 87 * @retval non-zero PRNG ready to read
Anna Bridge 186:707f6e361f3e 88 */
Anna Bridge 186:707f6e361f3e 89 __STATIC_INLINE uint16_t PRNG_Ready(void)
Anna Bridge 186:707f6e361f3e 90 {
Anna Bridge 186:707f6e361f3e 91 return (MXC_PRNG->user_entropy & MXC_F_PRNG_USER_ENTROPY_RND_NUM_READY);
Anna Bridge 186:707f6e361f3e 92 }
Anna Bridge 186:707f6e361f3e 93
Anna Bridge 186:707f6e361f3e 94 /**
Anna Bridge 186:707f6e361f3e 95 * @brief Retrieve a seed value from the PRNG.
Anna Bridge 186:707f6e361f3e 96 * @note The PRNG hardware does not produce true random numbers. The
Anna Bridge 186:707f6e361f3e 97 * output should be used as a seed to an approved random-number
Anna Bridge 186:707f6e361f3e 98 * algorithm, per a certifying authority such as NIST or PCI. The
Anna Bridge 186:707f6e361f3e 99 * approved algorithm will output random numbers which are cerfitied
Anna Bridge 186:707f6e361f3e 100 * for use in encryption and authentication algorithms.
Anna Bridge 186:707f6e361f3e 101 *
Anna Bridge 186:707f6e361f3e 102 * @return 16-bit seed value
Anna Bridge 186:707f6e361f3e 103 */
Anna Bridge 186:707f6e361f3e 104 __STATIC_INLINE uint16_t PRNG_GetSeed(void)
Anna Bridge 186:707f6e361f3e 105 {
Anna Bridge 186:707f6e361f3e 106 return MXC_PRNG->rnd_num;
Anna Bridge 186:707f6e361f3e 107 }
Anna Bridge 186:707f6e361f3e 108
Anna Bridge 186:707f6e361f3e 109 /**
Anna Bridge 186:707f6e361f3e 110 * @brief Add user entropy to the PRNG entropy source.
Anna Bridge 186:707f6e361f3e 111 *
Anna Bridge 186:707f6e361f3e 112 * @param entropy A value to be mixed into the PRNG entropy source.
Anna Bridge 186:707f6e361f3e 113 */
Anna Bridge 186:707f6e361f3e 114 __STATIC_INLINE void PRNG_AddUserEntropy(uint8_t entropy)
Anna Bridge 186:707f6e361f3e 115 {
Anna Bridge 186:707f6e361f3e 116 MXC_PRNG->user_entropy = (uint32_t)entropy;
Anna Bridge 186:707f6e361f3e 117 }
Anna Bridge 186:707f6e361f3e 118 /**@}*/
Anna Bridge 186:707f6e361f3e 119 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 120 }
Anna Bridge 186:707f6e361f3e 121 #endif
Anna Bridge 186:707f6e361f3e 122
Anna Bridge 186:707f6e361f3e 123 #endif /* _PRNG_H_ */