Tried to initialize the buttons and slider but couldn't get it to work.

Dependencies:   mbed

Committer:
mturner5
Date:
Mon Sep 19 03:28:41 2016 +0000
Revision:
0:0d6b77c9ae01
basic v2;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mturner5 0:0d6b77c9ae01 1 /* mbed Microcontroller Library
mturner5 0:0d6b77c9ae01 2 * Copyright (c) 2006-2013 ARM Limited
mturner5 0:0d6b77c9ae01 3 *
mturner5 0:0d6b77c9ae01 4 * Licensed under the Apache License, Version 2.0 (the "License");
mturner5 0:0d6b77c9ae01 5 * you may not use this file except in compliance with the License.
mturner5 0:0d6b77c9ae01 6 * You may obtain a copy of the License at
mturner5 0:0d6b77c9ae01 7 *
mturner5 0:0d6b77c9ae01 8 * http://www.apache.org/licenses/LICENSE-2.0
mturner5 0:0d6b77c9ae01 9 *
mturner5 0:0d6b77c9ae01 10 * Unless required by applicable law or agreed to in writing, software
mturner5 0:0d6b77c9ae01 11 * distributed under the License is distributed on an "AS IS" BASIS,
mturner5 0:0d6b77c9ae01 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mturner5 0:0d6b77c9ae01 13 * See the License for the specific language governing permissions and
mturner5 0:0d6b77c9ae01 14 * limitations under the License.
mturner5 0:0d6b77c9ae01 15 */
mturner5 0:0d6b77c9ae01 16 #ifndef MBED_ETHERNET_H
mturner5 0:0d6b77c9ae01 17 #define MBED_ETHERNET_H
mturner5 0:0d6b77c9ae01 18
mturner5 0:0d6b77c9ae01 19 #include "platform.h"
mturner5 0:0d6b77c9ae01 20
mturner5 0:0d6b77c9ae01 21 #if DEVICE_ETHERNET
mturner5 0:0d6b77c9ae01 22
mturner5 0:0d6b77c9ae01 23 namespace mbed {
mturner5 0:0d6b77c9ae01 24
mturner5 0:0d6b77c9ae01 25 /** An ethernet interface, to use with the ethernet pins.
mturner5 0:0d6b77c9ae01 26 *
mturner5 0:0d6b77c9ae01 27 * Example:
mturner5 0:0d6b77c9ae01 28 * @code
mturner5 0:0d6b77c9ae01 29 * // Read destination and source from every ethernet packet
mturner5 0:0d6b77c9ae01 30 *
mturner5 0:0d6b77c9ae01 31 * #include "mbed.h"
mturner5 0:0d6b77c9ae01 32 *
mturner5 0:0d6b77c9ae01 33 * Ethernet eth;
mturner5 0:0d6b77c9ae01 34 *
mturner5 0:0d6b77c9ae01 35 * int main() {
mturner5 0:0d6b77c9ae01 36 * char buf[0x600];
mturner5 0:0d6b77c9ae01 37 *
mturner5 0:0d6b77c9ae01 38 * while(1) {
mturner5 0:0d6b77c9ae01 39 * int size = eth.receive();
mturner5 0:0d6b77c9ae01 40 * if(size > 0) {
mturner5 0:0d6b77c9ae01 41 * eth.read(buf, size);
mturner5 0:0d6b77c9ae01 42 * printf("Destination: %02X:%02X:%02X:%02X:%02X:%02X\n",
mturner5 0:0d6b77c9ae01 43 * buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
mturner5 0:0d6b77c9ae01 44 * printf("Source: %02X:%02X:%02X:%02X:%02X:%02X\n",
mturner5 0:0d6b77c9ae01 45 * buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
mturner5 0:0d6b77c9ae01 46 * }
mturner5 0:0d6b77c9ae01 47 *
mturner5 0:0d6b77c9ae01 48 * wait(1);
mturner5 0:0d6b77c9ae01 49 * }
mturner5 0:0d6b77c9ae01 50 * }
mturner5 0:0d6b77c9ae01 51 * @endcode
mturner5 0:0d6b77c9ae01 52 */
mturner5 0:0d6b77c9ae01 53 class Ethernet {
mturner5 0:0d6b77c9ae01 54
mturner5 0:0d6b77c9ae01 55 public:
mturner5 0:0d6b77c9ae01 56
mturner5 0:0d6b77c9ae01 57 /** Initialise the ethernet interface.
mturner5 0:0d6b77c9ae01 58 */
mturner5 0:0d6b77c9ae01 59 Ethernet();
mturner5 0:0d6b77c9ae01 60
mturner5 0:0d6b77c9ae01 61 /** Powers the hardware down.
mturner5 0:0d6b77c9ae01 62 */
mturner5 0:0d6b77c9ae01 63 virtual ~Ethernet();
mturner5 0:0d6b77c9ae01 64
mturner5 0:0d6b77c9ae01 65 enum Mode {
mturner5 0:0d6b77c9ae01 66 AutoNegotiate,
mturner5 0:0d6b77c9ae01 67 HalfDuplex10,
mturner5 0:0d6b77c9ae01 68 FullDuplex10,
mturner5 0:0d6b77c9ae01 69 HalfDuplex100,
mturner5 0:0d6b77c9ae01 70 FullDuplex100
mturner5 0:0d6b77c9ae01 71 };
mturner5 0:0d6b77c9ae01 72
mturner5 0:0d6b77c9ae01 73 /** Writes into an outgoing ethernet packet.
mturner5 0:0d6b77c9ae01 74 *
mturner5 0:0d6b77c9ae01 75 * It will append size bytes of data to the previously written bytes.
mturner5 0:0d6b77c9ae01 76 *
mturner5 0:0d6b77c9ae01 77 * @param data An array to write.
mturner5 0:0d6b77c9ae01 78 * @param size The size of data.
mturner5 0:0d6b77c9ae01 79 *
mturner5 0:0d6b77c9ae01 80 * @returns
mturner5 0:0d6b77c9ae01 81 * The number of written bytes.
mturner5 0:0d6b77c9ae01 82 */
mturner5 0:0d6b77c9ae01 83 int write(const char *data, int size);
mturner5 0:0d6b77c9ae01 84
mturner5 0:0d6b77c9ae01 85 /** Send an outgoing ethernet packet.
mturner5 0:0d6b77c9ae01 86 *
mturner5 0:0d6b77c9ae01 87 * After filling in the data in an ethernet packet it must be send.
mturner5 0:0d6b77c9ae01 88 * Send will provide a new packet to write to.
mturner5 0:0d6b77c9ae01 89 *
mturner5 0:0d6b77c9ae01 90 * @returns
mturner5 0:0d6b77c9ae01 91 * 0 if the sending was failed,
mturner5 0:0d6b77c9ae01 92 * or the size of the packet successfully sent.
mturner5 0:0d6b77c9ae01 93 */
mturner5 0:0d6b77c9ae01 94 int send();
mturner5 0:0d6b77c9ae01 95
mturner5 0:0d6b77c9ae01 96 /** Recevies an arrived ethernet packet.
mturner5 0:0d6b77c9ae01 97 *
mturner5 0:0d6b77c9ae01 98 * Receiving an ethernet packet will drop the last received ethernet packet
mturner5 0:0d6b77c9ae01 99 * and make a new ethernet packet ready to read.
mturner5 0:0d6b77c9ae01 100 * If no ethernet packet is arrived it will return 0.
mturner5 0:0d6b77c9ae01 101 *
mturner5 0:0d6b77c9ae01 102 * @returns
mturner5 0:0d6b77c9ae01 103 * 0 if no ethernet packet is arrived,
mturner5 0:0d6b77c9ae01 104 * or the size of the arrived packet.
mturner5 0:0d6b77c9ae01 105 */
mturner5 0:0d6b77c9ae01 106 int receive();
mturner5 0:0d6b77c9ae01 107
mturner5 0:0d6b77c9ae01 108 /** Read from an recevied ethernet packet.
mturner5 0:0d6b77c9ae01 109 *
mturner5 0:0d6b77c9ae01 110 * After receive returnd a number bigger than 0it is
mturner5 0:0d6b77c9ae01 111 * possible to read bytes from this packet.
mturner5 0:0d6b77c9ae01 112 * Read will write up to size bytes into data.
mturner5 0:0d6b77c9ae01 113 *
mturner5 0:0d6b77c9ae01 114 * It is possible to use read multible times.
mturner5 0:0d6b77c9ae01 115 * Each time read will start reading after the last read byte before.
mturner5 0:0d6b77c9ae01 116 *
mturner5 0:0d6b77c9ae01 117 * @returns
mturner5 0:0d6b77c9ae01 118 * The number of byte read.
mturner5 0:0d6b77c9ae01 119 */
mturner5 0:0d6b77c9ae01 120 int read(char *data, int size);
mturner5 0:0d6b77c9ae01 121
mturner5 0:0d6b77c9ae01 122 /** Gives the ethernet address of the mbed.
mturner5 0:0d6b77c9ae01 123 *
mturner5 0:0d6b77c9ae01 124 * @param mac Must be a pointer to a 6 byte char array to copy the ethernet address in.
mturner5 0:0d6b77c9ae01 125 */
mturner5 0:0d6b77c9ae01 126 void address(char *mac);
mturner5 0:0d6b77c9ae01 127
mturner5 0:0d6b77c9ae01 128 /** Returns if an ethernet link is pressent or not. It takes a wile after Ethernet initializion to show up.
mturner5 0:0d6b77c9ae01 129 *
mturner5 0:0d6b77c9ae01 130 * @returns
mturner5 0:0d6b77c9ae01 131 * 0 if no ethernet link is pressent,
mturner5 0:0d6b77c9ae01 132 * 1 if an ethernet link is pressent.
mturner5 0:0d6b77c9ae01 133 *
mturner5 0:0d6b77c9ae01 134 * Example:
mturner5 0:0d6b77c9ae01 135 * @code
mturner5 0:0d6b77c9ae01 136 * // Using the Ethernet link function
mturner5 0:0d6b77c9ae01 137 * #include "mbed.h"
mturner5 0:0d6b77c9ae01 138 *
mturner5 0:0d6b77c9ae01 139 * Ethernet eth;
mturner5 0:0d6b77c9ae01 140 *
mturner5 0:0d6b77c9ae01 141 * int main() {
mturner5 0:0d6b77c9ae01 142 * wait(1); // Needed after startup.
mturner5 0:0d6b77c9ae01 143 * if (eth.link()) {
mturner5 0:0d6b77c9ae01 144 * printf("online\n");
mturner5 0:0d6b77c9ae01 145 * } else {
mturner5 0:0d6b77c9ae01 146 * printf("offline\n");
mturner5 0:0d6b77c9ae01 147 * }
mturner5 0:0d6b77c9ae01 148 * }
mturner5 0:0d6b77c9ae01 149 * @endcode
mturner5 0:0d6b77c9ae01 150 */
mturner5 0:0d6b77c9ae01 151 int link();
mturner5 0:0d6b77c9ae01 152
mturner5 0:0d6b77c9ae01 153 /** Sets the speed and duplex parameters of an ethernet link
mturner5 0:0d6b77c9ae01 154 *
mturner5 0:0d6b77c9ae01 155 * - AutoNegotiate Auto negotiate speed and duplex
mturner5 0:0d6b77c9ae01 156 * - HalfDuplex10 10 Mbit, half duplex
mturner5 0:0d6b77c9ae01 157 * - FullDuplex10 10 Mbit, full duplex
mturner5 0:0d6b77c9ae01 158 * - HalfDuplex100 100 Mbit, half duplex
mturner5 0:0d6b77c9ae01 159 * - FullDuplex100 100 Mbit, full duplex
mturner5 0:0d6b77c9ae01 160 *
mturner5 0:0d6b77c9ae01 161 * @param mode the speed and duplex mode to set the link to:
mturner5 0:0d6b77c9ae01 162 */
mturner5 0:0d6b77c9ae01 163 void set_link(Mode mode);
mturner5 0:0d6b77c9ae01 164 };
mturner5 0:0d6b77c9ae01 165
mturner5 0:0d6b77c9ae01 166 } // namespace mbed
mturner5 0:0d6b77c9ae01 167
mturner5 0:0d6b77c9ae01 168 #endif
mturner5 0:0d6b77c9ae01 169
mturner5 0:0d6b77c9ae01 170 #endif