source: asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/platform/mbed_board.c@ 374

Last change on this file since 374 was 374, checked in by coas-nagasima, 5 years ago

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 2.5 KB
Line 
1/* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <stdio.h>
17#include "hal/gpio_api.h"
18#include "platform/mbed_wait_api.h"
19#include "platform/mbed_toolchain.h"
20#include "platform/mbed_interface.h"
21#include "platform/mbed_critical.h"
22#include "hal/serial_api.h"
23
24#if DEVICE_SERIAL
25extern int stdio_uart_inited;
26extern serial_t stdio_uart;
27#endif
28
29WEAK void mbed_die(void)
30{
31#if !defined (NRF51_H) && !defined(TARGET_EFM32)
32 core_util_critical_section_enter();
33#endif
34 gpio_t led_err;
35 gpio_init_out(&led_err, LED1);
36
37 while (1) {
38 for (int i = 0; i < 4; ++i) {
39 gpio_write(&led_err, 1);
40 wait_ms(150);
41 gpio_write(&led_err, 0);
42 wait_ms(150);
43 }
44
45 for (int i = 0; i < 4; ++i) {
46 gpio_write(&led_err, 1);
47 wait_ms(400);
48 gpio_write(&led_err, 0);
49 wait_ms(400);
50 }
51 }
52}
53
54void mbed_error_printf(const char *format, ...)
55{
56 va_list arg;
57 va_start(arg, format);
58 mbed_error_vfprintf(format, arg);
59 va_end(arg);
60}
61
62void mbed_error_vfprintf(const char *format, va_list arg)
63{
64#if DEVICE_SERIAL
65#define ERROR_BUF_SIZE (128)
66 core_util_critical_section_enter();
67 char buffer[ERROR_BUF_SIZE];
68 int size = vsnprintf(buffer, ERROR_BUF_SIZE, format, arg);
69 if (size > 0) {
70 if (!stdio_uart_inited) {
71 serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
72 }
73#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
74 char stdio_out_prev = '\0';
75 for (int i = 0; i < size; i++) {
76 if (buffer[i] == '\n' && stdio_out_prev != '\r') {
77 serial_putc(&stdio_uart, '\r');
78 }
79 serial_putc(&stdio_uart, buffer[i]);
80 stdio_out_prev = buffer[i];
81 }
82#else
83 for (int i = 0; i < size; i++) {
84 serial_putc(&stdio_uart, buffer[i]);
85 }
86#endif
87 }
88 core_util_critical_section_exit();
89#endif
90}
Note: See TracBrowser for help on using the repository browser.