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:
Fri Feb 11 10:17:20 2011 +0000
Revision:
1:995212d326ca
Parent:
0:f30e2135b0db
V0.0.0.2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Yann 0:f30e2135b0db 1 /*****************************************************************************
Yann 0:f30e2135b0db 2 * magic.c - Network Random Number Generator program file.
Yann 0:f30e2135b0db 3 *
Yann 0:f30e2135b0db 4 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
Yann 0:f30e2135b0db 5 * portions Copyright (c) 1997 by 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 * 97-12-04 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
Yann 0:f30e2135b0db 31 * Original based on BSD magic.c.
Yann 0:f30e2135b0db 32 *****************************************************************************/
Yann 0:f30e2135b0db 33 /*
Yann 0:f30e2135b0db 34 * magic.c - PPP Magic Number routines.
Yann 0:f30e2135b0db 35 *
Yann 0:f30e2135b0db 36 * Copyright (c) 1989 Carnegie Mellon University.
Yann 0:f30e2135b0db 37 * All rights reserved.
Yann 0:f30e2135b0db 38 *
Yann 0:f30e2135b0db 39 * Redistribution and use in source and binary forms are permitted
Yann 0:f30e2135b0db 40 * provided that the above copyright notice and this paragraph are
Yann 0:f30e2135b0db 41 * duplicated in all such forms and that any documentation,
Yann 0:f30e2135b0db 42 * advertising materials, and other materials related to such
Yann 0:f30e2135b0db 43 * distribution and use acknowledge that the software was developed
Yann 0:f30e2135b0db 44 * by Carnegie Mellon University. The name of the
Yann 0:f30e2135b0db 45 * University may not be used to endorse or promote products derived
Yann 0:f30e2135b0db 46 * from this software without specific prior written permission.
Yann 0:f30e2135b0db 47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
Yann 0:f30e2135b0db 48 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
Yann 0:f30e2135b0db 49 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Yann 0:f30e2135b0db 50 */
Yann 0:f30e2135b0db 51
Yann 0:f30e2135b0db 52 #include "lwip/opt.h"
Yann 0:f30e2135b0db 53
Yann 0:f30e2135b0db 54 #if PPP_SUPPORT
Yann 0:f30e2135b0db 55
Yann 0:f30e2135b0db 56 #include "ppp.h"
Yann 0:f30e2135b0db 57 #include "randm.h"
Yann 0:f30e2135b0db 58 #include "magic.h"
Yann 0:f30e2135b0db 59
Yann 0:f30e2135b0db 60
Yann 0:f30e2135b0db 61 /*
Yann 0:f30e2135b0db 62 * magicInit - Initialize the magic number generator.
Yann 0:f30e2135b0db 63 *
Yann 0:f30e2135b0db 64 * Since we use another random number generator that has its own
Yann 0:f30e2135b0db 65 * initialization, we do nothing here.
Yann 0:f30e2135b0db 66 */
Yann 0:f30e2135b0db 67 void magicInit()
Yann 0:f30e2135b0db 68 {
Yann 0:f30e2135b0db 69 return;
Yann 0:f30e2135b0db 70 }
Yann 0:f30e2135b0db 71
Yann 0:f30e2135b0db 72 /*
Yann 0:f30e2135b0db 73 * magic - Returns the next magic number.
Yann 0:f30e2135b0db 74 */
Yann 0:f30e2135b0db 75 u32_t magic()
Yann 0:f30e2135b0db 76 {
Yann 0:f30e2135b0db 77 return avRandom();
Yann 0:f30e2135b0db 78 }
Yann 0:f30e2135b0db 79
Yann 0:f30e2135b0db 80 #endif /* PPP_SUPPORT */