Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
drivers/Ethernet.cpp@170:54ff26da7eb6, 2017-07-04 (annotated)
- Committer:
- thedo
- Date:
- Tue Jul 04 06:23:13 2017 +0000
- Revision:
- 170:54ff26da7eb6
- Parent:
- 167:1657b442184c
project opencv 3.1 on GR PEACH board, no use SD card.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 167:1657b442184c | 1 | /* mbed Microcontroller Library |
thedo | 167:1657b442184c | 2 | * Copyright (c) 2006-2013 ARM Limited |
thedo | 167:1657b442184c | 3 | * |
thedo | 167:1657b442184c | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
thedo | 167:1657b442184c | 5 | * you may not use this file except in compliance with the License. |
thedo | 167:1657b442184c | 6 | * You may obtain a copy of the License at |
thedo | 167:1657b442184c | 7 | * |
thedo | 167:1657b442184c | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
thedo | 167:1657b442184c | 9 | * |
thedo | 167:1657b442184c | 10 | * Unless required by applicable law or agreed to in writing, software |
thedo | 167:1657b442184c | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
thedo | 167:1657b442184c | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
thedo | 167:1657b442184c | 13 | * See the License for the specific language governing permissions and |
thedo | 167:1657b442184c | 14 | * limitations under the License. |
thedo | 167:1657b442184c | 15 | */ |
thedo | 167:1657b442184c | 16 | #include "drivers/Ethernet.h" |
thedo | 167:1657b442184c | 17 | |
thedo | 167:1657b442184c | 18 | #if DEVICE_ETHERNET |
thedo | 167:1657b442184c | 19 | |
thedo | 167:1657b442184c | 20 | #include "hal/ethernet_api.h" |
thedo | 167:1657b442184c | 21 | |
thedo | 167:1657b442184c | 22 | namespace mbed { |
thedo | 167:1657b442184c | 23 | |
thedo | 167:1657b442184c | 24 | Ethernet::Ethernet() { |
thedo | 167:1657b442184c | 25 | ethernet_init(); |
thedo | 167:1657b442184c | 26 | } |
thedo | 167:1657b442184c | 27 | |
thedo | 167:1657b442184c | 28 | Ethernet::~Ethernet() { |
thedo | 167:1657b442184c | 29 | ethernet_free(); |
thedo | 167:1657b442184c | 30 | } |
thedo | 167:1657b442184c | 31 | |
thedo | 167:1657b442184c | 32 | int Ethernet::write(const char *data, int size) { |
thedo | 167:1657b442184c | 33 | return ethernet_write(data, size); |
thedo | 167:1657b442184c | 34 | } |
thedo | 167:1657b442184c | 35 | |
thedo | 167:1657b442184c | 36 | int Ethernet::send() { |
thedo | 167:1657b442184c | 37 | return ethernet_send(); |
thedo | 167:1657b442184c | 38 | } |
thedo | 167:1657b442184c | 39 | |
thedo | 167:1657b442184c | 40 | int Ethernet::receive() { |
thedo | 167:1657b442184c | 41 | return ethernet_receive(); |
thedo | 167:1657b442184c | 42 | } |
thedo | 167:1657b442184c | 43 | |
thedo | 167:1657b442184c | 44 | int Ethernet::read(char *data, int size) { |
thedo | 167:1657b442184c | 45 | return ethernet_read(data, size); |
thedo | 167:1657b442184c | 46 | } |
thedo | 167:1657b442184c | 47 | |
thedo | 167:1657b442184c | 48 | void Ethernet::address(char *mac) { |
thedo | 167:1657b442184c | 49 | return ethernet_address(mac); |
thedo | 167:1657b442184c | 50 | } |
thedo | 167:1657b442184c | 51 | |
thedo | 167:1657b442184c | 52 | int Ethernet::link() { |
thedo | 167:1657b442184c | 53 | return ethernet_link(); |
thedo | 167:1657b442184c | 54 | } |
thedo | 167:1657b442184c | 55 | |
thedo | 167:1657b442184c | 56 | void Ethernet::set_link(Mode mode) { |
thedo | 167:1657b442184c | 57 | int speed = -1; |
thedo | 167:1657b442184c | 58 | int duplex = 0; |
thedo | 167:1657b442184c | 59 | |
thedo | 167:1657b442184c | 60 | switch(mode) { |
thedo | 167:1657b442184c | 61 | case AutoNegotiate : speed = -1; duplex = 0; break; |
thedo | 167:1657b442184c | 62 | case HalfDuplex10 : speed = 0; duplex = 0; break; |
thedo | 167:1657b442184c | 63 | case FullDuplex10 : speed = 0; duplex = 1; break; |
thedo | 167:1657b442184c | 64 | case HalfDuplex100 : speed = 1; duplex = 0; break; |
thedo | 167:1657b442184c | 65 | case FullDuplex100 : speed = 1; duplex = 1; break; |
thedo | 167:1657b442184c | 66 | } |
thedo | 167:1657b442184c | 67 | |
thedo | 167:1657b442184c | 68 | ethernet_set_link(speed, duplex); |
thedo | 167:1657b442184c | 69 | } |
thedo | 167:1657b442184c | 70 | |
thedo | 167:1657b442184c | 71 | } // namespace mbed |
thedo | 167:1657b442184c | 72 | |
thedo | 167:1657b442184c | 73 | #endif |
thedo | 167:1657b442184c | 74 |