Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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