Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Thu Jun 29 11:01:39 2017 +0000
Revision:
167:1657b442184c
Opencv 3.1 project on GR-PEACH board, 4 apps

Who changed what in which revision?

UserRevisionLine numberNew 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 <stdio.h>
thedo 167:1657b442184c 17 #include "platform/mbed_interface.h"
thedo 167:1657b442184c 18
thedo 167:1657b442184c 19 #include "hal/gpio_api.h"
thedo 167:1657b442184c 20 #include "platform/mbed_wait_api.h"
thedo 167:1657b442184c 21 #include "platform/mbed_semihost_api.h"
thedo 167:1657b442184c 22 #include "platform/mbed_error.h"
thedo 167:1657b442184c 23 #include "platform/mbed_toolchain.h"
thedo 167:1657b442184c 24
thedo 167:1657b442184c 25 #if DEVICE_SEMIHOST
thedo 167:1657b442184c 26
thedo 167:1657b442184c 27 // return true if a debugger is attached, indicating mbed interface is connected
thedo 167:1657b442184c 28 int mbed_interface_connected(void) {
thedo 167:1657b442184c 29 return semihost_connected();
thedo 167:1657b442184c 30 }
thedo 167:1657b442184c 31
thedo 167:1657b442184c 32 int mbed_interface_reset(void) {
thedo 167:1657b442184c 33 if (mbed_interface_connected()) {
thedo 167:1657b442184c 34 semihost_reset();
thedo 167:1657b442184c 35 return 0;
thedo 167:1657b442184c 36 } else {
thedo 167:1657b442184c 37 return -1;
thedo 167:1657b442184c 38 }
thedo 167:1657b442184c 39 }
thedo 167:1657b442184c 40
thedo 167:1657b442184c 41 WEAK int mbed_interface_uid(char *uid) {
thedo 167:1657b442184c 42 if (mbed_interface_connected()) {
thedo 167:1657b442184c 43 return semihost_uid(uid); // Returns 0 if successful, -1 on failure
thedo 167:1657b442184c 44 } else {
thedo 167:1657b442184c 45 uid[0] = 0;
thedo 167:1657b442184c 46 return -1;
thedo 167:1657b442184c 47 }
thedo 167:1657b442184c 48 }
thedo 167:1657b442184c 49
thedo 167:1657b442184c 50 int mbed_interface_disconnect(void) {
thedo 167:1657b442184c 51 int res;
thedo 167:1657b442184c 52 if (mbed_interface_connected()) {
thedo 167:1657b442184c 53 if ((res = semihost_disabledebug()) != 0)
thedo 167:1657b442184c 54 return res;
thedo 167:1657b442184c 55 while (mbed_interface_connected());
thedo 167:1657b442184c 56 return 0;
thedo 167:1657b442184c 57 } else {
thedo 167:1657b442184c 58 return -1;
thedo 167:1657b442184c 59 }
thedo 167:1657b442184c 60 }
thedo 167:1657b442184c 61
thedo 167:1657b442184c 62 int mbed_interface_powerdown(void) {
thedo 167:1657b442184c 63 int res;
thedo 167:1657b442184c 64 if (mbed_interface_connected()) {
thedo 167:1657b442184c 65 if ((res = semihost_powerdown()) != 0)
thedo 167:1657b442184c 66 return res;
thedo 167:1657b442184c 67 while (mbed_interface_connected());
thedo 167:1657b442184c 68 return 0;
thedo 167:1657b442184c 69 } else {
thedo 167:1657b442184c 70 return -1;
thedo 167:1657b442184c 71 }
thedo 167:1657b442184c 72 }
thedo 167:1657b442184c 73
thedo 167:1657b442184c 74 // for backward compatibility
thedo 167:1657b442184c 75 void mbed_reset(void) {
thedo 167:1657b442184c 76 mbed_interface_reset();
thedo 167:1657b442184c 77 }
thedo 167:1657b442184c 78
thedo 167:1657b442184c 79 WEAK int mbed_uid(char *uid) {
thedo 167:1657b442184c 80 return mbed_interface_uid(uid);
thedo 167:1657b442184c 81 }
thedo 167:1657b442184c 82 #endif
thedo 167:1657b442184c 83
thedo 167:1657b442184c 84 WEAK void mbed_mac_address(char *mac) {
thedo 167:1657b442184c 85 #if DEVICE_SEMIHOST
thedo 167:1657b442184c 86 char uid[DEVICE_ID_LENGTH + 1];
thedo 167:1657b442184c 87 int i;
thedo 167:1657b442184c 88
thedo 167:1657b442184c 89 // if we have a UID, extract the MAC
thedo 167:1657b442184c 90 if (mbed_interface_uid(uid) == 0) {
thedo 167:1657b442184c 91 char *p = uid;
thedo 167:1657b442184c 92 #if defined(DEVICE_MAC_OFFSET)
thedo 167:1657b442184c 93 p += DEVICE_MAC_OFFSET;
thedo 167:1657b442184c 94 #endif
thedo 167:1657b442184c 95 for (i=0; i<6; i++) {
thedo 167:1657b442184c 96 int byte;
thedo 167:1657b442184c 97 sscanf(p, "%2x", &byte);
thedo 167:1657b442184c 98 mac[i] = byte;
thedo 167:1657b442184c 99 p += 2;
thedo 167:1657b442184c 100 }
thedo 167:1657b442184c 101 mac[0] &= ~0x01; // reset the IG bit in the address; see IEE 802.3-2002, Section 3.2.3(b)
thedo 167:1657b442184c 102 } else { // else return a default MAC
thedo 167:1657b442184c 103 #endif
thedo 167:1657b442184c 104 mac[0] = 0x00;
thedo 167:1657b442184c 105 mac[1] = 0x02;
thedo 167:1657b442184c 106 mac[2] = 0xF7;
thedo 167:1657b442184c 107 mac[3] = 0xF0;
thedo 167:1657b442184c 108 mac[4] = 0x00;
thedo 167:1657b442184c 109 mac[5] = 0x00;
thedo 167:1657b442184c 110 #if DEVICE_SEMIHOST
thedo 167:1657b442184c 111 }
thedo 167:1657b442184c 112 #endif
thedo 167:1657b442184c 113 }
thedo 167:1657b442184c 114