![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/targets/TARGET_WICED/wiced_interface/wiced_emac.h@0:8fdf9a60065b, 2018-10-10 (annotated)
- Committer:
- kadonotakashi
- Date:
- Wed Oct 10 00:33:53 2018 +0000
- Revision:
- 0:8fdf9a60065b
how to make mbed librry
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | /* |
kadonotakashi | 0:8fdf9a60065b | 2 | * Copyright (c) 2018 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 3 | * |
kadonotakashi | 0:8fdf9a60065b | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 5 | * you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 6 | * You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 7 | * |
kadonotakashi | 0:8fdf9a60065b | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 9 | * |
kadonotakashi | 0:8fdf9a60065b | 10 | * Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 13 | * See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 14 | * limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 15 | */ |
kadonotakashi | 0:8fdf9a60065b | 16 | |
kadonotakashi | 0:8fdf9a60065b | 17 | #ifndef WICED_EMAC_H_ |
kadonotakashi | 0:8fdf9a60065b | 18 | #define WICED_EMAC_H_ |
kadonotakashi | 0:8fdf9a60065b | 19 | |
kadonotakashi | 0:8fdf9a60065b | 20 | #include "EMAC.h" |
kadonotakashi | 0:8fdf9a60065b | 21 | #include "EMACInterface.h" |
kadonotakashi | 0:8fdf9a60065b | 22 | #include "WiFiInterface.h" |
kadonotakashi | 0:8fdf9a60065b | 23 | |
kadonotakashi | 0:8fdf9a60065b | 24 | #include "rtos/Semaphore.h" |
kadonotakashi | 0:8fdf9a60065b | 25 | #include "rtos/Mutex.h" |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | class WICED_EMAC : public EMAC { |
kadonotakashi | 0:8fdf9a60065b | 28 | public: |
kadonotakashi | 0:8fdf9a60065b | 29 | WICED_EMAC(); |
kadonotakashi | 0:8fdf9a60065b | 30 | |
kadonotakashi | 0:8fdf9a60065b | 31 | static WICED_EMAC &get_instance(); |
kadonotakashi | 0:8fdf9a60065b | 32 | |
kadonotakashi | 0:8fdf9a60065b | 33 | /** |
kadonotakashi | 0:8fdf9a60065b | 34 | * Return maximum transmission unit |
kadonotakashi | 0:8fdf9a60065b | 35 | * |
kadonotakashi | 0:8fdf9a60065b | 36 | * @return MTU in bytes |
kadonotakashi | 0:8fdf9a60065b | 37 | */ |
kadonotakashi | 0:8fdf9a60065b | 38 | virtual uint32_t get_mtu_size() const; |
kadonotakashi | 0:8fdf9a60065b | 39 | |
kadonotakashi | 0:8fdf9a60065b | 40 | /** |
kadonotakashi | 0:8fdf9a60065b | 41 | * Gets memory buffer alignment preference |
kadonotakashi | 0:8fdf9a60065b | 42 | * |
kadonotakashi | 0:8fdf9a60065b | 43 | * Gets preferred memory buffer alignment of the Emac device. IP stack may or may not |
kadonotakashi | 0:8fdf9a60065b | 44 | * align link out memory buffer chains using the alignment. |
kadonotakashi | 0:8fdf9a60065b | 45 | * |
kadonotakashi | 0:8fdf9a60065b | 46 | * @return Memory alignment requirement in bytes |
kadonotakashi | 0:8fdf9a60065b | 47 | */ |
kadonotakashi | 0:8fdf9a60065b | 48 | virtual uint32_t get_align_preference() const; |
kadonotakashi | 0:8fdf9a60065b | 49 | |
kadonotakashi | 0:8fdf9a60065b | 50 | /** |
kadonotakashi | 0:8fdf9a60065b | 51 | * Return interface name |
kadonotakashi | 0:8fdf9a60065b | 52 | * |
kadonotakashi | 0:8fdf9a60065b | 53 | * @param name Pointer to where the name should be written |
kadonotakashi | 0:8fdf9a60065b | 54 | * @param size Maximum number of character to copy |
kadonotakashi | 0:8fdf9a60065b | 55 | */ |
kadonotakashi | 0:8fdf9a60065b | 56 | virtual void get_ifname(char *name, uint8_t size) const; |
kadonotakashi | 0:8fdf9a60065b | 57 | |
kadonotakashi | 0:8fdf9a60065b | 58 | /** |
kadonotakashi | 0:8fdf9a60065b | 59 | * Returns size of the underlying interface HW address size. |
kadonotakashi | 0:8fdf9a60065b | 60 | * |
kadonotakashi | 0:8fdf9a60065b | 61 | * @return HW address size in bytes |
kadonotakashi | 0:8fdf9a60065b | 62 | */ |
kadonotakashi | 0:8fdf9a60065b | 63 | virtual uint8_t get_hwaddr_size() const; |
kadonotakashi | 0:8fdf9a60065b | 64 | |
kadonotakashi | 0:8fdf9a60065b | 65 | /** |
kadonotakashi | 0:8fdf9a60065b | 66 | * Return interface-supplied HW address |
kadonotakashi | 0:8fdf9a60065b | 67 | * |
kadonotakashi | 0:8fdf9a60065b | 68 | * Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size |
kadonotakashi | 0:8fdf9a60065b | 69 | * |
kadonotakashi | 0:8fdf9a60065b | 70 | * HW address need not be provided if this interface does not have its own HW |
kadonotakashi | 0:8fdf9a60065b | 71 | * address configuration; stack will choose address from central system |
kadonotakashi | 0:8fdf9a60065b | 72 | * configuration if the function returns false and does not write to addr. |
kadonotakashi | 0:8fdf9a60065b | 73 | * |
kadonotakashi | 0:8fdf9a60065b | 74 | * @param addr HW address for underlying interface |
kadonotakashi | 0:8fdf9a60065b | 75 | * @return true if HW address is available |
kadonotakashi | 0:8fdf9a60065b | 76 | */ |
kadonotakashi | 0:8fdf9a60065b | 77 | virtual bool get_hwaddr(uint8_t *addr) const; |
kadonotakashi | 0:8fdf9a60065b | 78 | |
kadonotakashi | 0:8fdf9a60065b | 79 | /** |
kadonotakashi | 0:8fdf9a60065b | 80 | * Set HW address for interface |
kadonotakashi | 0:8fdf9a60065b | 81 | * |
kadonotakashi | 0:8fdf9a60065b | 82 | * Provided address has to be of correct size, see @a get_hwaddr_size |
kadonotakashi | 0:8fdf9a60065b | 83 | * |
kadonotakashi | 0:8fdf9a60065b | 84 | * Called to set the MAC address to actually use - if @a get_hwaddr is provided |
kadonotakashi | 0:8fdf9a60065b | 85 | * the stack would normally use that, but it could be overridden, eg for test |
kadonotakashi | 0:8fdf9a60065b | 86 | * purposes. |
kadonotakashi | 0:8fdf9a60065b | 87 | * |
kadonotakashi | 0:8fdf9a60065b | 88 | * @param addr Address to be set |
kadonotakashi | 0:8fdf9a60065b | 89 | */ |
kadonotakashi | 0:8fdf9a60065b | 90 | virtual void set_hwaddr(const uint8_t *addr); |
kadonotakashi | 0:8fdf9a60065b | 91 | |
kadonotakashi | 0:8fdf9a60065b | 92 | /** |
kadonotakashi | 0:8fdf9a60065b | 93 | * Sends the packet over the link |
kadonotakashi | 0:8fdf9a60065b | 94 | * |
kadonotakashi | 0:8fdf9a60065b | 95 | * That can not be called from an interrupt context. |
kadonotakashi | 0:8fdf9a60065b | 96 | * |
kadonotakashi | 0:8fdf9a60065b | 97 | * @param buf Packet to be send |
kadonotakashi | 0:8fdf9a60065b | 98 | * @return True if the packet was send successfully, False otherwise |
kadonotakashi | 0:8fdf9a60065b | 99 | */ |
kadonotakashi | 0:8fdf9a60065b | 100 | virtual bool link_out(emac_mem_buf_t *buf); |
kadonotakashi | 0:8fdf9a60065b | 101 | |
kadonotakashi | 0:8fdf9a60065b | 102 | /** |
kadonotakashi | 0:8fdf9a60065b | 103 | * Initializes the HW |
kadonotakashi | 0:8fdf9a60065b | 104 | * |
kadonotakashi | 0:8fdf9a60065b | 105 | * @return True on success, False in case of an error. |
kadonotakashi | 0:8fdf9a60065b | 106 | */ |
kadonotakashi | 0:8fdf9a60065b | 107 | virtual bool power_up(); |
kadonotakashi | 0:8fdf9a60065b | 108 | |
kadonotakashi | 0:8fdf9a60065b | 109 | /** |
kadonotakashi | 0:8fdf9a60065b | 110 | * Deinitializes the HW |
kadonotakashi | 0:8fdf9a60065b | 111 | * |
kadonotakashi | 0:8fdf9a60065b | 112 | */ |
kadonotakashi | 0:8fdf9a60065b | 113 | virtual void power_down(); |
kadonotakashi | 0:8fdf9a60065b | 114 | |
kadonotakashi | 0:8fdf9a60065b | 115 | /** |
kadonotakashi | 0:8fdf9a60065b | 116 | * Sets a callback that needs to be called for packets received for that interface |
kadonotakashi | 0:8fdf9a60065b | 117 | * |
kadonotakashi | 0:8fdf9a60065b | 118 | * @param input_cb Function to be register as a callback |
kadonotakashi | 0:8fdf9a60065b | 119 | */ |
kadonotakashi | 0:8fdf9a60065b | 120 | virtual void set_link_input_cb(emac_link_input_cb_t input_cb); |
kadonotakashi | 0:8fdf9a60065b | 121 | |
kadonotakashi | 0:8fdf9a60065b | 122 | /** |
kadonotakashi | 0:8fdf9a60065b | 123 | * Sets a callback that needs to be called on link status changes for given interface |
kadonotakashi | 0:8fdf9a60065b | 124 | * |
kadonotakashi | 0:8fdf9a60065b | 125 | * @param state_cb Function to be register as a callback |
kadonotakashi | 0:8fdf9a60065b | 126 | */ |
kadonotakashi | 0:8fdf9a60065b | 127 | virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb); |
kadonotakashi | 0:8fdf9a60065b | 128 | |
kadonotakashi | 0:8fdf9a60065b | 129 | /** Add device to a multicast group |
kadonotakashi | 0:8fdf9a60065b | 130 | * |
kadonotakashi | 0:8fdf9a60065b | 131 | * @param address A multicast group hardware address |
kadonotakashi | 0:8fdf9a60065b | 132 | */ |
kadonotakashi | 0:8fdf9a60065b | 133 | virtual void add_multicast_group(const uint8_t *address); |
kadonotakashi | 0:8fdf9a60065b | 134 | |
kadonotakashi | 0:8fdf9a60065b | 135 | /** Remove device from a multicast group |
kadonotakashi | 0:8fdf9a60065b | 136 | * |
kadonotakashi | 0:8fdf9a60065b | 137 | * @param address A multicast group hardware address |
kadonotakashi | 0:8fdf9a60065b | 138 | */ |
kadonotakashi | 0:8fdf9a60065b | 139 | virtual void remove_multicast_group(const uint8_t *address); |
kadonotakashi | 0:8fdf9a60065b | 140 | |
kadonotakashi | 0:8fdf9a60065b | 141 | /** Request reception of all multicast packets |
kadonotakashi | 0:8fdf9a60065b | 142 | * |
kadonotakashi | 0:8fdf9a60065b | 143 | * @param all True to receive all multicasts |
kadonotakashi | 0:8fdf9a60065b | 144 | * False to receive only multicasts addressed to specified groups |
kadonotakashi | 0:8fdf9a60065b | 145 | */ |
kadonotakashi | 0:8fdf9a60065b | 146 | virtual void set_all_multicast(bool all); |
kadonotakashi | 0:8fdf9a60065b | 147 | |
kadonotakashi | 0:8fdf9a60065b | 148 | /** Sets memory manager that is used to handle memory buffers |
kadonotakashi | 0:8fdf9a60065b | 149 | * |
kadonotakashi | 0:8fdf9a60065b | 150 | * @param mem_mngr Pointer to memory manager |
kadonotakashi | 0:8fdf9a60065b | 151 | */ |
kadonotakashi | 0:8fdf9a60065b | 152 | virtual void set_memory_manager(EMACMemoryManager &mem_mngr); |
kadonotakashi | 0:8fdf9a60065b | 153 | |
kadonotakashi | 0:8fdf9a60065b | 154 | emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */ |
kadonotakashi | 0:8fdf9a60065b | 155 | emac_link_state_change_cb_t emac_link_state_cb; |
kadonotakashi | 0:8fdf9a60065b | 156 | EMACMemoryManager *memory_manager; |
kadonotakashi | 0:8fdf9a60065b | 157 | |
kadonotakashi | 0:8fdf9a60065b | 158 | }; |
kadonotakashi | 0:8fdf9a60065b | 159 | |
kadonotakashi | 0:8fdf9a60065b | 160 | #endif /* WICED_EMAC_H_ */ |