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.
This commit is contained in:
parent
848369608b
commit
a5cb1bd31a
|
|
@ -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
|
||||
|
|
|
|||
49
mbed-error.c
49
mbed-error.c
|
|
@ -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 <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "mbed-device.h"
|
||||
#include "mbed-toolchain.h"
|
||||
#include "mbed-mbed_error.h"
|
||||
#if DEVICE_STDIO_MESSAGES
|
||||
#include <stdio.h>
|
||||
#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__ */
|
||||
|
|
@ -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
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
|
|
|||
|
|
@ -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 <rt_sys.h>
|
||||
#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
|
||||
Loading…
Reference in New Issue