From a5cb1bd31a0ca6df803134ca86927b37071a428e Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 12 Jul 2015 14:21:45 +0200 Subject: [PATCH] ARM: get rid of mbed-mbed_error.h and mbed-error.c. Same functionality, drastically smaller binary: SIZES ARM... lpc1114 FLASH : 1992 bytes 7% RAM : 156 bytes 4% EEPROM : 0 bytes 0% That's a reduction by 3948 bytes Flash and 20 bytes RAM. --- Makefile-ARM | 2 +- mbed-error.c | 49 ----------------------------- mbed-mbed_error.h | 75 -------------------------------------------- mbed-pinmap.c | 1 - mbed-pinmap_common.c | 6 +--- mbed-toolchain.h | 44 -------------------------- 6 files changed, 2 insertions(+), 175 deletions(-) delete mode 100644 mbed-error.c delete mode 100644 mbed-mbed_error.h delete mode 100644 mbed-toolchain.h diff --git a/Makefile-ARM b/Makefile-ARM index 24ec955..e2d6c41 100644 --- a/Makefile-ARM +++ b/Makefile-ARM @@ -98,7 +98,7 @@ TARGET = $(PROGRAM).hex # Until the generic ARM port is completed, we'd have to wrap all sources # in #ifdef __AVR__. To avoid this, build only a selection for now: SOURCES = mendel.c cpu.c serial.c -SOURCES += mbed-serial_api.c mbed-pinmap.c mbed-pinmap_common.c mbed-error.c +SOURCES += mbed-serial_api.c mbed-pinmap.c mbed-pinmap_common.c ifeq ($(MCU), lpc1114) SOURCES += mbed-system_LPC11xx.c endif diff --git a/mbed-error.c b/mbed-error.c deleted file mode 100644 index ca72c6d..0000000 --- a/mbed-error.c +++ /dev/null @@ -1,49 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - Notes for Teacup: - - Copied from $(MBED)/libraries/mbed/common/error.c. - - Used only to get things running quickly. Without serial it's almost - impossible to see wether code changes work. Should go away soon, because - all this MBED stuff is too bloated for Teacup's purposes. - - - Prefixed names of #include files with mbed- to match the names of the - copies in the Teacup repo. - - Wrapped the whole file in #ifdef __ARMEL__ to not cause conflicts with - AVR builds. -*/ -#ifdef __ARMEL__ -#include -#include -#include "mbed-device.h" -#include "mbed-toolchain.h" -#include "mbed-mbed_error.h" -#if DEVICE_STDIO_MESSAGES -#include -#endif - -WEAK void error(const char* format, ...) { -#if DEVICE_STDIO_MESSAGES - va_list arg; - va_start(arg, format); - vfprintf(stderr, format, arg); - va_end(arg); -#endif - exit(1); -} -#endif /* __ARMEL__ */ diff --git a/mbed-mbed_error.h b/mbed-mbed_error.h deleted file mode 100644 index 8b72480..0000000 --- a/mbed-mbed_error.h +++ /dev/null @@ -1,75 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - Notes for Teacup: - - Copied from $(MBED)/home/mah/RepRap/mbed/libraries/mbed/api/mbed_error.h. - - Used only to get things running quickly. Without serial it's almost - impossible to see wether code changes work. Should go away soon, because - all this MBED stuff is too bloated for Teacup's purposes. -*/ -#ifndef MBED_ERROR_H -#define MBED_ERROR_H - -/** To generate a fatal compile-time error, you can use the pre-processor #error directive. - * - * @code - * #error "That shouldn't have happened!" - * @endcode - * - * If the compiler evaluates this line, it will report the error and stop the compile. - * - * For example, you could use this to check some user-defined compile-time variables: - * - * @code - * #define NUM_PORTS 7 - * #if (NUM_PORTS > 4) - * #error "NUM_PORTS must be less than 4" - * #endif - * @endcode - * - * Reporting Run-Time Errors: - * To generate a fatal run-time error, you can use the mbed error() function. - * - * @code - * error("That shouldn't have happened!"); - * @endcode - * - * If the mbed running the program executes this function, it will print the - * message via the USB serial port, and then die with the blue lights of death! - * - * The message can use printf-style formatting, so you can report variables in the - * message too. For example, you could use this to check a run-time condition: - * - * @code - * if(x >= 5) { - * error("expected x to be less than 5, but got %d", x); - * } - * #endcode - */ - -#ifdef __cplusplus -extern "C" { -#endif - -void error(const char* format, ...); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mbed-pinmap.c b/mbed-pinmap.c index 01f4a6d..d882b39 100644 --- a/mbed-pinmap.c +++ b/mbed-pinmap.c @@ -29,7 +29,6 @@ */ #ifdef __ARMEL__ #include "mbed-pinmap.h" -#include "mbed-mbed_error.h" void pin_function(PinName pin, int function) { uint32_t offset = (uint32_t)pin & 0xff; diff --git a/mbed-pinmap_common.c b/mbed-pinmap_common.c index ed874d3..a2cf35d 100644 --- a/mbed-pinmap_common.c +++ b/mbed-pinmap_common.c @@ -29,7 +29,6 @@ */ #ifdef __ARMEL__ #include "mbed-pinmap.h" -#include "mbed-mbed_error.h" void pinmap_pinout(PinName pin, const PinMap *map) { if (pin == NC) @@ -44,7 +43,6 @@ void pinmap_pinout(PinName pin, const PinMap *map) { } map++; } - error("could not pinout"); } uint32_t pinmap_merge(uint32_t a, uint32_t b) { @@ -59,7 +57,6 @@ uint32_t pinmap_merge(uint32_t a, uint32_t b) { return a; // mis-match error case - error("pinmap mis-match"); return (uint32_t)NC; } @@ -78,8 +75,7 @@ uint32_t pinmap_peripheral(PinName pin, const PinMap* map) { if (pin == (PinName)NC) return (uint32_t)NC; peripheral = pinmap_find_peripheral(pin, map); - if ((uint32_t)NC == peripheral) // no mapping available - error("pinmap not found for peripheral"); + return peripheral; } #endif /* __ARMEL__ */ diff --git a/mbed-toolchain.h b/mbed-toolchain.h deleted file mode 100644 index 1740cbb..0000000 --- a/mbed-toolchain.h +++ /dev/null @@ -1,44 +0,0 @@ -/* mbed Microcontroller Library - * Copyright (c) 2006-2013 ARM Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* - Notes for Teacup: - - Copied from $(MBED)/libraries/mbed/api/toolchain.h. - - Used only to get things running quickly. Without serial it's almost - impossible to see wether code changes work. Should go away soon, because - all this MBED stuff is too bloated for Teacup's purposes. -*/ -#ifndef MBED_TOOLCHAIN_H -#define MBED_TOOLCHAIN_H - -#if defined(TOOLCHAIN_ARM) -#include -#endif - -#ifndef FILEHANDLE -typedef int FILEHANDLE; -#endif - -#if defined (__ICCARM__) -# define WEAK __weak -# define PACKED __packed -#else -# define WEAK __attribute__((weak)) -# define PACKED __attribute__((packed)) -#endif - -#endif