Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Thu Oct 11 02:27:46 2018 +0000
Revision:
3:f3764f852aa8
Parent:
0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 /*
kadonotakashi 0:8fdf9a60065b 2 * Copyright (c) 2017, Arm Limited and affiliates.
kadonotakashi 0:8fdf9a60065b 3 * SPDX-License-Identifier: Apache-2.0
kadonotakashi 0:8fdf9a60065b 4 *
kadonotakashi 0:8fdf9a60065b 5 * Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 6 * you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 7 * You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 8 *
kadonotakashi 0:8fdf9a60065b 9 * http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 10 *
kadonotakashi 0:8fdf9a60065b 11 * Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 12 * distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 14 * See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 15 * limitations under the License.
kadonotakashi 0:8fdf9a60065b 16 */
kadonotakashi 0:8fdf9a60065b 17
kadonotakashi 0:8fdf9a60065b 18 #ifndef NETWORKSTACKSTUB_H
kadonotakashi 0:8fdf9a60065b 19 #define NETWORKSTACKSTUB_H
kadonotakashi 0:8fdf9a60065b 20
kadonotakashi 0:8fdf9a60065b 21 #include "netsocket/NetworkStack.h"
kadonotakashi 0:8fdf9a60065b 22 #include <list>
kadonotakashi 0:8fdf9a60065b 23
kadonotakashi 0:8fdf9a60065b 24 class NetworkStackstub : public NetworkStack {
kadonotakashi 0:8fdf9a60065b 25 public:
kadonotakashi 0:8fdf9a60065b 26 std::list<nsapi_error_t> return_values;
kadonotakashi 0:8fdf9a60065b 27 nsapi_error_t return_value = 0;
kadonotakashi 0:8fdf9a60065b 28 virtual const char *get_ip_address()
kadonotakashi 0:8fdf9a60065b 29 {
kadonotakashi 0:8fdf9a60065b 30 return "127.0.0.1";
kadonotakashi 0:8fdf9a60065b 31 }
kadonotakashi 0:8fdf9a60065b 32 virtual nsapi_error_t gethostbyname(const char *host,
kadonotakashi 0:8fdf9a60065b 33 SocketAddress *address, nsapi_version_t version)
kadonotakashi 0:8fdf9a60065b 34 {
kadonotakashi 0:8fdf9a60065b 35 return return_value;
kadonotakashi 0:8fdf9a60065b 36 }
kadonotakashi 0:8fdf9a60065b 37 virtual nsapi_value_or_error_t gethostbyname_async(const char *host, hostbyname_cb_t callback,
kadonotakashi 0:8fdf9a60065b 38 nsapi_version_t version)
kadonotakashi 0:8fdf9a60065b 39 {
kadonotakashi 0:8fdf9a60065b 40 return return_value;
kadonotakashi 0:8fdf9a60065b 41 }
kadonotakashi 0:8fdf9a60065b 42 virtual nsapi_error_t gethostbyname_async_cancel(int id)
kadonotakashi 0:8fdf9a60065b 43 {
kadonotakashi 0:8fdf9a60065b 44 return return_value;
kadonotakashi 0:8fdf9a60065b 45 }
kadonotakashi 0:8fdf9a60065b 46
kadonotakashi 0:8fdf9a60065b 47 protected:
kadonotakashi 0:8fdf9a60065b 48 virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
kadonotakashi 0:8fdf9a60065b 49 {
kadonotakashi 0:8fdf9a60065b 50 if (return_value == NSAPI_ERROR_OK && return_values.front() == NSAPI_ERROR_OK)
kadonotakashi 0:8fdf9a60065b 51 {
kadonotakashi 0:8fdf9a60065b 52 // Make sure a non-NULL value is returned if error is not expected
kadonotakashi 0:8fdf9a60065b 53 *handle = reinterpret_cast<nsapi_socket_t*>(1234);
kadonotakashi 0:8fdf9a60065b 54 }
kadonotakashi 0:8fdf9a60065b 55 return return_value;
kadonotakashi 0:8fdf9a60065b 56 };
kadonotakashi 0:8fdf9a60065b 57 virtual nsapi_error_t socket_close(nsapi_socket_t handle)
kadonotakashi 0:8fdf9a60065b 58 {
kadonotakashi 0:8fdf9a60065b 59 return return_value;
kadonotakashi 0:8fdf9a60065b 60 };
kadonotakashi 0:8fdf9a60065b 61 virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address)
kadonotakashi 0:8fdf9a60065b 62 {
kadonotakashi 0:8fdf9a60065b 63 return return_value;
kadonotakashi 0:8fdf9a60065b 64 };
kadonotakashi 0:8fdf9a60065b 65 virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)
kadonotakashi 0:8fdf9a60065b 66 {
kadonotakashi 0:8fdf9a60065b 67 return return_value;
kadonotakashi 0:8fdf9a60065b 68 };
kadonotakashi 0:8fdf9a60065b 69 virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
kadonotakashi 0:8fdf9a60065b 70 {
kadonotakashi 0:8fdf9a60065b 71 if (!return_values.empty())
kadonotakashi 0:8fdf9a60065b 72 {
kadonotakashi 0:8fdf9a60065b 73 nsapi_error_t ret = return_values.front();
kadonotakashi 0:8fdf9a60065b 74 return_values.pop_front();
kadonotakashi 0:8fdf9a60065b 75 return ret;
kadonotakashi 0:8fdf9a60065b 76 }
kadonotakashi 0:8fdf9a60065b 77 return return_value;
kadonotakashi 0:8fdf9a60065b 78 };
kadonotakashi 0:8fdf9a60065b 79 virtual nsapi_error_t socket_accept(nsapi_socket_t server,
kadonotakashi 0:8fdf9a60065b 80 nsapi_socket_t *handle, SocketAddress *address = 0)
kadonotakashi 0:8fdf9a60065b 81 {
kadonotakashi 0:8fdf9a60065b 82 return return_value;
kadonotakashi 0:8fdf9a60065b 83 };
kadonotakashi 0:8fdf9a60065b 84 virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
kadonotakashi 0:8fdf9a60065b 85 const void *data, nsapi_size_t size)
kadonotakashi 0:8fdf9a60065b 86 {
kadonotakashi 0:8fdf9a60065b 87 if (!return_values.empty())
kadonotakashi 0:8fdf9a60065b 88 {
kadonotakashi 0:8fdf9a60065b 89 nsapi_error_t ret = return_values.front();
kadonotakashi 0:8fdf9a60065b 90 return_values.pop_front();
kadonotakashi 0:8fdf9a60065b 91 return ret;
kadonotakashi 0:8fdf9a60065b 92 }
kadonotakashi 0:8fdf9a60065b 93 return return_value;
kadonotakashi 0:8fdf9a60065b 94 };
kadonotakashi 0:8fdf9a60065b 95 virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
kadonotakashi 0:8fdf9a60065b 96 void *data, nsapi_size_t size)
kadonotakashi 0:8fdf9a60065b 97 {
kadonotakashi 0:8fdf9a60065b 98 if (!return_values.empty())
kadonotakashi 0:8fdf9a60065b 99 {
kadonotakashi 0:8fdf9a60065b 100 nsapi_error_t ret = return_values.front();
kadonotakashi 0:8fdf9a60065b 101 return_values.pop_front();
kadonotakashi 0:8fdf9a60065b 102 return ret;
kadonotakashi 0:8fdf9a60065b 103 }
kadonotakashi 0:8fdf9a60065b 104 return return_value;
kadonotakashi 0:8fdf9a60065b 105 };
kadonotakashi 0:8fdf9a60065b 106 virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address,
kadonotakashi 0:8fdf9a60065b 107 const void *data, nsapi_size_t size)
kadonotakashi 0:8fdf9a60065b 108 {
kadonotakashi 0:8fdf9a60065b 109 return return_value;
kadonotakashi 0:8fdf9a60065b 110 };
kadonotakashi 0:8fdf9a60065b 111 virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
kadonotakashi 0:8fdf9a60065b 112 void *buffer, nsapi_size_t size)
kadonotakashi 0:8fdf9a60065b 113 {
kadonotakashi 0:8fdf9a60065b 114 if (!return_values.empty())
kadonotakashi 0:8fdf9a60065b 115 {
kadonotakashi 0:8fdf9a60065b 116 nsapi_error_t ret = return_values.front();
kadonotakashi 0:8fdf9a60065b 117 return_values.pop_front();
kadonotakashi 0:8fdf9a60065b 118 return ret;
kadonotakashi 0:8fdf9a60065b 119 }
kadonotakashi 0:8fdf9a60065b 120 return return_value;
kadonotakashi 0:8fdf9a60065b 121 };
kadonotakashi 0:8fdf9a60065b 122 virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data) {};
kadonotakashi 0:8fdf9a60065b 123
kadonotakashi 0:8fdf9a60065b 124 private:
kadonotakashi 0:8fdf9a60065b 125 virtual nsapi_error_t call_in(int delay, mbed::Callback<void()> func)
kadonotakashi 0:8fdf9a60065b 126 {
kadonotakashi 0:8fdf9a60065b 127 return return_value;
kadonotakashi 0:8fdf9a60065b 128 }
kadonotakashi 0:8fdf9a60065b 129 };
kadonotakashi 0:8fdf9a60065b 130
kadonotakashi 0:8fdf9a60065b 131 #endif // NETWORKSTACKSTUB_H