fft

Dependencies:   BSP_DISCO_F746NG SDFileSystem_Warning_Fixed

Committer:
MikamiUitOpen
Date:
Sun Oct 09 10:11:14 2016 +0000
Revision:
0:3e46577dc273
1

Who changed what in which revision?

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