Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
platform/mbed_board.c@167:1657b442184c, 2017-06-29 (annotated)
- 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?
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 <stdio.h> |
thedo | 167:1657b442184c | 17 | #include "hal/gpio_api.h" |
thedo | 167:1657b442184c | 18 | #include "platform/mbed_wait_api.h" |
thedo | 167:1657b442184c | 19 | #include "platform/mbed_toolchain.h" |
thedo | 167:1657b442184c | 20 | #include "platform/mbed_interface.h" |
thedo | 167:1657b442184c | 21 | #include "platform/mbed_critical.h" |
thedo | 167:1657b442184c | 22 | #include "hal/serial_api.h" |
thedo | 167:1657b442184c | 23 | |
thedo | 167:1657b442184c | 24 | #if DEVICE_SERIAL |
thedo | 167:1657b442184c | 25 | extern int stdio_uart_inited; |
thedo | 167:1657b442184c | 26 | extern serial_t stdio_uart; |
thedo | 167:1657b442184c | 27 | #endif |
thedo | 167:1657b442184c | 28 | |
thedo | 167:1657b442184c | 29 | WEAK void mbed_die(void) { |
thedo | 167:1657b442184c | 30 | #if !defined (NRF51_H) && !defined(TARGET_EFM32) |
thedo | 167:1657b442184c | 31 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 32 | #endif |
thedo | 167:1657b442184c | 33 | #if (DEVICE_ERROR_RED == 1) |
thedo | 167:1657b442184c | 34 | gpio_t led_red; gpio_init_out(&led_red, LED_RED); |
thedo | 167:1657b442184c | 35 | #elif (DEVICE_ERROR_PATTERN == 1) |
thedo | 167:1657b442184c | 36 | gpio_t led_1; gpio_init_out(&led_1, LED1); |
thedo | 167:1657b442184c | 37 | gpio_t led_2; gpio_init_out(&led_2, LED2); |
thedo | 167:1657b442184c | 38 | gpio_t led_3; gpio_init_out(&led_3, LED3); |
thedo | 167:1657b442184c | 39 | gpio_t led_4; gpio_init_out(&led_4, LED4); |
thedo | 167:1657b442184c | 40 | #endif |
thedo | 167:1657b442184c | 41 | |
thedo | 167:1657b442184c | 42 | while (1) { |
thedo | 167:1657b442184c | 43 | #if (DEVICE_ERROR_RED == 1) |
thedo | 167:1657b442184c | 44 | gpio_write(&led_red, 1); |
thedo | 167:1657b442184c | 45 | |
thedo | 167:1657b442184c | 46 | #elif (DEVICE_ERROR_PATTERN == 1) |
thedo | 167:1657b442184c | 47 | gpio_write(&led_1, 1); |
thedo | 167:1657b442184c | 48 | gpio_write(&led_2, 0); |
thedo | 167:1657b442184c | 49 | gpio_write(&led_3, 0); |
thedo | 167:1657b442184c | 50 | gpio_write(&led_4, 1); |
thedo | 167:1657b442184c | 51 | #endif |
thedo | 167:1657b442184c | 52 | |
thedo | 167:1657b442184c | 53 | wait_ms(150); |
thedo | 167:1657b442184c | 54 | |
thedo | 167:1657b442184c | 55 | #if (DEVICE_ERROR_RED == 1) |
thedo | 167:1657b442184c | 56 | gpio_write(&led_red, 0); |
thedo | 167:1657b442184c | 57 | |
thedo | 167:1657b442184c | 58 | #elif (DEVICE_ERROR_PATTERN == 1) |
thedo | 167:1657b442184c | 59 | gpio_write(&led_1, 0); |
thedo | 167:1657b442184c | 60 | gpio_write(&led_2, 1); |
thedo | 167:1657b442184c | 61 | gpio_write(&led_3, 1); |
thedo | 167:1657b442184c | 62 | gpio_write(&led_4, 0); |
thedo | 167:1657b442184c | 63 | #endif |
thedo | 167:1657b442184c | 64 | |
thedo | 167:1657b442184c | 65 | wait_ms(150); |
thedo | 167:1657b442184c | 66 | } |
thedo | 167:1657b442184c | 67 | } |
thedo | 167:1657b442184c | 68 | |
thedo | 167:1657b442184c | 69 | void mbed_error_printf(const char* format, ...) { |
thedo | 167:1657b442184c | 70 | va_list arg; |
thedo | 167:1657b442184c | 71 | va_start(arg, format); |
thedo | 167:1657b442184c | 72 | mbed_error_vfprintf(format, arg); |
thedo | 167:1657b442184c | 73 | va_end(arg); |
thedo | 167:1657b442184c | 74 | } |
thedo | 167:1657b442184c | 75 | |
thedo | 167:1657b442184c | 76 | void mbed_error_vfprintf(const char * format, va_list arg) { |
thedo | 167:1657b442184c | 77 | #if DEVICE_SERIAL |
thedo | 167:1657b442184c | 78 | #define ERROR_BUF_SIZE (128) |
thedo | 167:1657b442184c | 79 | core_util_critical_section_enter(); |
thedo | 167:1657b442184c | 80 | char buffer[ERROR_BUF_SIZE]; |
thedo | 167:1657b442184c | 81 | int size = vsnprintf(buffer, ERROR_BUF_SIZE, format, arg); |
thedo | 167:1657b442184c | 82 | if (size > 0) { |
thedo | 167:1657b442184c | 83 | if (!stdio_uart_inited) { |
thedo | 167:1657b442184c | 84 | serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX); |
thedo | 167:1657b442184c | 85 | } |
thedo | 167:1657b442184c | 86 | #if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES |
thedo | 167:1657b442184c | 87 | char stdio_out_prev = '\0'; |
thedo | 167:1657b442184c | 88 | for (int i = 0; i < size; i++) { |
thedo | 167:1657b442184c | 89 | if (buffer[i] == '\n' && stdio_out_prev != '\r') { |
thedo | 167:1657b442184c | 90 | serial_putc(&stdio_uart, '\r'); |
thedo | 167:1657b442184c | 91 | } |
thedo | 167:1657b442184c | 92 | serial_putc(&stdio_uart, buffer[i]); |
thedo | 167:1657b442184c | 93 | stdio_out_prev = buffer[i]; |
thedo | 167:1657b442184c | 94 | } |
thedo | 167:1657b442184c | 95 | #else |
thedo | 167:1657b442184c | 96 | for (int i = 0; i < size; i++) { |
thedo | 167:1657b442184c | 97 | serial_putc(&stdio_uart, buffer[i]); |
thedo | 167:1657b442184c | 98 | } |
thedo | 167:1657b442184c | 99 | #endif |
thedo | 167:1657b442184c | 100 | } |
thedo | 167:1657b442184c | 101 | core_util_critical_section_exit(); |
thedo | 167:1657b442184c | 102 | #endif |
thedo | 167:1657b442184c | 103 | } |
thedo | 167:1657b442184c | 104 |