TCP/IP based digital io controller for operating DigitalsOuts and reading DigitalIns.

Dependencies:   EthernetInterface NetworkAPI mbed-rtos mbed

Fork of NetRelais by Roy van Dam

Committer:
NegativeBlack
Date:
Thu Sep 27 10:00:27 2012 +0000
Revision:
11:e5375ae5c8c3
Parent:
10:22d49341340c
Updated project to latest revision of the NetworkAPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NegativeBlack 10:22d49341340c 1 /**
NegativeBlack 10:22d49341340c 2 * Copyright (c) 2012, Roy van Dam <roy@vandam-innovations.com>
NegativeBlack 10:22d49341340c 3 * All rights reserved.
NegativeBlack 10:22d49341340c 4 *
NegativeBlack 10:22d49341340c 5 * Redistribution and use in source and binary forms, with or without
NegativeBlack 10:22d49341340c 6 * modification, are permitted provided that the following conditions are met:
NegativeBlack 10:22d49341340c 7 *
NegativeBlack 10:22d49341340c 8 * 1. Redistributions of source code must retain the above copyright notice, this
NegativeBlack 10:22d49341340c 9 * list of conditions and the following disclaimer.
NegativeBlack 10:22d49341340c 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
NegativeBlack 10:22d49341340c 11 * this list of conditions and the following disclaimer in the documentation
NegativeBlack 10:22d49341340c 12 * and/or other materials provided with the distribution.
NegativeBlack 10:22d49341340c 13 *
NegativeBlack 10:22d49341340c 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
NegativeBlack 10:22d49341340c 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
NegativeBlack 10:22d49341340c 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NegativeBlack 10:22d49341340c 17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
NegativeBlack 10:22d49341340c 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
NegativeBlack 10:22d49341340c 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
NegativeBlack 10:22d49341340c 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
NegativeBlack 10:22d49341340c 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
NegativeBlack 10:22d49341340c 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
NegativeBlack 10:22d49341340c 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NegativeBlack 10:22d49341340c 24 */
NegativeBlack 10:22d49341340c 25
donatien 0:bb128f0e952f 26 #include "mbed.h"
donatien 0:bb128f0e952f 27 #include "EthernetInterface.h"
donatien 0:bb128f0e952f 28
NegativeBlack 10:22d49341340c 29 #include "io.hpp"
NegativeBlack 10:22d49341340c 30 #include "controller.hpp"
donatien 0:bb128f0e952f 31
NegativeBlack 6:33b57f606f2b 32 int
NegativeBlack 6:33b57f606f2b 33 main()
NegativeBlack 6:33b57f606f2b 34 {
NegativeBlack 6:33b57f606f2b 35 EthernetInterface interface;
NegativeBlack 6:33b57f606f2b 36 interface.init();
NegativeBlack 6:33b57f606f2b 37 interface.connect();
NegativeBlack 9:a4c85bea2d77 38
NegativeBlack 10:22d49341340c 39 printf("IP Address: %s\n\r", interface.getIPAddress());
NegativeBlack 8:d55cac25e637 40
NegativeBlack 10:22d49341340c 41 Controller controller;
NegativeBlack 10:22d49341340c 42 for (int i = 0; i < 5; i++) {
NegativeBlack 10:22d49341340c 43 controller.addOutput(&io::output[i]);
NegativeBlack 8:d55cac25e637 44 }
donatien 0:bb128f0e952f 45
NegativeBlack 10:22d49341340c 46 for (int i = 0; i < 4; i++) {
NegativeBlack 10:22d49341340c 47 controller.addOutput(&io::led[i]);
NegativeBlack 10:22d49341340c 48 }
NegativeBlack 10:22d49341340c 49
NegativeBlack 10:22d49341340c 50 for (int i = 0; i < 4; i++) {
NegativeBlack 10:22d49341340c 51 controller.addInput(&io::input[i]);
NegativeBlack 10:22d49341340c 52 }
NegativeBlack 10:22d49341340c 53
NegativeBlack 10:22d49341340c 54 controller.start();
NegativeBlack 10:22d49341340c 55 controller.dispatch();
NegativeBlack 6:33b57f606f2b 56 }