cc y / mbed

Fork of mbed by mbed official

Committer:
kaoshen
Date:
Tue Jan 17 23:27:32 2017 +0000
Revision:
135:fce8a9387ed1
Parent:
129:0ab6a29f35bf
333 ADS1115 ADC1

Who changed what in which revision?

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