This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mbed_board.c Source File

mbed_board.c

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #include <stdio.h>
00017 #include "hal/gpio_api.h"
00018 #include "platform/wait_api.h"
00019 #include "platform/toolchain.h"
00020 #include "platform/mbed_interface.h"
00021 #include "platform/critical.h"
00022 #include "hal/serial_api.h"
00023 
00024 #if DEVICE_SERIAL
00025 extern int stdio_uart_inited;
00026 extern serial_t stdio_uart;
00027 #endif
00028 
00029 WEAK void mbed_die(void) {
00030 #if !defined (NRF51_H) && !defined(TARGET_EFM32)
00031     core_util_critical_section_enter();
00032 #endif
00033 #if   (DEVICE_ERROR_RED == 1)
00034     gpio_t led_red; gpio_init_out(&led_red, LED_RED);
00035 #elif (DEVICE_ERROR_PATTERN == 1)
00036     gpio_t led_1; gpio_init_out(&led_1, LED1);
00037     gpio_t led_2; gpio_init_out(&led_2, LED2);
00038     gpio_t led_3; gpio_init_out(&led_3, LED3);
00039     gpio_t led_4; gpio_init_out(&led_4, LED4);
00040 #endif
00041 
00042     while (1) {
00043 #if   (DEVICE_ERROR_RED == 1)
00044         gpio_write(&led_red, 1);
00045 
00046 #elif (DEVICE_ERROR_PATTERN == 1)
00047         gpio_write(&led_1, 1);
00048         gpio_write(&led_2, 0);
00049         gpio_write(&led_3, 0);
00050         gpio_write(&led_4, 1);
00051 #endif
00052 
00053         wait_ms(150);
00054 
00055 #if   (DEVICE_ERROR_RED == 1)
00056         gpio_write(&led_red, 0);
00057 
00058 #elif (DEVICE_ERROR_PATTERN == 1)
00059         gpio_write(&led_1, 0);
00060         gpio_write(&led_2, 1);
00061         gpio_write(&led_3, 1);
00062         gpio_write(&led_4, 0);
00063 #endif
00064 
00065         wait_ms(150);
00066     }
00067 }
00068 
00069 void mbed_error_printf(const char* format, ...) {
00070     va_list arg;
00071     va_start(arg, format);
00072     mbed_error_vfprintf(format, arg);
00073     va_end(arg);
00074 }
00075 
00076 void mbed_error_vfprintf(const char * format, va_list arg) {
00077 #if DEVICE_SERIAL
00078     core_util_critical_section_enter();
00079     char buffer[128];
00080     int size = vsprintf(buffer, format, arg);
00081     if (size > 0) {
00082         if (!stdio_uart_inited) {
00083         serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
00084         }
00085         for (int i = 0; i < size; i++) {
00086             serial_putc(&stdio_uart, buffer[i]);
00087         }
00088     }
00089     core_util_critical_section_exit();
00090 #endif
00091 }