The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 08 11:45:42 2018 +0000
Revision:
171:3a7713b1edbc
Parent:
TARGET_MAX32625PICO/TARGET_Maxim/TARGET_MAX32625/mxc/prng.h@169:a7c7b631e539
mbed library. Release version 164

Who changed what in which revision?

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