Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 /* mbed Microcontroller Library
switches 0:5c4d7b2438d3 2 * Copyright (c) 2006-2013 ARM Limited
switches 0:5c4d7b2438d3 3 *
switches 0:5c4d7b2438d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 5 * you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 6 * You may obtain a copy of the License at
switches 0:5c4d7b2438d3 7 *
switches 0:5c4d7b2438d3 8 * http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 9 *
switches 0:5c4d7b2438d3 10 * Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 13 * See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 14 * limitations under the License.
switches 0:5c4d7b2438d3 15 */
switches 0:5c4d7b2438d3 16 #include <stdio.h>
switches 0:5c4d7b2438d3 17 #include "hal/gpio_api.h"
switches 0:5c4d7b2438d3 18 #include "platform/wait_api.h"
switches 0:5c4d7b2438d3 19 #include "platform/toolchain.h"
switches 0:5c4d7b2438d3 20 #include "platform/mbed_interface.h"
switches 0:5c4d7b2438d3 21 #include "platform/critical.h"
switches 0:5c4d7b2438d3 22 #include "hal/serial_api.h"
switches 0:5c4d7b2438d3 23
switches 0:5c4d7b2438d3 24 #if DEVICE_SERIAL
switches 0:5c4d7b2438d3 25 extern int stdio_uart_inited;
switches 0:5c4d7b2438d3 26 extern serial_t stdio_uart;
switches 0:5c4d7b2438d3 27 #endif
switches 0:5c4d7b2438d3 28
switches 0:5c4d7b2438d3 29 WEAK void mbed_die(void) {
switches 0:5c4d7b2438d3 30 #if !defined (NRF51_H) && !defined(TARGET_EFM32)
switches 0:5c4d7b2438d3 31 core_util_critical_section_enter();
switches 0:5c4d7b2438d3 32 #endif
switches 0:5c4d7b2438d3 33 #if (DEVICE_ERROR_RED == 1)
switches 0:5c4d7b2438d3 34 gpio_t led_red; gpio_init_out(&led_red, LED_RED);
switches 0:5c4d7b2438d3 35 #elif (DEVICE_ERROR_PATTERN == 1)
switches 0:5c4d7b2438d3 36 gpio_t led_1; gpio_init_out(&led_1, LED1);
switches 0:5c4d7b2438d3 37 gpio_t led_2; gpio_init_out(&led_2, LED2);
switches 0:5c4d7b2438d3 38 gpio_t led_3; gpio_init_out(&led_3, LED3);
switches 0:5c4d7b2438d3 39 gpio_t led_4; gpio_init_out(&led_4, LED4);
switches 0:5c4d7b2438d3 40 #endif
switches 0:5c4d7b2438d3 41
switches 0:5c4d7b2438d3 42 while (1) {
switches 0:5c4d7b2438d3 43 #if (DEVICE_ERROR_RED == 1)
switches 0:5c4d7b2438d3 44 gpio_write(&led_red, 1);
switches 0:5c4d7b2438d3 45
switches 0:5c4d7b2438d3 46 #elif (DEVICE_ERROR_PATTERN == 1)
switches 0:5c4d7b2438d3 47 gpio_write(&led_1, 1);
switches 0:5c4d7b2438d3 48 gpio_write(&led_2, 0);
switches 0:5c4d7b2438d3 49 gpio_write(&led_3, 0);
switches 0:5c4d7b2438d3 50 gpio_write(&led_4, 1);
switches 0:5c4d7b2438d3 51 #endif
switches 0:5c4d7b2438d3 52
switches 0:5c4d7b2438d3 53 wait_ms(150);
switches 0:5c4d7b2438d3 54
switches 0:5c4d7b2438d3 55 #if (DEVICE_ERROR_RED == 1)
switches 0:5c4d7b2438d3 56 gpio_write(&led_red, 0);
switches 0:5c4d7b2438d3 57
switches 0:5c4d7b2438d3 58 #elif (DEVICE_ERROR_PATTERN == 1)
switches 0:5c4d7b2438d3 59 gpio_write(&led_1, 0);
switches 0:5c4d7b2438d3 60 gpio_write(&led_2, 1);
switches 0:5c4d7b2438d3 61 gpio_write(&led_3, 1);
switches 0:5c4d7b2438d3 62 gpio_write(&led_4, 0);
switches 0:5c4d7b2438d3 63 #endif
switches 0:5c4d7b2438d3 64
switches 0:5c4d7b2438d3 65 wait_ms(150);
switches 0:5c4d7b2438d3 66 }
switches 0:5c4d7b2438d3 67 }
switches 0:5c4d7b2438d3 68
switches 0:5c4d7b2438d3 69 void mbed_error_printf(const char* format, ...) {
switches 0:5c4d7b2438d3 70 va_list arg;
switches 0:5c4d7b2438d3 71 va_start(arg, format);
switches 0:5c4d7b2438d3 72 mbed_error_vfprintf(format, arg);
switches 0:5c4d7b2438d3 73 va_end(arg);
switches 0:5c4d7b2438d3 74 }
switches 0:5c4d7b2438d3 75
switches 0:5c4d7b2438d3 76 void mbed_error_vfprintf(const char * format, va_list arg) {
switches 0:5c4d7b2438d3 77 #if DEVICE_SERIAL
switches 0:5c4d7b2438d3 78 core_util_critical_section_enter();
switches 0:5c4d7b2438d3 79 char buffer[128];
switches 0:5c4d7b2438d3 80 int size = vsprintf(buffer, format, arg);
switches 0:5c4d7b2438d3 81 if (size > 0) {
switches 0:5c4d7b2438d3 82 if (!stdio_uart_inited) {
switches 0:5c4d7b2438d3 83 serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
switches 0:5c4d7b2438d3 84 }
switches 0:5c4d7b2438d3 85 for (int i = 0; i < size; i++) {
switches 0:5c4d7b2438d3 86 serial_putc(&stdio_uart, buffer[i]);
switches 0:5c4d7b2438d3 87 }
switches 0:5c4d7b2438d3 88 }
switches 0:5c4d7b2438d3 89 core_util_critical_section_exit();
switches 0:5c4d7b2438d3 90 #endif
switches 0:5c4d7b2438d3 91 }