This short program illustrates how to use the DS130x_I2C library. My objective is to share the same RTC with Microchip 18F MCU.

Dependencies:   mbed DebugLibrary

Committer:
Yann
Date:
Wed Feb 09 13:57:49 2011 +0000
Revision:
0:f30e2135b0db
V0.0.0.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yann 0:f30e2135b0db 1 /*****************************************************************************
Yann 0:f30e2135b0db 2 * randm.h - Random number generator header file.
Yann 0:f30e2135b0db 3 *
Yann 0:f30e2135b0db 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
Yann 0:f30e2135b0db 5 * Copyright (c) 1998 Global Election Systems Inc.
Yann 0:f30e2135b0db 6 *
Yann 0:f30e2135b0db 7 * The authors hereby grant permission to use, copy, modify, distribute,
Yann 0:f30e2135b0db 8 * and license this software and its documentation for any purpose, provided
Yann 0:f30e2135b0db 9 * that existing copyright notices are retained in all copies and that this
Yann 0:f30e2135b0db 10 * notice and the following disclaimer are included verbatim in any
Yann 0:f30e2135b0db 11 * distributions. No written agreement, license, or royalty fee is required
Yann 0:f30e2135b0db 12 * for any of the authorized uses.
Yann 0:f30e2135b0db 13 *
Yann 0:f30e2135b0db 14 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
Yann 0:f30e2135b0db 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Yann 0:f30e2135b0db 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
Yann 0:f30e2135b0db 17 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
Yann 0:f30e2135b0db 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
Yann 0:f30e2135b0db 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Yann 0:f30e2135b0db 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Yann 0:f30e2135b0db 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Yann 0:f30e2135b0db 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
Yann 0:f30e2135b0db 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Yann 0:f30e2135b0db 24 *
Yann 0:f30e2135b0db 25 ******************************************************************************
Yann 0:f30e2135b0db 26 * REVISION HISTORY
Yann 0:f30e2135b0db 27 *
Yann 0:f30e2135b0db 28 * 03-01-01 Marc Boucher <marc@mbsi.ca>
Yann 0:f30e2135b0db 29 * Ported to lwIP.
Yann 0:f30e2135b0db 30 * 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc.
Yann 0:f30e2135b0db 31 * Extracted from avos.
Yann 0:f30e2135b0db 32 *****************************************************************************/
Yann 0:f30e2135b0db 33
Yann 0:f30e2135b0db 34 #ifndef RANDM_H
Yann 0:f30e2135b0db 35 #define RANDM_H
Yann 0:f30e2135b0db 36
Yann 0:f30e2135b0db 37 /***********************
Yann 0:f30e2135b0db 38 *** PUBLIC FUNCTIONS ***
Yann 0:f30e2135b0db 39 ***********************/
Yann 0:f30e2135b0db 40 /*
Yann 0:f30e2135b0db 41 * Initialize the random number generator.
Yann 0:f30e2135b0db 42 */
Yann 0:f30e2135b0db 43 void avRandomInit(void);
Yann 0:f30e2135b0db 44
Yann 0:f30e2135b0db 45 /*
Yann 0:f30e2135b0db 46 * Churn the randomness pool on a random event. Call this early and often
Yann 0:f30e2135b0db 47 * on random and semi-random system events to build randomness in time for
Yann 0:f30e2135b0db 48 * usage. For randomly timed events, pass a null pointer and a zero length
Yann 0:f30e2135b0db 49 * and this will use the system timer and other sources to add randomness.
Yann 0:f30e2135b0db 50 * If new random data is available, pass a pointer to that and it will be
Yann 0:f30e2135b0db 51 * included.
Yann 0:f30e2135b0db 52 */
Yann 0:f30e2135b0db 53 void avChurnRand(char *randData, u32_t randLen);
Yann 0:f30e2135b0db 54
Yann 0:f30e2135b0db 55 /*
Yann 0:f30e2135b0db 56 * Randomize our random seed value. To be called for truely random events
Yann 0:f30e2135b0db 57 * such as user operations and network traffic.
Yann 0:f30e2135b0db 58 */
Yann 0:f30e2135b0db 59 #if MD5_SUPPORT
Yann 0:f30e2135b0db 60 #define avRandomize() avChurnRand(NULL, 0)
Yann 0:f30e2135b0db 61 #else /* MD5_SUPPORT */
Yann 0:f30e2135b0db 62 void avRandomize(void);
Yann 0:f30e2135b0db 63 #endif /* MD5_SUPPORT */
Yann 0:f30e2135b0db 64
Yann 0:f30e2135b0db 65 /*
Yann 0:f30e2135b0db 66 * Use the random pool to generate random data. This degrades to pseudo
Yann 0:f30e2135b0db 67 * random when used faster than randomness is supplied using churnRand().
Yann 0:f30e2135b0db 68 * Thus it's important to make sure that the results of this are not
Yann 0:f30e2135b0db 69 * published directly because one could predict the next result to at
Yann 0:f30e2135b0db 70 * least some degree. Also, it's important to get a good seed before
Yann 0:f30e2135b0db 71 * the first use.
Yann 0:f30e2135b0db 72 */
Yann 0:f30e2135b0db 73 void avGenRand(char *buf, u32_t bufLen);
Yann 0:f30e2135b0db 74
Yann 0:f30e2135b0db 75 /*
Yann 0:f30e2135b0db 76 * Return a new random number.
Yann 0:f30e2135b0db 77 */
Yann 0:f30e2135b0db 78 u32_t avRandom(void);
Yann 0:f30e2135b0db 79
Yann 0:f30e2135b0db 80
Yann 0:f30e2135b0db 81 #endif /* RANDM_H */