Ethernet for Nucleo and Disco board STM32F746 works with gcc and arm. IAC is untested

Fork of F7_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sun Jun 19 16:23:40 2016 +0000
Revision:
0:d26c1b55cfca
Ethernet Library for Nucleo stm32f746ZG and Disco stm32f746NG  works under arm and gcc environment

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DieterGraef 0:d26c1b55cfca 1 /* Copyright (C) 2012 mbed.org, MIT License
DieterGraef 0:d26c1b55cfca 2 *
DieterGraef 0:d26c1b55cfca 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
DieterGraef 0:d26c1b55cfca 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
DieterGraef 0:d26c1b55cfca 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
DieterGraef 0:d26c1b55cfca 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
DieterGraef 0:d26c1b55cfca 7 * furnished to do so, subject to the following conditions:
DieterGraef 0:d26c1b55cfca 8 *
DieterGraef 0:d26c1b55cfca 9 * The above copyright notice and this permission notice shall be included in all copies or
DieterGraef 0:d26c1b55cfca 10 * substantial portions of the Software.
DieterGraef 0:d26c1b55cfca 11 *
DieterGraef 0:d26c1b55cfca 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
DieterGraef 0:d26c1b55cfca 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
DieterGraef 0:d26c1b55cfca 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DieterGraef 0:d26c1b55cfca 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
DieterGraef 0:d26c1b55cfca 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DieterGraef 0:d26c1b55cfca 17 */
DieterGraef 0:d26c1b55cfca 18
DieterGraef 0:d26c1b55cfca 19 #ifndef TCPSOCKET_H
DieterGraef 0:d26c1b55cfca 20 #define TCPSOCKET_H
DieterGraef 0:d26c1b55cfca 21
DieterGraef 0:d26c1b55cfca 22 #include "Socket/Socket.h"
DieterGraef 0:d26c1b55cfca 23 #include "Socket/Endpoint.h"
DieterGraef 0:d26c1b55cfca 24 #include "lwip/tcp.h"
DieterGraef 0:d26c1b55cfca 25
DieterGraef 0:d26c1b55cfca 26 /**
DieterGraef 0:d26c1b55cfca 27 TCP socket connection
DieterGraef 0:d26c1b55cfca 28 */
DieterGraef 0:d26c1b55cfca 29 class TCPSocketConnection : public Socket, public Endpoint {
DieterGraef 0:d26c1b55cfca 30 friend class TCPSocketServer;
DieterGraef 0:d26c1b55cfca 31
DieterGraef 0:d26c1b55cfca 32 public:
DieterGraef 0:d26c1b55cfca 33 /** TCP socket connection
DieterGraef 0:d26c1b55cfca 34 */
DieterGraef 0:d26c1b55cfca 35 TCPSocketConnection();
DieterGraef 0:d26c1b55cfca 36
DieterGraef 0:d26c1b55cfca 37 /** sets the next port used from tcp_new_port
DieterGraef 0:d26c1b55cfca 38 \param port The host's port to connect to.
DieterGraef 0:d26c1b55cfca 39 \return 0
DieterGraef 0:d26c1b55cfca 40 */
DieterGraef 0:d26c1b55cfca 41 int set_source_port(const int port);
DieterGraef 0:d26c1b55cfca 42
DieterGraef 0:d26c1b55cfca 43 /** Connects this TCP socket to the server
DieterGraef 0:d26c1b55cfca 44 \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
DieterGraef 0:d26c1b55cfca 45 \param port The host's port to connect to.
DieterGraef 0:d26c1b55cfca 46 \return 0 on success, -1 on failure.
DieterGraef 0:d26c1b55cfca 47 */
DieterGraef 0:d26c1b55cfca 48 int connect(const char* host, const int port);
DieterGraef 0:d26c1b55cfca 49
DieterGraef 0:d26c1b55cfca 50 /** Check if the socket is connected
DieterGraef 0:d26c1b55cfca 51 \return true if connected, false otherwise.
DieterGraef 0:d26c1b55cfca 52 */
DieterGraef 0:d26c1b55cfca 53 bool is_connected(void);
DieterGraef 0:d26c1b55cfca 54
DieterGraef 0:d26c1b55cfca 55 /** Send data to the remote host.
DieterGraef 0:d26c1b55cfca 56 \param data The buffer to send to the host.
DieterGraef 0:d26c1b55cfca 57 \param length The length of the buffer to send.
DieterGraef 0:d26c1b55cfca 58 \return the number of written bytes on success (>=0) or -1 on failure
DieterGraef 0:d26c1b55cfca 59 */
DieterGraef 0:d26c1b55cfca 60 int send(char* data, int length);
DieterGraef 0:d26c1b55cfca 61
DieterGraef 0:d26c1b55cfca 62 /** Send all the data to the remote host.
DieterGraef 0:d26c1b55cfca 63 \param data The buffer to send to the host.
DieterGraef 0:d26c1b55cfca 64 \param length The length of the buffer to send.
DieterGraef 0:d26c1b55cfca 65 \return the number of written bytes on success (>=0) or -1 on failure
DieterGraef 0:d26c1b55cfca 66 */
DieterGraef 0:d26c1b55cfca 67 int send_all(char* data, int length);
DieterGraef 0:d26c1b55cfca 68
DieterGraef 0:d26c1b55cfca 69 /** Receive data from the remote host.
DieterGraef 0:d26c1b55cfca 70 \param data The buffer in which to store the data received from the host.
DieterGraef 0:d26c1b55cfca 71 \param length The maximum length of the buffer.
DieterGraef 0:d26c1b55cfca 72 \return the number of received bytes on success (>=0) or -1 on failure
DieterGraef 0:d26c1b55cfca 73 */
DieterGraef 0:d26c1b55cfca 74 int receive(char* data, int length);
DieterGraef 0:d26c1b55cfca 75
DieterGraef 0:d26c1b55cfca 76 /** Receive all the data from the remote host.
DieterGraef 0:d26c1b55cfca 77 \param data The buffer in which to store the data received from the host.
DieterGraef 0:d26c1b55cfca 78 \param length The maximum length of the buffer.
DieterGraef 0:d26c1b55cfca 79 \return the number of received bytes on success (>=0) or -1 on failure
DieterGraef 0:d26c1b55cfca 80 */
DieterGraef 0:d26c1b55cfca 81 int receive_all(char* data, int length);
DieterGraef 0:d26c1b55cfca 82
DieterGraef 0:d26c1b55cfca 83 private:
DieterGraef 0:d26c1b55cfca 84 bool _is_connected;
DieterGraef 0:d26c1b55cfca 85 };
DieterGraef 0:d26c1b55cfca 86
DieterGraef 0:d26c1b55cfca 87 #endif