Commit Graph

66 Commits (765aeb0dc6c67c798358ca4c5b465d1f7f1ef6c4)

Author SHA1 Message Date
Sam Grove a6b27319ec Merge pull request #2496 from geky/callback-cv
Add cv-qualifiers to Callback and deprecate combinatorial explody functions
2016-09-09 01:45:25 +02:00
Martin Kojtal 2df22277a5 alloc wrappers - fix calloc wrapping for uvisor
Done already in 7c0cc50, same applied to alloc wrappers that was moved
from retarget.
2016-09-02 11:07:19 +01:00
Martin Kojtal fd9d89aad0 retarget - fix uvisor header inclusion 2016-09-02 11:03:21 +01:00
Christopher Haster c71e67f2dc Updated minor functionality of the Callback class
- Marked `call` and `operator()` functions as const
- Moved to static_cast for internal function pointer to avoid losing
  compiler checked const-safety
- Added test for `operator=` with non-callback types
- Moved from zero-cast to value-initializer when callback is null
- Added `operator==` and `operator!=`
- Removed special handling of null callback
- Replicated doxygen to all overloads
- Added correct nops where uninitialized callbacks are called
- Added assertion for null callback
- Removed copy-constructor from callback constructor
2016-08-26 09:54:02 -05:00
Bogdan Marinescu 8b908abcc5 Added thread safety to the tracing mechanism
Without this in place, traces might be lost if a another thread
interrupts a memory function at the right time.
2016-08-26 09:42:41 -05:00
Bogdan Marinescu 7d09bb7d3b Runtime dynamic memory tracing
This commit adds a dynamic memory tracer that calls a callback whenever
one of the basic memory allocation functions (malloc, realloc, calloc,
free) is called. The operation of the tracer is guarded by the
'MBED_MEM_TRACING_ENABLED` macro.

Infinite recursion during tracing is guarded by using atomic
increment/decrement primitives on the `trace_level` variable.

Thanks to @c1728p9 and @heky for their help and  suggestions.
2016-08-26 09:42:39 -05:00
Sam Grove 23ffafa682 Merge pull request #2498 from toyowata/master
Fix multiple definition errors in GCC_CR build
2016-08-26 09:22:49 -05:00
Niklas Hauser 7c0cc50677 Fix missing wrapping of calloc_r with uVisor enabled.
uVisor only wraps malloc_r, realloc_r and free_r, not calloc_r!
2016-08-24 10:22:05 +01:00
Russ Butler 6a31ffbf3e Heap statistics
Keep track of the current size allocated, maximum size allocated,
number of allocations, failed allocations and total size allocated for
both GCC and ARM. Report the maximum size allocated at the end of
testing.

Also, add a test to verify heap metrics are working as expected.
2016-08-22 18:32:51 -05:00
Toyomasa Watarai 362bb0e94d Add TOOLCHAIN_GCC_CR support 2016-08-19 13:50:12 +09:00
Russ Butler 16329fd2d9 Override new and delete operators to trap errors
When new or new[] fails to allocate space trigger an error.
2016-08-09 14:42:23 -05:00
Russ Butler 7cf1dc1155 Fix heap limit checking and make memory explicit
Set well defined limits for the heap and configure GCC and ARMCC to
correctly check these. IAR already correctly checked its heap.

This also statically declares the main thread stack so the
linker is responsible for its placement.
2016-08-09 13:44:33 -05:00
Bogdan Marinescu 2f127cbd2b Merge pull request #2274 from ARMmbed/unified_wait
Unification of wait functions
2016-08-09 09:41:16 +01:00
Bogdan Marinescu 49606cd5de Improved accuracy for microsecond delays 2016-08-08 19:04:38 +03:00
Sam Grove 34caf43f5a Merge pull request #2238 from OpenNuvoton/nuc472
[NUC472] Add NUMAKER-PFM-NUC472
2016-08-04 10:37:31 -05:00
Martin Kojtal ac34f29f66 Merge pull request #2297 from neilt6/spi-mutex-fix
[HAL] Modified SPI to use shared mutex
2016-07-29 17:30:38 +02:00
Russ Butler 1da259af3b Fix RTC test failures by removing critical sect
Remove the critical section in mbed_rtc_time.c and instead use a
mutex to protect this. This function does not need to be interrupt
safe, just thread safe.

This fixes crashes on the GCC_ARM toolchain on the RTC test due to
trying to lock the GCC environment mutex while in a critical section.
Prior to this patch, this failure was likely to occur on STM and LPC
processor families.
2016-07-28 14:35:51 -05:00
Russ Butler 4047ff9576 Create dedicated file for PlatformMutex
Move the PlatformMutex class into a dedicated file to reduce the
number of unnecessary includes.
2016-07-28 14:21:04 -05:00
neilt6 e80b16628d [HAL] Modified SPI to use shared mutex
Modified the SPI class to use a shared mutex for all instances. This is
consistent with I2C and others.
2016-07-28 08:57:59 -06:00
ccli8 41242e3d55 Support NUMAKER_PFM_NUC472 2016-07-28 10:00:49 +08:00
Bogdan Marinescu 1a1507ac78 Unification of wait functions
This commit adds two implementations for the mbed wait functions (wait,
wait_ms, wait_us):

- with the RTOS present, the wait functions will use `Thread::wait` for
  millisecond delays and a busy wait loop for sub-millisecond delays.
- with the RTOS not present, the wait functions will always use a busy
  wait loop.
2016-07-27 17:30:59 +03:00
Sam Grove dc9fb460ee prepend common .c files with mbed_ 2016-07-22 23:36:25 -05:00
Sam Grove 542fcca670 Merge pull request #2137 from sg-/operators
Remove macro for operators. Enable these as default behavior
2016-07-22 19:01:24 -05:00
Russ Butler 348b32c3c6 Create singleton class and update code to use it
Create the wrapper class SingletonPtr.  This provides a safe way to
declare and use singletons.  This class allows both the lazy
initialization of a singleton, and allows the singleton to be
garbage collected by the linker if it is never referenced.

This patch also updates the HAL to use SingletonPtr when declaring
singleton mutexes.
2016-07-15 14:37:43 -05:00
Martin Kojtal 829289bdd9 Merge pull request #2129 from jamike/Fix_for_#2124
Fix issue #2124: IAR no rtos
2016-07-15 10:48:53 +01:00
Christopher Haster 126de5b07a Added config option for stdio baud rate 2016-07-11 18:42:44 -05:00
Sam Grove 254ae0e109 Remove macro for operators. Enable these as default behavior 2016-07-10 13:47:13 -05:00
Christopher Haster 98d55e71d8 Moved core_util_atomic_*_ptr functions out of cortex switch 2016-07-09 11:14:16 -05:00
Christopher Haster 70013d03b6 Fixed casts around calls to atomic u32 functions
- uint32_t -> void *
- void ** -> uint32_t *

For whatever reason `uintptr_t` and `uint32_t` expand to incompatible
types `unsigned int` and `unsigned long int`. This is implicitely casted
when passed by value, but causes a warning in gcc and error in iar when
passed by pointer.

This issue is not present on x86_32 gcc
2016-07-09 11:13:20 -05:00
Michel JAOUEN e29aa6a7fa Fix issue #2124: IAR no rtos
Remove the 2nd call of mbed_sdk_init in __iar_argc_argv
2016-07-08 13:45:52 +02:00
Christopher Haster 2c78dca69c Fixed typo in incr/decr function
Result of last minute change, interestingly only emits a
warning in gcc.
2016-07-07 22:51:31 -05:00
Christopher Haster 9067148618 Standardized style of critical.h
per @0xc0170
2016-07-06 13:06:37 -05:00
Christopher Haster 26726cc170 Added proper usage of standard types for critical pointer functions 2016-07-06 13:06:34 -05:00
Christopher Haster cf6f8e33fb Added cas instrinsics for pointer values
- core_util_atomic_cas
- core_util_atomic_incr
- core_util_atomic_decr
2016-07-06 13:04:36 -05:00
Martin Kojtal 1216d8088d Merge pull request #2092 from akselsm/spi-init-fix
SPI: Properly aquire peripheral in constructor
2016-07-04 10:10:11 +01:00
Aksel Skauge Mellbye b09a87ffb8 SPI: Properly aquire peripheral in constructor
Prevent mismatch between _owner and peripheral configuration. In the previous
implementation, the following code would leave the peripheral in an inconsistent
state:

```
SPI spi1(...);      // _owner is NULL, peripheral config is 1
spi1.transfer(...); // _owner is 1, config is 1
SPI spi2(...);      // _owner is 1, config is 2
spi1.transfer(...)  // 1 thinks it still owns peripheral, doesn't reconfigure
```
2016-07-04 09:52:57 +02:00
Anna Bridge 329f8a10dc Add core_util_ prefix to are_interrupts_enabled() function.
For consistency with other exposed functions from this file, core_util_
prefix should be added.
2016-07-01 15:08:31 +01:00
Anna Bridge 2292794385 Reverse the logic to get_interrupts_disabled() to are_interrupts_enabled()
and update the using functions accordingly.

Usage:
bool interrupts_enabled = are_interrupts_enabled()

Remove superfluos shift in are_interrupts_enabled().
2016-07-01 14:55:53 +01:00
Anna Bridge 9f052bc500 Update function get_interrupts_disabled() to return a bool value rather
than an integer. This removes the need for all users to mask the returned
value with 0x1 to determine interrupt status.
Expose this function externally to allow other users to check interrupt
status in a manner which will work for both cortex-A and cortex-M .
Usage:
bool disabled = get_interrupts_disabled();
2016-07-01 14:53:53 +01:00
Christopher Haster 54609f6d62 Added default value for MBED_CONF_CORE_STDIO_CONVERT_NEWLINES 2016-06-17 03:54:39 -05:00
Christopher Haster 1480c231e9 Added config option for newline conversion 2016-06-15 21:14:26 -05:00
Christopher Haster 2330dcc49a Added newline conversion for stdin
stdin converts the following character sequences:

\n   -> \n
\r\n -> \n
\r   -> \n
\n\r -> \n

For original behaviour, a serial object can be instantiated explicitly
2016-06-15 20:58:30 -05:00
Christopher Haster 69c33625eb Added newline conversion for stdout
stdout converts the following character sequences:

\n   -> \r\n
\r\n -> \r\n
\r   -> \r
\n\r -> \n\r

For original behaviour, a serial object can be instantiated explicitly
2016-06-15 20:58:30 -05:00
Jaeden Amero af572350f0 Don't call __disable_irq for uVisor
This is a hack to get debug builds applications that use uVisor to work.
The assertions in core_util_critical_section fail because interrupts can't
actually be disabled from unprivileged mode.

Without this hack, core_util_critical_section_enter() calls
mbed_assert_internal() when the assertion fails, which calls
core_util_critical_section_enter() again, which calls
mbed_assert_internal() again; this is infinite recursion.

core_util_critical_section_enter needs some fixing.
2016-06-14 14:09:56 +00:00
0xc0170 81a7bdc482 critical - fix __STDC_LIMIT_MACROS for armcc
UINT32_MAX is defined only if __STDC_LIMIT_MACROS is provided prior
including stdint.h
2016-06-13 22:14:13 +01:00
0xc0170 3b2d75fcda error - include interface header file
to get mbed_error_vprinf() declaration
2016-06-13 21:54:44 +01:00
Russ Butler 8c2e352dd8 Fix GCC malloc lock
The malloc lock functions were not declared as extern "C" so they
are not getting linked to the standard library.  Add extern "C" to
fix this.

This bug was introduced in the commit:
d0b7b3b497 -
Fix duplicate symbols for malloc lock and unlock
2016-06-13 15:00:42 +01:00
Russ Butler d0b7b3b497 Fix duplicate symbols for malloc lock and unlock
When the malloc lock and unlock functions are inside a library they
conflict with the standard libraries weak version of these functions.
This is because of the way weak references are handled by the linker.
This patch renames the lock and unlock functions defined inside RTX
so they do not conflict.  A thunk inside retarget.cpp then calls the
RTX functions.  This problem does not occur with retarget.cpp since
it is always build into an object file rather than a library file.
2016-06-12 18:18:41 +01:00
Russ Butler b174d6a314 Add virtual lock for thread safe classes
Add a virtual lock for the classes which are thread safe.  This
allows the use of a mutex to be overridden.
2016-06-11 17:33:12 +01:00
Russ Butler e4f6e1b327 Update assert and error to be interrupt safe
Add printf functions intended for errors which are safe to call from
interrupts.  Update assert and error to use this function.
2016-06-11 17:33:10 +01:00