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
LPC1768/if/net/netif.h@0:e083abcfe7a8, 2011-06-22 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
cheungderek | 0:e083abcfe7a8 | 1 | |
cheungderek | 0:e083abcfe7a8 | 2 | /* |
cheungderek | 0:e083abcfe7a8 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
cheungderek | 0:e083abcfe7a8 | 4 | |
cheungderek | 0:e083abcfe7a8 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
cheungderek | 0:e083abcfe7a8 | 6 | of this software and associated documentation files (the "Software"), to deal |
cheungderek | 0:e083abcfe7a8 | 7 | in the Software without restriction, including without limitation the rights |
cheungderek | 0:e083abcfe7a8 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
cheungderek | 0:e083abcfe7a8 | 9 | copies of the Software, and to permit persons to whom the Software is |
cheungderek | 0:e083abcfe7a8 | 10 | furnished to do so, subject to the following conditions: |
cheungderek | 0:e083abcfe7a8 | 11 | |
cheungderek | 0:e083abcfe7a8 | 12 | The above copyright notice and this permission notice shall be included in |
cheungderek | 0:e083abcfe7a8 | 13 | all copies or substantial portions of the Software. |
cheungderek | 0:e083abcfe7a8 | 14 | |
cheungderek | 0:e083abcfe7a8 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
cheungderek | 0:e083abcfe7a8 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
cheungderek | 0:e083abcfe7a8 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
cheungderek | 0:e083abcfe7a8 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
cheungderek | 0:e083abcfe7a8 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
cheungderek | 0:e083abcfe7a8 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
cheungderek | 0:e083abcfe7a8 | 21 | THE SOFTWARE. |
cheungderek | 0:e083abcfe7a8 | 22 | */ |
cheungderek | 0:e083abcfe7a8 | 23 | |
cheungderek | 0:e083abcfe7a8 | 24 | #ifndef NETIF_H |
cheungderek | 0:e083abcfe7a8 | 25 | #define NETIF_H |
cheungderek | 0:e083abcfe7a8 | 26 | |
cheungderek | 0:e083abcfe7a8 | 27 | #include "core/ipaddr.h" |
cheungderek | 0:e083abcfe7a8 | 28 | /* |
cheungderek | 0:e083abcfe7a8 | 29 | #include "nettcpsocket.h" |
cheungderek | 0:e083abcfe7a8 | 30 | #include "netudpsocket.h" |
cheungderek | 0:e083abcfe7a8 | 31 | #include "netdnsrequest.h" |
cheungderek | 0:e083abcfe7a8 | 32 | */ |
cheungderek | 0:e083abcfe7a8 | 33 | class NetTcpSocket; |
cheungderek | 0:e083abcfe7a8 | 34 | class NetUdpSocket; |
cheungderek | 0:e083abcfe7a8 | 35 | class NetDnsRequest; |
cheungderek | 0:e083abcfe7a8 | 36 | |
cheungderek | 0:e083abcfe7a8 | 37 | #if 0 |
cheungderek | 0:e083abcfe7a8 | 38 | enum NetifEvent |
cheungderek | 0:e083abcfe7a8 | 39 | { |
cheungderek | 0:e083abcfe7a8 | 40 | NETIF_CONNECTED, //Connected, can create & use sockets now |
cheungderek | 0:e083abcfe7a8 | 41 | NETIF_DNSREPLY, |
cheungderek | 0:e083abcfe7a8 | 42 | NETIF_DISCONNECTED |
cheungderek | 0:e083abcfe7a8 | 43 | }; |
cheungderek | 0:e083abcfe7a8 | 44 | #endif |
cheungderek | 0:e083abcfe7a8 | 45 | |
cheungderek | 0:e083abcfe7a8 | 46 | class NetIf |
cheungderek | 0:e083abcfe7a8 | 47 | { |
cheungderek | 0:e083abcfe7a8 | 48 | public: |
cheungderek | 0:e083abcfe7a8 | 49 | NetIf(); |
cheungderek | 0:e083abcfe7a8 | 50 | virtual ~NetIf(); |
cheungderek | 0:e083abcfe7a8 | 51 | virtual NetTcpSocket* tcpSocket() = 0; //Create a new tcp socket |
cheungderek | 0:e083abcfe7a8 | 52 | virtual NetUdpSocket* udpSocket() = 0; //Create a new udp socket |
cheungderek | 0:e083abcfe7a8 | 53 | virtual void poll() = 0; |
cheungderek | 0:e083abcfe7a8 | 54 | virtual NetDnsRequest* dnsRequest(const char* hostname) = 0; //Create a new NetDnsRequest object |
cheungderek | 0:e083abcfe7a8 | 55 | virtual NetDnsRequest* dnsRequest(Host* pHost) = 0; //Create a new NetDnsRequest object |
cheungderek | 0:e083abcfe7a8 | 56 | |
cheungderek | 0:e083abcfe7a8 | 57 | //!Returns the IP of the interface once it's connected |
cheungderek | 0:e083abcfe7a8 | 58 | IpAddr getIp() const; |
cheungderek | 0:e083abcfe7a8 | 59 | |
cheungderek | 0:e083abcfe7a8 | 60 | protected: |
cheungderek | 0:e083abcfe7a8 | 61 | IpAddr m_ip; |
cheungderek | 0:e083abcfe7a8 | 62 | }; |
cheungderek | 0:e083abcfe7a8 | 63 | |
cheungderek | 0:e083abcfe7a8 | 64 | #endif |