1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
32 #if defined(__ANDROID__) || defined(__linux__)
35 // MEGA has 16 input pins whereas Due has only 12 input pins
36 #define ANALOG_IN (10)
40 * Seed the random number generator. Seeding depends on platform.
41 * Android and Linux uses current time. Arduino uses Analog reading on pin ANALOG_IN
42 * @retval 0 for Success, otherwise some error value
44 int8_t OCSeedRandom();
47 * Generate a uniformly [0,2^32] distributed random number
48 * @retval On Success, it returns the random value.
50 uint32_t OCGetRandom();
53 * Generate a uniformly [0,2^8] distributed random number
54 * @retval On Success, it returns the random value, otherwise -1 for error.
56 uint8_t OCGetRandomByte(void);
59 * Generate a uniformly distributed 8-bit (byte) array random numbers
60 * @param[out] location
61 * memory location to start filling with random bytes
63 * length of array to be filled with random bytes
65 void OCFillRandomMem(uint8_t * location, uint16_t len);
68 * Generate a uniformly distributed number on the defined bounded range
69 * @param[in] firstBound
70 * the first bound of the range
71 * @param[in] secondBound
72 * the second bound of the range
74 uint32_t OCGetRandomRange(uint32_t firstBound, uint32_t secondBound);