Read NTP time from Ethernet and drive six 7-segment LEDs using a MAX7221 to show time, date, month, week, year etc....

Dependencies:   NTPClient_NetServices mbed

Committer:
cheungderek
Date:
Wed Jun 22 01:31:47 2011 +0000
Revision:
0:e083abcfe7a8
First release.
Just some testing but working code to read NTP time and drive 6 LEDs to display time, date, month, year etc...

Who changed what in which revision?

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