Commit Graph

29 Commits (6e4d74bc24554e16b61fc557491e4d514eb4b1e5)

Author SHA1 Message Date
Martin Kojtal 08ecdb296b Merge pull request #139 from geky/callback-fixes
Small fixes for issues with Callback class
2016-05-27 09:14:02 +01:00
Russ Butler caa88ba9f4 More IAR test fixes
Make the following changes:
-Fix keyword used in forced inline pragma
-Move alignment test variables off of the stack since alignment there
    is platform dependent.
2016-05-26 17:40:03 -05:00
Christopher Haster 753720af56 Fixed ambigous function declarations in serial class
Caused by default argument and overly generalized templated types.

SerialBase::attach(T *obj, M method, IrqType type=RxIrq)
->
SerialBase::attach(T *obj, void (T::*method)(), IrqType type=RxIrq)
SerialBase::attach(T *obj, void (*method)(T*), IrqType type=RxIrq)
2016-05-25 15:24:54 -05:00
Christopher Haster 7c7d514000 Added callback null check for each template class
per @c1728p9 #131
2016-05-25 14:48:12 -05:00
Russ Butler e37e1da7b9 Update Callback to fix fault in serial interrupts
Update the Callback class to handle a NULL thunk by returning 0
rather than trying to call the thunk.  This fixes a crash that occurs
on some targets when the TX uart handler is not attached.

Background:
The K64F HAL uart implementation calls the TX interrupt handler
every time a uart interrupt occurs while the TX register is empty.
It does not check to see if the TX interrupt has been enabled.
This means that the TX interrupt can and typically does get
run on RX events.  This causes a crash with the newer callback
code which did not (prior to this patch) support a NULL thunk.
2016-05-24 17:18:11 -05:00
Sam Grove 23d77e4423 Merge pull request #97 from geky/compiler-polyfill
Add useful attributes supported by supported compilers
2016-05-20 16:16:23 -05:00
Kevin Bracey 640116123c Use critical section helper in HAL
Routines using __disable_irq and __enable_irq had the effect of
enabling interrupts if called with interrupts disabled.

Some versions of __disable_irq do not return old status to restore it.

Change to use the critical section helper functions instead.
2016-05-18 14:50:31 +03:00
Christopher Haster 018e2571e6 Added other attributes on supported compilers
tested on GCC, Clang, online compiler, and IAR

attributes
- PACK
- ALIGN
- UNUSED
- WEAK
- PURE
- FORCEINLINE
- NORETURN
- UNREACHABLE
- DEPRECATED
2016-05-16 18:59:23 -05:00
Christopher Haster f05240b666 Added attribute tests from compiler-polyfill
from https://github.com/ARMmbed/compiler-polyfill/tree/master/test/attributes
2016-05-16 14:27:54 -05:00
Christopher Haster 8381fda624 Merged compiler-polyfill into toolchain.h
from https://github.com/armmbed/compiler-polyfill

notes
- Adopted existing mbed naming convention of all caps.
  This avoids conflicts with compiler declarations
  https://github.com/ARMmbed/compiler-polyfill/issues/7

- Dropped align attribute due to lack of support on IAR.

- Currently toolchain.h lives in /hal/api, although with
  the addition of /util there may be a better home.
2016-05-16 14:02:46 -05:00
Christopher Haster 4984077d07 Adopt Callback class in hal 2016-05-13 19:07:45 -05:00
Christopher Haster bf498de127 Add backward compatiblity for FunctionPointer class using Callback
effectively:
typedef Callback<R(A)> FunctionPointerArg1<R,A>
typedef Callback<R()> FunctionPointerArg1<R,void>
typedef Callback<R()> FunctionPointer
typedef Callback<R()> event_callback_t
2016-05-13 19:07:45 -05:00
Christopher Haster 8b330ae8a6 Add callback tests 2016-05-13 19:07:45 -05:00
Christopher Haster 8e42a32d00 Add Callback, an improved FunctionPointer class
- Adopt C++11 style template arguments, requires rename to Callback
- Add constructor for C style callback functions
- Add constructor for Callbacks
- Add static function for passing to C style callbacks
2016-05-13 19:07:45 -05:00
Russ Butler e161aad0c1 Create mbed-drivers/mbed.h for compatibility
Create a second mbed.h in the mbed-drivers directory to support
projects using 3.0 style includes.
2016-04-10 23:43:34 -05:00
Russ Butler 6b4dfeb1ab Fix heap allocation when used with RTOS
Remove the code which checks the heap against the stack to determine
if there is space left.  Using the stack pointer as a limit causes
problems when used with an RTOS since the stack pointer depends
on the current thread which can use a user-allocated stack residing
anywhere in memory.
2016-04-10 23:37:42 -05:00
sg- 034d3e9c27 track mbed_error.c 2016-04-07 10:25:29 -05:00
sg- 47ee2ed90f rename error.c to mbed_error.c. add toolchain.h to mbed.h exposing to all. add extern filler to toolchain.h 2016-04-07 10:22:59 -05:00
Christopher Haster 8a5121aaff Reverted merge of FuncPtr (#10)
Replaced FuncPtr with FunctionPointer in NSAPI
2016-04-06 11:23:42 -05:00
Marcus Shawcroft 0fbdad69ef Merge pull request #10 from geky/master
Added improved FuncPtr type
2016-04-07 09:23:21 +01:00
Alessandro Angelino 2fe077d50a Mirror huge PR from mbed OS
The following PRs have been mirrored:
https://github.com/ARMmbed/mbed-hal-k64f/pull/6  "All Freescale macros for memory access replaced"
https://github.com/ARMmbed/mbed-hal-k64f/pull/7  "Fix bug in union access macros"
https://github.com/ARMmbed/mbed-hal-k64f/pull/8  "Simpler and more universal macros for memory access"
https://github.com/ARMmbed/mbed-hal-k64f/pull/9  "Fixed bug in fallback macros for memory access"
https://github.com/ARMmbed/mbed-hal-k64f/pull/10 "Added volatile keyword to address for union read"
https://github.com/ARMmbed/mbed-hal-k64f/pull/14 "Removing copyright and revision from unmodified file"
2016-04-06 23:25:27 +01:00
Alessandro Angelino 3fcaed1eb0 Add uVisor to startup code 2016-04-06 23:25:27 +01:00
Alessandro Angelino e32f969459 Add uninitialized section to linker script 2016-04-06 23:25:27 +01:00
Alessandro Angelino ec980179bc Add uVisor-specific sections to linker script 2016-04-06 23:25:27 +01:00
Alessandro Angelino 7818102156 Round the SRAM offset in linker script 2016-04-06 23:25:27 +01:00
Alessandro Angelino 057bc9a98a Replace NVIC APIs with vIRQ ones 2016-04-06 23:25:27 +01:00
Alessandro Angelino 3ad0f0a430 Fix function to get sp when in unprivileged mode 2016-04-06 23:11:46 +01:00
Christopher Haster f396e3165f Added improved FuncPtr type
FuncPtr provides a more flexible templated function class as a
replacement for FunctionPointer.

FuncPtr provides an intuitive template interface:

void doit(int, char *);
FuncPtr<void(int, char *)> doit_ptr(doit);
doit_ptr(10, "hi!");

FuncPtr places memory management on the user, only supporting
storing an extra pointer for pointers to externally stored objects
that can be passed to the function. Additional binding can be
supplied by an external class.

FuncPtr<void(int)> hello(&object, &Object::method);

Additionally FuncPtr provides a copy constructor, allowing FuncPtrs
themselves to be passed to existing interfaces.

FuncPtr<void()> hello(doit); ticker.attach(hello, 1000);
2016-04-06 08:01:28 -05:00
Bogdan Marinescu 3feff63592 Preparing new layout - moved hal+mbed-drivers to ./hal 2016-04-05 16:26:29 +01:00